]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.9.2-201305132026.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.9.2-201305132026.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 3e71511..8ff502e 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 7eb18c1..e38b6d2 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/smp.h b/arch/arm/include/asm/smp.h
2032 index d3a22be..3a69ad5 100644
2033 --- a/arch/arm/include/asm/smp.h
2034 +++ b/arch/arm/include/asm/smp.h
2035 @@ -107,7 +107,7 @@ struct smp_operations {
2036 int (*cpu_disable)(unsigned int cpu);
2037 #endif
2038 #endif
2039 -};
2040 +} __no_const;
2041
2042 /*
2043 * set platform specific SMP operations
2044 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2045 index cddda1f..ff357f7 100644
2046 --- a/arch/arm/include/asm/thread_info.h
2047 +++ b/arch/arm/include/asm/thread_info.h
2048 @@ -77,9 +77,9 @@ struct thread_info {
2049 .flags = 0, \
2050 .preempt_count = INIT_PREEMPT_COUNT, \
2051 .addr_limit = KERNEL_DS, \
2052 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2053 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2054 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2055 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2056 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2057 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2058 .restart_block = { \
2059 .fn = do_no_restart_syscall, \
2060 }, \
2061 @@ -152,6 +152,12 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2062 #define TIF_SYSCALL_AUDIT 9
2063 #define TIF_SYSCALL_TRACEPOINT 10
2064 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2065 +
2066 +/* within 8 bits of TIF_SYSCALL_TRACE
2067 + * to meet flexible second operand requirements
2068 + */
2069 +#define TIF_GRSEC_SETXID 12
2070 +
2071 #define TIF_USING_IWMMXT 17
2072 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2073 #define TIF_RESTORE_SIGMASK 20
2074 @@ -165,10 +171,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2075 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2076 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2077 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2078 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2079
2080 /* Checks for any syscall work in entry-common.S */
2081 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2082 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2083 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2084
2085 /*
2086 * Change these and you break ASM code in entry-common.S
2087 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2088 index 7e1f760..752fcb7 100644
2089 --- a/arch/arm/include/asm/uaccess.h
2090 +++ b/arch/arm/include/asm/uaccess.h
2091 @@ -18,6 +18,7 @@
2092 #include <asm/domain.h>
2093 #include <asm/unified.h>
2094 #include <asm/compiler.h>
2095 +#include <asm/pgtable.h>
2096
2097 #define VERIFY_READ 0
2098 #define VERIFY_WRITE 1
2099 @@ -60,10 +61,34 @@ extern int __put_user_bad(void);
2100 #define USER_DS TASK_SIZE
2101 #define get_fs() (current_thread_info()->addr_limit)
2102
2103 +static inline void pax_open_userland(void)
2104 +{
2105 +
2106 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2107 + if (get_fs() == USER_DS) {
2108 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2109 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2110 + }
2111 +#endif
2112 +
2113 +}
2114 +
2115 +static inline void pax_close_userland(void)
2116 +{
2117 +
2118 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2119 + if (get_fs() == USER_DS) {
2120 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2121 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2122 + }
2123 +#endif
2124 +
2125 +}
2126 +
2127 static inline void set_fs(mm_segment_t fs)
2128 {
2129 current_thread_info()->addr_limit = fs;
2130 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2131 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2132 }
2133
2134 #define segment_eq(a,b) ((a) == (b))
2135 @@ -143,8 +168,12 @@ extern int __get_user_4(void *);
2136
2137 #define get_user(x,p) \
2138 ({ \
2139 + int __e; \
2140 might_fault(); \
2141 - __get_user_check(x,p); \
2142 + pax_open_userland(); \
2143 + __e = __get_user_check(x,p); \
2144 + pax_close_userland(); \
2145 + __e; \
2146 })
2147
2148 extern int __put_user_1(void *, unsigned int);
2149 @@ -188,8 +217,12 @@ extern int __put_user_8(void *, unsigned long long);
2150
2151 #define put_user(x,p) \
2152 ({ \
2153 + int __e; \
2154 might_fault(); \
2155 - __put_user_check(x,p); \
2156 + pax_open_userland(); \
2157 + __e = __put_user_check(x,p); \
2158 + pax_close_userland(); \
2159 + __e; \
2160 })
2161
2162 #else /* CONFIG_MMU */
2163 @@ -230,13 +263,17 @@ static inline void set_fs(mm_segment_t fs)
2164 #define __get_user(x,ptr) \
2165 ({ \
2166 long __gu_err = 0; \
2167 + pax_open_userland(); \
2168 __get_user_err((x),(ptr),__gu_err); \
2169 + pax_close_userland(); \
2170 __gu_err; \
2171 })
2172
2173 #define __get_user_error(x,ptr,err) \
2174 ({ \
2175 + pax_open_userland(); \
2176 __get_user_err((x),(ptr),err); \
2177 + pax_close_userland(); \
2178 (void) 0; \
2179 })
2180
2181 @@ -312,13 +349,17 @@ do { \
2182 #define __put_user(x,ptr) \
2183 ({ \
2184 long __pu_err = 0; \
2185 + pax_open_userland(); \
2186 __put_user_err((x),(ptr),__pu_err); \
2187 + pax_close_userland(); \
2188 __pu_err; \
2189 })
2190
2191 #define __put_user_error(x,ptr,err) \
2192 ({ \
2193 + pax_open_userland(); \
2194 __put_user_err((x),(ptr),err); \
2195 + pax_close_userland(); \
2196 (void) 0; \
2197 })
2198
2199 @@ -418,11 +459,44 @@ do { \
2200
2201
2202 #ifdef CONFIG_MMU
2203 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2204 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2205 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2206 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2207 +
2208 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2209 +{
2210 + unsigned long ret;
2211 +
2212 + check_object_size(to, n, false);
2213 + pax_open_userland();
2214 + ret = ___copy_from_user(to, from, n);
2215 + pax_close_userland();
2216 + return ret;
2217 +}
2218 +
2219 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2220 +{
2221 + unsigned long ret;
2222 +
2223 + check_object_size(from, n, true);
2224 + pax_open_userland();
2225 + ret = ___copy_to_user(to, from, n);
2226 + pax_close_userland();
2227 + return ret;
2228 +}
2229 +
2230 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2231 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2232 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2233 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2234 +
2235 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2236 +{
2237 + unsigned long ret;
2238 + pax_open_userland();
2239 + ret = ___clear_user(addr, n);
2240 + pax_close_userland();
2241 + return ret;
2242 +}
2243 +
2244 #else
2245 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2246 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2247 @@ -431,6 +505,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2248
2249 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2250 {
2251 + if ((long)n < 0)
2252 + return n;
2253 +
2254 if (access_ok(VERIFY_READ, from, n))
2255 n = __copy_from_user(to, from, n);
2256 else /* security hole - plug it */
2257 @@ -440,6 +517,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2258
2259 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2260 {
2261 + if ((long)n < 0)
2262 + return n;
2263 +
2264 if (access_ok(VERIFY_WRITE, to, n))
2265 n = __copy_to_user(to, from, n);
2266 return n;
2267 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2268 index 96ee092..37f1844 100644
2269 --- a/arch/arm/include/uapi/asm/ptrace.h
2270 +++ b/arch/arm/include/uapi/asm/ptrace.h
2271 @@ -73,7 +73,7 @@
2272 * ARMv7 groups of PSR bits
2273 */
2274 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2275 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2276 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2277 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2278 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2279
2280 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2281 index 60d3b73..d27ee09 100644
2282 --- a/arch/arm/kernel/armksyms.c
2283 +++ b/arch/arm/kernel/armksyms.c
2284 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2285 #ifdef CONFIG_MMU
2286 EXPORT_SYMBOL(copy_page);
2287
2288 -EXPORT_SYMBOL(__copy_from_user);
2289 -EXPORT_SYMBOL(__copy_to_user);
2290 -EXPORT_SYMBOL(__clear_user);
2291 +EXPORT_SYMBOL(___copy_from_user);
2292 +EXPORT_SYMBOL(___copy_to_user);
2293 +EXPORT_SYMBOL(___clear_user);
2294
2295 EXPORT_SYMBOL(__get_user_1);
2296 EXPORT_SYMBOL(__get_user_2);
2297 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2298 index 0f82098..3dbd3ee 100644
2299 --- a/arch/arm/kernel/entry-armv.S
2300 +++ b/arch/arm/kernel/entry-armv.S
2301 @@ -47,6 +47,87 @@
2302 9997:
2303 .endm
2304
2305 + .macro pax_enter_kernel
2306 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2307 + @ make aligned space for saved DACR
2308 + sub sp, sp, #8
2309 + @ save regs
2310 + stmdb sp!, {r1, r2}
2311 + @ read DACR from cpu_domain into r1
2312 + mov r2, sp
2313 + @ assume 8K pages, since we have to split the immediate in two
2314 + bic r2, r2, #(0x1fc0)
2315 + bic r2, r2, #(0x3f)
2316 + ldr r1, [r2, #TI_CPU_DOMAIN]
2317 + @ store old DACR on stack
2318 + str r1, [sp, #8]
2319 +#ifdef CONFIG_PAX_KERNEXEC
2320 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2321 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2322 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2323 +#endif
2324 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2325 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2326 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2327 +#endif
2328 + @ write r1 to current_thread_info()->cpu_domain
2329 + str r1, [r2, #TI_CPU_DOMAIN]
2330 + @ write r1 to DACR
2331 + mcr p15, 0, r1, c3, c0, 0
2332 + @ instruction sync
2333 + instr_sync
2334 + @ restore regs
2335 + ldmia sp!, {r1, r2}
2336 +#endif
2337 + .endm
2338 +
2339 + .macro pax_open_userland
2340 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2341 + @ save regs
2342 + stmdb sp!, {r0, r1}
2343 + @ read DACR from cpu_domain into r1
2344 + mov r0, sp
2345 + @ assume 8K pages, since we have to split the immediate in two
2346 + bic r0, r0, #(0x1fc0)
2347 + bic r0, r0, #(0x3f)
2348 + ldr r1, [r0, #TI_CPU_DOMAIN]
2349 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2350 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2351 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2352 + @ write r1 to current_thread_info()->cpu_domain
2353 + str r1, [r0, #TI_CPU_DOMAIN]
2354 + @ write r1 to DACR
2355 + mcr p15, 0, r1, c3, c0, 0
2356 + @ instruction sync
2357 + instr_sync
2358 + @ restore regs
2359 + ldmia sp!, {r0, r1}
2360 +#endif
2361 + .endm
2362 +
2363 + .macro pax_close_userland
2364 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2365 + @ save regs
2366 + stmdb sp!, {r0, r1}
2367 + @ read DACR from cpu_domain into r1
2368 + mov r0, sp
2369 + @ assume 8K pages, since we have to split the immediate in two
2370 + bic r0, r0, #(0x1fc0)
2371 + bic r0, r0, #(0x3f)
2372 + ldr r1, [r0, #TI_CPU_DOMAIN]
2373 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2374 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2375 + @ write r1 to current_thread_info()->cpu_domain
2376 + str r1, [r0, #TI_CPU_DOMAIN]
2377 + @ write r1 to DACR
2378 + mcr p15, 0, r1, c3, c0, 0
2379 + @ instruction sync
2380 + instr_sync
2381 + @ restore regs
2382 + ldmia sp!, {r0, r1}
2383 +#endif
2384 + .endm
2385 +
2386 .macro pabt_helper
2387 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2388 #ifdef MULTI_PABORT
2389 @@ -89,11 +170,15 @@
2390 * Invalid mode handlers
2391 */
2392 .macro inv_entry, reason
2393 +
2394 + pax_enter_kernel
2395 +
2396 sub sp, sp, #S_FRAME_SIZE
2397 ARM( stmib sp, {r1 - lr} )
2398 THUMB( stmia sp, {r0 - r12} )
2399 THUMB( str sp, [sp, #S_SP] )
2400 THUMB( str lr, [sp, #S_LR] )
2401 +
2402 mov r1, #\reason
2403 .endm
2404
2405 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2406 .macro svc_entry, stack_hole=0
2407 UNWIND(.fnstart )
2408 UNWIND(.save {r0 - pc} )
2409 +
2410 + pax_enter_kernel
2411 +
2412 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2413 +
2414 #ifdef CONFIG_THUMB2_KERNEL
2415 SPFIX( str r0, [sp] ) @ temporarily saved
2416 SPFIX( mov r0, sp )
2417 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2418 ldmia r0, {r3 - r5}
2419 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2420 mov r6, #-1 @ "" "" "" ""
2421 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2422 + @ offset sp by 8 as done in pax_enter_kernel
2423 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2424 +#else
2425 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2426 +#endif
2427 SPFIX( addeq r2, r2, #4 )
2428 str r3, [sp, #-4]! @ save the "real" r0 copied
2429 @ from the exception stack
2430 @@ -359,6 +453,9 @@ ENDPROC(__pabt_svc)
2431 .macro usr_entry
2432 UNWIND(.fnstart )
2433 UNWIND(.cantunwind ) @ don't unwind the user space
2434 +
2435 + pax_enter_kernel_user
2436 +
2437 sub sp, sp, #S_FRAME_SIZE
2438 ARM( stmib sp, {r1 - r12} )
2439 THUMB( stmia sp, {r0 - r12} )
2440 @@ -456,7 +553,9 @@ __und_usr:
2441 tst r3, #PSR_T_BIT @ Thumb mode?
2442 bne __und_usr_thumb
2443 sub r4, r2, #4 @ ARM instr at LR - 4
2444 + pax_open_userland
2445 1: ldrt r0, [r4]
2446 + pax_close_userland
2447 #ifdef CONFIG_CPU_ENDIAN_BE8
2448 rev r0, r0 @ little endian instruction
2449 #endif
2450 @@ -491,10 +590,14 @@ __und_usr_thumb:
2451 */
2452 .arch armv6t2
2453 #endif
2454 + pax_open_userland
2455 2: ldrht r5, [r4]
2456 + pax_close_userland
2457 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2458 blo __und_usr_fault_16 @ 16bit undefined instruction
2459 + pax_open_userland
2460 3: ldrht r0, [r2]
2461 + pax_close_userland
2462 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2463 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2464 orr r0, r0, r5, lsl #16
2465 @@ -733,7 +836,7 @@ ENTRY(__switch_to)
2466 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2467 THUMB( str sp, [ip], #4 )
2468 THUMB( str lr, [ip], #4 )
2469 -#ifdef CONFIG_CPU_USE_DOMAINS
2470 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2471 ldr r6, [r2, #TI_CPU_DOMAIN]
2472 #endif
2473 set_tls r3, r4, r5
2474 @@ -742,7 +845,7 @@ ENTRY(__switch_to)
2475 ldr r8, =__stack_chk_guard
2476 ldr r7, [r7, #TSK_STACK_CANARY]
2477 #endif
2478 -#ifdef CONFIG_CPU_USE_DOMAINS
2479 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2480 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2481 #endif
2482 mov r5, r0
2483 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2484 index fefd7f9..e6f250e 100644
2485 --- a/arch/arm/kernel/entry-common.S
2486 +++ b/arch/arm/kernel/entry-common.S
2487 @@ -10,18 +10,46 @@
2488
2489 #include <asm/unistd.h>
2490 #include <asm/ftrace.h>
2491 +#include <asm/domain.h>
2492 #include <asm/unwind.h>
2493
2494 +#include "entry-header.S"
2495 +
2496 #ifdef CONFIG_NEED_RET_TO_USER
2497 #include <mach/entry-macro.S>
2498 #else
2499 .macro arch_ret_to_user, tmp1, tmp2
2500 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2501 + @ save regs
2502 + stmdb sp!, {r1, r2}
2503 + @ read DACR from cpu_domain into r1
2504 + mov r2, sp
2505 + @ assume 8K pages, since we have to split the immediate in two
2506 + bic r2, r2, #(0x1fc0)
2507 + bic r2, r2, #(0x3f)
2508 + ldr r1, [r2, #TI_CPU_DOMAIN]
2509 +#ifdef CONFIG_PAX_KERNEXEC
2510 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2511 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2512 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2513 +#endif
2514 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2515 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2516 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2517 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2518 +#endif
2519 + @ write r1 to current_thread_info()->cpu_domain
2520 + str r1, [r2, #TI_CPU_DOMAIN]
2521 + @ write r1 to DACR
2522 + mcr p15, 0, r1, c3, c0, 0
2523 + @ instruction sync
2524 + instr_sync
2525 + @ restore regs
2526 + ldmia sp!, {r1, r2}
2527 +#endif
2528 .endm
2529 #endif
2530
2531 -#include "entry-header.S"
2532 -
2533 -
2534 .align 5
2535 /*
2536 * This is the fast syscall return path. We do as little as
2537 @@ -351,6 +379,7 @@ ENDPROC(ftrace_stub)
2538
2539 .align 5
2540 ENTRY(vector_swi)
2541 +
2542 sub sp, sp, #S_FRAME_SIZE
2543 stmia sp, {r0 - r12} @ Calling r0 - r12
2544 ARM( add r8, sp, #S_PC )
2545 @@ -400,6 +429,12 @@ ENTRY(vector_swi)
2546 ldr scno, [lr, #-4] @ get SWI instruction
2547 #endif
2548
2549 + /*
2550 + * do this here to avoid a performance hit of wrapping the code above
2551 + * that directly dereferences userland to parse the SWI instruction
2552 + */
2553 + pax_enter_kernel_user
2554 +
2555 #ifdef CONFIG_ALIGNMENT_TRAP
2556 ldr ip, __cr_alignment
2557 ldr ip, [ip]
2558 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2559 index 9a8531e..812e287 100644
2560 --- a/arch/arm/kernel/entry-header.S
2561 +++ b/arch/arm/kernel/entry-header.S
2562 @@ -73,9 +73,66 @@
2563 msr cpsr_c, \rtemp @ switch back to the SVC mode
2564 .endm
2565
2566 + .macro pax_enter_kernel_user
2567 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2568 + @ save regs
2569 + stmdb sp!, {r0, r1}
2570 + @ read DACR from cpu_domain into r1
2571 + mov r0, sp
2572 + @ assume 8K pages, since we have to split the immediate in two
2573 + bic r0, r0, #(0x1fc0)
2574 + bic r0, r0, #(0x3f)
2575 + ldr r1, [r0, #TI_CPU_DOMAIN]
2576 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2577 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2578 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2579 +#endif
2580 +#ifdef CONFIG_PAX_KERNEXEC
2581 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2582 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2583 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2584 +#endif
2585 + @ write r1 to current_thread_info()->cpu_domain
2586 + str r1, [r0, #TI_CPU_DOMAIN]
2587 + @ write r1 to DACR
2588 + mcr p15, 0, r1, c3, c0, 0
2589 + @ instruction sync
2590 + instr_sync
2591 + @ restore regs
2592 + ldmia sp!, {r0, r1}
2593 +#endif
2594 + .endm
2595 +
2596 + .macro pax_exit_kernel
2597 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2598 + @ save regs
2599 + stmdb sp!, {r0, r1}
2600 + @ read old DACR from stack into r1
2601 + ldr r1, [sp, #(8 + S_SP)]
2602 + sub r1, r1, #8
2603 + ldr r1, [r1]
2604 +
2605 + @ write r1 to current_thread_info()->cpu_domain
2606 + mov r0, sp
2607 + @ assume 8K pages, since we have to split the immediate in two
2608 + bic r0, r0, #(0x1fc0)
2609 + bic r0, r0, #(0x3f)
2610 + str r1, [r0, #TI_CPU_DOMAIN]
2611 + @ write r1 to DACR
2612 + mcr p15, 0, r1, c3, c0, 0
2613 + @ instruction sync
2614 + instr_sync
2615 + @ restore regs
2616 + ldmia sp!, {r0, r1}
2617 +#endif
2618 + .endm
2619 +
2620 #ifndef CONFIG_THUMB2_KERNEL
2621 .macro svc_exit, rpsr
2622 msr spsr_cxsf, \rpsr
2623 +
2624 + pax_exit_kernel
2625 +
2626 #if defined(CONFIG_CPU_V6)
2627 ldr r0, [sp]
2628 strex r1, r2, [sp] @ clear the exclusive monitor
2629 @@ -121,6 +178,9 @@
2630 .endm
2631 #else /* CONFIG_THUMB2_KERNEL */
2632 .macro svc_exit, rpsr
2633 +
2634 + pax_exit_kernel
2635 +
2636 ldr lr, [sp, #S_SP] @ top of the stack
2637 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2638 clrex @ clear the exclusive monitor
2639 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2640 index 2adda11..7fbe958 100644
2641 --- a/arch/arm/kernel/fiq.c
2642 +++ b/arch/arm/kernel/fiq.c
2643 @@ -82,7 +82,9 @@ void set_fiq_handler(void *start, unsigned int length)
2644 #if defined(CONFIG_CPU_USE_DOMAINS)
2645 memcpy((void *)0xffff001c, start, length);
2646 #else
2647 + pax_open_kernel();
2648 memcpy(vectors_page + 0x1c, start, length);
2649 + pax_close_kernel();
2650 #endif
2651 flush_icache_range(0xffff001c, 0xffff001c + length);
2652 if (!vectors_high())
2653 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2654 index 8bac553..caee108 100644
2655 --- a/arch/arm/kernel/head.S
2656 +++ b/arch/arm/kernel/head.S
2657 @@ -52,7 +52,9 @@
2658 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2659
2660 .macro pgtbl, rd, phys
2661 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2662 + mov \rd, #TEXT_OFFSET
2663 + sub \rd, #PG_DIR_SIZE
2664 + add \rd, \rd, \phys
2665 .endm
2666
2667 /*
2668 @@ -434,7 +436,7 @@ __enable_mmu:
2669 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2670 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2671 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2672 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2673 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2674 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2675 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2676 #endif
2677 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2678 index 1fd749e..47adb08 100644
2679 --- a/arch/arm/kernel/hw_breakpoint.c
2680 +++ b/arch/arm/kernel/hw_breakpoint.c
2681 @@ -1029,7 +1029,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2682 return NOTIFY_OK;
2683 }
2684
2685 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2686 +static struct notifier_block dbg_reset_nb = {
2687 .notifier_call = dbg_reset_notify,
2688 };
2689
2690 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2691 index 1e9be5d..03edbc2 100644
2692 --- a/arch/arm/kernel/module.c
2693 +++ b/arch/arm/kernel/module.c
2694 @@ -37,12 +37,37 @@
2695 #endif
2696
2697 #ifdef CONFIG_MMU
2698 -void *module_alloc(unsigned long size)
2699 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2700 {
2701 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2702 + return NULL;
2703 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2704 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2705 + GFP_KERNEL, prot, -1,
2706 __builtin_return_address(0));
2707 }
2708 +
2709 +void *module_alloc(unsigned long size)
2710 +{
2711 +
2712 +#ifdef CONFIG_PAX_KERNEXEC
2713 + return __module_alloc(size, PAGE_KERNEL);
2714 +#else
2715 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2716 +#endif
2717 +
2718 +}
2719 +
2720 +#ifdef CONFIG_PAX_KERNEXEC
2721 +void module_free_exec(struct module *mod, void *module_region)
2722 +{
2723 + module_free(mod, module_region);
2724 +}
2725 +
2726 +void *module_alloc_exec(unsigned long size)
2727 +{
2728 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2729 +}
2730 +#endif
2731 #endif
2732
2733 int
2734 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2735 index 07314af..c46655c 100644
2736 --- a/arch/arm/kernel/patch.c
2737 +++ b/arch/arm/kernel/patch.c
2738 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2739 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2740 int size;
2741
2742 + pax_open_kernel();
2743 if (thumb2 && __opcode_is_thumb16(insn)) {
2744 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2745 size = sizeof(u16);
2746 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2747 *(u32 *)addr = insn;
2748 size = sizeof(u32);
2749 }
2750 + pax_close_kernel();
2751
2752 flush_icache_range((uintptr_t)(addr),
2753 (uintptr_t)(addr) + size);
2754 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2755 index 1f2740e..b36e225 100644
2756 --- a/arch/arm/kernel/perf_event_cpu.c
2757 +++ b/arch/arm/kernel/perf_event_cpu.c
2758 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2759 return NOTIFY_OK;
2760 }
2761
2762 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2763 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2764 .notifier_call = cpu_pmu_notify,
2765 };
2766
2767 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2768 index 047d3e4..7e96107 100644
2769 --- a/arch/arm/kernel/process.c
2770 +++ b/arch/arm/kernel/process.c
2771 @@ -28,7 +28,6 @@
2772 #include <linux/tick.h>
2773 #include <linux/utsname.h>
2774 #include <linux/uaccess.h>
2775 -#include <linux/random.h>
2776 #include <linux/hw_breakpoint.h>
2777 #include <linux/cpuidle.h>
2778 #include <linux/leds.h>
2779 @@ -251,9 +250,10 @@ void machine_power_off(void)
2780 machine_shutdown();
2781 if (pm_power_off)
2782 pm_power_off();
2783 + BUG();
2784 }
2785
2786 -void machine_restart(char *cmd)
2787 +__noreturn void machine_restart(char *cmd)
2788 {
2789 machine_shutdown();
2790
2791 @@ -278,8 +278,8 @@ void __show_regs(struct pt_regs *regs)
2792 init_utsname()->release,
2793 (int)strcspn(init_utsname()->version, " "),
2794 init_utsname()->version);
2795 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2796 - print_symbol("LR is at %s\n", regs->ARM_lr);
2797 + printk("PC is at %pA\n", instruction_pointer(regs));
2798 + printk("LR is at %pA\n", regs->ARM_lr);
2799 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2800 "sp : %08lx ip : %08lx fp : %08lx\n",
2801 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2802 @@ -447,12 +447,6 @@ unsigned long get_wchan(struct task_struct *p)
2803 return 0;
2804 }
2805
2806 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2807 -{
2808 - unsigned long range_end = mm->brk + 0x02000000;
2809 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2810 -}
2811 -
2812 #ifdef CONFIG_MMU
2813 /*
2814 * The vectors page is always readable from user space for the
2815 @@ -465,9 +459,8 @@ static int __init gate_vma_init(void)
2816 {
2817 gate_vma.vm_start = 0xffff0000;
2818 gate_vma.vm_end = 0xffff0000 + PAGE_SIZE;
2819 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2820 - gate_vma.vm_flags = VM_READ | VM_EXEC |
2821 - VM_MAYREAD | VM_MAYEXEC;
2822 + gate_vma.vm_flags = VM_NONE;
2823 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2824 return 0;
2825 }
2826 arch_initcall(gate_vma_init);
2827 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2828 index 03deeff..741ce88 100644
2829 --- a/arch/arm/kernel/ptrace.c
2830 +++ b/arch/arm/kernel/ptrace.c
2831 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2832 return current_thread_info()->syscall;
2833 }
2834
2835 +#ifdef CONFIG_GRKERNSEC_SETXID
2836 +extern void gr_delayed_cred_worker(void);
2837 +#endif
2838 +
2839 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2840 {
2841 current_thread_info()->syscall = scno;
2842
2843 +#ifdef CONFIG_GRKERNSEC_SETXID
2844 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2845 + gr_delayed_cred_worker();
2846 +#endif
2847 +
2848 /* Do the secure computing check first; failures should be fast. */
2849 if (secure_computing(scno) == -1)
2850 return -1;
2851 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2852 index 234e339..81264a1 100644
2853 --- a/arch/arm/kernel/setup.c
2854 +++ b/arch/arm/kernel/setup.c
2855 @@ -96,21 +96,23 @@ EXPORT_SYMBOL(system_serial_high);
2856 unsigned int elf_hwcap __read_mostly;
2857 EXPORT_SYMBOL(elf_hwcap);
2858
2859 +pteval_t __supported_pte_mask __read_only;
2860 +pmdval_t __supported_pmd_mask __read_only;
2861
2862 #ifdef MULTI_CPU
2863 -struct processor processor __read_mostly;
2864 +struct processor processor;
2865 #endif
2866 #ifdef MULTI_TLB
2867 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2868 +struct cpu_tlb_fns cpu_tlb __read_only;
2869 #endif
2870 #ifdef MULTI_USER
2871 -struct cpu_user_fns cpu_user __read_mostly;
2872 +struct cpu_user_fns cpu_user __read_only;
2873 #endif
2874 #ifdef MULTI_CACHE
2875 -struct cpu_cache_fns cpu_cache __read_mostly;
2876 +struct cpu_cache_fns cpu_cache __read_only;
2877 #endif
2878 #ifdef CONFIG_OUTER_CACHE
2879 -struct outer_cache_fns outer_cache __read_mostly;
2880 +struct outer_cache_fns outer_cache __read_only;
2881 EXPORT_SYMBOL(outer_cache);
2882 #endif
2883
2884 @@ -235,9 +237,13 @@ static int __get_cpu_architecture(void)
2885 asm("mrc p15, 0, %0, c0, c1, 4"
2886 : "=r" (mmfr0));
2887 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2888 - (mmfr0 & 0x000000f0) >= 0x00000030)
2889 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2890 cpu_arch = CPU_ARCH_ARMv7;
2891 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2892 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2893 + __supported_pte_mask |= L_PTE_PXN;
2894 + __supported_pmd_mask |= PMD_PXNTABLE;
2895 + }
2896 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2897 (mmfr0 & 0x000000f0) == 0x00000020)
2898 cpu_arch = CPU_ARCH_ARMv6;
2899 else
2900 @@ -478,7 +484,7 @@ static void __init setup_processor(void)
2901 __cpu_architecture = __get_cpu_architecture();
2902
2903 #ifdef MULTI_CPU
2904 - processor = *list->proc;
2905 + memcpy((void *)&processor, list->proc, sizeof processor);
2906 #endif
2907 #ifdef MULTI_TLB
2908 cpu_tlb = *list->tlb;
2909 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
2910 index 296786b..a8d4dd5 100644
2911 --- a/arch/arm/kernel/signal.c
2912 +++ b/arch/arm/kernel/signal.c
2913 @@ -396,22 +396,14 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
2914 __put_user(sigreturn_codes[idx+1], rc+1))
2915 return 1;
2916
2917 - if (cpsr & MODE32_BIT) {
2918 - /*
2919 - * 32-bit code can use the new high-page
2920 - * signal return code support.
2921 - */
2922 - retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
2923 - } else {
2924 - /*
2925 - * Ensure that the instruction cache sees
2926 - * the return code written onto the stack.
2927 - */
2928 - flush_icache_range((unsigned long)rc,
2929 - (unsigned long)(rc + 2));
2930 + /*
2931 + * Ensure that the instruction cache sees
2932 + * the return code written onto the stack.
2933 + */
2934 + flush_icache_range((unsigned long)rc,
2935 + (unsigned long)(rc + 2));
2936
2937 - retcode = ((unsigned long)rc) + thumb;
2938 - }
2939 + retcode = ((unsigned long)rc) + thumb;
2940 }
2941
2942 regs->ARM_r0 = map_sig(ksig->sig);
2943 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
2944 index 1f2cccc..f40c02e 100644
2945 --- a/arch/arm/kernel/smp.c
2946 +++ b/arch/arm/kernel/smp.c
2947 @@ -70,7 +70,7 @@ enum ipi_msg_type {
2948
2949 static DECLARE_COMPLETION(cpu_running);
2950
2951 -static struct smp_operations smp_ops;
2952 +static struct smp_operations smp_ops __read_only;
2953
2954 void __init smp_set_ops(struct smp_operations *ops)
2955 {
2956 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
2957 index 1c08911..264f009 100644
2958 --- a/arch/arm/kernel/traps.c
2959 +++ b/arch/arm/kernel/traps.c
2960 @@ -57,7 +57,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
2961 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
2962 {
2963 #ifdef CONFIG_KALLSYMS
2964 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
2965 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
2966 #else
2967 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
2968 #endif
2969 @@ -266,6 +266,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
2970 static int die_owner = -1;
2971 static unsigned int die_nest_count;
2972
2973 +extern void gr_handle_kernel_exploit(void);
2974 +
2975 static unsigned long oops_begin(void)
2976 {
2977 int cpu;
2978 @@ -308,6 +310,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
2979 panic("Fatal exception in interrupt");
2980 if (panic_on_oops)
2981 panic("Fatal exception");
2982 +
2983 + gr_handle_kernel_exploit();
2984 +
2985 if (signr)
2986 do_exit(signr);
2987 }
2988 @@ -601,7 +606,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
2989 * The user helper at 0xffff0fe0 must be used instead.
2990 * (see entry-armv.S for details)
2991 */
2992 + pax_open_kernel();
2993 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
2994 + pax_close_kernel();
2995 }
2996 return 0;
2997
2998 @@ -841,13 +848,10 @@ void __init early_trap_init(void *vectors_base)
2999 */
3000 kuser_get_tls_init(vectors);
3001
3002 - /*
3003 - * Copy signal return handlers into the vector page, and
3004 - * set sigreturn to be a pointer to these.
3005 - */
3006 - memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
3007 - sigreturn_codes, sizeof(sigreturn_codes));
3008 -
3009 flush_icache_range(vectors, vectors + PAGE_SIZE);
3010 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3011 +
3012 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3013 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3014 +#endif
3015 +
3016 }
3017 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3018 index b571484..4b2fc9b 100644
3019 --- a/arch/arm/kernel/vmlinux.lds.S
3020 +++ b/arch/arm/kernel/vmlinux.lds.S
3021 @@ -8,7 +8,11 @@
3022 #include <asm/thread_info.h>
3023 #include <asm/memory.h>
3024 #include <asm/page.h>
3025 -
3026 +
3027 +#ifdef CONFIG_PAX_KERNEXEC
3028 +#include <asm/pgtable.h>
3029 +#endif
3030 +
3031 #define PROC_INFO \
3032 . = ALIGN(4); \
3033 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3034 @@ -94,6 +98,11 @@ SECTIONS
3035 _text = .;
3036 HEAD_TEXT
3037 }
3038 +
3039 +#ifdef CONFIG_PAX_KERNEXEC
3040 + . = ALIGN(1<<SECTION_SHIFT);
3041 +#endif
3042 +
3043 .text : { /* Real text segment */
3044 _stext = .; /* Text and read-only data */
3045 __exception_text_start = .;
3046 @@ -116,6 +125,8 @@ SECTIONS
3047 ARM_CPU_KEEP(PROC_INFO)
3048 }
3049
3050 + _etext = .; /* End of text section */
3051 +
3052 RO_DATA(PAGE_SIZE)
3053
3054 . = ALIGN(4);
3055 @@ -146,7 +157,9 @@ SECTIONS
3056
3057 NOTES
3058
3059 - _etext = .; /* End of text and rodata section */
3060 +#ifdef CONFIG_PAX_KERNEXEC
3061 + . = ALIGN(1<<SECTION_SHIFT);
3062 +#endif
3063
3064 #ifndef CONFIG_XIP_KERNEL
3065 . = ALIGN(PAGE_SIZE);
3066 @@ -207,6 +220,11 @@ SECTIONS
3067 . = PAGE_OFFSET + TEXT_OFFSET;
3068 #else
3069 __init_end = .;
3070 +
3071 +#ifdef CONFIG_PAX_KERNEXEC
3072 + . = ALIGN(1<<SECTION_SHIFT);
3073 +#endif
3074 +
3075 . = ALIGN(THREAD_SIZE);
3076 __data_loc = .;
3077 #endif
3078 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3079 index 14a0d98..7771a7d 100644
3080 --- a/arch/arm/lib/clear_user.S
3081 +++ b/arch/arm/lib/clear_user.S
3082 @@ -12,14 +12,14 @@
3083
3084 .text
3085
3086 -/* Prototype: int __clear_user(void *addr, size_t sz)
3087 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3088 * Purpose : clear some user memory
3089 * Params : addr - user memory address to clear
3090 * : sz - number of bytes to clear
3091 * Returns : number of bytes NOT cleared
3092 */
3093 ENTRY(__clear_user_std)
3094 -WEAK(__clear_user)
3095 +WEAK(___clear_user)
3096 stmfd sp!, {r1, lr}
3097 mov r2, #0
3098 cmp r1, #4
3099 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3100 USER( strnebt r2, [r0])
3101 mov r0, #0
3102 ldmfd sp!, {r1, pc}
3103 -ENDPROC(__clear_user)
3104 +ENDPROC(___clear_user)
3105 ENDPROC(__clear_user_std)
3106
3107 .pushsection .fixup,"ax"
3108 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3109 index 66a477a..bee61d3 100644
3110 --- a/arch/arm/lib/copy_from_user.S
3111 +++ b/arch/arm/lib/copy_from_user.S
3112 @@ -16,7 +16,7 @@
3113 /*
3114 * Prototype:
3115 *
3116 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3117 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3118 *
3119 * Purpose:
3120 *
3121 @@ -84,11 +84,11 @@
3122
3123 .text
3124
3125 -ENTRY(__copy_from_user)
3126 +ENTRY(___copy_from_user)
3127
3128 #include "copy_template.S"
3129
3130 -ENDPROC(__copy_from_user)
3131 +ENDPROC(___copy_from_user)
3132
3133 .pushsection .fixup,"ax"
3134 .align 0
3135 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3136 index 6ee2f67..d1cce76 100644
3137 --- a/arch/arm/lib/copy_page.S
3138 +++ b/arch/arm/lib/copy_page.S
3139 @@ -10,6 +10,7 @@
3140 * ASM optimised string functions
3141 */
3142 #include <linux/linkage.h>
3143 +#include <linux/const.h>
3144 #include <asm/assembler.h>
3145 #include <asm/asm-offsets.h>
3146 #include <asm/cache.h>
3147 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3148 index d066df6..df28194 100644
3149 --- a/arch/arm/lib/copy_to_user.S
3150 +++ b/arch/arm/lib/copy_to_user.S
3151 @@ -16,7 +16,7 @@
3152 /*
3153 * Prototype:
3154 *
3155 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3156 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3157 *
3158 * Purpose:
3159 *
3160 @@ -88,11 +88,11 @@
3161 .text
3162
3163 ENTRY(__copy_to_user_std)
3164 -WEAK(__copy_to_user)
3165 +WEAK(___copy_to_user)
3166
3167 #include "copy_template.S"
3168
3169 -ENDPROC(__copy_to_user)
3170 +ENDPROC(___copy_to_user)
3171 ENDPROC(__copy_to_user_std)
3172
3173 .pushsection .fixup,"ax"
3174 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3175 index 7d08b43..f7ca7ea 100644
3176 --- a/arch/arm/lib/csumpartialcopyuser.S
3177 +++ b/arch/arm/lib/csumpartialcopyuser.S
3178 @@ -57,8 +57,8 @@
3179 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3180 */
3181
3182 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3183 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3184 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3185 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3186
3187 #include "csumpartialcopygeneric.S"
3188
3189 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3190 index 64dbfa5..84a3fd9 100644
3191 --- a/arch/arm/lib/delay.c
3192 +++ b/arch/arm/lib/delay.c
3193 @@ -28,7 +28,7 @@
3194 /*
3195 * Default to the loop-based delay implementation.
3196 */
3197 -struct arm_delay_ops arm_delay_ops = {
3198 +struct arm_delay_ops arm_delay_ops __read_only = {
3199 .delay = __loop_delay,
3200 .const_udelay = __loop_const_udelay,
3201 .udelay = __loop_udelay,
3202 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3203 index 025f742..8432b08 100644
3204 --- a/arch/arm/lib/uaccess_with_memcpy.c
3205 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3206 @@ -104,7 +104,7 @@ out:
3207 }
3208
3209 unsigned long
3210 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3211 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3212 {
3213 /*
3214 * This test is stubbed out of the main function above to keep
3215 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3216 index 49792a0..f192052 100644
3217 --- a/arch/arm/mach-kirkwood/common.c
3218 +++ b/arch/arm/mach-kirkwood/common.c
3219 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3220 clk_gate_ops.disable(hw);
3221 }
3222
3223 -static struct clk_ops clk_gate_fn_ops;
3224 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3225 +{
3226 + return clk_gate_ops.is_enabled(hw);
3227 +}
3228 +
3229 +static struct clk_ops clk_gate_fn_ops = {
3230 + .enable = clk_gate_fn_enable,
3231 + .disable = clk_gate_fn_disable,
3232 + .is_enabled = clk_gate_fn_is_enabled,
3233 +};
3234
3235 static struct clk __init *clk_register_gate_fn(struct device *dev,
3236 const char *name,
3237 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3238 gate_fn->fn_en = fn_en;
3239 gate_fn->fn_dis = fn_dis;
3240
3241 - /* ops is the gate ops, but with our enable/disable functions */
3242 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3243 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3244 - clk_gate_fn_ops = clk_gate_ops;
3245 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3246 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3247 - }
3248 -
3249 clk = clk_register(dev, &gate_fn->gate.hw);
3250
3251 if (IS_ERR(clk))
3252 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3253 index f6eeb87..cc90868 100644
3254 --- a/arch/arm/mach-omap2/board-n8x0.c
3255 +++ b/arch/arm/mach-omap2/board-n8x0.c
3256 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3257 }
3258 #endif
3259
3260 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3261 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3262 .late_init = n8x0_menelaus_late_init,
3263 };
3264
3265 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3266 index 410e1ba..1d2dd59 100644
3267 --- a/arch/arm/mach-omap2/gpmc.c
3268 +++ b/arch/arm/mach-omap2/gpmc.c
3269 @@ -145,7 +145,6 @@ struct omap3_gpmc_regs {
3270 };
3271
3272 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3273 -static struct irq_chip gpmc_irq_chip;
3274 static unsigned gpmc_irq_start;
3275
3276 static struct resource gpmc_mem_root;
3277 @@ -707,6 +706,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3278
3279 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3280
3281 +static struct irq_chip gpmc_irq_chip = {
3282 + .name = "gpmc",
3283 + .irq_startup = gpmc_irq_noop_ret,
3284 + .irq_enable = gpmc_irq_enable,
3285 + .irq_disable = gpmc_irq_disable,
3286 + .irq_shutdown = gpmc_irq_noop,
3287 + .irq_ack = gpmc_irq_noop,
3288 + .irq_mask = gpmc_irq_noop,
3289 + .irq_unmask = gpmc_irq_noop,
3290 +
3291 +};
3292 +
3293 static int gpmc_setup_irq(void)
3294 {
3295 int i;
3296 @@ -721,15 +732,6 @@ static int gpmc_setup_irq(void)
3297 return gpmc_irq_start;
3298 }
3299
3300 - gpmc_irq_chip.name = "gpmc";
3301 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3302 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3303 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3304 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3305 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3306 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3307 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3308 -
3309 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3310 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3311
3312 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3313 index f8bb3b9..831e7b8 100644
3314 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3315 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3316 @@ -339,7 +339,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3317 return NOTIFY_OK;
3318 }
3319
3320 -static struct notifier_block __refdata irq_hotplug_notifier = {
3321 +static struct notifier_block irq_hotplug_notifier = {
3322 .notifier_call = irq_cpu_hotplug_notify,
3323 };
3324
3325 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3326 index 381be7a..89b9c7e 100644
3327 --- a/arch/arm/mach-omap2/omap_device.c
3328 +++ b/arch/arm/mach-omap2/omap_device.c
3329 @@ -499,7 +499,7 @@ void omap_device_delete(struct omap_device *od)
3330 struct platform_device __init *omap_device_build(const char *pdev_name,
3331 int pdev_id,
3332 struct omap_hwmod *oh,
3333 - void *pdata, int pdata_len)
3334 + const void *pdata, int pdata_len)
3335 {
3336 struct omap_hwmod *ohs[] = { oh };
3337
3338 @@ -527,7 +527,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3339 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3340 int pdev_id,
3341 struct omap_hwmod **ohs,
3342 - int oh_cnt, void *pdata,
3343 + int oh_cnt, const void *pdata,
3344 int pdata_len)
3345 {
3346 int ret = -ENOMEM;
3347 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3348 index 044c31d..2ee0861 100644
3349 --- a/arch/arm/mach-omap2/omap_device.h
3350 +++ b/arch/arm/mach-omap2/omap_device.h
3351 @@ -72,12 +72,12 @@ int omap_device_idle(struct platform_device *pdev);
3352 /* Core code interface */
3353
3354 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3355 - struct omap_hwmod *oh, void *pdata,
3356 + struct omap_hwmod *oh, const void *pdata,
3357 int pdata_len);
3358
3359 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3360 struct omap_hwmod **oh, int oh_cnt,
3361 - void *pdata, int pdata_len);
3362 + const void *pdata, int pdata_len);
3363
3364 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3365 struct omap_hwmod **ohs, int oh_cnt);
3366 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3367 index a202a47..c430564 100644
3368 --- a/arch/arm/mach-omap2/omap_hwmod.c
3369 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3370 @@ -191,10 +191,10 @@ struct omap_hwmod_soc_ops {
3371 int (*init_clkdm)(struct omap_hwmod *oh);
3372 void (*update_context_lost)(struct omap_hwmod *oh);
3373 int (*get_context_lost)(struct omap_hwmod *oh);
3374 -};
3375 +} __no_const;
3376
3377 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3378 -static struct omap_hwmod_soc_ops soc_ops;
3379 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3380
3381 /* omap_hwmod_list contains all registered struct omap_hwmods */
3382 static LIST_HEAD(omap_hwmod_list);
3383 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3384 index d15c7bb..b2d1f0c 100644
3385 --- a/arch/arm/mach-omap2/wd_timer.c
3386 +++ b/arch/arm/mach-omap2/wd_timer.c
3387 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3388 struct omap_hwmod *oh;
3389 char *oh_name = "wd_timer2";
3390 char *dev_name = "omap_wdt";
3391 - struct omap_wd_timer_platform_data pdata;
3392 + static struct omap_wd_timer_platform_data pdata = {
3393 + .read_reset_sources = prm_read_reset_sources
3394 + };
3395
3396 if (!cpu_class_is_omap2() || of_have_populated_dt())
3397 return 0;
3398 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3399 return -EINVAL;
3400 }
3401
3402 - pdata.read_reset_sources = prm_read_reset_sources;
3403 -
3404 pdev = omap_device_build(dev_name, id, oh, &pdata,
3405 sizeof(struct omap_wd_timer_platform_data));
3406 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3407 diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h
3408 index bddce2b..3eb04e2 100644
3409 --- a/arch/arm/mach-ux500/include/mach/setup.h
3410 +++ b/arch/arm/mach-ux500/include/mach/setup.h
3411 @@ -37,13 +37,6 @@ extern void ux500_timer_init(void);
3412 .type = MT_DEVICE, \
3413 }
3414
3415 -#define __MEM_DEV_DESC(x, sz) { \
3416 - .virtual = IO_ADDRESS(x), \
3417 - .pfn = __phys_to_pfn(x), \
3418 - .length = sz, \
3419 - .type = MT_MEMORY, \
3420 -}
3421 -
3422 extern struct smp_operations ux500_smp_ops;
3423 extern void ux500_cpu_die(unsigned int cpu);
3424
3425 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3426 index 4045c49..4e26c79 100644
3427 --- a/arch/arm/mm/Kconfig
3428 +++ b/arch/arm/mm/Kconfig
3429 @@ -425,7 +425,7 @@ config CPU_32v5
3430
3431 config CPU_32v6
3432 bool
3433 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3434 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC
3435 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3436
3437 config CPU_32v6K
3438 @@ -574,6 +574,7 @@ config CPU_CP15_MPU
3439
3440 config CPU_USE_DOMAINS
3441 bool
3442 + depends on !ARM_LPAE && !PAX_KERNEXEC
3443 help
3444 This option enables or disables the use of domain switching
3445 via the set_fs() function.
3446 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3447 index db26e2e..ee44569 100644
3448 --- a/arch/arm/mm/alignment.c
3449 +++ b/arch/arm/mm/alignment.c
3450 @@ -211,10 +211,12 @@ union offset_union {
3451 #define __get16_unaligned_check(ins,val,addr) \
3452 do { \
3453 unsigned int err = 0, v, a = addr; \
3454 + pax_open_userland(); \
3455 __get8_unaligned_check(ins,v,a,err); \
3456 val = v << ((BE) ? 8 : 0); \
3457 __get8_unaligned_check(ins,v,a,err); \
3458 val |= v << ((BE) ? 0 : 8); \
3459 + pax_close_userland(); \
3460 if (err) \
3461 goto fault; \
3462 } while (0)
3463 @@ -228,6 +230,7 @@ union offset_union {
3464 #define __get32_unaligned_check(ins,val,addr) \
3465 do { \
3466 unsigned int err = 0, v, a = addr; \
3467 + pax_open_userland(); \
3468 __get8_unaligned_check(ins,v,a,err); \
3469 val = v << ((BE) ? 24 : 0); \
3470 __get8_unaligned_check(ins,v,a,err); \
3471 @@ -236,6 +239,7 @@ union offset_union {
3472 val |= v << ((BE) ? 8 : 16); \
3473 __get8_unaligned_check(ins,v,a,err); \
3474 val |= v << ((BE) ? 0 : 24); \
3475 + pax_close_userland(); \
3476 if (err) \
3477 goto fault; \
3478 } while (0)
3479 @@ -249,6 +253,7 @@ union offset_union {
3480 #define __put16_unaligned_check(ins,val,addr) \
3481 do { \
3482 unsigned int err = 0, v = val, a = addr; \
3483 + pax_open_userland(); \
3484 __asm__( FIRST_BYTE_16 \
3485 ARM( "1: "ins" %1, [%2], #1\n" ) \
3486 THUMB( "1: "ins" %1, [%2]\n" ) \
3487 @@ -268,6 +273,7 @@ union offset_union {
3488 " .popsection\n" \
3489 : "=r" (err), "=&r" (v), "=&r" (a) \
3490 : "0" (err), "1" (v), "2" (a)); \
3491 + pax_close_userland(); \
3492 if (err) \
3493 goto fault; \
3494 } while (0)
3495 @@ -281,6 +287,7 @@ union offset_union {
3496 #define __put32_unaligned_check(ins,val,addr) \
3497 do { \
3498 unsigned int err = 0, v = val, a = addr; \
3499 + pax_open_userland(); \
3500 __asm__( FIRST_BYTE_32 \
3501 ARM( "1: "ins" %1, [%2], #1\n" ) \
3502 THUMB( "1: "ins" %1, [%2]\n" ) \
3503 @@ -310,6 +317,7 @@ union offset_union {
3504 " .popsection\n" \
3505 : "=r" (err), "=&r" (v), "=&r" (a) \
3506 : "0" (err), "1" (v), "2" (a)); \
3507 + pax_close_userland(); \
3508 if (err) \
3509 goto fault; \
3510 } while (0)
3511 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3512 index 5dbf13f..1a60561 100644
3513 --- a/arch/arm/mm/fault.c
3514 +++ b/arch/arm/mm/fault.c
3515 @@ -25,6 +25,7 @@
3516 #include <asm/system_misc.h>
3517 #include <asm/system_info.h>
3518 #include <asm/tlbflush.h>
3519 +#include <asm/sections.h>
3520
3521 #include "fault.h"
3522
3523 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3524 if (fixup_exception(regs))
3525 return;
3526
3527 +#ifdef CONFIG_PAX_KERNEXEC
3528 + if ((fsr & FSR_WRITE) &&
3529 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3530 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3531 + {
3532 + if (current->signal->curr_ip)
3533 + 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),
3534 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3535 + else
3536 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3537 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3538 + }
3539 +#endif
3540 +
3541 /*
3542 * No handler, we'll have to terminate things with extreme prejudice.
3543 */
3544 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3545 }
3546 #endif
3547
3548 +#ifdef CONFIG_PAX_PAGEEXEC
3549 + if (fsr & FSR_LNX_PF) {
3550 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3551 + do_group_exit(SIGKILL);
3552 + }
3553 +#endif
3554 +
3555 tsk->thread.address = addr;
3556 tsk->thread.error_code = fsr;
3557 tsk->thread.trap_no = 14;
3558 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3559 }
3560 #endif /* CONFIG_MMU */
3561
3562 +#ifdef CONFIG_PAX_PAGEEXEC
3563 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3564 +{
3565 + long i;
3566 +
3567 + printk(KERN_ERR "PAX: bytes at PC: ");
3568 + for (i = 0; i < 20; i++) {
3569 + unsigned char c;
3570 + if (get_user(c, (__force unsigned char __user *)pc+i))
3571 + printk(KERN_CONT "?? ");
3572 + else
3573 + printk(KERN_CONT "%02x ", c);
3574 + }
3575 + printk("\n");
3576 +
3577 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3578 + for (i = -1; i < 20; i++) {
3579 + unsigned long c;
3580 + if (get_user(c, (__force unsigned long __user *)sp+i))
3581 + printk(KERN_CONT "???????? ");
3582 + else
3583 + printk(KERN_CONT "%08lx ", c);
3584 + }
3585 + printk("\n");
3586 +}
3587 +#endif
3588 +
3589 /*
3590 * First Level Translation Fault Handler
3591 *
3592 @@ -543,9 +592,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3593 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3594 struct siginfo info;
3595
3596 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3597 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3598 + if (current->signal->curr_ip)
3599 + 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),
3600 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3601 + else
3602 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3603 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3604 + goto die;
3605 + }
3606 +#endif
3607 +
3608 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3609 return;
3610
3611 +die:
3612 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3613 inf->name, fsr, addr);
3614
3615 @@ -575,9 +637,49 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3616 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3617 struct siginfo info;
3618
3619 + if (user_mode(regs)) {
3620 + if (addr == 0xffff0fe0UL) {
3621 + /*
3622 + * PaX: __kuser_get_tls emulation
3623 + */
3624 + regs->ARM_r0 = current_thread_info()->tp_value;
3625 + regs->ARM_pc = regs->ARM_lr;
3626 + return;
3627 + }
3628 + }
3629 +
3630 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3631 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3632 + if (current->signal->curr_ip)
3633 + 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),
3634 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3635 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3636 + else
3637 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3638 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3639 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3640 + goto die;
3641 + }
3642 +#endif
3643 +
3644 +#ifdef CONFIG_PAX_REFCOUNT
3645 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3646 + unsigned int bkpt;
3647 +
3648 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
3649 + current->thread.error_code = ifsr;
3650 + current->thread.trap_no = 0;
3651 + pax_report_refcount_overflow(regs);
3652 + fixup_exception(regs);
3653 + return;
3654 + }
3655 + }
3656 +#endif
3657 +
3658 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3659 return;
3660
3661 +die:
3662 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3663 inf->name, ifsr, addr);
3664
3665 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3666 index cf08bdf..772656c 100644
3667 --- a/arch/arm/mm/fault.h
3668 +++ b/arch/arm/mm/fault.h
3669 @@ -3,6 +3,7 @@
3670
3671 /*
3672 * Fault status register encodings. We steal bit 31 for our own purposes.
3673 + * Set when the FSR value is from an instruction fault.
3674 */
3675 #define FSR_LNX_PF (1 << 31)
3676 #define FSR_WRITE (1 << 11)
3677 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
3678 }
3679 #endif
3680
3681 +/* valid for LPAE and !LPAE */
3682 +static inline int is_xn_fault(unsigned int fsr)
3683 +{
3684 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
3685 +}
3686 +
3687 +static inline int is_domain_fault(unsigned int fsr)
3688 +{
3689 + return ((fsr_fs(fsr) & 0xD) == 0x9);
3690 +}
3691 +
3692 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
3693 unsigned long search_exception_table(unsigned long addr);
3694
3695 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
3696 index ad722f1..763fdd3 100644
3697 --- a/arch/arm/mm/init.c
3698 +++ b/arch/arm/mm/init.c
3699 @@ -30,6 +30,8 @@
3700 #include <asm/setup.h>
3701 #include <asm/tlb.h>
3702 #include <asm/fixmap.h>
3703 +#include <asm/system_info.h>
3704 +#include <asm/cp15.h>
3705
3706 #include <asm/mach/arch.h>
3707 #include <asm/mach/map.h>
3708 @@ -736,7 +738,46 @@ void free_initmem(void)
3709 {
3710 #ifdef CONFIG_HAVE_TCM
3711 extern char __tcm_start, __tcm_end;
3712 +#endif
3713
3714 +#ifdef CONFIG_PAX_KERNEXEC
3715 + unsigned long addr;
3716 + pgd_t *pgd;
3717 + pud_t *pud;
3718 + pmd_t *pmd;
3719 + int cpu_arch = cpu_architecture();
3720 + unsigned int cr = get_cr();
3721 +
3722 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
3723 + /* make pages tables, etc before .text NX */
3724 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
3725 + pgd = pgd_offset_k(addr);
3726 + pud = pud_offset(pgd, addr);
3727 + pmd = pmd_offset(pud, addr);
3728 + __section_update(pmd, addr, PMD_SECT_XN);
3729 + }
3730 + /* make init NX */
3731 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
3732 + pgd = pgd_offset_k(addr);
3733 + pud = pud_offset(pgd, addr);
3734 + pmd = pmd_offset(pud, addr);
3735 + __section_update(pmd, addr, PMD_SECT_XN);
3736 + }
3737 + /* make kernel code/rodata RX */
3738 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
3739 + pgd = pgd_offset_k(addr);
3740 + pud = pud_offset(pgd, addr);
3741 + pmd = pmd_offset(pud, addr);
3742 +#ifdef CONFIG_ARM_LPAE
3743 + __section_update(pmd, addr, PMD_SECT_RDONLY);
3744 +#else
3745 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
3746 +#endif
3747 + }
3748 + }
3749 +#endif
3750 +
3751 +#ifdef CONFIG_HAVE_TCM
3752 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
3753 totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)),
3754 __phys_to_pfn(__pa(&__tcm_end)),
3755 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
3756 index 04d9006..c547d85 100644
3757 --- a/arch/arm/mm/ioremap.c
3758 +++ b/arch/arm/mm/ioremap.c
3759 @@ -392,9 +392,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
3760 unsigned int mtype;
3761
3762 if (cached)
3763 - mtype = MT_MEMORY;
3764 + mtype = MT_MEMORY_RX;
3765 else
3766 - mtype = MT_MEMORY_NONCACHED;
3767 + mtype = MT_MEMORY_NONCACHED_RX;
3768
3769 return __arm_ioremap_caller(phys_addr, size, mtype,
3770 __builtin_return_address(0));
3771 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
3772 index 10062ce..cd34fb9 100644
3773 --- a/arch/arm/mm/mmap.c
3774 +++ b/arch/arm/mm/mmap.c
3775 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3776 struct vm_area_struct *vma;
3777 int do_align = 0;
3778 int aliasing = cache_is_vipt_aliasing();
3779 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3780 struct vm_unmapped_area_info info;
3781
3782 /*
3783 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3784 if (len > TASK_SIZE)
3785 return -ENOMEM;
3786
3787 +#ifdef CONFIG_PAX_RANDMMAP
3788 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3789 +#endif
3790 +
3791 if (addr) {
3792 if (do_align)
3793 addr = COLOUR_ALIGN(addr, pgoff);
3794 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3795 addr = PAGE_ALIGN(addr);
3796
3797 vma = find_vma(mm, addr);
3798 - if (TASK_SIZE - len >= addr &&
3799 - (!vma || addr + len <= vma->vm_start))
3800 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3801 return addr;
3802 }
3803
3804 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3805 info.high_limit = TASK_SIZE;
3806 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
3807 info.align_offset = pgoff << PAGE_SHIFT;
3808 + info.threadstack_offset = offset;
3809 return vm_unmapped_area(&info);
3810 }
3811
3812 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3813 unsigned long addr = addr0;
3814 int do_align = 0;
3815 int aliasing = cache_is_vipt_aliasing();
3816 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3817 struct vm_unmapped_area_info info;
3818
3819 /*
3820 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3821 return addr;
3822 }
3823
3824 +#ifdef CONFIG_PAX_RANDMMAP
3825 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3826 +#endif
3827 +
3828 /* requesting a specific address */
3829 if (addr) {
3830 if (do_align)
3831 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3832 else
3833 addr = PAGE_ALIGN(addr);
3834 vma = find_vma(mm, addr);
3835 - if (TASK_SIZE - len >= addr &&
3836 - (!vma || addr + len <= vma->vm_start))
3837 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3838 return addr;
3839 }
3840
3841 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3842 info.high_limit = mm->mmap_base;
3843 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
3844 info.align_offset = pgoff << PAGE_SHIFT;
3845 + info.threadstack_offset = offset;
3846 addr = vm_unmapped_area(&info);
3847
3848 /*
3849 @@ -162,6 +172,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3850 VM_BUG_ON(addr != -ENOMEM);
3851 info.flags = 0;
3852 info.low_limit = mm->mmap_base;
3853 +
3854 +#ifdef CONFIG_PAX_RANDMMAP
3855 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3856 + info.low_limit += mm->delta_mmap;
3857 +#endif
3858 +
3859 info.high_limit = TASK_SIZE;
3860 addr = vm_unmapped_area(&info);
3861 }
3862 @@ -173,6 +189,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3863 {
3864 unsigned long random_factor = 0UL;
3865
3866 +#ifdef CONFIG_PAX_RANDMMAP
3867 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3868 +#endif
3869 +
3870 /* 8 bits of randomness in 20 address space bits */
3871 if ((current->flags & PF_RANDOMIZE) &&
3872 !(current->personality & ADDR_NO_RANDOMIZE))
3873 @@ -180,10 +200,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3874
3875 if (mmap_is_legacy()) {
3876 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
3877 +
3878 +#ifdef CONFIG_PAX_RANDMMAP
3879 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3880 + mm->mmap_base += mm->delta_mmap;
3881 +#endif
3882 +
3883 mm->get_unmapped_area = arch_get_unmapped_area;
3884 mm->unmap_area = arch_unmap_area;
3885 } else {
3886 mm->mmap_base = mmap_base(random_factor);
3887 +
3888 +#ifdef CONFIG_PAX_RANDMMAP
3889 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3890 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
3891 +#endif
3892 +
3893 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
3894 mm->unmap_area = arch_unmap_area_topdown;
3895 }
3896 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
3897 index a84ff76..f221c1d 100644
3898 --- a/arch/arm/mm/mmu.c
3899 +++ b/arch/arm/mm/mmu.c
3900 @@ -36,6 +36,22 @@
3901 #include "mm.h"
3902 #include "tcm.h"
3903
3904 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3905 +void modify_domain(unsigned int dom, unsigned int type)
3906 +{
3907 + struct thread_info *thread = current_thread_info();
3908 + unsigned int domain = thread->cpu_domain;
3909 + /*
3910 + * DOMAIN_MANAGER might be defined to some other value,
3911 + * use the arch-defined constant
3912 + */
3913 + domain &= ~domain_val(dom, 3);
3914 + thread->cpu_domain = domain | domain_val(dom, type);
3915 + set_domain(thread->cpu_domain);
3916 +}
3917 +EXPORT_SYMBOL(modify_domain);
3918 +#endif
3919 +
3920 /*
3921 * empty_zero_page is a special page that is used for
3922 * zero-initialized data and COW.
3923 @@ -211,10 +227,18 @@ void adjust_cr(unsigned long mask, unsigned long set)
3924 }
3925 #endif
3926
3927 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
3928 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
3929 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
3930
3931 -static struct mem_type mem_types[] = {
3932 +#ifdef CONFIG_PAX_KERNEXEC
3933 +#define L_PTE_KERNEXEC L_PTE_RDONLY
3934 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
3935 +#else
3936 +#define L_PTE_KERNEXEC L_PTE_DIRTY
3937 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
3938 +#endif
3939 +
3940 +static struct mem_type mem_types[] __read_only = {
3941 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
3942 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
3943 L_PTE_SHARED,
3944 @@ -243,16 +267,16 @@ static struct mem_type mem_types[] = {
3945 [MT_UNCACHED] = {
3946 .prot_pte = PROT_PTE_DEVICE,
3947 .prot_l1 = PMD_TYPE_TABLE,
3948 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
3949 + .prot_sect = PROT_SECT_DEVICE,
3950 .domain = DOMAIN_IO,
3951 },
3952 [MT_CACHECLEAN] = {
3953 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
3954 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
3955 .domain = DOMAIN_KERNEL,
3956 },
3957 #ifndef CONFIG_ARM_LPAE
3958 [MT_MINICLEAN] = {
3959 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
3960 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
3961 .domain = DOMAIN_KERNEL,
3962 },
3963 #endif
3964 @@ -260,36 +284,54 @@ static struct mem_type mem_types[] = {
3965 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
3966 L_PTE_RDONLY,
3967 .prot_l1 = PMD_TYPE_TABLE,
3968 - .domain = DOMAIN_USER,
3969 + .domain = DOMAIN_VECTORS,
3970 },
3971 [MT_HIGH_VECTORS] = {
3972 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
3973 - L_PTE_USER | L_PTE_RDONLY,
3974 + L_PTE_RDONLY,
3975 .prot_l1 = PMD_TYPE_TABLE,
3976 - .domain = DOMAIN_USER,
3977 + .domain = DOMAIN_VECTORS,
3978 },
3979 - [MT_MEMORY] = {
3980 + [MT_MEMORY_RWX] = {
3981 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
3982 .prot_l1 = PMD_TYPE_TABLE,
3983 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
3984 .domain = DOMAIN_KERNEL,
3985 },
3986 + [MT_MEMORY_RW] = {
3987 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
3988 + .prot_l1 = PMD_TYPE_TABLE,
3989 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
3990 + .domain = DOMAIN_KERNEL,
3991 + },
3992 + [MT_MEMORY_RX] = {
3993 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
3994 + .prot_l1 = PMD_TYPE_TABLE,
3995 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
3996 + .domain = DOMAIN_KERNEL,
3997 + },
3998 [MT_ROM] = {
3999 - .prot_sect = PMD_TYPE_SECT,
4000 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4001 .domain = DOMAIN_KERNEL,
4002 },
4003 - [MT_MEMORY_NONCACHED] = {
4004 + [MT_MEMORY_NONCACHED_RW] = {
4005 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4006 L_PTE_MT_BUFFERABLE,
4007 .prot_l1 = PMD_TYPE_TABLE,
4008 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4009 .domain = DOMAIN_KERNEL,
4010 },
4011 + [MT_MEMORY_NONCACHED_RX] = {
4012 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4013 + L_PTE_MT_BUFFERABLE,
4014 + .prot_l1 = PMD_TYPE_TABLE,
4015 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4016 + .domain = DOMAIN_KERNEL,
4017 + },
4018 [MT_MEMORY_DTCM] = {
4019 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4020 - L_PTE_XN,
4021 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4022 .prot_l1 = PMD_TYPE_TABLE,
4023 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4024 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4025 .domain = DOMAIN_KERNEL,
4026 },
4027 [MT_MEMORY_ITCM] = {
4028 @@ -299,10 +341,10 @@ static struct mem_type mem_types[] = {
4029 },
4030 [MT_MEMORY_SO] = {
4031 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4032 - L_PTE_MT_UNCACHED | L_PTE_XN,
4033 + L_PTE_MT_UNCACHED,
4034 .prot_l1 = PMD_TYPE_TABLE,
4035 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4036 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4037 + PMD_SECT_UNCACHED,
4038 .domain = DOMAIN_KERNEL,
4039 },
4040 [MT_MEMORY_DMA_READY] = {
4041 @@ -388,9 +430,35 @@ static void __init build_mem_type_table(void)
4042 * to prevent speculative instruction fetches.
4043 */
4044 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4045 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4046 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4047 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4048 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4049 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4050 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4051 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4052 +
4053 + /* Mark other regions on ARMv6+ as execute-never */
4054 +
4055 +#ifdef CONFIG_PAX_KERNEXEC
4056 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4057 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4058 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4059 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4060 +#ifndef CONFIG_ARM_LPAE
4061 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4062 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4063 +#endif
4064 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4065 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4066 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4067 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4068 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4069 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4070 +#endif
4071 +
4072 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4073 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4074 }
4075 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4076 /*
4077 @@ -451,6 +519,9 @@ static void __init build_mem_type_table(void)
4078 * from SVC mode and no access from userspace.
4079 */
4080 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4081 +#ifdef CONFIG_PAX_KERNEXEC
4082 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4083 +#endif
4084 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4085 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4086 #endif
4087 @@ -468,11 +539,17 @@ static void __init build_mem_type_table(void)
4088 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4089 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4090 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4091 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4092 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4093 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4094 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4095 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4096 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4097 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4098 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4099 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4100 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4101 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4102 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4103 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4104 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4105 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4106 }
4107 }
4108
4109 @@ -483,15 +560,20 @@ static void __init build_mem_type_table(void)
4110 if (cpu_arch >= CPU_ARCH_ARMv6) {
4111 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4112 /* Non-cacheable Normal is XCB = 001 */
4113 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4114 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4115 + PMD_SECT_BUFFERED;
4116 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4117 PMD_SECT_BUFFERED;
4118 } else {
4119 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4120 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4121 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4122 + PMD_SECT_TEX(1);
4123 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4124 PMD_SECT_TEX(1);
4125 }
4126 } else {
4127 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4128 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4129 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4130 }
4131
4132 #ifdef CONFIG_ARM_LPAE
4133 @@ -507,6 +589,8 @@ static void __init build_mem_type_table(void)
4134 vecs_pgprot |= PTE_EXT_AF;
4135 #endif
4136
4137 + user_pgprot |= __supported_pte_mask;
4138 +
4139 for (i = 0; i < 16; i++) {
4140 pteval_t v = pgprot_val(protection_map[i]);
4141 protection_map[i] = __pgprot(v | user_pgprot);
4142 @@ -524,10 +608,15 @@ static void __init build_mem_type_table(void)
4143
4144 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4145 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4146 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4147 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4148 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4149 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4150 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4151 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4152 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4153 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4154 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4155 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4156 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4157 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4158 mem_types[MT_ROM].prot_sect |= cp->pmd;
4159
4160 switch (cp->pmd) {
4161 @@ -1147,18 +1236,15 @@ void __init arm_mm_memblock_reserve(void)
4162 * called function. This means you can't use any function or debugging
4163 * method which may touch any device, otherwise the kernel _will_ crash.
4164 */
4165 +
4166 +static char vectors[PAGE_SIZE] __read_only __aligned(PAGE_SIZE);
4167 +
4168 static void __init devicemaps_init(struct machine_desc *mdesc)
4169 {
4170 struct map_desc map;
4171 unsigned long addr;
4172 - void *vectors;
4173
4174 - /*
4175 - * Allocate the vector page early.
4176 - */
4177 - vectors = early_alloc(PAGE_SIZE);
4178 -
4179 - early_trap_init(vectors);
4180 + early_trap_init(&vectors);
4181
4182 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4183 pmd_clear(pmd_off_k(addr));
4184 @@ -1198,7 +1284,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4185 * location (0xffff0000). If we aren't using high-vectors, also
4186 * create a mapping at the low-vectors virtual address.
4187 */
4188 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4189 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4190 map.virtual = 0xffff0000;
4191 map.length = PAGE_SIZE;
4192 map.type = MT_HIGH_VECTORS;
4193 @@ -1256,8 +1342,39 @@ static void __init map_lowmem(void)
4194 map.pfn = __phys_to_pfn(start);
4195 map.virtual = __phys_to_virt(start);
4196 map.length = end - start;
4197 - map.type = MT_MEMORY;
4198
4199 +#ifdef CONFIG_PAX_KERNEXEC
4200 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4201 + struct map_desc kernel;
4202 + struct map_desc initmap;
4203 +
4204 + /* when freeing initmem we will make this RW */
4205 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4206 + initmap.virtual = (unsigned long)__init_begin;
4207 + initmap.length = _sdata - __init_begin;
4208 + initmap.type = MT_MEMORY_RWX;
4209 + create_mapping(&initmap);
4210 +
4211 + /* when freeing initmem we will make this RX */
4212 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4213 + kernel.virtual = (unsigned long)_stext;
4214 + kernel.length = __init_begin - _stext;
4215 + kernel.type = MT_MEMORY_RWX;
4216 + create_mapping(&kernel);
4217 +
4218 + if (map.virtual < (unsigned long)_stext) {
4219 + map.length = (unsigned long)_stext - map.virtual;
4220 + map.type = MT_MEMORY_RWX;
4221 + create_mapping(&map);
4222 + }
4223 +
4224 + map.pfn = __phys_to_pfn(__pa(_sdata));
4225 + map.virtual = (unsigned long)_sdata;
4226 + map.length = end - __pa(_sdata);
4227 + }
4228 +#endif
4229 +
4230 + map.type = MT_MEMORY_RW;
4231 create_mapping(&map);
4232 }
4233 }
4234 diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
4235 index 78f520b..31f0cb6 100644
4236 --- a/arch/arm/mm/proc-v7-2level.S
4237 +++ b/arch/arm/mm/proc-v7-2level.S
4238 @@ -99,6 +99,9 @@ ENTRY(cpu_v7_set_pte_ext)
4239 tst r1, #L_PTE_XN
4240 orrne r3, r3, #PTE_EXT_XN
4241
4242 + tst r1, #L_PTE_PXN
4243 + orrne r3, r3, #PTE_EXT_PXN
4244 +
4245 tst r1, #L_PTE_YOUNG
4246 tstne r1, #L_PTE_VALID
4247 #ifndef CONFIG_CPU_USE_DOMAINS
4248 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4249 index a5bc92d..0bb4730 100644
4250 --- a/arch/arm/plat-omap/sram.c
4251 +++ b/arch/arm/plat-omap/sram.c
4252 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4253 * Looks like we need to preserve some bootloader code at the
4254 * beginning of SRAM for jumping to flash for reboot to work...
4255 */
4256 + pax_open_kernel();
4257 memset_io(omap_sram_base + omap_sram_skip, 0,
4258 omap_sram_size - omap_sram_skip);
4259 + pax_close_kernel();
4260 }
4261 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4262 index 1141782..0959d64 100644
4263 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4264 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4265 @@ -48,7 +48,7 @@ struct samsung_dma_ops {
4266 int (*started)(unsigned ch);
4267 int (*flush)(unsigned ch);
4268 int (*stop)(unsigned ch);
4269 -};
4270 +} __no_const;
4271
4272 extern void *samsung_dmadev_get_ops(void);
4273 extern void *s3c_dma_get_ops(void);
4274 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4275 index 0c3ba9f..95722b3 100644
4276 --- a/arch/arm64/kernel/debug-monitors.c
4277 +++ b/arch/arm64/kernel/debug-monitors.c
4278 @@ -151,7 +151,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4279 return NOTIFY_OK;
4280 }
4281
4282 -static struct notifier_block __cpuinitdata os_lock_nb = {
4283 +static struct notifier_block os_lock_nb = {
4284 .notifier_call = os_lock_notify,
4285 };
4286
4287 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4288 index 5ab825c..96aaec8 100644
4289 --- a/arch/arm64/kernel/hw_breakpoint.c
4290 +++ b/arch/arm64/kernel/hw_breakpoint.c
4291 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4292 return NOTIFY_OK;
4293 }
4294
4295 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4296 +static struct notifier_block hw_breakpoint_reset_nb = {
4297 .notifier_call = hw_breakpoint_reset_notify,
4298 };
4299
4300 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4301 index c3a58a1..78fbf54 100644
4302 --- a/arch/avr32/include/asm/cache.h
4303 +++ b/arch/avr32/include/asm/cache.h
4304 @@ -1,8 +1,10 @@
4305 #ifndef __ASM_AVR32_CACHE_H
4306 #define __ASM_AVR32_CACHE_H
4307
4308 +#include <linux/const.h>
4309 +
4310 #define L1_CACHE_SHIFT 5
4311 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4312 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4313
4314 /*
4315 * Memory returned by kmalloc() may be used for DMA, so we must make
4316 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4317 index d232888..87c8df1 100644
4318 --- a/arch/avr32/include/asm/elf.h
4319 +++ b/arch/avr32/include/asm/elf.h
4320 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4321 the loader. We need to make sure that it is out of the way of the program
4322 that it will "exec", and that there is sufficient room for the brk. */
4323
4324 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4325 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4326
4327 +#ifdef CONFIG_PAX_ASLR
4328 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4329 +
4330 +#define PAX_DELTA_MMAP_LEN 15
4331 +#define PAX_DELTA_STACK_LEN 15
4332 +#endif
4333
4334 /* This yields a mask that user programs can use to figure out what
4335 instruction set this CPU supports. This could be done in user space,
4336 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4337 index 479330b..53717a8 100644
4338 --- a/arch/avr32/include/asm/kmap_types.h
4339 +++ b/arch/avr32/include/asm/kmap_types.h
4340 @@ -2,9 +2,9 @@
4341 #define __ASM_AVR32_KMAP_TYPES_H
4342
4343 #ifdef CONFIG_DEBUG_HIGHMEM
4344 -# define KM_TYPE_NR 29
4345 +# define KM_TYPE_NR 30
4346 #else
4347 -# define KM_TYPE_NR 14
4348 +# define KM_TYPE_NR 15
4349 #endif
4350
4351 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4352 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4353 index b2f2d2d..d1c85cb 100644
4354 --- a/arch/avr32/mm/fault.c
4355 +++ b/arch/avr32/mm/fault.c
4356 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4357
4358 int exception_trace = 1;
4359
4360 +#ifdef CONFIG_PAX_PAGEEXEC
4361 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4362 +{
4363 + unsigned long i;
4364 +
4365 + printk(KERN_ERR "PAX: bytes at PC: ");
4366 + for (i = 0; i < 20; i++) {
4367 + unsigned char c;
4368 + if (get_user(c, (unsigned char *)pc+i))
4369 + printk(KERN_CONT "???????? ");
4370 + else
4371 + printk(KERN_CONT "%02x ", c);
4372 + }
4373 + printk("\n");
4374 +}
4375 +#endif
4376 +
4377 /*
4378 * This routine handles page faults. It determines the address and the
4379 * problem, and then passes it off to one of the appropriate routines.
4380 @@ -174,6 +191,16 @@ bad_area:
4381 up_read(&mm->mmap_sem);
4382
4383 if (user_mode(regs)) {
4384 +
4385 +#ifdef CONFIG_PAX_PAGEEXEC
4386 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4387 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4388 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4389 + do_group_exit(SIGKILL);
4390 + }
4391 + }
4392 +#endif
4393 +
4394 if (exception_trace && printk_ratelimit())
4395 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4396 "sp %08lx ecr %lu\n",
4397 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4398 index 568885a..f8008df 100644
4399 --- a/arch/blackfin/include/asm/cache.h
4400 +++ b/arch/blackfin/include/asm/cache.h
4401 @@ -7,6 +7,7 @@
4402 #ifndef __ARCH_BLACKFIN_CACHE_H
4403 #define __ARCH_BLACKFIN_CACHE_H
4404
4405 +#include <linux/const.h>
4406 #include <linux/linkage.h> /* for asmlinkage */
4407
4408 /*
4409 @@ -14,7 +15,7 @@
4410 * Blackfin loads 32 bytes for cache
4411 */
4412 #define L1_CACHE_SHIFT 5
4413 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4414 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4415 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4416
4417 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4418 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4419 index aea2718..3639a60 100644
4420 --- a/arch/cris/include/arch-v10/arch/cache.h
4421 +++ b/arch/cris/include/arch-v10/arch/cache.h
4422 @@ -1,8 +1,9 @@
4423 #ifndef _ASM_ARCH_CACHE_H
4424 #define _ASM_ARCH_CACHE_H
4425
4426 +#include <linux/const.h>
4427 /* Etrax 100LX have 32-byte cache-lines. */
4428 -#define L1_CACHE_BYTES 32
4429 #define L1_CACHE_SHIFT 5
4430 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4431
4432 #endif /* _ASM_ARCH_CACHE_H */
4433 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4434 index 7caf25d..ee65ac5 100644
4435 --- a/arch/cris/include/arch-v32/arch/cache.h
4436 +++ b/arch/cris/include/arch-v32/arch/cache.h
4437 @@ -1,11 +1,12 @@
4438 #ifndef _ASM_CRIS_ARCH_CACHE_H
4439 #define _ASM_CRIS_ARCH_CACHE_H
4440
4441 +#include <linux/const.h>
4442 #include <arch/hwregs/dma.h>
4443
4444 /* A cache-line is 32 bytes. */
4445 -#define L1_CACHE_BYTES 32
4446 #define L1_CACHE_SHIFT 5
4447 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4448
4449 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4450
4451 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4452 index b86329d..6709906 100644
4453 --- a/arch/frv/include/asm/atomic.h
4454 +++ b/arch/frv/include/asm/atomic.h
4455 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4456 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4457 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4458
4459 +#define atomic64_read_unchecked(v) atomic64_read(v)
4460 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4461 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4462 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4463 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4464 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4465 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4466 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4467 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4468 +
4469 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4470 {
4471 int c, old;
4472 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4473 index 2797163..c2a401d 100644
4474 --- a/arch/frv/include/asm/cache.h
4475 +++ b/arch/frv/include/asm/cache.h
4476 @@ -12,10 +12,11 @@
4477 #ifndef __ASM_CACHE_H
4478 #define __ASM_CACHE_H
4479
4480 +#include <linux/const.h>
4481
4482 /* bytes per L1 cache line */
4483 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4484 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4485 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4486
4487 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4488 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4489 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4490 index 43901f2..0d8b865 100644
4491 --- a/arch/frv/include/asm/kmap_types.h
4492 +++ b/arch/frv/include/asm/kmap_types.h
4493 @@ -2,6 +2,6 @@
4494 #ifndef _ASM_KMAP_TYPES_H
4495 #define _ASM_KMAP_TYPES_H
4496
4497 -#define KM_TYPE_NR 17
4498 +#define KM_TYPE_NR 18
4499
4500 #endif
4501 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4502 index 836f147..4cf23f5 100644
4503 --- a/arch/frv/mm/elf-fdpic.c
4504 +++ b/arch/frv/mm/elf-fdpic.c
4505 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4506 {
4507 struct vm_area_struct *vma;
4508 struct vm_unmapped_area_info info;
4509 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4510
4511 if (len > TASK_SIZE)
4512 return -ENOMEM;
4513 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4514 if (addr) {
4515 addr = PAGE_ALIGN(addr);
4516 vma = find_vma(current->mm, addr);
4517 - if (TASK_SIZE - len >= addr &&
4518 - (!vma || addr + len <= vma->vm_start))
4519 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4520 goto success;
4521 }
4522
4523 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4524 info.high_limit = (current->mm->start_stack - 0x00200000);
4525 info.align_mask = 0;
4526 info.align_offset = 0;
4527 + info.threadstack_offset = offset;
4528 addr = vm_unmapped_area(&info);
4529 if (!(addr & ~PAGE_MASK))
4530 goto success;
4531 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4532 index f4ca594..adc72fd6 100644
4533 --- a/arch/hexagon/include/asm/cache.h
4534 +++ b/arch/hexagon/include/asm/cache.h
4535 @@ -21,9 +21,11 @@
4536 #ifndef __ASM_CACHE_H
4537 #define __ASM_CACHE_H
4538
4539 +#include <linux/const.h>
4540 +
4541 /* Bytes per L1 cache line */
4542 -#define L1_CACHE_SHIFT (5)
4543 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4544 +#define L1_CACHE_SHIFT 5
4545 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4546
4547 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4548 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4549 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4550 index 6e6fe18..a6ae668 100644
4551 --- a/arch/ia64/include/asm/atomic.h
4552 +++ b/arch/ia64/include/asm/atomic.h
4553 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4554 #define atomic64_inc(v) atomic64_add(1, (v))
4555 #define atomic64_dec(v) atomic64_sub(1, (v))
4556
4557 +#define atomic64_read_unchecked(v) atomic64_read(v)
4558 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4559 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4560 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4561 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4562 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4563 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4564 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4565 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4566 +
4567 /* Atomic operations are already serializing */
4568 #define smp_mb__before_atomic_dec() barrier()
4569 #define smp_mb__after_atomic_dec() barrier()
4570 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4571 index 988254a..e1ee885 100644
4572 --- a/arch/ia64/include/asm/cache.h
4573 +++ b/arch/ia64/include/asm/cache.h
4574 @@ -1,6 +1,7 @@
4575 #ifndef _ASM_IA64_CACHE_H
4576 #define _ASM_IA64_CACHE_H
4577
4578 +#include <linux/const.h>
4579
4580 /*
4581 * Copyright (C) 1998-2000 Hewlett-Packard Co
4582 @@ -9,7 +10,7 @@
4583
4584 /* Bytes per L1 (data) cache line. */
4585 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4586 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4587 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4588
4589 #ifdef CONFIG_SMP
4590 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4591 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4592 index 5a83c5c..4d7f553 100644
4593 --- a/arch/ia64/include/asm/elf.h
4594 +++ b/arch/ia64/include/asm/elf.h
4595 @@ -42,6 +42,13 @@
4596 */
4597 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4598
4599 +#ifdef CONFIG_PAX_ASLR
4600 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4601 +
4602 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4603 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4604 +#endif
4605 +
4606 #define PT_IA_64_UNWIND 0x70000001
4607
4608 /* IA-64 relocations: */
4609 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4610 index 96a8d92..617a1cf 100644
4611 --- a/arch/ia64/include/asm/pgalloc.h
4612 +++ b/arch/ia64/include/asm/pgalloc.h
4613 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4614 pgd_val(*pgd_entry) = __pa(pud);
4615 }
4616
4617 +static inline void
4618 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4619 +{
4620 + pgd_populate(mm, pgd_entry, pud);
4621 +}
4622 +
4623 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4624 {
4625 return quicklist_alloc(0, GFP_KERNEL, NULL);
4626 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4627 pud_val(*pud_entry) = __pa(pmd);
4628 }
4629
4630 +static inline void
4631 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4632 +{
4633 + pud_populate(mm, pud_entry, pmd);
4634 +}
4635 +
4636 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4637 {
4638 return quicklist_alloc(0, GFP_KERNEL, NULL);
4639 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4640 index 815810c..d60bd4c 100644
4641 --- a/arch/ia64/include/asm/pgtable.h
4642 +++ b/arch/ia64/include/asm/pgtable.h
4643 @@ -12,7 +12,7 @@
4644 * David Mosberger-Tang <davidm@hpl.hp.com>
4645 */
4646
4647 -
4648 +#include <linux/const.h>
4649 #include <asm/mman.h>
4650 #include <asm/page.h>
4651 #include <asm/processor.h>
4652 @@ -142,6 +142,17 @@
4653 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4654 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4655 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4656 +
4657 +#ifdef CONFIG_PAX_PAGEEXEC
4658 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4659 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4660 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4661 +#else
4662 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4663 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4664 +# define PAGE_COPY_NOEXEC PAGE_COPY
4665 +#endif
4666 +
4667 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4668 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4669 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4670 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4671 index 54ff557..70c88b7 100644
4672 --- a/arch/ia64/include/asm/spinlock.h
4673 +++ b/arch/ia64/include/asm/spinlock.h
4674 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4675 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4676
4677 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4678 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4679 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4680 }
4681
4682 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4683 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4684 index 449c8c0..18965fb 100644
4685 --- a/arch/ia64/include/asm/uaccess.h
4686 +++ b/arch/ia64/include/asm/uaccess.h
4687 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4688 static inline unsigned long
4689 __copy_to_user (void __user *to, const void *from, unsigned long count)
4690 {
4691 + if (count > INT_MAX)
4692 + return count;
4693 +
4694 + if (!__builtin_constant_p(count))
4695 + check_object_size(from, count, true);
4696 +
4697 return __copy_user(to, (__force void __user *) from, count);
4698 }
4699
4700 static inline unsigned long
4701 __copy_from_user (void *to, const void __user *from, unsigned long count)
4702 {
4703 + if (count > INT_MAX)
4704 + return count;
4705 +
4706 + if (!__builtin_constant_p(count))
4707 + check_object_size(to, count, false);
4708 +
4709 return __copy_user((__force void __user *) to, from, count);
4710 }
4711
4712 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4713 ({ \
4714 void __user *__cu_to = (to); \
4715 const void *__cu_from = (from); \
4716 - long __cu_len = (n); \
4717 + unsigned long __cu_len = (n); \
4718 \
4719 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4720 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4721 + if (!__builtin_constant_p(n)) \
4722 + check_object_size(__cu_from, __cu_len, true); \
4723 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
4724 + } \
4725 __cu_len; \
4726 })
4727
4728 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4729 ({ \
4730 void *__cu_to = (to); \
4731 const void __user *__cu_from = (from); \
4732 - long __cu_len = (n); \
4733 + unsigned long __cu_len = (n); \
4734 \
4735 __chk_user_ptr(__cu_from); \
4736 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
4737 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
4738 + if (!__builtin_constant_p(n)) \
4739 + check_object_size(__cu_to, __cu_len, false); \
4740 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
4741 + } \
4742 __cu_len; \
4743 })
4744
4745 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
4746 index 2d67317..07d8bfa 100644
4747 --- a/arch/ia64/kernel/err_inject.c
4748 +++ b/arch/ia64/kernel/err_inject.c
4749 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
4750 return NOTIFY_OK;
4751 }
4752
4753 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
4754 +static struct notifier_block err_inject_cpu_notifier =
4755 {
4756 .notifier_call = err_inject_cpu_callback,
4757 };
4758 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
4759 index d7396db..b33e873 100644
4760 --- a/arch/ia64/kernel/mca.c
4761 +++ b/arch/ia64/kernel/mca.c
4762 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
4763 return NOTIFY_OK;
4764 }
4765
4766 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
4767 +static struct notifier_block mca_cpu_notifier = {
4768 .notifier_call = mca_cpu_callback
4769 };
4770
4771 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
4772 index 24603be..948052d 100644
4773 --- a/arch/ia64/kernel/module.c
4774 +++ b/arch/ia64/kernel/module.c
4775 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
4776 void
4777 module_free (struct module *mod, void *module_region)
4778 {
4779 - if (mod && mod->arch.init_unw_table &&
4780 - module_region == mod->module_init) {
4781 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
4782 unw_remove_unwind_table(mod->arch.init_unw_table);
4783 mod->arch.init_unw_table = NULL;
4784 }
4785 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
4786 }
4787
4788 static inline int
4789 +in_init_rx (const struct module *mod, uint64_t addr)
4790 +{
4791 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
4792 +}
4793 +
4794 +static inline int
4795 +in_init_rw (const struct module *mod, uint64_t addr)
4796 +{
4797 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
4798 +}
4799 +
4800 +static inline int
4801 in_init (const struct module *mod, uint64_t addr)
4802 {
4803 - return addr - (uint64_t) mod->module_init < mod->init_size;
4804 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
4805 +}
4806 +
4807 +static inline int
4808 +in_core_rx (const struct module *mod, uint64_t addr)
4809 +{
4810 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
4811 +}
4812 +
4813 +static inline int
4814 +in_core_rw (const struct module *mod, uint64_t addr)
4815 +{
4816 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
4817 }
4818
4819 static inline int
4820 in_core (const struct module *mod, uint64_t addr)
4821 {
4822 - return addr - (uint64_t) mod->module_core < mod->core_size;
4823 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
4824 }
4825
4826 static inline int
4827 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
4828 break;
4829
4830 case RV_BDREL:
4831 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
4832 + if (in_init_rx(mod, val))
4833 + val -= (uint64_t) mod->module_init_rx;
4834 + else if (in_init_rw(mod, val))
4835 + val -= (uint64_t) mod->module_init_rw;
4836 + else if (in_core_rx(mod, val))
4837 + val -= (uint64_t) mod->module_core_rx;
4838 + else if (in_core_rw(mod, val))
4839 + val -= (uint64_t) mod->module_core_rw;
4840 break;
4841
4842 case RV_LTV:
4843 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
4844 * addresses have been selected...
4845 */
4846 uint64_t gp;
4847 - if (mod->core_size > MAX_LTOFF)
4848 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
4849 /*
4850 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
4851 * at the end of the module.
4852 */
4853 - gp = mod->core_size - MAX_LTOFF / 2;
4854 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
4855 else
4856 - gp = mod->core_size / 2;
4857 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
4858 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
4859 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
4860 mod->arch.gp = gp;
4861 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
4862 }
4863 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
4864 index 79521d5..43dddff 100644
4865 --- a/arch/ia64/kernel/palinfo.c
4866 +++ b/arch/ia64/kernel/palinfo.c
4867 @@ -1006,7 +1006,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
4868 return NOTIFY_OK;
4869 }
4870
4871 -static struct notifier_block __refdata palinfo_cpu_notifier =
4872 +static struct notifier_block palinfo_cpu_notifier =
4873 {
4874 .notifier_call = palinfo_cpu_callback,
4875 .priority = 0,
4876 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
4877 index aa527d7..f237752 100644
4878 --- a/arch/ia64/kernel/salinfo.c
4879 +++ b/arch/ia64/kernel/salinfo.c
4880 @@ -616,7 +616,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
4881 return NOTIFY_OK;
4882 }
4883
4884 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
4885 +static struct notifier_block salinfo_cpu_notifier =
4886 {
4887 .notifier_call = salinfo_cpu_callback,
4888 .priority = 0,
4889 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
4890 index 41e33f8..65180b2 100644
4891 --- a/arch/ia64/kernel/sys_ia64.c
4892 +++ b/arch/ia64/kernel/sys_ia64.c
4893 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
4894 unsigned long align_mask = 0;
4895 struct mm_struct *mm = current->mm;
4896 struct vm_unmapped_area_info info;
4897 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4898
4899 if (len > RGN_MAP_LIMIT)
4900 return -ENOMEM;
4901 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
4902 if (REGION_NUMBER(addr) == RGN_HPAGE)
4903 addr = 0;
4904 #endif
4905 +
4906 +#ifdef CONFIG_PAX_RANDMMAP
4907 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4908 + addr = mm->free_area_cache;
4909 + else
4910 +#endif
4911 +
4912 if (!addr)
4913 addr = TASK_UNMAPPED_BASE;
4914
4915 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
4916 info.high_limit = TASK_SIZE;
4917 info.align_mask = align_mask;
4918 info.align_offset = 0;
4919 + info.threadstack_offset = offset;
4920 return vm_unmapped_area(&info);
4921 }
4922
4923 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
4924 index dc00b2c..cce53c2 100644
4925 --- a/arch/ia64/kernel/topology.c
4926 +++ b/arch/ia64/kernel/topology.c
4927 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
4928 return NOTIFY_OK;
4929 }
4930
4931 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
4932 +static struct notifier_block cache_cpu_notifier =
4933 {
4934 .notifier_call = cache_cpu_callback
4935 };
4936 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
4937 index 0ccb28f..8992469 100644
4938 --- a/arch/ia64/kernel/vmlinux.lds.S
4939 +++ b/arch/ia64/kernel/vmlinux.lds.S
4940 @@ -198,7 +198,7 @@ SECTIONS {
4941 /* Per-cpu data: */
4942 . = ALIGN(PERCPU_PAGE_SIZE);
4943 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
4944 - __phys_per_cpu_start = __per_cpu_load;
4945 + __phys_per_cpu_start = per_cpu_load;
4946 /*
4947 * ensure percpu data fits
4948 * into percpu page size
4949 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
4950 index 6cf0341..d352594 100644
4951 --- a/arch/ia64/mm/fault.c
4952 +++ b/arch/ia64/mm/fault.c
4953 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
4954 return pte_present(pte);
4955 }
4956
4957 +#ifdef CONFIG_PAX_PAGEEXEC
4958 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4959 +{
4960 + unsigned long i;
4961 +
4962 + printk(KERN_ERR "PAX: bytes at PC: ");
4963 + for (i = 0; i < 8; i++) {
4964 + unsigned int c;
4965 + if (get_user(c, (unsigned int *)pc+i))
4966 + printk(KERN_CONT "???????? ");
4967 + else
4968 + printk(KERN_CONT "%08x ", c);
4969 + }
4970 + printk("\n");
4971 +}
4972 +#endif
4973 +
4974 # define VM_READ_BIT 0
4975 # define VM_WRITE_BIT 1
4976 # define VM_EXEC_BIT 2
4977 @@ -149,8 +166,21 @@ retry:
4978 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
4979 goto bad_area;
4980
4981 - if ((vma->vm_flags & mask) != mask)
4982 + if ((vma->vm_flags & mask) != mask) {
4983 +
4984 +#ifdef CONFIG_PAX_PAGEEXEC
4985 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
4986 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
4987 + goto bad_area;
4988 +
4989 + up_read(&mm->mmap_sem);
4990 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
4991 + do_group_exit(SIGKILL);
4992 + }
4993 +#endif
4994 +
4995 goto bad_area;
4996 + }
4997
4998 /*
4999 * If for any reason at all we couldn't handle the fault, make
5000 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5001 index 76069c1..c2aa816 100644
5002 --- a/arch/ia64/mm/hugetlbpage.c
5003 +++ b/arch/ia64/mm/hugetlbpage.c
5004 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5005 unsigned long pgoff, unsigned long flags)
5006 {
5007 struct vm_unmapped_area_info info;
5008 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5009
5010 if (len > RGN_MAP_LIMIT)
5011 return -ENOMEM;
5012 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5013 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5014 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5015 info.align_offset = 0;
5016 + info.threadstack_offset = offset;
5017 return vm_unmapped_area(&info);
5018 }
5019
5020 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5021 index 20bc967..a26993e 100644
5022 --- a/arch/ia64/mm/init.c
5023 +++ b/arch/ia64/mm/init.c
5024 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5025 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5026 vma->vm_end = vma->vm_start + PAGE_SIZE;
5027 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5028 +
5029 +#ifdef CONFIG_PAX_PAGEEXEC
5030 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5031 + vma->vm_flags &= ~VM_EXEC;
5032 +
5033 +#ifdef CONFIG_PAX_MPROTECT
5034 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5035 + vma->vm_flags &= ~VM_MAYEXEC;
5036 +#endif
5037 +
5038 + }
5039 +#endif
5040 +
5041 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5042 down_write(&current->mm->mmap_sem);
5043 if (insert_vm_struct(current->mm, vma)) {
5044 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5045 index 40b3ee9..8c2c112 100644
5046 --- a/arch/m32r/include/asm/cache.h
5047 +++ b/arch/m32r/include/asm/cache.h
5048 @@ -1,8 +1,10 @@
5049 #ifndef _ASM_M32R_CACHE_H
5050 #define _ASM_M32R_CACHE_H
5051
5052 +#include <linux/const.h>
5053 +
5054 /* L1 cache line size */
5055 #define L1_CACHE_SHIFT 4
5056 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5057 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5058
5059 #endif /* _ASM_M32R_CACHE_H */
5060 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5061 index 82abd15..d95ae5d 100644
5062 --- a/arch/m32r/lib/usercopy.c
5063 +++ b/arch/m32r/lib/usercopy.c
5064 @@ -14,6 +14,9 @@
5065 unsigned long
5066 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5067 {
5068 + if ((long)n < 0)
5069 + return n;
5070 +
5071 prefetch(from);
5072 if (access_ok(VERIFY_WRITE, to, n))
5073 __copy_user(to,from,n);
5074 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5075 unsigned long
5076 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5077 {
5078 + if ((long)n < 0)
5079 + return n;
5080 +
5081 prefetchw(to);
5082 if (access_ok(VERIFY_READ, from, n))
5083 __copy_user_zeroing(to,from,n);
5084 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5085 index 0395c51..5f26031 100644
5086 --- a/arch/m68k/include/asm/cache.h
5087 +++ b/arch/m68k/include/asm/cache.h
5088 @@ -4,9 +4,11 @@
5089 #ifndef __ARCH_M68K_CACHE_H
5090 #define __ARCH_M68K_CACHE_H
5091
5092 +#include <linux/const.h>
5093 +
5094 /* bytes per L1 cache line */
5095 #define L1_CACHE_SHIFT 4
5096 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5097 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5098
5099 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5100
5101 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5102 index 3c52fa6..11b2ad8 100644
5103 --- a/arch/metag/mm/hugetlbpage.c
5104 +++ b/arch/metag/mm/hugetlbpage.c
5105 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5106 info.high_limit = TASK_SIZE;
5107 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5108 info.align_offset = 0;
5109 + info.threadstack_offset = 0;
5110 return vm_unmapped_area(&info);
5111 }
5112
5113 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5114 index 4efe96a..60e8699 100644
5115 --- a/arch/microblaze/include/asm/cache.h
5116 +++ b/arch/microblaze/include/asm/cache.h
5117 @@ -13,11 +13,12 @@
5118 #ifndef _ASM_MICROBLAZE_CACHE_H
5119 #define _ASM_MICROBLAZE_CACHE_H
5120
5121 +#include <linux/const.h>
5122 #include <asm/registers.h>
5123
5124 #define L1_CACHE_SHIFT 5
5125 /* word-granular cache in microblaze */
5126 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5127 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5128
5129 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5130
5131 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5132 index 08b6079..eb272cf 100644
5133 --- a/arch/mips/include/asm/atomic.h
5134 +++ b/arch/mips/include/asm/atomic.h
5135 @@ -21,6 +21,10 @@
5136 #include <asm/cmpxchg.h>
5137 #include <asm/war.h>
5138
5139 +#ifdef CONFIG_GENERIC_ATOMIC64
5140 +#include <asm-generic/atomic64.h>
5141 +#endif
5142 +
5143 #define ATOMIC_INIT(i) { (i) }
5144
5145 /*
5146 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5147 */
5148 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5149
5150 +#define atomic64_read_unchecked(v) atomic64_read(v)
5151 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5152 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5153 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5154 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5155 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5156 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5157 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5158 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5159 +
5160 #endif /* CONFIG_64BIT */
5161
5162 /*
5163 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5164 index b4db69f..8f3b093 100644
5165 --- a/arch/mips/include/asm/cache.h
5166 +++ b/arch/mips/include/asm/cache.h
5167 @@ -9,10 +9,11 @@
5168 #ifndef _ASM_CACHE_H
5169 #define _ASM_CACHE_H
5170
5171 +#include <linux/const.h>
5172 #include <kmalloc.h>
5173
5174 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5175 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5176 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5177
5178 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5179 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5180 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5181 index cf3ae24..238d22f 100644
5182 --- a/arch/mips/include/asm/elf.h
5183 +++ b/arch/mips/include/asm/elf.h
5184 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5185 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5186 #endif
5187
5188 +#ifdef CONFIG_PAX_ASLR
5189 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5190 +
5191 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5192 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5193 +#endif
5194 +
5195 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5196 struct linux_binprm;
5197 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5198 int uses_interp);
5199
5200 -struct mm_struct;
5201 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5202 -#define arch_randomize_brk arch_randomize_brk
5203 -
5204 #endif /* _ASM_ELF_H */
5205 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5206 index c1f6afa..38cc6e9 100644
5207 --- a/arch/mips/include/asm/exec.h
5208 +++ b/arch/mips/include/asm/exec.h
5209 @@ -12,6 +12,6 @@
5210 #ifndef _ASM_EXEC_H
5211 #define _ASM_EXEC_H
5212
5213 -extern unsigned long arch_align_stack(unsigned long sp);
5214 +#define arch_align_stack(x) ((x) & ~0xfUL)
5215
5216 #endif /* _ASM_EXEC_H */
5217 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5218 index eab99e5..607c98e 100644
5219 --- a/arch/mips/include/asm/page.h
5220 +++ b/arch/mips/include/asm/page.h
5221 @@ -96,7 +96,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5222 #ifdef CONFIG_CPU_MIPS32
5223 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5224 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5225 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5226 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5227 #else
5228 typedef struct { unsigned long long pte; } pte_t;
5229 #define pte_val(x) ((x).pte)
5230 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5231 index 881d18b..cea38bc 100644
5232 --- a/arch/mips/include/asm/pgalloc.h
5233 +++ b/arch/mips/include/asm/pgalloc.h
5234 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5235 {
5236 set_pud(pud, __pud((unsigned long)pmd));
5237 }
5238 +
5239 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5240 +{
5241 + pud_populate(mm, pud, pmd);
5242 +}
5243 #endif
5244
5245 /*
5246 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5247 index 178f792..8ebc510 100644
5248 --- a/arch/mips/include/asm/thread_info.h
5249 +++ b/arch/mips/include/asm/thread_info.h
5250 @@ -111,6 +111,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
5251 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5252 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5253 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5254 +/* li takes a 32bit immediate */
5255 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5256 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5257
5258 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5259 @@ -126,15 +128,18 @@ register struct thread_info *__current_thread_info __asm__("$28");
5260 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5261 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5262 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5263 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5264 +
5265 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5266
5267 /* work to do in syscall_trace_leave() */
5268 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5269 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5270
5271 /* work to do on interrupt/exception return */
5272 #define _TIF_WORK_MASK \
5273 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5274 /* work to do on any return to u-space */
5275 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5276 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5277
5278 #endif /* __KERNEL__ */
5279
5280 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5281 index e06f777..3244284 100644
5282 --- a/arch/mips/kernel/binfmt_elfn32.c
5283 +++ b/arch/mips/kernel/binfmt_elfn32.c
5284 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5285 #undef ELF_ET_DYN_BASE
5286 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5287
5288 +#ifdef CONFIG_PAX_ASLR
5289 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5290 +
5291 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5292 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5293 +#endif
5294 +
5295 #include <asm/processor.h>
5296 #include <linux/module.h>
5297 #include <linux/elfcore.h>
5298 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5299 index 556a435..b4fd2e3 100644
5300 --- a/arch/mips/kernel/binfmt_elfo32.c
5301 +++ b/arch/mips/kernel/binfmt_elfo32.c
5302 @@ -52,6 +52,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5303 #undef ELF_ET_DYN_BASE
5304 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5305
5306 +#ifdef CONFIG_PAX_ASLR
5307 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5308 +
5309 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5310 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5311 +#endif
5312 +
5313 #include <asm/processor.h>
5314
5315 /*
5316 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5317 index 3be4405..a799827 100644
5318 --- a/arch/mips/kernel/process.c
5319 +++ b/arch/mips/kernel/process.c
5320 @@ -461,15 +461,3 @@ unsigned long get_wchan(struct task_struct *task)
5321 out:
5322 return pc;
5323 }
5324 -
5325 -/*
5326 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5327 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5328 - */
5329 -unsigned long arch_align_stack(unsigned long sp)
5330 -{
5331 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5332 - sp -= get_random_int() & ~PAGE_MASK;
5333 -
5334 - return sp & ALMASK;
5335 -}
5336 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5337 index 9c6299c..2fb4c22 100644
5338 --- a/arch/mips/kernel/ptrace.c
5339 +++ b/arch/mips/kernel/ptrace.c
5340 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5341 return arch;
5342 }
5343
5344 +#ifdef CONFIG_GRKERNSEC_SETXID
5345 +extern void gr_delayed_cred_worker(void);
5346 +#endif
5347 +
5348 /*
5349 * Notification of system call entry/exit
5350 * - triggered by current->work.syscall_trace
5351 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5352 /* do the secure computing check first */
5353 secure_computing_strict(regs->regs[2]);
5354
5355 +#ifdef CONFIG_GRKERNSEC_SETXID
5356 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5357 + gr_delayed_cred_worker();
5358 +#endif
5359 +
5360 if (!(current->ptrace & PT_PTRACED))
5361 goto out;
5362
5363 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5364 index 9ea2964..c4329c3 100644
5365 --- a/arch/mips/kernel/scall32-o32.S
5366 +++ b/arch/mips/kernel/scall32-o32.S
5367 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5368
5369 stack_done:
5370 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5371 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5372 + li t1, _TIF_SYSCALL_WORK
5373 and t0, t1
5374 bnez t0, syscall_trace_entry # -> yes
5375
5376 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5377 index 36cfd40..b1436e0 100644
5378 --- a/arch/mips/kernel/scall64-64.S
5379 +++ b/arch/mips/kernel/scall64-64.S
5380 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5381
5382 sd a3, PT_R26(sp) # save a3 for syscall restarting
5383
5384 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5385 + li t1, _TIF_SYSCALL_WORK
5386 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5387 and t0, t1, t0
5388 bnez t0, syscall_trace_entry
5389 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5390 index 693d60b..ae0ba75 100644
5391 --- a/arch/mips/kernel/scall64-n32.S
5392 +++ b/arch/mips/kernel/scall64-n32.S
5393 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5394
5395 sd a3, PT_R26(sp) # save a3 for syscall restarting
5396
5397 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5398 + li t1, _TIF_SYSCALL_WORK
5399 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5400 and t0, t1, t0
5401 bnez t0, n32_syscall_trace_entry
5402 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5403 index af8887f..611ccb6 100644
5404 --- a/arch/mips/kernel/scall64-o32.S
5405 +++ b/arch/mips/kernel/scall64-o32.S
5406 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5407 PTR 4b, bad_stack
5408 .previous
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, trace_a_syscall
5415 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5416 index 0fead53..a2c0fb5 100644
5417 --- a/arch/mips/mm/fault.c
5418 +++ b/arch/mips/mm/fault.c
5419 @@ -27,6 +27,23 @@
5420 #include <asm/highmem.h> /* For VMALLOC_END */
5421 #include <linux/kdebug.h>
5422
5423 +#ifdef CONFIG_PAX_PAGEEXEC
5424 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5425 +{
5426 + unsigned long i;
5427 +
5428 + printk(KERN_ERR "PAX: bytes at PC: ");
5429 + for (i = 0; i < 5; i++) {
5430 + unsigned int c;
5431 + if (get_user(c, (unsigned int *)pc+i))
5432 + printk(KERN_CONT "???????? ");
5433 + else
5434 + printk(KERN_CONT "%08x ", c);
5435 + }
5436 + printk("\n");
5437 +}
5438 +#endif
5439 +
5440 /*
5441 * This routine handles page faults. It determines the address,
5442 * and the problem, and then passes it off to one of the appropriate
5443 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5444 index 7e5fe27..9656513 100644
5445 --- a/arch/mips/mm/mmap.c
5446 +++ b/arch/mips/mm/mmap.c
5447 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5448 struct vm_area_struct *vma;
5449 unsigned long addr = addr0;
5450 int do_color_align;
5451 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5452 struct vm_unmapped_area_info info;
5453
5454 if (unlikely(len > TASK_SIZE))
5455 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5456 do_color_align = 1;
5457
5458 /* requesting a specific address */
5459 +
5460 +#ifdef CONFIG_PAX_RANDMMAP
5461 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5462 +#endif
5463 +
5464 if (addr) {
5465 if (do_color_align)
5466 addr = COLOUR_ALIGN(addr, pgoff);
5467 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5468 addr = PAGE_ALIGN(addr);
5469
5470 vma = find_vma(mm, addr);
5471 - if (TASK_SIZE - len >= addr &&
5472 - (!vma || addr + len <= vma->vm_start))
5473 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5474 return addr;
5475 }
5476
5477 info.length = len;
5478 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
5479 info.align_offset = pgoff << PAGE_SHIFT;
5480 + info.threadstack_offset = offset;
5481
5482 if (dir == DOWN) {
5483 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
5484 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5485 {
5486 unsigned long random_factor = 0UL;
5487
5488 +#ifdef CONFIG_PAX_RANDMMAP
5489 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5490 +#endif
5491 +
5492 if (current->flags & PF_RANDOMIZE) {
5493 random_factor = get_random_int();
5494 random_factor = random_factor << PAGE_SHIFT;
5495 @@ -157,42 +167,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5496
5497 if (mmap_is_legacy()) {
5498 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5499 +
5500 +#ifdef CONFIG_PAX_RANDMMAP
5501 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5502 + mm->mmap_base += mm->delta_mmap;
5503 +#endif
5504 +
5505 mm->get_unmapped_area = arch_get_unmapped_area;
5506 mm->unmap_area = arch_unmap_area;
5507 } else {
5508 mm->mmap_base = mmap_base(random_factor);
5509 +
5510 +#ifdef CONFIG_PAX_RANDMMAP
5511 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5512 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5513 +#endif
5514 +
5515 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5516 mm->unmap_area = arch_unmap_area_topdown;
5517 }
5518 }
5519
5520 -static inline unsigned long brk_rnd(void)
5521 -{
5522 - unsigned long rnd = get_random_int();
5523 -
5524 - rnd = rnd << PAGE_SHIFT;
5525 - /* 8MB for 32bit, 256MB for 64bit */
5526 - if (TASK_IS_32BIT_ADDR)
5527 - rnd = rnd & 0x7ffffful;
5528 - else
5529 - rnd = rnd & 0xffffffful;
5530 -
5531 - return rnd;
5532 -}
5533 -
5534 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5535 -{
5536 - unsigned long base = mm->brk;
5537 - unsigned long ret;
5538 -
5539 - ret = PAGE_ALIGN(base + brk_rnd());
5540 -
5541 - if (ret < mm->brk)
5542 - return mm->brk;
5543 -
5544 - return ret;
5545 -}
5546 -
5547 int __virt_addr_valid(const volatile void *kaddr)
5548 {
5549 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5550 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5551 index 967d144..db12197 100644
5552 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5553 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5554 @@ -11,12 +11,14 @@
5555 #ifndef _ASM_PROC_CACHE_H
5556 #define _ASM_PROC_CACHE_H
5557
5558 +#include <linux/const.h>
5559 +
5560 /* L1 cache */
5561
5562 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5563 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5564 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5565 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5566 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5567 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5568
5569 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5570 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5571 index bcb5df2..84fabd2 100644
5572 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5573 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5574 @@ -16,13 +16,15 @@
5575 #ifndef _ASM_PROC_CACHE_H
5576 #define _ASM_PROC_CACHE_H
5577
5578 +#include <linux/const.h>
5579 +
5580 /*
5581 * L1 cache
5582 */
5583 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5584 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5585 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5586 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5587 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5588 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5589
5590 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5591 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5592 index 4ce7a01..449202a 100644
5593 --- a/arch/openrisc/include/asm/cache.h
5594 +++ b/arch/openrisc/include/asm/cache.h
5595 @@ -19,11 +19,13 @@
5596 #ifndef __ASM_OPENRISC_CACHE_H
5597 #define __ASM_OPENRISC_CACHE_H
5598
5599 +#include <linux/const.h>
5600 +
5601 /* FIXME: How can we replace these with values from the CPU...
5602 * they shouldn't be hard-coded!
5603 */
5604
5605 -#define L1_CACHE_BYTES 16
5606 #define L1_CACHE_SHIFT 4
5607 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5608
5609 #endif /* __ASM_OPENRISC_CACHE_H */
5610 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5611 index f38e198..4179e38 100644
5612 --- a/arch/parisc/include/asm/atomic.h
5613 +++ b/arch/parisc/include/asm/atomic.h
5614 @@ -229,6 +229,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5615
5616 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
5617
5618 +#define atomic64_read_unchecked(v) atomic64_read(v)
5619 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5620 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5621 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5622 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5623 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5624 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5625 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5626 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5627 +
5628 #endif /* !CONFIG_64BIT */
5629
5630
5631 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5632 index 47f11c7..3420df2 100644
5633 --- a/arch/parisc/include/asm/cache.h
5634 +++ b/arch/parisc/include/asm/cache.h
5635 @@ -5,6 +5,7 @@
5636 #ifndef __ARCH_PARISC_CACHE_H
5637 #define __ARCH_PARISC_CACHE_H
5638
5639 +#include <linux/const.h>
5640
5641 /*
5642 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5643 @@ -15,13 +16,13 @@
5644 * just ruin performance.
5645 */
5646 #ifdef CONFIG_PA20
5647 -#define L1_CACHE_BYTES 64
5648 #define L1_CACHE_SHIFT 6
5649 #else
5650 -#define L1_CACHE_BYTES 32
5651 #define L1_CACHE_SHIFT 5
5652 #endif
5653
5654 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5655 +
5656 #ifndef __ASSEMBLY__
5657
5658 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5659 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
5660 index ad2b503..bdf1651 100644
5661 --- a/arch/parisc/include/asm/elf.h
5662 +++ b/arch/parisc/include/asm/elf.h
5663 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
5664
5665 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
5666
5667 +#ifdef CONFIG_PAX_ASLR
5668 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
5669 +
5670 +#define PAX_DELTA_MMAP_LEN 16
5671 +#define PAX_DELTA_STACK_LEN 16
5672 +#endif
5673 +
5674 /* This yields a mask that user programs can use to figure out what
5675 instruction set this CPU supports. This could be done in user space,
5676 but it's not easy, and we've already done it here. */
5677 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
5678 index fc987a1..6e068ef 100644
5679 --- a/arch/parisc/include/asm/pgalloc.h
5680 +++ b/arch/parisc/include/asm/pgalloc.h
5681 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5682 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
5683 }
5684
5685 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5686 +{
5687 + pgd_populate(mm, pgd, pmd);
5688 +}
5689 +
5690 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
5691 {
5692 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
5693 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
5694 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
5695 #define pmd_free(mm, x) do { } while (0)
5696 #define pgd_populate(mm, pmd, pte) BUG()
5697 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
5698
5699 #endif
5700
5701 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
5702 index 1e40d7f..a3eb445 100644
5703 --- a/arch/parisc/include/asm/pgtable.h
5704 +++ b/arch/parisc/include/asm/pgtable.h
5705 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
5706 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
5707 #define PAGE_COPY PAGE_EXECREAD
5708 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
5709 +
5710 +#ifdef CONFIG_PAX_PAGEEXEC
5711 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
5712 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5713 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5714 +#else
5715 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5716 +# define PAGE_COPY_NOEXEC PAGE_COPY
5717 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5718 +#endif
5719 +
5720 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
5721 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
5722 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
5723 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
5724 index e0a8235..ce2f1e1 100644
5725 --- a/arch/parisc/include/asm/uaccess.h
5726 +++ b/arch/parisc/include/asm/uaccess.h
5727 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
5728 const void __user *from,
5729 unsigned long n)
5730 {
5731 - int sz = __compiletime_object_size(to);
5732 + size_t sz = __compiletime_object_size(to);
5733 int ret = -EFAULT;
5734
5735 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
5736 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
5737 ret = __copy_from_user(to, from, n);
5738 else
5739 copy_from_user_overflow();
5740 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
5741 index 2a625fb..9908930 100644
5742 --- a/arch/parisc/kernel/module.c
5743 +++ b/arch/parisc/kernel/module.c
5744 @@ -98,16 +98,38 @@
5745
5746 /* three functions to determine where in the module core
5747 * or init pieces the location is */
5748 +static inline int in_init_rx(struct module *me, void *loc)
5749 +{
5750 + return (loc >= me->module_init_rx &&
5751 + loc < (me->module_init_rx + me->init_size_rx));
5752 +}
5753 +
5754 +static inline int in_init_rw(struct module *me, void *loc)
5755 +{
5756 + return (loc >= me->module_init_rw &&
5757 + loc < (me->module_init_rw + me->init_size_rw));
5758 +}
5759 +
5760 static inline int in_init(struct module *me, void *loc)
5761 {
5762 - return (loc >= me->module_init &&
5763 - loc <= (me->module_init + me->init_size));
5764 + return in_init_rx(me, loc) || in_init_rw(me, loc);
5765 +}
5766 +
5767 +static inline int in_core_rx(struct module *me, void *loc)
5768 +{
5769 + return (loc >= me->module_core_rx &&
5770 + loc < (me->module_core_rx + me->core_size_rx));
5771 +}
5772 +
5773 +static inline int in_core_rw(struct module *me, void *loc)
5774 +{
5775 + return (loc >= me->module_core_rw &&
5776 + loc < (me->module_core_rw + me->core_size_rw));
5777 }
5778
5779 static inline int in_core(struct module *me, void *loc)
5780 {
5781 - return (loc >= me->module_core &&
5782 - loc <= (me->module_core + me->core_size));
5783 + return in_core_rx(me, loc) || in_core_rw(me, loc);
5784 }
5785
5786 static inline int in_local(struct module *me, void *loc)
5787 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
5788 }
5789
5790 /* align things a bit */
5791 - me->core_size = ALIGN(me->core_size, 16);
5792 - me->arch.got_offset = me->core_size;
5793 - me->core_size += gots * sizeof(struct got_entry);
5794 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5795 + me->arch.got_offset = me->core_size_rw;
5796 + me->core_size_rw += gots * sizeof(struct got_entry);
5797
5798 - me->core_size = ALIGN(me->core_size, 16);
5799 - me->arch.fdesc_offset = me->core_size;
5800 - me->core_size += fdescs * sizeof(Elf_Fdesc);
5801 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5802 + me->arch.fdesc_offset = me->core_size_rw;
5803 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
5804
5805 me->arch.got_max = gots;
5806 me->arch.fdesc_max = fdescs;
5807 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5808
5809 BUG_ON(value == 0);
5810
5811 - got = me->module_core + me->arch.got_offset;
5812 + got = me->module_core_rw + me->arch.got_offset;
5813 for (i = 0; got[i].addr; i++)
5814 if (got[i].addr == value)
5815 goto out;
5816 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5817 #ifdef CONFIG_64BIT
5818 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5819 {
5820 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
5821 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
5822
5823 if (!value) {
5824 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
5825 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5826
5827 /* Create new one */
5828 fdesc->addr = value;
5829 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5830 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5831 return (Elf_Addr)fdesc;
5832 }
5833 #endif /* CONFIG_64BIT */
5834 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
5835
5836 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
5837 end = table + sechdrs[me->arch.unwind_section].sh_size;
5838 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5839 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5840
5841 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
5842 me->arch.unwind_section, table, end, gp);
5843 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
5844 index 5dfd248..64914ac 100644
5845 --- a/arch/parisc/kernel/sys_parisc.c
5846 +++ b/arch/parisc/kernel/sys_parisc.c
5847 @@ -33,9 +33,11 @@
5848 #include <linux/utsname.h>
5849 #include <linux/personality.h>
5850
5851 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5852 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
5853 + unsigned long flags)
5854 {
5855 struct vm_unmapped_area_info info;
5856 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5857
5858 info.flags = 0;
5859 info.length = len;
5860 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5861 info.high_limit = TASK_SIZE;
5862 info.align_mask = 0;
5863 info.align_offset = 0;
5864 + info.threadstack_offset = offset;
5865 return vm_unmapped_area(&info);
5866 }
5867
5868 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
5869 return (unsigned long) mapping >> 8;
5870 }
5871
5872 -static unsigned long get_shared_area(struct address_space *mapping,
5873 - unsigned long addr, unsigned long len, unsigned long pgoff)
5874 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
5875 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
5876 {
5877 struct vm_unmapped_area_info info;
5878 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5879
5880 info.flags = 0;
5881 info.length = len;
5882 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
5883 info.high_limit = TASK_SIZE;
5884 info.align_mask = PAGE_MASK & (SHMLBA - 1);
5885 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
5886 + info.threadstack_offset = offset;
5887 return vm_unmapped_area(&info);
5888 }
5889
5890 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
5891 return -EINVAL;
5892 return addr;
5893 }
5894 - if (!addr)
5895 + if (!addr) {
5896 addr = TASK_UNMAPPED_BASE;
5897
5898 +#ifdef CONFIG_PAX_RANDMMAP
5899 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
5900 + addr += current->mm->delta_mmap;
5901 +#endif
5902 +
5903 + }
5904 +
5905 if (filp) {
5906 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
5907 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
5908 } else if(flags & MAP_SHARED) {
5909 - addr = get_shared_area(NULL, addr, len, pgoff);
5910 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
5911 } else {
5912 - addr = get_unshared_area(addr, len);
5913 + addr = get_unshared_area(filp, addr, len, flags);
5914 }
5915 return addr;
5916 }
5917 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
5918 index aeb8f8f..27a6c2f 100644
5919 --- a/arch/parisc/kernel/traps.c
5920 +++ b/arch/parisc/kernel/traps.c
5921 @@ -732,9 +732,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
5922
5923 down_read(&current->mm->mmap_sem);
5924 vma = find_vma(current->mm,regs->iaoq[0]);
5925 - if (vma && (regs->iaoq[0] >= vma->vm_start)
5926 - && (vma->vm_flags & VM_EXEC)) {
5927 -
5928 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
5929 fault_address = regs->iaoq[0];
5930 fault_space = regs->iasq[0];
5931
5932 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
5933 index f247a34..dc0f219 100644
5934 --- a/arch/parisc/mm/fault.c
5935 +++ b/arch/parisc/mm/fault.c
5936 @@ -15,6 +15,7 @@
5937 #include <linux/sched.h>
5938 #include <linux/interrupt.h>
5939 #include <linux/module.h>
5940 +#include <linux/unistd.h>
5941
5942 #include <asm/uaccess.h>
5943 #include <asm/traps.h>
5944 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
5945 static unsigned long
5946 parisc_acctyp(unsigned long code, unsigned int inst)
5947 {
5948 - if (code == 6 || code == 16)
5949 + if (code == 6 || code == 7 || code == 16)
5950 return VM_EXEC;
5951
5952 switch (inst & 0xf0000000) {
5953 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
5954 }
5955 #endif
5956
5957 +#ifdef CONFIG_PAX_PAGEEXEC
5958 +/*
5959 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
5960 + *
5961 + * returns 1 when task should be killed
5962 + * 2 when rt_sigreturn trampoline was detected
5963 + * 3 when unpatched PLT trampoline was detected
5964 + */
5965 +static int pax_handle_fetch_fault(struct pt_regs *regs)
5966 +{
5967 +
5968 +#ifdef CONFIG_PAX_EMUPLT
5969 + int err;
5970 +
5971 + do { /* PaX: unpatched PLT emulation */
5972 + unsigned int bl, depwi;
5973 +
5974 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
5975 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
5976 +
5977 + if (err)
5978 + break;
5979 +
5980 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
5981 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
5982 +
5983 + err = get_user(ldw, (unsigned int *)addr);
5984 + err |= get_user(bv, (unsigned int *)(addr+4));
5985 + err |= get_user(ldw2, (unsigned int *)(addr+8));
5986 +
5987 + if (err)
5988 + break;
5989 +
5990 + if (ldw == 0x0E801096U &&
5991 + bv == 0xEAC0C000U &&
5992 + ldw2 == 0x0E881095U)
5993 + {
5994 + unsigned int resolver, map;
5995 +
5996 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
5997 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
5998 + if (err)
5999 + break;
6000 +
6001 + regs->gr[20] = instruction_pointer(regs)+8;
6002 + regs->gr[21] = map;
6003 + regs->gr[22] = resolver;
6004 + regs->iaoq[0] = resolver | 3UL;
6005 + regs->iaoq[1] = regs->iaoq[0] + 4;
6006 + return 3;
6007 + }
6008 + }
6009 + } while (0);
6010 +#endif
6011 +
6012 +#ifdef CONFIG_PAX_EMUTRAMP
6013 +
6014 +#ifndef CONFIG_PAX_EMUSIGRT
6015 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6016 + return 1;
6017 +#endif
6018 +
6019 + do { /* PaX: rt_sigreturn emulation */
6020 + unsigned int ldi1, ldi2, bel, nop;
6021 +
6022 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6023 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6024 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6025 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6026 +
6027 + if (err)
6028 + break;
6029 +
6030 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6031 + ldi2 == 0x3414015AU &&
6032 + bel == 0xE4008200U &&
6033 + nop == 0x08000240U)
6034 + {
6035 + regs->gr[25] = (ldi1 & 2) >> 1;
6036 + regs->gr[20] = __NR_rt_sigreturn;
6037 + regs->gr[31] = regs->iaoq[1] + 16;
6038 + regs->sr[0] = regs->iasq[1];
6039 + regs->iaoq[0] = 0x100UL;
6040 + regs->iaoq[1] = regs->iaoq[0] + 4;
6041 + regs->iasq[0] = regs->sr[2];
6042 + regs->iasq[1] = regs->sr[2];
6043 + return 2;
6044 + }
6045 + } while (0);
6046 +#endif
6047 +
6048 + return 1;
6049 +}
6050 +
6051 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6052 +{
6053 + unsigned long i;
6054 +
6055 + printk(KERN_ERR "PAX: bytes at PC: ");
6056 + for (i = 0; i < 5; i++) {
6057 + unsigned int c;
6058 + if (get_user(c, (unsigned int *)pc+i))
6059 + printk(KERN_CONT "???????? ");
6060 + else
6061 + printk(KERN_CONT "%08x ", c);
6062 + }
6063 + printk("\n");
6064 +}
6065 +#endif
6066 +
6067 int fixup_exception(struct pt_regs *regs)
6068 {
6069 const struct exception_table_entry *fix;
6070 @@ -194,8 +305,33 @@ good_area:
6071
6072 acc_type = parisc_acctyp(code,regs->iir);
6073
6074 - if ((vma->vm_flags & acc_type) != acc_type)
6075 + if ((vma->vm_flags & acc_type) != acc_type) {
6076 +
6077 +#ifdef CONFIG_PAX_PAGEEXEC
6078 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6079 + (address & ~3UL) == instruction_pointer(regs))
6080 + {
6081 + up_read(&mm->mmap_sem);
6082 + switch (pax_handle_fetch_fault(regs)) {
6083 +
6084 +#ifdef CONFIG_PAX_EMUPLT
6085 + case 3:
6086 + return;
6087 +#endif
6088 +
6089 +#ifdef CONFIG_PAX_EMUTRAMP
6090 + case 2:
6091 + return;
6092 +#endif
6093 +
6094 + }
6095 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6096 + do_group_exit(SIGKILL);
6097 + }
6098 +#endif
6099 +
6100 goto bad_area;
6101 + }
6102
6103 /*
6104 * If for any reason at all we couldn't handle the fault, make
6105 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6106 index e3b1d41..8e81edf 100644
6107 --- a/arch/powerpc/include/asm/atomic.h
6108 +++ b/arch/powerpc/include/asm/atomic.h
6109 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6110 return t1;
6111 }
6112
6113 +#define atomic64_read_unchecked(v) atomic64_read(v)
6114 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6115 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6116 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6117 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6118 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6119 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6120 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6121 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6122 +
6123 #endif /* __powerpc64__ */
6124
6125 #endif /* __KERNEL__ */
6126 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6127 index 9e495c9..b6878e5 100644
6128 --- a/arch/powerpc/include/asm/cache.h
6129 +++ b/arch/powerpc/include/asm/cache.h
6130 @@ -3,6 +3,7 @@
6131
6132 #ifdef __KERNEL__
6133
6134 +#include <linux/const.h>
6135
6136 /* bytes per L1 cache line */
6137 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6138 @@ -22,7 +23,7 @@
6139 #define L1_CACHE_SHIFT 7
6140 #endif
6141
6142 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6143 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6144
6145 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6146
6147 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6148 index ac9790f..6d30741 100644
6149 --- a/arch/powerpc/include/asm/elf.h
6150 +++ b/arch/powerpc/include/asm/elf.h
6151 @@ -28,8 +28,19 @@
6152 the loader. We need to make sure that it is out of the way of the program
6153 that it will "exec", and that there is sufficient room for the brk. */
6154
6155 -extern unsigned long randomize_et_dyn(unsigned long base);
6156 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6157 +#define ELF_ET_DYN_BASE (0x20000000)
6158 +
6159 +#ifdef CONFIG_PAX_ASLR
6160 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6161 +
6162 +#ifdef __powerpc64__
6163 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6164 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6165 +#else
6166 +#define PAX_DELTA_MMAP_LEN 15
6167 +#define PAX_DELTA_STACK_LEN 15
6168 +#endif
6169 +#endif
6170
6171 /*
6172 * Our registers are always unsigned longs, whether we're a 32 bit
6173 @@ -122,10 +133,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6174 (0x7ff >> (PAGE_SHIFT - 12)) : \
6175 (0x3ffff >> (PAGE_SHIFT - 12)))
6176
6177 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6178 -#define arch_randomize_brk arch_randomize_brk
6179 -
6180 -
6181 #ifdef CONFIG_SPU_BASE
6182 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6183 #define NT_SPU 1
6184 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6185 index 8196e9c..d83a9f3 100644
6186 --- a/arch/powerpc/include/asm/exec.h
6187 +++ b/arch/powerpc/include/asm/exec.h
6188 @@ -4,6 +4,6 @@
6189 #ifndef _ASM_POWERPC_EXEC_H
6190 #define _ASM_POWERPC_EXEC_H
6191
6192 -extern unsigned long arch_align_stack(unsigned long sp);
6193 +#define arch_align_stack(x) ((x) & ~0xfUL)
6194
6195 #endif /* _ASM_POWERPC_EXEC_H */
6196 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6197 index 5acabbd..7ea14fa 100644
6198 --- a/arch/powerpc/include/asm/kmap_types.h
6199 +++ b/arch/powerpc/include/asm/kmap_types.h
6200 @@ -10,7 +10,7 @@
6201 * 2 of the License, or (at your option) any later version.
6202 */
6203
6204 -#define KM_TYPE_NR 16
6205 +#define KM_TYPE_NR 17
6206
6207 #endif /* __KERNEL__ */
6208 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6209 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6210 index 8565c25..2865190 100644
6211 --- a/arch/powerpc/include/asm/mman.h
6212 +++ b/arch/powerpc/include/asm/mman.h
6213 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6214 }
6215 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6216
6217 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6218 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6219 {
6220 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6221 }
6222 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6223 index f072e97..b436dee 100644
6224 --- a/arch/powerpc/include/asm/page.h
6225 +++ b/arch/powerpc/include/asm/page.h
6226 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6227 * and needs to be executable. This means the whole heap ends
6228 * up being executable.
6229 */
6230 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6231 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6232 +#define VM_DATA_DEFAULT_FLAGS32 \
6233 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6234 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6235
6236 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6237 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6238 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6239 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6240 #endif
6241
6242 +#define ktla_ktva(addr) (addr)
6243 +#define ktva_ktla(addr) (addr)
6244 +
6245 /*
6246 * Use the top bit of the higher-level page table entries to indicate whether
6247 * the entries we point to contain hugepages. This works because we know that
6248 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6249 index cd915d6..c10cee8 100644
6250 --- a/arch/powerpc/include/asm/page_64.h
6251 +++ b/arch/powerpc/include/asm/page_64.h
6252 @@ -154,15 +154,18 @@ do { \
6253 * stack by default, so in the absence of a PT_GNU_STACK program header
6254 * we turn execute permission off.
6255 */
6256 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6257 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6258 +#define VM_STACK_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_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6263 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6264
6265 +#ifndef CONFIG_PAX_PAGEEXEC
6266 #define VM_STACK_DEFAULT_FLAGS \
6267 (is_32bit_task() ? \
6268 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6269 +#endif
6270
6271 #include <asm-generic/getorder.h>
6272
6273 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6274 index 292725c..f87ae14 100644
6275 --- a/arch/powerpc/include/asm/pgalloc-64.h
6276 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6277 @@ -50,6 +50,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6278 #ifndef CONFIG_PPC_64K_PAGES
6279
6280 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6281 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6282
6283 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6284 {
6285 @@ -67,6 +68,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6286 pud_set(pud, (unsigned long)pmd);
6287 }
6288
6289 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6290 +{
6291 + pud_populate(mm, pud, pmd);
6292 +}
6293 +
6294 #define pmd_populate(mm, pmd, pte_page) \
6295 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6296 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6297 @@ -76,6 +82,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6298 #else /* CONFIG_PPC_64K_PAGES */
6299
6300 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6301 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6302
6303 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6304 pte_t *pte)
6305 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6306 index a9cbd3b..3b67efa 100644
6307 --- a/arch/powerpc/include/asm/pgtable.h
6308 +++ b/arch/powerpc/include/asm/pgtable.h
6309 @@ -2,6 +2,7 @@
6310 #define _ASM_POWERPC_PGTABLE_H
6311 #ifdef __KERNEL__
6312
6313 +#include <linux/const.h>
6314 #ifndef __ASSEMBLY__
6315 #include <asm/processor.h> /* For TASK_SIZE */
6316 #include <asm/mmu.h>
6317 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6318 index 4aad413..85d86bf 100644
6319 --- a/arch/powerpc/include/asm/pte-hash32.h
6320 +++ b/arch/powerpc/include/asm/pte-hash32.h
6321 @@ -21,6 +21,7 @@
6322 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6323 #define _PAGE_USER 0x004 /* usermode access allowed */
6324 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6325 +#define _PAGE_EXEC _PAGE_GUARDED
6326 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6327 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6328 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6329 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6330 index c9c67fc..e10c012 100644
6331 --- a/arch/powerpc/include/asm/reg.h
6332 +++ b/arch/powerpc/include/asm/reg.h
6333 @@ -245,6 +245,7 @@
6334 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6335 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6336 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6337 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6338 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6339 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6340 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6341 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
6342 index 195ce2a..ab5c614 100644
6343 --- a/arch/powerpc/include/asm/smp.h
6344 +++ b/arch/powerpc/include/asm/smp.h
6345 @@ -50,7 +50,7 @@ struct smp_ops_t {
6346 int (*cpu_disable)(void);
6347 void (*cpu_die)(unsigned int nr);
6348 int (*cpu_bootable)(unsigned int nr);
6349 -};
6350 +} __no_const;
6351
6352 extern void smp_send_debugger_break(void);
6353 extern void start_secondary_resume(void);
6354 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6355 index 406b7b9..af63426 100644
6356 --- a/arch/powerpc/include/asm/thread_info.h
6357 +++ b/arch/powerpc/include/asm/thread_info.h
6358 @@ -97,7 +97,6 @@ static inline struct thread_info *current_thread_info(void)
6359 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6360 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6361 #define TIF_SINGLESTEP 8 /* singlestepping active */
6362 -#define TIF_MEMDIE 9 /* is terminating due to OOM killer */
6363 #define TIF_SECCOMP 10 /* secure computing */
6364 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
6365 #define TIF_NOERROR 12 /* Force successful syscall return */
6366 @@ -106,6 +105,9 @@ static inline struct thread_info *current_thread_info(void)
6367 #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
6368 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6369 for stack store? */
6370 +#define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6371 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6372 +#define TIF_GRSEC_SETXID 9 /* update credentials on syscall entry/exit */
6373
6374 /* as above, but as bit values */
6375 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6376 @@ -124,8 +126,10 @@ static inline struct thread_info *current_thread_info(void)
6377 #define _TIF_UPROBE (1<<TIF_UPROBE)
6378 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6379 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6380 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6381 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6382 - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
6383 + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6384 + _TIF_GRSEC_SETXID)
6385
6386 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6387 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6388 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6389 index 4db4959..aba5c41 100644
6390 --- a/arch/powerpc/include/asm/uaccess.h
6391 +++ b/arch/powerpc/include/asm/uaccess.h
6392 @@ -318,52 +318,6 @@ do { \
6393 extern unsigned long __copy_tofrom_user(void __user *to,
6394 const void __user *from, unsigned long size);
6395
6396 -#ifndef __powerpc64__
6397 -
6398 -static inline unsigned long copy_from_user(void *to,
6399 - const void __user *from, unsigned long n)
6400 -{
6401 - unsigned long over;
6402 -
6403 - if (access_ok(VERIFY_READ, from, n))
6404 - return __copy_tofrom_user((__force void __user *)to, from, n);
6405 - if ((unsigned long)from < TASK_SIZE) {
6406 - over = (unsigned long)from + n - TASK_SIZE;
6407 - return __copy_tofrom_user((__force void __user *)to, from,
6408 - n - over) + over;
6409 - }
6410 - return n;
6411 -}
6412 -
6413 -static inline unsigned long copy_to_user(void __user *to,
6414 - const void *from, unsigned long n)
6415 -{
6416 - unsigned long over;
6417 -
6418 - if (access_ok(VERIFY_WRITE, to, n))
6419 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6420 - if ((unsigned long)to < TASK_SIZE) {
6421 - over = (unsigned long)to + n - TASK_SIZE;
6422 - return __copy_tofrom_user(to, (__force void __user *)from,
6423 - n - over) + over;
6424 - }
6425 - return n;
6426 -}
6427 -
6428 -#else /* __powerpc64__ */
6429 -
6430 -#define __copy_in_user(to, from, size) \
6431 - __copy_tofrom_user((to), (from), (size))
6432 -
6433 -extern unsigned long copy_from_user(void *to, const void __user *from,
6434 - unsigned long n);
6435 -extern unsigned long copy_to_user(void __user *to, const void *from,
6436 - unsigned long n);
6437 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6438 - unsigned long n);
6439 -
6440 -#endif /* __powerpc64__ */
6441 -
6442 static inline unsigned long __copy_from_user_inatomic(void *to,
6443 const void __user *from, unsigned long n)
6444 {
6445 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6446 if (ret == 0)
6447 return 0;
6448 }
6449 +
6450 + if (!__builtin_constant_p(n))
6451 + check_object_size(to, n, false);
6452 +
6453 return __copy_tofrom_user((__force void __user *)to, from, n);
6454 }
6455
6456 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6457 if (ret == 0)
6458 return 0;
6459 }
6460 +
6461 + if (!__builtin_constant_p(n))
6462 + check_object_size(from, n, true);
6463 +
6464 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6465 }
6466
6467 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6468 return __copy_to_user_inatomic(to, from, size);
6469 }
6470
6471 +#ifndef __powerpc64__
6472 +
6473 +static inline unsigned long __must_check copy_from_user(void *to,
6474 + const void __user *from, unsigned long n)
6475 +{
6476 + unsigned long over;
6477 +
6478 + if ((long)n < 0)
6479 + return n;
6480 +
6481 + if (access_ok(VERIFY_READ, from, n)) {
6482 + if (!__builtin_constant_p(n))
6483 + check_object_size(to, n, false);
6484 + return __copy_tofrom_user((__force void __user *)to, from, n);
6485 + }
6486 + if ((unsigned long)from < TASK_SIZE) {
6487 + over = (unsigned long)from + n - TASK_SIZE;
6488 + if (!__builtin_constant_p(n - over))
6489 + check_object_size(to, n - over, false);
6490 + return __copy_tofrom_user((__force void __user *)to, from,
6491 + n - over) + over;
6492 + }
6493 + return n;
6494 +}
6495 +
6496 +static inline unsigned long __must_check copy_to_user(void __user *to,
6497 + const void *from, unsigned long n)
6498 +{
6499 + unsigned long over;
6500 +
6501 + if ((long)n < 0)
6502 + return n;
6503 +
6504 + if (access_ok(VERIFY_WRITE, to, n)) {
6505 + if (!__builtin_constant_p(n))
6506 + check_object_size(from, n, true);
6507 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6508 + }
6509 + if ((unsigned long)to < TASK_SIZE) {
6510 + over = (unsigned long)to + n - TASK_SIZE;
6511 + if (!__builtin_constant_p(n))
6512 + check_object_size(from, n - over, true);
6513 + return __copy_tofrom_user(to, (__force void __user *)from,
6514 + n - over) + over;
6515 + }
6516 + return n;
6517 +}
6518 +
6519 +#else /* __powerpc64__ */
6520 +
6521 +#define __copy_in_user(to, from, size) \
6522 + __copy_tofrom_user((to), (from), (size))
6523 +
6524 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6525 +{
6526 + if ((long)n < 0 || n > INT_MAX)
6527 + return n;
6528 +
6529 + if (!__builtin_constant_p(n))
6530 + check_object_size(to, n, false);
6531 +
6532 + if (likely(access_ok(VERIFY_READ, from, n)))
6533 + n = __copy_from_user(to, from, n);
6534 + else
6535 + memset(to, 0, n);
6536 + return n;
6537 +}
6538 +
6539 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6540 +{
6541 + if ((long)n < 0 || n > INT_MAX)
6542 + return n;
6543 +
6544 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6545 + if (!__builtin_constant_p(n))
6546 + check_object_size(from, n, true);
6547 + n = __copy_to_user(to, from, n);
6548 + }
6549 + return n;
6550 +}
6551 +
6552 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6553 + unsigned long n);
6554 +
6555 +#endif /* __powerpc64__ */
6556 +
6557 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6558
6559 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6560 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6561 index ae54553..cf2184d 100644
6562 --- a/arch/powerpc/kernel/exceptions-64e.S
6563 +++ b/arch/powerpc/kernel/exceptions-64e.S
6564 @@ -716,6 +716,7 @@ storage_fault_common:
6565 std r14,_DAR(r1)
6566 std r15,_DSISR(r1)
6567 addi r3,r1,STACK_FRAME_OVERHEAD
6568 + bl .save_nvgprs
6569 mr r4,r14
6570 mr r5,r15
6571 ld r14,PACA_EXGEN+EX_R14(r13)
6572 @@ -724,8 +725,7 @@ storage_fault_common:
6573 cmpdi r3,0
6574 bne- 1f
6575 b .ret_from_except_lite
6576 -1: bl .save_nvgprs
6577 - mr r5,r3
6578 +1: mr r5,r3
6579 addi r3,r1,STACK_FRAME_OVERHEAD
6580 ld r4,_DAR(r1)
6581 bl .bad_page_fault
6582 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6583 index 3bbe7ed..14ec3eb 100644
6584 --- a/arch/powerpc/kernel/exceptions-64s.S
6585 +++ b/arch/powerpc/kernel/exceptions-64s.S
6586 @@ -1390,10 +1390,10 @@ handle_page_fault:
6587 11: ld r4,_DAR(r1)
6588 ld r5,_DSISR(r1)
6589 addi r3,r1,STACK_FRAME_OVERHEAD
6590 + bl .save_nvgprs
6591 bl .do_page_fault
6592 cmpdi r3,0
6593 beq+ 12f
6594 - bl .save_nvgprs
6595 mr r5,r3
6596 addi r3,r1,STACK_FRAME_OVERHEAD
6597 lwz r4,_DAR(r1)
6598 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6599 index 2e3200c..72095ce 100644
6600 --- a/arch/powerpc/kernel/module_32.c
6601 +++ b/arch/powerpc/kernel/module_32.c
6602 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6603 me->arch.core_plt_section = i;
6604 }
6605 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6606 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6607 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
6608 return -ENOEXEC;
6609 }
6610
6611 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
6612
6613 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
6614 /* Init, or core PLT? */
6615 - if (location >= mod->module_core
6616 - && location < mod->module_core + mod->core_size)
6617 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
6618 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
6619 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
6620 - else
6621 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
6622 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
6623 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
6624 + else {
6625 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
6626 + return ~0UL;
6627 + }
6628
6629 /* Find this entry, or if that fails, the next avail. entry */
6630 while (entry->jump[0]) {
6631 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
6632 index 16e77a8..4501b41 100644
6633 --- a/arch/powerpc/kernel/process.c
6634 +++ b/arch/powerpc/kernel/process.c
6635 @@ -870,8 +870,8 @@ void show_regs(struct pt_regs * regs)
6636 * Lookup NIP late so we have the best change of getting the
6637 * above info out without failing
6638 */
6639 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
6640 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
6641 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
6642 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
6643 #endif
6644 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
6645 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
6646 @@ -1330,10 +1330,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6647 newsp = stack[0];
6648 ip = stack[STACK_FRAME_LR_SAVE];
6649 if (!firstframe || ip != lr) {
6650 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
6651 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
6652 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6653 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
6654 - printk(" (%pS)",
6655 + printk(" (%pA)",
6656 (void *)current->ret_stack[curr_frame].ret);
6657 curr_frame--;
6658 }
6659 @@ -1353,7 +1353,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6660 struct pt_regs *regs = (struct pt_regs *)
6661 (sp + STACK_FRAME_OVERHEAD);
6662 lr = regs->link;
6663 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
6664 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
6665 regs->trap, (void *)regs->nip, (void *)lr);
6666 firstframe = 1;
6667 }
6668 @@ -1395,58 +1395,3 @@ void __ppc64_runlatch_off(void)
6669 mtspr(SPRN_CTRLT, ctrl);
6670 }
6671 #endif /* CONFIG_PPC64 */
6672 -
6673 -unsigned long arch_align_stack(unsigned long sp)
6674 -{
6675 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6676 - sp -= get_random_int() & ~PAGE_MASK;
6677 - return sp & ~0xf;
6678 -}
6679 -
6680 -static inline unsigned long brk_rnd(void)
6681 -{
6682 - unsigned long rnd = 0;
6683 -
6684 - /* 8MB for 32bit, 1GB for 64bit */
6685 - if (is_32bit_task())
6686 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
6687 - else
6688 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
6689 -
6690 - return rnd << PAGE_SHIFT;
6691 -}
6692 -
6693 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6694 -{
6695 - unsigned long base = mm->brk;
6696 - unsigned long ret;
6697 -
6698 -#ifdef CONFIG_PPC_STD_MMU_64
6699 - /*
6700 - * If we are using 1TB segments and we are allowed to randomise
6701 - * the heap, we can put it above 1TB so it is backed by a 1TB
6702 - * segment. Otherwise the heap will be in the bottom 1TB
6703 - * which always uses 256MB segments and this may result in a
6704 - * performance penalty.
6705 - */
6706 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
6707 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
6708 -#endif
6709 -
6710 - ret = PAGE_ALIGN(base + brk_rnd());
6711 -
6712 - if (ret < mm->brk)
6713 - return mm->brk;
6714 -
6715 - return ret;
6716 -}
6717 -
6718 -unsigned long randomize_et_dyn(unsigned long base)
6719 -{
6720 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
6721 -
6722 - if (ret < base)
6723 - return base;
6724 -
6725 - return ret;
6726 -}
6727 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
6728 index f9b30c6..d72e7a3 100644
6729 --- a/arch/powerpc/kernel/ptrace.c
6730 +++ b/arch/powerpc/kernel/ptrace.c
6731 @@ -1771,6 +1771,10 @@ long arch_ptrace(struct task_struct *child, long request,
6732 return ret;
6733 }
6734
6735 +#ifdef CONFIG_GRKERNSEC_SETXID
6736 +extern void gr_delayed_cred_worker(void);
6737 +#endif
6738 +
6739 /*
6740 * We must return the syscall number to actually look up in the table.
6741 * This can be -1L to skip running any syscall at all.
6742 @@ -1781,6 +1785,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
6743
6744 secure_computing_strict(regs->gpr[0]);
6745
6746 +#ifdef CONFIG_GRKERNSEC_SETXID
6747 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6748 + gr_delayed_cred_worker();
6749 +#endif
6750 +
6751 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
6752 tracehook_report_syscall_entry(regs))
6753 /*
6754 @@ -1815,6 +1824,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
6755 {
6756 int step;
6757
6758 +#ifdef CONFIG_GRKERNSEC_SETXID
6759 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6760 + gr_delayed_cred_worker();
6761 +#endif
6762 +
6763 audit_syscall_exit(regs);
6764
6765 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
6766 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
6767 index 95068bf..9ba1814 100644
6768 --- a/arch/powerpc/kernel/signal_32.c
6769 +++ b/arch/powerpc/kernel/signal_32.c
6770 @@ -982,7 +982,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
6771 /* Save user registers on the stack */
6772 frame = &rt_sf->uc.uc_mcontext;
6773 addr = frame;
6774 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
6775 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6776 sigret = 0;
6777 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
6778 } else {
6779 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
6780 index c179428..58acdaa 100644
6781 --- a/arch/powerpc/kernel/signal_64.c
6782 +++ b/arch/powerpc/kernel/signal_64.c
6783 @@ -758,7 +758,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
6784 #endif
6785
6786 /* Set up to return from userspace. */
6787 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
6788 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6789 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
6790 } else {
6791 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
6792 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
6793 index 3ce1f86..c30e629 100644
6794 --- a/arch/powerpc/kernel/sysfs.c
6795 +++ b/arch/powerpc/kernel/sysfs.c
6796 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
6797 return NOTIFY_OK;
6798 }
6799
6800 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
6801 +static struct notifier_block sysfs_cpu_nb = {
6802 .notifier_call = sysfs_cpu_notify,
6803 };
6804
6805 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
6806 index 83efa2f..6bb5839 100644
6807 --- a/arch/powerpc/kernel/traps.c
6808 +++ b/arch/powerpc/kernel/traps.c
6809 @@ -141,6 +141,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
6810 return flags;
6811 }
6812
6813 +extern void gr_handle_kernel_exploit(void);
6814 +
6815 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6816 int signr)
6817 {
6818 @@ -190,6 +192,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6819 panic("Fatal exception in interrupt");
6820 if (panic_on_oops)
6821 panic("Fatal exception");
6822 +
6823 + gr_handle_kernel_exploit();
6824 +
6825 do_exit(signr);
6826 }
6827
6828 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
6829 index 1b2076f..835e4be 100644
6830 --- a/arch/powerpc/kernel/vdso.c
6831 +++ b/arch/powerpc/kernel/vdso.c
6832 @@ -34,6 +34,7 @@
6833 #include <asm/firmware.h>
6834 #include <asm/vdso.h>
6835 #include <asm/vdso_datapage.h>
6836 +#include <asm/mman.h>
6837
6838 #include "setup.h"
6839
6840 @@ -218,7 +219,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6841 vdso_base = VDSO32_MBASE;
6842 #endif
6843
6844 - current->mm->context.vdso_base = 0;
6845 + current->mm->context.vdso_base = ~0UL;
6846
6847 /* vDSO has a problem and was disabled, just don't "enable" it for the
6848 * process
6849 @@ -238,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6850 vdso_base = get_unmapped_area(NULL, vdso_base,
6851 (vdso_pages << PAGE_SHIFT) +
6852 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
6853 - 0, 0);
6854 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
6855 if (IS_ERR_VALUE(vdso_base)) {
6856 rc = vdso_base;
6857 goto fail_mmapsem;
6858 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
6859 index 5eea6f3..5d10396 100644
6860 --- a/arch/powerpc/lib/usercopy_64.c
6861 +++ b/arch/powerpc/lib/usercopy_64.c
6862 @@ -9,22 +9,6 @@
6863 #include <linux/module.h>
6864 #include <asm/uaccess.h>
6865
6866 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
6867 -{
6868 - if (likely(access_ok(VERIFY_READ, from, n)))
6869 - n = __copy_from_user(to, from, n);
6870 - else
6871 - memset(to, 0, n);
6872 - return n;
6873 -}
6874 -
6875 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
6876 -{
6877 - if (likely(access_ok(VERIFY_WRITE, to, n)))
6878 - n = __copy_to_user(to, from, n);
6879 - return n;
6880 -}
6881 -
6882 unsigned long copy_in_user(void __user *to, const void __user *from,
6883 unsigned long n)
6884 {
6885 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
6886 return n;
6887 }
6888
6889 -EXPORT_SYMBOL(copy_from_user);
6890 -EXPORT_SYMBOL(copy_to_user);
6891 EXPORT_SYMBOL(copy_in_user);
6892
6893 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
6894 index 229951f..cdeca42 100644
6895 --- a/arch/powerpc/mm/fault.c
6896 +++ b/arch/powerpc/mm/fault.c
6897 @@ -32,6 +32,10 @@
6898 #include <linux/perf_event.h>
6899 #include <linux/magic.h>
6900 #include <linux/ratelimit.h>
6901 +#include <linux/slab.h>
6902 +#include <linux/pagemap.h>
6903 +#include <linux/compiler.h>
6904 +#include <linux/unistd.h>
6905
6906 #include <asm/firmware.h>
6907 #include <asm/page.h>
6908 @@ -68,6 +72,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
6909 }
6910 #endif
6911
6912 +#ifdef CONFIG_PAX_PAGEEXEC
6913 +/*
6914 + * PaX: decide what to do with offenders (regs->nip = fault address)
6915 + *
6916 + * returns 1 when task should be killed
6917 + */
6918 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6919 +{
6920 + return 1;
6921 +}
6922 +
6923 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6924 +{
6925 + unsigned long i;
6926 +
6927 + printk(KERN_ERR "PAX: bytes at PC: ");
6928 + for (i = 0; i < 5; i++) {
6929 + unsigned int c;
6930 + if (get_user(c, (unsigned int __user *)pc+i))
6931 + printk(KERN_CONT "???????? ");
6932 + else
6933 + printk(KERN_CONT "%08x ", c);
6934 + }
6935 + printk("\n");
6936 +}
6937 +#endif
6938 +
6939 /*
6940 * Check whether the instruction at regs->nip is a store using
6941 * an update addressing form which will update r1.
6942 @@ -213,7 +244,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
6943 * indicate errors in DSISR but can validly be set in SRR1.
6944 */
6945 if (trap == 0x400)
6946 - error_code &= 0x48200000;
6947 + error_code &= 0x58200000;
6948 else
6949 is_write = error_code & DSISR_ISSTORE;
6950 #else
6951 @@ -364,7 +395,7 @@ good_area:
6952 * "undefined". Of those that can be set, this is the only
6953 * one which seems bad.
6954 */
6955 - if (error_code & 0x10000000)
6956 + if (error_code & DSISR_GUARDED)
6957 /* Guarded storage error. */
6958 goto bad_area;
6959 #endif /* CONFIG_8xx */
6960 @@ -379,7 +410,7 @@ good_area:
6961 * processors use the same I/D cache coherency mechanism
6962 * as embedded.
6963 */
6964 - if (error_code & DSISR_PROTFAULT)
6965 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
6966 goto bad_area;
6967 #endif /* CONFIG_PPC_STD_MMU */
6968
6969 @@ -462,6 +493,23 @@ bad_area:
6970 bad_area_nosemaphore:
6971 /* User mode accesses cause a SIGSEGV */
6972 if (user_mode(regs)) {
6973 +
6974 +#ifdef CONFIG_PAX_PAGEEXEC
6975 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
6976 +#ifdef CONFIG_PPC_STD_MMU
6977 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
6978 +#else
6979 + if (is_exec && regs->nip == address) {
6980 +#endif
6981 + switch (pax_handle_fetch_fault(regs)) {
6982 + }
6983 +
6984 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
6985 + do_group_exit(SIGKILL);
6986 + }
6987 + }
6988 +#endif
6989 +
6990 _exception(SIGSEGV, regs, code, address);
6991 return 0;
6992 }
6993 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
6994 index 67a42ed..cd463e0 100644
6995 --- a/arch/powerpc/mm/mmap_64.c
6996 +++ b/arch/powerpc/mm/mmap_64.c
6997 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
6998 {
6999 unsigned long rnd = 0;
7000
7001 +#ifdef CONFIG_PAX_RANDMMAP
7002 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7003 +#endif
7004 +
7005 if (current->flags & PF_RANDOMIZE) {
7006 /* 8MB for 32bit, 1GB for 64bit */
7007 if (is_32bit_task())
7008 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7009 */
7010 if (mmap_is_legacy()) {
7011 mm->mmap_base = TASK_UNMAPPED_BASE;
7012 +
7013 +#ifdef CONFIG_PAX_RANDMMAP
7014 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7015 + mm->mmap_base += mm->delta_mmap;
7016 +#endif
7017 +
7018 mm->get_unmapped_area = arch_get_unmapped_area;
7019 mm->unmap_area = arch_unmap_area;
7020 } else {
7021 mm->mmap_base = mmap_base();
7022 +
7023 +#ifdef CONFIG_PAX_RANDMMAP
7024 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7025 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7026 +#endif
7027 +
7028 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7029 mm->unmap_area = arch_unmap_area_topdown;
7030 }
7031 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7032 index e779642..e5bb889 100644
7033 --- a/arch/powerpc/mm/mmu_context_nohash.c
7034 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7035 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7036 return NOTIFY_OK;
7037 }
7038
7039 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7040 +static struct notifier_block mmu_context_cpu_nb = {
7041 .notifier_call = mmu_context_cpu_notify,
7042 };
7043
7044 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7045 index 6a252c4..3024d81 100644
7046 --- a/arch/powerpc/mm/numa.c
7047 +++ b/arch/powerpc/mm/numa.c
7048 @@ -932,7 +932,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7049 return ret;
7050 }
7051
7052 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7053 +static struct notifier_block ppc64_numa_nb = {
7054 .notifier_call = cpu_numa_callback,
7055 .priority = 1 /* Must run before sched domains notifier. */
7056 };
7057 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7058 index cf9dada..241529f 100644
7059 --- a/arch/powerpc/mm/slice.c
7060 +++ b/arch/powerpc/mm/slice.c
7061 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7062 if ((mm->task_size - len) < addr)
7063 return 0;
7064 vma = find_vma(mm, addr);
7065 - return (!vma || (addr + len) <= vma->vm_start);
7066 + return check_heap_stack_gap(vma, addr, len, 0);
7067 }
7068
7069 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7070 @@ -272,7 +272,7 @@ full_search:
7071 addr = _ALIGN_UP(addr + 1, 1ul << SLICE_HIGH_SHIFT);
7072 continue;
7073 }
7074 - if (!vma || addr + len <= vma->vm_start) {
7075 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7076 /*
7077 * Remember the place where we stopped the search:
7078 */
7079 @@ -329,10 +329,14 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7080 }
7081 }
7082
7083 - addr = mm->mmap_base;
7084 - while (addr > len) {
7085 + if (mm->mmap_base < len)
7086 + addr = -ENOMEM;
7087 + else
7088 + addr = mm->mmap_base - len;
7089 +
7090 + while (!IS_ERR_VALUE(addr)) {
7091 /* Go down by chunk size */
7092 - addr = _ALIGN_DOWN(addr - len, 1ul << pshift);
7093 + addr = _ALIGN_DOWN(addr, 1ul << pshift);
7094
7095 /* Check for hit with different page size */
7096 mask = slice_range_to_mask(addr, len);
7097 @@ -352,7 +356,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7098 * return with success:
7099 */
7100 vma = find_vma(mm, addr);
7101 - if (!vma || (addr + len) <= vma->vm_start) {
7102 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7103 /* remember the address as a hint for next time */
7104 if (use_cache)
7105 mm->free_area_cache = addr;
7106 @@ -364,7 +368,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7107 mm->cached_hole_size = vma->vm_start - addr;
7108
7109 /* try just below the current vma->vm_start */
7110 - addr = vma->vm_start;
7111 + addr = skip_heap_stack_gap(vma, len, 0);
7112 }
7113
7114 /*
7115 @@ -442,6 +446,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7116 if (fixed && addr > (mm->task_size - len))
7117 return -EINVAL;
7118
7119 +#ifdef CONFIG_PAX_RANDMMAP
7120 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7121 + addr = 0;
7122 +#endif
7123 +
7124 /* If hint, make sure it matches our alignment restrictions */
7125 if (!fixed && addr) {
7126 addr = _ALIGN_UP(addr, 1ul << pshift);
7127 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7128 index 68c57d3..1fdcfb2 100644
7129 --- a/arch/powerpc/platforms/cell/spufs/file.c
7130 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7131 @@ -281,9 +281,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7132 return VM_FAULT_NOPAGE;
7133 }
7134
7135 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7136 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7137 unsigned long address,
7138 - void *buf, int len, int write)
7139 + void *buf, size_t len, int write)
7140 {
7141 struct spu_context *ctx = vma->vm_file->private_data;
7142 unsigned long offset = address - vma->vm_start;
7143 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7144 index bdb738a..49c9f95 100644
7145 --- a/arch/powerpc/platforms/powermac/smp.c
7146 +++ b/arch/powerpc/platforms/powermac/smp.c
7147 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7148 return NOTIFY_OK;
7149 }
7150
7151 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7152 +static struct notifier_block smp_core99_cpu_nb = {
7153 .notifier_call = smp_core99_cpu_notify,
7154 };
7155 #endif /* CONFIG_HOTPLUG_CPU */
7156 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7157 index c797832..ce575c8 100644
7158 --- a/arch/s390/include/asm/atomic.h
7159 +++ b/arch/s390/include/asm/atomic.h
7160 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7161 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7162 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7163
7164 +#define atomic64_read_unchecked(v) atomic64_read(v)
7165 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7166 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7167 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7168 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7169 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7170 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7171 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7172 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7173 +
7174 #define smp_mb__before_atomic_dec() smp_mb()
7175 #define smp_mb__after_atomic_dec() smp_mb()
7176 #define smp_mb__before_atomic_inc() smp_mb()
7177 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7178 index 4d7ccac..d03d0ad 100644
7179 --- a/arch/s390/include/asm/cache.h
7180 +++ b/arch/s390/include/asm/cache.h
7181 @@ -9,8 +9,10 @@
7182 #ifndef __ARCH_S390_CACHE_H
7183 #define __ARCH_S390_CACHE_H
7184
7185 -#define L1_CACHE_BYTES 256
7186 +#include <linux/const.h>
7187 +
7188 #define L1_CACHE_SHIFT 8
7189 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7190 #define NET_SKB_PAD 32
7191
7192 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7193 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7194 index 1bfdf24..9c9ab2e 100644
7195 --- a/arch/s390/include/asm/elf.h
7196 +++ b/arch/s390/include/asm/elf.h
7197 @@ -160,8 +160,14 @@ extern unsigned int vdso_enabled;
7198 the loader. We need to make sure that it is out of the way of the program
7199 that it will "exec", and that there is sufficient room for the brk. */
7200
7201 -extern unsigned long randomize_et_dyn(unsigned long base);
7202 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7203 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7204 +
7205 +#ifdef CONFIG_PAX_ASLR
7206 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7207 +
7208 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7209 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7210 +#endif
7211
7212 /* This yields a mask that user programs can use to figure out what
7213 instruction set this CPU supports. */
7214 @@ -207,9 +213,6 @@ struct linux_binprm;
7215 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7216 int arch_setup_additional_pages(struct linux_binprm *, int);
7217
7218 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7219 -#define arch_randomize_brk arch_randomize_brk
7220 -
7221 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7222
7223 #endif
7224 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7225 index c4a93d6..4d2a9b4 100644
7226 --- a/arch/s390/include/asm/exec.h
7227 +++ b/arch/s390/include/asm/exec.h
7228 @@ -7,6 +7,6 @@
7229 #ifndef __ASM_EXEC_H
7230 #define __ASM_EXEC_H
7231
7232 -extern unsigned long arch_align_stack(unsigned long sp);
7233 +#define arch_align_stack(x) ((x) & ~0xfUL)
7234
7235 #endif /* __ASM_EXEC_H */
7236 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7237 index 9c33ed4..e40cbef 100644
7238 --- a/arch/s390/include/asm/uaccess.h
7239 +++ b/arch/s390/include/asm/uaccess.h
7240 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7241 copy_to_user(void __user *to, const void *from, unsigned long n)
7242 {
7243 might_fault();
7244 +
7245 + if ((long)n < 0)
7246 + return n;
7247 +
7248 return __copy_to_user(to, from, n);
7249 }
7250
7251 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7252 static inline unsigned long __must_check
7253 __copy_from_user(void *to, const void __user *from, unsigned long n)
7254 {
7255 + if ((long)n < 0)
7256 + return n;
7257 +
7258 if (__builtin_constant_p(n) && (n <= 256))
7259 return uaccess.copy_from_user_small(n, from, to);
7260 else
7261 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7262 static inline unsigned long __must_check
7263 copy_from_user(void *to, const void __user *from, unsigned long n)
7264 {
7265 - unsigned int sz = __compiletime_object_size(to);
7266 + size_t sz = __compiletime_object_size(to);
7267
7268 might_fault();
7269 - if (unlikely(sz != -1 && sz < n)) {
7270 +
7271 + if ((long)n < 0)
7272 + return n;
7273 +
7274 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7275 copy_from_user_overflow();
7276 return n;
7277 }
7278 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7279 index 7845e15..59c4353 100644
7280 --- a/arch/s390/kernel/module.c
7281 +++ b/arch/s390/kernel/module.c
7282 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7283
7284 /* Increase core size by size of got & plt and set start
7285 offsets for got and plt. */
7286 - me->core_size = ALIGN(me->core_size, 4);
7287 - me->arch.got_offset = me->core_size;
7288 - me->core_size += me->arch.got_size;
7289 - me->arch.plt_offset = me->core_size;
7290 - me->core_size += me->arch.plt_size;
7291 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7292 + me->arch.got_offset = me->core_size_rw;
7293 + me->core_size_rw += me->arch.got_size;
7294 + me->arch.plt_offset = me->core_size_rx;
7295 + me->core_size_rx += me->arch.plt_size;
7296 return 0;
7297 }
7298
7299 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7300 if (info->got_initialized == 0) {
7301 Elf_Addr *gotent;
7302
7303 - gotent = me->module_core + me->arch.got_offset +
7304 + gotent = me->module_core_rw + me->arch.got_offset +
7305 info->got_offset;
7306 *gotent = val;
7307 info->got_initialized = 1;
7308 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7309 rc = apply_rela_bits(loc, val, 0, 64, 0);
7310 else if (r_type == R_390_GOTENT ||
7311 r_type == R_390_GOTPLTENT) {
7312 - val += (Elf_Addr) me->module_core - loc;
7313 + val += (Elf_Addr) me->module_core_rw - loc;
7314 rc = apply_rela_bits(loc, val, 1, 32, 1);
7315 }
7316 break;
7317 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7318 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7319 if (info->plt_initialized == 0) {
7320 unsigned int *ip;
7321 - ip = me->module_core + me->arch.plt_offset +
7322 + ip = me->module_core_rx + me->arch.plt_offset +
7323 info->plt_offset;
7324 #ifndef CONFIG_64BIT
7325 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7326 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7327 val - loc + 0xffffUL < 0x1ffffeUL) ||
7328 (r_type == R_390_PLT32DBL &&
7329 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7330 - val = (Elf_Addr) me->module_core +
7331 + val = (Elf_Addr) me->module_core_rx +
7332 me->arch.plt_offset +
7333 info->plt_offset;
7334 val += rela->r_addend - loc;
7335 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7336 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7337 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7338 val = val + rela->r_addend -
7339 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7340 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7341 if (r_type == R_390_GOTOFF16)
7342 rc = apply_rela_bits(loc, val, 0, 16, 0);
7343 else if (r_type == R_390_GOTOFF32)
7344 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7345 break;
7346 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7347 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7348 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7349 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7350 rela->r_addend - loc;
7351 if (r_type == R_390_GOTPC)
7352 rc = apply_rela_bits(loc, val, 1, 32, 0);
7353 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7354 index 536d645..4a5bd9e 100644
7355 --- a/arch/s390/kernel/process.c
7356 +++ b/arch/s390/kernel/process.c
7357 @@ -250,39 +250,3 @@ unsigned long get_wchan(struct task_struct *p)
7358 }
7359 return 0;
7360 }
7361 -
7362 -unsigned long arch_align_stack(unsigned long sp)
7363 -{
7364 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7365 - sp -= get_random_int() & ~PAGE_MASK;
7366 - return sp & ~0xf;
7367 -}
7368 -
7369 -static inline unsigned long brk_rnd(void)
7370 -{
7371 - /* 8MB for 32bit, 1GB for 64bit */
7372 - if (is_32bit_task())
7373 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7374 - else
7375 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7376 -}
7377 -
7378 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7379 -{
7380 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7381 -
7382 - if (ret < mm->brk)
7383 - return mm->brk;
7384 - return ret;
7385 -}
7386 -
7387 -unsigned long randomize_et_dyn(unsigned long base)
7388 -{
7389 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7390 -
7391 - if (!(current->flags & PF_RANDOMIZE))
7392 - return base;
7393 - if (ret < base)
7394 - return base;
7395 - return ret;
7396 -}
7397 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7398 index 06bafec..2bca531 100644
7399 --- a/arch/s390/mm/mmap.c
7400 +++ b/arch/s390/mm/mmap.c
7401 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7402 */
7403 if (mmap_is_legacy()) {
7404 mm->mmap_base = TASK_UNMAPPED_BASE;
7405 +
7406 +#ifdef CONFIG_PAX_RANDMMAP
7407 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7408 + mm->mmap_base += mm->delta_mmap;
7409 +#endif
7410 +
7411 mm->get_unmapped_area = arch_get_unmapped_area;
7412 mm->unmap_area = arch_unmap_area;
7413 } else {
7414 mm->mmap_base = mmap_base();
7415 +
7416 +#ifdef CONFIG_PAX_RANDMMAP
7417 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7418 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7419 +#endif
7420 +
7421 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7422 mm->unmap_area = arch_unmap_area_topdown;
7423 }
7424 @@ -175,10 +187,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7425 */
7426 if (mmap_is_legacy()) {
7427 mm->mmap_base = TASK_UNMAPPED_BASE;
7428 +
7429 +#ifdef CONFIG_PAX_RANDMMAP
7430 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7431 + mm->mmap_base += mm->delta_mmap;
7432 +#endif
7433 +
7434 mm->get_unmapped_area = s390_get_unmapped_area;
7435 mm->unmap_area = arch_unmap_area;
7436 } else {
7437 mm->mmap_base = mmap_base();
7438 +
7439 +#ifdef CONFIG_PAX_RANDMMAP
7440 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7441 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7442 +#endif
7443 +
7444 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7445 mm->unmap_area = arch_unmap_area_topdown;
7446 }
7447 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7448 index ae3d59f..f65f075 100644
7449 --- a/arch/score/include/asm/cache.h
7450 +++ b/arch/score/include/asm/cache.h
7451 @@ -1,7 +1,9 @@
7452 #ifndef _ASM_SCORE_CACHE_H
7453 #define _ASM_SCORE_CACHE_H
7454
7455 +#include <linux/const.h>
7456 +
7457 #define L1_CACHE_SHIFT 4
7458 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7459 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7460
7461 #endif /* _ASM_SCORE_CACHE_H */
7462 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7463 index f9f3cd5..58ff438 100644
7464 --- a/arch/score/include/asm/exec.h
7465 +++ b/arch/score/include/asm/exec.h
7466 @@ -1,6 +1,6 @@
7467 #ifndef _ASM_SCORE_EXEC_H
7468 #define _ASM_SCORE_EXEC_H
7469
7470 -extern unsigned long arch_align_stack(unsigned long sp);
7471 +#define arch_align_stack(x) (x)
7472
7473 #endif /* _ASM_SCORE_EXEC_H */
7474 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7475 index 7956846..5f37677 100644
7476 --- a/arch/score/kernel/process.c
7477 +++ b/arch/score/kernel/process.c
7478 @@ -134,8 +134,3 @@ unsigned long get_wchan(struct task_struct *task)
7479
7480 return task_pt_regs(task)->cp0_epc;
7481 }
7482 -
7483 -unsigned long arch_align_stack(unsigned long sp)
7484 -{
7485 - return sp;
7486 -}
7487 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7488 index ef9e555..331bd29 100644
7489 --- a/arch/sh/include/asm/cache.h
7490 +++ b/arch/sh/include/asm/cache.h
7491 @@ -9,10 +9,11 @@
7492 #define __ASM_SH_CACHE_H
7493 #ifdef __KERNEL__
7494
7495 +#include <linux/const.h>
7496 #include <linux/init.h>
7497 #include <cpu/cache.h>
7498
7499 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7500 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7501
7502 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7503
7504 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7505 index 03f2b55..b0270327 100644
7506 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7507 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7508 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7509 return NOTIFY_OK;
7510 }
7511
7512 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7513 +static struct notifier_block shx3_cpu_notifier = {
7514 .notifier_call = shx3_cpu_callback,
7515 };
7516
7517 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7518 index 6777177..cb5e44f 100644
7519 --- a/arch/sh/mm/mmap.c
7520 +++ b/arch/sh/mm/mmap.c
7521 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7522 struct mm_struct *mm = current->mm;
7523 struct vm_area_struct *vma;
7524 int do_colour_align;
7525 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7526 struct vm_unmapped_area_info info;
7527
7528 if (flags & MAP_FIXED) {
7529 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7530 if (filp || (flags & MAP_SHARED))
7531 do_colour_align = 1;
7532
7533 +#ifdef CONFIG_PAX_RANDMMAP
7534 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7535 +#endif
7536 +
7537 if (addr) {
7538 if (do_colour_align)
7539 addr = COLOUR_ALIGN(addr, pgoff);
7540 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7541 addr = PAGE_ALIGN(addr);
7542
7543 vma = find_vma(mm, addr);
7544 - if (TASK_SIZE - len >= addr &&
7545 - (!vma || addr + len <= vma->vm_start))
7546 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7547 return addr;
7548 }
7549
7550 info.flags = 0;
7551 info.length = len;
7552 - info.low_limit = TASK_UNMAPPED_BASE;
7553 + info.low_limit = mm->mmap_base;
7554 info.high_limit = TASK_SIZE;
7555 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7556 info.align_offset = pgoff << PAGE_SHIFT;
7557 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7558 struct mm_struct *mm = current->mm;
7559 unsigned long addr = addr0;
7560 int do_colour_align;
7561 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7562 struct vm_unmapped_area_info info;
7563
7564 if (flags & MAP_FIXED) {
7565 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7566 if (filp || (flags & MAP_SHARED))
7567 do_colour_align = 1;
7568
7569 +#ifdef CONFIG_PAX_RANDMMAP
7570 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7571 +#endif
7572 +
7573 /* requesting a specific address */
7574 if (addr) {
7575 if (do_colour_align)
7576 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7577 addr = PAGE_ALIGN(addr);
7578
7579 vma = find_vma(mm, addr);
7580 - if (TASK_SIZE - len >= addr &&
7581 - (!vma || addr + len <= vma->vm_start))
7582 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7583 return addr;
7584 }
7585
7586 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7587 VM_BUG_ON(addr != -ENOMEM);
7588 info.flags = 0;
7589 info.low_limit = TASK_UNMAPPED_BASE;
7590 +
7591 +#ifdef CONFIG_PAX_RANDMMAP
7592 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7593 + info.low_limit += mm->delta_mmap;
7594 +#endif
7595 +
7596 info.high_limit = TASK_SIZE;
7597 addr = vm_unmapped_area(&info);
7598 }
7599 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7600 index be56a24..443328f 100644
7601 --- a/arch/sparc/include/asm/atomic_64.h
7602 +++ b/arch/sparc/include/asm/atomic_64.h
7603 @@ -14,18 +14,40 @@
7604 #define ATOMIC64_INIT(i) { (i) }
7605
7606 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7607 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
7608 +{
7609 + return v->counter;
7610 +}
7611 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
7612 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
7613 +{
7614 + return v->counter;
7615 +}
7616
7617 #define atomic_set(v, i) (((v)->counter) = i)
7618 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7619 +{
7620 + v->counter = i;
7621 +}
7622 #define atomic64_set(v, i) (((v)->counter) = i)
7623 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
7624 +{
7625 + v->counter = i;
7626 +}
7627
7628 extern void atomic_add(int, atomic_t *);
7629 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
7630 extern void atomic64_add(long, atomic64_t *);
7631 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
7632 extern void atomic_sub(int, atomic_t *);
7633 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
7634 extern void atomic64_sub(long, atomic64_t *);
7635 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
7636
7637 extern int atomic_add_ret(int, atomic_t *);
7638 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
7639 extern long atomic64_add_ret(long, atomic64_t *);
7640 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
7641 extern int atomic_sub_ret(int, atomic_t *);
7642 extern long atomic64_sub_ret(long, atomic64_t *);
7643
7644 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7645 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
7646
7647 #define atomic_inc_return(v) atomic_add_ret(1, v)
7648 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
7649 +{
7650 + return atomic_add_ret_unchecked(1, v);
7651 +}
7652 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
7653 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
7654 +{
7655 + return atomic64_add_ret_unchecked(1, v);
7656 +}
7657
7658 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
7659 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
7660
7661 #define atomic_add_return(i, v) atomic_add_ret(i, v)
7662 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
7663 +{
7664 + return atomic_add_ret_unchecked(i, v);
7665 +}
7666 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
7667 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
7668 +{
7669 + return atomic64_add_ret_unchecked(i, v);
7670 +}
7671
7672 /*
7673 * atomic_inc_and_test - increment and test
7674 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7675 * other cases.
7676 */
7677 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
7678 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
7679 +{
7680 + return atomic_inc_return_unchecked(v) == 0;
7681 +}
7682 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
7683
7684 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
7685 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7686 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
7687
7688 #define atomic_inc(v) atomic_add(1, v)
7689 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
7690 +{
7691 + atomic_add_unchecked(1, v);
7692 +}
7693 #define atomic64_inc(v) atomic64_add(1, v)
7694 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
7695 +{
7696 + atomic64_add_unchecked(1, v);
7697 +}
7698
7699 #define atomic_dec(v) atomic_sub(1, v)
7700 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
7701 +{
7702 + atomic_sub_unchecked(1, v);
7703 +}
7704 #define atomic64_dec(v) atomic64_sub(1, v)
7705 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
7706 +{
7707 + atomic64_sub_unchecked(1, v);
7708 +}
7709
7710 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
7711 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
7712
7713 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
7714 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
7715 +{
7716 + return cmpxchg(&v->counter, old, new);
7717 +}
7718 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
7719 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
7720 +{
7721 + return xchg(&v->counter, new);
7722 +}
7723
7724 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7725 {
7726 - int c, old;
7727 + int c, old, new;
7728 c = atomic_read(v);
7729 for (;;) {
7730 - if (unlikely(c == (u)))
7731 + if (unlikely(c == u))
7732 break;
7733 - old = atomic_cmpxchg((v), c, c + (a));
7734 +
7735 + asm volatile("addcc %2, %0, %0\n"
7736 +
7737 +#ifdef CONFIG_PAX_REFCOUNT
7738 + "tvs %%icc, 6\n"
7739 +#endif
7740 +
7741 + : "=r" (new)
7742 + : "0" (c), "ir" (a)
7743 + : "cc");
7744 +
7745 + old = atomic_cmpxchg(v, c, new);
7746 if (likely(old == c))
7747 break;
7748 c = old;
7749 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7750 #define atomic64_cmpxchg(v, o, n) \
7751 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
7752 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
7753 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
7754 +{
7755 + return xchg(&v->counter, new);
7756 +}
7757
7758 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
7759 {
7760 - long c, old;
7761 + long c, old, new;
7762 c = atomic64_read(v);
7763 for (;;) {
7764 - if (unlikely(c == (u)))
7765 + if (unlikely(c == u))
7766 break;
7767 - old = atomic64_cmpxchg((v), c, c + (a));
7768 +
7769 + asm volatile("addcc %2, %0, %0\n"
7770 +
7771 +#ifdef CONFIG_PAX_REFCOUNT
7772 + "tvs %%xcc, 6\n"
7773 +#endif
7774 +
7775 + : "=r" (new)
7776 + : "0" (c), "ir" (a)
7777 + : "cc");
7778 +
7779 + old = atomic64_cmpxchg(v, c, new);
7780 if (likely(old == c))
7781 break;
7782 c = old;
7783 }
7784 - return c != (u);
7785 + return c != u;
7786 }
7787
7788 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7789 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
7790 index 5bb6991..5c2132e 100644
7791 --- a/arch/sparc/include/asm/cache.h
7792 +++ b/arch/sparc/include/asm/cache.h
7793 @@ -7,10 +7,12 @@
7794 #ifndef _SPARC_CACHE_H
7795 #define _SPARC_CACHE_H
7796
7797 +#include <linux/const.h>
7798 +
7799 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
7800
7801 #define L1_CACHE_SHIFT 5
7802 -#define L1_CACHE_BYTES 32
7803 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7804
7805 #ifdef CONFIG_SPARC32
7806 #define SMP_CACHE_BYTES_SHIFT 5
7807 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
7808 index a24e41f..47677ff 100644
7809 --- a/arch/sparc/include/asm/elf_32.h
7810 +++ b/arch/sparc/include/asm/elf_32.h
7811 @@ -114,6 +114,13 @@ typedef struct {
7812
7813 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
7814
7815 +#ifdef CONFIG_PAX_ASLR
7816 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7817 +
7818 +#define PAX_DELTA_MMAP_LEN 16
7819 +#define PAX_DELTA_STACK_LEN 16
7820 +#endif
7821 +
7822 /* This yields a mask that user programs can use to figure out what
7823 instruction set this cpu supports. This can NOT be done in userspace
7824 on Sparc. */
7825 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
7826 index 370ca1e..d4f4a98 100644
7827 --- a/arch/sparc/include/asm/elf_64.h
7828 +++ b/arch/sparc/include/asm/elf_64.h
7829 @@ -189,6 +189,13 @@ typedef struct {
7830 #define ELF_ET_DYN_BASE 0x0000010000000000UL
7831 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
7832
7833 +#ifdef CONFIG_PAX_ASLR
7834 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
7835 +
7836 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
7837 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
7838 +#endif
7839 +
7840 extern unsigned long sparc64_elf_hwcap;
7841 #define ELF_HWCAP sparc64_elf_hwcap
7842
7843 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
7844 index 9b1c36d..209298b 100644
7845 --- a/arch/sparc/include/asm/pgalloc_32.h
7846 +++ b/arch/sparc/include/asm/pgalloc_32.h
7847 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
7848 }
7849
7850 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
7851 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
7852
7853 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
7854 unsigned long address)
7855 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
7856 index bcfe063..b333142 100644
7857 --- a/arch/sparc/include/asm/pgalloc_64.h
7858 +++ b/arch/sparc/include/asm/pgalloc_64.h
7859 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7860 }
7861
7862 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
7863 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
7864
7865 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
7866 {
7867 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
7868 index 6fc1348..390c50a 100644
7869 --- a/arch/sparc/include/asm/pgtable_32.h
7870 +++ b/arch/sparc/include/asm/pgtable_32.h
7871 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
7872 #define PAGE_SHARED SRMMU_PAGE_SHARED
7873 #define PAGE_COPY SRMMU_PAGE_COPY
7874 #define PAGE_READONLY SRMMU_PAGE_RDONLY
7875 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
7876 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
7877 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
7878 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
7879
7880 /* Top-level page directory - dummy used by init-mm.
7881 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
7882
7883 /* xwr */
7884 #define __P000 PAGE_NONE
7885 -#define __P001 PAGE_READONLY
7886 -#define __P010 PAGE_COPY
7887 -#define __P011 PAGE_COPY
7888 +#define __P001 PAGE_READONLY_NOEXEC
7889 +#define __P010 PAGE_COPY_NOEXEC
7890 +#define __P011 PAGE_COPY_NOEXEC
7891 #define __P100 PAGE_READONLY
7892 #define __P101 PAGE_READONLY
7893 #define __P110 PAGE_COPY
7894 #define __P111 PAGE_COPY
7895
7896 #define __S000 PAGE_NONE
7897 -#define __S001 PAGE_READONLY
7898 -#define __S010 PAGE_SHARED
7899 -#define __S011 PAGE_SHARED
7900 +#define __S001 PAGE_READONLY_NOEXEC
7901 +#define __S010 PAGE_SHARED_NOEXEC
7902 +#define __S011 PAGE_SHARED_NOEXEC
7903 #define __S100 PAGE_READONLY
7904 #define __S101 PAGE_READONLY
7905 #define __S110 PAGE_SHARED
7906 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
7907 index 79da178..c2eede8 100644
7908 --- a/arch/sparc/include/asm/pgtsrmmu.h
7909 +++ b/arch/sparc/include/asm/pgtsrmmu.h
7910 @@ -115,6 +115,11 @@
7911 SRMMU_EXEC | SRMMU_REF)
7912 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
7913 SRMMU_EXEC | SRMMU_REF)
7914 +
7915 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
7916 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7917 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7918 +
7919 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
7920 SRMMU_DIRTY | SRMMU_REF)
7921
7922 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
7923 index 9689176..63c18ea 100644
7924 --- a/arch/sparc/include/asm/spinlock_64.h
7925 +++ b/arch/sparc/include/asm/spinlock_64.h
7926 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
7927
7928 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
7929
7930 -static void inline arch_read_lock(arch_rwlock_t *lock)
7931 +static inline void arch_read_lock(arch_rwlock_t *lock)
7932 {
7933 unsigned long tmp1, tmp2;
7934
7935 __asm__ __volatile__ (
7936 "1: ldsw [%2], %0\n"
7937 " brlz,pn %0, 2f\n"
7938 -"4: add %0, 1, %1\n"
7939 +"4: addcc %0, 1, %1\n"
7940 +
7941 +#ifdef CONFIG_PAX_REFCOUNT
7942 +" tvs %%icc, 6\n"
7943 +#endif
7944 +
7945 " cas [%2], %0, %1\n"
7946 " cmp %0, %1\n"
7947 " bne,pn %%icc, 1b\n"
7948 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
7949 " .previous"
7950 : "=&r" (tmp1), "=&r" (tmp2)
7951 : "r" (lock)
7952 - : "memory");
7953 + : "memory", "cc");
7954 }
7955
7956 -static int inline arch_read_trylock(arch_rwlock_t *lock)
7957 +static inline int arch_read_trylock(arch_rwlock_t *lock)
7958 {
7959 int tmp1, tmp2;
7960
7961 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
7962 "1: ldsw [%2], %0\n"
7963 " brlz,a,pn %0, 2f\n"
7964 " mov 0, %0\n"
7965 -" add %0, 1, %1\n"
7966 +" addcc %0, 1, %1\n"
7967 +
7968 +#ifdef CONFIG_PAX_REFCOUNT
7969 +" tvs %%icc, 6\n"
7970 +#endif
7971 +
7972 " cas [%2], %0, %1\n"
7973 " cmp %0, %1\n"
7974 " bne,pn %%icc, 1b\n"
7975 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
7976 return tmp1;
7977 }
7978
7979 -static void inline arch_read_unlock(arch_rwlock_t *lock)
7980 +static inline void arch_read_unlock(arch_rwlock_t *lock)
7981 {
7982 unsigned long tmp1, tmp2;
7983
7984 __asm__ __volatile__(
7985 "1: lduw [%2], %0\n"
7986 -" sub %0, 1, %1\n"
7987 +" subcc %0, 1, %1\n"
7988 +
7989 +#ifdef CONFIG_PAX_REFCOUNT
7990 +" tvs %%icc, 6\n"
7991 +#endif
7992 +
7993 " cas [%2], %0, %1\n"
7994 " cmp %0, %1\n"
7995 " bne,pn %%xcc, 1b\n"
7996 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
7997 : "memory");
7998 }
7999
8000 -static void inline arch_write_lock(arch_rwlock_t *lock)
8001 +static inline void arch_write_lock(arch_rwlock_t *lock)
8002 {
8003 unsigned long mask, tmp1, tmp2;
8004
8005 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8006 : "memory");
8007 }
8008
8009 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8010 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8011 {
8012 __asm__ __volatile__(
8013 " stw %%g0, [%0]"
8014 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8015 : "memory");
8016 }
8017
8018 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8019 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8020 {
8021 unsigned long mask, tmp1, tmp2, result;
8022
8023 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8024 index 25849ae..924c54b 100644
8025 --- a/arch/sparc/include/asm/thread_info_32.h
8026 +++ b/arch/sparc/include/asm/thread_info_32.h
8027 @@ -49,6 +49,8 @@ struct thread_info {
8028 unsigned long w_saved;
8029
8030 struct restart_block restart_block;
8031 +
8032 + unsigned long lowest_stack;
8033 };
8034
8035 /*
8036 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8037 index 269bd92..e46a9b8 100644
8038 --- a/arch/sparc/include/asm/thread_info_64.h
8039 +++ b/arch/sparc/include/asm/thread_info_64.h
8040 @@ -63,6 +63,8 @@ struct thread_info {
8041 struct pt_regs *kern_una_regs;
8042 unsigned int kern_una_insn;
8043
8044 + unsigned long lowest_stack;
8045 +
8046 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8047 };
8048
8049 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8050 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8051 /* flag bit 6 is available */
8052 #define TIF_32BIT 7 /* 32-bit binary */
8053 -/* flag bit 8 is available */
8054 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8055 #define TIF_SECCOMP 9 /* secure computing */
8056 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8057 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8058 +
8059 /* NOTE: Thread flags >= 12 should be ones we have no interest
8060 * in using in assembly, else we can't use the mask as
8061 * an immediate value in instructions such as andcc.
8062 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8063 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8064 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8065 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8066 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8067
8068 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8069 _TIF_DO_NOTIFY_RESUME_MASK | \
8070 _TIF_NEED_RESCHED)
8071 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8072
8073 +#define _TIF_WORK_SYSCALL \
8074 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8075 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8076 +
8077 +
8078 /*
8079 * Thread-synchronous status.
8080 *
8081 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8082 index 0167d26..767bb0c 100644
8083 --- a/arch/sparc/include/asm/uaccess.h
8084 +++ b/arch/sparc/include/asm/uaccess.h
8085 @@ -1,5 +1,6 @@
8086 #ifndef ___ASM_SPARC_UACCESS_H
8087 #define ___ASM_SPARC_UACCESS_H
8088 +
8089 #if defined(__sparc__) && defined(__arch64__)
8090 #include <asm/uaccess_64.h>
8091 #else
8092 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8093 index 53a28dd..50c38c3 100644
8094 --- a/arch/sparc/include/asm/uaccess_32.h
8095 +++ b/arch/sparc/include/asm/uaccess_32.h
8096 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8097
8098 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8099 {
8100 - if (n && __access_ok((unsigned long) to, n))
8101 + if ((long)n < 0)
8102 + return n;
8103 +
8104 + if (n && __access_ok((unsigned long) to, n)) {
8105 + if (!__builtin_constant_p(n))
8106 + check_object_size(from, n, true);
8107 return __copy_user(to, (__force void __user *) from, n);
8108 - else
8109 + } else
8110 return n;
8111 }
8112
8113 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8114 {
8115 + if ((long)n < 0)
8116 + return n;
8117 +
8118 + if (!__builtin_constant_p(n))
8119 + check_object_size(from, n, true);
8120 +
8121 return __copy_user(to, (__force void __user *) from, n);
8122 }
8123
8124 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8125 {
8126 - if (n && __access_ok((unsigned long) from, n))
8127 + if ((long)n < 0)
8128 + return n;
8129 +
8130 + if (n && __access_ok((unsigned long) from, n)) {
8131 + if (!__builtin_constant_p(n))
8132 + check_object_size(to, n, false);
8133 return __copy_user((__force void __user *) to, from, n);
8134 - else
8135 + } else
8136 return n;
8137 }
8138
8139 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8140 {
8141 + if ((long)n < 0)
8142 + return n;
8143 +
8144 return __copy_user((__force void __user *) to, from, n);
8145 }
8146
8147 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8148 index e562d3c..191f176 100644
8149 --- a/arch/sparc/include/asm/uaccess_64.h
8150 +++ b/arch/sparc/include/asm/uaccess_64.h
8151 @@ -10,6 +10,7 @@
8152 #include <linux/compiler.h>
8153 #include <linux/string.h>
8154 #include <linux/thread_info.h>
8155 +#include <linux/kernel.h>
8156 #include <asm/asi.h>
8157 #include <asm/spitfire.h>
8158 #include <asm-generic/uaccess-unaligned.h>
8159 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8160 static inline unsigned long __must_check
8161 copy_from_user(void *to, const void __user *from, unsigned long size)
8162 {
8163 - unsigned long ret = ___copy_from_user(to, from, size);
8164 + unsigned long ret;
8165
8166 + if ((long)size < 0 || size > INT_MAX)
8167 + return size;
8168 +
8169 + if (!__builtin_constant_p(size))
8170 + check_object_size(to, size, false);
8171 +
8172 + ret = ___copy_from_user(to, from, size);
8173 if (unlikely(ret))
8174 ret = copy_from_user_fixup(to, from, size);
8175
8176 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8177 static inline unsigned long __must_check
8178 copy_to_user(void __user *to, const void *from, unsigned long size)
8179 {
8180 - unsigned long ret = ___copy_to_user(to, from, size);
8181 + unsigned long ret;
8182
8183 + if ((long)size < 0 || size > INT_MAX)
8184 + return size;
8185 +
8186 + if (!__builtin_constant_p(size))
8187 + check_object_size(from, size, true);
8188 +
8189 + ret = ___copy_to_user(to, from, size);
8190 if (unlikely(ret))
8191 ret = copy_to_user_fixup(to, from, size);
8192 return ret;
8193 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8194 index 6cf591b..b49e65a 100644
8195 --- a/arch/sparc/kernel/Makefile
8196 +++ b/arch/sparc/kernel/Makefile
8197 @@ -3,7 +3,7 @@
8198 #
8199
8200 asflags-y := -ansi
8201 -ccflags-y := -Werror
8202 +#ccflags-y := -Werror
8203
8204 extra-y := head_$(BITS).o
8205
8206 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8207 index 62eede1..9c5b904 100644
8208 --- a/arch/sparc/kernel/process_32.c
8209 +++ b/arch/sparc/kernel/process_32.c
8210 @@ -125,14 +125,14 @@ void show_regs(struct pt_regs *r)
8211
8212 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8213 r->psr, r->pc, r->npc, r->y, print_tainted());
8214 - printk("PC: <%pS>\n", (void *) r->pc);
8215 + printk("PC: <%pA>\n", (void *) r->pc);
8216 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8217 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8218 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8219 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8220 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8221 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8222 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8223 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8224
8225 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8226 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8227 @@ -167,7 +167,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8228 rw = (struct reg_window32 *) fp;
8229 pc = rw->ins[7];
8230 printk("[%08lx : ", pc);
8231 - printk("%pS ] ", (void *) pc);
8232 + printk("%pA ] ", (void *) pc);
8233 fp = rw->ins[6];
8234 } while (++count < 16);
8235 printk("\n");
8236 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8237 index cdb80b2..5ca141d 100644
8238 --- a/arch/sparc/kernel/process_64.c
8239 +++ b/arch/sparc/kernel/process_64.c
8240 @@ -181,14 +181,14 @@ static void show_regwindow(struct pt_regs *regs)
8241 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8242 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8243 if (regs->tstate & TSTATE_PRIV)
8244 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8245 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8246 }
8247
8248 void show_regs(struct pt_regs *regs)
8249 {
8250 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8251 regs->tpc, regs->tnpc, regs->y, print_tainted());
8252 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8253 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8254 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8255 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8256 regs->u_regs[3]);
8257 @@ -201,7 +201,7 @@ void show_regs(struct pt_regs *regs)
8258 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8259 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8260 regs->u_regs[15]);
8261 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8262 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8263 show_regwindow(regs);
8264 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8265 }
8266 @@ -290,7 +290,7 @@ void arch_trigger_all_cpu_backtrace(void)
8267 ((tp && tp->task) ? tp->task->pid : -1));
8268
8269 if (gp->tstate & TSTATE_PRIV) {
8270 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8271 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8272 (void *) gp->tpc,
8273 (void *) gp->o7,
8274 (void *) gp->i7,
8275 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
8276 index 9f20566..67eb41b 100644
8277 --- a/arch/sparc/kernel/prom_common.c
8278 +++ b/arch/sparc/kernel/prom_common.c
8279 @@ -143,7 +143,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
8280
8281 unsigned int prom_early_allocated __initdata;
8282
8283 -static struct of_pdt_ops prom_sparc_ops __initdata = {
8284 +static struct of_pdt_ops prom_sparc_ops __initconst = {
8285 .nextprop = prom_common_nextprop,
8286 .getproplen = prom_getproplen,
8287 .getproperty = prom_getproperty,
8288 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8289 index 7ff45e4..a58f271 100644
8290 --- a/arch/sparc/kernel/ptrace_64.c
8291 +++ b/arch/sparc/kernel/ptrace_64.c
8292 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8293 return ret;
8294 }
8295
8296 +#ifdef CONFIG_GRKERNSEC_SETXID
8297 +extern void gr_delayed_cred_worker(void);
8298 +#endif
8299 +
8300 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8301 {
8302 int ret = 0;
8303 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8304 /* do the secure computing check first */
8305 secure_computing_strict(regs->u_regs[UREG_G1]);
8306
8307 +#ifdef CONFIG_GRKERNSEC_SETXID
8308 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8309 + gr_delayed_cred_worker();
8310 +#endif
8311 +
8312 if (test_thread_flag(TIF_SYSCALL_TRACE))
8313 ret = tracehook_report_syscall_entry(regs);
8314
8315 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8316
8317 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8318 {
8319 +#ifdef CONFIG_GRKERNSEC_SETXID
8320 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8321 + gr_delayed_cred_worker();
8322 +#endif
8323 +
8324 audit_syscall_exit(regs);
8325
8326 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8327 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8328 index 3a8d184..49498a8 100644
8329 --- a/arch/sparc/kernel/sys_sparc_32.c
8330 +++ b/arch/sparc/kernel/sys_sparc_32.c
8331 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8332 if (len > TASK_SIZE - PAGE_SIZE)
8333 return -ENOMEM;
8334 if (!addr)
8335 - addr = TASK_UNMAPPED_BASE;
8336 + addr = current->mm->mmap_base;
8337
8338 info.flags = 0;
8339 info.length = len;
8340 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8341 index 708bc29..6bfdfad 100644
8342 --- a/arch/sparc/kernel/sys_sparc_64.c
8343 +++ b/arch/sparc/kernel/sys_sparc_64.c
8344 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8345 struct vm_area_struct * vma;
8346 unsigned long task_size = TASK_SIZE;
8347 int do_color_align;
8348 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8349 struct vm_unmapped_area_info info;
8350
8351 if (flags & MAP_FIXED) {
8352 /* We do not accept a shared mapping if it would violate
8353 * cache aliasing constraints.
8354 */
8355 - if ((flags & MAP_SHARED) &&
8356 + if ((filp || (flags & MAP_SHARED)) &&
8357 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8358 return -EINVAL;
8359 return addr;
8360 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8361 if (filp || (flags & MAP_SHARED))
8362 do_color_align = 1;
8363
8364 +#ifdef CONFIG_PAX_RANDMMAP
8365 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8366 +#endif
8367 +
8368 if (addr) {
8369 if (do_color_align)
8370 addr = COLOR_ALIGN(addr, pgoff);
8371 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8372 addr = PAGE_ALIGN(addr);
8373
8374 vma = find_vma(mm, addr);
8375 - if (task_size - len >= addr &&
8376 - (!vma || addr + len <= vma->vm_start))
8377 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8378 return addr;
8379 }
8380
8381 info.flags = 0;
8382 info.length = len;
8383 - info.low_limit = TASK_UNMAPPED_BASE;
8384 + info.low_limit = mm->mmap_base;
8385 info.high_limit = min(task_size, VA_EXCLUDE_START);
8386 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8387 info.align_offset = pgoff << PAGE_SHIFT;
8388 + info.threadstack_offset = offset;
8389 addr = vm_unmapped_area(&info);
8390
8391 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8392 VM_BUG_ON(addr != -ENOMEM);
8393 info.low_limit = VA_EXCLUDE_END;
8394 +
8395 +#ifdef CONFIG_PAX_RANDMMAP
8396 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8397 + info.low_limit += mm->delta_mmap;
8398 +#endif
8399 +
8400 info.high_limit = task_size;
8401 addr = vm_unmapped_area(&info);
8402 }
8403 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8404 unsigned long task_size = STACK_TOP32;
8405 unsigned long addr = addr0;
8406 int do_color_align;
8407 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8408 struct vm_unmapped_area_info info;
8409
8410 /* This should only ever run for 32-bit processes. */
8411 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8412 /* We do not accept a shared mapping if it would violate
8413 * cache aliasing constraints.
8414 */
8415 - if ((flags & MAP_SHARED) &&
8416 + if ((filp || (flags & MAP_SHARED)) &&
8417 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8418 return -EINVAL;
8419 return addr;
8420 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8421 if (filp || (flags & MAP_SHARED))
8422 do_color_align = 1;
8423
8424 +#ifdef CONFIG_PAX_RANDMMAP
8425 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8426 +#endif
8427 +
8428 /* requesting a specific address */
8429 if (addr) {
8430 if (do_color_align)
8431 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8432 addr = PAGE_ALIGN(addr);
8433
8434 vma = find_vma(mm, addr);
8435 - if (task_size - len >= addr &&
8436 - (!vma || addr + len <= vma->vm_start))
8437 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8438 return addr;
8439 }
8440
8441 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8442 info.high_limit = mm->mmap_base;
8443 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8444 info.align_offset = pgoff << PAGE_SHIFT;
8445 + info.threadstack_offset = offset;
8446 addr = vm_unmapped_area(&info);
8447
8448 /*
8449 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8450 VM_BUG_ON(addr != -ENOMEM);
8451 info.flags = 0;
8452 info.low_limit = TASK_UNMAPPED_BASE;
8453 +
8454 +#ifdef CONFIG_PAX_RANDMMAP
8455 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8456 + info.low_limit += mm->delta_mmap;
8457 +#endif
8458 +
8459 info.high_limit = STACK_TOP32;
8460 addr = vm_unmapped_area(&info);
8461 }
8462 @@ -264,6 +286,10 @@ static unsigned long mmap_rnd(void)
8463 {
8464 unsigned long rnd = 0UL;
8465
8466 +#ifdef CONFIG_PAX_RANDMMAP
8467 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8468 +#endif
8469 +
8470 if (current->flags & PF_RANDOMIZE) {
8471 unsigned long val = get_random_int();
8472 if (test_thread_flag(TIF_32BIT))
8473 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8474 gap == RLIM_INFINITY ||
8475 sysctl_legacy_va_layout) {
8476 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8477 +
8478 +#ifdef CONFIG_PAX_RANDMMAP
8479 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8480 + mm->mmap_base += mm->delta_mmap;
8481 +#endif
8482 +
8483 mm->get_unmapped_area = arch_get_unmapped_area;
8484 mm->unmap_area = arch_unmap_area;
8485 } else {
8486 @@ -301,6 +333,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8487 gap = (task_size / 6 * 5);
8488
8489 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8490 +
8491 +#ifdef CONFIG_PAX_RANDMMAP
8492 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8493 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8494 +#endif
8495 +
8496 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8497 mm->unmap_area = arch_unmap_area_topdown;
8498 }
8499 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8500 index 22a1098..6255eb9 100644
8501 --- a/arch/sparc/kernel/syscalls.S
8502 +++ b/arch/sparc/kernel/syscalls.S
8503 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
8504 #endif
8505 .align 32
8506 1: ldx [%g6 + TI_FLAGS], %l5
8507 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8508 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8509 be,pt %icc, rtrap
8510 nop
8511 call syscall_trace_leave
8512 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
8513
8514 srl %i5, 0, %o5 ! IEU1
8515 srl %i2, 0, %o2 ! IEU0 Group
8516 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8517 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8518 bne,pn %icc, linux_syscall_trace32 ! CTI
8519 mov %i0, %l5 ! IEU1
8520 call %l7 ! CTI Group brk forced
8521 @@ -207,7 +207,7 @@ linux_sparc_syscall:
8522
8523 mov %i3, %o3 ! IEU1
8524 mov %i4, %o4 ! IEU0 Group
8525 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8526 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8527 bne,pn %icc, linux_syscall_trace ! CTI Group
8528 mov %i0, %l5 ! IEU0
8529 2: call %l7 ! CTI Group brk forced
8530 @@ -223,7 +223,7 @@ ret_sys_call:
8531
8532 cmp %o0, -ERESTART_RESTARTBLOCK
8533 bgeu,pn %xcc, 1f
8534 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8535 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8536 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8537
8538 2:
8539 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8540 index 654e8aa..45f431b 100644
8541 --- a/arch/sparc/kernel/sysfs.c
8542 +++ b/arch/sparc/kernel/sysfs.c
8543 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8544 return NOTIFY_OK;
8545 }
8546
8547 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8548 +static struct notifier_block sysfs_cpu_nb = {
8549 .notifier_call = sysfs_cpu_notify,
8550 };
8551
8552 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8553 index 6629829..036032d 100644
8554 --- a/arch/sparc/kernel/traps_32.c
8555 +++ b/arch/sparc/kernel/traps_32.c
8556 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8557 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8558 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8559
8560 +extern void gr_handle_kernel_exploit(void);
8561 +
8562 void die_if_kernel(char *str, struct pt_regs *regs)
8563 {
8564 static int die_counter;
8565 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8566 count++ < 30 &&
8567 (((unsigned long) rw) >= PAGE_OFFSET) &&
8568 !(((unsigned long) rw) & 0x7)) {
8569 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8570 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8571 (void *) rw->ins[7]);
8572 rw = (struct reg_window32 *)rw->ins[6];
8573 }
8574 }
8575 printk("Instruction DUMP:");
8576 instruction_dump ((unsigned long *) regs->pc);
8577 - if(regs->psr & PSR_PS)
8578 + if(regs->psr & PSR_PS) {
8579 + gr_handle_kernel_exploit();
8580 do_exit(SIGKILL);
8581 + }
8582 do_exit(SIGSEGV);
8583 }
8584
8585 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8586 index 8d38ca9..845b1d6 100644
8587 --- a/arch/sparc/kernel/traps_64.c
8588 +++ b/arch/sparc/kernel/traps_64.c
8589 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8590 i + 1,
8591 p->trapstack[i].tstate, p->trapstack[i].tpc,
8592 p->trapstack[i].tnpc, p->trapstack[i].tt);
8593 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8594 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8595 }
8596 }
8597
8598 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8599
8600 lvl -= 0x100;
8601 if (regs->tstate & TSTATE_PRIV) {
8602 +
8603 +#ifdef CONFIG_PAX_REFCOUNT
8604 + if (lvl == 6)
8605 + pax_report_refcount_overflow(regs);
8606 +#endif
8607 +
8608 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8609 die_if_kernel(buffer, regs);
8610 }
8611 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8612 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8613 {
8614 char buffer[32];
8615 -
8616 +
8617 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
8618 0, lvl, SIGTRAP) == NOTIFY_STOP)
8619 return;
8620
8621 +#ifdef CONFIG_PAX_REFCOUNT
8622 + if (lvl == 6)
8623 + pax_report_refcount_overflow(regs);
8624 +#endif
8625 +
8626 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
8627
8628 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
8629 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
8630 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
8631 printk("%s" "ERROR(%d): ",
8632 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
8633 - printk("TPC<%pS>\n", (void *) regs->tpc);
8634 + printk("TPC<%pA>\n", (void *) regs->tpc);
8635 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
8636 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
8637 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
8638 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8639 smp_processor_id(),
8640 (type & 0x1) ? 'I' : 'D',
8641 regs->tpc);
8642 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
8643 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
8644 panic("Irrecoverable Cheetah+ parity error.");
8645 }
8646
8647 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8648 smp_processor_id(),
8649 (type & 0x1) ? 'I' : 'D',
8650 regs->tpc);
8651 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
8652 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
8653 }
8654
8655 struct sun4v_error_entry {
8656 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
8657
8658 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
8659 regs->tpc, tl);
8660 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
8661 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
8662 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8663 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
8664 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
8665 (void *) regs->u_regs[UREG_I7]);
8666 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
8667 "pte[%lx] error[%lx]\n",
8668 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
8669
8670 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
8671 regs->tpc, tl);
8672 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
8673 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
8674 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8675 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
8676 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
8677 (void *) regs->u_regs[UREG_I7]);
8678 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
8679 "pte[%lx] error[%lx]\n",
8680 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8681 fp = (unsigned long)sf->fp + STACK_BIAS;
8682 }
8683
8684 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8685 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8686 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8687 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
8688 int index = tsk->curr_ret_stack;
8689 if (tsk->ret_stack && index >= graph) {
8690 pc = tsk->ret_stack[index - graph].ret;
8691 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8692 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8693 graph++;
8694 }
8695 }
8696 @@ -2367,6 +2378,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
8697 return (struct reg_window *) (fp + STACK_BIAS);
8698 }
8699
8700 +extern void gr_handle_kernel_exploit(void);
8701 +
8702 void die_if_kernel(char *str, struct pt_regs *regs)
8703 {
8704 static int die_counter;
8705 @@ -2395,7 +2408,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8706 while (rw &&
8707 count++ < 30 &&
8708 kstack_valid(tp, (unsigned long) rw)) {
8709 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
8710 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
8711 (void *) rw->ins[7]);
8712
8713 rw = kernel_stack_up(rw);
8714 @@ -2408,8 +2421,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8715 }
8716 user_instruction_dump ((unsigned int __user *) regs->tpc);
8717 }
8718 - if (regs->tstate & TSTATE_PRIV)
8719 + if (regs->tstate & TSTATE_PRIV) {
8720 + gr_handle_kernel_exploit();
8721 do_exit(SIGKILL);
8722 + }
8723 do_exit(SIGSEGV);
8724 }
8725 EXPORT_SYMBOL(die_if_kernel);
8726 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
8727 index 8201c25e..072a2a7 100644
8728 --- a/arch/sparc/kernel/unaligned_64.c
8729 +++ b/arch/sparc/kernel/unaligned_64.c
8730 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
8731 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
8732
8733 if (__ratelimit(&ratelimit)) {
8734 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
8735 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
8736 regs->tpc, (void *) regs->tpc);
8737 }
8738 }
8739 diff --git a/arch/sparc/kernel/us3_cpufreq.c b/arch/sparc/kernel/us3_cpufreq.c
8740 index eb1624b..55100de 100644
8741 --- a/arch/sparc/kernel/us3_cpufreq.c
8742 +++ b/arch/sparc/kernel/us3_cpufreq.c
8743 @@ -18,14 +18,12 @@
8744 #include <asm/head.h>
8745 #include <asm/timer.h>
8746
8747 -static struct cpufreq_driver *cpufreq_us3_driver;
8748 -
8749 struct us3_freq_percpu_info {
8750 struct cpufreq_frequency_table table[4];
8751 };
8752
8753 /* Indexed by cpu number. */
8754 -static struct us3_freq_percpu_info *us3_freq_table;
8755 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
8756
8757 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
8758 * in the Safari config register.
8759 @@ -191,12 +189,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
8760
8761 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
8762 {
8763 - if (cpufreq_us3_driver)
8764 - us3_set_cpu_divider_index(policy->cpu, 0);
8765 + us3_set_cpu_divider_index(policy->cpu, 0);
8766
8767 return 0;
8768 }
8769
8770 +static int __init us3_freq_init(void);
8771 +static void __exit us3_freq_exit(void);
8772 +
8773 +static struct cpufreq_driver cpufreq_us3_driver = {
8774 + .init = us3_freq_cpu_init,
8775 + .verify = us3_freq_verify,
8776 + .target = us3_freq_target,
8777 + .get = us3_freq_get,
8778 + .exit = us3_freq_cpu_exit,
8779 + .owner = THIS_MODULE,
8780 + .name = "UltraSPARC-III",
8781 +
8782 +};
8783 +
8784 static int __init us3_freq_init(void)
8785 {
8786 unsigned long manuf, impl, ver;
8787 @@ -213,57 +224,15 @@ static int __init us3_freq_init(void)
8788 (impl == CHEETAH_IMPL ||
8789 impl == CHEETAH_PLUS_IMPL ||
8790 impl == JAGUAR_IMPL ||
8791 - impl == PANTHER_IMPL)) {
8792 - struct cpufreq_driver *driver;
8793 -
8794 - ret = -ENOMEM;
8795 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
8796 - if (!driver)
8797 - goto err_out;
8798 -
8799 - us3_freq_table = kzalloc(
8800 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
8801 - GFP_KERNEL);
8802 - if (!us3_freq_table)
8803 - goto err_out;
8804 -
8805 - driver->init = us3_freq_cpu_init;
8806 - driver->verify = us3_freq_verify;
8807 - driver->target = us3_freq_target;
8808 - driver->get = us3_freq_get;
8809 - driver->exit = us3_freq_cpu_exit;
8810 - driver->owner = THIS_MODULE,
8811 - strcpy(driver->name, "UltraSPARC-III");
8812 -
8813 - cpufreq_us3_driver = driver;
8814 - ret = cpufreq_register_driver(driver);
8815 - if (ret)
8816 - goto err_out;
8817 -
8818 - return 0;
8819 -
8820 -err_out:
8821 - if (driver) {
8822 - kfree(driver);
8823 - cpufreq_us3_driver = NULL;
8824 - }
8825 - kfree(us3_freq_table);
8826 - us3_freq_table = NULL;
8827 - return ret;
8828 - }
8829 + impl == PANTHER_IMPL))
8830 + return cpufreq_register_driver(&cpufreq_us3_driver);
8831
8832 return -ENODEV;
8833 }
8834
8835 static void __exit us3_freq_exit(void)
8836 {
8837 - if (cpufreq_us3_driver) {
8838 - cpufreq_unregister_driver(cpufreq_us3_driver);
8839 - kfree(cpufreq_us3_driver);
8840 - cpufreq_us3_driver = NULL;
8841 - kfree(us3_freq_table);
8842 - us3_freq_table = NULL;
8843 - }
8844 + cpufreq_unregister_driver(&cpufreq_us3_driver);
8845 }
8846
8847 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
8848 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
8849 index 8410065f2..4fd4ca22 100644
8850 --- a/arch/sparc/lib/Makefile
8851 +++ b/arch/sparc/lib/Makefile
8852 @@ -2,7 +2,7 @@
8853 #
8854
8855 asflags-y := -ansi -DST_DIV0=0x02
8856 -ccflags-y := -Werror
8857 +#ccflags-y := -Werror
8858
8859 lib-$(CONFIG_SPARC32) += ashrdi3.o
8860 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
8861 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
8862 index 85c233d..68500e0 100644
8863 --- a/arch/sparc/lib/atomic_64.S
8864 +++ b/arch/sparc/lib/atomic_64.S
8865 @@ -17,7 +17,12 @@
8866 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8867 BACKOFF_SETUP(%o2)
8868 1: lduw [%o1], %g1
8869 - add %g1, %o0, %g7
8870 + addcc %g1, %o0, %g7
8871 +
8872 +#ifdef CONFIG_PAX_REFCOUNT
8873 + tvs %icc, 6
8874 +#endif
8875 +
8876 cas [%o1], %g1, %g7
8877 cmp %g1, %g7
8878 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8879 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8880 2: BACKOFF_SPIN(%o2, %o3, 1b)
8881 ENDPROC(atomic_add)
8882
8883 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8884 + BACKOFF_SETUP(%o2)
8885 +1: lduw [%o1], %g1
8886 + add %g1, %o0, %g7
8887 + cas [%o1], %g1, %g7
8888 + cmp %g1, %g7
8889 + bne,pn %icc, 2f
8890 + nop
8891 + retl
8892 + nop
8893 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8894 +ENDPROC(atomic_add_unchecked)
8895 +
8896 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8897 BACKOFF_SETUP(%o2)
8898 1: lduw [%o1], %g1
8899 - sub %g1, %o0, %g7
8900 + subcc %g1, %o0, %g7
8901 +
8902 +#ifdef CONFIG_PAX_REFCOUNT
8903 + tvs %icc, 6
8904 +#endif
8905 +
8906 cas [%o1], %g1, %g7
8907 cmp %g1, %g7
8908 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8909 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8910 2: BACKOFF_SPIN(%o2, %o3, 1b)
8911 ENDPROC(atomic_sub)
8912
8913 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
8914 + BACKOFF_SETUP(%o2)
8915 +1: lduw [%o1], %g1
8916 + sub %g1, %o0, %g7
8917 + cas [%o1], %g1, %g7
8918 + cmp %g1, %g7
8919 + bne,pn %icc, 2f
8920 + nop
8921 + retl
8922 + nop
8923 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8924 +ENDPROC(atomic_sub_unchecked)
8925 +
8926 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8927 BACKOFF_SETUP(%o2)
8928 1: lduw [%o1], %g1
8929 - add %g1, %o0, %g7
8930 + addcc %g1, %o0, %g7
8931 +
8932 +#ifdef CONFIG_PAX_REFCOUNT
8933 + tvs %icc, 6
8934 +#endif
8935 +
8936 cas [%o1], %g1, %g7
8937 cmp %g1, %g7
8938 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8939 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8940 2: BACKOFF_SPIN(%o2, %o3, 1b)
8941 ENDPROC(atomic_add_ret)
8942
8943 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8944 + BACKOFF_SETUP(%o2)
8945 +1: lduw [%o1], %g1
8946 + addcc %g1, %o0, %g7
8947 + cas [%o1], %g1, %g7
8948 + cmp %g1, %g7
8949 + bne,pn %icc, 2f
8950 + add %g7, %o0, %g7
8951 + sra %g7, 0, %o0
8952 + retl
8953 + nop
8954 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8955 +ENDPROC(atomic_add_ret_unchecked)
8956 +
8957 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
8958 BACKOFF_SETUP(%o2)
8959 1: lduw [%o1], %g1
8960 - sub %g1, %o0, %g7
8961 + subcc %g1, %o0, %g7
8962 +
8963 +#ifdef CONFIG_PAX_REFCOUNT
8964 + tvs %icc, 6
8965 +#endif
8966 +
8967 cas [%o1], %g1, %g7
8968 cmp %g1, %g7
8969 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8970 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
8971 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
8972 BACKOFF_SETUP(%o2)
8973 1: ldx [%o1], %g1
8974 - add %g1, %o0, %g7
8975 + addcc %g1, %o0, %g7
8976 +
8977 +#ifdef CONFIG_PAX_REFCOUNT
8978 + tvs %xcc, 6
8979 +#endif
8980 +
8981 casx [%o1], %g1, %g7
8982 cmp %g1, %g7
8983 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
8984 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
8985 2: BACKOFF_SPIN(%o2, %o3, 1b)
8986 ENDPROC(atomic64_add)
8987
8988 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8989 + BACKOFF_SETUP(%o2)
8990 +1: ldx [%o1], %g1
8991 + addcc %g1, %o0, %g7
8992 + casx [%o1], %g1, %g7
8993 + cmp %g1, %g7
8994 + bne,pn %xcc, 2f
8995 + nop
8996 + retl
8997 + nop
8998 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8999 +ENDPROC(atomic64_add_unchecked)
9000 +
9001 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9002 BACKOFF_SETUP(%o2)
9003 1: ldx [%o1], %g1
9004 - sub %g1, %o0, %g7
9005 + subcc %g1, %o0, %g7
9006 +
9007 +#ifdef CONFIG_PAX_REFCOUNT
9008 + tvs %xcc, 6
9009 +#endif
9010 +
9011 casx [%o1], %g1, %g7
9012 cmp %g1, %g7
9013 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9014 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9015 2: BACKOFF_SPIN(%o2, %o3, 1b)
9016 ENDPROC(atomic64_sub)
9017
9018 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9019 + BACKOFF_SETUP(%o2)
9020 +1: ldx [%o1], %g1
9021 + subcc %g1, %o0, %g7
9022 + casx [%o1], %g1, %g7
9023 + cmp %g1, %g7
9024 + bne,pn %xcc, 2f
9025 + nop
9026 + retl
9027 + nop
9028 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9029 +ENDPROC(atomic64_sub_unchecked)
9030 +
9031 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9032 BACKOFF_SETUP(%o2)
9033 1: ldx [%o1], %g1
9034 - add %g1, %o0, %g7
9035 + addcc %g1, %o0, %g7
9036 +
9037 +#ifdef CONFIG_PAX_REFCOUNT
9038 + tvs %xcc, 6
9039 +#endif
9040 +
9041 casx [%o1], %g1, %g7
9042 cmp %g1, %g7
9043 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9044 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9045 2: BACKOFF_SPIN(%o2, %o3, 1b)
9046 ENDPROC(atomic64_add_ret)
9047
9048 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9049 + BACKOFF_SETUP(%o2)
9050 +1: ldx [%o1], %g1
9051 + addcc %g1, %o0, %g7
9052 + casx [%o1], %g1, %g7
9053 + cmp %g1, %g7
9054 + bne,pn %xcc, 2f
9055 + add %g7, %o0, %g7
9056 + mov %g7, %o0
9057 + retl
9058 + nop
9059 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9060 +ENDPROC(atomic64_add_ret_unchecked)
9061 +
9062 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9063 BACKOFF_SETUP(%o2)
9064 1: ldx [%o1], %g1
9065 - sub %g1, %o0, %g7
9066 + subcc %g1, %o0, %g7
9067 +
9068 +#ifdef CONFIG_PAX_REFCOUNT
9069 + tvs %xcc, 6
9070 +#endif
9071 +
9072 casx [%o1], %g1, %g7
9073 cmp %g1, %g7
9074 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9075 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9076 index 0c4e35e..745d3e4 100644
9077 --- a/arch/sparc/lib/ksyms.c
9078 +++ b/arch/sparc/lib/ksyms.c
9079 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9080
9081 /* Atomic counter implementation. */
9082 EXPORT_SYMBOL(atomic_add);
9083 +EXPORT_SYMBOL(atomic_add_unchecked);
9084 EXPORT_SYMBOL(atomic_add_ret);
9085 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9086 EXPORT_SYMBOL(atomic_sub);
9087 +EXPORT_SYMBOL(atomic_sub_unchecked);
9088 EXPORT_SYMBOL(atomic_sub_ret);
9089 EXPORT_SYMBOL(atomic64_add);
9090 +EXPORT_SYMBOL(atomic64_add_unchecked);
9091 EXPORT_SYMBOL(atomic64_add_ret);
9092 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9093 EXPORT_SYMBOL(atomic64_sub);
9094 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9095 EXPORT_SYMBOL(atomic64_sub_ret);
9096 EXPORT_SYMBOL(atomic64_dec_if_positive);
9097
9098 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9099 index 30c3ecc..736f015 100644
9100 --- a/arch/sparc/mm/Makefile
9101 +++ b/arch/sparc/mm/Makefile
9102 @@ -2,7 +2,7 @@
9103 #
9104
9105 asflags-y := -ansi
9106 -ccflags-y := -Werror
9107 +#ccflags-y := -Werror
9108
9109 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9110 obj-y += fault_$(BITS).o
9111 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9112 index e98bfda..ea8d221 100644
9113 --- a/arch/sparc/mm/fault_32.c
9114 +++ b/arch/sparc/mm/fault_32.c
9115 @@ -21,6 +21,9 @@
9116 #include <linux/perf_event.h>
9117 #include <linux/interrupt.h>
9118 #include <linux/kdebug.h>
9119 +#include <linux/slab.h>
9120 +#include <linux/pagemap.h>
9121 +#include <linux/compiler.h>
9122
9123 #include <asm/page.h>
9124 #include <asm/pgtable.h>
9125 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9126 return safe_compute_effective_address(regs, insn);
9127 }
9128
9129 +#ifdef CONFIG_PAX_PAGEEXEC
9130 +#ifdef CONFIG_PAX_DLRESOLVE
9131 +static void pax_emuplt_close(struct vm_area_struct *vma)
9132 +{
9133 + vma->vm_mm->call_dl_resolve = 0UL;
9134 +}
9135 +
9136 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9137 +{
9138 + unsigned int *kaddr;
9139 +
9140 + vmf->page = alloc_page(GFP_HIGHUSER);
9141 + if (!vmf->page)
9142 + return VM_FAULT_OOM;
9143 +
9144 + kaddr = kmap(vmf->page);
9145 + memset(kaddr, 0, PAGE_SIZE);
9146 + kaddr[0] = 0x9DE3BFA8U; /* save */
9147 + flush_dcache_page(vmf->page);
9148 + kunmap(vmf->page);
9149 + return VM_FAULT_MAJOR;
9150 +}
9151 +
9152 +static const struct vm_operations_struct pax_vm_ops = {
9153 + .close = pax_emuplt_close,
9154 + .fault = pax_emuplt_fault
9155 +};
9156 +
9157 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9158 +{
9159 + int ret;
9160 +
9161 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9162 + vma->vm_mm = current->mm;
9163 + vma->vm_start = addr;
9164 + vma->vm_end = addr + PAGE_SIZE;
9165 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9166 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9167 + vma->vm_ops = &pax_vm_ops;
9168 +
9169 + ret = insert_vm_struct(current->mm, vma);
9170 + if (ret)
9171 + return ret;
9172 +
9173 + ++current->mm->total_vm;
9174 + return 0;
9175 +}
9176 +#endif
9177 +
9178 +/*
9179 + * PaX: decide what to do with offenders (regs->pc = fault address)
9180 + *
9181 + * returns 1 when task should be killed
9182 + * 2 when patched PLT trampoline was detected
9183 + * 3 when unpatched PLT trampoline was detected
9184 + */
9185 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9186 +{
9187 +
9188 +#ifdef CONFIG_PAX_EMUPLT
9189 + int err;
9190 +
9191 + do { /* PaX: patched PLT emulation #1 */
9192 + unsigned int sethi1, sethi2, jmpl;
9193 +
9194 + err = get_user(sethi1, (unsigned int *)regs->pc);
9195 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9196 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9197 +
9198 + if (err)
9199 + break;
9200 +
9201 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9202 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9203 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9204 + {
9205 + unsigned int addr;
9206 +
9207 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9208 + addr = regs->u_regs[UREG_G1];
9209 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9210 + regs->pc = addr;
9211 + regs->npc = addr+4;
9212 + return 2;
9213 + }
9214 + } while (0);
9215 +
9216 + do { /* PaX: patched PLT emulation #2 */
9217 + unsigned int ba;
9218 +
9219 + err = get_user(ba, (unsigned int *)regs->pc);
9220 +
9221 + if (err)
9222 + break;
9223 +
9224 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9225 + unsigned int addr;
9226 +
9227 + if ((ba & 0xFFC00000U) == 0x30800000U)
9228 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9229 + else
9230 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9231 + regs->pc = addr;
9232 + regs->npc = addr+4;
9233 + return 2;
9234 + }
9235 + } while (0);
9236 +
9237 + do { /* PaX: patched PLT emulation #3 */
9238 + unsigned int sethi, bajmpl, nop;
9239 +
9240 + err = get_user(sethi, (unsigned int *)regs->pc);
9241 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9242 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9243 +
9244 + if (err)
9245 + break;
9246 +
9247 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9248 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9249 + nop == 0x01000000U)
9250 + {
9251 + unsigned int addr;
9252 +
9253 + addr = (sethi & 0x003FFFFFU) << 10;
9254 + regs->u_regs[UREG_G1] = addr;
9255 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9256 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9257 + else
9258 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9259 + regs->pc = addr;
9260 + regs->npc = addr+4;
9261 + return 2;
9262 + }
9263 + } while (0);
9264 +
9265 + do { /* PaX: unpatched PLT emulation step 1 */
9266 + unsigned int sethi, ba, nop;
9267 +
9268 + err = get_user(sethi, (unsigned int *)regs->pc);
9269 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9270 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9271 +
9272 + if (err)
9273 + break;
9274 +
9275 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9276 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9277 + nop == 0x01000000U)
9278 + {
9279 + unsigned int addr, save, call;
9280 +
9281 + if ((ba & 0xFFC00000U) == 0x30800000U)
9282 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9283 + else
9284 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9285 +
9286 + err = get_user(save, (unsigned int *)addr);
9287 + err |= get_user(call, (unsigned int *)(addr+4));
9288 + err |= get_user(nop, (unsigned int *)(addr+8));
9289 + if (err)
9290 + break;
9291 +
9292 +#ifdef CONFIG_PAX_DLRESOLVE
9293 + if (save == 0x9DE3BFA8U &&
9294 + (call & 0xC0000000U) == 0x40000000U &&
9295 + nop == 0x01000000U)
9296 + {
9297 + struct vm_area_struct *vma;
9298 + unsigned long call_dl_resolve;
9299 +
9300 + down_read(&current->mm->mmap_sem);
9301 + call_dl_resolve = current->mm->call_dl_resolve;
9302 + up_read(&current->mm->mmap_sem);
9303 + if (likely(call_dl_resolve))
9304 + goto emulate;
9305 +
9306 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9307 +
9308 + down_write(&current->mm->mmap_sem);
9309 + if (current->mm->call_dl_resolve) {
9310 + call_dl_resolve = current->mm->call_dl_resolve;
9311 + up_write(&current->mm->mmap_sem);
9312 + if (vma)
9313 + kmem_cache_free(vm_area_cachep, vma);
9314 + goto emulate;
9315 + }
9316 +
9317 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9318 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9319 + up_write(&current->mm->mmap_sem);
9320 + if (vma)
9321 + kmem_cache_free(vm_area_cachep, vma);
9322 + return 1;
9323 + }
9324 +
9325 + if (pax_insert_vma(vma, call_dl_resolve)) {
9326 + up_write(&current->mm->mmap_sem);
9327 + kmem_cache_free(vm_area_cachep, vma);
9328 + return 1;
9329 + }
9330 +
9331 + current->mm->call_dl_resolve = call_dl_resolve;
9332 + up_write(&current->mm->mmap_sem);
9333 +
9334 +emulate:
9335 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9336 + regs->pc = call_dl_resolve;
9337 + regs->npc = addr+4;
9338 + return 3;
9339 + }
9340 +#endif
9341 +
9342 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9343 + if ((save & 0xFFC00000U) == 0x05000000U &&
9344 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9345 + nop == 0x01000000U)
9346 + {
9347 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9348 + regs->u_regs[UREG_G2] = addr + 4;
9349 + addr = (save & 0x003FFFFFU) << 10;
9350 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9351 + regs->pc = addr;
9352 + regs->npc = addr+4;
9353 + return 3;
9354 + }
9355 + }
9356 + } while (0);
9357 +
9358 + do { /* PaX: unpatched PLT emulation step 2 */
9359 + unsigned int save, call, nop;
9360 +
9361 + err = get_user(save, (unsigned int *)(regs->pc-4));
9362 + err |= get_user(call, (unsigned int *)regs->pc);
9363 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9364 + if (err)
9365 + break;
9366 +
9367 + if (save == 0x9DE3BFA8U &&
9368 + (call & 0xC0000000U) == 0x40000000U &&
9369 + nop == 0x01000000U)
9370 + {
9371 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9372 +
9373 + regs->u_regs[UREG_RETPC] = regs->pc;
9374 + regs->pc = dl_resolve;
9375 + regs->npc = dl_resolve+4;
9376 + return 3;
9377 + }
9378 + } while (0);
9379 +#endif
9380 +
9381 + return 1;
9382 +}
9383 +
9384 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9385 +{
9386 + unsigned long i;
9387 +
9388 + printk(KERN_ERR "PAX: bytes at PC: ");
9389 + for (i = 0; i < 8; i++) {
9390 + unsigned int c;
9391 + if (get_user(c, (unsigned int *)pc+i))
9392 + printk(KERN_CONT "???????? ");
9393 + else
9394 + printk(KERN_CONT "%08x ", c);
9395 + }
9396 + printk("\n");
9397 +}
9398 +#endif
9399 +
9400 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9401 int text_fault)
9402 {
9403 @@ -230,6 +504,24 @@ good_area:
9404 if (!(vma->vm_flags & VM_WRITE))
9405 goto bad_area;
9406 } else {
9407 +
9408 +#ifdef CONFIG_PAX_PAGEEXEC
9409 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9410 + up_read(&mm->mmap_sem);
9411 + switch (pax_handle_fetch_fault(regs)) {
9412 +
9413 +#ifdef CONFIG_PAX_EMUPLT
9414 + case 2:
9415 + case 3:
9416 + return;
9417 +#endif
9418 +
9419 + }
9420 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9421 + do_group_exit(SIGKILL);
9422 + }
9423 +#endif
9424 +
9425 /* Allow reads even for write-only mappings */
9426 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9427 goto bad_area;
9428 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9429 index 5062ff3..e0b75f3 100644
9430 --- a/arch/sparc/mm/fault_64.c
9431 +++ b/arch/sparc/mm/fault_64.c
9432 @@ -21,6 +21,9 @@
9433 #include <linux/kprobes.h>
9434 #include <linux/kdebug.h>
9435 #include <linux/percpu.h>
9436 +#include <linux/slab.h>
9437 +#include <linux/pagemap.h>
9438 +#include <linux/compiler.h>
9439
9440 #include <asm/page.h>
9441 #include <asm/pgtable.h>
9442 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9443 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9444 regs->tpc);
9445 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9446 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9447 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9448 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9449 dump_stack();
9450 unhandled_fault(regs->tpc, current, regs);
9451 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9452 show_regs(regs);
9453 }
9454
9455 +#ifdef CONFIG_PAX_PAGEEXEC
9456 +#ifdef CONFIG_PAX_DLRESOLVE
9457 +static void pax_emuplt_close(struct vm_area_struct *vma)
9458 +{
9459 + vma->vm_mm->call_dl_resolve = 0UL;
9460 +}
9461 +
9462 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9463 +{
9464 + unsigned int *kaddr;
9465 +
9466 + vmf->page = alloc_page(GFP_HIGHUSER);
9467 + if (!vmf->page)
9468 + return VM_FAULT_OOM;
9469 +
9470 + kaddr = kmap(vmf->page);
9471 + memset(kaddr, 0, PAGE_SIZE);
9472 + kaddr[0] = 0x9DE3BFA8U; /* save */
9473 + flush_dcache_page(vmf->page);
9474 + kunmap(vmf->page);
9475 + return VM_FAULT_MAJOR;
9476 +}
9477 +
9478 +static const struct vm_operations_struct pax_vm_ops = {
9479 + .close = pax_emuplt_close,
9480 + .fault = pax_emuplt_fault
9481 +};
9482 +
9483 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9484 +{
9485 + int ret;
9486 +
9487 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9488 + vma->vm_mm = current->mm;
9489 + vma->vm_start = addr;
9490 + vma->vm_end = addr + PAGE_SIZE;
9491 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9492 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9493 + vma->vm_ops = &pax_vm_ops;
9494 +
9495 + ret = insert_vm_struct(current->mm, vma);
9496 + if (ret)
9497 + return ret;
9498 +
9499 + ++current->mm->total_vm;
9500 + return 0;
9501 +}
9502 +#endif
9503 +
9504 +/*
9505 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9506 + *
9507 + * returns 1 when task should be killed
9508 + * 2 when patched PLT trampoline was detected
9509 + * 3 when unpatched PLT trampoline was detected
9510 + */
9511 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9512 +{
9513 +
9514 +#ifdef CONFIG_PAX_EMUPLT
9515 + int err;
9516 +
9517 + do { /* PaX: patched PLT emulation #1 */
9518 + unsigned int sethi1, sethi2, jmpl;
9519 +
9520 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9521 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9522 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9523 +
9524 + if (err)
9525 + break;
9526 +
9527 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9528 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9529 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9530 + {
9531 + unsigned long addr;
9532 +
9533 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9534 + addr = regs->u_regs[UREG_G1];
9535 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9536 +
9537 + if (test_thread_flag(TIF_32BIT))
9538 + addr &= 0xFFFFFFFFUL;
9539 +
9540 + regs->tpc = addr;
9541 + regs->tnpc = addr+4;
9542 + return 2;
9543 + }
9544 + } while (0);
9545 +
9546 + do { /* PaX: patched PLT emulation #2 */
9547 + unsigned int ba;
9548 +
9549 + err = get_user(ba, (unsigned int *)regs->tpc);
9550 +
9551 + if (err)
9552 + break;
9553 +
9554 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9555 + unsigned long addr;
9556 +
9557 + if ((ba & 0xFFC00000U) == 0x30800000U)
9558 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9559 + else
9560 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9561 +
9562 + if (test_thread_flag(TIF_32BIT))
9563 + addr &= 0xFFFFFFFFUL;
9564 +
9565 + regs->tpc = addr;
9566 + regs->tnpc = addr+4;
9567 + return 2;
9568 + }
9569 + } while (0);
9570 +
9571 + do { /* PaX: patched PLT emulation #3 */
9572 + unsigned int sethi, bajmpl, nop;
9573 +
9574 + err = get_user(sethi, (unsigned int *)regs->tpc);
9575 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9576 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9577 +
9578 + if (err)
9579 + break;
9580 +
9581 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9582 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9583 + nop == 0x01000000U)
9584 + {
9585 + unsigned long addr;
9586 +
9587 + addr = (sethi & 0x003FFFFFU) << 10;
9588 + regs->u_regs[UREG_G1] = addr;
9589 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9590 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9591 + else
9592 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9593 +
9594 + if (test_thread_flag(TIF_32BIT))
9595 + addr &= 0xFFFFFFFFUL;
9596 +
9597 + regs->tpc = addr;
9598 + regs->tnpc = addr+4;
9599 + return 2;
9600 + }
9601 + } while (0);
9602 +
9603 + do { /* PaX: patched PLT emulation #4 */
9604 + unsigned int sethi, mov1, call, mov2;
9605 +
9606 + err = get_user(sethi, (unsigned int *)regs->tpc);
9607 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9608 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9609 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9610 +
9611 + if (err)
9612 + break;
9613 +
9614 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9615 + mov1 == 0x8210000FU &&
9616 + (call & 0xC0000000U) == 0x40000000U &&
9617 + mov2 == 0x9E100001U)
9618 + {
9619 + unsigned long addr;
9620 +
9621 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
9622 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9623 +
9624 + if (test_thread_flag(TIF_32BIT))
9625 + addr &= 0xFFFFFFFFUL;
9626 +
9627 + regs->tpc = addr;
9628 + regs->tnpc = addr+4;
9629 + return 2;
9630 + }
9631 + } while (0);
9632 +
9633 + do { /* PaX: patched PLT emulation #5 */
9634 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
9635 +
9636 + err = get_user(sethi, (unsigned int *)regs->tpc);
9637 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9638 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9639 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
9640 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
9641 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
9642 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
9643 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
9644 +
9645 + if (err)
9646 + break;
9647 +
9648 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9649 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9650 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9651 + (or1 & 0xFFFFE000U) == 0x82106000U &&
9652 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9653 + sllx == 0x83287020U &&
9654 + jmpl == 0x81C04005U &&
9655 + nop == 0x01000000U)
9656 + {
9657 + unsigned long addr;
9658 +
9659 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9660 + regs->u_regs[UREG_G1] <<= 32;
9661 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9662 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9663 + regs->tpc = addr;
9664 + regs->tnpc = addr+4;
9665 + return 2;
9666 + }
9667 + } while (0);
9668 +
9669 + do { /* PaX: patched PLT emulation #6 */
9670 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
9671 +
9672 + err = get_user(sethi, (unsigned int *)regs->tpc);
9673 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9674 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9675 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
9676 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
9677 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
9678 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
9679 +
9680 + if (err)
9681 + break;
9682 +
9683 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9684 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9685 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9686 + sllx == 0x83287020U &&
9687 + (or & 0xFFFFE000U) == 0x8A116000U &&
9688 + jmpl == 0x81C04005U &&
9689 + nop == 0x01000000U)
9690 + {
9691 + unsigned long addr;
9692 +
9693 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
9694 + regs->u_regs[UREG_G1] <<= 32;
9695 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
9696 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9697 + regs->tpc = addr;
9698 + regs->tnpc = addr+4;
9699 + return 2;
9700 + }
9701 + } while (0);
9702 +
9703 + do { /* PaX: unpatched PLT emulation step 1 */
9704 + unsigned int sethi, ba, nop;
9705 +
9706 + err = get_user(sethi, (unsigned int *)regs->tpc);
9707 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9708 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9709 +
9710 + if (err)
9711 + break;
9712 +
9713 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9714 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9715 + nop == 0x01000000U)
9716 + {
9717 + unsigned long addr;
9718 + unsigned int save, call;
9719 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
9720 +
9721 + if ((ba & 0xFFC00000U) == 0x30800000U)
9722 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9723 + else
9724 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9725 +
9726 + if (test_thread_flag(TIF_32BIT))
9727 + addr &= 0xFFFFFFFFUL;
9728 +
9729 + err = get_user(save, (unsigned int *)addr);
9730 + err |= get_user(call, (unsigned int *)(addr+4));
9731 + err |= get_user(nop, (unsigned int *)(addr+8));
9732 + if (err)
9733 + break;
9734 +
9735 +#ifdef CONFIG_PAX_DLRESOLVE
9736 + if (save == 0x9DE3BFA8U &&
9737 + (call & 0xC0000000U) == 0x40000000U &&
9738 + nop == 0x01000000U)
9739 + {
9740 + struct vm_area_struct *vma;
9741 + unsigned long call_dl_resolve;
9742 +
9743 + down_read(&current->mm->mmap_sem);
9744 + call_dl_resolve = current->mm->call_dl_resolve;
9745 + up_read(&current->mm->mmap_sem);
9746 + if (likely(call_dl_resolve))
9747 + goto emulate;
9748 +
9749 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9750 +
9751 + down_write(&current->mm->mmap_sem);
9752 + if (current->mm->call_dl_resolve) {
9753 + call_dl_resolve = current->mm->call_dl_resolve;
9754 + up_write(&current->mm->mmap_sem);
9755 + if (vma)
9756 + kmem_cache_free(vm_area_cachep, vma);
9757 + goto emulate;
9758 + }
9759 +
9760 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9761 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9762 + up_write(&current->mm->mmap_sem);
9763 + if (vma)
9764 + kmem_cache_free(vm_area_cachep, vma);
9765 + return 1;
9766 + }
9767 +
9768 + if (pax_insert_vma(vma, call_dl_resolve)) {
9769 + up_write(&current->mm->mmap_sem);
9770 + kmem_cache_free(vm_area_cachep, vma);
9771 + return 1;
9772 + }
9773 +
9774 + current->mm->call_dl_resolve = call_dl_resolve;
9775 + up_write(&current->mm->mmap_sem);
9776 +
9777 +emulate:
9778 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9779 + regs->tpc = call_dl_resolve;
9780 + regs->tnpc = addr+4;
9781 + return 3;
9782 + }
9783 +#endif
9784 +
9785 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9786 + if ((save & 0xFFC00000U) == 0x05000000U &&
9787 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9788 + nop == 0x01000000U)
9789 + {
9790 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9791 + regs->u_regs[UREG_G2] = addr + 4;
9792 + addr = (save & 0x003FFFFFU) << 10;
9793 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9794 +
9795 + if (test_thread_flag(TIF_32BIT))
9796 + addr &= 0xFFFFFFFFUL;
9797 +
9798 + regs->tpc = addr;
9799 + regs->tnpc = addr+4;
9800 + return 3;
9801 + }
9802 +
9803 + /* PaX: 64-bit PLT stub */
9804 + err = get_user(sethi1, (unsigned int *)addr);
9805 + err |= get_user(sethi2, (unsigned int *)(addr+4));
9806 + err |= get_user(or1, (unsigned int *)(addr+8));
9807 + err |= get_user(or2, (unsigned int *)(addr+12));
9808 + err |= get_user(sllx, (unsigned int *)(addr+16));
9809 + err |= get_user(add, (unsigned int *)(addr+20));
9810 + err |= get_user(jmpl, (unsigned int *)(addr+24));
9811 + err |= get_user(nop, (unsigned int *)(addr+28));
9812 + if (err)
9813 + break;
9814 +
9815 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
9816 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9817 + (or1 & 0xFFFFE000U) == 0x88112000U &&
9818 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9819 + sllx == 0x89293020U &&
9820 + add == 0x8A010005U &&
9821 + jmpl == 0x89C14000U &&
9822 + nop == 0x01000000U)
9823 + {
9824 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9825 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9826 + regs->u_regs[UREG_G4] <<= 32;
9827 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9828 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
9829 + regs->u_regs[UREG_G4] = addr + 24;
9830 + addr = regs->u_regs[UREG_G5];
9831 + regs->tpc = addr;
9832 + regs->tnpc = addr+4;
9833 + return 3;
9834 + }
9835 + }
9836 + } while (0);
9837 +
9838 +#ifdef CONFIG_PAX_DLRESOLVE
9839 + do { /* PaX: unpatched PLT emulation step 2 */
9840 + unsigned int save, call, nop;
9841 +
9842 + err = get_user(save, (unsigned int *)(regs->tpc-4));
9843 + err |= get_user(call, (unsigned int *)regs->tpc);
9844 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
9845 + if (err)
9846 + break;
9847 +
9848 + if (save == 0x9DE3BFA8U &&
9849 + (call & 0xC0000000U) == 0x40000000U &&
9850 + nop == 0x01000000U)
9851 + {
9852 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9853 +
9854 + if (test_thread_flag(TIF_32BIT))
9855 + dl_resolve &= 0xFFFFFFFFUL;
9856 +
9857 + regs->u_regs[UREG_RETPC] = regs->tpc;
9858 + regs->tpc = dl_resolve;
9859 + regs->tnpc = dl_resolve+4;
9860 + return 3;
9861 + }
9862 + } while (0);
9863 +#endif
9864 +
9865 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
9866 + unsigned int sethi, ba, nop;
9867 +
9868 + err = get_user(sethi, (unsigned int *)regs->tpc);
9869 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9870 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9871 +
9872 + if (err)
9873 + break;
9874 +
9875 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9876 + (ba & 0xFFF00000U) == 0x30600000U &&
9877 + nop == 0x01000000U)
9878 + {
9879 + unsigned long addr;
9880 +
9881 + addr = (sethi & 0x003FFFFFU) << 10;
9882 + regs->u_regs[UREG_G1] = addr;
9883 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9884 +
9885 + if (test_thread_flag(TIF_32BIT))
9886 + addr &= 0xFFFFFFFFUL;
9887 +
9888 + regs->tpc = addr;
9889 + regs->tnpc = addr+4;
9890 + return 2;
9891 + }
9892 + } while (0);
9893 +
9894 +#endif
9895 +
9896 + return 1;
9897 +}
9898 +
9899 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9900 +{
9901 + unsigned long i;
9902 +
9903 + printk(KERN_ERR "PAX: bytes at PC: ");
9904 + for (i = 0; i < 8; i++) {
9905 + unsigned int c;
9906 + if (get_user(c, (unsigned int *)pc+i))
9907 + printk(KERN_CONT "???????? ");
9908 + else
9909 + printk(KERN_CONT "%08x ", c);
9910 + }
9911 + printk("\n");
9912 +}
9913 +#endif
9914 +
9915 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
9916 {
9917 struct mm_struct *mm = current->mm;
9918 @@ -341,6 +804,29 @@ retry:
9919 if (!vma)
9920 goto bad_area;
9921
9922 +#ifdef CONFIG_PAX_PAGEEXEC
9923 + /* PaX: detect ITLB misses on non-exec pages */
9924 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
9925 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
9926 + {
9927 + if (address != regs->tpc)
9928 + goto good_area;
9929 +
9930 + up_read(&mm->mmap_sem);
9931 + switch (pax_handle_fetch_fault(regs)) {
9932 +
9933 +#ifdef CONFIG_PAX_EMUPLT
9934 + case 2:
9935 + case 3:
9936 + return;
9937 +#endif
9938 +
9939 + }
9940 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
9941 + do_group_exit(SIGKILL);
9942 + }
9943 +#endif
9944 +
9945 /* Pure DTLB misses do not tell us whether the fault causing
9946 * load/store/atomic was a write or not, it only says that there
9947 * was no match. So in such a case we (carefully) read the
9948 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
9949 index d2b5944..bd813f2 100644
9950 --- a/arch/sparc/mm/hugetlbpage.c
9951 +++ b/arch/sparc/mm/hugetlbpage.c
9952 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9953
9954 info.flags = 0;
9955 info.length = len;
9956 - info.low_limit = TASK_UNMAPPED_BASE;
9957 + info.low_limit = mm->mmap_base;
9958 info.high_limit = min(task_size, VA_EXCLUDE_START);
9959 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
9960 info.align_offset = 0;
9961 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9962 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9963 VM_BUG_ON(addr != -ENOMEM);
9964 info.low_limit = VA_EXCLUDE_END;
9965 +
9966 +#ifdef CONFIG_PAX_RANDMMAP
9967 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9968 + info.low_limit += mm->delta_mmap;
9969 +#endif
9970 +
9971 info.high_limit = task_size;
9972 addr = vm_unmapped_area(&info);
9973 }
9974 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9975 VM_BUG_ON(addr != -ENOMEM);
9976 info.flags = 0;
9977 info.low_limit = TASK_UNMAPPED_BASE;
9978 +
9979 +#ifdef CONFIG_PAX_RANDMMAP
9980 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9981 + info.low_limit += mm->delta_mmap;
9982 +#endif
9983 +
9984 info.high_limit = STACK_TOP32;
9985 addr = vm_unmapped_area(&info);
9986 }
9987 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
9988 struct mm_struct *mm = current->mm;
9989 struct vm_area_struct *vma;
9990 unsigned long task_size = TASK_SIZE;
9991 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
9992
9993 if (test_thread_flag(TIF_32BIT))
9994 task_size = STACK_TOP32;
9995 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
9996 return addr;
9997 }
9998
9999 +#ifdef CONFIG_PAX_RANDMMAP
10000 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10001 +#endif
10002 +
10003 if (addr) {
10004 addr = ALIGN(addr, HPAGE_SIZE);
10005 vma = find_vma(mm, addr);
10006 - if (task_size - len >= addr &&
10007 - (!vma || addr + len <= vma->vm_start))
10008 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10009 return addr;
10010 }
10011 if (mm->get_unmapped_area == arch_get_unmapped_area)
10012 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
10013 index f4500c6..889656c 100644
10014 --- a/arch/tile/include/asm/atomic_64.h
10015 +++ b/arch/tile/include/asm/atomic_64.h
10016 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10017
10018 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10019
10020 +#define atomic64_read_unchecked(v) atomic64_read(v)
10021 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
10022 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
10023 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
10024 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
10025 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
10026 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
10027 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
10028 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
10029 +
10030 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
10031 #define smp_mb__before_atomic_dec() smp_mb()
10032 #define smp_mb__after_atomic_dec() smp_mb()
10033 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
10034 index a9a5299..0fce79e 100644
10035 --- a/arch/tile/include/asm/cache.h
10036 +++ b/arch/tile/include/asm/cache.h
10037 @@ -15,11 +15,12 @@
10038 #ifndef _ASM_TILE_CACHE_H
10039 #define _ASM_TILE_CACHE_H
10040
10041 +#include <linux/const.h>
10042 #include <arch/chip.h>
10043
10044 /* bytes per L1 data cache line */
10045 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
10046 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10047 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10048
10049 /* bytes per L2 cache line */
10050 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10051 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10052 index 9ab078a..d6635c2 100644
10053 --- a/arch/tile/include/asm/uaccess.h
10054 +++ b/arch/tile/include/asm/uaccess.h
10055 @@ -403,9 +403,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10056 const void __user *from,
10057 unsigned long n)
10058 {
10059 - int sz = __compiletime_object_size(to);
10060 + size_t sz = __compiletime_object_size(to);
10061
10062 - if (likely(sz == -1 || sz >= n))
10063 + if (likely(sz == (size_t)-1 || sz >= n))
10064 n = _copy_from_user(to, from, n);
10065 else
10066 copy_from_user_overflow();
10067 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
10068 index 650ccff..45fe2d6 100644
10069 --- a/arch/tile/mm/hugetlbpage.c
10070 +++ b/arch/tile/mm/hugetlbpage.c
10071 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
10072 info.high_limit = TASK_SIZE;
10073 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10074 info.align_offset = 0;
10075 + info.threadstack_offset = 0;
10076 return vm_unmapped_area(&info);
10077 }
10078
10079 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
10080 info.high_limit = current->mm->mmap_base;
10081 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10082 info.align_offset = 0;
10083 + info.threadstack_offset = 0;
10084 addr = vm_unmapped_area(&info);
10085
10086 /*
10087 diff --git a/arch/um/Makefile b/arch/um/Makefile
10088 index 133f7de..1d6f2f1 100644
10089 --- a/arch/um/Makefile
10090 +++ b/arch/um/Makefile
10091 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10092 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10093 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10094
10095 +ifdef CONSTIFY_PLUGIN
10096 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10097 +endif
10098 +
10099 #This will adjust *FLAGS accordingly to the platform.
10100 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10101
10102 diff --git a/arch/um/defconfig b/arch/um/defconfig
10103 index 08107a7..ab22afe 100644
10104 --- a/arch/um/defconfig
10105 +++ b/arch/um/defconfig
10106 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
10107 CONFIG_X86_L1_CACHE_SHIFT=5
10108 CONFIG_X86_XADD=y
10109 CONFIG_X86_PPRO_FENCE=y
10110 -CONFIG_X86_WP_WORKS_OK=y
10111 CONFIG_X86_INVLPG=y
10112 CONFIG_X86_BSWAP=y
10113 CONFIG_X86_POPAD_OK=y
10114 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10115 index 19e1bdd..3665b77 100644
10116 --- a/arch/um/include/asm/cache.h
10117 +++ b/arch/um/include/asm/cache.h
10118 @@ -1,6 +1,7 @@
10119 #ifndef __UM_CACHE_H
10120 #define __UM_CACHE_H
10121
10122 +#include <linux/const.h>
10123
10124 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10125 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10126 @@ -12,6 +13,6 @@
10127 # define L1_CACHE_SHIFT 5
10128 #endif
10129
10130 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10131 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10132
10133 #endif
10134 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10135 index 2e0a6b1..a64d0f5 100644
10136 --- a/arch/um/include/asm/kmap_types.h
10137 +++ b/arch/um/include/asm/kmap_types.h
10138 @@ -8,6 +8,6 @@
10139
10140 /* No more #include "asm/arch/kmap_types.h" ! */
10141
10142 -#define KM_TYPE_NR 14
10143 +#define KM_TYPE_NR 15
10144
10145 #endif
10146 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10147 index 5ff53d9..5850cdf 100644
10148 --- a/arch/um/include/asm/page.h
10149 +++ b/arch/um/include/asm/page.h
10150 @@ -14,6 +14,9 @@
10151 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10152 #define PAGE_MASK (~(PAGE_SIZE-1))
10153
10154 +#define ktla_ktva(addr) (addr)
10155 +#define ktva_ktla(addr) (addr)
10156 +
10157 #ifndef __ASSEMBLY__
10158
10159 struct page;
10160 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10161 index 0032f92..cd151e0 100644
10162 --- a/arch/um/include/asm/pgtable-3level.h
10163 +++ b/arch/um/include/asm/pgtable-3level.h
10164 @@ -58,6 +58,7 @@
10165 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10166 #define pud_populate(mm, pud, pmd) \
10167 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10168 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10169
10170 #ifdef CONFIG_64BIT
10171 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10172 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10173 index b462b13..e7a19aa 100644
10174 --- a/arch/um/kernel/process.c
10175 +++ b/arch/um/kernel/process.c
10176 @@ -386,22 +386,6 @@ int singlestepping(void * t)
10177 return 2;
10178 }
10179
10180 -/*
10181 - * Only x86 and x86_64 have an arch_align_stack().
10182 - * All other arches have "#define arch_align_stack(x) (x)"
10183 - * in their asm/system.h
10184 - * As this is included in UML from asm-um/system-generic.h,
10185 - * we can use it to behave as the subarch does.
10186 - */
10187 -#ifndef arch_align_stack
10188 -unsigned long arch_align_stack(unsigned long sp)
10189 -{
10190 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10191 - sp -= get_random_int() % 8192;
10192 - return sp & ~0xf;
10193 -}
10194 -#endif
10195 -
10196 unsigned long get_wchan(struct task_struct *p)
10197 {
10198 unsigned long stack_page, sp, ip;
10199 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10200 index ad8f795..2c7eec6 100644
10201 --- a/arch/unicore32/include/asm/cache.h
10202 +++ b/arch/unicore32/include/asm/cache.h
10203 @@ -12,8 +12,10 @@
10204 #ifndef __UNICORE_CACHE_H__
10205 #define __UNICORE_CACHE_H__
10206
10207 -#define L1_CACHE_SHIFT (5)
10208 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10209 +#include <linux/const.h>
10210 +
10211 +#define L1_CACHE_SHIFT 5
10212 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10213
10214 /*
10215 * Memory returned by kmalloc() may be used for DMA, so we must make
10216 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10217 index 15b5cef..173babc 100644
10218 --- a/arch/x86/Kconfig
10219 +++ b/arch/x86/Kconfig
10220 @@ -244,7 +244,7 @@ config X86_HT
10221
10222 config X86_32_LAZY_GS
10223 def_bool y
10224 - depends on X86_32 && !CC_STACKPROTECTOR
10225 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10226
10227 config ARCH_HWEIGHT_CFLAGS
10228 string
10229 @@ -1077,6 +1077,7 @@ config MICROCODE_EARLY
10230
10231 config X86_MSR
10232 tristate "/dev/cpu/*/msr - Model-specific register support"
10233 + depends on !GRKERNSEC_KMEM
10234 ---help---
10235 This device gives privileged processes access to the x86
10236 Model-Specific Registers (MSRs). It is a character device with
10237 @@ -1100,7 +1101,7 @@ choice
10238
10239 config NOHIGHMEM
10240 bool "off"
10241 - depends on !X86_NUMAQ
10242 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10243 ---help---
10244 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10245 However, the address space of 32-bit x86 processors is only 4
10246 @@ -1137,7 +1138,7 @@ config NOHIGHMEM
10247
10248 config HIGHMEM4G
10249 bool "4GB"
10250 - depends on !X86_NUMAQ
10251 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10252 ---help---
10253 Select this if you have a 32-bit processor and between 1 and 4
10254 gigabytes of physical RAM.
10255 @@ -1190,7 +1191,7 @@ config PAGE_OFFSET
10256 hex
10257 default 0xB0000000 if VMSPLIT_3G_OPT
10258 default 0x80000000 if VMSPLIT_2G
10259 - default 0x78000000 if VMSPLIT_2G_OPT
10260 + default 0x70000000 if VMSPLIT_2G_OPT
10261 default 0x40000000 if VMSPLIT_1G
10262 default 0xC0000000
10263 depends on X86_32
10264 @@ -1588,6 +1589,7 @@ config SECCOMP
10265
10266 config CC_STACKPROTECTOR
10267 bool "Enable -fstack-protector buffer overflow detection"
10268 + depends on X86_64 || !PAX_MEMORY_UDEREF
10269 ---help---
10270 This option turns on the -fstack-protector GCC feature. This
10271 feature puts, at the beginning of functions, a canary value on
10272 @@ -1707,6 +1709,8 @@ config X86_NEED_RELOCS
10273 config PHYSICAL_ALIGN
10274 hex "Alignment value to which kernel should be aligned" if X86_32
10275 default "0x1000000"
10276 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
10277 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
10278 range 0x2000 0x1000000
10279 ---help---
10280 This value puts the alignment restrictions on physical address
10281 @@ -1782,9 +1786,10 @@ config DEBUG_HOTPLUG_CPU0
10282 If unsure, say N.
10283
10284 config COMPAT_VDSO
10285 - def_bool y
10286 + def_bool n
10287 prompt "Compat VDSO support"
10288 depends on X86_32 || IA32_EMULATION
10289 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10290 ---help---
10291 Map the 32-bit VDSO to the predictable old-style address too.
10292
10293 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10294 index c026cca..14657ae 100644
10295 --- a/arch/x86/Kconfig.cpu
10296 +++ b/arch/x86/Kconfig.cpu
10297 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10298
10299 config X86_F00F_BUG
10300 def_bool y
10301 - depends on M586MMX || M586TSC || M586 || M486
10302 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10303
10304 config X86_INVD_BUG
10305 def_bool y
10306 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10307
10308 config X86_ALIGNMENT_16
10309 def_bool y
10310 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10311 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10312
10313 config X86_INTEL_USERCOPY
10314 def_bool y
10315 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10316 # generates cmov.
10317 config X86_CMOV
10318 def_bool y
10319 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10320 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10321
10322 config X86_MINIMUM_CPU_FAMILY
10323 int
10324 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10325 index b322f12..652d0d9 100644
10326 --- a/arch/x86/Kconfig.debug
10327 +++ b/arch/x86/Kconfig.debug
10328 @@ -84,7 +84,7 @@ config X86_PTDUMP
10329 config DEBUG_RODATA
10330 bool "Write protect kernel read-only data structures"
10331 default y
10332 - depends on DEBUG_KERNEL
10333 + depends on DEBUG_KERNEL && BROKEN
10334 ---help---
10335 Mark the kernel read-only data as write-protected in the pagetables,
10336 in order to catch accidental (and incorrect) writes to such const
10337 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10338
10339 config DEBUG_SET_MODULE_RONX
10340 bool "Set loadable kernel module data as NX and text as RO"
10341 - depends on MODULES
10342 + depends on MODULES && BROKEN
10343 ---help---
10344 This option helps catch unintended modifications to loadable
10345 kernel module's text and read-only data. It also prevents execution
10346 @@ -294,7 +294,7 @@ config OPTIMIZE_INLINING
10347
10348 config DEBUG_STRICT_USER_COPY_CHECKS
10349 bool "Strict copy size checks"
10350 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
10351 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
10352 ---help---
10353 Enabling this option turns a certain set of sanity checks for user
10354 copy operations into compile time failures.
10355 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10356 index 5c47726..8c4fa67 100644
10357 --- a/arch/x86/Makefile
10358 +++ b/arch/x86/Makefile
10359 @@ -54,6 +54,7 @@ else
10360 UTS_MACHINE := x86_64
10361 CHECKFLAGS += -D__x86_64__ -m64
10362
10363 + biarch := $(call cc-option,-m64)
10364 KBUILD_AFLAGS += -m64
10365 KBUILD_CFLAGS += -m64
10366
10367 @@ -234,3 +235,12 @@ define archhelp
10368 echo ' FDARGS="..." arguments for the booted kernel'
10369 echo ' FDINITRD=file initrd for the booted kernel'
10370 endef
10371 +
10372 +define OLD_LD
10373 +
10374 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10375 +*** Please upgrade your binutils to 2.18 or newer
10376 +endef
10377 +
10378 +archprepare:
10379 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10380 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10381 index 379814b..add62ce 100644
10382 --- a/arch/x86/boot/Makefile
10383 +++ b/arch/x86/boot/Makefile
10384 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10385 $(call cc-option, -fno-stack-protector) \
10386 $(call cc-option, -mpreferred-stack-boundary=2)
10387 KBUILD_CFLAGS += $(call cc-option, -m32)
10388 +ifdef CONSTIFY_PLUGIN
10389 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10390 +endif
10391 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10392 GCOV_PROFILE := n
10393
10394 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10395 index 878e4b9..20537ab 100644
10396 --- a/arch/x86/boot/bitops.h
10397 +++ b/arch/x86/boot/bitops.h
10398 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10399 u8 v;
10400 const u32 *p = (const u32 *)addr;
10401
10402 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10403 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10404 return v;
10405 }
10406
10407 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10408
10409 static inline void set_bit(int nr, void *addr)
10410 {
10411 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10412 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10413 }
10414
10415 #endif /* BOOT_BITOPS_H */
10416 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10417 index 5b75319..331a4ca 100644
10418 --- a/arch/x86/boot/boot.h
10419 +++ b/arch/x86/boot/boot.h
10420 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10421 static inline u16 ds(void)
10422 {
10423 u16 seg;
10424 - asm("movw %%ds,%0" : "=rm" (seg));
10425 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10426 return seg;
10427 }
10428
10429 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10430 static inline int memcmp(const void *s1, const void *s2, size_t len)
10431 {
10432 u8 diff;
10433 - asm("repe; cmpsb; setnz %0"
10434 + asm volatile("repe; cmpsb; setnz %0"
10435 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10436 return diff;
10437 }
10438 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10439 index 5ef205c..342191d 100644
10440 --- a/arch/x86/boot/compressed/Makefile
10441 +++ b/arch/x86/boot/compressed/Makefile
10442 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10443 KBUILD_CFLAGS += $(cflags-y)
10444 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10445 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10446 +ifdef CONSTIFY_PLUGIN
10447 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10448 +endif
10449
10450 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10451 GCOV_PROFILE := n
10452 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10453 index 35ee62f..b6609b6 100644
10454 --- a/arch/x86/boot/compressed/eboot.c
10455 +++ b/arch/x86/boot/compressed/eboot.c
10456 @@ -150,7 +150,6 @@ again:
10457 *addr = max_addr;
10458 }
10459
10460 -free_pool:
10461 efi_call_phys1(sys_table->boottime->free_pool, map);
10462
10463 fail:
10464 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10465 if (i == map_size / desc_size)
10466 status = EFI_NOT_FOUND;
10467
10468 -free_pool:
10469 efi_call_phys1(sys_table->boottime->free_pool, map);
10470 fail:
10471 return status;
10472 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10473 index 1e3184f..0d11e2e 100644
10474 --- a/arch/x86/boot/compressed/head_32.S
10475 +++ b/arch/x86/boot/compressed/head_32.S
10476 @@ -118,7 +118,7 @@ preferred_addr:
10477 notl %eax
10478 andl %eax, %ebx
10479 #else
10480 - movl $LOAD_PHYSICAL_ADDR, %ebx
10481 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10482 #endif
10483
10484 /* Target address to relocate to for decompression */
10485 @@ -204,7 +204,7 @@ relocated:
10486 * and where it was actually loaded.
10487 */
10488 movl %ebp, %ebx
10489 - subl $LOAD_PHYSICAL_ADDR, %ebx
10490 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10491 jz 2f /* Nothing to be done if loaded at compiled addr. */
10492 /*
10493 * Process relocations.
10494 @@ -212,8 +212,7 @@ relocated:
10495
10496 1: subl $4, %edi
10497 movl (%edi), %ecx
10498 - testl %ecx, %ecx
10499 - jz 2f
10500 + jecxz 2f
10501 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10502 jmp 1b
10503 2:
10504 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10505 index c1d383d..57ab51c 100644
10506 --- a/arch/x86/boot/compressed/head_64.S
10507 +++ b/arch/x86/boot/compressed/head_64.S
10508 @@ -97,7 +97,7 @@ ENTRY(startup_32)
10509 notl %eax
10510 andl %eax, %ebx
10511 #else
10512 - movl $LOAD_PHYSICAL_ADDR, %ebx
10513 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10514 #endif
10515
10516 /* Target address to relocate to for decompression */
10517 @@ -272,7 +272,7 @@ preferred_addr:
10518 notq %rax
10519 andq %rax, %rbp
10520 #else
10521 - movq $LOAD_PHYSICAL_ADDR, %rbp
10522 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10523 #endif
10524
10525 /* Target address to relocate to for decompression */
10526 @@ -363,8 +363,8 @@ gdt:
10527 .long gdt
10528 .word 0
10529 .quad 0x0000000000000000 /* NULL descriptor */
10530 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
10531 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
10532 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
10533 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
10534 .quad 0x0080890000000000 /* TS descriptor */
10535 .quad 0x0000000000000000 /* TS continued */
10536 gdt_end:
10537 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10538 index 7cb56c6..d382d84 100644
10539 --- a/arch/x86/boot/compressed/misc.c
10540 +++ b/arch/x86/boot/compressed/misc.c
10541 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10542 case PT_LOAD:
10543 #ifdef CONFIG_RELOCATABLE
10544 dest = output;
10545 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10546 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10547 #else
10548 dest = (void *)(phdr->p_paddr);
10549 #endif
10550 @@ -354,7 +354,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10551 error("Destination address too large");
10552 #endif
10553 #ifndef CONFIG_RELOCATABLE
10554 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10555 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10556 error("Wrong destination address");
10557 #endif
10558
10559 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10560 index 4d3ff03..e4972ff 100644
10561 --- a/arch/x86/boot/cpucheck.c
10562 +++ b/arch/x86/boot/cpucheck.c
10563 @@ -74,7 +74,7 @@ static int has_fpu(void)
10564 u16 fcw = -1, fsw = -1;
10565 u32 cr0;
10566
10567 - asm("movl %%cr0,%0" : "=r" (cr0));
10568 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10569 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10570 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10571 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10572 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10573 {
10574 u32 f0, f1;
10575
10576 - asm("pushfl ; "
10577 + asm volatile("pushfl ; "
10578 "pushfl ; "
10579 "popl %0 ; "
10580 "movl %0,%1 ; "
10581 @@ -115,7 +115,7 @@ static void get_flags(void)
10582 set_bit(X86_FEATURE_FPU, cpu.flags);
10583
10584 if (has_eflag(X86_EFLAGS_ID)) {
10585 - asm("cpuid"
10586 + asm volatile("cpuid"
10587 : "=a" (max_intel_level),
10588 "=b" (cpu_vendor[0]),
10589 "=d" (cpu_vendor[1]),
10590 @@ -124,7 +124,7 @@ static void get_flags(void)
10591
10592 if (max_intel_level >= 0x00000001 &&
10593 max_intel_level <= 0x0000ffff) {
10594 - asm("cpuid"
10595 + asm volatile("cpuid"
10596 : "=a" (tfms),
10597 "=c" (cpu.flags[4]),
10598 "=d" (cpu.flags[0])
10599 @@ -136,7 +136,7 @@ static void get_flags(void)
10600 cpu.model += ((tfms >> 16) & 0xf) << 4;
10601 }
10602
10603 - asm("cpuid"
10604 + asm volatile("cpuid"
10605 : "=a" (max_amd_level)
10606 : "a" (0x80000000)
10607 : "ebx", "ecx", "edx");
10608 @@ -144,7 +144,7 @@ static void get_flags(void)
10609 if (max_amd_level >= 0x80000001 &&
10610 max_amd_level <= 0x8000ffff) {
10611 u32 eax = 0x80000001;
10612 - asm("cpuid"
10613 + asm volatile("cpuid"
10614 : "+a" (eax),
10615 "=c" (cpu.flags[6]),
10616 "=d" (cpu.flags[1])
10617 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10618 u32 ecx = MSR_K7_HWCR;
10619 u32 eax, edx;
10620
10621 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10622 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10623 eax &= ~(1 << 15);
10624 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10625 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10626
10627 get_flags(); /* Make sure it really did something */
10628 err = check_flags();
10629 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10630 u32 ecx = MSR_VIA_FCR;
10631 u32 eax, edx;
10632
10633 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10634 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10635 eax |= (1<<1)|(1<<7);
10636 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10637 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10638
10639 set_bit(X86_FEATURE_CX8, cpu.flags);
10640 err = check_flags();
10641 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10642 u32 eax, edx;
10643 u32 level = 1;
10644
10645 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10646 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10647 - asm("cpuid"
10648 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10649 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10650 + asm volatile("cpuid"
10651 : "+a" (level), "=d" (cpu.flags[0])
10652 : : "ecx", "ebx");
10653 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10654 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10655
10656 err = check_flags();
10657 }
10658 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
10659 index 9ec06a1..2c25e79 100644
10660 --- a/arch/x86/boot/header.S
10661 +++ b/arch/x86/boot/header.S
10662 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
10663 # single linked list of
10664 # struct setup_data
10665
10666 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
10667 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
10668
10669 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
10670 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
10671 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
10672 +#else
10673 #define VO_INIT_SIZE (VO__end - VO__text)
10674 +#endif
10675 #if ZO_INIT_SIZE > VO_INIT_SIZE
10676 #define INIT_SIZE ZO_INIT_SIZE
10677 #else
10678 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
10679 index db75d07..8e6d0af 100644
10680 --- a/arch/x86/boot/memory.c
10681 +++ b/arch/x86/boot/memory.c
10682 @@ -19,7 +19,7 @@
10683
10684 static int detect_memory_e820(void)
10685 {
10686 - int count = 0;
10687 + unsigned int count = 0;
10688 struct biosregs ireg, oreg;
10689 struct e820entry *desc = boot_params.e820_map;
10690 static struct e820entry buf; /* static so it is zeroed */
10691 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
10692 index 11e8c6e..fdbb1ed 100644
10693 --- a/arch/x86/boot/video-vesa.c
10694 +++ b/arch/x86/boot/video-vesa.c
10695 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
10696
10697 boot_params.screen_info.vesapm_seg = oreg.es;
10698 boot_params.screen_info.vesapm_off = oreg.di;
10699 + boot_params.screen_info.vesapm_size = oreg.cx;
10700 }
10701
10702 /*
10703 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
10704 index 43eda28..5ab5fdb 100644
10705 --- a/arch/x86/boot/video.c
10706 +++ b/arch/x86/boot/video.c
10707 @@ -96,7 +96,7 @@ static void store_mode_params(void)
10708 static unsigned int get_entry(void)
10709 {
10710 char entry_buf[4];
10711 - int i, len = 0;
10712 + unsigned int i, len = 0;
10713 int key;
10714 unsigned int v;
10715
10716 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
10717 index 9105655..5e37f27 100644
10718 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
10719 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
10720 @@ -8,6 +8,8 @@
10721 * including this sentence is retained in full.
10722 */
10723
10724 +#include <asm/alternative-asm.h>
10725 +
10726 .extern crypto_ft_tab
10727 .extern crypto_it_tab
10728 .extern crypto_fl_tab
10729 @@ -70,6 +72,8 @@
10730 je B192; \
10731 leaq 32(r9),r9;
10732
10733 +#define ret pax_force_retaddr 0, 1; ret
10734 +
10735 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
10736 movq r1,r2; \
10737 movq r3,r4; \
10738 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
10739 index 04b7977..402f223 100644
10740 --- a/arch/x86/crypto/aesni-intel_asm.S
10741 +++ b/arch/x86/crypto/aesni-intel_asm.S
10742 @@ -31,6 +31,7 @@
10743
10744 #include <linux/linkage.h>
10745 #include <asm/inst.h>
10746 +#include <asm/alternative-asm.h>
10747
10748 #ifdef __x86_64__
10749 .data
10750 @@ -1435,6 +1436,7 @@ _return_T_done_decrypt:
10751 pop %r14
10752 pop %r13
10753 pop %r12
10754 + pax_force_retaddr 0, 1
10755 ret
10756 ENDPROC(aesni_gcm_dec)
10757
10758 @@ -1699,6 +1701,7 @@ _return_T_done_encrypt:
10759 pop %r14
10760 pop %r13
10761 pop %r12
10762 + pax_force_retaddr 0, 1
10763 ret
10764 ENDPROC(aesni_gcm_enc)
10765
10766 @@ -1716,6 +1719,7 @@ _key_expansion_256a:
10767 pxor %xmm1, %xmm0
10768 movaps %xmm0, (TKEYP)
10769 add $0x10, TKEYP
10770 + pax_force_retaddr_bts
10771 ret
10772 ENDPROC(_key_expansion_128)
10773 ENDPROC(_key_expansion_256a)
10774 @@ -1742,6 +1746,7 @@ _key_expansion_192a:
10775 shufps $0b01001110, %xmm2, %xmm1
10776 movaps %xmm1, 0x10(TKEYP)
10777 add $0x20, TKEYP
10778 + pax_force_retaddr_bts
10779 ret
10780 ENDPROC(_key_expansion_192a)
10781
10782 @@ -1762,6 +1767,7 @@ _key_expansion_192b:
10783
10784 movaps %xmm0, (TKEYP)
10785 add $0x10, TKEYP
10786 + pax_force_retaddr_bts
10787 ret
10788 ENDPROC(_key_expansion_192b)
10789
10790 @@ -1775,6 +1781,7 @@ _key_expansion_256b:
10791 pxor %xmm1, %xmm2
10792 movaps %xmm2, (TKEYP)
10793 add $0x10, TKEYP
10794 + pax_force_retaddr_bts
10795 ret
10796 ENDPROC(_key_expansion_256b)
10797
10798 @@ -1888,6 +1895,7 @@ ENTRY(aesni_set_key)
10799 #ifndef __x86_64__
10800 popl KEYP
10801 #endif
10802 + pax_force_retaddr 0, 1
10803 ret
10804 ENDPROC(aesni_set_key)
10805
10806 @@ -1910,6 +1918,7 @@ ENTRY(aesni_enc)
10807 popl KLEN
10808 popl KEYP
10809 #endif
10810 + pax_force_retaddr 0, 1
10811 ret
10812 ENDPROC(aesni_enc)
10813
10814 @@ -1968,6 +1977,7 @@ _aesni_enc1:
10815 AESENC KEY STATE
10816 movaps 0x70(TKEYP), KEY
10817 AESENCLAST KEY STATE
10818 + pax_force_retaddr_bts
10819 ret
10820 ENDPROC(_aesni_enc1)
10821
10822 @@ -2077,6 +2087,7 @@ _aesni_enc4:
10823 AESENCLAST KEY STATE2
10824 AESENCLAST KEY STATE3
10825 AESENCLAST KEY STATE4
10826 + pax_force_retaddr_bts
10827 ret
10828 ENDPROC(_aesni_enc4)
10829
10830 @@ -2100,6 +2111,7 @@ ENTRY(aesni_dec)
10831 popl KLEN
10832 popl KEYP
10833 #endif
10834 + pax_force_retaddr 0, 1
10835 ret
10836 ENDPROC(aesni_dec)
10837
10838 @@ -2158,6 +2170,7 @@ _aesni_dec1:
10839 AESDEC KEY STATE
10840 movaps 0x70(TKEYP), KEY
10841 AESDECLAST KEY STATE
10842 + pax_force_retaddr_bts
10843 ret
10844 ENDPROC(_aesni_dec1)
10845
10846 @@ -2267,6 +2280,7 @@ _aesni_dec4:
10847 AESDECLAST KEY STATE2
10848 AESDECLAST KEY STATE3
10849 AESDECLAST KEY STATE4
10850 + pax_force_retaddr_bts
10851 ret
10852 ENDPROC(_aesni_dec4)
10853
10854 @@ -2325,6 +2339,7 @@ ENTRY(aesni_ecb_enc)
10855 popl KEYP
10856 popl LEN
10857 #endif
10858 + pax_force_retaddr 0, 1
10859 ret
10860 ENDPROC(aesni_ecb_enc)
10861
10862 @@ -2384,6 +2399,7 @@ ENTRY(aesni_ecb_dec)
10863 popl KEYP
10864 popl LEN
10865 #endif
10866 + pax_force_retaddr 0, 1
10867 ret
10868 ENDPROC(aesni_ecb_dec)
10869
10870 @@ -2426,6 +2442,7 @@ ENTRY(aesni_cbc_enc)
10871 popl LEN
10872 popl IVP
10873 #endif
10874 + pax_force_retaddr 0, 1
10875 ret
10876 ENDPROC(aesni_cbc_enc)
10877
10878 @@ -2517,6 +2534,7 @@ ENTRY(aesni_cbc_dec)
10879 popl LEN
10880 popl IVP
10881 #endif
10882 + pax_force_retaddr 0, 1
10883 ret
10884 ENDPROC(aesni_cbc_dec)
10885
10886 @@ -2544,6 +2562,7 @@ _aesni_inc_init:
10887 mov $1, TCTR_LOW
10888 MOVQ_R64_XMM TCTR_LOW INC
10889 MOVQ_R64_XMM CTR TCTR_LOW
10890 + pax_force_retaddr_bts
10891 ret
10892 ENDPROC(_aesni_inc_init)
10893
10894 @@ -2573,6 +2592,7 @@ _aesni_inc:
10895 .Linc_low:
10896 movaps CTR, IV
10897 PSHUFB_XMM BSWAP_MASK IV
10898 + pax_force_retaddr_bts
10899 ret
10900 ENDPROC(_aesni_inc)
10901
10902 @@ -2634,6 +2654,7 @@ ENTRY(aesni_ctr_enc)
10903 .Lctr_enc_ret:
10904 movups IV, (IVP)
10905 .Lctr_enc_just_ret:
10906 + pax_force_retaddr 0, 1
10907 ret
10908 ENDPROC(aesni_ctr_enc)
10909 #endif
10910 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10911 index 246c670..4d1ed00 100644
10912 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
10913 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10914 @@ -21,6 +21,7 @@
10915 */
10916
10917 #include <linux/linkage.h>
10918 +#include <asm/alternative-asm.h>
10919
10920 .file "blowfish-x86_64-asm.S"
10921 .text
10922 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
10923 jnz .L__enc_xor;
10924
10925 write_block();
10926 + pax_force_retaddr 0, 1
10927 ret;
10928 .L__enc_xor:
10929 xor_block();
10930 + pax_force_retaddr 0, 1
10931 ret;
10932 ENDPROC(__blowfish_enc_blk)
10933
10934 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
10935
10936 movq %r11, %rbp;
10937
10938 + pax_force_retaddr 0, 1
10939 ret;
10940 ENDPROC(blowfish_dec_blk)
10941
10942 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
10943
10944 popq %rbx;
10945 popq %rbp;
10946 + pax_force_retaddr 0, 1
10947 ret;
10948
10949 .L__enc_xor4:
10950 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
10951
10952 popq %rbx;
10953 popq %rbp;
10954 + pax_force_retaddr 0, 1
10955 ret;
10956 ENDPROC(__blowfish_enc_blk_4way)
10957
10958 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
10959 popq %rbx;
10960 popq %rbp;
10961
10962 + pax_force_retaddr 0, 1
10963 ret;
10964 ENDPROC(blowfish_dec_blk_4way)
10965 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
10966 index 310319c..ce174a4 100644
10967 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
10968 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
10969 @@ -21,6 +21,7 @@
10970 */
10971
10972 #include <linux/linkage.h>
10973 +#include <asm/alternative-asm.h>
10974
10975 .file "camellia-x86_64-asm_64.S"
10976 .text
10977 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
10978 enc_outunpack(mov, RT1);
10979
10980 movq RRBP, %rbp;
10981 + pax_force_retaddr 0, 1
10982 ret;
10983
10984 .L__enc_xor:
10985 enc_outunpack(xor, RT1);
10986
10987 movq RRBP, %rbp;
10988 + pax_force_retaddr 0, 1
10989 ret;
10990 ENDPROC(__camellia_enc_blk)
10991
10992 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
10993 dec_outunpack();
10994
10995 movq RRBP, %rbp;
10996 + pax_force_retaddr 0, 1
10997 ret;
10998 ENDPROC(camellia_dec_blk)
10999
11000 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
11001
11002 movq RRBP, %rbp;
11003 popq %rbx;
11004 + pax_force_retaddr 0, 1
11005 ret;
11006
11007 .L__enc2_xor:
11008 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
11009
11010 movq RRBP, %rbp;
11011 popq %rbx;
11012 + pax_force_retaddr 0, 1
11013 ret;
11014 ENDPROC(__camellia_enc_blk_2way)
11015
11016 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
11017
11018 movq RRBP, %rbp;
11019 movq RXOR, %rbx;
11020 + pax_force_retaddr 0, 1
11021 ret;
11022 ENDPROC(camellia_dec_blk_2way)
11023 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11024 index c35fd5d..c1ee236 100644
11025 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11026 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11027 @@ -24,6 +24,7 @@
11028 */
11029
11030 #include <linux/linkage.h>
11031 +#include <asm/alternative-asm.h>
11032
11033 .file "cast5-avx-x86_64-asm_64.S"
11034
11035 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
11036 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11037 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11038
11039 + pax_force_retaddr 0, 1
11040 ret;
11041 ENDPROC(__cast5_enc_blk16)
11042
11043 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
11044 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11045 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11046
11047 + pax_force_retaddr 0, 1
11048 ret;
11049
11050 .L__skip_dec:
11051 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
11052 vmovdqu RR4, (6*4*4)(%r11);
11053 vmovdqu RL4, (7*4*4)(%r11);
11054
11055 + pax_force_retaddr
11056 ret;
11057 ENDPROC(cast5_ecb_enc_16way)
11058
11059 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
11060 vmovdqu RR4, (6*4*4)(%r11);
11061 vmovdqu RL4, (7*4*4)(%r11);
11062
11063 + pax_force_retaddr
11064 ret;
11065 ENDPROC(cast5_ecb_dec_16way)
11066
11067 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
11068
11069 popq %r12;
11070
11071 + pax_force_retaddr
11072 ret;
11073 ENDPROC(cast5_cbc_dec_16way)
11074
11075 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
11076
11077 popq %r12;
11078
11079 + pax_force_retaddr
11080 ret;
11081 ENDPROC(cast5_ctr_16way)
11082 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11083 index f93b610..c09bf40 100644
11084 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11085 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11086 @@ -24,6 +24,7 @@
11087 */
11088
11089 #include <linux/linkage.h>
11090 +#include <asm/alternative-asm.h>
11091 #include "glue_helper-asm-avx.S"
11092
11093 .file "cast6-avx-x86_64-asm_64.S"
11094 @@ -293,6 +294,7 @@ __cast6_enc_blk8:
11095 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11096 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11097
11098 + pax_force_retaddr 0, 1
11099 ret;
11100 ENDPROC(__cast6_enc_blk8)
11101
11102 @@ -338,6 +340,7 @@ __cast6_dec_blk8:
11103 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11104 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11105
11106 + pax_force_retaddr 0, 1
11107 ret;
11108 ENDPROC(__cast6_dec_blk8)
11109
11110 @@ -356,6 +359,7 @@ ENTRY(cast6_ecb_enc_8way)
11111
11112 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11113
11114 + pax_force_retaddr
11115 ret;
11116 ENDPROC(cast6_ecb_enc_8way)
11117
11118 @@ -374,6 +378,7 @@ ENTRY(cast6_ecb_dec_8way)
11119
11120 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11121
11122 + pax_force_retaddr
11123 ret;
11124 ENDPROC(cast6_ecb_dec_8way)
11125
11126 @@ -397,6 +402,7 @@ ENTRY(cast6_cbc_dec_8way)
11127
11128 popq %r12;
11129
11130 + pax_force_retaddr
11131 ret;
11132 ENDPROC(cast6_cbc_dec_8way)
11133
11134 @@ -422,5 +428,6 @@ ENTRY(cast6_ctr_8way)
11135
11136 popq %r12;
11137
11138 + pax_force_retaddr
11139 ret;
11140 ENDPROC(cast6_ctr_8way)
11141 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11142 index 9279e0b..9270820 100644
11143 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11144 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11145 @@ -1,4 +1,5 @@
11146 #include <linux/linkage.h>
11147 +#include <asm/alternative-asm.h>
11148
11149 # enter salsa20_encrypt_bytes
11150 ENTRY(salsa20_encrypt_bytes)
11151 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
11152 add %r11,%rsp
11153 mov %rdi,%rax
11154 mov %rsi,%rdx
11155 + pax_force_retaddr 0, 1
11156 ret
11157 # bytesatleast65:
11158 ._bytesatleast65:
11159 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
11160 add %r11,%rsp
11161 mov %rdi,%rax
11162 mov %rsi,%rdx
11163 + pax_force_retaddr
11164 ret
11165 ENDPROC(salsa20_keysetup)
11166
11167 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
11168 add %r11,%rsp
11169 mov %rdi,%rax
11170 mov %rsi,%rdx
11171 + pax_force_retaddr
11172 ret
11173 ENDPROC(salsa20_ivsetup)
11174 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11175 index 43c9386..a0e2d60 100644
11176 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11177 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11178 @@ -25,6 +25,7 @@
11179 */
11180
11181 #include <linux/linkage.h>
11182 +#include <asm/alternative-asm.h>
11183 #include "glue_helper-asm-avx.S"
11184
11185 .file "serpent-avx-x86_64-asm_64.S"
11186 @@ -617,6 +618,7 @@ __serpent_enc_blk8_avx:
11187 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11188 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11189
11190 + pax_force_retaddr
11191 ret;
11192 ENDPROC(__serpent_enc_blk8_avx)
11193
11194 @@ -671,6 +673,7 @@ __serpent_dec_blk8_avx:
11195 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11196 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11197
11198 + pax_force_retaddr
11199 ret;
11200 ENDPROC(__serpent_dec_blk8_avx)
11201
11202 @@ -687,6 +690,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
11203
11204 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11205
11206 + pax_force_retaddr
11207 ret;
11208 ENDPROC(serpent_ecb_enc_8way_avx)
11209
11210 @@ -703,6 +707,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
11211
11212 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11213
11214 + pax_force_retaddr
11215 ret;
11216 ENDPROC(serpent_ecb_dec_8way_avx)
11217
11218 @@ -719,6 +724,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
11219
11220 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11221
11222 + pax_force_retaddr
11223 ret;
11224 ENDPROC(serpent_cbc_dec_8way_avx)
11225
11226 @@ -737,5 +743,6 @@ ENTRY(serpent_ctr_8way_avx)
11227
11228 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11229
11230 + pax_force_retaddr
11231 ret;
11232 ENDPROC(serpent_ctr_8way_avx)
11233 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11234 index acc066c..1559cc4 100644
11235 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11236 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11237 @@ -25,6 +25,7 @@
11238 */
11239
11240 #include <linux/linkage.h>
11241 +#include <asm/alternative-asm.h>
11242
11243 .file "serpent-sse2-x86_64-asm_64.S"
11244 .text
11245 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
11246 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11247 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11248
11249 + pax_force_retaddr
11250 ret;
11251
11252 .L__enc_xor8:
11253 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11254 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11255
11256 + pax_force_retaddr
11257 ret;
11258 ENDPROC(__serpent_enc_blk_8way)
11259
11260 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
11261 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11262 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11263
11264 + pax_force_retaddr
11265 ret;
11266 ENDPROC(serpent_dec_blk_8way)
11267 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11268 index a410950..3356d42 100644
11269 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11270 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11271 @@ -29,6 +29,7 @@
11272 */
11273
11274 #include <linux/linkage.h>
11275 +#include <asm/alternative-asm.h>
11276
11277 #define CTX %rdi // arg1
11278 #define BUF %rsi // arg2
11279 @@ -104,6 +105,7 @@
11280 pop %r12
11281 pop %rbp
11282 pop %rbx
11283 + pax_force_retaddr 0, 1
11284 ret
11285
11286 ENDPROC(\name)
11287 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11288 index 8d3e113..898b161 100644
11289 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11290 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11291 @@ -24,6 +24,7 @@
11292 */
11293
11294 #include <linux/linkage.h>
11295 +#include <asm/alternative-asm.h>
11296 #include "glue_helper-asm-avx.S"
11297
11298 .file "twofish-avx-x86_64-asm_64.S"
11299 @@ -282,6 +283,7 @@ __twofish_enc_blk8:
11300 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11301 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11302
11303 + pax_force_retaddr 0, 1
11304 ret;
11305 ENDPROC(__twofish_enc_blk8)
11306
11307 @@ -322,6 +324,7 @@ __twofish_dec_blk8:
11308 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11309 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11310
11311 + pax_force_retaddr 0, 1
11312 ret;
11313 ENDPROC(__twofish_dec_blk8)
11314
11315 @@ -340,6 +343,7 @@ ENTRY(twofish_ecb_enc_8way)
11316
11317 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11318
11319 + pax_force_retaddr 0, 1
11320 ret;
11321 ENDPROC(twofish_ecb_enc_8way)
11322
11323 @@ -358,6 +362,7 @@ ENTRY(twofish_ecb_dec_8way)
11324
11325 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11326
11327 + pax_force_retaddr 0, 1
11328 ret;
11329 ENDPROC(twofish_ecb_dec_8way)
11330
11331 @@ -381,6 +386,7 @@ ENTRY(twofish_cbc_dec_8way)
11332
11333 popq %r12;
11334
11335 + pax_force_retaddr 0, 1
11336 ret;
11337 ENDPROC(twofish_cbc_dec_8way)
11338
11339 @@ -406,5 +412,6 @@ ENTRY(twofish_ctr_8way)
11340
11341 popq %r12;
11342
11343 + pax_force_retaddr 0, 1
11344 ret;
11345 ENDPROC(twofish_ctr_8way)
11346 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11347 index 1c3b7ce..b365c5e 100644
11348 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11349 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11350 @@ -21,6 +21,7 @@
11351 */
11352
11353 #include <linux/linkage.h>
11354 +#include <asm/alternative-asm.h>
11355
11356 .file "twofish-x86_64-asm-3way.S"
11357 .text
11358 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
11359 popq %r13;
11360 popq %r14;
11361 popq %r15;
11362 + pax_force_retaddr 0, 1
11363 ret;
11364
11365 .L__enc_xor3:
11366 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
11367 popq %r13;
11368 popq %r14;
11369 popq %r15;
11370 + pax_force_retaddr 0, 1
11371 ret;
11372 ENDPROC(__twofish_enc_blk_3way)
11373
11374 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
11375 popq %r13;
11376 popq %r14;
11377 popq %r15;
11378 + pax_force_retaddr 0, 1
11379 ret;
11380 ENDPROC(twofish_dec_blk_3way)
11381 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11382 index a039d21..29e7615 100644
11383 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11384 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11385 @@ -22,6 +22,7 @@
11386
11387 #include <linux/linkage.h>
11388 #include <asm/asm-offsets.h>
11389 +#include <asm/alternative-asm.h>
11390
11391 #define a_offset 0
11392 #define b_offset 4
11393 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
11394
11395 popq R1
11396 movq $1,%rax
11397 + pax_force_retaddr 0, 1
11398 ret
11399 ENDPROC(twofish_enc_blk)
11400
11401 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
11402
11403 popq R1
11404 movq $1,%rax
11405 + pax_force_retaddr 0, 1
11406 ret
11407 ENDPROC(twofish_dec_blk)
11408 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11409 index 03abf9b..a42ba29 100644
11410 --- a/arch/x86/ia32/ia32_aout.c
11411 +++ b/arch/x86/ia32/ia32_aout.c
11412 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11413 unsigned long dump_start, dump_size;
11414 struct user32 dump;
11415
11416 + memset(&dump, 0, sizeof(dump));
11417 +
11418 fs = get_fs();
11419 set_fs(KERNEL_DS);
11420 has_dumped = 1;
11421 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11422 index cf1a471..3bc4cf8 100644
11423 --- a/arch/x86/ia32/ia32_signal.c
11424 +++ b/arch/x86/ia32/ia32_signal.c
11425 @@ -340,7 +340,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
11426 sp -= frame_size;
11427 /* Align the stack pointer according to the i386 ABI,
11428 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11429 - sp = ((sp + 4) & -16ul) - 4;
11430 + sp = ((sp - 12) & -16ul) - 4;
11431 return (void __user *) sp;
11432 }
11433
11434 @@ -398,7 +398,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
11435 * These are actually not used anymore, but left because some
11436 * gdb versions depend on them as a marker.
11437 */
11438 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11439 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11440 } put_user_catch(err);
11441
11442 if (err)
11443 @@ -440,7 +440,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11444 0xb8,
11445 __NR_ia32_rt_sigreturn,
11446 0x80cd,
11447 - 0,
11448 + 0
11449 };
11450
11451 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
11452 @@ -463,16 +463,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11453
11454 if (ksig->ka.sa.sa_flags & SA_RESTORER)
11455 restorer = ksig->ka.sa.sa_restorer;
11456 + else if (current->mm->context.vdso)
11457 + /* Return stub is in 32bit vsyscall page */
11458 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11459 else
11460 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11461 - rt_sigreturn);
11462 + restorer = &frame->retcode;
11463 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11464
11465 /*
11466 * Not actually used anymore, but left because some gdb
11467 * versions need it.
11468 */
11469 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11470 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11471 } put_user_catch(err);
11472
11473 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
11474 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11475 index 474dc1b..be7bff5 100644
11476 --- a/arch/x86/ia32/ia32entry.S
11477 +++ b/arch/x86/ia32/ia32entry.S
11478 @@ -15,8 +15,10 @@
11479 #include <asm/irqflags.h>
11480 #include <asm/asm.h>
11481 #include <asm/smap.h>
11482 +#include <asm/pgtable.h>
11483 #include <linux/linkage.h>
11484 #include <linux/err.h>
11485 +#include <asm/alternative-asm.h>
11486
11487 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11488 #include <linux/elf-em.h>
11489 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11490 ENDPROC(native_irq_enable_sysexit)
11491 #endif
11492
11493 + .macro pax_enter_kernel_user
11494 + pax_set_fptr_mask
11495 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11496 + call pax_enter_kernel_user
11497 +#endif
11498 + .endm
11499 +
11500 + .macro pax_exit_kernel_user
11501 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11502 + call pax_exit_kernel_user
11503 +#endif
11504 +#ifdef CONFIG_PAX_RANDKSTACK
11505 + pushq %rax
11506 + pushq %r11
11507 + call pax_randomize_kstack
11508 + popq %r11
11509 + popq %rax
11510 +#endif
11511 + .endm
11512 +
11513 +.macro pax_erase_kstack
11514 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11515 + call pax_erase_kstack
11516 +#endif
11517 +.endm
11518 +
11519 /*
11520 * 32bit SYSENTER instruction entry.
11521 *
11522 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11523 CFI_REGISTER rsp,rbp
11524 SWAPGS_UNSAFE_STACK
11525 movq PER_CPU_VAR(kernel_stack), %rsp
11526 - addq $(KERNEL_STACK_OFFSET),%rsp
11527 - /*
11528 - * No need to follow this irqs on/off section: the syscall
11529 - * disabled irqs, here we enable it straight after entry:
11530 - */
11531 - ENABLE_INTERRUPTS(CLBR_NONE)
11532 movl %ebp,%ebp /* zero extension */
11533 pushq_cfi $__USER32_DS
11534 /*CFI_REL_OFFSET ss,0*/
11535 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11536 CFI_REL_OFFSET rsp,0
11537 pushfq_cfi
11538 /*CFI_REL_OFFSET rflags,0*/
11539 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11540 - CFI_REGISTER rip,r10
11541 + orl $X86_EFLAGS_IF,(%rsp)
11542 + GET_THREAD_INFO(%r11)
11543 + movl TI_sysenter_return(%r11), %r11d
11544 + CFI_REGISTER rip,r11
11545 pushq_cfi $__USER32_CS
11546 /*CFI_REL_OFFSET cs,0*/
11547 movl %eax, %eax
11548 - pushq_cfi %r10
11549 + pushq_cfi %r11
11550 CFI_REL_OFFSET rip,0
11551 pushq_cfi %rax
11552 cld
11553 SAVE_ARGS 0,1,0
11554 + pax_enter_kernel_user
11555 +
11556 +#ifdef CONFIG_PAX_RANDKSTACK
11557 + pax_erase_kstack
11558 +#endif
11559 +
11560 + /*
11561 + * No need to follow this irqs on/off section: the syscall
11562 + * disabled irqs, here we enable it straight after entry:
11563 + */
11564 + ENABLE_INTERRUPTS(CLBR_NONE)
11565 /* no need to do an access_ok check here because rbp has been
11566 32bit zero extended */
11567 +
11568 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11569 + mov pax_user_shadow_base,%r11
11570 + add %r11,%rbp
11571 +#endif
11572 +
11573 ASM_STAC
11574 1: movl (%rbp),%ebp
11575 _ASM_EXTABLE(1b,ia32_badarg)
11576 ASM_CLAC
11577 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11578 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11579 + GET_THREAD_INFO(%r11)
11580 + orl $TS_COMPAT,TI_status(%r11)
11581 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11582 CFI_REMEMBER_STATE
11583 jnz sysenter_tracesys
11584 cmpq $(IA32_NR_syscalls-1),%rax
11585 @@ -162,12 +204,15 @@ sysenter_do_call:
11586 sysenter_dispatch:
11587 call *ia32_sys_call_table(,%rax,8)
11588 movq %rax,RAX-ARGOFFSET(%rsp)
11589 + GET_THREAD_INFO(%r11)
11590 DISABLE_INTERRUPTS(CLBR_NONE)
11591 TRACE_IRQS_OFF
11592 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11593 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11594 jnz sysexit_audit
11595 sysexit_from_sys_call:
11596 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11597 + pax_exit_kernel_user
11598 + pax_erase_kstack
11599 + andl $~TS_COMPAT,TI_status(%r11)
11600 /* clear IF, that popfq doesn't enable interrupts early */
11601 andl $~0x200,EFLAGS-R11(%rsp)
11602 movl RIP-R11(%rsp),%edx /* User %eip */
11603 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11604 movl %eax,%esi /* 2nd arg: syscall number */
11605 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11606 call __audit_syscall_entry
11607 +
11608 + pax_erase_kstack
11609 +
11610 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11611 cmpq $(IA32_NR_syscalls-1),%rax
11612 ja ia32_badsys
11613 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11614 .endm
11615
11616 .macro auditsys_exit exit
11617 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11618 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11619 jnz ia32_ret_from_sys_call
11620 TRACE_IRQS_ON
11621 ENABLE_INTERRUPTS(CLBR_NONE)
11622 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11623 1: setbe %al /* 1 if error, 0 if not */
11624 movzbl %al,%edi /* zero-extend that into %edi */
11625 call __audit_syscall_exit
11626 + GET_THREAD_INFO(%r11)
11627 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11628 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11629 DISABLE_INTERRUPTS(CLBR_NONE)
11630 TRACE_IRQS_OFF
11631 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11632 + testl %edi,TI_flags(%r11)
11633 jz \exit
11634 CLEAR_RREGS -ARGOFFSET
11635 jmp int_with_check
11636 @@ -237,7 +286,7 @@ sysexit_audit:
11637
11638 sysenter_tracesys:
11639 #ifdef CONFIG_AUDITSYSCALL
11640 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11641 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11642 jz sysenter_auditsys
11643 #endif
11644 SAVE_REST
11645 @@ -249,6 +298,9 @@ sysenter_tracesys:
11646 RESTORE_REST
11647 cmpq $(IA32_NR_syscalls-1),%rax
11648 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
11649 +
11650 + pax_erase_kstack
11651 +
11652 jmp sysenter_do_call
11653 CFI_ENDPROC
11654 ENDPROC(ia32_sysenter_target)
11655 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
11656 ENTRY(ia32_cstar_target)
11657 CFI_STARTPROC32 simple
11658 CFI_SIGNAL_FRAME
11659 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
11660 + CFI_DEF_CFA rsp,0
11661 CFI_REGISTER rip,rcx
11662 /*CFI_REGISTER rflags,r11*/
11663 SWAPGS_UNSAFE_STACK
11664 movl %esp,%r8d
11665 CFI_REGISTER rsp,r8
11666 movq PER_CPU_VAR(kernel_stack),%rsp
11667 + SAVE_ARGS 8*6,0,0
11668 + pax_enter_kernel_user
11669 +
11670 +#ifdef CONFIG_PAX_RANDKSTACK
11671 + pax_erase_kstack
11672 +#endif
11673 +
11674 /*
11675 * No need to follow this irqs on/off section: the syscall
11676 * disabled irqs and here we enable it straight after entry:
11677 */
11678 ENABLE_INTERRUPTS(CLBR_NONE)
11679 - SAVE_ARGS 8,0,0
11680 movl %eax,%eax /* zero extension */
11681 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
11682 movq %rcx,RIP-ARGOFFSET(%rsp)
11683 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
11684 /* no need to do an access_ok check here because r8 has been
11685 32bit zero extended */
11686 /* hardware stack frame is complete now */
11687 +
11688 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11689 + mov pax_user_shadow_base,%r11
11690 + add %r11,%r8
11691 +#endif
11692 +
11693 ASM_STAC
11694 1: movl (%r8),%r9d
11695 _ASM_EXTABLE(1b,ia32_badarg)
11696 ASM_CLAC
11697 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11698 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11699 + GET_THREAD_INFO(%r11)
11700 + orl $TS_COMPAT,TI_status(%r11)
11701 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11702 CFI_REMEMBER_STATE
11703 jnz cstar_tracesys
11704 cmpq $IA32_NR_syscalls-1,%rax
11705 @@ -319,12 +384,15 @@ cstar_do_call:
11706 cstar_dispatch:
11707 call *ia32_sys_call_table(,%rax,8)
11708 movq %rax,RAX-ARGOFFSET(%rsp)
11709 + GET_THREAD_INFO(%r11)
11710 DISABLE_INTERRUPTS(CLBR_NONE)
11711 TRACE_IRQS_OFF
11712 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11713 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11714 jnz sysretl_audit
11715 sysretl_from_sys_call:
11716 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11717 + pax_exit_kernel_user
11718 + pax_erase_kstack
11719 + andl $~TS_COMPAT,TI_status(%r11)
11720 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
11721 movl RIP-ARGOFFSET(%rsp),%ecx
11722 CFI_REGISTER rip,rcx
11723 @@ -352,7 +420,7 @@ sysretl_audit:
11724
11725 cstar_tracesys:
11726 #ifdef CONFIG_AUDITSYSCALL
11727 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11728 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11729 jz cstar_auditsys
11730 #endif
11731 xchgl %r9d,%ebp
11732 @@ -366,6 +434,9 @@ cstar_tracesys:
11733 xchgl %ebp,%r9d
11734 cmpq $(IA32_NR_syscalls-1),%rax
11735 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
11736 +
11737 + pax_erase_kstack
11738 +
11739 jmp cstar_do_call
11740 END(ia32_cstar_target)
11741
11742 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
11743 CFI_REL_OFFSET rip,RIP-RIP
11744 PARAVIRT_ADJUST_EXCEPTION_FRAME
11745 SWAPGS
11746 - /*
11747 - * No need to follow this irqs on/off section: the syscall
11748 - * disabled irqs and here we enable it straight after entry:
11749 - */
11750 - ENABLE_INTERRUPTS(CLBR_NONE)
11751 movl %eax,%eax
11752 pushq_cfi %rax
11753 cld
11754 /* note the registers are not zero extended to the sf.
11755 this could be a problem. */
11756 SAVE_ARGS 0,1,0
11757 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11758 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11759 + pax_enter_kernel_user
11760 +
11761 +#ifdef CONFIG_PAX_RANDKSTACK
11762 + pax_erase_kstack
11763 +#endif
11764 +
11765 + /*
11766 + * No need to follow this irqs on/off section: the syscall
11767 + * disabled irqs and here we enable it straight after entry:
11768 + */
11769 + ENABLE_INTERRUPTS(CLBR_NONE)
11770 + GET_THREAD_INFO(%r11)
11771 + orl $TS_COMPAT,TI_status(%r11)
11772 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11773 jnz ia32_tracesys
11774 cmpq $(IA32_NR_syscalls-1),%rax
11775 ja ia32_badsys
11776 @@ -442,6 +520,9 @@ ia32_tracesys:
11777 RESTORE_REST
11778 cmpq $(IA32_NR_syscalls-1),%rax
11779 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
11780 +
11781 + pax_erase_kstack
11782 +
11783 jmp ia32_do_call
11784 END(ia32_syscall)
11785
11786 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
11787 index ad7a20c..1ffa3c1 100644
11788 --- a/arch/x86/ia32/sys_ia32.c
11789 +++ b/arch/x86/ia32/sys_ia32.c
11790 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
11791 */
11792 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
11793 {
11794 - typeof(ubuf->st_uid) uid = 0;
11795 - typeof(ubuf->st_gid) gid = 0;
11796 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
11797 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
11798 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
11799 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
11800 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
11801 @@ -205,7 +205,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
11802 return -EFAULT;
11803
11804 set_fs(KERNEL_DS);
11805 - ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
11806 + ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __force_user *)&of : NULL,
11807 count);
11808 set_fs(old_fs);
11809
11810 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
11811 index 372231c..a5aa1a1 100644
11812 --- a/arch/x86/include/asm/alternative-asm.h
11813 +++ b/arch/x86/include/asm/alternative-asm.h
11814 @@ -18,6 +18,45 @@
11815 .endm
11816 #endif
11817
11818 +#ifdef KERNEXEC_PLUGIN
11819 + .macro pax_force_retaddr_bts rip=0
11820 + btsq $63,\rip(%rsp)
11821 + .endm
11822 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
11823 + .macro pax_force_retaddr rip=0, reload=0
11824 + btsq $63,\rip(%rsp)
11825 + .endm
11826 + .macro pax_force_fptr ptr
11827 + btsq $63,\ptr
11828 + .endm
11829 + .macro pax_set_fptr_mask
11830 + .endm
11831 +#endif
11832 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
11833 + .macro pax_force_retaddr rip=0, reload=0
11834 + .if \reload
11835 + pax_set_fptr_mask
11836 + .endif
11837 + orq %r10,\rip(%rsp)
11838 + .endm
11839 + .macro pax_force_fptr ptr
11840 + orq %r10,\ptr
11841 + .endm
11842 + .macro pax_set_fptr_mask
11843 + movabs $0x8000000000000000,%r10
11844 + .endm
11845 +#endif
11846 +#else
11847 + .macro pax_force_retaddr rip=0, reload=0
11848 + .endm
11849 + .macro pax_force_fptr ptr
11850 + .endm
11851 + .macro pax_force_retaddr_bts rip=0
11852 + .endm
11853 + .macro pax_set_fptr_mask
11854 + .endm
11855 +#endif
11856 +
11857 .macro altinstruction_entry orig alt feature orig_len alt_len
11858 .long \orig - .
11859 .long \alt - .
11860 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
11861 index 58ed6d9..f1cbe58 100644
11862 --- a/arch/x86/include/asm/alternative.h
11863 +++ b/arch/x86/include/asm/alternative.h
11864 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11865 ".pushsection .discard,\"aw\",@progbits\n" \
11866 DISCARD_ENTRY(1) \
11867 ".popsection\n" \
11868 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11869 + ".pushsection .altinstr_replacement, \"a\"\n" \
11870 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
11871 ".popsection"
11872
11873 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11874 DISCARD_ENTRY(1) \
11875 DISCARD_ENTRY(2) \
11876 ".popsection\n" \
11877 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11878 + ".pushsection .altinstr_replacement, \"a\"\n" \
11879 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
11880 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
11881 ".popsection"
11882 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
11883 index 3388034..050f0b9 100644
11884 --- a/arch/x86/include/asm/apic.h
11885 +++ b/arch/x86/include/asm/apic.h
11886 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
11887
11888 #ifdef CONFIG_X86_LOCAL_APIC
11889
11890 -extern unsigned int apic_verbosity;
11891 +extern int apic_verbosity;
11892 extern int local_apic_timer_c2_ok;
11893
11894 extern int disable_apic;
11895 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
11896 index 20370c6..a2eb9b0 100644
11897 --- a/arch/x86/include/asm/apm.h
11898 +++ b/arch/x86/include/asm/apm.h
11899 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
11900 __asm__ __volatile__(APM_DO_ZERO_SEGS
11901 "pushl %%edi\n\t"
11902 "pushl %%ebp\n\t"
11903 - "lcall *%%cs:apm_bios_entry\n\t"
11904 + "lcall *%%ss:apm_bios_entry\n\t"
11905 "setc %%al\n\t"
11906 "popl %%ebp\n\t"
11907 "popl %%edi\n\t"
11908 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
11909 __asm__ __volatile__(APM_DO_ZERO_SEGS
11910 "pushl %%edi\n\t"
11911 "pushl %%ebp\n\t"
11912 - "lcall *%%cs:apm_bios_entry\n\t"
11913 + "lcall *%%ss:apm_bios_entry\n\t"
11914 "setc %%bl\n\t"
11915 "popl %%ebp\n\t"
11916 "popl %%edi\n\t"
11917 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
11918 index 722aa3b..3a0bb27 100644
11919 --- a/arch/x86/include/asm/atomic.h
11920 +++ b/arch/x86/include/asm/atomic.h
11921 @@ -22,7 +22,18 @@
11922 */
11923 static inline int atomic_read(const atomic_t *v)
11924 {
11925 - return (*(volatile int *)&(v)->counter);
11926 + return (*(volatile const int *)&(v)->counter);
11927 +}
11928 +
11929 +/**
11930 + * atomic_read_unchecked - read atomic variable
11931 + * @v: pointer of type atomic_unchecked_t
11932 + *
11933 + * Atomically reads the value of @v.
11934 + */
11935 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
11936 +{
11937 + return (*(volatile const int *)&(v)->counter);
11938 }
11939
11940 /**
11941 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
11942 }
11943
11944 /**
11945 + * atomic_set_unchecked - set atomic variable
11946 + * @v: pointer of type atomic_unchecked_t
11947 + * @i: required value
11948 + *
11949 + * Atomically sets the value of @v to @i.
11950 + */
11951 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
11952 +{
11953 + v->counter = i;
11954 +}
11955 +
11956 +/**
11957 * atomic_add - add integer to atomic variable
11958 * @i: integer value to add
11959 * @v: pointer of type atomic_t
11960 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
11961 */
11962 static inline void atomic_add(int i, atomic_t *v)
11963 {
11964 - asm volatile(LOCK_PREFIX "addl %1,%0"
11965 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
11966 +
11967 +#ifdef CONFIG_PAX_REFCOUNT
11968 + "jno 0f\n"
11969 + LOCK_PREFIX "subl %1,%0\n"
11970 + "int $4\n0:\n"
11971 + _ASM_EXTABLE(0b, 0b)
11972 +#endif
11973 +
11974 + : "+m" (v->counter)
11975 + : "ir" (i));
11976 +}
11977 +
11978 +/**
11979 + * atomic_add_unchecked - add integer to atomic variable
11980 + * @i: integer value to add
11981 + * @v: pointer of type atomic_unchecked_t
11982 + *
11983 + * Atomically adds @i to @v.
11984 + */
11985 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
11986 +{
11987 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
11988 : "+m" (v->counter)
11989 : "ir" (i));
11990 }
11991 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
11992 */
11993 static inline void atomic_sub(int i, atomic_t *v)
11994 {
11995 - asm volatile(LOCK_PREFIX "subl %1,%0"
11996 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
11997 +
11998 +#ifdef CONFIG_PAX_REFCOUNT
11999 + "jno 0f\n"
12000 + LOCK_PREFIX "addl %1,%0\n"
12001 + "int $4\n0:\n"
12002 + _ASM_EXTABLE(0b, 0b)
12003 +#endif
12004 +
12005 + : "+m" (v->counter)
12006 + : "ir" (i));
12007 +}
12008 +
12009 +/**
12010 + * atomic_sub_unchecked - subtract integer from atomic variable
12011 + * @i: integer value to subtract
12012 + * @v: pointer of type atomic_unchecked_t
12013 + *
12014 + * Atomically subtracts @i from @v.
12015 + */
12016 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
12017 +{
12018 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12019 : "+m" (v->counter)
12020 : "ir" (i));
12021 }
12022 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12023 {
12024 unsigned char c;
12025
12026 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
12027 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
12028 +
12029 +#ifdef CONFIG_PAX_REFCOUNT
12030 + "jno 0f\n"
12031 + LOCK_PREFIX "addl %2,%0\n"
12032 + "int $4\n0:\n"
12033 + _ASM_EXTABLE(0b, 0b)
12034 +#endif
12035 +
12036 + "sete %1\n"
12037 : "+m" (v->counter), "=qm" (c)
12038 : "ir" (i) : "memory");
12039 return c;
12040 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12041 */
12042 static inline void atomic_inc(atomic_t *v)
12043 {
12044 - asm volatile(LOCK_PREFIX "incl %0"
12045 + asm volatile(LOCK_PREFIX "incl %0\n"
12046 +
12047 +#ifdef CONFIG_PAX_REFCOUNT
12048 + "jno 0f\n"
12049 + LOCK_PREFIX "decl %0\n"
12050 + "int $4\n0:\n"
12051 + _ASM_EXTABLE(0b, 0b)
12052 +#endif
12053 +
12054 + : "+m" (v->counter));
12055 +}
12056 +
12057 +/**
12058 + * atomic_inc_unchecked - increment atomic variable
12059 + * @v: pointer of type atomic_unchecked_t
12060 + *
12061 + * Atomically increments @v by 1.
12062 + */
12063 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12064 +{
12065 + asm volatile(LOCK_PREFIX "incl %0\n"
12066 : "+m" (v->counter));
12067 }
12068
12069 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12070 */
12071 static inline void atomic_dec(atomic_t *v)
12072 {
12073 - asm volatile(LOCK_PREFIX "decl %0"
12074 + asm volatile(LOCK_PREFIX "decl %0\n"
12075 +
12076 +#ifdef CONFIG_PAX_REFCOUNT
12077 + "jno 0f\n"
12078 + LOCK_PREFIX "incl %0\n"
12079 + "int $4\n0:\n"
12080 + _ASM_EXTABLE(0b, 0b)
12081 +#endif
12082 +
12083 + : "+m" (v->counter));
12084 +}
12085 +
12086 +/**
12087 + * atomic_dec_unchecked - decrement atomic variable
12088 + * @v: pointer of type atomic_unchecked_t
12089 + *
12090 + * Atomically decrements @v by 1.
12091 + */
12092 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12093 +{
12094 + asm volatile(LOCK_PREFIX "decl %0\n"
12095 : "+m" (v->counter));
12096 }
12097
12098 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12099 {
12100 unsigned char c;
12101
12102 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12103 + asm volatile(LOCK_PREFIX "decl %0\n"
12104 +
12105 +#ifdef CONFIG_PAX_REFCOUNT
12106 + "jno 0f\n"
12107 + LOCK_PREFIX "incl %0\n"
12108 + "int $4\n0:\n"
12109 + _ASM_EXTABLE(0b, 0b)
12110 +#endif
12111 +
12112 + "sete %1\n"
12113 : "+m" (v->counter), "=qm" (c)
12114 : : "memory");
12115 return c != 0;
12116 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12117 {
12118 unsigned char c;
12119
12120 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
12121 + asm volatile(LOCK_PREFIX "incl %0\n"
12122 +
12123 +#ifdef CONFIG_PAX_REFCOUNT
12124 + "jno 0f\n"
12125 + LOCK_PREFIX "decl %0\n"
12126 + "int $4\n0:\n"
12127 + _ASM_EXTABLE(0b, 0b)
12128 +#endif
12129 +
12130 + "sete %1\n"
12131 + : "+m" (v->counter), "=qm" (c)
12132 + : : "memory");
12133 + return c != 0;
12134 +}
12135 +
12136 +/**
12137 + * atomic_inc_and_test_unchecked - increment and test
12138 + * @v: pointer of type atomic_unchecked_t
12139 + *
12140 + * Atomically increments @v by 1
12141 + * and returns true if the result is zero, or false for all
12142 + * other cases.
12143 + */
12144 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12145 +{
12146 + unsigned char c;
12147 +
12148 + asm volatile(LOCK_PREFIX "incl %0\n"
12149 + "sete %1\n"
12150 : "+m" (v->counter), "=qm" (c)
12151 : : "memory");
12152 return c != 0;
12153 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12154 {
12155 unsigned char c;
12156
12157 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12158 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12159 +
12160 +#ifdef CONFIG_PAX_REFCOUNT
12161 + "jno 0f\n"
12162 + LOCK_PREFIX "subl %2,%0\n"
12163 + "int $4\n0:\n"
12164 + _ASM_EXTABLE(0b, 0b)
12165 +#endif
12166 +
12167 + "sets %1\n"
12168 : "+m" (v->counter), "=qm" (c)
12169 : "ir" (i) : "memory");
12170 return c;
12171 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12172 */
12173 static inline int atomic_add_return(int i, atomic_t *v)
12174 {
12175 + return i + xadd_check_overflow(&v->counter, i);
12176 +}
12177 +
12178 +/**
12179 + * atomic_add_return_unchecked - add integer and return
12180 + * @i: integer value to add
12181 + * @v: pointer of type atomic_unchecked_t
12182 + *
12183 + * Atomically adds @i to @v and returns @i + @v
12184 + */
12185 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12186 +{
12187 return i + xadd(&v->counter, i);
12188 }
12189
12190 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12191 }
12192
12193 #define atomic_inc_return(v) (atomic_add_return(1, v))
12194 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12195 +{
12196 + return atomic_add_return_unchecked(1, v);
12197 +}
12198 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12199
12200 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12201 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12202 return cmpxchg(&v->counter, old, new);
12203 }
12204
12205 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12206 +{
12207 + return cmpxchg(&v->counter, old, new);
12208 +}
12209 +
12210 static inline int atomic_xchg(atomic_t *v, int new)
12211 {
12212 return xchg(&v->counter, new);
12213 }
12214
12215 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12216 +{
12217 + return xchg(&v->counter, new);
12218 +}
12219 +
12220 /**
12221 * __atomic_add_unless - add unless the number is already a given value
12222 * @v: pointer of type atomic_t
12223 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12224 */
12225 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12226 {
12227 - int c, old;
12228 + int c, old, new;
12229 c = atomic_read(v);
12230 for (;;) {
12231 - if (unlikely(c == (u)))
12232 + if (unlikely(c == u))
12233 break;
12234 - old = atomic_cmpxchg((v), c, c + (a));
12235 +
12236 + asm volatile("addl %2,%0\n"
12237 +
12238 +#ifdef CONFIG_PAX_REFCOUNT
12239 + "jno 0f\n"
12240 + "subl %2,%0\n"
12241 + "int $4\n0:\n"
12242 + _ASM_EXTABLE(0b, 0b)
12243 +#endif
12244 +
12245 + : "=r" (new)
12246 + : "0" (c), "ir" (a));
12247 +
12248 + old = atomic_cmpxchg(v, c, new);
12249 if (likely(old == c))
12250 break;
12251 c = old;
12252 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12253 }
12254
12255 /**
12256 + * atomic_inc_not_zero_hint - increment if not null
12257 + * @v: pointer of type atomic_t
12258 + * @hint: probable value of the atomic before the increment
12259 + *
12260 + * This version of atomic_inc_not_zero() gives a hint of probable
12261 + * value of the atomic. This helps processor to not read the memory
12262 + * before doing the atomic read/modify/write cycle, lowering
12263 + * number of bus transactions on some arches.
12264 + *
12265 + * Returns: 0 if increment was not done, 1 otherwise.
12266 + */
12267 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12268 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12269 +{
12270 + int val, c = hint, new;
12271 +
12272 + /* sanity test, should be removed by compiler if hint is a constant */
12273 + if (!hint)
12274 + return __atomic_add_unless(v, 1, 0);
12275 +
12276 + do {
12277 + asm volatile("incl %0\n"
12278 +
12279 +#ifdef CONFIG_PAX_REFCOUNT
12280 + "jno 0f\n"
12281 + "decl %0\n"
12282 + "int $4\n0:\n"
12283 + _ASM_EXTABLE(0b, 0b)
12284 +#endif
12285 +
12286 + : "=r" (new)
12287 + : "0" (c));
12288 +
12289 + val = atomic_cmpxchg(v, c, new);
12290 + if (val == c)
12291 + return 1;
12292 + c = val;
12293 + } while (c);
12294 +
12295 + return 0;
12296 +}
12297 +
12298 +/**
12299 * atomic_inc_short - increment of a short integer
12300 * @v: pointer to type int
12301 *
12302 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12303 #endif
12304
12305 /* These are x86-specific, used by some header files */
12306 -#define atomic_clear_mask(mask, addr) \
12307 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12308 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12309 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12310 +{
12311 + asm volatile(LOCK_PREFIX "andl %1,%0"
12312 + : "+m" (v->counter)
12313 + : "r" (~(mask))
12314 + : "memory");
12315 +}
12316
12317 -#define atomic_set_mask(mask, addr) \
12318 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12319 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12320 - : "memory")
12321 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12322 +{
12323 + asm volatile(LOCK_PREFIX "andl %1,%0"
12324 + : "+m" (v->counter)
12325 + : "r" (~(mask))
12326 + : "memory");
12327 +}
12328 +
12329 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12330 +{
12331 + asm volatile(LOCK_PREFIX "orl %1,%0"
12332 + : "+m" (v->counter)
12333 + : "r" (mask)
12334 + : "memory");
12335 +}
12336 +
12337 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12338 +{
12339 + asm volatile(LOCK_PREFIX "orl %1,%0"
12340 + : "+m" (v->counter)
12341 + : "r" (mask)
12342 + : "memory");
12343 +}
12344
12345 /* Atomic operations are already serializing on x86 */
12346 #define smp_mb__before_atomic_dec() barrier()
12347 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12348 index b154de7..aadebd8 100644
12349 --- a/arch/x86/include/asm/atomic64_32.h
12350 +++ b/arch/x86/include/asm/atomic64_32.h
12351 @@ -12,6 +12,14 @@ typedef struct {
12352 u64 __aligned(8) counter;
12353 } atomic64_t;
12354
12355 +#ifdef CONFIG_PAX_REFCOUNT
12356 +typedef struct {
12357 + u64 __aligned(8) counter;
12358 +} atomic64_unchecked_t;
12359 +#else
12360 +typedef atomic64_t atomic64_unchecked_t;
12361 +#endif
12362 +
12363 #define ATOMIC64_INIT(val) { (val) }
12364
12365 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12366 @@ -37,21 +45,31 @@ typedef struct {
12367 ATOMIC64_DECL_ONE(sym##_386)
12368
12369 ATOMIC64_DECL_ONE(add_386);
12370 +ATOMIC64_DECL_ONE(add_unchecked_386);
12371 ATOMIC64_DECL_ONE(sub_386);
12372 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12373 ATOMIC64_DECL_ONE(inc_386);
12374 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12375 ATOMIC64_DECL_ONE(dec_386);
12376 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12377 #endif
12378
12379 #define alternative_atomic64(f, out, in...) \
12380 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12381
12382 ATOMIC64_DECL(read);
12383 +ATOMIC64_DECL(read_unchecked);
12384 ATOMIC64_DECL(set);
12385 +ATOMIC64_DECL(set_unchecked);
12386 ATOMIC64_DECL(xchg);
12387 ATOMIC64_DECL(add_return);
12388 +ATOMIC64_DECL(add_return_unchecked);
12389 ATOMIC64_DECL(sub_return);
12390 +ATOMIC64_DECL(sub_return_unchecked);
12391 ATOMIC64_DECL(inc_return);
12392 +ATOMIC64_DECL(inc_return_unchecked);
12393 ATOMIC64_DECL(dec_return);
12394 +ATOMIC64_DECL(dec_return_unchecked);
12395 ATOMIC64_DECL(dec_if_positive);
12396 ATOMIC64_DECL(inc_not_zero);
12397 ATOMIC64_DECL(add_unless);
12398 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12399 }
12400
12401 /**
12402 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12403 + * @p: pointer to type atomic64_unchecked_t
12404 + * @o: expected value
12405 + * @n: new value
12406 + *
12407 + * Atomically sets @v to @n if it was equal to @o and returns
12408 + * the old value.
12409 + */
12410 +
12411 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12412 +{
12413 + return cmpxchg64(&v->counter, o, n);
12414 +}
12415 +
12416 +/**
12417 * atomic64_xchg - xchg atomic64 variable
12418 * @v: pointer to type atomic64_t
12419 * @n: value to assign
12420 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12421 }
12422
12423 /**
12424 + * atomic64_set_unchecked - set atomic64 variable
12425 + * @v: pointer to type atomic64_unchecked_t
12426 + * @n: value to assign
12427 + *
12428 + * Atomically sets the value of @v to @n.
12429 + */
12430 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12431 +{
12432 + unsigned high = (unsigned)(i >> 32);
12433 + unsigned low = (unsigned)i;
12434 + alternative_atomic64(set, /* no output */,
12435 + "S" (v), "b" (low), "c" (high)
12436 + : "eax", "edx", "memory");
12437 +}
12438 +
12439 +/**
12440 * atomic64_read - read atomic64 variable
12441 * @v: pointer to type atomic64_t
12442 *
12443 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12444 }
12445
12446 /**
12447 + * atomic64_read_unchecked - read atomic64 variable
12448 + * @v: pointer to type atomic64_unchecked_t
12449 + *
12450 + * Atomically reads the value of @v and returns it.
12451 + */
12452 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12453 +{
12454 + long long r;
12455 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12456 + return r;
12457 + }
12458 +
12459 +/**
12460 * atomic64_add_return - add and return
12461 * @i: integer value to add
12462 * @v: pointer to type atomic64_t
12463 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12464 return i;
12465 }
12466
12467 +/**
12468 + * atomic64_add_return_unchecked - add and return
12469 + * @i: integer value to add
12470 + * @v: pointer to type atomic64_unchecked_t
12471 + *
12472 + * Atomically adds @i to @v and returns @i + *@v
12473 + */
12474 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12475 +{
12476 + alternative_atomic64(add_return_unchecked,
12477 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12478 + ASM_NO_INPUT_CLOBBER("memory"));
12479 + return i;
12480 +}
12481 +
12482 /*
12483 * Other variants with different arithmetic operators:
12484 */
12485 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12486 return a;
12487 }
12488
12489 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12490 +{
12491 + long long a;
12492 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12493 + "S" (v) : "memory", "ecx");
12494 + return a;
12495 +}
12496 +
12497 static inline long long atomic64_dec_return(atomic64_t *v)
12498 {
12499 long long a;
12500 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12501 }
12502
12503 /**
12504 + * atomic64_add_unchecked - add integer to atomic64 variable
12505 + * @i: integer value to add
12506 + * @v: pointer to type atomic64_unchecked_t
12507 + *
12508 + * Atomically adds @i to @v.
12509 + */
12510 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12511 +{
12512 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12513 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12514 + ASM_NO_INPUT_CLOBBER("memory"));
12515 + return i;
12516 +}
12517 +
12518 +/**
12519 * atomic64_sub - subtract the atomic64 variable
12520 * @i: integer value to subtract
12521 * @v: pointer to type atomic64_t
12522 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12523 index 0e1cbfc..5623683 100644
12524 --- a/arch/x86/include/asm/atomic64_64.h
12525 +++ b/arch/x86/include/asm/atomic64_64.h
12526 @@ -18,7 +18,19 @@
12527 */
12528 static inline long atomic64_read(const atomic64_t *v)
12529 {
12530 - return (*(volatile long *)&(v)->counter);
12531 + return (*(volatile const long *)&(v)->counter);
12532 +}
12533 +
12534 +/**
12535 + * atomic64_read_unchecked - read atomic64 variable
12536 + * @v: pointer of type atomic64_unchecked_t
12537 + *
12538 + * Atomically reads the value of @v.
12539 + * Doesn't imply a read memory barrier.
12540 + */
12541 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12542 +{
12543 + return (*(volatile const long *)&(v)->counter);
12544 }
12545
12546 /**
12547 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12548 }
12549
12550 /**
12551 + * atomic64_set_unchecked - set atomic64 variable
12552 + * @v: pointer to type atomic64_unchecked_t
12553 + * @i: required value
12554 + *
12555 + * Atomically sets the value of @v to @i.
12556 + */
12557 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12558 +{
12559 + v->counter = i;
12560 +}
12561 +
12562 +/**
12563 * atomic64_add - add integer to atomic64 variable
12564 * @i: integer value to add
12565 * @v: pointer to type atomic64_t
12566 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12567 */
12568 static inline void atomic64_add(long i, atomic64_t *v)
12569 {
12570 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12571 +
12572 +#ifdef CONFIG_PAX_REFCOUNT
12573 + "jno 0f\n"
12574 + LOCK_PREFIX "subq %1,%0\n"
12575 + "int $4\n0:\n"
12576 + _ASM_EXTABLE(0b, 0b)
12577 +#endif
12578 +
12579 + : "=m" (v->counter)
12580 + : "er" (i), "m" (v->counter));
12581 +}
12582 +
12583 +/**
12584 + * atomic64_add_unchecked - add integer to atomic64 variable
12585 + * @i: integer value to add
12586 + * @v: pointer to type atomic64_unchecked_t
12587 + *
12588 + * Atomically adds @i to @v.
12589 + */
12590 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12591 +{
12592 asm volatile(LOCK_PREFIX "addq %1,%0"
12593 : "=m" (v->counter)
12594 : "er" (i), "m" (v->counter));
12595 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
12596 */
12597 static inline void atomic64_sub(long i, atomic64_t *v)
12598 {
12599 - asm volatile(LOCK_PREFIX "subq %1,%0"
12600 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12601 +
12602 +#ifdef CONFIG_PAX_REFCOUNT
12603 + "jno 0f\n"
12604 + LOCK_PREFIX "addq %1,%0\n"
12605 + "int $4\n0:\n"
12606 + _ASM_EXTABLE(0b, 0b)
12607 +#endif
12608 +
12609 + : "=m" (v->counter)
12610 + : "er" (i), "m" (v->counter));
12611 +}
12612 +
12613 +/**
12614 + * atomic64_sub_unchecked - subtract the atomic64 variable
12615 + * @i: integer value to subtract
12616 + * @v: pointer to type atomic64_unchecked_t
12617 + *
12618 + * Atomically subtracts @i from @v.
12619 + */
12620 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
12621 +{
12622 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12623 : "=m" (v->counter)
12624 : "er" (i), "m" (v->counter));
12625 }
12626 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12627 {
12628 unsigned char c;
12629
12630 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
12631 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
12632 +
12633 +#ifdef CONFIG_PAX_REFCOUNT
12634 + "jno 0f\n"
12635 + LOCK_PREFIX "addq %2,%0\n"
12636 + "int $4\n0:\n"
12637 + _ASM_EXTABLE(0b, 0b)
12638 +#endif
12639 +
12640 + "sete %1\n"
12641 : "=m" (v->counter), "=qm" (c)
12642 : "er" (i), "m" (v->counter) : "memory");
12643 return c;
12644 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12645 */
12646 static inline void atomic64_inc(atomic64_t *v)
12647 {
12648 + asm volatile(LOCK_PREFIX "incq %0\n"
12649 +
12650 +#ifdef CONFIG_PAX_REFCOUNT
12651 + "jno 0f\n"
12652 + LOCK_PREFIX "decq %0\n"
12653 + "int $4\n0:\n"
12654 + _ASM_EXTABLE(0b, 0b)
12655 +#endif
12656 +
12657 + : "=m" (v->counter)
12658 + : "m" (v->counter));
12659 +}
12660 +
12661 +/**
12662 + * atomic64_inc_unchecked - increment atomic64 variable
12663 + * @v: pointer to type atomic64_unchecked_t
12664 + *
12665 + * Atomically increments @v by 1.
12666 + */
12667 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
12668 +{
12669 asm volatile(LOCK_PREFIX "incq %0"
12670 : "=m" (v->counter)
12671 : "m" (v->counter));
12672 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
12673 */
12674 static inline void atomic64_dec(atomic64_t *v)
12675 {
12676 - asm volatile(LOCK_PREFIX "decq %0"
12677 + asm volatile(LOCK_PREFIX "decq %0\n"
12678 +
12679 +#ifdef CONFIG_PAX_REFCOUNT
12680 + "jno 0f\n"
12681 + LOCK_PREFIX "incq %0\n"
12682 + "int $4\n0:\n"
12683 + _ASM_EXTABLE(0b, 0b)
12684 +#endif
12685 +
12686 + : "=m" (v->counter)
12687 + : "m" (v->counter));
12688 +}
12689 +
12690 +/**
12691 + * atomic64_dec_unchecked - decrement atomic64 variable
12692 + * @v: pointer to type atomic64_t
12693 + *
12694 + * Atomically decrements @v by 1.
12695 + */
12696 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
12697 +{
12698 + asm volatile(LOCK_PREFIX "decq %0\n"
12699 : "=m" (v->counter)
12700 : "m" (v->counter));
12701 }
12702 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
12703 {
12704 unsigned char c;
12705
12706 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
12707 + asm volatile(LOCK_PREFIX "decq %0\n"
12708 +
12709 +#ifdef CONFIG_PAX_REFCOUNT
12710 + "jno 0f\n"
12711 + LOCK_PREFIX "incq %0\n"
12712 + "int $4\n0:\n"
12713 + _ASM_EXTABLE(0b, 0b)
12714 +#endif
12715 +
12716 + "sete %1\n"
12717 : "=m" (v->counter), "=qm" (c)
12718 : "m" (v->counter) : "memory");
12719 return c != 0;
12720 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
12721 {
12722 unsigned char c;
12723
12724 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
12725 + asm volatile(LOCK_PREFIX "incq %0\n"
12726 +
12727 +#ifdef CONFIG_PAX_REFCOUNT
12728 + "jno 0f\n"
12729 + LOCK_PREFIX "decq %0\n"
12730 + "int $4\n0:\n"
12731 + _ASM_EXTABLE(0b, 0b)
12732 +#endif
12733 +
12734 + "sete %1\n"
12735 : "=m" (v->counter), "=qm" (c)
12736 : "m" (v->counter) : "memory");
12737 return c != 0;
12738 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12739 {
12740 unsigned char c;
12741
12742 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
12743 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
12744 +
12745 +#ifdef CONFIG_PAX_REFCOUNT
12746 + "jno 0f\n"
12747 + LOCK_PREFIX "subq %2,%0\n"
12748 + "int $4\n0:\n"
12749 + _ASM_EXTABLE(0b, 0b)
12750 +#endif
12751 +
12752 + "sets %1\n"
12753 : "=m" (v->counter), "=qm" (c)
12754 : "er" (i), "m" (v->counter) : "memory");
12755 return c;
12756 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12757 */
12758 static inline long atomic64_add_return(long i, atomic64_t *v)
12759 {
12760 + return i + xadd_check_overflow(&v->counter, i);
12761 +}
12762 +
12763 +/**
12764 + * atomic64_add_return_unchecked - add and return
12765 + * @i: integer value to add
12766 + * @v: pointer to type atomic64_unchecked_t
12767 + *
12768 + * Atomically adds @i to @v and returns @i + @v
12769 + */
12770 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
12771 +{
12772 return i + xadd(&v->counter, i);
12773 }
12774
12775 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
12776 }
12777
12778 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
12779 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12780 +{
12781 + return atomic64_add_return_unchecked(1, v);
12782 +}
12783 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
12784
12785 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12786 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12787 return cmpxchg(&v->counter, old, new);
12788 }
12789
12790 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
12791 +{
12792 + return cmpxchg(&v->counter, old, new);
12793 +}
12794 +
12795 static inline long atomic64_xchg(atomic64_t *v, long new)
12796 {
12797 return xchg(&v->counter, new);
12798 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
12799 */
12800 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
12801 {
12802 - long c, old;
12803 + long c, old, new;
12804 c = atomic64_read(v);
12805 for (;;) {
12806 - if (unlikely(c == (u)))
12807 + if (unlikely(c == u))
12808 break;
12809 - old = atomic64_cmpxchg((v), c, c + (a));
12810 +
12811 + asm volatile("add %2,%0\n"
12812 +
12813 +#ifdef CONFIG_PAX_REFCOUNT
12814 + "jno 0f\n"
12815 + "sub %2,%0\n"
12816 + "int $4\n0:\n"
12817 + _ASM_EXTABLE(0b, 0b)
12818 +#endif
12819 +
12820 + : "=r" (new)
12821 + : "0" (c), "ir" (a));
12822 +
12823 + old = atomic64_cmpxchg(v, c, new);
12824 if (likely(old == c))
12825 break;
12826 c = old;
12827 }
12828 - return c != (u);
12829 + return c != u;
12830 }
12831
12832 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
12833 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
12834 index 6dfd019..28e188d 100644
12835 --- a/arch/x86/include/asm/bitops.h
12836 +++ b/arch/x86/include/asm/bitops.h
12837 @@ -40,7 +40,7 @@
12838 * a mask operation on a byte.
12839 */
12840 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
12841 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
12842 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
12843 #define CONST_MASK(nr) (1 << ((nr) & 7))
12844
12845 /**
12846 @@ -486,7 +486,7 @@ static inline int fls(int x)
12847 * at position 64.
12848 */
12849 #ifdef CONFIG_X86_64
12850 -static __always_inline int fls64(__u64 x)
12851 +static __always_inline long fls64(__u64 x)
12852 {
12853 int bitpos = -1;
12854 /*
12855 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
12856 index 4fa687a..60f2d39 100644
12857 --- a/arch/x86/include/asm/boot.h
12858 +++ b/arch/x86/include/asm/boot.h
12859 @@ -6,10 +6,15 @@
12860 #include <uapi/asm/boot.h>
12861
12862 /* Physical address where kernel should be loaded. */
12863 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12864 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12865 + (CONFIG_PHYSICAL_ALIGN - 1)) \
12866 & ~(CONFIG_PHYSICAL_ALIGN - 1))
12867
12868 +#ifndef __ASSEMBLY__
12869 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
12870 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
12871 +#endif
12872 +
12873 /* Minimum kernel alignment, as a power of two */
12874 #ifdef CONFIG_X86_64
12875 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
12876 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
12877 index 48f99f1..d78ebf9 100644
12878 --- a/arch/x86/include/asm/cache.h
12879 +++ b/arch/x86/include/asm/cache.h
12880 @@ -5,12 +5,13 @@
12881
12882 /* L1 cache line size */
12883 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
12884 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12885 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12886
12887 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
12888 +#define __read_only __attribute__((__section__(".data..read_only")))
12889
12890 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
12891 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
12892 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
12893
12894 #ifdef CONFIG_X86_VSMP
12895 #ifdef CONFIG_SMP
12896 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
12897 index 9863ee3..4a1f8e1 100644
12898 --- a/arch/x86/include/asm/cacheflush.h
12899 +++ b/arch/x86/include/asm/cacheflush.h
12900 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
12901 unsigned long pg_flags = pg->flags & _PGMT_MASK;
12902
12903 if (pg_flags == _PGMT_DEFAULT)
12904 - return -1;
12905 + return ~0UL;
12906 else if (pg_flags == _PGMT_WC)
12907 return _PAGE_CACHE_WC;
12908 else if (pg_flags == _PGMT_UC_MINUS)
12909 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
12910 index 46fc474..b02b0f9 100644
12911 --- a/arch/x86/include/asm/checksum_32.h
12912 +++ b/arch/x86/include/asm/checksum_32.h
12913 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
12914 int len, __wsum sum,
12915 int *src_err_ptr, int *dst_err_ptr);
12916
12917 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
12918 + int len, __wsum sum,
12919 + int *src_err_ptr, int *dst_err_ptr);
12920 +
12921 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
12922 + int len, __wsum sum,
12923 + int *src_err_ptr, int *dst_err_ptr);
12924 +
12925 /*
12926 * Note: when you get a NULL pointer exception here this means someone
12927 * passed in an incorrect kernel address to one of these functions.
12928 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
12929 int *err_ptr)
12930 {
12931 might_sleep();
12932 - return csum_partial_copy_generic((__force void *)src, dst,
12933 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
12934 len, sum, err_ptr, NULL);
12935 }
12936
12937 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
12938 {
12939 might_sleep();
12940 if (access_ok(VERIFY_WRITE, dst, len))
12941 - return csum_partial_copy_generic(src, (__force void *)dst,
12942 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
12943 len, sum, NULL, err_ptr);
12944
12945 if (len)
12946 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
12947 index 8d871ea..c1a0dc9 100644
12948 --- a/arch/x86/include/asm/cmpxchg.h
12949 +++ b/arch/x86/include/asm/cmpxchg.h
12950 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
12951 __compiletime_error("Bad argument size for cmpxchg");
12952 extern void __xadd_wrong_size(void)
12953 __compiletime_error("Bad argument size for xadd");
12954 +extern void __xadd_check_overflow_wrong_size(void)
12955 + __compiletime_error("Bad argument size for xadd_check_overflow");
12956 extern void __add_wrong_size(void)
12957 __compiletime_error("Bad argument size for add");
12958 +extern void __add_check_overflow_wrong_size(void)
12959 + __compiletime_error("Bad argument size for add_check_overflow");
12960
12961 /*
12962 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
12963 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
12964 __ret; \
12965 })
12966
12967 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
12968 + ({ \
12969 + __typeof__ (*(ptr)) __ret = (arg); \
12970 + switch (sizeof(*(ptr))) { \
12971 + case __X86_CASE_L: \
12972 + asm volatile (lock #op "l %0, %1\n" \
12973 + "jno 0f\n" \
12974 + "mov %0,%1\n" \
12975 + "int $4\n0:\n" \
12976 + _ASM_EXTABLE(0b, 0b) \
12977 + : "+r" (__ret), "+m" (*(ptr)) \
12978 + : : "memory", "cc"); \
12979 + break; \
12980 + case __X86_CASE_Q: \
12981 + asm volatile (lock #op "q %q0, %1\n" \
12982 + "jno 0f\n" \
12983 + "mov %0,%1\n" \
12984 + "int $4\n0:\n" \
12985 + _ASM_EXTABLE(0b, 0b) \
12986 + : "+r" (__ret), "+m" (*(ptr)) \
12987 + : : "memory", "cc"); \
12988 + break; \
12989 + default: \
12990 + __ ## op ## _check_overflow_wrong_size(); \
12991 + } \
12992 + __ret; \
12993 + })
12994 +
12995 /*
12996 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
12997 * Since this is generally used to protect other memory information, we
12998 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
12999 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
13000 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
13001
13002 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
13003 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
13004 +
13005 #define __add(ptr, inc, lock) \
13006 ({ \
13007 __typeof__ (*(ptr)) __ret = (inc); \
13008 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
13009 index 59c6c40..5e0b22c 100644
13010 --- a/arch/x86/include/asm/compat.h
13011 +++ b/arch/x86/include/asm/compat.h
13012 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
13013 typedef u32 compat_uint_t;
13014 typedef u32 compat_ulong_t;
13015 typedef u64 __attribute__((aligned(4))) compat_u64;
13016 -typedef u32 compat_uptr_t;
13017 +typedef u32 __user compat_uptr_t;
13018
13019 struct compat_timespec {
13020 compat_time_t tv_sec;
13021 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
13022 index 93fe929..90858b7 100644
13023 --- a/arch/x86/include/asm/cpufeature.h
13024 +++ b/arch/x86/include/asm/cpufeature.h
13025 @@ -207,7 +207,7 @@
13026 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
13027 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
13028 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
13029 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
13030 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
13031 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
13032 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
13033 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
13034 @@ -377,7 +377,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
13035 ".section .discard,\"aw\",@progbits\n"
13036 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
13037 ".previous\n"
13038 - ".section .altinstr_replacement,\"ax\"\n"
13039 + ".section .altinstr_replacement,\"a\"\n"
13040 "3: movb $1,%0\n"
13041 "4:\n"
13042 ".previous\n"
13043 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
13044 index 8bf1c06..b6ae785 100644
13045 --- a/arch/x86/include/asm/desc.h
13046 +++ b/arch/x86/include/asm/desc.h
13047 @@ -4,6 +4,7 @@
13048 #include <asm/desc_defs.h>
13049 #include <asm/ldt.h>
13050 #include <asm/mmu.h>
13051 +#include <asm/pgtable.h>
13052
13053 #include <linux/smp.h>
13054 #include <linux/percpu.h>
13055 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13056
13057 desc->type = (info->read_exec_only ^ 1) << 1;
13058 desc->type |= info->contents << 2;
13059 + desc->type |= info->seg_not_present ^ 1;
13060
13061 desc->s = 1;
13062 desc->dpl = 0x3;
13063 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13064 }
13065
13066 extern struct desc_ptr idt_descr;
13067 -extern gate_desc idt_table[];
13068 extern struct desc_ptr nmi_idt_descr;
13069 -extern gate_desc nmi_idt_table[];
13070 -
13071 -struct gdt_page {
13072 - struct desc_struct gdt[GDT_ENTRIES];
13073 -} __attribute__((aligned(PAGE_SIZE)));
13074 -
13075 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13076 +extern gate_desc idt_table[256];
13077 +extern gate_desc nmi_idt_table[256];
13078
13079 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13080 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13081 {
13082 - return per_cpu(gdt_page, cpu).gdt;
13083 + return cpu_gdt_table[cpu];
13084 }
13085
13086 #ifdef CONFIG_X86_64
13087 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13088 unsigned long base, unsigned dpl, unsigned flags,
13089 unsigned short seg)
13090 {
13091 - gate->a = (seg << 16) | (base & 0xffff);
13092 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13093 + gate->gate.offset_low = base;
13094 + gate->gate.seg = seg;
13095 + gate->gate.reserved = 0;
13096 + gate->gate.type = type;
13097 + gate->gate.s = 0;
13098 + gate->gate.dpl = dpl;
13099 + gate->gate.p = 1;
13100 + gate->gate.offset_high = base >> 16;
13101 }
13102
13103 #endif
13104 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13105
13106 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13107 {
13108 + pax_open_kernel();
13109 memcpy(&idt[entry], gate, sizeof(*gate));
13110 + pax_close_kernel();
13111 }
13112
13113 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13114 {
13115 + pax_open_kernel();
13116 memcpy(&ldt[entry], desc, 8);
13117 + pax_close_kernel();
13118 }
13119
13120 static inline void
13121 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13122 default: size = sizeof(*gdt); break;
13123 }
13124
13125 + pax_open_kernel();
13126 memcpy(&gdt[entry], desc, size);
13127 + pax_close_kernel();
13128 }
13129
13130 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13131 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13132
13133 static inline void native_load_tr_desc(void)
13134 {
13135 + pax_open_kernel();
13136 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13137 + pax_close_kernel();
13138 }
13139
13140 static inline void native_load_gdt(const struct desc_ptr *dtr)
13141 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13142 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13143 unsigned int i;
13144
13145 + pax_open_kernel();
13146 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13147 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13148 + pax_close_kernel();
13149 }
13150
13151 #define _LDT_empty(info) \
13152 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13153 preempt_enable();
13154 }
13155
13156 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13157 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13158 {
13159 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13160 }
13161 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13162 }
13163
13164 #ifdef CONFIG_X86_64
13165 -static inline void set_nmi_gate(int gate, void *addr)
13166 +static inline void set_nmi_gate(int gate, const void *addr)
13167 {
13168 gate_desc s;
13169
13170 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13171 }
13172 #endif
13173
13174 -static inline void _set_gate(int gate, unsigned type, void *addr,
13175 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13176 unsigned dpl, unsigned ist, unsigned seg)
13177 {
13178 gate_desc s;
13179 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13180 * Pentium F0 0F bugfix can have resulted in the mapped
13181 * IDT being write-protected.
13182 */
13183 -static inline void set_intr_gate(unsigned int n, void *addr)
13184 +static inline void set_intr_gate(unsigned int n, const void *addr)
13185 {
13186 BUG_ON((unsigned)n > 0xFF);
13187 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13188 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13189 /*
13190 * This routine sets up an interrupt gate at directory privilege level 3.
13191 */
13192 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13193 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13194 {
13195 BUG_ON((unsigned)n > 0xFF);
13196 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13197 }
13198
13199 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13200 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13201 {
13202 BUG_ON((unsigned)n > 0xFF);
13203 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13204 }
13205
13206 -static inline void set_trap_gate(unsigned int n, void *addr)
13207 +static inline void set_trap_gate(unsigned int n, const void *addr)
13208 {
13209 BUG_ON((unsigned)n > 0xFF);
13210 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13211 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13212 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13213 {
13214 BUG_ON((unsigned)n > 0xFF);
13215 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13216 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13217 }
13218
13219 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13220 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13221 {
13222 BUG_ON((unsigned)n > 0xFF);
13223 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13224 }
13225
13226 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13227 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13228 {
13229 BUG_ON((unsigned)n > 0xFF);
13230 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13231 }
13232
13233 +#ifdef CONFIG_X86_32
13234 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13235 +{
13236 + struct desc_struct d;
13237 +
13238 + if (likely(limit))
13239 + limit = (limit - 1UL) >> PAGE_SHIFT;
13240 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13241 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13242 +}
13243 +#endif
13244 +
13245 #endif /* _ASM_X86_DESC_H */
13246 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13247 index 278441f..b95a174 100644
13248 --- a/arch/x86/include/asm/desc_defs.h
13249 +++ b/arch/x86/include/asm/desc_defs.h
13250 @@ -31,6 +31,12 @@ struct desc_struct {
13251 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13252 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13253 };
13254 + struct {
13255 + u16 offset_low;
13256 + u16 seg;
13257 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13258 + unsigned offset_high: 16;
13259 + } gate;
13260 };
13261 } __attribute__((packed));
13262
13263 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13264 index ced283a..ffe04cc 100644
13265 --- a/arch/x86/include/asm/div64.h
13266 +++ b/arch/x86/include/asm/div64.h
13267 @@ -39,7 +39,7 @@
13268 __mod; \
13269 })
13270
13271 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13272 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13273 {
13274 union {
13275 u64 v64;
13276 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13277 index 9c999c1..3860cb8 100644
13278 --- a/arch/x86/include/asm/elf.h
13279 +++ b/arch/x86/include/asm/elf.h
13280 @@ -243,7 +243,25 @@ extern int force_personality32;
13281 the loader. We need to make sure that it is out of the way of the program
13282 that it will "exec", and that there is sufficient room for the brk. */
13283
13284 +#ifdef CONFIG_PAX_SEGMEXEC
13285 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13286 +#else
13287 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13288 +#endif
13289 +
13290 +#ifdef CONFIG_PAX_ASLR
13291 +#ifdef CONFIG_X86_32
13292 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13293 +
13294 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13295 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13296 +#else
13297 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13298 +
13299 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13300 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13301 +#endif
13302 +#endif
13303
13304 /* This yields a mask that user programs can use to figure out what
13305 instruction set this CPU supports. This could be done in user space,
13306 @@ -296,16 +314,12 @@ do { \
13307
13308 #define ARCH_DLINFO \
13309 do { \
13310 - if (vdso_enabled) \
13311 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13312 - (unsigned long)current->mm->context.vdso); \
13313 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13314 } while (0)
13315
13316 #define ARCH_DLINFO_X32 \
13317 do { \
13318 - if (vdso_enabled) \
13319 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13320 - (unsigned long)current->mm->context.vdso); \
13321 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13322 } while (0)
13323
13324 #define AT_SYSINFO 32
13325 @@ -320,7 +334,7 @@ else \
13326
13327 #endif /* !CONFIG_X86_32 */
13328
13329 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13330 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13331
13332 #define VDSO_ENTRY \
13333 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13334 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13335 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13336 #define compat_arch_setup_additional_pages syscall32_setup_pages
13337
13338 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13339 -#define arch_randomize_brk arch_randomize_brk
13340 -
13341 /*
13342 * True on X86_32 or when emulating IA32 on X86_64
13343 */
13344 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13345 index 75ce3f4..882e801 100644
13346 --- a/arch/x86/include/asm/emergency-restart.h
13347 +++ b/arch/x86/include/asm/emergency-restart.h
13348 @@ -13,6 +13,6 @@ enum reboot_type {
13349
13350 extern enum reboot_type reboot_type;
13351
13352 -extern void machine_emergency_restart(void);
13353 +extern void machine_emergency_restart(void) __noreturn;
13354
13355 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13356 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13357 index e25cc33..425d099 100644
13358 --- a/arch/x86/include/asm/fpu-internal.h
13359 +++ b/arch/x86/include/asm/fpu-internal.h
13360 @@ -127,7 +127,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13361 ({ \
13362 int err; \
13363 asm volatile(ASM_STAC "\n" \
13364 - "1:" #insn "\n\t" \
13365 + "1:" \
13366 + __copyuser_seg \
13367 + #insn "\n\t" \
13368 "2: " ASM_CLAC "\n" \
13369 ".section .fixup,\"ax\"\n" \
13370 "3: movl $-1,%[err]\n" \
13371 @@ -300,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13372 "emms\n\t" /* clear stack tags */
13373 "fildl %P[addr]", /* set F?P to defined value */
13374 X86_FEATURE_FXSAVE_LEAK,
13375 - [addr] "m" (tsk->thread.fpu.has_fpu));
13376 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13377
13378 return fpu_restore_checking(&tsk->thread.fpu);
13379 }
13380 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13381 index be27ba1..8f13ff9 100644
13382 --- a/arch/x86/include/asm/futex.h
13383 +++ b/arch/x86/include/asm/futex.h
13384 @@ -12,6 +12,7 @@
13385 #include <asm/smap.h>
13386
13387 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13388 + typecheck(u32 __user *, uaddr); \
13389 asm volatile("\t" ASM_STAC "\n" \
13390 "1:\t" insn "\n" \
13391 "2:\t" ASM_CLAC "\n" \
13392 @@ -20,15 +21,16 @@
13393 "\tjmp\t2b\n" \
13394 "\t.previous\n" \
13395 _ASM_EXTABLE(1b, 3b) \
13396 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13397 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13398 : "i" (-EFAULT), "0" (oparg), "1" (0))
13399
13400 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13401 + typecheck(u32 __user *, uaddr); \
13402 asm volatile("\t" ASM_STAC "\n" \
13403 "1:\tmovl %2, %0\n" \
13404 "\tmovl\t%0, %3\n" \
13405 "\t" insn "\n" \
13406 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13407 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13408 "\tjnz\t1b\n" \
13409 "3:\t" ASM_CLAC "\n" \
13410 "\t.section .fixup,\"ax\"\n" \
13411 @@ -38,7 +40,7 @@
13412 _ASM_EXTABLE(1b, 4b) \
13413 _ASM_EXTABLE(2b, 4b) \
13414 : "=&a" (oldval), "=&r" (ret), \
13415 - "+m" (*uaddr), "=&r" (tem) \
13416 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13417 : "r" (oparg), "i" (-EFAULT), "1" (0))
13418
13419 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13420 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13421
13422 switch (op) {
13423 case FUTEX_OP_SET:
13424 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13425 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13426 break;
13427 case FUTEX_OP_ADD:
13428 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13429 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13430 uaddr, oparg);
13431 break;
13432 case FUTEX_OP_OR:
13433 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13434 return -EFAULT;
13435
13436 asm volatile("\t" ASM_STAC "\n"
13437 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13438 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13439 "2:\t" ASM_CLAC "\n"
13440 "\t.section .fixup, \"ax\"\n"
13441 "3:\tmov %3, %0\n"
13442 "\tjmp 2b\n"
13443 "\t.previous\n"
13444 _ASM_EXTABLE(1b, 3b)
13445 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13446 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13447 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13448 : "memory"
13449 );
13450 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13451 index 10a78c3..cc77143 100644
13452 --- a/arch/x86/include/asm/hw_irq.h
13453 +++ b/arch/x86/include/asm/hw_irq.h
13454 @@ -147,8 +147,8 @@ extern void setup_ioapic_dest(void);
13455 extern void enable_IO_APIC(void);
13456
13457 /* Statistics */
13458 -extern atomic_t irq_err_count;
13459 -extern atomic_t irq_mis_count;
13460 +extern atomic_unchecked_t irq_err_count;
13461 +extern atomic_unchecked_t irq_mis_count;
13462
13463 /* EISA */
13464 extern void eisa_set_level_irq(unsigned int irq);
13465 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13466 index a203659..9889f1c 100644
13467 --- a/arch/x86/include/asm/i8259.h
13468 +++ b/arch/x86/include/asm/i8259.h
13469 @@ -62,7 +62,7 @@ struct legacy_pic {
13470 void (*init)(int auto_eoi);
13471 int (*irq_pending)(unsigned int irq);
13472 void (*make_irq)(unsigned int irq);
13473 -};
13474 +} __do_const;
13475
13476 extern struct legacy_pic *legacy_pic;
13477 extern struct legacy_pic null_legacy_pic;
13478 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13479 index d8e8eef..1765f78 100644
13480 --- a/arch/x86/include/asm/io.h
13481 +++ b/arch/x86/include/asm/io.h
13482 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13483 "m" (*(volatile type __force *)addr) barrier); }
13484
13485 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13486 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13487 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13488 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13489 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13490
13491 build_mmio_read(__readb, "b", unsigned char, "=q", )
13492 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13493 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13494 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13495 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13496
13497 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13498 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13499 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13500 return ioremap_nocache(offset, size);
13501 }
13502
13503 -extern void iounmap(volatile void __iomem *addr);
13504 +extern void iounmap(const volatile void __iomem *addr);
13505
13506 extern void set_iounmap_nonlazy(void);
13507
13508 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13509
13510 #include <linux/vmalloc.h>
13511
13512 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13513 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13514 +{
13515 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13516 +}
13517 +
13518 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13519 +{
13520 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13521 +}
13522 +
13523 /*
13524 * Convert a virtual cached pointer to an uncached pointer
13525 */
13526 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13527 index bba3cf8..06bc8da 100644
13528 --- a/arch/x86/include/asm/irqflags.h
13529 +++ b/arch/x86/include/asm/irqflags.h
13530 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13531 sti; \
13532 sysexit
13533
13534 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13535 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13536 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13537 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13538 +
13539 #else
13540 #define INTERRUPT_RETURN iret
13541 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13542 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13543 index 5a6d287..f815789 100644
13544 --- a/arch/x86/include/asm/kprobes.h
13545 +++ b/arch/x86/include/asm/kprobes.h
13546 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13547 #define RELATIVEJUMP_SIZE 5
13548 #define RELATIVECALL_OPCODE 0xe8
13549 #define RELATIVE_ADDR_SIZE 4
13550 -#define MAX_STACK_SIZE 64
13551 -#define MIN_STACK_SIZE(ADDR) \
13552 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13553 - THREAD_SIZE - (unsigned long)(ADDR))) \
13554 - ? (MAX_STACK_SIZE) \
13555 - : (((unsigned long)current_thread_info()) + \
13556 - THREAD_SIZE - (unsigned long)(ADDR)))
13557 +#define MAX_STACK_SIZE 64UL
13558 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13559
13560 #define flush_insn_slot(p) do { } while (0)
13561
13562 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13563 index 2d89e39..baee879 100644
13564 --- a/arch/x86/include/asm/local.h
13565 +++ b/arch/x86/include/asm/local.h
13566 @@ -10,33 +10,97 @@ typedef struct {
13567 atomic_long_t a;
13568 } local_t;
13569
13570 +typedef struct {
13571 + atomic_long_unchecked_t a;
13572 +} local_unchecked_t;
13573 +
13574 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13575
13576 #define local_read(l) atomic_long_read(&(l)->a)
13577 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13578 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13579 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13580
13581 static inline void local_inc(local_t *l)
13582 {
13583 - asm volatile(_ASM_INC "%0"
13584 + asm volatile(_ASM_INC "%0\n"
13585 +
13586 +#ifdef CONFIG_PAX_REFCOUNT
13587 + "jno 0f\n"
13588 + _ASM_DEC "%0\n"
13589 + "int $4\n0:\n"
13590 + _ASM_EXTABLE(0b, 0b)
13591 +#endif
13592 +
13593 + : "+m" (l->a.counter));
13594 +}
13595 +
13596 +static inline void local_inc_unchecked(local_unchecked_t *l)
13597 +{
13598 + asm volatile(_ASM_INC "%0\n"
13599 : "+m" (l->a.counter));
13600 }
13601
13602 static inline void local_dec(local_t *l)
13603 {
13604 - asm volatile(_ASM_DEC "%0"
13605 + asm volatile(_ASM_DEC "%0\n"
13606 +
13607 +#ifdef CONFIG_PAX_REFCOUNT
13608 + "jno 0f\n"
13609 + _ASM_INC "%0\n"
13610 + "int $4\n0:\n"
13611 + _ASM_EXTABLE(0b, 0b)
13612 +#endif
13613 +
13614 + : "+m" (l->a.counter));
13615 +}
13616 +
13617 +static inline void local_dec_unchecked(local_unchecked_t *l)
13618 +{
13619 + asm volatile(_ASM_DEC "%0\n"
13620 : "+m" (l->a.counter));
13621 }
13622
13623 static inline void local_add(long i, local_t *l)
13624 {
13625 - asm volatile(_ASM_ADD "%1,%0"
13626 + asm volatile(_ASM_ADD "%1,%0\n"
13627 +
13628 +#ifdef CONFIG_PAX_REFCOUNT
13629 + "jno 0f\n"
13630 + _ASM_SUB "%1,%0\n"
13631 + "int $4\n0:\n"
13632 + _ASM_EXTABLE(0b, 0b)
13633 +#endif
13634 +
13635 + : "+m" (l->a.counter)
13636 + : "ir" (i));
13637 +}
13638 +
13639 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
13640 +{
13641 + asm volatile(_ASM_ADD "%1,%0\n"
13642 : "+m" (l->a.counter)
13643 : "ir" (i));
13644 }
13645
13646 static inline void local_sub(long i, local_t *l)
13647 {
13648 - asm volatile(_ASM_SUB "%1,%0"
13649 + asm volatile(_ASM_SUB "%1,%0\n"
13650 +
13651 +#ifdef CONFIG_PAX_REFCOUNT
13652 + "jno 0f\n"
13653 + _ASM_ADD "%1,%0\n"
13654 + "int $4\n0:\n"
13655 + _ASM_EXTABLE(0b, 0b)
13656 +#endif
13657 +
13658 + : "+m" (l->a.counter)
13659 + : "ir" (i));
13660 +}
13661 +
13662 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
13663 +{
13664 + asm volatile(_ASM_SUB "%1,%0\n"
13665 : "+m" (l->a.counter)
13666 : "ir" (i));
13667 }
13668 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
13669 {
13670 unsigned char c;
13671
13672 - asm volatile(_ASM_SUB "%2,%0; sete %1"
13673 + asm volatile(_ASM_SUB "%2,%0\n"
13674 +
13675 +#ifdef CONFIG_PAX_REFCOUNT
13676 + "jno 0f\n"
13677 + _ASM_ADD "%2,%0\n"
13678 + "int $4\n0:\n"
13679 + _ASM_EXTABLE(0b, 0b)
13680 +#endif
13681 +
13682 + "sete %1\n"
13683 : "+m" (l->a.counter), "=qm" (c)
13684 : "ir" (i) : "memory");
13685 return c;
13686 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
13687 {
13688 unsigned char c;
13689
13690 - asm volatile(_ASM_DEC "%0; sete %1"
13691 + asm volatile(_ASM_DEC "%0\n"
13692 +
13693 +#ifdef CONFIG_PAX_REFCOUNT
13694 + "jno 0f\n"
13695 + _ASM_INC "%0\n"
13696 + "int $4\n0:\n"
13697 + _ASM_EXTABLE(0b, 0b)
13698 +#endif
13699 +
13700 + "sete %1\n"
13701 : "+m" (l->a.counter), "=qm" (c)
13702 : : "memory");
13703 return c != 0;
13704 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
13705 {
13706 unsigned char c;
13707
13708 - asm volatile(_ASM_INC "%0; sete %1"
13709 + asm volatile(_ASM_INC "%0\n"
13710 +
13711 +#ifdef CONFIG_PAX_REFCOUNT
13712 + "jno 0f\n"
13713 + _ASM_DEC "%0\n"
13714 + "int $4\n0:\n"
13715 + _ASM_EXTABLE(0b, 0b)
13716 +#endif
13717 +
13718 + "sete %1\n"
13719 : "+m" (l->a.counter), "=qm" (c)
13720 : : "memory");
13721 return c != 0;
13722 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
13723 {
13724 unsigned char c;
13725
13726 - asm volatile(_ASM_ADD "%2,%0; sets %1"
13727 + asm volatile(_ASM_ADD "%2,%0\n"
13728 +
13729 +#ifdef CONFIG_PAX_REFCOUNT
13730 + "jno 0f\n"
13731 + _ASM_SUB "%2,%0\n"
13732 + "int $4\n0:\n"
13733 + _ASM_EXTABLE(0b, 0b)
13734 +#endif
13735 +
13736 + "sets %1\n"
13737 : "+m" (l->a.counter), "=qm" (c)
13738 : "ir" (i) : "memory");
13739 return c;
13740 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
13741 static inline long local_add_return(long i, local_t *l)
13742 {
13743 long __i = i;
13744 + asm volatile(_ASM_XADD "%0, %1\n"
13745 +
13746 +#ifdef CONFIG_PAX_REFCOUNT
13747 + "jno 0f\n"
13748 + _ASM_MOV "%0,%1\n"
13749 + "int $4\n0:\n"
13750 + _ASM_EXTABLE(0b, 0b)
13751 +#endif
13752 +
13753 + : "+r" (i), "+m" (l->a.counter)
13754 + : : "memory");
13755 + return i + __i;
13756 +}
13757 +
13758 +/**
13759 + * local_add_return_unchecked - add and return
13760 + * @i: integer value to add
13761 + * @l: pointer to type local_unchecked_t
13762 + *
13763 + * Atomically adds @i to @l and returns @i + @l
13764 + */
13765 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
13766 +{
13767 + long __i = i;
13768 asm volatile(_ASM_XADD "%0, %1;"
13769 : "+r" (i), "+m" (l->a.counter)
13770 : : "memory");
13771 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
13772
13773 #define local_cmpxchg(l, o, n) \
13774 (cmpxchg_local(&((l)->a.counter), (o), (n)))
13775 +#define local_cmpxchg_unchecked(l, o, n) \
13776 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
13777 /* Always has a lock prefix */
13778 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
13779
13780 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
13781 new file mode 100644
13782 index 0000000..2bfd3ba
13783 --- /dev/null
13784 +++ b/arch/x86/include/asm/mman.h
13785 @@ -0,0 +1,15 @@
13786 +#ifndef _X86_MMAN_H
13787 +#define _X86_MMAN_H
13788 +
13789 +#include <uapi/asm/mman.h>
13790 +
13791 +#ifdef __KERNEL__
13792 +#ifndef __ASSEMBLY__
13793 +#ifdef CONFIG_X86_32
13794 +#define arch_mmap_check i386_mmap_check
13795 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
13796 +#endif
13797 +#endif
13798 +#endif
13799 +
13800 +#endif /* X86_MMAN_H */
13801 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
13802 index 5f55e69..e20bfb1 100644
13803 --- a/arch/x86/include/asm/mmu.h
13804 +++ b/arch/x86/include/asm/mmu.h
13805 @@ -9,7 +9,7 @@
13806 * we put the segment information here.
13807 */
13808 typedef struct {
13809 - void *ldt;
13810 + struct desc_struct *ldt;
13811 int size;
13812
13813 #ifdef CONFIG_X86_64
13814 @@ -18,7 +18,19 @@ typedef struct {
13815 #endif
13816
13817 struct mutex lock;
13818 - void *vdso;
13819 + unsigned long vdso;
13820 +
13821 +#ifdef CONFIG_X86_32
13822 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
13823 + unsigned long user_cs_base;
13824 + unsigned long user_cs_limit;
13825 +
13826 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13827 + cpumask_t cpu_user_cs_mask;
13828 +#endif
13829 +
13830 +#endif
13831 +#endif
13832 } mm_context_t;
13833
13834 #ifdef CONFIG_SMP
13835 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
13836 index cdbf367..adb37ac 100644
13837 --- a/arch/x86/include/asm/mmu_context.h
13838 +++ b/arch/x86/include/asm/mmu_context.h
13839 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
13840
13841 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
13842 {
13843 +
13844 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
13845 + unsigned int i;
13846 + pgd_t *pgd;
13847 +
13848 + pax_open_kernel();
13849 + pgd = get_cpu_pgd(smp_processor_id());
13850 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
13851 + set_pgd_batched(pgd+i, native_make_pgd(0));
13852 + pax_close_kernel();
13853 +#endif
13854 +
13855 #ifdef CONFIG_SMP
13856 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
13857 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
13858 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13859 struct task_struct *tsk)
13860 {
13861 unsigned cpu = smp_processor_id();
13862 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13863 + int tlbstate = TLBSTATE_OK;
13864 +#endif
13865
13866 if (likely(prev != next)) {
13867 #ifdef CONFIG_SMP
13868 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13869 + tlbstate = this_cpu_read(cpu_tlbstate.state);
13870 +#endif
13871 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13872 this_cpu_write(cpu_tlbstate.active_mm, next);
13873 #endif
13874 cpumask_set_cpu(cpu, mm_cpumask(next));
13875
13876 /* Re-load page tables */
13877 +#ifdef CONFIG_PAX_PER_CPU_PGD
13878 + pax_open_kernel();
13879 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13880 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13881 + pax_close_kernel();
13882 + load_cr3(get_cpu_pgd(cpu));
13883 +#else
13884 load_cr3(next->pgd);
13885 +#endif
13886
13887 /* stop flush ipis for the previous mm */
13888 cpumask_clear_cpu(cpu, mm_cpumask(prev));
13889 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13890 */
13891 if (unlikely(prev->context.ldt != next->context.ldt))
13892 load_LDT_nolock(&next->context);
13893 - }
13894 +
13895 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13896 + if (!(__supported_pte_mask & _PAGE_NX)) {
13897 + smp_mb__before_clear_bit();
13898 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
13899 + smp_mb__after_clear_bit();
13900 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13901 + }
13902 +#endif
13903 +
13904 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13905 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
13906 + prev->context.user_cs_limit != next->context.user_cs_limit))
13907 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13908 #ifdef CONFIG_SMP
13909 + else if (unlikely(tlbstate != TLBSTATE_OK))
13910 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13911 +#endif
13912 +#endif
13913 +
13914 + }
13915 else {
13916 +
13917 +#ifdef CONFIG_PAX_PER_CPU_PGD
13918 + pax_open_kernel();
13919 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13920 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13921 + pax_close_kernel();
13922 + load_cr3(get_cpu_pgd(cpu));
13923 +#endif
13924 +
13925 +#ifdef CONFIG_SMP
13926 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13927 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
13928
13929 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13930 * tlb flush IPI delivery. We must reload CR3
13931 * to make sure to use no freed page tables.
13932 */
13933 +
13934 +#ifndef CONFIG_PAX_PER_CPU_PGD
13935 load_cr3(next->pgd);
13936 +#endif
13937 +
13938 load_LDT_nolock(&next->context);
13939 +
13940 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
13941 + if (!(__supported_pte_mask & _PAGE_NX))
13942 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13943 +#endif
13944 +
13945 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13946 +#ifdef CONFIG_PAX_PAGEEXEC
13947 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
13948 +#endif
13949 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13950 +#endif
13951 +
13952 }
13953 +#endif
13954 }
13955 -#endif
13956 }
13957
13958 #define activate_mm(prev, next) \
13959 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
13960 index e3b7819..b257c64 100644
13961 --- a/arch/x86/include/asm/module.h
13962 +++ b/arch/x86/include/asm/module.h
13963 @@ -5,6 +5,7 @@
13964
13965 #ifdef CONFIG_X86_64
13966 /* X86_64 does not define MODULE_PROC_FAMILY */
13967 +#define MODULE_PROC_FAMILY ""
13968 #elif defined CONFIG_M486
13969 #define MODULE_PROC_FAMILY "486 "
13970 #elif defined CONFIG_M586
13971 @@ -57,8 +58,20 @@
13972 #error unknown processor family
13973 #endif
13974
13975 -#ifdef CONFIG_X86_32
13976 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
13977 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
13978 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
13979 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
13980 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
13981 +#else
13982 +#define MODULE_PAX_KERNEXEC ""
13983 #endif
13984
13985 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13986 +#define MODULE_PAX_UDEREF "UDEREF "
13987 +#else
13988 +#define MODULE_PAX_UDEREF ""
13989 +#endif
13990 +
13991 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
13992 +
13993 #endif /* _ASM_X86_MODULE_H */
13994 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
13995 index c0fa356..07a498a 100644
13996 --- a/arch/x86/include/asm/nmi.h
13997 +++ b/arch/x86/include/asm/nmi.h
13998 @@ -42,11 +42,11 @@ struct nmiaction {
13999 nmi_handler_t handler;
14000 unsigned long flags;
14001 const char *name;
14002 -};
14003 +} __do_const;
14004
14005 #define register_nmi_handler(t, fn, fg, n, init...) \
14006 ({ \
14007 - static struct nmiaction init fn##_na = { \
14008 + static const struct nmiaction init fn##_na = { \
14009 .handler = (fn), \
14010 .name = (n), \
14011 .flags = (fg), \
14012 @@ -54,7 +54,7 @@ struct nmiaction {
14013 __register_nmi_handler((t), &fn##_na); \
14014 })
14015
14016 -int __register_nmi_handler(unsigned int, struct nmiaction *);
14017 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
14018
14019 void unregister_nmi_handler(unsigned int, const char *);
14020
14021 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
14022 index 0f1ddee..e56bec9 100644
14023 --- a/arch/x86/include/asm/page_64.h
14024 +++ b/arch/x86/include/asm/page_64.h
14025 @@ -7,7 +7,7 @@
14026
14027 /* duplicated to the one in bootmem.h */
14028 extern unsigned long max_pfn;
14029 -extern unsigned long phys_base;
14030 +extern const unsigned long phys_base;
14031
14032 static inline unsigned long __phys_addr_nodebug(unsigned long x)
14033 {
14034 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
14035 index 7361e47..16dc226 100644
14036 --- a/arch/x86/include/asm/paravirt.h
14037 +++ b/arch/x86/include/asm/paravirt.h
14038 @@ -564,7 +564,7 @@ static inline pmd_t __pmd(pmdval_t val)
14039 return (pmd_t) { ret };
14040 }
14041
14042 -static inline pmdval_t pmd_val(pmd_t pmd)
14043 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
14044 {
14045 pmdval_t ret;
14046
14047 @@ -630,6 +630,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
14048 val);
14049 }
14050
14051 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14052 +{
14053 + pgdval_t val = native_pgd_val(pgd);
14054 +
14055 + if (sizeof(pgdval_t) > sizeof(long))
14056 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14057 + val, (u64)val >> 32);
14058 + else
14059 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14060 + val);
14061 +}
14062 +
14063 static inline void pgd_clear(pgd_t *pgdp)
14064 {
14065 set_pgd(pgdp, __pgd(0));
14066 @@ -714,6 +726,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14067 pv_mmu_ops.set_fixmap(idx, phys, flags);
14068 }
14069
14070 +#ifdef CONFIG_PAX_KERNEXEC
14071 +static inline unsigned long pax_open_kernel(void)
14072 +{
14073 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14074 +}
14075 +
14076 +static inline unsigned long pax_close_kernel(void)
14077 +{
14078 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14079 +}
14080 +#else
14081 +static inline unsigned long pax_open_kernel(void) { return 0; }
14082 +static inline unsigned long pax_close_kernel(void) { return 0; }
14083 +#endif
14084 +
14085 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14086
14087 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14088 @@ -930,7 +957,7 @@ extern void default_banner(void);
14089
14090 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14091 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14092 -#define PARA_INDIRECT(addr) *%cs:addr
14093 +#define PARA_INDIRECT(addr) *%ss:addr
14094 #endif
14095
14096 #define INTERRUPT_RETURN \
14097 @@ -1005,6 +1032,21 @@ extern void default_banner(void);
14098 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14099 CLBR_NONE, \
14100 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14101 +
14102 +#define GET_CR0_INTO_RDI \
14103 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14104 + mov %rax,%rdi
14105 +
14106 +#define SET_RDI_INTO_CR0 \
14107 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14108 +
14109 +#define GET_CR3_INTO_RDI \
14110 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14111 + mov %rax,%rdi
14112 +
14113 +#define SET_RDI_INTO_CR3 \
14114 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14115 +
14116 #endif /* CONFIG_X86_32 */
14117
14118 #endif /* __ASSEMBLY__ */
14119 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14120 index b3b0ec1..b1cd3eb 100644
14121 --- a/arch/x86/include/asm/paravirt_types.h
14122 +++ b/arch/x86/include/asm/paravirt_types.h
14123 @@ -84,7 +84,7 @@ struct pv_init_ops {
14124 */
14125 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14126 unsigned long addr, unsigned len);
14127 -};
14128 +} __no_const;
14129
14130
14131 struct pv_lazy_ops {
14132 @@ -98,7 +98,7 @@ struct pv_time_ops {
14133 unsigned long long (*sched_clock)(void);
14134 unsigned long long (*steal_clock)(int cpu);
14135 unsigned long (*get_tsc_khz)(void);
14136 -};
14137 +} __no_const;
14138
14139 struct pv_cpu_ops {
14140 /* hooks for various privileged instructions */
14141 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
14142
14143 void (*start_context_switch)(struct task_struct *prev);
14144 void (*end_context_switch)(struct task_struct *next);
14145 -};
14146 +} __no_const;
14147
14148 struct pv_irq_ops {
14149 /*
14150 @@ -223,7 +223,7 @@ struct pv_apic_ops {
14151 unsigned long start_eip,
14152 unsigned long start_esp);
14153 #endif
14154 -};
14155 +} __no_const;
14156
14157 struct pv_mmu_ops {
14158 unsigned long (*read_cr2)(void);
14159 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
14160 struct paravirt_callee_save make_pud;
14161
14162 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14163 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14164 #endif /* PAGETABLE_LEVELS == 4 */
14165 #endif /* PAGETABLE_LEVELS >= 3 */
14166
14167 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
14168 an mfn. We can tell which is which from the index. */
14169 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14170 phys_addr_t phys, pgprot_t flags);
14171 +
14172 +#ifdef CONFIG_PAX_KERNEXEC
14173 + unsigned long (*pax_open_kernel)(void);
14174 + unsigned long (*pax_close_kernel)(void);
14175 +#endif
14176 +
14177 };
14178
14179 struct arch_spinlock;
14180 @@ -334,7 +341,7 @@ struct pv_lock_ops {
14181 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14182 int (*spin_trylock)(struct arch_spinlock *lock);
14183 void (*spin_unlock)(struct arch_spinlock *lock);
14184 -};
14185 +} __no_const;
14186
14187 /* This contains all the paravirt structures: we get a convenient
14188 * number for each function using the offset which we use to indicate
14189 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14190 index b4389a4..7024269 100644
14191 --- a/arch/x86/include/asm/pgalloc.h
14192 +++ b/arch/x86/include/asm/pgalloc.h
14193 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14194 pmd_t *pmd, pte_t *pte)
14195 {
14196 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14197 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14198 +}
14199 +
14200 +static inline void pmd_populate_user(struct mm_struct *mm,
14201 + pmd_t *pmd, pte_t *pte)
14202 +{
14203 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14204 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14205 }
14206
14207 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14208
14209 #ifdef CONFIG_X86_PAE
14210 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14211 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14212 +{
14213 + pud_populate(mm, pudp, pmd);
14214 +}
14215 #else /* !CONFIG_X86_PAE */
14216 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14217 {
14218 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14219 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14220 }
14221 +
14222 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14223 +{
14224 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14225 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
14226 +}
14227 #endif /* CONFIG_X86_PAE */
14228
14229 #if PAGETABLE_LEVELS > 3
14230 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14231 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14232 }
14233
14234 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14235 +{
14236 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14237 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14238 +}
14239 +
14240 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14241 {
14242 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14243 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14244 index f2b489c..4f7e2e5 100644
14245 --- a/arch/x86/include/asm/pgtable-2level.h
14246 +++ b/arch/x86/include/asm/pgtable-2level.h
14247 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14248
14249 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14250 {
14251 + pax_open_kernel();
14252 *pmdp = pmd;
14253 + pax_close_kernel();
14254 }
14255
14256 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14257 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14258 index 4cc9f2b..5fd9226 100644
14259 --- a/arch/x86/include/asm/pgtable-3level.h
14260 +++ b/arch/x86/include/asm/pgtable-3level.h
14261 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14262
14263 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14264 {
14265 + pax_open_kernel();
14266 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14267 + pax_close_kernel();
14268 }
14269
14270 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14271 {
14272 + pax_open_kernel();
14273 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14274 + pax_close_kernel();
14275 }
14276
14277 /*
14278 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14279 index 1e67223..9183226 100644
14280 --- a/arch/x86/include/asm/pgtable.h
14281 +++ b/arch/x86/include/asm/pgtable.h
14282 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14283
14284 #ifndef __PAGETABLE_PUD_FOLDED
14285 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14286 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14287 #define pgd_clear(pgd) native_pgd_clear(pgd)
14288 #endif
14289
14290 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14291
14292 #define arch_end_context_switch(prev) do {} while(0)
14293
14294 +#define pax_open_kernel() native_pax_open_kernel()
14295 +#define pax_close_kernel() native_pax_close_kernel()
14296 #endif /* CONFIG_PARAVIRT */
14297
14298 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14299 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14300 +
14301 +#ifdef CONFIG_PAX_KERNEXEC
14302 +static inline unsigned long native_pax_open_kernel(void)
14303 +{
14304 + unsigned long cr0;
14305 +
14306 + preempt_disable();
14307 + barrier();
14308 + cr0 = read_cr0() ^ X86_CR0_WP;
14309 + BUG_ON(cr0 & X86_CR0_WP);
14310 + write_cr0(cr0);
14311 + return cr0 ^ X86_CR0_WP;
14312 +}
14313 +
14314 +static inline unsigned long native_pax_close_kernel(void)
14315 +{
14316 + unsigned long cr0;
14317 +
14318 + cr0 = read_cr0() ^ X86_CR0_WP;
14319 + BUG_ON(!(cr0 & X86_CR0_WP));
14320 + write_cr0(cr0);
14321 + barrier();
14322 + preempt_enable_no_resched();
14323 + return cr0 ^ X86_CR0_WP;
14324 +}
14325 +#else
14326 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14327 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14328 +#endif
14329 +
14330 /*
14331 * The following only work if pte_present() is true.
14332 * Undefined behaviour if not..
14333 */
14334 +static inline int pte_user(pte_t pte)
14335 +{
14336 + return pte_val(pte) & _PAGE_USER;
14337 +}
14338 +
14339 static inline int pte_dirty(pte_t pte)
14340 {
14341 return pte_flags(pte) & _PAGE_DIRTY;
14342 @@ -200,9 +240,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14343 return pte_clear_flags(pte, _PAGE_RW);
14344 }
14345
14346 +static inline pte_t pte_mkread(pte_t pte)
14347 +{
14348 + return __pte(pte_val(pte) | _PAGE_USER);
14349 +}
14350 +
14351 static inline pte_t pte_mkexec(pte_t pte)
14352 {
14353 - return pte_clear_flags(pte, _PAGE_NX);
14354 +#ifdef CONFIG_X86_PAE
14355 + if (__supported_pte_mask & _PAGE_NX)
14356 + return pte_clear_flags(pte, _PAGE_NX);
14357 + else
14358 +#endif
14359 + return pte_set_flags(pte, _PAGE_USER);
14360 +}
14361 +
14362 +static inline pte_t pte_exprotect(pte_t pte)
14363 +{
14364 +#ifdef CONFIG_X86_PAE
14365 + if (__supported_pte_mask & _PAGE_NX)
14366 + return pte_set_flags(pte, _PAGE_NX);
14367 + else
14368 +#endif
14369 + return pte_clear_flags(pte, _PAGE_USER);
14370 }
14371
14372 static inline pte_t pte_mkdirty(pte_t pte)
14373 @@ -394,6 +454,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14374 #endif
14375
14376 #ifndef __ASSEMBLY__
14377 +
14378 +#ifdef CONFIG_PAX_PER_CPU_PGD
14379 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14380 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14381 +{
14382 + return cpu_pgd[cpu];
14383 +}
14384 +#endif
14385 +
14386 #include <linux/mm_types.h>
14387 #include <linux/log2.h>
14388
14389 @@ -584,7 +653,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14390
14391 static inline int pgd_bad(pgd_t pgd)
14392 {
14393 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14394 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14395 }
14396
14397 static inline int pgd_none(pgd_t pgd)
14398 @@ -607,7 +676,12 @@ static inline int pgd_none(pgd_t pgd)
14399 * pgd_offset() returns a (pgd_t *)
14400 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14401 */
14402 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14403 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14404 +
14405 +#ifdef CONFIG_PAX_PER_CPU_PGD
14406 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14407 +#endif
14408 +
14409 /*
14410 * a shortcut which implies the use of the kernel's pgd, instead
14411 * of a process's
14412 @@ -618,6 +692,22 @@ static inline int pgd_none(pgd_t pgd)
14413 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14414 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14415
14416 +#ifdef CONFIG_X86_32
14417 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14418 +#else
14419 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14420 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14421 +
14422 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14423 +#ifdef __ASSEMBLY__
14424 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
14425 +#else
14426 +extern unsigned long pax_user_shadow_base;
14427 +#endif
14428 +#endif
14429 +
14430 +#endif
14431 +
14432 #ifndef __ASSEMBLY__
14433
14434 extern int direct_gbpages;
14435 @@ -784,11 +874,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14436 * dst and src can be on the same page, but the range must not overlap,
14437 * and must not cross a page boundary.
14438 */
14439 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14440 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14441 {
14442 - memcpy(dst, src, count * sizeof(pgd_t));
14443 + pax_open_kernel();
14444 + while (count--)
14445 + *dst++ = *src++;
14446 + pax_close_kernel();
14447 }
14448
14449 +#ifdef CONFIG_PAX_PER_CPU_PGD
14450 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14451 +#endif
14452 +
14453 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14454 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14455 +#else
14456 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14457 +#endif
14458 +
14459 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
14460 static inline int page_level_shift(enum pg_level level)
14461 {
14462 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14463 index 9ee3221..b979c6b 100644
14464 --- a/arch/x86/include/asm/pgtable_32.h
14465 +++ b/arch/x86/include/asm/pgtable_32.h
14466 @@ -25,9 +25,6 @@
14467 struct mm_struct;
14468 struct vm_area_struct;
14469
14470 -extern pgd_t swapper_pg_dir[1024];
14471 -extern pgd_t initial_page_table[1024];
14472 -
14473 static inline void pgtable_cache_init(void) { }
14474 static inline void check_pgt_cache(void) { }
14475 void paging_init(void);
14476 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14477 # include <asm/pgtable-2level.h>
14478 #endif
14479
14480 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14481 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14482 +#ifdef CONFIG_X86_PAE
14483 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14484 +#endif
14485 +
14486 #if defined(CONFIG_HIGHPTE)
14487 #define pte_offset_map(dir, address) \
14488 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14489 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14490 /* Clear a kernel PTE and flush it from the TLB */
14491 #define kpte_clear_flush(ptep, vaddr) \
14492 do { \
14493 + pax_open_kernel(); \
14494 pte_clear(&init_mm, (vaddr), (ptep)); \
14495 + pax_close_kernel(); \
14496 __flush_tlb_one((vaddr)); \
14497 } while (0)
14498
14499 #endif /* !__ASSEMBLY__ */
14500
14501 +#define HAVE_ARCH_UNMAPPED_AREA
14502 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14503 +
14504 /*
14505 * kern_addr_valid() is (1) for FLATMEM and (0) for
14506 * SPARSEMEM and DISCONTIGMEM
14507 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14508 index ed5903b..c7fe163 100644
14509 --- a/arch/x86/include/asm/pgtable_32_types.h
14510 +++ b/arch/x86/include/asm/pgtable_32_types.h
14511 @@ -8,7 +8,7 @@
14512 */
14513 #ifdef CONFIG_X86_PAE
14514 # include <asm/pgtable-3level_types.h>
14515 -# define PMD_SIZE (1UL << PMD_SHIFT)
14516 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14517 # define PMD_MASK (~(PMD_SIZE - 1))
14518 #else
14519 # include <asm/pgtable-2level_types.h>
14520 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14521 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14522 #endif
14523
14524 +#ifdef CONFIG_PAX_KERNEXEC
14525 +#ifndef __ASSEMBLY__
14526 +extern unsigned char MODULES_EXEC_VADDR[];
14527 +extern unsigned char MODULES_EXEC_END[];
14528 +#endif
14529 +#include <asm/boot.h>
14530 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14531 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14532 +#else
14533 +#define ktla_ktva(addr) (addr)
14534 +#define ktva_ktla(addr) (addr)
14535 +#endif
14536 +
14537 #define MODULES_VADDR VMALLOC_START
14538 #define MODULES_END VMALLOC_END
14539 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14540 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14541 index e22c1db..23a625a 100644
14542 --- a/arch/x86/include/asm/pgtable_64.h
14543 +++ b/arch/x86/include/asm/pgtable_64.h
14544 @@ -16,10 +16,14 @@
14545
14546 extern pud_t level3_kernel_pgt[512];
14547 extern pud_t level3_ident_pgt[512];
14548 +extern pud_t level3_vmalloc_start_pgt[512];
14549 +extern pud_t level3_vmalloc_end_pgt[512];
14550 +extern pud_t level3_vmemmap_pgt[512];
14551 +extern pud_t level2_vmemmap_pgt[512];
14552 extern pmd_t level2_kernel_pgt[512];
14553 extern pmd_t level2_fixmap_pgt[512];
14554 -extern pmd_t level2_ident_pgt[512];
14555 -extern pgd_t init_level4_pgt[];
14556 +extern pmd_t level2_ident_pgt[512*2];
14557 +extern pgd_t init_level4_pgt[512];
14558
14559 #define swapper_pg_dir init_level4_pgt
14560
14561 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14562
14563 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14564 {
14565 + pax_open_kernel();
14566 *pmdp = pmd;
14567 + pax_close_kernel();
14568 }
14569
14570 static inline void native_pmd_clear(pmd_t *pmd)
14571 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14572
14573 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14574 {
14575 + pax_open_kernel();
14576 *pudp = pud;
14577 + pax_close_kernel();
14578 }
14579
14580 static inline void native_pud_clear(pud_t *pud)
14581 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14582
14583 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14584 {
14585 + pax_open_kernel();
14586 + *pgdp = pgd;
14587 + pax_close_kernel();
14588 +}
14589 +
14590 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14591 +{
14592 *pgdp = pgd;
14593 }
14594
14595 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14596 index 2d88344..4679fc3 100644
14597 --- a/arch/x86/include/asm/pgtable_64_types.h
14598 +++ b/arch/x86/include/asm/pgtable_64_types.h
14599 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
14600 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
14601 #define MODULES_END _AC(0xffffffffff000000, UL)
14602 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
14603 +#define MODULES_EXEC_VADDR MODULES_VADDR
14604 +#define MODULES_EXEC_END MODULES_END
14605 +
14606 +#define ktla_ktva(addr) (addr)
14607 +#define ktva_ktla(addr) (addr)
14608
14609 #define EARLY_DYNAMIC_PAGE_TABLES 64
14610
14611 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
14612 index 567b5d0..bd91d64 100644
14613 --- a/arch/x86/include/asm/pgtable_types.h
14614 +++ b/arch/x86/include/asm/pgtable_types.h
14615 @@ -16,13 +16,12 @@
14616 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
14617 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
14618 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
14619 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
14620 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
14621 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
14622 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
14623 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
14624 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
14625 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
14626 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
14627 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
14628 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
14629 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
14630
14631 /* If _PAGE_BIT_PRESENT is clear, we use these: */
14632 @@ -40,7 +39,6 @@
14633 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
14634 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
14635 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
14636 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
14637 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
14638 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
14639 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
14640 @@ -57,8 +55,10 @@
14641
14642 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
14643 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
14644 -#else
14645 +#elif defined(CONFIG_KMEMCHECK)
14646 #define _PAGE_NX (_AT(pteval_t, 0))
14647 +#else
14648 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
14649 #endif
14650
14651 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
14652 @@ -116,6 +116,9 @@
14653 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
14654 _PAGE_ACCESSED)
14655
14656 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
14657 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
14658 +
14659 #define __PAGE_KERNEL_EXEC \
14660 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
14661 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
14662 @@ -126,7 +129,7 @@
14663 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
14664 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
14665 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
14666 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
14667 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
14668 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
14669 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
14670 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
14671 @@ -188,8 +191,8 @@
14672 * bits are combined, this will alow user to access the high address mapped
14673 * VDSO in the presence of CONFIG_COMPAT_VDSO
14674 */
14675 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
14676 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
14677 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14678 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14679 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
14680 #endif
14681
14682 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
14683 {
14684 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
14685 }
14686 +#endif
14687
14688 +#if PAGETABLE_LEVELS == 3
14689 +#include <asm-generic/pgtable-nopud.h>
14690 +#endif
14691 +
14692 +#if PAGETABLE_LEVELS == 2
14693 +#include <asm-generic/pgtable-nopmd.h>
14694 +#endif
14695 +
14696 +#ifndef __ASSEMBLY__
14697 #if PAGETABLE_LEVELS > 3
14698 typedef struct { pudval_t pud; } pud_t;
14699
14700 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
14701 return pud.pud;
14702 }
14703 #else
14704 -#include <asm-generic/pgtable-nopud.h>
14705 -
14706 static inline pudval_t native_pud_val(pud_t pud)
14707 {
14708 return native_pgd_val(pud.pgd);
14709 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
14710 return pmd.pmd;
14711 }
14712 #else
14713 -#include <asm-generic/pgtable-nopmd.h>
14714 -
14715 static inline pmdval_t native_pmd_val(pmd_t pmd)
14716 {
14717 return native_pgd_val(pmd.pud.pgd);
14718 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
14719
14720 extern pteval_t __supported_pte_mask;
14721 extern void set_nx(void);
14722 -extern int nx_enabled;
14723
14724 #define pgprot_writecombine pgprot_writecombine
14725 extern pgprot_t pgprot_writecombine(pgprot_t prot);
14726 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
14727 index 3270116..8d99d82 100644
14728 --- a/arch/x86/include/asm/processor.h
14729 +++ b/arch/x86/include/asm/processor.h
14730 @@ -285,7 +285,7 @@ struct tss_struct {
14731
14732 } ____cacheline_aligned;
14733
14734 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
14735 +extern struct tss_struct init_tss[NR_CPUS];
14736
14737 /*
14738 * Save the original ist values for checking stack pointers during debugging
14739 @@ -826,11 +826,18 @@ static inline void spin_lock_prefetch(const void *x)
14740 */
14741 #define TASK_SIZE PAGE_OFFSET
14742 #define TASK_SIZE_MAX TASK_SIZE
14743 +
14744 +#ifdef CONFIG_PAX_SEGMEXEC
14745 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
14746 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
14747 +#else
14748 #define STACK_TOP TASK_SIZE
14749 -#define STACK_TOP_MAX STACK_TOP
14750 +#endif
14751 +
14752 +#define STACK_TOP_MAX TASK_SIZE
14753
14754 #define INIT_THREAD { \
14755 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14756 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14757 .vm86_info = NULL, \
14758 .sysenter_cs = __KERNEL_CS, \
14759 .io_bitmap_ptr = NULL, \
14760 @@ -844,7 +851,7 @@ static inline void spin_lock_prefetch(const void *x)
14761 */
14762 #define INIT_TSS { \
14763 .x86_tss = { \
14764 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14765 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14766 .ss0 = __KERNEL_DS, \
14767 .ss1 = __KERNEL_CS, \
14768 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
14769 @@ -855,11 +862,7 @@ static inline void spin_lock_prefetch(const void *x)
14770 extern unsigned long thread_saved_pc(struct task_struct *tsk);
14771
14772 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
14773 -#define KSTK_TOP(info) \
14774 -({ \
14775 - unsigned long *__ptr = (unsigned long *)(info); \
14776 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
14777 -})
14778 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
14779
14780 /*
14781 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
14782 @@ -874,7 +877,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14783 #define task_pt_regs(task) \
14784 ({ \
14785 struct pt_regs *__regs__; \
14786 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
14787 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
14788 __regs__ - 1; \
14789 })
14790
14791 @@ -884,13 +887,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14792 /*
14793 * User space process size. 47bits minus one guard page.
14794 */
14795 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
14796 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
14797
14798 /* This decides where the kernel will search for a free chunk of vm
14799 * space during mmap's.
14800 */
14801 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
14802 - 0xc0000000 : 0xFFFFe000)
14803 + 0xc0000000 : 0xFFFFf000)
14804
14805 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
14806 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
14807 @@ -901,11 +904,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14808 #define STACK_TOP_MAX TASK_SIZE_MAX
14809
14810 #define INIT_THREAD { \
14811 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14812 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14813 }
14814
14815 #define INIT_TSS { \
14816 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14817 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14818 }
14819
14820 /*
14821 @@ -933,6 +936,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
14822 */
14823 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
14824
14825 +#ifdef CONFIG_PAX_SEGMEXEC
14826 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
14827 +#endif
14828 +
14829 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
14830
14831 /* Get/set a process' ability to use the timestamp counter instruction */
14832 @@ -993,7 +1000,7 @@ extern bool cpu_has_amd_erratum(const int *);
14833 #define cpu_has_amd_erratum(x) (false)
14834 #endif /* CONFIG_CPU_SUP_AMD */
14835
14836 -extern unsigned long arch_align_stack(unsigned long sp);
14837 +#define arch_align_stack(x) ((x) & ~0xfUL)
14838 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
14839
14840 void default_idle(void);
14841 @@ -1003,6 +1010,6 @@ bool xen_set_default_idle(void);
14842 #define xen_set_default_idle 0
14843 #endif
14844
14845 -void stop_this_cpu(void *dummy);
14846 +void stop_this_cpu(void *dummy) __noreturn;
14847
14848 #endif /* _ASM_X86_PROCESSOR_H */
14849 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
14850 index 942a086..6c26446 100644
14851 --- a/arch/x86/include/asm/ptrace.h
14852 +++ b/arch/x86/include/asm/ptrace.h
14853 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
14854 }
14855
14856 /*
14857 - * user_mode_vm(regs) determines whether a register set came from user mode.
14858 + * user_mode(regs) determines whether a register set came from user mode.
14859 * This is true if V8086 mode was enabled OR if the register set was from
14860 * protected mode with RPL-3 CS value. This tricky test checks that with
14861 * one comparison. Many places in the kernel can bypass this full check
14862 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
14863 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
14864 + * be used.
14865 */
14866 -static inline int user_mode(struct pt_regs *regs)
14867 +static inline int user_mode_novm(struct pt_regs *regs)
14868 {
14869 #ifdef CONFIG_X86_32
14870 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
14871 #else
14872 - return !!(regs->cs & 3);
14873 + return !!(regs->cs & SEGMENT_RPL_MASK);
14874 #endif
14875 }
14876
14877 -static inline int user_mode_vm(struct pt_regs *regs)
14878 +static inline int user_mode(struct pt_regs *regs)
14879 {
14880 #ifdef CONFIG_X86_32
14881 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
14882 USER_RPL;
14883 #else
14884 - return user_mode(regs);
14885 + return user_mode_novm(regs);
14886 #endif
14887 }
14888
14889 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
14890 #ifdef CONFIG_X86_64
14891 static inline bool user_64bit_mode(struct pt_regs *regs)
14892 {
14893 + unsigned long cs = regs->cs & 0xffff;
14894 #ifndef CONFIG_PARAVIRT
14895 /*
14896 * On non-paravirt systems, this is the only long mode CPL 3
14897 * selector. We do not allow long mode selectors in the LDT.
14898 */
14899 - return regs->cs == __USER_CS;
14900 + return cs == __USER_CS;
14901 #else
14902 /* Headers are too twisted for this to go in paravirt.h. */
14903 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
14904 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
14905 #endif
14906 }
14907
14908 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
14909 * Traps from the kernel do not save sp and ss.
14910 * Use the helper function to retrieve sp.
14911 */
14912 - if (offset == offsetof(struct pt_regs, sp) &&
14913 - regs->cs == __KERNEL_CS)
14914 - return kernel_stack_pointer(regs);
14915 + if (offset == offsetof(struct pt_regs, sp)) {
14916 + unsigned long cs = regs->cs & 0xffff;
14917 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
14918 + return kernel_stack_pointer(regs);
14919 + }
14920 #endif
14921 return *(unsigned long *)((unsigned long)regs + offset);
14922 }
14923 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
14924 index 9c6b890..5305f53 100644
14925 --- a/arch/x86/include/asm/realmode.h
14926 +++ b/arch/x86/include/asm/realmode.h
14927 @@ -22,16 +22,14 @@ struct real_mode_header {
14928 #endif
14929 /* APM/BIOS reboot */
14930 u32 machine_real_restart_asm;
14931 -#ifdef CONFIG_X86_64
14932 u32 machine_real_restart_seg;
14933 -#endif
14934 };
14935
14936 /* This must match data at trampoline_32/64.S */
14937 struct trampoline_header {
14938 #ifdef CONFIG_X86_32
14939 u32 start;
14940 - u16 gdt_pad;
14941 + u16 boot_cs;
14942 u16 gdt_limit;
14943 u32 gdt_base;
14944 #else
14945 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
14946 index a82c4f1..ac45053 100644
14947 --- a/arch/x86/include/asm/reboot.h
14948 +++ b/arch/x86/include/asm/reboot.h
14949 @@ -6,13 +6,13 @@
14950 struct pt_regs;
14951
14952 struct machine_ops {
14953 - void (*restart)(char *cmd);
14954 - void (*halt)(void);
14955 - void (*power_off)(void);
14956 + void (* __noreturn restart)(char *cmd);
14957 + void (* __noreturn halt)(void);
14958 + void (* __noreturn power_off)(void);
14959 void (*shutdown)(void);
14960 void (*crash_shutdown)(struct pt_regs *);
14961 - void (*emergency_restart)(void);
14962 -};
14963 + void (* __noreturn emergency_restart)(void);
14964 +} __no_const;
14965
14966 extern struct machine_ops machine_ops;
14967
14968 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
14969 index 2dbe4a7..ce1db00 100644
14970 --- a/arch/x86/include/asm/rwsem.h
14971 +++ b/arch/x86/include/asm/rwsem.h
14972 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
14973 {
14974 asm volatile("# beginning down_read\n\t"
14975 LOCK_PREFIX _ASM_INC "(%1)\n\t"
14976 +
14977 +#ifdef CONFIG_PAX_REFCOUNT
14978 + "jno 0f\n"
14979 + LOCK_PREFIX _ASM_DEC "(%1)\n"
14980 + "int $4\n0:\n"
14981 + _ASM_EXTABLE(0b, 0b)
14982 +#endif
14983 +
14984 /* adds 0x00000001 */
14985 " jns 1f\n"
14986 " call call_rwsem_down_read_failed\n"
14987 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
14988 "1:\n\t"
14989 " mov %1,%2\n\t"
14990 " add %3,%2\n\t"
14991 +
14992 +#ifdef CONFIG_PAX_REFCOUNT
14993 + "jno 0f\n"
14994 + "sub %3,%2\n"
14995 + "int $4\n0:\n"
14996 + _ASM_EXTABLE(0b, 0b)
14997 +#endif
14998 +
14999 " jle 2f\n\t"
15000 LOCK_PREFIX " cmpxchg %2,%0\n\t"
15001 " jnz 1b\n\t"
15002 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
15003 long tmp;
15004 asm volatile("# beginning down_write\n\t"
15005 LOCK_PREFIX " xadd %1,(%2)\n\t"
15006 +
15007 +#ifdef CONFIG_PAX_REFCOUNT
15008 + "jno 0f\n"
15009 + "mov %1,(%2)\n"
15010 + "int $4\n0:\n"
15011 + _ASM_EXTABLE(0b, 0b)
15012 +#endif
15013 +
15014 /* adds 0xffff0001, returns the old value */
15015 " test %1,%1\n\t"
15016 /* was the count 0 before? */
15017 @@ -141,6 +165,14 @@ static inline void __up_read(struct rw_semaphore *sem)
15018 long tmp;
15019 asm volatile("# beginning __up_read\n\t"
15020 LOCK_PREFIX " xadd %1,(%2)\n\t"
15021 +
15022 +#ifdef CONFIG_PAX_REFCOUNT
15023 + "jno 0f\n"
15024 + "mov %1,(%2)\n"
15025 + "int $4\n0:\n"
15026 + _ASM_EXTABLE(0b, 0b)
15027 +#endif
15028 +
15029 /* subtracts 1, returns the old value */
15030 " jns 1f\n\t"
15031 " call call_rwsem_wake\n" /* expects old value in %edx */
15032 @@ -159,6 +191,14 @@ static inline void __up_write(struct rw_semaphore *sem)
15033 long tmp;
15034 asm volatile("# beginning __up_write\n\t"
15035 LOCK_PREFIX " xadd %1,(%2)\n\t"
15036 +
15037 +#ifdef CONFIG_PAX_REFCOUNT
15038 + "jno 0f\n"
15039 + "mov %1,(%2)\n"
15040 + "int $4\n0:\n"
15041 + _ASM_EXTABLE(0b, 0b)
15042 +#endif
15043 +
15044 /* subtracts 0xffff0001, returns the old value */
15045 " jns 1f\n\t"
15046 " call call_rwsem_wake\n" /* expects old value in %edx */
15047 @@ -176,6 +216,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15048 {
15049 asm volatile("# beginning __downgrade_write\n\t"
15050 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
15051 +
15052 +#ifdef CONFIG_PAX_REFCOUNT
15053 + "jno 0f\n"
15054 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15055 + "int $4\n0:\n"
15056 + _ASM_EXTABLE(0b, 0b)
15057 +#endif
15058 +
15059 /*
15060 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15061 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15062 @@ -194,7 +242,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15063 */
15064 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15065 {
15066 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15067 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15068 +
15069 +#ifdef CONFIG_PAX_REFCOUNT
15070 + "jno 0f\n"
15071 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15072 + "int $4\n0:\n"
15073 + _ASM_EXTABLE(0b, 0b)
15074 +#endif
15075 +
15076 : "+m" (sem->count)
15077 : "er" (delta));
15078 }
15079 @@ -204,7 +260,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15080 */
15081 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15082 {
15083 - return delta + xadd(&sem->count, delta);
15084 + return delta + xadd_check_overflow(&sem->count, delta);
15085 }
15086
15087 #endif /* __KERNEL__ */
15088 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15089 index c48a950..c6d7468 100644
15090 --- a/arch/x86/include/asm/segment.h
15091 +++ b/arch/x86/include/asm/segment.h
15092 @@ -64,10 +64,15 @@
15093 * 26 - ESPFIX small SS
15094 * 27 - per-cpu [ offset to per-cpu data area ]
15095 * 28 - stack_canary-20 [ for stack protector ]
15096 - * 29 - unused
15097 - * 30 - unused
15098 + * 29 - PCI BIOS CS
15099 + * 30 - PCI BIOS DS
15100 * 31 - TSS for double fault handler
15101 */
15102 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15103 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15104 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15105 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15106 +
15107 #define GDT_ENTRY_TLS_MIN 6
15108 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15109
15110 @@ -79,6 +84,8 @@
15111
15112 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15113
15114 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15115 +
15116 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15117
15118 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15119 @@ -104,6 +111,12 @@
15120 #define __KERNEL_STACK_CANARY 0
15121 #endif
15122
15123 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15124 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15125 +
15126 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15127 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15128 +
15129 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15130
15131 /*
15132 @@ -141,7 +154,7 @@
15133 */
15134
15135 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15136 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15137 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15138
15139
15140 #else
15141 @@ -165,6 +178,8 @@
15142 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15143 #define __USER32_DS __USER_DS
15144
15145 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15146 +
15147 #define GDT_ENTRY_TSS 8 /* needs two entries */
15148 #define GDT_ENTRY_LDT 10 /* needs two entries */
15149 #define GDT_ENTRY_TLS_MIN 12
15150 @@ -185,6 +200,7 @@
15151 #endif
15152
15153 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15154 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15155 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15156 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15157 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15158 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15159 {
15160 unsigned long __limit;
15161 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15162 - return __limit + 1;
15163 + return __limit;
15164 }
15165
15166 #endif /* !__ASSEMBLY__ */
15167 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15168 index b073aae..39f9bdd 100644
15169 --- a/arch/x86/include/asm/smp.h
15170 +++ b/arch/x86/include/asm/smp.h
15171 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15172 /* cpus sharing the last level cache: */
15173 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15174 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15175 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15176 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15177
15178 static inline struct cpumask *cpu_sibling_mask(int cpu)
15179 {
15180 @@ -79,7 +79,7 @@ struct smp_ops {
15181
15182 void (*send_call_func_ipi)(const struct cpumask *mask);
15183 void (*send_call_func_single_ipi)(int cpu);
15184 -};
15185 +} __no_const;
15186
15187 /* Globals due to paravirt */
15188 extern void set_cpu_sibling_map(int cpu);
15189 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15190 extern int safe_smp_processor_id(void);
15191
15192 #elif defined(CONFIG_X86_64_SMP)
15193 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15194 -
15195 -#define stack_smp_processor_id() \
15196 -({ \
15197 - struct thread_info *ti; \
15198 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15199 - ti->cpu; \
15200 -})
15201 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15202 +#define stack_smp_processor_id() raw_smp_processor_id()
15203 #define safe_smp_processor_id() smp_processor_id()
15204
15205 #endif
15206 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15207 index 33692ea..350a534 100644
15208 --- a/arch/x86/include/asm/spinlock.h
15209 +++ b/arch/x86/include/asm/spinlock.h
15210 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15211 static inline void arch_read_lock(arch_rwlock_t *rw)
15212 {
15213 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15214 +
15215 +#ifdef CONFIG_PAX_REFCOUNT
15216 + "jno 0f\n"
15217 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15218 + "int $4\n0:\n"
15219 + _ASM_EXTABLE(0b, 0b)
15220 +#endif
15221 +
15222 "jns 1f\n"
15223 "call __read_lock_failed\n\t"
15224 "1:\n"
15225 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15226 static inline void arch_write_lock(arch_rwlock_t *rw)
15227 {
15228 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15229 +
15230 +#ifdef CONFIG_PAX_REFCOUNT
15231 + "jno 0f\n"
15232 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15233 + "int $4\n0:\n"
15234 + _ASM_EXTABLE(0b, 0b)
15235 +#endif
15236 +
15237 "jz 1f\n"
15238 "call __write_lock_failed\n\t"
15239 "1:\n"
15240 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15241
15242 static inline void arch_read_unlock(arch_rwlock_t *rw)
15243 {
15244 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15245 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15246 +
15247 +#ifdef CONFIG_PAX_REFCOUNT
15248 + "jno 0f\n"
15249 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15250 + "int $4\n0:\n"
15251 + _ASM_EXTABLE(0b, 0b)
15252 +#endif
15253 +
15254 :"+m" (rw->lock) : : "memory");
15255 }
15256
15257 static inline void arch_write_unlock(arch_rwlock_t *rw)
15258 {
15259 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15260 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15261 +
15262 +#ifdef CONFIG_PAX_REFCOUNT
15263 + "jno 0f\n"
15264 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15265 + "int $4\n0:\n"
15266 + _ASM_EXTABLE(0b, 0b)
15267 +#endif
15268 +
15269 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15270 }
15271
15272 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15273 index 6a99859..03cb807 100644
15274 --- a/arch/x86/include/asm/stackprotector.h
15275 +++ b/arch/x86/include/asm/stackprotector.h
15276 @@ -47,7 +47,7 @@
15277 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15278 */
15279 #define GDT_STACK_CANARY_INIT \
15280 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15281 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15282
15283 /*
15284 * Initialize the stackprotector canary value.
15285 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15286
15287 static inline void load_stack_canary_segment(void)
15288 {
15289 -#ifdef CONFIG_X86_32
15290 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15291 asm volatile ("mov %0, %%gs" : : "r" (0));
15292 #endif
15293 }
15294 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15295 index 70bbe39..4ae2bd4 100644
15296 --- a/arch/x86/include/asm/stacktrace.h
15297 +++ b/arch/x86/include/asm/stacktrace.h
15298 @@ -11,28 +11,20 @@
15299
15300 extern int kstack_depth_to_print;
15301
15302 -struct thread_info;
15303 +struct task_struct;
15304 struct stacktrace_ops;
15305
15306 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15307 - unsigned long *stack,
15308 - unsigned long bp,
15309 - const struct stacktrace_ops *ops,
15310 - void *data,
15311 - unsigned long *end,
15312 - int *graph);
15313 +typedef unsigned long walk_stack_t(struct task_struct *task,
15314 + void *stack_start,
15315 + unsigned long *stack,
15316 + unsigned long bp,
15317 + const struct stacktrace_ops *ops,
15318 + void *data,
15319 + unsigned long *end,
15320 + int *graph);
15321
15322 -extern unsigned long
15323 -print_context_stack(struct thread_info *tinfo,
15324 - unsigned long *stack, unsigned long bp,
15325 - const struct stacktrace_ops *ops, void *data,
15326 - unsigned long *end, int *graph);
15327 -
15328 -extern unsigned long
15329 -print_context_stack_bp(struct thread_info *tinfo,
15330 - unsigned long *stack, unsigned long bp,
15331 - const struct stacktrace_ops *ops, void *data,
15332 - unsigned long *end, int *graph);
15333 +extern walk_stack_t print_context_stack;
15334 +extern walk_stack_t print_context_stack_bp;
15335
15336 /* Generic stack tracer with callbacks */
15337
15338 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15339 void (*address)(void *data, unsigned long address, int reliable);
15340 /* On negative return stop dumping */
15341 int (*stack)(void *data, char *name);
15342 - walk_stack_t walk_stack;
15343 + walk_stack_t *walk_stack;
15344 };
15345
15346 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15347 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15348 index 4ec45b3..a4f0a8a 100644
15349 --- a/arch/x86/include/asm/switch_to.h
15350 +++ b/arch/x86/include/asm/switch_to.h
15351 @@ -108,7 +108,7 @@ do { \
15352 "call __switch_to\n\t" \
15353 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15354 __switch_canary \
15355 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15356 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15357 "movq %%rax,%%rdi\n\t" \
15358 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15359 "jnz ret_from_fork\n\t" \
15360 @@ -119,7 +119,7 @@ do { \
15361 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15362 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15363 [_tif_fork] "i" (_TIF_FORK), \
15364 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15365 + [thread_info] "m" (current_tinfo), \
15366 [current_task] "m" (current_task) \
15367 __switch_canary_iparam \
15368 : "memory", "cc" __EXTRA_CLOBBER)
15369 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15370 index 2cd056e..0224df8 100644
15371 --- a/arch/x86/include/asm/thread_info.h
15372 +++ b/arch/x86/include/asm/thread_info.h
15373 @@ -10,6 +10,7 @@
15374 #include <linux/compiler.h>
15375 #include <asm/page.h>
15376 #include <asm/types.h>
15377 +#include <asm/percpu.h>
15378
15379 /*
15380 * low level task data that entry.S needs immediate access to
15381 @@ -23,7 +24,6 @@ struct exec_domain;
15382 #include <linux/atomic.h>
15383
15384 struct thread_info {
15385 - struct task_struct *task; /* main task structure */
15386 struct exec_domain *exec_domain; /* execution domain */
15387 __u32 flags; /* low level flags */
15388 __u32 status; /* thread synchronous flags */
15389 @@ -33,19 +33,13 @@ struct thread_info {
15390 mm_segment_t addr_limit;
15391 struct restart_block restart_block;
15392 void __user *sysenter_return;
15393 -#ifdef CONFIG_X86_32
15394 - unsigned long previous_esp; /* ESP of the previous stack in
15395 - case of nested (IRQ) stacks
15396 - */
15397 - __u8 supervisor_stack[0];
15398 -#endif
15399 + unsigned long lowest_stack;
15400 unsigned int sig_on_uaccess_error:1;
15401 unsigned int uaccess_err:1; /* uaccess failed */
15402 };
15403
15404 -#define INIT_THREAD_INFO(tsk) \
15405 +#define INIT_THREAD_INFO \
15406 { \
15407 - .task = &tsk, \
15408 .exec_domain = &default_exec_domain, \
15409 .flags = 0, \
15410 .cpu = 0, \
15411 @@ -56,7 +50,7 @@ struct thread_info {
15412 }, \
15413 }
15414
15415 -#define init_thread_info (init_thread_union.thread_info)
15416 +#define init_thread_info (init_thread_union.stack)
15417 #define init_stack (init_thread_union.stack)
15418
15419 #else /* !__ASSEMBLY__ */
15420 @@ -97,6 +91,7 @@ struct thread_info {
15421 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15422 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15423 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15424 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15425
15426 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15427 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15428 @@ -121,17 +116,18 @@ struct thread_info {
15429 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15430 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15431 #define _TIF_X32 (1 << TIF_X32)
15432 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15433
15434 /* work to do in syscall_trace_enter() */
15435 #define _TIF_WORK_SYSCALL_ENTRY \
15436 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15437 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15438 - _TIF_NOHZ)
15439 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15440
15441 /* work to do in syscall_trace_leave() */
15442 #define _TIF_WORK_SYSCALL_EXIT \
15443 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15444 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15445 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15446
15447 /* work to do on interrupt/exception return */
15448 #define _TIF_WORK_MASK \
15449 @@ -142,7 +138,7 @@ struct thread_info {
15450 /* work to do on any return to user space */
15451 #define _TIF_ALLWORK_MASK \
15452 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15453 - _TIF_NOHZ)
15454 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15455
15456 /* Only used for 64 bit */
15457 #define _TIF_DO_NOTIFY_MASK \
15458 @@ -158,45 +154,40 @@ struct thread_info {
15459
15460 #define PREEMPT_ACTIVE 0x10000000
15461
15462 -#ifdef CONFIG_X86_32
15463 -
15464 -#define STACK_WARN (THREAD_SIZE/8)
15465 -/*
15466 - * macros/functions for gaining access to the thread information structure
15467 - *
15468 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15469 - */
15470 -#ifndef __ASSEMBLY__
15471 -
15472 -
15473 -/* how to get the current stack pointer from C */
15474 -register unsigned long current_stack_pointer asm("esp") __used;
15475 -
15476 -/* how to get the thread information struct from C */
15477 -static inline struct thread_info *current_thread_info(void)
15478 -{
15479 - return (struct thread_info *)
15480 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15481 -}
15482 -
15483 -#else /* !__ASSEMBLY__ */
15484 -
15485 +#ifdef __ASSEMBLY__
15486 /* how to get the thread information struct from ASM */
15487 #define GET_THREAD_INFO(reg) \
15488 - movl $-THREAD_SIZE, reg; \
15489 - andl %esp, reg
15490 + mov PER_CPU_VAR(current_tinfo), reg
15491
15492 /* use this one if reg already contains %esp */
15493 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15494 - andl $-THREAD_SIZE, reg
15495 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15496 +#else
15497 +/* how to get the thread information struct from C */
15498 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15499 +
15500 +static __always_inline struct thread_info *current_thread_info(void)
15501 +{
15502 + return this_cpu_read_stable(current_tinfo);
15503 +}
15504 +#endif
15505 +
15506 +#ifdef CONFIG_X86_32
15507 +
15508 +#define STACK_WARN (THREAD_SIZE/8)
15509 +/*
15510 + * macros/functions for gaining access to the thread information structure
15511 + *
15512 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15513 + */
15514 +#ifndef __ASSEMBLY__
15515 +
15516 +/* how to get the current stack pointer from C */
15517 +register unsigned long current_stack_pointer asm("esp") __used;
15518
15519 #endif
15520
15521 #else /* X86_32 */
15522
15523 -#include <asm/percpu.h>
15524 -#define KERNEL_STACK_OFFSET (5*8)
15525 -
15526 /*
15527 * macros/functions for gaining access to the thread information structure
15528 * preempt_count needs to be 1 initially, until the scheduler is functional.
15529 @@ -204,27 +195,8 @@ static inline struct thread_info *current_thread_info(void)
15530 #ifndef __ASSEMBLY__
15531 DECLARE_PER_CPU(unsigned long, kernel_stack);
15532
15533 -static inline struct thread_info *current_thread_info(void)
15534 -{
15535 - struct thread_info *ti;
15536 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15537 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15538 - return ti;
15539 -}
15540 -
15541 -#else /* !__ASSEMBLY__ */
15542 -
15543 -/* how to get the thread information struct from ASM */
15544 -#define GET_THREAD_INFO(reg) \
15545 - movq PER_CPU_VAR(kernel_stack),reg ; \
15546 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15547 -
15548 -/*
15549 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15550 - * a certain register (to be used in assembler memory operands).
15551 - */
15552 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15553 -
15554 +/* how to get the current stack pointer from C */
15555 +register unsigned long current_stack_pointer asm("rsp") __used;
15556 #endif
15557
15558 #endif /* !X86_32 */
15559 @@ -285,5 +257,12 @@ static inline bool is_ia32_task(void)
15560 extern void arch_task_cache_init(void);
15561 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15562 extern void arch_release_task_struct(struct task_struct *tsk);
15563 +
15564 +#define __HAVE_THREAD_FUNCTIONS
15565 +#define task_thread_info(task) (&(task)->tinfo)
15566 +#define task_stack_page(task) ((task)->stack)
15567 +#define setup_thread_stack(p, org) do {} while (0)
15568 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15569 +
15570 #endif
15571 #endif /* _ASM_X86_THREAD_INFO_H */
15572 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15573 index 5ee2687..70d5895 100644
15574 --- a/arch/x86/include/asm/uaccess.h
15575 +++ b/arch/x86/include/asm/uaccess.h
15576 @@ -7,6 +7,7 @@
15577 #include <linux/compiler.h>
15578 #include <linux/thread_info.h>
15579 #include <linux/string.h>
15580 +#include <linux/sched.h>
15581 #include <asm/asm.h>
15582 #include <asm/page.h>
15583 #include <asm/smap.h>
15584 @@ -29,7 +30,12 @@
15585
15586 #define get_ds() (KERNEL_DS)
15587 #define get_fs() (current_thread_info()->addr_limit)
15588 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15589 +void __set_fs(mm_segment_t x);
15590 +void set_fs(mm_segment_t x);
15591 +#else
15592 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15593 +#endif
15594
15595 #define segment_eq(a, b) ((a).seg == (b).seg)
15596
15597 @@ -77,8 +83,33 @@
15598 * checks that the pointer is in the user space range - after calling
15599 * this function, memory access functions may still return -EFAULT.
15600 */
15601 -#define access_ok(type, addr, size) \
15602 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15603 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15604 +#define access_ok(type, addr, size) \
15605 +({ \
15606 + long __size = size; \
15607 + unsigned long __addr = (unsigned long)addr; \
15608 + unsigned long __addr_ao = __addr & PAGE_MASK; \
15609 + unsigned long __end_ao = __addr + __size - 1; \
15610 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
15611 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
15612 + while(__addr_ao <= __end_ao) { \
15613 + char __c_ao; \
15614 + __addr_ao += PAGE_SIZE; \
15615 + if (__size > PAGE_SIZE) \
15616 + cond_resched(); \
15617 + if (__get_user(__c_ao, (char __user *)__addr)) \
15618 + break; \
15619 + if (type != VERIFY_WRITE) { \
15620 + __addr = __addr_ao; \
15621 + continue; \
15622 + } \
15623 + if (__put_user(__c_ao, (char __user *)__addr)) \
15624 + break; \
15625 + __addr = __addr_ao; \
15626 + } \
15627 + } \
15628 + __ret_ao; \
15629 +})
15630
15631 /*
15632 * The exception table consists of pairs of addresses relative to the
15633 @@ -176,13 +207,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15634 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
15635 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
15636
15637 -
15638 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15639 +#define __copyuser_seg "gs;"
15640 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
15641 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
15642 +#else
15643 +#define __copyuser_seg
15644 +#define __COPYUSER_SET_ES
15645 +#define __COPYUSER_RESTORE_ES
15646 +#endif
15647
15648 #ifdef CONFIG_X86_32
15649 #define __put_user_asm_u64(x, addr, err, errret) \
15650 asm volatile(ASM_STAC "\n" \
15651 - "1: movl %%eax,0(%2)\n" \
15652 - "2: movl %%edx,4(%2)\n" \
15653 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
15654 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
15655 "3: " ASM_CLAC "\n" \
15656 ".section .fixup,\"ax\"\n" \
15657 "4: movl %3,%0\n" \
15658 @@ -195,8 +234,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15659
15660 #define __put_user_asm_ex_u64(x, addr) \
15661 asm volatile(ASM_STAC "\n" \
15662 - "1: movl %%eax,0(%1)\n" \
15663 - "2: movl %%edx,4(%1)\n" \
15664 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
15665 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
15666 "3: " ASM_CLAC "\n" \
15667 _ASM_EXTABLE_EX(1b, 2b) \
15668 _ASM_EXTABLE_EX(2b, 3b) \
15669 @@ -246,7 +285,7 @@ extern void __put_user_8(void);
15670 __typeof__(*(ptr)) __pu_val; \
15671 __chk_user_ptr(ptr); \
15672 might_fault(); \
15673 - __pu_val = x; \
15674 + __pu_val = (x); \
15675 switch (sizeof(*(ptr))) { \
15676 case 1: \
15677 __put_user_x(1, __pu_val, ptr, __ret_pu); \
15678 @@ -345,7 +384,7 @@ do { \
15679
15680 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15681 asm volatile(ASM_STAC "\n" \
15682 - "1: mov"itype" %2,%"rtype"1\n" \
15683 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
15684 "2: " ASM_CLAC "\n" \
15685 ".section .fixup,\"ax\"\n" \
15686 "3: mov %3,%0\n" \
15687 @@ -353,7 +392,7 @@ do { \
15688 " jmp 2b\n" \
15689 ".previous\n" \
15690 _ASM_EXTABLE(1b, 3b) \
15691 - : "=r" (err), ltype(x) \
15692 + : "=r" (err), ltype (x) \
15693 : "m" (__m(addr)), "i" (errret), "0" (err))
15694
15695 #define __get_user_size_ex(x, ptr, size) \
15696 @@ -378,7 +417,7 @@ do { \
15697 } while (0)
15698
15699 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
15700 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
15701 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
15702 "2:\n" \
15703 _ASM_EXTABLE_EX(1b, 2b) \
15704 : ltype(x) : "m" (__m(addr)))
15705 @@ -395,13 +434,24 @@ do { \
15706 int __gu_err; \
15707 unsigned long __gu_val; \
15708 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
15709 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
15710 + (x) = (__typeof__(*(ptr)))__gu_val; \
15711 __gu_err; \
15712 })
15713
15714 /* FIXME: this hack is definitely wrong -AK */
15715 struct __large_struct { unsigned long buf[100]; };
15716 -#define __m(x) (*(struct __large_struct __user *)(x))
15717 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15718 +#define ____m(x) \
15719 +({ \
15720 + unsigned long ____x = (unsigned long)(x); \
15721 + if (____x < pax_user_shadow_base) \
15722 + ____x += pax_user_shadow_base; \
15723 + (typeof(x))____x; \
15724 +})
15725 +#else
15726 +#define ____m(x) (x)
15727 +#endif
15728 +#define __m(x) (*(struct __large_struct __user *)____m(x))
15729
15730 /*
15731 * Tell gcc we read from memory instead of writing: this is because
15732 @@ -410,7 +460,7 @@ struct __large_struct { unsigned long buf[100]; };
15733 */
15734 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15735 asm volatile(ASM_STAC "\n" \
15736 - "1: mov"itype" %"rtype"1,%2\n" \
15737 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
15738 "2: " ASM_CLAC "\n" \
15739 ".section .fixup,\"ax\"\n" \
15740 "3: mov %3,%0\n" \
15741 @@ -418,10 +468,10 @@ struct __large_struct { unsigned long buf[100]; };
15742 ".previous\n" \
15743 _ASM_EXTABLE(1b, 3b) \
15744 : "=r"(err) \
15745 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
15746 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
15747
15748 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
15749 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
15750 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
15751 "2:\n" \
15752 _ASM_EXTABLE_EX(1b, 2b) \
15753 : : ltype(x), "m" (__m(addr)))
15754 @@ -460,8 +510,12 @@ struct __large_struct { unsigned long buf[100]; };
15755 * On error, the variable @x is set to zero.
15756 */
15757
15758 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15759 +#define __get_user(x, ptr) get_user((x), (ptr))
15760 +#else
15761 #define __get_user(x, ptr) \
15762 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
15763 +#endif
15764
15765 /**
15766 * __put_user: - Write a simple value into user space, with less checking.
15767 @@ -483,8 +537,12 @@ struct __large_struct { unsigned long buf[100]; };
15768 * Returns zero on success, or -EFAULT on error.
15769 */
15770
15771 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15772 +#define __put_user(x, ptr) put_user((x), (ptr))
15773 +#else
15774 #define __put_user(x, ptr) \
15775 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
15776 +#endif
15777
15778 #define __get_user_unaligned __get_user
15779 #define __put_user_unaligned __put_user
15780 @@ -502,7 +560,7 @@ struct __large_struct { unsigned long buf[100]; };
15781 #define get_user_ex(x, ptr) do { \
15782 unsigned long __gue_val; \
15783 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
15784 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
15785 + (x) = (__typeof__(*(ptr)))__gue_val; \
15786 } while (0)
15787
15788 #define put_user_try uaccess_try
15789 @@ -519,8 +577,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
15790 extern __must_check long strlen_user(const char __user *str);
15791 extern __must_check long strnlen_user(const char __user *str, long n);
15792
15793 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
15794 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
15795 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15796 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15797
15798 /*
15799 * movsl can be slow when source and dest are not both 8-byte aligned
15800 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
15801 index 7f760a9..04b1c65 100644
15802 --- a/arch/x86/include/asm/uaccess_32.h
15803 +++ b/arch/x86/include/asm/uaccess_32.h
15804 @@ -11,15 +11,15 @@
15805 #include <asm/page.h>
15806
15807 unsigned long __must_check __copy_to_user_ll
15808 - (void __user *to, const void *from, unsigned long n);
15809 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
15810 unsigned long __must_check __copy_from_user_ll
15811 - (void *to, const void __user *from, unsigned long n);
15812 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15813 unsigned long __must_check __copy_from_user_ll_nozero
15814 - (void *to, const void __user *from, unsigned long n);
15815 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15816 unsigned long __must_check __copy_from_user_ll_nocache
15817 - (void *to, const void __user *from, unsigned long n);
15818 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15819 unsigned long __must_check __copy_from_user_ll_nocache_nozero
15820 - (void *to, const void __user *from, unsigned long n);
15821 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15822
15823 /**
15824 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
15825 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
15826 static __always_inline unsigned long __must_check
15827 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
15828 {
15829 + if ((long)n < 0)
15830 + return n;
15831 +
15832 + check_object_size(from, n, true);
15833 +
15834 if (__builtin_constant_p(n)) {
15835 unsigned long ret;
15836
15837 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
15838 __copy_to_user(void __user *to, const void *from, unsigned long n)
15839 {
15840 might_fault();
15841 +
15842 return __copy_to_user_inatomic(to, from, n);
15843 }
15844
15845 static __always_inline unsigned long
15846 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
15847 {
15848 + if ((long)n < 0)
15849 + return n;
15850 +
15851 /* Avoid zeroing the tail if the copy fails..
15852 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
15853 * but as the zeroing behaviour is only significant when n is not
15854 @@ -137,6 +146,12 @@ static __always_inline unsigned long
15855 __copy_from_user(void *to, const void __user *from, unsigned long n)
15856 {
15857 might_fault();
15858 +
15859 + if ((long)n < 0)
15860 + return n;
15861 +
15862 + check_object_size(to, n, false);
15863 +
15864 if (__builtin_constant_p(n)) {
15865 unsigned long ret;
15866
15867 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
15868 const void __user *from, unsigned long n)
15869 {
15870 might_fault();
15871 +
15872 + if ((long)n < 0)
15873 + return n;
15874 +
15875 if (__builtin_constant_p(n)) {
15876 unsigned long ret;
15877
15878 @@ -181,15 +200,19 @@ static __always_inline unsigned long
15879 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
15880 unsigned long n)
15881 {
15882 - return __copy_from_user_ll_nocache_nozero(to, from, n);
15883 + if ((long)n < 0)
15884 + return n;
15885 +
15886 + return __copy_from_user_ll_nocache_nozero(to, from, n);
15887 }
15888
15889 -unsigned long __must_check copy_to_user(void __user *to,
15890 - const void *from, unsigned long n);
15891 -unsigned long __must_check _copy_from_user(void *to,
15892 - const void __user *from,
15893 - unsigned long n);
15894 -
15895 +extern void copy_to_user_overflow(void)
15896 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15897 + __compiletime_error("copy_to_user() buffer size is not provably correct")
15898 +#else
15899 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
15900 +#endif
15901 +;
15902
15903 extern void copy_from_user_overflow(void)
15904 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15905 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
15906 #endif
15907 ;
15908
15909 -static inline unsigned long __must_check copy_from_user(void *to,
15910 - const void __user *from,
15911 - unsigned long n)
15912 +/**
15913 + * copy_to_user: - Copy a block of data into user space.
15914 + * @to: Destination address, in user space.
15915 + * @from: Source address, in kernel space.
15916 + * @n: Number of bytes to copy.
15917 + *
15918 + * Context: User context only. This function may sleep.
15919 + *
15920 + * Copy data from kernel space to user space.
15921 + *
15922 + * Returns number of bytes that could not be copied.
15923 + * On success, this will be zero.
15924 + */
15925 +static inline unsigned long __must_check
15926 +copy_to_user(void __user *to, const void *from, unsigned long n)
15927 {
15928 - int sz = __compiletime_object_size(to);
15929 + size_t sz = __compiletime_object_size(from);
15930
15931 - if (likely(sz == -1 || sz >= n))
15932 - n = _copy_from_user(to, from, n);
15933 - else
15934 + if (unlikely(sz != (size_t)-1 && sz < n))
15935 + copy_to_user_overflow();
15936 + else if (access_ok(VERIFY_WRITE, to, n))
15937 + n = __copy_to_user(to, from, n);
15938 + return n;
15939 +}
15940 +
15941 +/**
15942 + * copy_from_user: - Copy a block of data from user space.
15943 + * @to: Destination address, in kernel space.
15944 + * @from: Source address, in user space.
15945 + * @n: Number of bytes to copy.
15946 + *
15947 + * Context: User context only. This function may sleep.
15948 + *
15949 + * Copy data from user space to kernel space.
15950 + *
15951 + * Returns number of bytes that could not be copied.
15952 + * On success, this will be zero.
15953 + *
15954 + * If some data could not be copied, this function will pad the copied
15955 + * data to the requested size using zero bytes.
15956 + */
15957 +static inline unsigned long __must_check
15958 +copy_from_user(void *to, const void __user *from, unsigned long n)
15959 +{
15960 + size_t sz = __compiletime_object_size(to);
15961 +
15962 + check_object_size(to, n, false);
15963 +
15964 + if (unlikely(sz != (size_t)-1 && sz < n))
15965 copy_from_user_overflow();
15966 -
15967 + else if (access_ok(VERIFY_READ, from, n))
15968 + n = __copy_from_user(to, from, n);
15969 + else if ((long)n > 0)
15970 + memset(to, 0, n);
15971 return n;
15972 }
15973
15974 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
15975 index 142810c..1f2a0a7 100644
15976 --- a/arch/x86/include/asm/uaccess_64.h
15977 +++ b/arch/x86/include/asm/uaccess_64.h
15978 @@ -10,6 +10,9 @@
15979 #include <asm/alternative.h>
15980 #include <asm/cpufeature.h>
15981 #include <asm/page.h>
15982 +#include <asm/pgtable.h>
15983 +
15984 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
15985
15986 /*
15987 * Copy To/From Userspace
15988 @@ -17,13 +20,13 @@
15989
15990 /* Handles exceptions in both to and from, but doesn't do access_ok */
15991 __must_check unsigned long
15992 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
15993 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
15994 __must_check unsigned long
15995 -copy_user_generic_string(void *to, const void *from, unsigned len);
15996 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
15997 __must_check unsigned long
15998 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
15999 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
16000
16001 -static __always_inline __must_check unsigned long
16002 +static __always_inline __must_check __size_overflow(3) unsigned long
16003 copy_user_generic(void *to, const void *from, unsigned len)
16004 {
16005 unsigned ret;
16006 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
16007 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
16008 "=d" (len)),
16009 "1" (to), "2" (from), "3" (len)
16010 - : "memory", "rcx", "r8", "r9", "r10", "r11");
16011 + : "memory", "rcx", "r8", "r9", "r11");
16012 return ret;
16013 }
16014
16015 +static __always_inline __must_check unsigned long
16016 +__copy_to_user(void __user *to, const void *from, unsigned long len);
16017 +static __always_inline __must_check unsigned long
16018 +__copy_from_user(void *to, const void __user *from, unsigned long len);
16019 __must_check unsigned long
16020 -_copy_to_user(void __user *to, const void *from, unsigned len);
16021 -__must_check unsigned long
16022 -_copy_from_user(void *to, const void __user *from, unsigned len);
16023 -__must_check unsigned long
16024 -copy_in_user(void __user *to, const void __user *from, unsigned len);
16025 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
16026 +
16027 +extern void copy_to_user_overflow(void)
16028 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16029 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16030 +#else
16031 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16032 +#endif
16033 +;
16034 +
16035 +extern void copy_from_user_overflow(void)
16036 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16037 + __compiletime_error("copy_from_user() buffer size is not provably correct")
16038 +#else
16039 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
16040 +#endif
16041 +;
16042
16043 static inline unsigned long __must_check copy_from_user(void *to,
16044 const void __user *from,
16045 unsigned long n)
16046 {
16047 - int sz = __compiletime_object_size(to);
16048 -
16049 might_fault();
16050 - if (likely(sz == -1 || sz >= n))
16051 - n = _copy_from_user(to, from, n);
16052 -#ifdef CONFIG_DEBUG_VM
16053 - else
16054 - WARN(1, "Buffer overflow detected!\n");
16055 -#endif
16056 +
16057 + check_object_size(to, n, false);
16058 +
16059 + if (access_ok(VERIFY_READ, from, n))
16060 + n = __copy_from_user(to, from, n);
16061 + else if (n < INT_MAX)
16062 + memset(to, 0, n);
16063 return n;
16064 }
16065
16066 static __always_inline __must_check
16067 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16068 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16069 {
16070 might_fault();
16071
16072 - return _copy_to_user(dst, src, size);
16073 + if (access_ok(VERIFY_WRITE, dst, size))
16074 + size = __copy_to_user(dst, src, size);
16075 + return size;
16076 }
16077
16078 static __always_inline __must_check
16079 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16080 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16081 {
16082 - int ret = 0;
16083 + size_t sz = __compiletime_object_size(dst);
16084 + unsigned ret = 0;
16085
16086 might_fault();
16087 +
16088 + if (size > INT_MAX)
16089 + return size;
16090 +
16091 + check_object_size(dst, size, false);
16092 +
16093 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16094 + if (!__access_ok(VERIFY_READ, src, size))
16095 + return size;
16096 +#endif
16097 +
16098 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16099 + copy_from_user_overflow();
16100 + return size;
16101 + }
16102 +
16103 if (!__builtin_constant_p(size))
16104 - return copy_user_generic(dst, (__force void *)src, size);
16105 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16106 switch (size) {
16107 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16108 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16109 ret, "b", "b", "=q", 1);
16110 return ret;
16111 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16112 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16113 ret, "w", "w", "=r", 2);
16114 return ret;
16115 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16116 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16117 ret, "l", "k", "=r", 4);
16118 return ret;
16119 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16120 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16121 ret, "q", "", "=r", 8);
16122 return ret;
16123 case 10:
16124 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16125 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16126 ret, "q", "", "=r", 10);
16127 if (unlikely(ret))
16128 return ret;
16129 __get_user_asm(*(u16 *)(8 + (char *)dst),
16130 - (u16 __user *)(8 + (char __user *)src),
16131 + (const u16 __user *)(8 + (const char __user *)src),
16132 ret, "w", "w", "=r", 2);
16133 return ret;
16134 case 16:
16135 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16136 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16137 ret, "q", "", "=r", 16);
16138 if (unlikely(ret))
16139 return ret;
16140 __get_user_asm(*(u64 *)(8 + (char *)dst),
16141 - (u64 __user *)(8 + (char __user *)src),
16142 + (const u64 __user *)(8 + (const char __user *)src),
16143 ret, "q", "", "=r", 8);
16144 return ret;
16145 default:
16146 - return copy_user_generic(dst, (__force void *)src, size);
16147 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16148 }
16149 }
16150
16151 static __always_inline __must_check
16152 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16153 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16154 {
16155 - int ret = 0;
16156 + size_t sz = __compiletime_object_size(src);
16157 + unsigned ret = 0;
16158
16159 might_fault();
16160 +
16161 + if (size > INT_MAX)
16162 + return size;
16163 +
16164 + check_object_size(src, size, true);
16165 +
16166 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16167 + if (!__access_ok(VERIFY_WRITE, dst, size))
16168 + return size;
16169 +#endif
16170 +
16171 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16172 + copy_to_user_overflow();
16173 + return size;
16174 + }
16175 +
16176 if (!__builtin_constant_p(size))
16177 - return copy_user_generic((__force void *)dst, src, size);
16178 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16179 switch (size) {
16180 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16181 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16182 ret, "b", "b", "iq", 1);
16183 return ret;
16184 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16185 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16186 ret, "w", "w", "ir", 2);
16187 return ret;
16188 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16189 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16190 ret, "l", "k", "ir", 4);
16191 return ret;
16192 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16193 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16194 ret, "q", "", "er", 8);
16195 return ret;
16196 case 10:
16197 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16198 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16199 ret, "q", "", "er", 10);
16200 if (unlikely(ret))
16201 return ret;
16202 asm("":::"memory");
16203 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16204 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16205 ret, "w", "w", "ir", 2);
16206 return ret;
16207 case 16:
16208 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16209 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16210 ret, "q", "", "er", 16);
16211 if (unlikely(ret))
16212 return ret;
16213 asm("":::"memory");
16214 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16215 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16216 ret, "q", "", "er", 8);
16217 return ret;
16218 default:
16219 - return copy_user_generic((__force void *)dst, src, size);
16220 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16221 }
16222 }
16223
16224 static __always_inline __must_check
16225 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16226 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16227 {
16228 - int ret = 0;
16229 + unsigned ret = 0;
16230
16231 might_fault();
16232 +
16233 + if (size > INT_MAX)
16234 + return size;
16235 +
16236 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16237 + if (!__access_ok(VERIFY_READ, src, size))
16238 + return size;
16239 + if (!__access_ok(VERIFY_WRITE, dst, size))
16240 + return size;
16241 +#endif
16242 +
16243 if (!__builtin_constant_p(size))
16244 - return copy_user_generic((__force void *)dst,
16245 - (__force void *)src, size);
16246 + return copy_user_generic((__force_kernel void *)____m(dst),
16247 + (__force_kernel const void *)____m(src), size);
16248 switch (size) {
16249 case 1: {
16250 u8 tmp;
16251 - __get_user_asm(tmp, (u8 __user *)src,
16252 + __get_user_asm(tmp, (const u8 __user *)src,
16253 ret, "b", "b", "=q", 1);
16254 if (likely(!ret))
16255 __put_user_asm(tmp, (u8 __user *)dst,
16256 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16257 }
16258 case 2: {
16259 u16 tmp;
16260 - __get_user_asm(tmp, (u16 __user *)src,
16261 + __get_user_asm(tmp, (const u16 __user *)src,
16262 ret, "w", "w", "=r", 2);
16263 if (likely(!ret))
16264 __put_user_asm(tmp, (u16 __user *)dst,
16265 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16266
16267 case 4: {
16268 u32 tmp;
16269 - __get_user_asm(tmp, (u32 __user *)src,
16270 + __get_user_asm(tmp, (const u32 __user *)src,
16271 ret, "l", "k", "=r", 4);
16272 if (likely(!ret))
16273 __put_user_asm(tmp, (u32 __user *)dst,
16274 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16275 }
16276 case 8: {
16277 u64 tmp;
16278 - __get_user_asm(tmp, (u64 __user *)src,
16279 + __get_user_asm(tmp, (const u64 __user *)src,
16280 ret, "q", "", "=r", 8);
16281 if (likely(!ret))
16282 __put_user_asm(tmp, (u64 __user *)dst,
16283 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16284 return ret;
16285 }
16286 default:
16287 - return copy_user_generic((__force void *)dst,
16288 - (__force void *)src, size);
16289 + return copy_user_generic((__force_kernel void *)____m(dst),
16290 + (__force_kernel const void *)____m(src), size);
16291 }
16292 }
16293
16294 static __must_check __always_inline int
16295 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16296 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16297 {
16298 - return copy_user_generic(dst, (__force const void *)src, size);
16299 + if (size > INT_MAX)
16300 + return size;
16301 +
16302 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16303 + if (!__access_ok(VERIFY_READ, src, size))
16304 + return size;
16305 +#endif
16306 +
16307 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16308 }
16309
16310 -static __must_check __always_inline int
16311 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16312 +static __must_check __always_inline unsigned long
16313 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16314 {
16315 - return copy_user_generic((__force void *)dst, src, size);
16316 + if (size > INT_MAX)
16317 + return size;
16318 +
16319 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16320 + if (!__access_ok(VERIFY_WRITE, dst, size))
16321 + return size;
16322 +#endif
16323 +
16324 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16325 }
16326
16327 -extern long __copy_user_nocache(void *dst, const void __user *src,
16328 - unsigned size, int zerorest);
16329 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16330 + unsigned long size, int zerorest) __size_overflow(3);
16331
16332 -static inline int
16333 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16334 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16335 {
16336 might_sleep();
16337 +
16338 + if (size > INT_MAX)
16339 + return size;
16340 +
16341 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16342 + if (!__access_ok(VERIFY_READ, src, size))
16343 + return size;
16344 +#endif
16345 +
16346 return __copy_user_nocache(dst, src, size, 1);
16347 }
16348
16349 -static inline int
16350 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16351 - unsigned size)
16352 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16353 + unsigned long size)
16354 {
16355 + if (size > INT_MAX)
16356 + return size;
16357 +
16358 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16359 + if (!__access_ok(VERIFY_READ, src, size))
16360 + return size;
16361 +#endif
16362 +
16363 return __copy_user_nocache(dst, src, size, 0);
16364 }
16365
16366 -unsigned long
16367 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16368 +extern unsigned long
16369 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16370
16371 #endif /* _ASM_X86_UACCESS_64_H */
16372 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16373 index 5b238981..77fdd78 100644
16374 --- a/arch/x86/include/asm/word-at-a-time.h
16375 +++ b/arch/x86/include/asm/word-at-a-time.h
16376 @@ -11,7 +11,7 @@
16377 * and shift, for example.
16378 */
16379 struct word_at_a_time {
16380 - const unsigned long one_bits, high_bits;
16381 + unsigned long one_bits, high_bits;
16382 };
16383
16384 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16385 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16386 index d8d9922..bf6cecb 100644
16387 --- a/arch/x86/include/asm/x86_init.h
16388 +++ b/arch/x86/include/asm/x86_init.h
16389 @@ -129,7 +129,7 @@ struct x86_init_ops {
16390 struct x86_init_timers timers;
16391 struct x86_init_iommu iommu;
16392 struct x86_init_pci pci;
16393 -};
16394 +} __no_const;
16395
16396 /**
16397 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16398 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
16399 void (*setup_percpu_clockev)(void);
16400 void (*early_percpu_clock_init)(void);
16401 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16402 -};
16403 +} __no_const;
16404
16405 /**
16406 * struct x86_platform_ops - platform specific runtime functions
16407 @@ -166,7 +166,7 @@ struct x86_platform_ops {
16408 void (*save_sched_clock_state)(void);
16409 void (*restore_sched_clock_state)(void);
16410 void (*apic_post_init)(void);
16411 -};
16412 +} __no_const;
16413
16414 struct pci_dev;
16415 struct msi_msg;
16416 @@ -180,7 +180,7 @@ struct x86_msi_ops {
16417 void (*teardown_msi_irqs)(struct pci_dev *dev);
16418 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16419 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
16420 -};
16421 +} __no_const;
16422
16423 struct IO_APIC_route_entry;
16424 struct io_apic_irq_attr;
16425 @@ -201,7 +201,7 @@ struct x86_io_apic_ops {
16426 unsigned int destination, int vector,
16427 struct io_apic_irq_attr *attr);
16428 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
16429 -};
16430 +} __no_const;
16431
16432 extern struct x86_init_ops x86_init;
16433 extern struct x86_cpuinit_ops x86_cpuinit;
16434 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16435 index 0415cda..b43d877 100644
16436 --- a/arch/x86/include/asm/xsave.h
16437 +++ b/arch/x86/include/asm/xsave.h
16438 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16439 return -EFAULT;
16440
16441 __asm__ __volatile__(ASM_STAC "\n"
16442 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16443 + "1:"
16444 + __copyuser_seg
16445 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16446 "2: " ASM_CLAC "\n"
16447 ".section .fixup,\"ax\"\n"
16448 "3: movl $-1,%[err]\n"
16449 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16450 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16451 {
16452 int err;
16453 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16454 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16455 u32 lmask = mask;
16456 u32 hmask = mask >> 32;
16457
16458 __asm__ __volatile__(ASM_STAC "\n"
16459 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16460 + "1:"
16461 + __copyuser_seg
16462 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16463 "2: " ASM_CLAC "\n"
16464 ".section .fixup,\"ax\"\n"
16465 "3: movl $-1,%[err]\n"
16466 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16467 index bbae024..e1528f9 100644
16468 --- a/arch/x86/include/uapi/asm/e820.h
16469 +++ b/arch/x86/include/uapi/asm/e820.h
16470 @@ -63,7 +63,7 @@ struct e820map {
16471 #define ISA_START_ADDRESS 0xa0000
16472 #define ISA_END_ADDRESS 0x100000
16473
16474 -#define BIOS_BEGIN 0x000a0000
16475 +#define BIOS_BEGIN 0x000c0000
16476 #define BIOS_END 0x00100000
16477
16478 #define BIOS_ROM_BASE 0xffe00000
16479 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16480 index 7bd3bd3..5dac791 100644
16481 --- a/arch/x86/kernel/Makefile
16482 +++ b/arch/x86/kernel/Makefile
16483 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16484 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16485 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16486 obj-y += probe_roms.o
16487 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16488 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16489 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16490 obj-y += syscall_$(BITS).o
16491 obj-$(CONFIG_X86_64) += vsyscall_64.o
16492 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16493 index 230c8ea..f915130 100644
16494 --- a/arch/x86/kernel/acpi/boot.c
16495 +++ b/arch/x86/kernel/acpi/boot.c
16496 @@ -1361,7 +1361,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16497 * If your system is blacklisted here, but you find that acpi=force
16498 * works for you, please contact linux-acpi@vger.kernel.org
16499 */
16500 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16501 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16502 /*
16503 * Boxes that need ACPI disabled
16504 */
16505 @@ -1436,7 +1436,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16506 };
16507
16508 /* second table for DMI checks that should run after early-quirks */
16509 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16510 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16511 /*
16512 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16513 * which includes some code which overrides all temperature
16514 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16515 index 0532f5d..36afc0a 100644
16516 --- a/arch/x86/kernel/acpi/sleep.c
16517 +++ b/arch/x86/kernel/acpi/sleep.c
16518 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16519 #else /* CONFIG_64BIT */
16520 #ifdef CONFIG_SMP
16521 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16522 +
16523 + pax_open_kernel();
16524 early_gdt_descr.address =
16525 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16526 + pax_close_kernel();
16527 +
16528 initial_gs = per_cpu_offset(smp_processor_id());
16529 #endif
16530 initial_code = (unsigned long)wakeup_long64;
16531 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16532 index 13ab720..95d5442 100644
16533 --- a/arch/x86/kernel/acpi/wakeup_32.S
16534 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16535 @@ -30,13 +30,11 @@ wakeup_pmode_return:
16536 # and restore the stack ... but you need gdt for this to work
16537 movl saved_context_esp, %esp
16538
16539 - movl %cs:saved_magic, %eax
16540 - cmpl $0x12345678, %eax
16541 + cmpl $0x12345678, saved_magic
16542 jne bogus_magic
16543
16544 # jump to place where we left off
16545 - movl saved_eip, %eax
16546 - jmp *%eax
16547 + jmp *(saved_eip)
16548
16549 bogus_magic:
16550 jmp bogus_magic
16551 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16552 index ef5ccca..bd83949 100644
16553 --- a/arch/x86/kernel/alternative.c
16554 +++ b/arch/x86/kernel/alternative.c
16555 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16556 */
16557 for (a = start; a < end; a++) {
16558 instr = (u8 *)&a->instr_offset + a->instr_offset;
16559 +
16560 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16561 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16562 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16563 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16564 +#endif
16565 +
16566 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16567 BUG_ON(a->replacementlen > a->instrlen);
16568 BUG_ON(a->instrlen > sizeof(insnbuf));
16569 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16570 for (poff = start; poff < end; poff++) {
16571 u8 *ptr = (u8 *)poff + *poff;
16572
16573 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16574 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16575 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16576 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16577 +#endif
16578 +
16579 if (!*poff || ptr < text || ptr >= text_end)
16580 continue;
16581 /* turn DS segment override prefix into lock prefix */
16582 - if (*ptr == 0x3e)
16583 + if (*ktla_ktva(ptr) == 0x3e)
16584 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16585 }
16586 mutex_unlock(&text_mutex);
16587 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16588 for (poff = start; poff < end; poff++) {
16589 u8 *ptr = (u8 *)poff + *poff;
16590
16591 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16592 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16593 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16594 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16595 +#endif
16596 +
16597 if (!*poff || ptr < text || ptr >= text_end)
16598 continue;
16599 /* turn lock prefix into DS segment override prefix */
16600 - if (*ptr == 0xf0)
16601 + if (*ktla_ktva(ptr) == 0xf0)
16602 text_poke(ptr, ((unsigned char []){0x3E}), 1);
16603 }
16604 mutex_unlock(&text_mutex);
16605 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
16606
16607 BUG_ON(p->len > MAX_PATCH_LEN);
16608 /* prep the buffer with the original instructions */
16609 - memcpy(insnbuf, p->instr, p->len);
16610 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
16611 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
16612 (unsigned long)p->instr, p->len);
16613
16614 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
16615 if (!uniproc_patched || num_possible_cpus() == 1)
16616 free_init_pages("SMP alternatives",
16617 (unsigned long)__smp_locks,
16618 - (unsigned long)__smp_locks_end);
16619 + PAGE_ALIGN((unsigned long)__smp_locks_end));
16620 #endif
16621
16622 apply_paravirt(__parainstructions, __parainstructions_end);
16623 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
16624 * instructions. And on the local CPU you need to be protected again NMI or MCE
16625 * handlers seeing an inconsistent instruction while you patch.
16626 */
16627 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
16628 +void *__kprobes text_poke_early(void *addr, const void *opcode,
16629 size_t len)
16630 {
16631 unsigned long flags;
16632 local_irq_save(flags);
16633 - memcpy(addr, opcode, len);
16634 +
16635 + pax_open_kernel();
16636 + memcpy(ktla_ktva(addr), opcode, len);
16637 sync_core();
16638 + pax_close_kernel();
16639 +
16640 local_irq_restore(flags);
16641 /* Could also do a CLFLUSH here to speed up CPU recovery; but
16642 that causes hangs on some VIA CPUs. */
16643 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
16644 */
16645 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
16646 {
16647 - unsigned long flags;
16648 - char *vaddr;
16649 + unsigned char *vaddr = ktla_ktva(addr);
16650 struct page *pages[2];
16651 - int i;
16652 + size_t i;
16653
16654 if (!core_kernel_text((unsigned long)addr)) {
16655 - pages[0] = vmalloc_to_page(addr);
16656 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
16657 + pages[0] = vmalloc_to_page(vaddr);
16658 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
16659 } else {
16660 - pages[0] = virt_to_page(addr);
16661 + pages[0] = virt_to_page(vaddr);
16662 WARN_ON(!PageReserved(pages[0]));
16663 - pages[1] = virt_to_page(addr + PAGE_SIZE);
16664 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
16665 }
16666 BUG_ON(!pages[0]);
16667 - local_irq_save(flags);
16668 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
16669 - if (pages[1])
16670 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
16671 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
16672 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
16673 - clear_fixmap(FIX_TEXT_POKE0);
16674 - if (pages[1])
16675 - clear_fixmap(FIX_TEXT_POKE1);
16676 - local_flush_tlb();
16677 - sync_core();
16678 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
16679 - that causes hangs on some VIA CPUs. */
16680 + text_poke_early(addr, opcode, len);
16681 for (i = 0; i < len; i++)
16682 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
16683 - local_irq_restore(flags);
16684 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
16685 return addr;
16686 }
16687
16688 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
16689 index 904611b..004dde6 100644
16690 --- a/arch/x86/kernel/apic/apic.c
16691 +++ b/arch/x86/kernel/apic/apic.c
16692 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
16693 /*
16694 * Debug level, exported for io_apic.c
16695 */
16696 -unsigned int apic_verbosity;
16697 +int apic_verbosity;
16698
16699 int pic_mode;
16700
16701 @@ -1955,7 +1955,7 @@ void smp_error_interrupt(struct pt_regs *regs)
16702 apic_write(APIC_ESR, 0);
16703 v1 = apic_read(APIC_ESR);
16704 ack_APIC_irq();
16705 - atomic_inc(&irq_err_count);
16706 + atomic_inc_unchecked(&irq_err_count);
16707
16708 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
16709 smp_processor_id(), v0 , v1);
16710 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
16711 index 00c77cf..2dc6a2d 100644
16712 --- a/arch/x86/kernel/apic/apic_flat_64.c
16713 +++ b/arch/x86/kernel/apic/apic_flat_64.c
16714 @@ -157,7 +157,7 @@ static int flat_probe(void)
16715 return 1;
16716 }
16717
16718 -static struct apic apic_flat = {
16719 +static struct apic apic_flat __read_only = {
16720 .name = "flat",
16721 .probe = flat_probe,
16722 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
16723 @@ -271,7 +271,7 @@ static int physflat_probe(void)
16724 return 0;
16725 }
16726
16727 -static struct apic apic_physflat = {
16728 +static struct apic apic_physflat __read_only = {
16729
16730 .name = "physical flat",
16731 .probe = physflat_probe,
16732 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
16733 index e145f28..2752888 100644
16734 --- a/arch/x86/kernel/apic/apic_noop.c
16735 +++ b/arch/x86/kernel/apic/apic_noop.c
16736 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
16737 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
16738 }
16739
16740 -struct apic apic_noop = {
16741 +struct apic apic_noop __read_only = {
16742 .name = "noop",
16743 .probe = noop_probe,
16744 .acpi_madt_oem_check = NULL,
16745 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
16746 index d50e364..543bee3 100644
16747 --- a/arch/x86/kernel/apic/bigsmp_32.c
16748 +++ b/arch/x86/kernel/apic/bigsmp_32.c
16749 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
16750 return dmi_bigsmp;
16751 }
16752
16753 -static struct apic apic_bigsmp = {
16754 +static struct apic apic_bigsmp __read_only = {
16755
16756 .name = "bigsmp",
16757 .probe = probe_bigsmp,
16758 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
16759 index 0874799..a7a7892 100644
16760 --- a/arch/x86/kernel/apic/es7000_32.c
16761 +++ b/arch/x86/kernel/apic/es7000_32.c
16762 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
16763 return ret && es7000_apic_is_cluster();
16764 }
16765
16766 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
16767 -static struct apic __refdata apic_es7000_cluster = {
16768 +static struct apic apic_es7000_cluster __read_only = {
16769
16770 .name = "es7000",
16771 .probe = probe_es7000,
16772 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
16773 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
16774 };
16775
16776 -static struct apic __refdata apic_es7000 = {
16777 +static struct apic apic_es7000 __read_only = {
16778
16779 .name = "es7000",
16780 .probe = probe_es7000,
16781 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
16782 index 9ed796c..e930fe4 100644
16783 --- a/arch/x86/kernel/apic/io_apic.c
16784 +++ b/arch/x86/kernel/apic/io_apic.c
16785 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
16786 }
16787 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
16788
16789 -void lock_vector_lock(void)
16790 +void lock_vector_lock(void) __acquires(vector_lock)
16791 {
16792 /* Used to the online set of cpus does not change
16793 * during assign_irq_vector.
16794 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
16795 raw_spin_lock(&vector_lock);
16796 }
16797
16798 -void unlock_vector_lock(void)
16799 +void unlock_vector_lock(void) __releases(vector_lock)
16800 {
16801 raw_spin_unlock(&vector_lock);
16802 }
16803 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
16804 ack_APIC_irq();
16805 }
16806
16807 -atomic_t irq_mis_count;
16808 +atomic_unchecked_t irq_mis_count;
16809
16810 #ifdef CONFIG_GENERIC_PENDING_IRQ
16811 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
16812 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
16813 * at the cpu.
16814 */
16815 if (!(v & (1 << (i & 0x1f)))) {
16816 - atomic_inc(&irq_mis_count);
16817 + atomic_inc_unchecked(&irq_mis_count);
16818
16819 eoi_ioapic_irq(irq, cfg);
16820 }
16821 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
16822 index d661ee9..791fd33 100644
16823 --- a/arch/x86/kernel/apic/numaq_32.c
16824 +++ b/arch/x86/kernel/apic/numaq_32.c
16825 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
16826 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
16827 }
16828
16829 -/* Use __refdata to keep false positive warning calm. */
16830 -static struct apic __refdata apic_numaq = {
16831 +static struct apic apic_numaq __read_only = {
16832
16833 .name = "NUMAQ",
16834 .probe = probe_numaq,
16835 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
16836 index eb35ef9..f184a21 100644
16837 --- a/arch/x86/kernel/apic/probe_32.c
16838 +++ b/arch/x86/kernel/apic/probe_32.c
16839 @@ -72,7 +72,7 @@ static int probe_default(void)
16840 return 1;
16841 }
16842
16843 -static struct apic apic_default = {
16844 +static struct apic apic_default __read_only = {
16845
16846 .name = "default",
16847 .probe = probe_default,
16848 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
16849 index 77c95c0..434f8a4 100644
16850 --- a/arch/x86/kernel/apic/summit_32.c
16851 +++ b/arch/x86/kernel/apic/summit_32.c
16852 @@ -486,7 +486,7 @@ void setup_summit(void)
16853 }
16854 #endif
16855
16856 -static struct apic apic_summit = {
16857 +static struct apic apic_summit __read_only = {
16858
16859 .name = "summit",
16860 .probe = probe_summit,
16861 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
16862 index c88baa4..757aee1 100644
16863 --- a/arch/x86/kernel/apic/x2apic_cluster.c
16864 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
16865 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
16866 return notifier_from_errno(err);
16867 }
16868
16869 -static struct notifier_block __refdata x2apic_cpu_notifier = {
16870 +static struct notifier_block x2apic_cpu_notifier = {
16871 .notifier_call = update_clusterinfo,
16872 };
16873
16874 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
16875 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
16876 }
16877
16878 -static struct apic apic_x2apic_cluster = {
16879 +static struct apic apic_x2apic_cluster __read_only = {
16880
16881 .name = "cluster x2apic",
16882 .probe = x2apic_cluster_probe,
16883 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
16884 index 562a76d..a003c0f 100644
16885 --- a/arch/x86/kernel/apic/x2apic_phys.c
16886 +++ b/arch/x86/kernel/apic/x2apic_phys.c
16887 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
16888 return apic == &apic_x2apic_phys;
16889 }
16890
16891 -static struct apic apic_x2apic_phys = {
16892 +static struct apic apic_x2apic_phys __read_only = {
16893
16894 .name = "physical x2apic",
16895 .probe = x2apic_phys_probe,
16896 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
16897 index 794f6eb..67e1db2 100644
16898 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
16899 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
16900 @@ -342,7 +342,7 @@ static int uv_probe(void)
16901 return apic == &apic_x2apic_uv_x;
16902 }
16903
16904 -static struct apic __refdata apic_x2apic_uv_x = {
16905 +static struct apic apic_x2apic_uv_x __read_only = {
16906
16907 .name = "UV large system",
16908 .probe = uv_probe,
16909 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
16910 index 66b5faf..3442423 100644
16911 --- a/arch/x86/kernel/apm_32.c
16912 +++ b/arch/x86/kernel/apm_32.c
16913 @@ -434,7 +434,7 @@ static DEFINE_MUTEX(apm_mutex);
16914 * This is for buggy BIOS's that refer to (real mode) segment 0x40
16915 * even though they are called in protected mode.
16916 */
16917 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
16918 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
16919 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
16920
16921 static const char driver_version[] = "1.16ac"; /* no spaces */
16922 @@ -612,7 +612,10 @@ static long __apm_bios_call(void *_call)
16923 BUG_ON(cpu != 0);
16924 gdt = get_cpu_gdt_table(cpu);
16925 save_desc_40 = gdt[0x40 / 8];
16926 +
16927 + pax_open_kernel();
16928 gdt[0x40 / 8] = bad_bios_desc;
16929 + pax_close_kernel();
16930
16931 apm_irq_save(flags);
16932 APM_DO_SAVE_SEGS;
16933 @@ -621,7 +624,11 @@ static long __apm_bios_call(void *_call)
16934 &call->esi);
16935 APM_DO_RESTORE_SEGS;
16936 apm_irq_restore(flags);
16937 +
16938 + pax_open_kernel();
16939 gdt[0x40 / 8] = save_desc_40;
16940 + pax_close_kernel();
16941 +
16942 put_cpu();
16943
16944 return call->eax & 0xff;
16945 @@ -688,7 +695,10 @@ static long __apm_bios_call_simple(void *_call)
16946 BUG_ON(cpu != 0);
16947 gdt = get_cpu_gdt_table(cpu);
16948 save_desc_40 = gdt[0x40 / 8];
16949 +
16950 + pax_open_kernel();
16951 gdt[0x40 / 8] = bad_bios_desc;
16952 + pax_close_kernel();
16953
16954 apm_irq_save(flags);
16955 APM_DO_SAVE_SEGS;
16956 @@ -696,7 +706,11 @@ static long __apm_bios_call_simple(void *_call)
16957 &call->eax);
16958 APM_DO_RESTORE_SEGS;
16959 apm_irq_restore(flags);
16960 +
16961 + pax_open_kernel();
16962 gdt[0x40 / 8] = save_desc_40;
16963 + pax_close_kernel();
16964 +
16965 put_cpu();
16966 return error;
16967 }
16968 @@ -2363,12 +2377,15 @@ static int __init apm_init(void)
16969 * code to that CPU.
16970 */
16971 gdt = get_cpu_gdt_table(0);
16972 +
16973 + pax_open_kernel();
16974 set_desc_base(&gdt[APM_CS >> 3],
16975 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
16976 set_desc_base(&gdt[APM_CS_16 >> 3],
16977 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
16978 set_desc_base(&gdt[APM_DS >> 3],
16979 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
16980 + pax_close_kernel();
16981
16982 proc_create("apm", 0, NULL, &apm_file_ops);
16983
16984 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
16985 index 2861082..6d4718e 100644
16986 --- a/arch/x86/kernel/asm-offsets.c
16987 +++ b/arch/x86/kernel/asm-offsets.c
16988 @@ -33,6 +33,8 @@ void common(void) {
16989 OFFSET(TI_status, thread_info, status);
16990 OFFSET(TI_addr_limit, thread_info, addr_limit);
16991 OFFSET(TI_preempt_count, thread_info, preempt_count);
16992 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
16993 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
16994
16995 BLANK();
16996 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
16997 @@ -53,8 +55,26 @@ void common(void) {
16998 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
16999 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
17000 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
17001 +
17002 +#ifdef CONFIG_PAX_KERNEXEC
17003 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
17004 #endif
17005
17006 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17007 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
17008 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
17009 +#ifdef CONFIG_X86_64
17010 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
17011 +#endif
17012 +#endif
17013 +
17014 +#endif
17015 +
17016 + BLANK();
17017 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
17018 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
17019 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
17020 +
17021 #ifdef CONFIG_XEN
17022 BLANK();
17023 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
17024 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
17025 index 1b4754f..fbb4227 100644
17026 --- a/arch/x86/kernel/asm-offsets_64.c
17027 +++ b/arch/x86/kernel/asm-offsets_64.c
17028 @@ -76,6 +76,7 @@ int main(void)
17029 BLANK();
17030 #undef ENTRY
17031
17032 + DEFINE(TSS_size, sizeof(struct tss_struct));
17033 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17034 BLANK();
17035
17036 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17037 index a0e067d..9c7db16 100644
17038 --- a/arch/x86/kernel/cpu/Makefile
17039 +++ b/arch/x86/kernel/cpu/Makefile
17040 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17041 CFLAGS_REMOVE_perf_event.o = -pg
17042 endif
17043
17044 -# Make sure load_percpu_segment has no stackprotector
17045 -nostackp := $(call cc-option, -fno-stack-protector)
17046 -CFLAGS_common.o := $(nostackp)
17047 -
17048 obj-y := intel_cacheinfo.o scattered.o topology.o
17049 obj-y += proc.o capflags.o powerflags.o common.o
17050 obj-y += vmware.o hypervisor.o mshyperv.o
17051 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17052 index fa96eb0..03efe73 100644
17053 --- a/arch/x86/kernel/cpu/amd.c
17054 +++ b/arch/x86/kernel/cpu/amd.c
17055 @@ -737,7 +737,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17056 unsigned int size)
17057 {
17058 /* AMD errata T13 (order #21922) */
17059 - if ((c->x86 == 6)) {
17060 + if (c->x86 == 6) {
17061 /* Duron Rev A0 */
17062 if (c->x86_model == 3 && c->x86_mask == 0)
17063 size = 64;
17064 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17065 index d814772..c615653 100644
17066 --- a/arch/x86/kernel/cpu/common.c
17067 +++ b/arch/x86/kernel/cpu/common.c
17068 @@ -88,60 +88,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17069
17070 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17071
17072 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17073 -#ifdef CONFIG_X86_64
17074 - /*
17075 - * We need valid kernel segments for data and code in long mode too
17076 - * IRET will check the segment types kkeil 2000/10/28
17077 - * Also sysret mandates a special GDT layout
17078 - *
17079 - * TLS descriptors are currently at a different place compared to i386.
17080 - * Hopefully nobody expects them at a fixed place (Wine?)
17081 - */
17082 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17083 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17084 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17085 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17086 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17087 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17088 -#else
17089 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17090 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17091 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17092 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17093 - /*
17094 - * Segments used for calling PnP BIOS have byte granularity.
17095 - * They code segments and data segments have fixed 64k limits,
17096 - * the transfer segment sizes are set at run time.
17097 - */
17098 - /* 32-bit code */
17099 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17100 - /* 16-bit code */
17101 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17102 - /* 16-bit data */
17103 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17104 - /* 16-bit data */
17105 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17106 - /* 16-bit data */
17107 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17108 - /*
17109 - * The APM segments have byte granularity and their bases
17110 - * are set at run time. All have 64k limits.
17111 - */
17112 - /* 32-bit code */
17113 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17114 - /* 16-bit code */
17115 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17116 - /* data */
17117 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17118 -
17119 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17120 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17121 - GDT_STACK_CANARY_INIT
17122 -#endif
17123 -} };
17124 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17125 -
17126 static int __init x86_xsave_setup(char *s)
17127 {
17128 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17129 @@ -386,7 +332,7 @@ void switch_to_new_gdt(int cpu)
17130 {
17131 struct desc_ptr gdt_descr;
17132
17133 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17134 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17135 gdt_descr.size = GDT_SIZE - 1;
17136 load_gdt(&gdt_descr);
17137 /* Reload the per-cpu base */
17138 @@ -882,6 +828,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17139 /* Filter out anything that depends on CPUID levels we don't have */
17140 filter_cpuid_features(c, true);
17141
17142 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17143 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17144 +#endif
17145 +
17146 /* If the model name is still unset, do table lookup. */
17147 if (!c->x86_model_id[0]) {
17148 const char *p;
17149 @@ -1065,10 +1015,12 @@ static __init int setup_disablecpuid(char *arg)
17150 }
17151 __setup("clearcpuid=", setup_disablecpuid);
17152
17153 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17154 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17155 +
17156 #ifdef CONFIG_X86_64
17157 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17158 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17159 - (unsigned long) nmi_idt_table };
17160 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17161
17162 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17163 irq_stack_union) __aligned(PAGE_SIZE);
17164 @@ -1082,7 +1034,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17165 EXPORT_PER_CPU_SYMBOL(current_task);
17166
17167 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17168 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17169 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17170 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17171
17172 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17173 @@ -1227,7 +1179,7 @@ void __cpuinit cpu_init(void)
17174 load_ucode_ap();
17175
17176 cpu = stack_smp_processor_id();
17177 - t = &per_cpu(init_tss, cpu);
17178 + t = init_tss + cpu;
17179 oist = &per_cpu(orig_ist, cpu);
17180
17181 #ifdef CONFIG_NUMA
17182 @@ -1253,7 +1205,7 @@ void __cpuinit cpu_init(void)
17183 switch_to_new_gdt(cpu);
17184 loadsegment(fs, 0);
17185
17186 - load_idt((const struct desc_ptr *)&idt_descr);
17187 + load_idt(&idt_descr);
17188
17189 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17190 syscall_init();
17191 @@ -1262,7 +1214,6 @@ void __cpuinit cpu_init(void)
17192 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17193 barrier();
17194
17195 - x86_configure_nx();
17196 enable_x2apic();
17197
17198 /*
17199 @@ -1314,7 +1265,7 @@ void __cpuinit cpu_init(void)
17200 {
17201 int cpu = smp_processor_id();
17202 struct task_struct *curr = current;
17203 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17204 + struct tss_struct *t = init_tss + cpu;
17205 struct thread_struct *thread = &curr->thread;
17206
17207 show_ucode_info_early();
17208 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
17209 index 1905ce9..a7ac587 100644
17210 --- a/arch/x86/kernel/cpu/intel.c
17211 +++ b/arch/x86/kernel/cpu/intel.c
17212 @@ -173,7 +173,7 @@ static void __cpuinit trap_init_f00f_bug(void)
17213 * Update the IDT descriptor and reload the IDT so that
17214 * it uses the read-only mapped virtual address.
17215 */
17216 - idt_descr.address = fix_to_virt(FIX_F00F_IDT);
17217 + idt_descr.address = (struct desc_struct *)fix_to_virt(FIX_F00F_IDT);
17218 load_idt(&idt_descr);
17219 }
17220 #endif
17221 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17222 index 7c6f7d5..8cac382 100644
17223 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17224 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17225 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17226 };
17227
17228 #ifdef CONFIG_AMD_NB
17229 +static struct attribute *default_attrs_amd_nb[] = {
17230 + &type.attr,
17231 + &level.attr,
17232 + &coherency_line_size.attr,
17233 + &physical_line_partition.attr,
17234 + &ways_of_associativity.attr,
17235 + &number_of_sets.attr,
17236 + &size.attr,
17237 + &shared_cpu_map.attr,
17238 + &shared_cpu_list.attr,
17239 + NULL,
17240 + NULL,
17241 + NULL,
17242 + NULL
17243 +};
17244 +
17245 static struct attribute ** __cpuinit amd_l3_attrs(void)
17246 {
17247 static struct attribute **attrs;
17248 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17249
17250 n = ARRAY_SIZE(default_attrs);
17251
17252 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17253 - n += 2;
17254 -
17255 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17256 - n += 1;
17257 -
17258 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17259 - if (attrs == NULL)
17260 - return attrs = default_attrs;
17261 -
17262 - for (n = 0; default_attrs[n]; n++)
17263 - attrs[n] = default_attrs[n];
17264 + attrs = default_attrs_amd_nb;
17265
17266 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17267 attrs[n++] = &cache_disable_0.attr;
17268 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17269 .default_attrs = default_attrs,
17270 };
17271
17272 +#ifdef CONFIG_AMD_NB
17273 +static struct kobj_type ktype_cache_amd_nb = {
17274 + .sysfs_ops = &sysfs_ops,
17275 + .default_attrs = default_attrs_amd_nb,
17276 +};
17277 +#endif
17278 +
17279 static struct kobj_type ktype_percpu_entry = {
17280 .sysfs_ops = &sysfs_ops,
17281 };
17282 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17283 return retval;
17284 }
17285
17286 +#ifdef CONFIG_AMD_NB
17287 + amd_l3_attrs();
17288 +#endif
17289 +
17290 for (i = 0; i < num_cache_leaves; i++) {
17291 + struct kobj_type *ktype;
17292 +
17293 this_object = INDEX_KOBJECT_PTR(cpu, i);
17294 this_object->cpu = cpu;
17295 this_object->index = i;
17296
17297 this_leaf = CPUID4_INFO_IDX(cpu, i);
17298
17299 - ktype_cache.default_attrs = default_attrs;
17300 + ktype = &ktype_cache;
17301 #ifdef CONFIG_AMD_NB
17302 if (this_leaf->base.nb)
17303 - ktype_cache.default_attrs = amd_l3_attrs();
17304 + ktype = &ktype_cache_amd_nb;
17305 #endif
17306 retval = kobject_init_and_add(&(this_object->kobj),
17307 - &ktype_cache,
17308 + ktype,
17309 per_cpu(ici_cache_kobject, cpu),
17310 "index%1lu", i);
17311 if (unlikely(retval)) {
17312 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17313 return NOTIFY_OK;
17314 }
17315
17316 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17317 +static struct notifier_block cacheinfo_cpu_notifier = {
17318 .notifier_call = cacheinfo_cpu_callback,
17319 };
17320
17321 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17322 index 7bc1263..ce2cbfb 100644
17323 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17324 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17325 @@ -45,6 +45,7 @@
17326 #include <asm/processor.h>
17327 #include <asm/mce.h>
17328 #include <asm/msr.h>
17329 +#include <asm/local.h>
17330
17331 #include "mce-internal.h"
17332
17333 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17334 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17335 m->cs, m->ip);
17336
17337 - if (m->cs == __KERNEL_CS)
17338 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17339 print_symbol("{%s}", m->ip);
17340 pr_cont("\n");
17341 }
17342 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17343
17344 #define PANIC_TIMEOUT 5 /* 5 seconds */
17345
17346 -static atomic_t mce_paniced;
17347 +static atomic_unchecked_t mce_paniced;
17348
17349 static int fake_panic;
17350 -static atomic_t mce_fake_paniced;
17351 +static atomic_unchecked_t mce_fake_paniced;
17352
17353 /* Panic in progress. Enable interrupts and wait for final IPI */
17354 static void wait_for_panic(void)
17355 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17356 /*
17357 * Make sure only one CPU runs in machine check panic
17358 */
17359 - if (atomic_inc_return(&mce_paniced) > 1)
17360 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17361 wait_for_panic();
17362 barrier();
17363
17364 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17365 console_verbose();
17366 } else {
17367 /* Don't log too much for fake panic */
17368 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17369 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17370 return;
17371 }
17372 /* First print corrected ones that are still unlogged */
17373 @@ -683,7 +684,7 @@ static int mce_timed_out(u64 *t)
17374 * might have been modified by someone else.
17375 */
17376 rmb();
17377 - if (atomic_read(&mce_paniced))
17378 + if (atomic_read_unchecked(&mce_paniced))
17379 wait_for_panic();
17380 if (!mca_cfg.monarch_timeout)
17381 goto out;
17382 @@ -1654,7 +1655,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17383 }
17384
17385 /* Call the installed machine check handler for this CPU setup. */
17386 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17387 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17388 unexpected_machine_check;
17389
17390 /*
17391 @@ -1677,7 +1678,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17392 return;
17393 }
17394
17395 + pax_open_kernel();
17396 machine_check_vector = do_machine_check;
17397 + pax_close_kernel();
17398
17399 __mcheck_cpu_init_generic();
17400 __mcheck_cpu_init_vendor(c);
17401 @@ -1691,7 +1694,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17402 */
17403
17404 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17405 -static int mce_chrdev_open_count; /* #times opened */
17406 +static local_t mce_chrdev_open_count; /* #times opened */
17407 static int mce_chrdev_open_exclu; /* already open exclusive? */
17408
17409 static int mce_chrdev_open(struct inode *inode, struct file *file)
17410 @@ -1699,7 +1702,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17411 spin_lock(&mce_chrdev_state_lock);
17412
17413 if (mce_chrdev_open_exclu ||
17414 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17415 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17416 spin_unlock(&mce_chrdev_state_lock);
17417
17418 return -EBUSY;
17419 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17420
17421 if (file->f_flags & O_EXCL)
17422 mce_chrdev_open_exclu = 1;
17423 - mce_chrdev_open_count++;
17424 + local_inc(&mce_chrdev_open_count);
17425
17426 spin_unlock(&mce_chrdev_state_lock);
17427
17428 @@ -1718,7 +1721,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17429 {
17430 spin_lock(&mce_chrdev_state_lock);
17431
17432 - mce_chrdev_open_count--;
17433 + local_dec(&mce_chrdev_open_count);
17434 mce_chrdev_open_exclu = 0;
17435
17436 spin_unlock(&mce_chrdev_state_lock);
17437 @@ -2364,7 +2367,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17438 return NOTIFY_OK;
17439 }
17440
17441 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17442 +static struct notifier_block mce_cpu_notifier = {
17443 .notifier_call = mce_cpu_callback,
17444 };
17445
17446 @@ -2374,7 +2377,7 @@ static __init void mce_init_banks(void)
17447
17448 for (i = 0; i < mca_cfg.banks; i++) {
17449 struct mce_bank *b = &mce_banks[i];
17450 - struct device_attribute *a = &b->attr;
17451 + device_attribute_no_const *a = &b->attr;
17452
17453 sysfs_attr_init(&a->attr);
17454 a->attr.name = b->attrname;
17455 @@ -2442,7 +2445,7 @@ struct dentry *mce_get_debugfs_dir(void)
17456 static void mce_reset(void)
17457 {
17458 cpu_missing = 0;
17459 - atomic_set(&mce_fake_paniced, 0);
17460 + atomic_set_unchecked(&mce_fake_paniced, 0);
17461 atomic_set(&mce_executing, 0);
17462 atomic_set(&mce_callin, 0);
17463 atomic_set(&global_nwo, 0);
17464 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17465 index 1c044b1..37a2a43 100644
17466 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17467 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17468 @@ -11,6 +11,7 @@
17469 #include <asm/processor.h>
17470 #include <asm/mce.h>
17471 #include <asm/msr.h>
17472 +#include <asm/pgtable.h>
17473
17474 /* By default disabled */
17475 int mce_p5_enabled __read_mostly;
17476 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17477 if (!cpu_has(c, X86_FEATURE_MCE))
17478 return;
17479
17480 + pax_open_kernel();
17481 machine_check_vector = pentium_machine_check;
17482 + pax_close_kernel();
17483 /* Make sure the vector pointer is visible before we enable MCEs: */
17484 wmb();
17485
17486 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17487 index 47a1870..8c019a7 100644
17488 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17489 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17490 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17491 return notifier_from_errno(err);
17492 }
17493
17494 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17495 +static struct notifier_block thermal_throttle_cpu_notifier =
17496 {
17497 .notifier_call = thermal_throttle_cpu_callback,
17498 };
17499 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17500 index e9a701a..35317d6 100644
17501 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17502 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17503 @@ -10,6 +10,7 @@
17504 #include <asm/processor.h>
17505 #include <asm/mce.h>
17506 #include <asm/msr.h>
17507 +#include <asm/pgtable.h>
17508
17509 /* Machine check handler for WinChip C6: */
17510 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17511 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17512 {
17513 u32 lo, hi;
17514
17515 + pax_open_kernel();
17516 machine_check_vector = winchip_machine_check;
17517 + pax_close_kernel();
17518 /* Make sure the vector pointer is visible before we enable MCEs: */
17519 wmb();
17520
17521 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17522 index 726bf96..81f0526 100644
17523 --- a/arch/x86/kernel/cpu/mtrr/main.c
17524 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17525 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17526 u64 size_or_mask, size_and_mask;
17527 static bool mtrr_aps_delayed_init;
17528
17529 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17530 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17531
17532 const struct mtrr_ops *mtrr_if;
17533
17534 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17535 index df5e41f..816c719 100644
17536 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17537 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17538 @@ -25,7 +25,7 @@ struct mtrr_ops {
17539 int (*validate_add_page)(unsigned long base, unsigned long size,
17540 unsigned int type);
17541 int (*have_wrcomb)(void);
17542 -};
17543 +} __do_const;
17544
17545 extern int generic_get_free_region(unsigned long base, unsigned long size,
17546 int replace_reg);
17547 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17548 index bf0f01a..9adfee1 100644
17549 --- a/arch/x86/kernel/cpu/perf_event.c
17550 +++ b/arch/x86/kernel/cpu/perf_event.c
17551 @@ -1305,7 +1305,7 @@ static void __init pmu_check_apic(void)
17552 pr_info("no hardware sampling interrupt available.\n");
17553 }
17554
17555 -static struct attribute_group x86_pmu_format_group = {
17556 +static attribute_group_no_const x86_pmu_format_group = {
17557 .name = "format",
17558 .attrs = NULL,
17559 };
17560 @@ -1374,7 +1374,7 @@ static struct attribute *events_attr[] = {
17561 NULL,
17562 };
17563
17564 -static struct attribute_group x86_pmu_events_group = {
17565 +static attribute_group_no_const x86_pmu_events_group = {
17566 .name = "events",
17567 .attrs = events_attr,
17568 };
17569 @@ -1873,7 +1873,7 @@ static unsigned long get_segment_base(unsigned int segment)
17570 if (idx > GDT_ENTRIES)
17571 return 0;
17572
17573 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
17574 + desc = get_cpu_gdt_table(smp_processor_id());
17575 }
17576
17577 return get_desc_base(desc + idx);
17578 @@ -1963,7 +1963,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
17579 break;
17580
17581 perf_callchain_store(entry, frame.return_address);
17582 - fp = frame.next_frame;
17583 + fp = (const void __force_user *)frame.next_frame;
17584 }
17585 }
17586
17587 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
17588 index 4a0a462..be3b204 100644
17589 --- a/arch/x86/kernel/cpu/perf_event_intel.c
17590 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
17591 @@ -1994,10 +1994,10 @@ __init int intel_pmu_init(void)
17592 * v2 and above have a perf capabilities MSR
17593 */
17594 if (version > 1) {
17595 - u64 capabilities;
17596 + u64 capabilities = x86_pmu.intel_cap.capabilities;
17597
17598 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
17599 - x86_pmu.intel_cap.capabilities = capabilities;
17600 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
17601 + x86_pmu.intel_cap.capabilities = capabilities;
17602 }
17603
17604 intel_ds_init();
17605 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17606 index 3e091f0..d2dc8d6 100644
17607 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17608 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17609 @@ -2428,7 +2428,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
17610 static int __init uncore_type_init(struct intel_uncore_type *type)
17611 {
17612 struct intel_uncore_pmu *pmus;
17613 - struct attribute_group *attr_group;
17614 + attribute_group_no_const *attr_group;
17615 struct attribute **attrs;
17616 int i, j;
17617
17618 @@ -2826,7 +2826,7 @@ static int
17619 return NOTIFY_OK;
17620 }
17621
17622 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
17623 +static struct notifier_block uncore_cpu_nb = {
17624 .notifier_call = uncore_cpu_notifier,
17625 /*
17626 * to migrate uncore events, our notifier should be executed
17627 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17628 index e68a455..975a932 100644
17629 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17630 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17631 @@ -428,7 +428,7 @@ struct intel_uncore_box {
17632 struct uncore_event_desc {
17633 struct kobj_attribute attr;
17634 const char *config;
17635 -};
17636 +} __do_const;
17637
17638 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
17639 { \
17640 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
17641 index 1e4dbcf..b9a34c2 100644
17642 --- a/arch/x86/kernel/cpuid.c
17643 +++ b/arch/x86/kernel/cpuid.c
17644 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
17645 return notifier_from_errno(err);
17646 }
17647
17648 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
17649 +static struct notifier_block cpuid_class_cpu_notifier =
17650 {
17651 .notifier_call = cpuid_class_cpu_callback,
17652 };
17653 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
17654 index 74467fe..18793d5 100644
17655 --- a/arch/x86/kernel/crash.c
17656 +++ b/arch/x86/kernel/crash.c
17657 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
17658 {
17659 #ifdef CONFIG_X86_32
17660 struct pt_regs fixed_regs;
17661 -#endif
17662
17663 -#ifdef CONFIG_X86_32
17664 - if (!user_mode_vm(regs)) {
17665 + if (!user_mode(regs)) {
17666 crash_fixup_ss_esp(&fixed_regs, regs);
17667 regs = &fixed_regs;
17668 }
17669 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
17670 index 37250fe..bf2ec74 100644
17671 --- a/arch/x86/kernel/doublefault_32.c
17672 +++ b/arch/x86/kernel/doublefault_32.c
17673 @@ -11,7 +11,7 @@
17674
17675 #define DOUBLEFAULT_STACKSIZE (1024)
17676 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
17677 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
17678 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
17679
17680 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
17681
17682 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
17683 unsigned long gdt, tss;
17684
17685 store_gdt(&gdt_desc);
17686 - gdt = gdt_desc.address;
17687 + gdt = (unsigned long)gdt_desc.address;
17688
17689 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
17690
17691 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
17692 /* 0x2 bit is always set */
17693 .flags = X86_EFLAGS_SF | 0x2,
17694 .sp = STACK_START,
17695 - .es = __USER_DS,
17696 + .es = __KERNEL_DS,
17697 .cs = __KERNEL_CS,
17698 .ss = __KERNEL_DS,
17699 - .ds = __USER_DS,
17700 + .ds = __KERNEL_DS,
17701 .fs = __KERNEL_PERCPU,
17702
17703 .__cr3 = __pa_nodebug(swapper_pg_dir),
17704 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
17705 index c8797d5..c605e53 100644
17706 --- a/arch/x86/kernel/dumpstack.c
17707 +++ b/arch/x86/kernel/dumpstack.c
17708 @@ -2,6 +2,9 @@
17709 * Copyright (C) 1991, 1992 Linus Torvalds
17710 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
17711 */
17712 +#ifdef CONFIG_GRKERNSEC_HIDESYM
17713 +#define __INCLUDED_BY_HIDESYM 1
17714 +#endif
17715 #include <linux/kallsyms.h>
17716 #include <linux/kprobes.h>
17717 #include <linux/uaccess.h>
17718 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
17719 static void
17720 print_ftrace_graph_addr(unsigned long addr, void *data,
17721 const struct stacktrace_ops *ops,
17722 - struct thread_info *tinfo, int *graph)
17723 + struct task_struct *task, int *graph)
17724 {
17725 - struct task_struct *task;
17726 unsigned long ret_addr;
17727 int index;
17728
17729 if (addr != (unsigned long)return_to_handler)
17730 return;
17731
17732 - task = tinfo->task;
17733 index = task->curr_ret_stack;
17734
17735 if (!task->ret_stack || index < *graph)
17736 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17737 static inline void
17738 print_ftrace_graph_addr(unsigned long addr, void *data,
17739 const struct stacktrace_ops *ops,
17740 - struct thread_info *tinfo, int *graph)
17741 + struct task_struct *task, int *graph)
17742 { }
17743 #endif
17744
17745 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17746 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
17747 */
17748
17749 -static inline int valid_stack_ptr(struct thread_info *tinfo,
17750 - void *p, unsigned int size, void *end)
17751 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
17752 {
17753 - void *t = tinfo;
17754 if (end) {
17755 if (p < end && p >= (end-THREAD_SIZE))
17756 return 1;
17757 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
17758 }
17759
17760 unsigned long
17761 -print_context_stack(struct thread_info *tinfo,
17762 +print_context_stack(struct task_struct *task, void *stack_start,
17763 unsigned long *stack, unsigned long bp,
17764 const struct stacktrace_ops *ops, void *data,
17765 unsigned long *end, int *graph)
17766 {
17767 struct stack_frame *frame = (struct stack_frame *)bp;
17768
17769 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
17770 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
17771 unsigned long addr;
17772
17773 addr = *stack;
17774 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
17775 } else {
17776 ops->address(data, addr, 0);
17777 }
17778 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17779 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17780 }
17781 stack++;
17782 }
17783 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
17784 EXPORT_SYMBOL_GPL(print_context_stack);
17785
17786 unsigned long
17787 -print_context_stack_bp(struct thread_info *tinfo,
17788 +print_context_stack_bp(struct task_struct *task, void *stack_start,
17789 unsigned long *stack, unsigned long bp,
17790 const struct stacktrace_ops *ops, void *data,
17791 unsigned long *end, int *graph)
17792 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17793 struct stack_frame *frame = (struct stack_frame *)bp;
17794 unsigned long *ret_addr = &frame->return_address;
17795
17796 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
17797 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
17798 unsigned long addr = *ret_addr;
17799
17800 if (!__kernel_text_address(addr))
17801 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17802 ops->address(data, addr, 1);
17803 frame = frame->next_frame;
17804 ret_addr = &frame->return_address;
17805 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17806 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17807 }
17808
17809 return (unsigned long)frame;
17810 @@ -189,7 +188,7 @@ void dump_stack(void)
17811
17812 bp = stack_frame(current, NULL);
17813 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
17814 - current->pid, current->comm, print_tainted(),
17815 + task_pid_nr(current), current->comm, print_tainted(),
17816 init_utsname()->release,
17817 (int)strcspn(init_utsname()->version, " "),
17818 init_utsname()->version);
17819 @@ -225,6 +224,8 @@ unsigned __kprobes long oops_begin(void)
17820 }
17821 EXPORT_SYMBOL_GPL(oops_begin);
17822
17823 +extern void gr_handle_kernel_exploit(void);
17824 +
17825 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17826 {
17827 if (regs && kexec_should_crash(current))
17828 @@ -246,7 +247,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17829 panic("Fatal exception in interrupt");
17830 if (panic_on_oops)
17831 panic("Fatal exception");
17832 - do_exit(signr);
17833 +
17834 + gr_handle_kernel_exploit();
17835 +
17836 + do_group_exit(signr);
17837 }
17838
17839 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17840 @@ -274,7 +278,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17841 print_modules();
17842 show_regs(regs);
17843 #ifdef CONFIG_X86_32
17844 - if (user_mode_vm(regs)) {
17845 + if (user_mode(regs)) {
17846 sp = regs->sp;
17847 ss = regs->ss & 0xffff;
17848 } else {
17849 @@ -302,7 +306,7 @@ void die(const char *str, struct pt_regs *regs, long err)
17850 unsigned long flags = oops_begin();
17851 int sig = SIGSEGV;
17852
17853 - if (!user_mode_vm(regs))
17854 + if (!user_mode(regs))
17855 report_bug(regs->ip, regs);
17856
17857 if (__die(str, regs, err))
17858 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
17859 index 1038a41..db2c12b 100644
17860 --- a/arch/x86/kernel/dumpstack_32.c
17861 +++ b/arch/x86/kernel/dumpstack_32.c
17862 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17863 bp = stack_frame(task, regs);
17864
17865 for (;;) {
17866 - struct thread_info *context;
17867 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
17868
17869 - context = (struct thread_info *)
17870 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
17871 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
17872 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
17873
17874 - stack = (unsigned long *)context->previous_esp;
17875 - if (!stack)
17876 + if (stack_start == task_stack_page(task))
17877 break;
17878 + stack = *(unsigned long **)stack_start;
17879 if (ops->stack(data, "IRQ") < 0)
17880 break;
17881 touch_nmi_watchdog();
17882 @@ -86,7 +84,7 @@ void show_regs(struct pt_regs *regs)
17883 {
17884 int i;
17885
17886 - __show_regs(regs, !user_mode_vm(regs));
17887 + __show_regs(regs, !user_mode(regs));
17888
17889 pr_emerg("Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
17890 TASK_COMM_LEN, current->comm, task_pid_nr(current),
17891 @@ -95,21 +93,22 @@ void show_regs(struct pt_regs *regs)
17892 * When in-kernel, we also print out the stack and code at the
17893 * time of the fault..
17894 */
17895 - if (!user_mode_vm(regs)) {
17896 + if (!user_mode(regs)) {
17897 unsigned int code_prologue = code_bytes * 43 / 64;
17898 unsigned int code_len = code_bytes;
17899 unsigned char c;
17900 u8 *ip;
17901 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
17902
17903 pr_emerg("Stack:\n");
17904 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
17905
17906 pr_emerg("Code:");
17907
17908 - ip = (u8 *)regs->ip - code_prologue;
17909 + ip = (u8 *)regs->ip - code_prologue + cs_base;
17910 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
17911 /* try starting at IP */
17912 - ip = (u8 *)regs->ip;
17913 + ip = (u8 *)regs->ip + cs_base;
17914 code_len = code_len - code_prologue + 1;
17915 }
17916 for (i = 0; i < code_len; i++, ip++) {
17917 @@ -118,7 +117,7 @@ void show_regs(struct pt_regs *regs)
17918 pr_cont(" Bad EIP value.");
17919 break;
17920 }
17921 - if (ip == (u8 *)regs->ip)
17922 + if (ip == (u8 *)regs->ip + cs_base)
17923 pr_cont(" <%02x>", c);
17924 else
17925 pr_cont(" %02x", c);
17926 @@ -131,6 +130,7 @@ int is_valid_bugaddr(unsigned long ip)
17927 {
17928 unsigned short ud2;
17929
17930 + ip = ktla_ktva(ip);
17931 if (ip < PAGE_OFFSET)
17932 return 0;
17933 if (probe_kernel_address((unsigned short *)ip, ud2))
17934 @@ -138,3 +138,15 @@ int is_valid_bugaddr(unsigned long ip)
17935
17936 return ud2 == 0x0b0f;
17937 }
17938 +
17939 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
17940 +void pax_check_alloca(unsigned long size)
17941 +{
17942 + unsigned long sp = (unsigned long)&sp, stack_left;
17943 +
17944 + /* all kernel stacks are of the same size */
17945 + stack_left = sp & (THREAD_SIZE - 1);
17946 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
17947 +}
17948 +EXPORT_SYMBOL(pax_check_alloca);
17949 +#endif
17950 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
17951 index b653675..51cc8c0 100644
17952 --- a/arch/x86/kernel/dumpstack_64.c
17953 +++ b/arch/x86/kernel/dumpstack_64.c
17954 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17955 unsigned long *irq_stack_end =
17956 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
17957 unsigned used = 0;
17958 - struct thread_info *tinfo;
17959 int graph = 0;
17960 unsigned long dummy;
17961 + void *stack_start;
17962
17963 if (!task)
17964 task = current;
17965 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17966 * current stack address. If the stacks consist of nested
17967 * exceptions
17968 */
17969 - tinfo = task_thread_info(task);
17970 for (;;) {
17971 char *id;
17972 unsigned long *estack_end;
17973 +
17974 estack_end = in_exception_stack(cpu, (unsigned long)stack,
17975 &used, &id);
17976
17977 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17978 if (ops->stack(data, id) < 0)
17979 break;
17980
17981 - bp = ops->walk_stack(tinfo, stack, bp, ops,
17982 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
17983 data, estack_end, &graph);
17984 ops->stack(data, "<EOE>");
17985 /*
17986 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17987 * second-to-last pointer (index -2 to end) in the
17988 * exception stack:
17989 */
17990 + if ((u16)estack_end[-1] != __KERNEL_DS)
17991 + goto out;
17992 stack = (unsigned long *) estack_end[-2];
17993 continue;
17994 }
17995 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17996 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
17997 if (ops->stack(data, "IRQ") < 0)
17998 break;
17999 - bp = ops->walk_stack(tinfo, stack, bp,
18000 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18001 ops, data, irq_stack_end, &graph);
18002 /*
18003 * We link to the next stack (which would be
18004 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18005 /*
18006 * This handles the process stack:
18007 */
18008 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18009 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18010 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18011 +out:
18012 put_cpu();
18013 }
18014 EXPORT_SYMBOL(dump_trace);
18015 @@ -249,7 +253,7 @@ void show_regs(struct pt_regs *regs)
18016 {
18017 int i;
18018 unsigned long sp;
18019 - const int cpu = smp_processor_id();
18020 + const int cpu = raw_smp_processor_id();
18021 struct task_struct *cur = current;
18022
18023 sp = regs->sp;
18024 @@ -304,3 +308,50 @@ int is_valid_bugaddr(unsigned long ip)
18025
18026 return ud2 == 0x0b0f;
18027 }
18028 +
18029 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18030 +void pax_check_alloca(unsigned long size)
18031 +{
18032 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18033 + unsigned cpu, used;
18034 + char *id;
18035 +
18036 + /* check the process stack first */
18037 + stack_start = (unsigned long)task_stack_page(current);
18038 + stack_end = stack_start + THREAD_SIZE;
18039 + if (likely(stack_start <= sp && sp < stack_end)) {
18040 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18041 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18042 + return;
18043 + }
18044 +
18045 + cpu = get_cpu();
18046 +
18047 + /* check the irq stacks */
18048 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18049 + stack_start = stack_end - IRQ_STACK_SIZE;
18050 + if (stack_start <= sp && sp < stack_end) {
18051 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18052 + put_cpu();
18053 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18054 + return;
18055 + }
18056 +
18057 + /* check the exception stacks */
18058 + used = 0;
18059 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18060 + stack_start = stack_end - EXCEPTION_STKSZ;
18061 + if (stack_end && stack_start <= sp && sp < stack_end) {
18062 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18063 + put_cpu();
18064 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18065 + return;
18066 + }
18067 +
18068 + put_cpu();
18069 +
18070 + /* unknown stack */
18071 + BUG();
18072 +}
18073 +EXPORT_SYMBOL(pax_check_alloca);
18074 +#endif
18075 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18076 index 9b9f18b..9fcaa04 100644
18077 --- a/arch/x86/kernel/early_printk.c
18078 +++ b/arch/x86/kernel/early_printk.c
18079 @@ -7,6 +7,7 @@
18080 #include <linux/pci_regs.h>
18081 #include <linux/pci_ids.h>
18082 #include <linux/errno.h>
18083 +#include <linux/sched.h>
18084 #include <asm/io.h>
18085 #include <asm/processor.h>
18086 #include <asm/fcntl.h>
18087 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18088 index 8f3e2de..934870f 100644
18089 --- a/arch/x86/kernel/entry_32.S
18090 +++ b/arch/x86/kernel/entry_32.S
18091 @@ -177,13 +177,153 @@
18092 /*CFI_REL_OFFSET gs, PT_GS*/
18093 .endm
18094 .macro SET_KERNEL_GS reg
18095 +
18096 +#ifdef CONFIG_CC_STACKPROTECTOR
18097 movl $(__KERNEL_STACK_CANARY), \reg
18098 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18099 + movl $(__USER_DS), \reg
18100 +#else
18101 + xorl \reg, \reg
18102 +#endif
18103 +
18104 movl \reg, %gs
18105 .endm
18106
18107 #endif /* CONFIG_X86_32_LAZY_GS */
18108
18109 -.macro SAVE_ALL
18110 +.macro pax_enter_kernel
18111 +#ifdef CONFIG_PAX_KERNEXEC
18112 + call pax_enter_kernel
18113 +#endif
18114 +.endm
18115 +
18116 +.macro pax_exit_kernel
18117 +#ifdef CONFIG_PAX_KERNEXEC
18118 + call pax_exit_kernel
18119 +#endif
18120 +.endm
18121 +
18122 +#ifdef CONFIG_PAX_KERNEXEC
18123 +ENTRY(pax_enter_kernel)
18124 +#ifdef CONFIG_PARAVIRT
18125 + pushl %eax
18126 + pushl %ecx
18127 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18128 + mov %eax, %esi
18129 +#else
18130 + mov %cr0, %esi
18131 +#endif
18132 + bts $16, %esi
18133 + jnc 1f
18134 + mov %cs, %esi
18135 + cmp $__KERNEL_CS, %esi
18136 + jz 3f
18137 + ljmp $__KERNEL_CS, $3f
18138 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18139 +2:
18140 +#ifdef CONFIG_PARAVIRT
18141 + mov %esi, %eax
18142 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18143 +#else
18144 + mov %esi, %cr0
18145 +#endif
18146 +3:
18147 +#ifdef CONFIG_PARAVIRT
18148 + popl %ecx
18149 + popl %eax
18150 +#endif
18151 + ret
18152 +ENDPROC(pax_enter_kernel)
18153 +
18154 +ENTRY(pax_exit_kernel)
18155 +#ifdef CONFIG_PARAVIRT
18156 + pushl %eax
18157 + pushl %ecx
18158 +#endif
18159 + mov %cs, %esi
18160 + cmp $__KERNEXEC_KERNEL_CS, %esi
18161 + jnz 2f
18162 +#ifdef CONFIG_PARAVIRT
18163 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18164 + mov %eax, %esi
18165 +#else
18166 + mov %cr0, %esi
18167 +#endif
18168 + btr $16, %esi
18169 + ljmp $__KERNEL_CS, $1f
18170 +1:
18171 +#ifdef CONFIG_PARAVIRT
18172 + mov %esi, %eax
18173 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18174 +#else
18175 + mov %esi, %cr0
18176 +#endif
18177 +2:
18178 +#ifdef CONFIG_PARAVIRT
18179 + popl %ecx
18180 + popl %eax
18181 +#endif
18182 + ret
18183 +ENDPROC(pax_exit_kernel)
18184 +#endif
18185 +
18186 +.macro pax_erase_kstack
18187 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18188 + call pax_erase_kstack
18189 +#endif
18190 +.endm
18191 +
18192 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18193 +/*
18194 + * ebp: thread_info
18195 + */
18196 +ENTRY(pax_erase_kstack)
18197 + pushl %edi
18198 + pushl %ecx
18199 + pushl %eax
18200 +
18201 + mov TI_lowest_stack(%ebp), %edi
18202 + mov $-0xBEEF, %eax
18203 + std
18204 +
18205 +1: mov %edi, %ecx
18206 + and $THREAD_SIZE_asm - 1, %ecx
18207 + shr $2, %ecx
18208 + repne scasl
18209 + jecxz 2f
18210 +
18211 + cmp $2*16, %ecx
18212 + jc 2f
18213 +
18214 + mov $2*16, %ecx
18215 + repe scasl
18216 + jecxz 2f
18217 + jne 1b
18218 +
18219 +2: cld
18220 + mov %esp, %ecx
18221 + sub %edi, %ecx
18222 +
18223 + cmp $THREAD_SIZE_asm, %ecx
18224 + jb 3f
18225 + ud2
18226 +3:
18227 +
18228 + shr $2, %ecx
18229 + rep stosl
18230 +
18231 + mov TI_task_thread_sp0(%ebp), %edi
18232 + sub $128, %edi
18233 + mov %edi, TI_lowest_stack(%ebp)
18234 +
18235 + popl %eax
18236 + popl %ecx
18237 + popl %edi
18238 + ret
18239 +ENDPROC(pax_erase_kstack)
18240 +#endif
18241 +
18242 +.macro __SAVE_ALL _DS
18243 cld
18244 PUSH_GS
18245 pushl_cfi %fs
18246 @@ -206,7 +346,7 @@
18247 CFI_REL_OFFSET ecx, 0
18248 pushl_cfi %ebx
18249 CFI_REL_OFFSET ebx, 0
18250 - movl $(__USER_DS), %edx
18251 + movl $\_DS, %edx
18252 movl %edx, %ds
18253 movl %edx, %es
18254 movl $(__KERNEL_PERCPU), %edx
18255 @@ -214,6 +354,15 @@
18256 SET_KERNEL_GS %edx
18257 .endm
18258
18259 +.macro SAVE_ALL
18260 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18261 + __SAVE_ALL __KERNEL_DS
18262 + pax_enter_kernel
18263 +#else
18264 + __SAVE_ALL __USER_DS
18265 +#endif
18266 +.endm
18267 +
18268 .macro RESTORE_INT_REGS
18269 popl_cfi %ebx
18270 CFI_RESTORE ebx
18271 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18272 popfl_cfi
18273 jmp syscall_exit
18274 CFI_ENDPROC
18275 -END(ret_from_fork)
18276 +ENDPROC(ret_from_fork)
18277
18278 ENTRY(ret_from_kernel_thread)
18279 CFI_STARTPROC
18280 @@ -344,7 +493,15 @@ ret_from_intr:
18281 andl $SEGMENT_RPL_MASK, %eax
18282 #endif
18283 cmpl $USER_RPL, %eax
18284 +
18285 +#ifdef CONFIG_PAX_KERNEXEC
18286 + jae resume_userspace
18287 +
18288 + pax_exit_kernel
18289 + jmp resume_kernel
18290 +#else
18291 jb resume_kernel # not returning to v8086 or userspace
18292 +#endif
18293
18294 ENTRY(resume_userspace)
18295 LOCKDEP_SYS_EXIT
18296 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18297 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18298 # int/exception return?
18299 jne work_pending
18300 - jmp restore_all
18301 -END(ret_from_exception)
18302 + jmp restore_all_pax
18303 +ENDPROC(ret_from_exception)
18304
18305 #ifdef CONFIG_PREEMPT
18306 ENTRY(resume_kernel)
18307 @@ -372,7 +529,7 @@ need_resched:
18308 jz restore_all
18309 call preempt_schedule_irq
18310 jmp need_resched
18311 -END(resume_kernel)
18312 +ENDPROC(resume_kernel)
18313 #endif
18314 CFI_ENDPROC
18315 /*
18316 @@ -406,30 +563,45 @@ sysenter_past_esp:
18317 /*CFI_REL_OFFSET cs, 0*/
18318 /*
18319 * Push current_thread_info()->sysenter_return to the stack.
18320 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18321 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18322 */
18323 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18324 + pushl_cfi $0
18325 CFI_REL_OFFSET eip, 0
18326
18327 pushl_cfi %eax
18328 SAVE_ALL
18329 + GET_THREAD_INFO(%ebp)
18330 + movl TI_sysenter_return(%ebp),%ebp
18331 + movl %ebp,PT_EIP(%esp)
18332 ENABLE_INTERRUPTS(CLBR_NONE)
18333
18334 /*
18335 * Load the potential sixth argument from user stack.
18336 * Careful about security.
18337 */
18338 + movl PT_OLDESP(%esp),%ebp
18339 +
18340 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18341 + mov PT_OLDSS(%esp),%ds
18342 +1: movl %ds:(%ebp),%ebp
18343 + push %ss
18344 + pop %ds
18345 +#else
18346 cmpl $__PAGE_OFFSET-3,%ebp
18347 jae syscall_fault
18348 ASM_STAC
18349 1: movl (%ebp),%ebp
18350 ASM_CLAC
18351 +#endif
18352 +
18353 movl %ebp,PT_EBP(%esp)
18354 _ASM_EXTABLE(1b,syscall_fault)
18355
18356 GET_THREAD_INFO(%ebp)
18357
18358 +#ifdef CONFIG_PAX_RANDKSTACK
18359 + pax_erase_kstack
18360 +#endif
18361 +
18362 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18363 jnz sysenter_audit
18364 sysenter_do_call:
18365 @@ -444,12 +616,24 @@ sysenter_do_call:
18366 testl $_TIF_ALLWORK_MASK, %ecx
18367 jne sysexit_audit
18368 sysenter_exit:
18369 +
18370 +#ifdef CONFIG_PAX_RANDKSTACK
18371 + pushl_cfi %eax
18372 + movl %esp, %eax
18373 + call pax_randomize_kstack
18374 + popl_cfi %eax
18375 +#endif
18376 +
18377 + pax_erase_kstack
18378 +
18379 /* if something modifies registers it must also disable sysexit */
18380 movl PT_EIP(%esp), %edx
18381 movl PT_OLDESP(%esp), %ecx
18382 xorl %ebp,%ebp
18383 TRACE_IRQS_ON
18384 1: mov PT_FS(%esp), %fs
18385 +2: mov PT_DS(%esp), %ds
18386 +3: mov PT_ES(%esp), %es
18387 PTGS_TO_GS
18388 ENABLE_INTERRUPTS_SYSEXIT
18389
18390 @@ -466,6 +650,9 @@ sysenter_audit:
18391 movl %eax,%edx /* 2nd arg: syscall number */
18392 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18393 call __audit_syscall_entry
18394 +
18395 + pax_erase_kstack
18396 +
18397 pushl_cfi %ebx
18398 movl PT_EAX(%esp),%eax /* reload syscall number */
18399 jmp sysenter_do_call
18400 @@ -491,10 +678,16 @@ sysexit_audit:
18401
18402 CFI_ENDPROC
18403 .pushsection .fixup,"ax"
18404 -2: movl $0,PT_FS(%esp)
18405 +4: movl $0,PT_FS(%esp)
18406 + jmp 1b
18407 +5: movl $0,PT_DS(%esp)
18408 + jmp 1b
18409 +6: movl $0,PT_ES(%esp)
18410 jmp 1b
18411 .popsection
18412 - _ASM_EXTABLE(1b,2b)
18413 + _ASM_EXTABLE(1b,4b)
18414 + _ASM_EXTABLE(2b,5b)
18415 + _ASM_EXTABLE(3b,6b)
18416 PTGS_TO_GS_EX
18417 ENDPROC(ia32_sysenter_target)
18418
18419 @@ -509,6 +702,11 @@ ENTRY(system_call)
18420 pushl_cfi %eax # save orig_eax
18421 SAVE_ALL
18422 GET_THREAD_INFO(%ebp)
18423 +
18424 +#ifdef CONFIG_PAX_RANDKSTACK
18425 + pax_erase_kstack
18426 +#endif
18427 +
18428 # system call tracing in operation / emulation
18429 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18430 jnz syscall_trace_entry
18431 @@ -527,6 +725,15 @@ syscall_exit:
18432 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18433 jne syscall_exit_work
18434
18435 +restore_all_pax:
18436 +
18437 +#ifdef CONFIG_PAX_RANDKSTACK
18438 + movl %esp, %eax
18439 + call pax_randomize_kstack
18440 +#endif
18441 +
18442 + pax_erase_kstack
18443 +
18444 restore_all:
18445 TRACE_IRQS_IRET
18446 restore_all_notrace:
18447 @@ -583,14 +790,34 @@ ldt_ss:
18448 * compensating for the offset by changing to the ESPFIX segment with
18449 * a base address that matches for the difference.
18450 */
18451 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18452 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18453 mov %esp, %edx /* load kernel esp */
18454 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18455 mov %dx, %ax /* eax: new kernel esp */
18456 sub %eax, %edx /* offset (low word is 0) */
18457 +#ifdef CONFIG_SMP
18458 + movl PER_CPU_VAR(cpu_number), %ebx
18459 + shll $PAGE_SHIFT_asm, %ebx
18460 + addl $cpu_gdt_table, %ebx
18461 +#else
18462 + movl $cpu_gdt_table, %ebx
18463 +#endif
18464 shr $16, %edx
18465 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18466 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18467 +
18468 +#ifdef CONFIG_PAX_KERNEXEC
18469 + mov %cr0, %esi
18470 + btr $16, %esi
18471 + mov %esi, %cr0
18472 +#endif
18473 +
18474 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18475 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18476 +
18477 +#ifdef CONFIG_PAX_KERNEXEC
18478 + bts $16, %esi
18479 + mov %esi, %cr0
18480 +#endif
18481 +
18482 pushl_cfi $__ESPFIX_SS
18483 pushl_cfi %eax /* new kernel esp */
18484 /* Disable interrupts, but do not irqtrace this section: we
18485 @@ -619,20 +846,18 @@ work_resched:
18486 movl TI_flags(%ebp), %ecx
18487 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18488 # than syscall tracing?
18489 - jz restore_all
18490 + jz restore_all_pax
18491 testb $_TIF_NEED_RESCHED, %cl
18492 jnz work_resched
18493
18494 work_notifysig: # deal with pending signals and
18495 # notify-resume requests
18496 + movl %esp, %eax
18497 #ifdef CONFIG_VM86
18498 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18499 - movl %esp, %eax
18500 jne work_notifysig_v86 # returning to kernel-space or
18501 # vm86-space
18502 1:
18503 -#else
18504 - movl %esp, %eax
18505 #endif
18506 TRACE_IRQS_ON
18507 ENABLE_INTERRUPTS(CLBR_NONE)
18508 @@ -653,7 +878,7 @@ work_notifysig_v86:
18509 movl %eax, %esp
18510 jmp 1b
18511 #endif
18512 -END(work_pending)
18513 +ENDPROC(work_pending)
18514
18515 # perform syscall exit tracing
18516 ALIGN
18517 @@ -661,11 +886,14 @@ syscall_trace_entry:
18518 movl $-ENOSYS,PT_EAX(%esp)
18519 movl %esp, %eax
18520 call syscall_trace_enter
18521 +
18522 + pax_erase_kstack
18523 +
18524 /* What it returned is what we'll actually use. */
18525 cmpl $(NR_syscalls), %eax
18526 jnae syscall_call
18527 jmp syscall_exit
18528 -END(syscall_trace_entry)
18529 +ENDPROC(syscall_trace_entry)
18530
18531 # perform syscall exit tracing
18532 ALIGN
18533 @@ -678,21 +906,25 @@ syscall_exit_work:
18534 movl %esp, %eax
18535 call syscall_trace_leave
18536 jmp resume_userspace
18537 -END(syscall_exit_work)
18538 +ENDPROC(syscall_exit_work)
18539 CFI_ENDPROC
18540
18541 RING0_INT_FRAME # can't unwind into user space anyway
18542 syscall_fault:
18543 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18544 + push %ss
18545 + pop %ds
18546 +#endif
18547 ASM_CLAC
18548 GET_THREAD_INFO(%ebp)
18549 movl $-EFAULT,PT_EAX(%esp)
18550 jmp resume_userspace
18551 -END(syscall_fault)
18552 +ENDPROC(syscall_fault)
18553
18554 syscall_badsys:
18555 movl $-ENOSYS,PT_EAX(%esp)
18556 jmp resume_userspace
18557 -END(syscall_badsys)
18558 +ENDPROC(syscall_badsys)
18559 CFI_ENDPROC
18560 /*
18561 * End of kprobes section
18562 @@ -708,8 +940,15 @@ END(syscall_badsys)
18563 * normal stack and adjusts ESP with the matching offset.
18564 */
18565 /* fixup the stack */
18566 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
18567 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
18568 +#ifdef CONFIG_SMP
18569 + movl PER_CPU_VAR(cpu_number), %ebx
18570 + shll $PAGE_SHIFT_asm, %ebx
18571 + addl $cpu_gdt_table, %ebx
18572 +#else
18573 + movl $cpu_gdt_table, %ebx
18574 +#endif
18575 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
18576 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
18577 shl $16, %eax
18578 addl %esp, %eax /* the adjusted stack pointer */
18579 pushl_cfi $__KERNEL_DS
18580 @@ -762,7 +1001,7 @@ vector=vector+1
18581 .endr
18582 2: jmp common_interrupt
18583 .endr
18584 -END(irq_entries_start)
18585 +ENDPROC(irq_entries_start)
18586
18587 .previous
18588 END(interrupt)
18589 @@ -813,7 +1052,7 @@ ENTRY(coprocessor_error)
18590 pushl_cfi $do_coprocessor_error
18591 jmp error_code
18592 CFI_ENDPROC
18593 -END(coprocessor_error)
18594 +ENDPROC(coprocessor_error)
18595
18596 ENTRY(simd_coprocessor_error)
18597 RING0_INT_FRAME
18598 @@ -835,7 +1074,7 @@ ENTRY(simd_coprocessor_error)
18599 #endif
18600 jmp error_code
18601 CFI_ENDPROC
18602 -END(simd_coprocessor_error)
18603 +ENDPROC(simd_coprocessor_error)
18604
18605 ENTRY(device_not_available)
18606 RING0_INT_FRAME
18607 @@ -844,18 +1083,18 @@ ENTRY(device_not_available)
18608 pushl_cfi $do_device_not_available
18609 jmp error_code
18610 CFI_ENDPROC
18611 -END(device_not_available)
18612 +ENDPROC(device_not_available)
18613
18614 #ifdef CONFIG_PARAVIRT
18615 ENTRY(native_iret)
18616 iret
18617 _ASM_EXTABLE(native_iret, iret_exc)
18618 -END(native_iret)
18619 +ENDPROC(native_iret)
18620
18621 ENTRY(native_irq_enable_sysexit)
18622 sti
18623 sysexit
18624 -END(native_irq_enable_sysexit)
18625 +ENDPROC(native_irq_enable_sysexit)
18626 #endif
18627
18628 ENTRY(overflow)
18629 @@ -865,7 +1104,7 @@ ENTRY(overflow)
18630 pushl_cfi $do_overflow
18631 jmp error_code
18632 CFI_ENDPROC
18633 -END(overflow)
18634 +ENDPROC(overflow)
18635
18636 ENTRY(bounds)
18637 RING0_INT_FRAME
18638 @@ -874,7 +1113,7 @@ ENTRY(bounds)
18639 pushl_cfi $do_bounds
18640 jmp error_code
18641 CFI_ENDPROC
18642 -END(bounds)
18643 +ENDPROC(bounds)
18644
18645 ENTRY(invalid_op)
18646 RING0_INT_FRAME
18647 @@ -883,7 +1122,7 @@ ENTRY(invalid_op)
18648 pushl_cfi $do_invalid_op
18649 jmp error_code
18650 CFI_ENDPROC
18651 -END(invalid_op)
18652 +ENDPROC(invalid_op)
18653
18654 ENTRY(coprocessor_segment_overrun)
18655 RING0_INT_FRAME
18656 @@ -892,7 +1131,7 @@ ENTRY(coprocessor_segment_overrun)
18657 pushl_cfi $do_coprocessor_segment_overrun
18658 jmp error_code
18659 CFI_ENDPROC
18660 -END(coprocessor_segment_overrun)
18661 +ENDPROC(coprocessor_segment_overrun)
18662
18663 ENTRY(invalid_TSS)
18664 RING0_EC_FRAME
18665 @@ -900,7 +1139,7 @@ ENTRY(invalid_TSS)
18666 pushl_cfi $do_invalid_TSS
18667 jmp error_code
18668 CFI_ENDPROC
18669 -END(invalid_TSS)
18670 +ENDPROC(invalid_TSS)
18671
18672 ENTRY(segment_not_present)
18673 RING0_EC_FRAME
18674 @@ -908,7 +1147,7 @@ ENTRY(segment_not_present)
18675 pushl_cfi $do_segment_not_present
18676 jmp error_code
18677 CFI_ENDPROC
18678 -END(segment_not_present)
18679 +ENDPROC(segment_not_present)
18680
18681 ENTRY(stack_segment)
18682 RING0_EC_FRAME
18683 @@ -916,7 +1155,7 @@ ENTRY(stack_segment)
18684 pushl_cfi $do_stack_segment
18685 jmp error_code
18686 CFI_ENDPROC
18687 -END(stack_segment)
18688 +ENDPROC(stack_segment)
18689
18690 ENTRY(alignment_check)
18691 RING0_EC_FRAME
18692 @@ -924,7 +1163,7 @@ ENTRY(alignment_check)
18693 pushl_cfi $do_alignment_check
18694 jmp error_code
18695 CFI_ENDPROC
18696 -END(alignment_check)
18697 +ENDPROC(alignment_check)
18698
18699 ENTRY(divide_error)
18700 RING0_INT_FRAME
18701 @@ -933,7 +1172,7 @@ ENTRY(divide_error)
18702 pushl_cfi $do_divide_error
18703 jmp error_code
18704 CFI_ENDPROC
18705 -END(divide_error)
18706 +ENDPROC(divide_error)
18707
18708 #ifdef CONFIG_X86_MCE
18709 ENTRY(machine_check)
18710 @@ -943,7 +1182,7 @@ ENTRY(machine_check)
18711 pushl_cfi machine_check_vector
18712 jmp error_code
18713 CFI_ENDPROC
18714 -END(machine_check)
18715 +ENDPROC(machine_check)
18716 #endif
18717
18718 ENTRY(spurious_interrupt_bug)
18719 @@ -953,7 +1192,7 @@ ENTRY(spurious_interrupt_bug)
18720 pushl_cfi $do_spurious_interrupt_bug
18721 jmp error_code
18722 CFI_ENDPROC
18723 -END(spurious_interrupt_bug)
18724 +ENDPROC(spurious_interrupt_bug)
18725 /*
18726 * End of kprobes section
18727 */
18728 @@ -1063,7 +1302,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
18729
18730 ENTRY(mcount)
18731 ret
18732 -END(mcount)
18733 +ENDPROC(mcount)
18734
18735 ENTRY(ftrace_caller)
18736 cmpl $0, function_trace_stop
18737 @@ -1096,7 +1335,7 @@ ftrace_graph_call:
18738 .globl ftrace_stub
18739 ftrace_stub:
18740 ret
18741 -END(ftrace_caller)
18742 +ENDPROC(ftrace_caller)
18743
18744 ENTRY(ftrace_regs_caller)
18745 pushf /* push flags before compare (in cs location) */
18746 @@ -1197,7 +1436,7 @@ trace:
18747 popl %ecx
18748 popl %eax
18749 jmp ftrace_stub
18750 -END(mcount)
18751 +ENDPROC(mcount)
18752 #endif /* CONFIG_DYNAMIC_FTRACE */
18753 #endif /* CONFIG_FUNCTION_TRACER */
18754
18755 @@ -1215,7 +1454,7 @@ ENTRY(ftrace_graph_caller)
18756 popl %ecx
18757 popl %eax
18758 ret
18759 -END(ftrace_graph_caller)
18760 +ENDPROC(ftrace_graph_caller)
18761
18762 .globl return_to_handler
18763 return_to_handler:
18764 @@ -1271,15 +1510,18 @@ error_code:
18765 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
18766 REG_TO_PTGS %ecx
18767 SET_KERNEL_GS %ecx
18768 - movl $(__USER_DS), %ecx
18769 + movl $(__KERNEL_DS), %ecx
18770 movl %ecx, %ds
18771 movl %ecx, %es
18772 +
18773 + pax_enter_kernel
18774 +
18775 TRACE_IRQS_OFF
18776 movl %esp,%eax # pt_regs pointer
18777 call *%edi
18778 jmp ret_from_exception
18779 CFI_ENDPROC
18780 -END(page_fault)
18781 +ENDPROC(page_fault)
18782
18783 /*
18784 * Debug traps and NMI can happen at the one SYSENTER instruction
18785 @@ -1322,7 +1564,7 @@ debug_stack_correct:
18786 call do_debug
18787 jmp ret_from_exception
18788 CFI_ENDPROC
18789 -END(debug)
18790 +ENDPROC(debug)
18791
18792 /*
18793 * NMI is doubly nasty. It can happen _while_ we're handling
18794 @@ -1360,6 +1602,9 @@ nmi_stack_correct:
18795 xorl %edx,%edx # zero error code
18796 movl %esp,%eax # pt_regs pointer
18797 call do_nmi
18798 +
18799 + pax_exit_kernel
18800 +
18801 jmp restore_all_notrace
18802 CFI_ENDPROC
18803
18804 @@ -1396,12 +1641,15 @@ nmi_espfix_stack:
18805 FIXUP_ESPFIX_STACK # %eax == %esp
18806 xorl %edx,%edx # zero error code
18807 call do_nmi
18808 +
18809 + pax_exit_kernel
18810 +
18811 RESTORE_REGS
18812 lss 12+4(%esp), %esp # back to espfix stack
18813 CFI_ADJUST_CFA_OFFSET -24
18814 jmp irq_return
18815 CFI_ENDPROC
18816 -END(nmi)
18817 +ENDPROC(nmi)
18818
18819 ENTRY(int3)
18820 RING0_INT_FRAME
18821 @@ -1414,14 +1662,14 @@ ENTRY(int3)
18822 call do_int3
18823 jmp ret_from_exception
18824 CFI_ENDPROC
18825 -END(int3)
18826 +ENDPROC(int3)
18827
18828 ENTRY(general_protection)
18829 RING0_EC_FRAME
18830 pushl_cfi $do_general_protection
18831 jmp error_code
18832 CFI_ENDPROC
18833 -END(general_protection)
18834 +ENDPROC(general_protection)
18835
18836 #ifdef CONFIG_KVM_GUEST
18837 ENTRY(async_page_fault)
18838 @@ -1430,7 +1678,7 @@ ENTRY(async_page_fault)
18839 pushl_cfi $do_async_page_fault
18840 jmp error_code
18841 CFI_ENDPROC
18842 -END(async_page_fault)
18843 +ENDPROC(async_page_fault)
18844 #endif
18845
18846 /*
18847 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
18848 index c1d01e6..5625dce 100644
18849 --- a/arch/x86/kernel/entry_64.S
18850 +++ b/arch/x86/kernel/entry_64.S
18851 @@ -59,6 +59,8 @@
18852 #include <asm/context_tracking.h>
18853 #include <asm/smap.h>
18854 #include <linux/err.h>
18855 +#include <asm/pgtable.h>
18856 +#include <asm/alternative-asm.h>
18857
18858 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
18859 #include <linux/elf-em.h>
18860 @@ -80,8 +82,9 @@
18861 #ifdef CONFIG_DYNAMIC_FTRACE
18862
18863 ENTRY(function_hook)
18864 + pax_force_retaddr
18865 retq
18866 -END(function_hook)
18867 +ENDPROC(function_hook)
18868
18869 /* skip is set if stack has been adjusted */
18870 .macro ftrace_caller_setup skip=0
18871 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
18872 #endif
18873
18874 GLOBAL(ftrace_stub)
18875 + pax_force_retaddr
18876 retq
18877 -END(ftrace_caller)
18878 +ENDPROC(ftrace_caller)
18879
18880 ENTRY(ftrace_regs_caller)
18881 /* Save the current flags before compare (in SS location)*/
18882 @@ -191,7 +195,7 @@ ftrace_restore_flags:
18883 popfq
18884 jmp ftrace_stub
18885
18886 -END(ftrace_regs_caller)
18887 +ENDPROC(ftrace_regs_caller)
18888
18889
18890 #else /* ! CONFIG_DYNAMIC_FTRACE */
18891 @@ -212,6 +216,7 @@ ENTRY(function_hook)
18892 #endif
18893
18894 GLOBAL(ftrace_stub)
18895 + pax_force_retaddr
18896 retq
18897
18898 trace:
18899 @@ -225,12 +230,13 @@ trace:
18900 #endif
18901 subq $MCOUNT_INSN_SIZE, %rdi
18902
18903 + pax_force_fptr ftrace_trace_function
18904 call *ftrace_trace_function
18905
18906 MCOUNT_RESTORE_FRAME
18907
18908 jmp ftrace_stub
18909 -END(function_hook)
18910 +ENDPROC(function_hook)
18911 #endif /* CONFIG_DYNAMIC_FTRACE */
18912 #endif /* CONFIG_FUNCTION_TRACER */
18913
18914 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
18915
18916 MCOUNT_RESTORE_FRAME
18917
18918 + pax_force_retaddr
18919 retq
18920 -END(ftrace_graph_caller)
18921 +ENDPROC(ftrace_graph_caller)
18922
18923 GLOBAL(return_to_handler)
18924 subq $24, %rsp
18925 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
18926 movq 8(%rsp), %rdx
18927 movq (%rsp), %rax
18928 addq $24, %rsp
18929 + pax_force_fptr %rdi
18930 jmp *%rdi
18931 +ENDPROC(return_to_handler)
18932 #endif
18933
18934
18935 @@ -284,6 +293,282 @@ ENTRY(native_usergs_sysret64)
18936 ENDPROC(native_usergs_sysret64)
18937 #endif /* CONFIG_PARAVIRT */
18938
18939 + .macro ljmpq sel, off
18940 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
18941 + .byte 0x48; ljmp *1234f(%rip)
18942 + .pushsection .rodata
18943 + .align 16
18944 + 1234: .quad \off; .word \sel
18945 + .popsection
18946 +#else
18947 + pushq $\sel
18948 + pushq $\off
18949 + lretq
18950 +#endif
18951 + .endm
18952 +
18953 + .macro pax_enter_kernel
18954 + pax_set_fptr_mask
18955 +#ifdef CONFIG_PAX_KERNEXEC
18956 + call pax_enter_kernel
18957 +#endif
18958 + .endm
18959 +
18960 + .macro pax_exit_kernel
18961 +#ifdef CONFIG_PAX_KERNEXEC
18962 + call pax_exit_kernel
18963 +#endif
18964 + .endm
18965 +
18966 +#ifdef CONFIG_PAX_KERNEXEC
18967 +ENTRY(pax_enter_kernel)
18968 + pushq %rdi
18969 +
18970 +#ifdef CONFIG_PARAVIRT
18971 + PV_SAVE_REGS(CLBR_RDI)
18972 +#endif
18973 +
18974 + GET_CR0_INTO_RDI
18975 + bts $16,%rdi
18976 + jnc 3f
18977 + mov %cs,%edi
18978 + cmp $__KERNEL_CS,%edi
18979 + jnz 2f
18980 +1:
18981 +
18982 +#ifdef CONFIG_PARAVIRT
18983 + PV_RESTORE_REGS(CLBR_RDI)
18984 +#endif
18985 +
18986 + popq %rdi
18987 + pax_force_retaddr
18988 + retq
18989 +
18990 +2: ljmpq __KERNEL_CS,1b
18991 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
18992 +4: SET_RDI_INTO_CR0
18993 + jmp 1b
18994 +ENDPROC(pax_enter_kernel)
18995 +
18996 +ENTRY(pax_exit_kernel)
18997 + pushq %rdi
18998 +
18999 +#ifdef CONFIG_PARAVIRT
19000 + PV_SAVE_REGS(CLBR_RDI)
19001 +#endif
19002 +
19003 + mov %cs,%rdi
19004 + cmp $__KERNEXEC_KERNEL_CS,%edi
19005 + jz 2f
19006 + GET_CR0_INTO_RDI
19007 + bts $16,%rdi
19008 + jnc 4f
19009 +1:
19010 +
19011 +#ifdef CONFIG_PARAVIRT
19012 + PV_RESTORE_REGS(CLBR_RDI);
19013 +#endif
19014 +
19015 + popq %rdi
19016 + pax_force_retaddr
19017 + retq
19018 +
19019 +2: GET_CR0_INTO_RDI
19020 + btr $16,%rdi
19021 + jnc 4f
19022 + ljmpq __KERNEL_CS,3f
19023 +3: SET_RDI_INTO_CR0
19024 + jmp 1b
19025 +4: ud2
19026 + jmp 4b
19027 +ENDPROC(pax_exit_kernel)
19028 +#endif
19029 +
19030 + .macro pax_enter_kernel_user
19031 + pax_set_fptr_mask
19032 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19033 + call pax_enter_kernel_user
19034 +#endif
19035 + .endm
19036 +
19037 + .macro pax_exit_kernel_user
19038 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19039 + call pax_exit_kernel_user
19040 +#endif
19041 +#ifdef CONFIG_PAX_RANDKSTACK
19042 + pushq %rax
19043 + call pax_randomize_kstack
19044 + popq %rax
19045 +#endif
19046 + .endm
19047 +
19048 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19049 +ENTRY(pax_enter_kernel_user)
19050 + pushq %rdi
19051 + pushq %rbx
19052 +
19053 +#ifdef CONFIG_PARAVIRT
19054 + PV_SAVE_REGS(CLBR_RDI)
19055 +#endif
19056 +
19057 + GET_CR3_INTO_RDI
19058 + mov %rdi,%rbx
19059 + add $__START_KERNEL_map,%rbx
19060 + sub phys_base(%rip),%rbx
19061 +
19062 +#ifdef CONFIG_PARAVIRT
19063 + pushq %rdi
19064 + cmpl $0, pv_info+PARAVIRT_enabled
19065 + jz 1f
19066 + i = 0
19067 + .rept USER_PGD_PTRS
19068 + mov i*8(%rbx),%rsi
19069 + mov $0,%sil
19070 + lea i*8(%rbx),%rdi
19071 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19072 + i = i + 1
19073 + .endr
19074 + jmp 2f
19075 +1:
19076 +#endif
19077 +
19078 + i = 0
19079 + .rept USER_PGD_PTRS
19080 + movb $0,i*8(%rbx)
19081 + i = i + 1
19082 + .endr
19083 +
19084 +#ifdef CONFIG_PARAVIRT
19085 +2: popq %rdi
19086 +#endif
19087 + SET_RDI_INTO_CR3
19088 +
19089 +#ifdef CONFIG_PAX_KERNEXEC
19090 + GET_CR0_INTO_RDI
19091 + bts $16,%rdi
19092 + SET_RDI_INTO_CR0
19093 +#endif
19094 +
19095 +#ifdef CONFIG_PARAVIRT
19096 + PV_RESTORE_REGS(CLBR_RDI)
19097 +#endif
19098 +
19099 + popq %rbx
19100 + popq %rdi
19101 + pax_force_retaddr
19102 + retq
19103 +ENDPROC(pax_enter_kernel_user)
19104 +
19105 +ENTRY(pax_exit_kernel_user)
19106 + push %rdi
19107 +
19108 +#ifdef CONFIG_PARAVIRT
19109 + pushq %rbx
19110 + PV_SAVE_REGS(CLBR_RDI)
19111 +#endif
19112 +
19113 +#ifdef CONFIG_PAX_KERNEXEC
19114 + GET_CR0_INTO_RDI
19115 + btr $16,%rdi
19116 + jnc 3f
19117 + SET_RDI_INTO_CR0
19118 +#endif
19119 +
19120 + GET_CR3_INTO_RDI
19121 + add $__START_KERNEL_map,%rdi
19122 + sub phys_base(%rip),%rdi
19123 +
19124 +#ifdef CONFIG_PARAVIRT
19125 + cmpl $0, pv_info+PARAVIRT_enabled
19126 + jz 1f
19127 + mov %rdi,%rbx
19128 + i = 0
19129 + .rept USER_PGD_PTRS
19130 + mov i*8(%rbx),%rsi
19131 + mov $0x67,%sil
19132 + lea i*8(%rbx),%rdi
19133 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19134 + i = i + 1
19135 + .endr
19136 + jmp 2f
19137 +1:
19138 +#endif
19139 +
19140 + i = 0
19141 + .rept USER_PGD_PTRS
19142 + movb $0x67,i*8(%rdi)
19143 + i = i + 1
19144 + .endr
19145 +
19146 +#ifdef CONFIG_PARAVIRT
19147 +2: PV_RESTORE_REGS(CLBR_RDI)
19148 + popq %rbx
19149 +#endif
19150 +
19151 + popq %rdi
19152 + pax_force_retaddr
19153 + retq
19154 +3: ud2
19155 + jmp 3b
19156 +ENDPROC(pax_exit_kernel_user)
19157 +#endif
19158 +
19159 +.macro pax_erase_kstack
19160 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19161 + call pax_erase_kstack
19162 +#endif
19163 +.endm
19164 +
19165 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19166 +ENTRY(pax_erase_kstack)
19167 + pushq %rdi
19168 + pushq %rcx
19169 + pushq %rax
19170 + pushq %r11
19171 +
19172 + GET_THREAD_INFO(%r11)
19173 + mov TI_lowest_stack(%r11), %rdi
19174 + mov $-0xBEEF, %rax
19175 + std
19176 +
19177 +1: mov %edi, %ecx
19178 + and $THREAD_SIZE_asm - 1, %ecx
19179 + shr $3, %ecx
19180 + repne scasq
19181 + jecxz 2f
19182 +
19183 + cmp $2*8, %ecx
19184 + jc 2f
19185 +
19186 + mov $2*8, %ecx
19187 + repe scasq
19188 + jecxz 2f
19189 + jne 1b
19190 +
19191 +2: cld
19192 + mov %esp, %ecx
19193 + sub %edi, %ecx
19194 +
19195 + cmp $THREAD_SIZE_asm, %rcx
19196 + jb 3f
19197 + ud2
19198 +3:
19199 +
19200 + shr $3, %ecx
19201 + rep stosq
19202 +
19203 + mov TI_task_thread_sp0(%r11), %rdi
19204 + sub $256, %rdi
19205 + mov %rdi, TI_lowest_stack(%r11)
19206 +
19207 + popq %r11
19208 + popq %rax
19209 + popq %rcx
19210 + popq %rdi
19211 + pax_force_retaddr
19212 + ret
19213 +ENDPROC(pax_erase_kstack)
19214 +#endif
19215
19216 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19217 #ifdef CONFIG_TRACE_IRQFLAGS
19218 @@ -375,8 +660,8 @@ ENDPROC(native_usergs_sysret64)
19219 .endm
19220
19221 .macro UNFAKE_STACK_FRAME
19222 - addq $8*6, %rsp
19223 - CFI_ADJUST_CFA_OFFSET -(6*8)
19224 + addq $8*6 + ARG_SKIP, %rsp
19225 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19226 .endm
19227
19228 /*
19229 @@ -463,7 +748,7 @@ ENDPROC(native_usergs_sysret64)
19230 movq %rsp, %rsi
19231
19232 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19233 - testl $3, CS-RBP(%rsi)
19234 + testb $3, CS-RBP(%rsi)
19235 je 1f
19236 SWAPGS
19237 /*
19238 @@ -498,9 +783,10 @@ ENTRY(save_rest)
19239 movq_cfi r15, R15+16
19240 movq %r11, 8(%rsp) /* return address */
19241 FIXUP_TOP_OF_STACK %r11, 16
19242 + pax_force_retaddr
19243 ret
19244 CFI_ENDPROC
19245 -END(save_rest)
19246 +ENDPROC(save_rest)
19247
19248 /* save complete stack frame */
19249 .pushsection .kprobes.text, "ax"
19250 @@ -529,9 +815,10 @@ ENTRY(save_paranoid)
19251 js 1f /* negative -> in kernel */
19252 SWAPGS
19253 xorl %ebx,%ebx
19254 -1: ret
19255 +1: pax_force_retaddr_bts
19256 + ret
19257 CFI_ENDPROC
19258 -END(save_paranoid)
19259 +ENDPROC(save_paranoid)
19260 .popsection
19261
19262 /*
19263 @@ -553,7 +840,7 @@ ENTRY(ret_from_fork)
19264
19265 RESTORE_REST
19266
19267 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19268 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19269 jz 1f
19270
19271 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19272 @@ -571,7 +858,7 @@ ENTRY(ret_from_fork)
19273 RESTORE_REST
19274 jmp int_ret_from_sys_call
19275 CFI_ENDPROC
19276 -END(ret_from_fork)
19277 +ENDPROC(ret_from_fork)
19278
19279 /*
19280 * System call entry. Up to 6 arguments in registers are supported.
19281 @@ -608,7 +895,7 @@ END(ret_from_fork)
19282 ENTRY(system_call)
19283 CFI_STARTPROC simple
19284 CFI_SIGNAL_FRAME
19285 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19286 + CFI_DEF_CFA rsp,0
19287 CFI_REGISTER rip,rcx
19288 /*CFI_REGISTER rflags,r11*/
19289 SWAPGS_UNSAFE_STACK
19290 @@ -621,16 +908,23 @@ GLOBAL(system_call_after_swapgs)
19291
19292 movq %rsp,PER_CPU_VAR(old_rsp)
19293 movq PER_CPU_VAR(kernel_stack),%rsp
19294 + SAVE_ARGS 8*6,0
19295 + pax_enter_kernel_user
19296 +
19297 +#ifdef CONFIG_PAX_RANDKSTACK
19298 + pax_erase_kstack
19299 +#endif
19300 +
19301 /*
19302 * No need to follow this irqs off/on section - it's straight
19303 * and short:
19304 */
19305 ENABLE_INTERRUPTS(CLBR_NONE)
19306 - SAVE_ARGS 8,0
19307 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19308 movq %rcx,RIP-ARGOFFSET(%rsp)
19309 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19310 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19311 + GET_THREAD_INFO(%rcx)
19312 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19313 jnz tracesys
19314 system_call_fastpath:
19315 #if __SYSCALL_MASK == ~0
19316 @@ -640,7 +934,7 @@ system_call_fastpath:
19317 cmpl $__NR_syscall_max,%eax
19318 #endif
19319 ja badsys
19320 - movq %r10,%rcx
19321 + movq R10-ARGOFFSET(%rsp),%rcx
19322 call *sys_call_table(,%rax,8) # XXX: rip relative
19323 movq %rax,RAX-ARGOFFSET(%rsp)
19324 /*
19325 @@ -654,10 +948,13 @@ sysret_check:
19326 LOCKDEP_SYS_EXIT
19327 DISABLE_INTERRUPTS(CLBR_NONE)
19328 TRACE_IRQS_OFF
19329 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19330 + GET_THREAD_INFO(%rcx)
19331 + movl TI_flags(%rcx),%edx
19332 andl %edi,%edx
19333 jnz sysret_careful
19334 CFI_REMEMBER_STATE
19335 + pax_exit_kernel_user
19336 + pax_erase_kstack
19337 /*
19338 * sysretq will re-enable interrupts:
19339 */
19340 @@ -709,14 +1006,18 @@ badsys:
19341 * jump back to the normal fast path.
19342 */
19343 auditsys:
19344 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19345 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19346 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19347 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19348 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19349 movq %rax,%rsi /* 2nd arg: syscall number */
19350 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19351 call __audit_syscall_entry
19352 +
19353 + pax_erase_kstack
19354 +
19355 LOAD_ARGS 0 /* reload call-clobbered registers */
19356 + pax_set_fptr_mask
19357 jmp system_call_fastpath
19358
19359 /*
19360 @@ -737,7 +1038,7 @@ sysret_audit:
19361 /* Do syscall tracing */
19362 tracesys:
19363 #ifdef CONFIG_AUDITSYSCALL
19364 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19365 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19366 jz auditsys
19367 #endif
19368 SAVE_REST
19369 @@ -745,12 +1046,16 @@ tracesys:
19370 FIXUP_TOP_OF_STACK %rdi
19371 movq %rsp,%rdi
19372 call syscall_trace_enter
19373 +
19374 + pax_erase_kstack
19375 +
19376 /*
19377 * Reload arg registers from stack in case ptrace changed them.
19378 * We don't reload %rax because syscall_trace_enter() returned
19379 * the value it wants us to use in the table lookup.
19380 */
19381 LOAD_ARGS ARGOFFSET, 1
19382 + pax_set_fptr_mask
19383 RESTORE_REST
19384 #if __SYSCALL_MASK == ~0
19385 cmpq $__NR_syscall_max,%rax
19386 @@ -759,7 +1064,7 @@ tracesys:
19387 cmpl $__NR_syscall_max,%eax
19388 #endif
19389 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19390 - movq %r10,%rcx /* fixup for C */
19391 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19392 call *sys_call_table(,%rax,8)
19393 movq %rax,RAX-ARGOFFSET(%rsp)
19394 /* Use IRET because user could have changed frame */
19395 @@ -780,7 +1085,9 @@ GLOBAL(int_with_check)
19396 andl %edi,%edx
19397 jnz int_careful
19398 andl $~TS_COMPAT,TI_status(%rcx)
19399 - jmp retint_swapgs
19400 + pax_exit_kernel_user
19401 + pax_erase_kstack
19402 + jmp retint_swapgs_pax
19403
19404 /* Either reschedule or signal or syscall exit tracking needed. */
19405 /* First do a reschedule test. */
19406 @@ -826,7 +1133,7 @@ int_restore_rest:
19407 TRACE_IRQS_OFF
19408 jmp int_with_check
19409 CFI_ENDPROC
19410 -END(system_call)
19411 +ENDPROC(system_call)
19412
19413 .macro FORK_LIKE func
19414 ENTRY(stub_\func)
19415 @@ -839,9 +1146,10 @@ ENTRY(stub_\func)
19416 DEFAULT_FRAME 0 8 /* offset 8: return address */
19417 call sys_\func
19418 RESTORE_TOP_OF_STACK %r11, 8
19419 + pax_force_retaddr
19420 ret $REST_SKIP /* pop extended registers */
19421 CFI_ENDPROC
19422 -END(stub_\func)
19423 +ENDPROC(stub_\func)
19424 .endm
19425
19426 .macro FIXED_FRAME label,func
19427 @@ -851,9 +1159,10 @@ ENTRY(\label)
19428 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
19429 call \func
19430 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
19431 + pax_force_retaddr
19432 ret
19433 CFI_ENDPROC
19434 -END(\label)
19435 +ENDPROC(\label)
19436 .endm
19437
19438 FORK_LIKE clone
19439 @@ -870,9 +1179,10 @@ ENTRY(ptregscall_common)
19440 movq_cfi_restore R12+8, r12
19441 movq_cfi_restore RBP+8, rbp
19442 movq_cfi_restore RBX+8, rbx
19443 + pax_force_retaddr
19444 ret $REST_SKIP /* pop extended registers */
19445 CFI_ENDPROC
19446 -END(ptregscall_common)
19447 +ENDPROC(ptregscall_common)
19448
19449 ENTRY(stub_execve)
19450 CFI_STARTPROC
19451 @@ -885,7 +1195,7 @@ ENTRY(stub_execve)
19452 RESTORE_REST
19453 jmp int_ret_from_sys_call
19454 CFI_ENDPROC
19455 -END(stub_execve)
19456 +ENDPROC(stub_execve)
19457
19458 /*
19459 * sigreturn is special because it needs to restore all registers on return.
19460 @@ -902,7 +1212,7 @@ ENTRY(stub_rt_sigreturn)
19461 RESTORE_REST
19462 jmp int_ret_from_sys_call
19463 CFI_ENDPROC
19464 -END(stub_rt_sigreturn)
19465 +ENDPROC(stub_rt_sigreturn)
19466
19467 #ifdef CONFIG_X86_X32_ABI
19468 ENTRY(stub_x32_rt_sigreturn)
19469 @@ -916,7 +1226,7 @@ ENTRY(stub_x32_rt_sigreturn)
19470 RESTORE_REST
19471 jmp int_ret_from_sys_call
19472 CFI_ENDPROC
19473 -END(stub_x32_rt_sigreturn)
19474 +ENDPROC(stub_x32_rt_sigreturn)
19475
19476 ENTRY(stub_x32_execve)
19477 CFI_STARTPROC
19478 @@ -930,7 +1240,7 @@ ENTRY(stub_x32_execve)
19479 RESTORE_REST
19480 jmp int_ret_from_sys_call
19481 CFI_ENDPROC
19482 -END(stub_x32_execve)
19483 +ENDPROC(stub_x32_execve)
19484
19485 #endif
19486
19487 @@ -967,7 +1277,7 @@ vector=vector+1
19488 2: jmp common_interrupt
19489 .endr
19490 CFI_ENDPROC
19491 -END(irq_entries_start)
19492 +ENDPROC(irq_entries_start)
19493
19494 .previous
19495 END(interrupt)
19496 @@ -987,6 +1297,16 @@ END(interrupt)
19497 subq $ORIG_RAX-RBP, %rsp
19498 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19499 SAVE_ARGS_IRQ
19500 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19501 + testb $3, CS(%rdi)
19502 + jnz 1f
19503 + pax_enter_kernel
19504 + jmp 2f
19505 +1: pax_enter_kernel_user
19506 +2:
19507 +#else
19508 + pax_enter_kernel
19509 +#endif
19510 call \func
19511 .endm
19512
19513 @@ -1019,7 +1339,7 @@ ret_from_intr:
19514
19515 exit_intr:
19516 GET_THREAD_INFO(%rcx)
19517 - testl $3,CS-ARGOFFSET(%rsp)
19518 + testb $3,CS-ARGOFFSET(%rsp)
19519 je retint_kernel
19520
19521 /* Interrupt came from user space */
19522 @@ -1041,12 +1361,16 @@ retint_swapgs: /* return to user-space */
19523 * The iretq could re-enable interrupts:
19524 */
19525 DISABLE_INTERRUPTS(CLBR_ANY)
19526 + pax_exit_kernel_user
19527 +retint_swapgs_pax:
19528 TRACE_IRQS_IRETQ
19529 SWAPGS
19530 jmp restore_args
19531
19532 retint_restore_args: /* return to kernel space */
19533 DISABLE_INTERRUPTS(CLBR_ANY)
19534 + pax_exit_kernel
19535 + pax_force_retaddr (RIP-ARGOFFSET)
19536 /*
19537 * The iretq could re-enable interrupts:
19538 */
19539 @@ -1129,7 +1453,7 @@ ENTRY(retint_kernel)
19540 #endif
19541
19542 CFI_ENDPROC
19543 -END(common_interrupt)
19544 +ENDPROC(common_interrupt)
19545 /*
19546 * End of kprobes section
19547 */
19548 @@ -1147,7 +1471,7 @@ ENTRY(\sym)
19549 interrupt \do_sym
19550 jmp ret_from_intr
19551 CFI_ENDPROC
19552 -END(\sym)
19553 +ENDPROC(\sym)
19554 .endm
19555
19556 #ifdef CONFIG_SMP
19557 @@ -1203,12 +1527,22 @@ ENTRY(\sym)
19558 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19559 call error_entry
19560 DEFAULT_FRAME 0
19561 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19562 + testb $3, CS(%rsp)
19563 + jnz 1f
19564 + pax_enter_kernel
19565 + jmp 2f
19566 +1: pax_enter_kernel_user
19567 +2:
19568 +#else
19569 + pax_enter_kernel
19570 +#endif
19571 movq %rsp,%rdi /* pt_regs pointer */
19572 xorl %esi,%esi /* no error code */
19573 call \do_sym
19574 jmp error_exit /* %ebx: no swapgs flag */
19575 CFI_ENDPROC
19576 -END(\sym)
19577 +ENDPROC(\sym)
19578 .endm
19579
19580 .macro paranoidzeroentry sym do_sym
19581 @@ -1221,15 +1555,25 @@ ENTRY(\sym)
19582 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19583 call save_paranoid
19584 TRACE_IRQS_OFF
19585 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19586 + testb $3, CS(%rsp)
19587 + jnz 1f
19588 + pax_enter_kernel
19589 + jmp 2f
19590 +1: pax_enter_kernel_user
19591 +2:
19592 +#else
19593 + pax_enter_kernel
19594 +#endif
19595 movq %rsp,%rdi /* pt_regs pointer */
19596 xorl %esi,%esi /* no error code */
19597 call \do_sym
19598 jmp paranoid_exit /* %ebx: no swapgs flag */
19599 CFI_ENDPROC
19600 -END(\sym)
19601 +ENDPROC(\sym)
19602 .endm
19603
19604 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
19605 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
19606 .macro paranoidzeroentry_ist sym do_sym ist
19607 ENTRY(\sym)
19608 INTR_FRAME
19609 @@ -1240,14 +1584,30 @@ ENTRY(\sym)
19610 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19611 call save_paranoid
19612 TRACE_IRQS_OFF_DEBUG
19613 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19614 + testb $3, CS(%rsp)
19615 + jnz 1f
19616 + pax_enter_kernel
19617 + jmp 2f
19618 +1: pax_enter_kernel_user
19619 +2:
19620 +#else
19621 + pax_enter_kernel
19622 +#endif
19623 movq %rsp,%rdi /* pt_regs pointer */
19624 xorl %esi,%esi /* no error code */
19625 +#ifdef CONFIG_SMP
19626 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
19627 + lea init_tss(%r12), %r12
19628 +#else
19629 + lea init_tss(%rip), %r12
19630 +#endif
19631 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19632 call \do_sym
19633 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19634 jmp paranoid_exit /* %ebx: no swapgs flag */
19635 CFI_ENDPROC
19636 -END(\sym)
19637 +ENDPROC(\sym)
19638 .endm
19639
19640 .macro errorentry sym do_sym
19641 @@ -1259,13 +1619,23 @@ ENTRY(\sym)
19642 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19643 call error_entry
19644 DEFAULT_FRAME 0
19645 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19646 + testb $3, CS(%rsp)
19647 + jnz 1f
19648 + pax_enter_kernel
19649 + jmp 2f
19650 +1: pax_enter_kernel_user
19651 +2:
19652 +#else
19653 + pax_enter_kernel
19654 +#endif
19655 movq %rsp,%rdi /* pt_regs pointer */
19656 movq ORIG_RAX(%rsp),%rsi /* get error code */
19657 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19658 call \do_sym
19659 jmp error_exit /* %ebx: no swapgs flag */
19660 CFI_ENDPROC
19661 -END(\sym)
19662 +ENDPROC(\sym)
19663 .endm
19664
19665 /* error code is on the stack already */
19666 @@ -1279,13 +1649,23 @@ ENTRY(\sym)
19667 call save_paranoid
19668 DEFAULT_FRAME 0
19669 TRACE_IRQS_OFF
19670 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19671 + testb $3, CS(%rsp)
19672 + jnz 1f
19673 + pax_enter_kernel
19674 + jmp 2f
19675 +1: pax_enter_kernel_user
19676 +2:
19677 +#else
19678 + pax_enter_kernel
19679 +#endif
19680 movq %rsp,%rdi /* pt_regs pointer */
19681 movq ORIG_RAX(%rsp),%rsi /* get error code */
19682 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19683 call \do_sym
19684 jmp paranoid_exit /* %ebx: no swapgs flag */
19685 CFI_ENDPROC
19686 -END(\sym)
19687 +ENDPROC(\sym)
19688 .endm
19689
19690 zeroentry divide_error do_divide_error
19691 @@ -1315,9 +1695,10 @@ gs_change:
19692 2: mfence /* workaround */
19693 SWAPGS
19694 popfq_cfi
19695 + pax_force_retaddr
19696 ret
19697 CFI_ENDPROC
19698 -END(native_load_gs_index)
19699 +ENDPROC(native_load_gs_index)
19700
19701 _ASM_EXTABLE(gs_change,bad_gs)
19702 .section .fixup,"ax"
19703 @@ -1345,9 +1726,10 @@ ENTRY(call_softirq)
19704 CFI_DEF_CFA_REGISTER rsp
19705 CFI_ADJUST_CFA_OFFSET -8
19706 decl PER_CPU_VAR(irq_count)
19707 + pax_force_retaddr
19708 ret
19709 CFI_ENDPROC
19710 -END(call_softirq)
19711 +ENDPROC(call_softirq)
19712
19713 #ifdef CONFIG_XEN
19714 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
19715 @@ -1385,7 +1767,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
19716 decl PER_CPU_VAR(irq_count)
19717 jmp error_exit
19718 CFI_ENDPROC
19719 -END(xen_do_hypervisor_callback)
19720 +ENDPROC(xen_do_hypervisor_callback)
19721
19722 /*
19723 * Hypervisor uses this for application faults while it executes.
19724 @@ -1444,7 +1826,7 @@ ENTRY(xen_failsafe_callback)
19725 SAVE_ALL
19726 jmp error_exit
19727 CFI_ENDPROC
19728 -END(xen_failsafe_callback)
19729 +ENDPROC(xen_failsafe_callback)
19730
19731 apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
19732 xen_hvm_callback_vector xen_evtchn_do_upcall
19733 @@ -1498,16 +1880,31 @@ ENTRY(paranoid_exit)
19734 TRACE_IRQS_OFF_DEBUG
19735 testl %ebx,%ebx /* swapgs needed? */
19736 jnz paranoid_restore
19737 - testl $3,CS(%rsp)
19738 + testb $3,CS(%rsp)
19739 jnz paranoid_userspace
19740 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19741 + pax_exit_kernel
19742 + TRACE_IRQS_IRETQ 0
19743 + SWAPGS_UNSAFE_STACK
19744 + RESTORE_ALL 8
19745 + pax_force_retaddr_bts
19746 + jmp irq_return
19747 +#endif
19748 paranoid_swapgs:
19749 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19750 + pax_exit_kernel_user
19751 +#else
19752 + pax_exit_kernel
19753 +#endif
19754 TRACE_IRQS_IRETQ 0
19755 SWAPGS_UNSAFE_STACK
19756 RESTORE_ALL 8
19757 jmp irq_return
19758 paranoid_restore:
19759 + pax_exit_kernel
19760 TRACE_IRQS_IRETQ_DEBUG 0
19761 RESTORE_ALL 8
19762 + pax_force_retaddr_bts
19763 jmp irq_return
19764 paranoid_userspace:
19765 GET_THREAD_INFO(%rcx)
19766 @@ -1536,7 +1933,7 @@ paranoid_schedule:
19767 TRACE_IRQS_OFF
19768 jmp paranoid_userspace
19769 CFI_ENDPROC
19770 -END(paranoid_exit)
19771 +ENDPROC(paranoid_exit)
19772
19773 /*
19774 * Exception entry point. This expects an error code/orig_rax on the stack.
19775 @@ -1563,12 +1960,13 @@ ENTRY(error_entry)
19776 movq_cfi r14, R14+8
19777 movq_cfi r15, R15+8
19778 xorl %ebx,%ebx
19779 - testl $3,CS+8(%rsp)
19780 + testb $3,CS+8(%rsp)
19781 je error_kernelspace
19782 error_swapgs:
19783 SWAPGS
19784 error_sti:
19785 TRACE_IRQS_OFF
19786 + pax_force_retaddr_bts
19787 ret
19788
19789 /*
19790 @@ -1595,7 +1993,7 @@ bstep_iret:
19791 movq %rcx,RIP+8(%rsp)
19792 jmp error_swapgs
19793 CFI_ENDPROC
19794 -END(error_entry)
19795 +ENDPROC(error_entry)
19796
19797
19798 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
19799 @@ -1615,7 +2013,7 @@ ENTRY(error_exit)
19800 jnz retint_careful
19801 jmp retint_swapgs
19802 CFI_ENDPROC
19803 -END(error_exit)
19804 +ENDPROC(error_exit)
19805
19806 /*
19807 * Test if a given stack is an NMI stack or not.
19808 @@ -1673,9 +2071,11 @@ ENTRY(nmi)
19809 * If %cs was not the kernel segment, then the NMI triggered in user
19810 * space, which means it is definitely not nested.
19811 */
19812 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
19813 + je 1f
19814 cmpl $__KERNEL_CS, 16(%rsp)
19815 jne first_nmi
19816 -
19817 +1:
19818 /*
19819 * Check the special variable on the stack to see if NMIs are
19820 * executing.
19821 @@ -1709,8 +2109,7 @@ nested_nmi:
19822
19823 1:
19824 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
19825 - leaq -1*8(%rsp), %rdx
19826 - movq %rdx, %rsp
19827 + subq $8, %rsp
19828 CFI_ADJUST_CFA_OFFSET 1*8
19829 leaq -10*8(%rsp), %rdx
19830 pushq_cfi $__KERNEL_DS
19831 @@ -1728,6 +2127,7 @@ nested_nmi_out:
19832 CFI_RESTORE rdx
19833
19834 /* No need to check faults here */
19835 + pax_force_retaddr_bts
19836 INTERRUPT_RETURN
19837
19838 CFI_RESTORE_STATE
19839 @@ -1844,6 +2244,17 @@ end_repeat_nmi:
19840 */
19841 movq %cr2, %r12
19842
19843 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19844 + testb $3, CS(%rsp)
19845 + jnz 1f
19846 + pax_enter_kernel
19847 + jmp 2f
19848 +1: pax_enter_kernel_user
19849 +2:
19850 +#else
19851 + pax_enter_kernel
19852 +#endif
19853 +
19854 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
19855 movq %rsp,%rdi
19856 movq $-1,%rsi
19857 @@ -1859,23 +2270,34 @@ end_repeat_nmi:
19858 testl %ebx,%ebx /* swapgs needed? */
19859 jnz nmi_restore
19860 nmi_swapgs:
19861 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19862 + pax_exit_kernel_user
19863 +#else
19864 + pax_exit_kernel
19865 +#endif
19866 SWAPGS_UNSAFE_STACK
19867 + RESTORE_ALL 6*8
19868 + /* Clear the NMI executing stack variable */
19869 + movq $0, 5*8(%rsp)
19870 + jmp irq_return
19871 nmi_restore:
19872 + pax_exit_kernel
19873 /* Pop the extra iret frame at once */
19874 RESTORE_ALL 6*8
19875 + pax_force_retaddr_bts
19876
19877 /* Clear the NMI executing stack variable */
19878 movq $0, 5*8(%rsp)
19879 jmp irq_return
19880 CFI_ENDPROC
19881 -END(nmi)
19882 +ENDPROC(nmi)
19883
19884 ENTRY(ignore_sysret)
19885 CFI_STARTPROC
19886 mov $-ENOSYS,%eax
19887 sysret
19888 CFI_ENDPROC
19889 -END(ignore_sysret)
19890 +ENDPROC(ignore_sysret)
19891
19892 /*
19893 * End of kprobes section
19894 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
19895 index 42a392a..fbbd930 100644
19896 --- a/arch/x86/kernel/ftrace.c
19897 +++ b/arch/x86/kernel/ftrace.c
19898 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
19899 {
19900 unsigned char replaced[MCOUNT_INSN_SIZE];
19901
19902 + ip = ktla_ktva(ip);
19903 +
19904 /*
19905 * Note: Due to modules and __init, code can
19906 * disappear and change, we need to protect against faulting
19907 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
19908 unsigned char old[MCOUNT_INSN_SIZE], *new;
19909 int ret;
19910
19911 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
19912 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
19913 new = ftrace_call_replace(ip, (unsigned long)func);
19914
19915 /* See comment above by declaration of modifying_ftrace_code */
19916 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
19917 /* Also update the regs callback function */
19918 if (!ret) {
19919 ip = (unsigned long)(&ftrace_regs_call);
19920 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
19921 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
19922 new = ftrace_call_replace(ip, (unsigned long)func);
19923 ret = ftrace_modify_code(ip, old, new);
19924 }
19925 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
19926 * kernel identity mapping to modify code.
19927 */
19928 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
19929 - ip = (unsigned long)__va(__pa_symbol(ip));
19930 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
19931
19932 return probe_kernel_write((void *)ip, val, size);
19933 }
19934 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
19935 unsigned char replaced[MCOUNT_INSN_SIZE];
19936 unsigned char brk = BREAKPOINT_INSTRUCTION;
19937
19938 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
19939 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
19940 return -EFAULT;
19941
19942 /* Make sure it is what we expect it to be */
19943 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
19944 return ret;
19945
19946 fail_update:
19947 - probe_kernel_write((void *)ip, &old_code[0], 1);
19948 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
19949 goto out;
19950 }
19951
19952 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
19953 {
19954 unsigned char code[MCOUNT_INSN_SIZE];
19955
19956 + ip = ktla_ktva(ip);
19957 +
19958 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
19959 return -EFAULT;
19960
19961 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
19962 index 1c68ccb..b4bc15c 100644
19963 --- a/arch/x86/kernel/head64.c
19964 +++ b/arch/x86/kernel/head64.c
19965 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
19966 if (console_loglevel == 10)
19967 early_printk("Kernel alive\n");
19968
19969 - clear_page(init_level4_pgt);
19970 /* set init_level4_pgt kernel high mapping*/
19971 init_level4_pgt[511] = early_level4_pgt[511];
19972
19973 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
19974 index 73afd11..d1670f5 100644
19975 --- a/arch/x86/kernel/head_32.S
19976 +++ b/arch/x86/kernel/head_32.S
19977 @@ -26,6 +26,12 @@
19978 /* Physical address */
19979 #define pa(X) ((X) - __PAGE_OFFSET)
19980
19981 +#ifdef CONFIG_PAX_KERNEXEC
19982 +#define ta(X) (X)
19983 +#else
19984 +#define ta(X) ((X) - __PAGE_OFFSET)
19985 +#endif
19986 +
19987 /*
19988 * References to members of the new_cpu_data structure.
19989 */
19990 @@ -55,11 +61,7 @@
19991 * and small than max_low_pfn, otherwise will waste some page table entries
19992 */
19993
19994 -#if PTRS_PER_PMD > 1
19995 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
19996 -#else
19997 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
19998 -#endif
19999 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
20000
20001 /* Number of possible pages in the lowmem region */
20002 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
20003 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
20004 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20005
20006 /*
20007 + * Real beginning of normal "text" segment
20008 + */
20009 +ENTRY(stext)
20010 +ENTRY(_stext)
20011 +
20012 +/*
20013 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20014 * %esi points to the real-mode code as a 32-bit pointer.
20015 * CS and DS must be 4 GB flat segments, but we don't depend on
20016 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20017 * can.
20018 */
20019 __HEAD
20020 +
20021 +#ifdef CONFIG_PAX_KERNEXEC
20022 + jmp startup_32
20023 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20024 +.fill PAGE_SIZE-5,1,0xcc
20025 +#endif
20026 +
20027 ENTRY(startup_32)
20028 movl pa(stack_start),%ecx
20029
20030 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20031 2:
20032 leal -__PAGE_OFFSET(%ecx),%esp
20033
20034 +#ifdef CONFIG_SMP
20035 + movl $pa(cpu_gdt_table),%edi
20036 + movl $__per_cpu_load,%eax
20037 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20038 + rorl $16,%eax
20039 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20040 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20041 + movl $__per_cpu_end - 1,%eax
20042 + subl $__per_cpu_start,%eax
20043 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20044 +#endif
20045 +
20046 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20047 + movl $NR_CPUS,%ecx
20048 + movl $pa(cpu_gdt_table),%edi
20049 +1:
20050 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20051 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20052 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20053 + addl $PAGE_SIZE_asm,%edi
20054 + loop 1b
20055 +#endif
20056 +
20057 +#ifdef CONFIG_PAX_KERNEXEC
20058 + movl $pa(boot_gdt),%edi
20059 + movl $__LOAD_PHYSICAL_ADDR,%eax
20060 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20061 + rorl $16,%eax
20062 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20063 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20064 + rorl $16,%eax
20065 +
20066 + ljmp $(__BOOT_CS),$1f
20067 +1:
20068 +
20069 + movl $NR_CPUS,%ecx
20070 + movl $pa(cpu_gdt_table),%edi
20071 + addl $__PAGE_OFFSET,%eax
20072 +1:
20073 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20074 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20075 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20076 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20077 + rorl $16,%eax
20078 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20079 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20080 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20081 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20082 + rorl $16,%eax
20083 + addl $PAGE_SIZE_asm,%edi
20084 + loop 1b
20085 +#endif
20086 +
20087 /*
20088 * Clear BSS first so that there are no surprises...
20089 */
20090 @@ -201,8 +269,11 @@ ENTRY(startup_32)
20091 movl %eax, pa(max_pfn_mapped)
20092
20093 /* Do early initialization of the fixmap area */
20094 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20095 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20096 +#ifdef CONFIG_COMPAT_VDSO
20097 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20098 +#else
20099 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20100 +#endif
20101 #else /* Not PAE */
20102
20103 page_pde_offset = (__PAGE_OFFSET >> 20);
20104 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20105 movl %eax, pa(max_pfn_mapped)
20106
20107 /* Do early initialization of the fixmap area */
20108 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20109 - movl %eax,pa(initial_page_table+0xffc)
20110 +#ifdef CONFIG_COMPAT_VDSO
20111 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20112 +#else
20113 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20114 +#endif
20115 #endif
20116
20117 #ifdef CONFIG_PARAVIRT
20118 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20119 cmpl $num_subarch_entries, %eax
20120 jae bad_subarch
20121
20122 - movl pa(subarch_entries)(,%eax,4), %eax
20123 - subl $__PAGE_OFFSET, %eax
20124 - jmp *%eax
20125 + jmp *pa(subarch_entries)(,%eax,4)
20126
20127 bad_subarch:
20128 WEAK(lguest_entry)
20129 @@ -261,10 +333,10 @@ WEAK(xen_entry)
20130 __INITDATA
20131
20132 subarch_entries:
20133 - .long default_entry /* normal x86/PC */
20134 - .long lguest_entry /* lguest hypervisor */
20135 - .long xen_entry /* Xen hypervisor */
20136 - .long default_entry /* Moorestown MID */
20137 + .long ta(default_entry) /* normal x86/PC */
20138 + .long ta(lguest_entry) /* lguest hypervisor */
20139 + .long ta(xen_entry) /* Xen hypervisor */
20140 + .long ta(default_entry) /* Moorestown MID */
20141 num_subarch_entries = (. - subarch_entries) / 4
20142 .previous
20143 #else
20144 @@ -355,6 +427,7 @@ default_entry:
20145 movl pa(mmu_cr4_features),%eax
20146 movl %eax,%cr4
20147
20148 +#ifdef CONFIG_X86_PAE
20149 testb $X86_CR4_PAE, %al # check if PAE is enabled
20150 jz enable_paging
20151
20152 @@ -383,6 +456,9 @@ default_entry:
20153 /* Make changes effective */
20154 wrmsr
20155
20156 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20157 +#endif
20158 +
20159 enable_paging:
20160
20161 /*
20162 @@ -451,14 +527,20 @@ is486:
20163 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20164 movl %eax,%ss # after changing gdt.
20165
20166 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20167 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20168 movl %eax,%ds
20169 movl %eax,%es
20170
20171 movl $(__KERNEL_PERCPU), %eax
20172 movl %eax,%fs # set this cpu's percpu
20173
20174 +#ifdef CONFIG_CC_STACKPROTECTOR
20175 movl $(__KERNEL_STACK_CANARY),%eax
20176 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20177 + movl $(__USER_DS),%eax
20178 +#else
20179 + xorl %eax,%eax
20180 +#endif
20181 movl %eax,%gs
20182
20183 xorl %eax,%eax # Clear LDT
20184 @@ -534,8 +616,11 @@ setup_once:
20185 * relocation. Manually set base address in stack canary
20186 * segment descriptor.
20187 */
20188 - movl $gdt_page,%eax
20189 + movl $cpu_gdt_table,%eax
20190 movl $stack_canary,%ecx
20191 +#ifdef CONFIG_SMP
20192 + addl $__per_cpu_load,%ecx
20193 +#endif
20194 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20195 shrl $16, %ecx
20196 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20197 @@ -566,7 +651,7 @@ ENDPROC(early_idt_handlers)
20198 /* This is global to keep gas from relaxing the jumps */
20199 ENTRY(early_idt_handler)
20200 cld
20201 - cmpl $2,%ss:early_recursion_flag
20202 + cmpl $1,%ss:early_recursion_flag
20203 je hlt_loop
20204 incl %ss:early_recursion_flag
20205
20206 @@ -604,8 +689,8 @@ ENTRY(early_idt_handler)
20207 pushl (20+6*4)(%esp) /* trapno */
20208 pushl $fault_msg
20209 call printk
20210 -#endif
20211 call dump_stack
20212 +#endif
20213 hlt_loop:
20214 hlt
20215 jmp hlt_loop
20216 @@ -624,8 +709,11 @@ ENDPROC(early_idt_handler)
20217 /* This is the default interrupt "handler" :-) */
20218 ALIGN
20219 ignore_int:
20220 - cld
20221 #ifdef CONFIG_PRINTK
20222 + cmpl $2,%ss:early_recursion_flag
20223 + je hlt_loop
20224 + incl %ss:early_recursion_flag
20225 + cld
20226 pushl %eax
20227 pushl %ecx
20228 pushl %edx
20229 @@ -634,9 +722,6 @@ ignore_int:
20230 movl $(__KERNEL_DS),%eax
20231 movl %eax,%ds
20232 movl %eax,%es
20233 - cmpl $2,early_recursion_flag
20234 - je hlt_loop
20235 - incl early_recursion_flag
20236 pushl 16(%esp)
20237 pushl 24(%esp)
20238 pushl 32(%esp)
20239 @@ -670,29 +755,43 @@ ENTRY(setup_once_ref)
20240 /*
20241 * BSS section
20242 */
20243 -__PAGE_ALIGNED_BSS
20244 - .align PAGE_SIZE
20245 #ifdef CONFIG_X86_PAE
20246 +.section .initial_pg_pmd,"a",@progbits
20247 initial_pg_pmd:
20248 .fill 1024*KPMDS,4,0
20249 #else
20250 +.section .initial_page_table,"a",@progbits
20251 ENTRY(initial_page_table)
20252 .fill 1024,4,0
20253 #endif
20254 +.section .initial_pg_fixmap,"a",@progbits
20255 initial_pg_fixmap:
20256 .fill 1024,4,0
20257 +.section .empty_zero_page,"a",@progbits
20258 ENTRY(empty_zero_page)
20259 .fill 4096,1,0
20260 +.section .swapper_pg_dir,"a",@progbits
20261 ENTRY(swapper_pg_dir)
20262 +#ifdef CONFIG_X86_PAE
20263 + .fill 4,8,0
20264 +#else
20265 .fill 1024,4,0
20266 +#endif
20267 +
20268 +/*
20269 + * The IDT has to be page-aligned to simplify the Pentium
20270 + * F0 0F bug workaround.. We have a special link segment
20271 + * for this.
20272 + */
20273 +.section .idt,"a",@progbits
20274 +ENTRY(idt_table)
20275 + .fill 256,8,0
20276
20277 /*
20278 * This starts the data section.
20279 */
20280 #ifdef CONFIG_X86_PAE
20281 -__PAGE_ALIGNED_DATA
20282 - /* Page-aligned for the benefit of paravirt? */
20283 - .align PAGE_SIZE
20284 +.section .initial_page_table,"a",@progbits
20285 ENTRY(initial_page_table)
20286 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20287 # if KPMDS == 3
20288 @@ -711,12 +810,20 @@ ENTRY(initial_page_table)
20289 # error "Kernel PMDs should be 1, 2 or 3"
20290 # endif
20291 .align PAGE_SIZE /* needs to be page-sized too */
20292 +
20293 +#ifdef CONFIG_PAX_PER_CPU_PGD
20294 +ENTRY(cpu_pgd)
20295 + .rept NR_CPUS
20296 + .fill 4,8,0
20297 + .endr
20298 +#endif
20299 +
20300 #endif
20301
20302 .data
20303 .balign 4
20304 ENTRY(stack_start)
20305 - .long init_thread_union+THREAD_SIZE
20306 + .long init_thread_union+THREAD_SIZE-8
20307
20308 __INITRODATA
20309 int_msg:
20310 @@ -744,7 +851,7 @@ fault_msg:
20311 * segment size, and 32-bit linear address value:
20312 */
20313
20314 - .data
20315 +.section .rodata,"a",@progbits
20316 .globl boot_gdt_descr
20317 .globl idt_descr
20318
20319 @@ -753,7 +860,7 @@ fault_msg:
20320 .word 0 # 32 bit align gdt_desc.address
20321 boot_gdt_descr:
20322 .word __BOOT_DS+7
20323 - .long boot_gdt - __PAGE_OFFSET
20324 + .long pa(boot_gdt)
20325
20326 .word 0 # 32-bit align idt_desc.address
20327 idt_descr:
20328 @@ -764,7 +871,7 @@ idt_descr:
20329 .word 0 # 32 bit align gdt_desc.address
20330 ENTRY(early_gdt_descr)
20331 .word GDT_ENTRIES*8-1
20332 - .long gdt_page /* Overwritten for secondary CPUs */
20333 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20334
20335 /*
20336 * The boot_gdt must mirror the equivalent in setup.S and is
20337 @@ -773,5 +880,65 @@ ENTRY(early_gdt_descr)
20338 .align L1_CACHE_BYTES
20339 ENTRY(boot_gdt)
20340 .fill GDT_ENTRY_BOOT_CS,8,0
20341 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20342 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20343 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20344 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20345 +
20346 + .align PAGE_SIZE_asm
20347 +ENTRY(cpu_gdt_table)
20348 + .rept NR_CPUS
20349 + .quad 0x0000000000000000 /* NULL descriptor */
20350 + .quad 0x0000000000000000 /* 0x0b reserved */
20351 + .quad 0x0000000000000000 /* 0x13 reserved */
20352 + .quad 0x0000000000000000 /* 0x1b reserved */
20353 +
20354 +#ifdef CONFIG_PAX_KERNEXEC
20355 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20356 +#else
20357 + .quad 0x0000000000000000 /* 0x20 unused */
20358 +#endif
20359 +
20360 + .quad 0x0000000000000000 /* 0x28 unused */
20361 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20362 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20363 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20364 + .quad 0x0000000000000000 /* 0x4b reserved */
20365 + .quad 0x0000000000000000 /* 0x53 reserved */
20366 + .quad 0x0000000000000000 /* 0x5b reserved */
20367 +
20368 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20369 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20370 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20371 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20372 +
20373 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20374 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20375 +
20376 + /*
20377 + * Segments used for calling PnP BIOS have byte granularity.
20378 + * The code segments and data segments have fixed 64k limits,
20379 + * the transfer segment sizes are set at run time.
20380 + */
20381 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20382 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20383 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20384 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20385 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20386 +
20387 + /*
20388 + * The APM segments have byte granularity and their bases
20389 + * are set at run time. All have 64k limits.
20390 + */
20391 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20392 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20393 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20394 +
20395 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20396 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20397 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20398 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20399 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20400 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20401 +
20402 + /* Be sure this is zeroed to avoid false validations in Xen */
20403 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20404 + .endr
20405 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20406 index 08f7e80..40cbed5 100644
20407 --- a/arch/x86/kernel/head_64.S
20408 +++ b/arch/x86/kernel/head_64.S
20409 @@ -20,6 +20,8 @@
20410 #include <asm/processor-flags.h>
20411 #include <asm/percpu.h>
20412 #include <asm/nops.h>
20413 +#include <asm/cpufeature.h>
20414 +#include <asm/alternative-asm.h>
20415
20416 #ifdef CONFIG_PARAVIRT
20417 #include <asm/asm-offsets.h>
20418 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20419 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20420 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20421 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20422 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20423 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20424 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20425 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20426 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20427 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20428
20429 .text
20430 __HEAD
20431 @@ -89,11 +97,15 @@ startup_64:
20432 * Fixup the physical addresses in the page table
20433 */
20434 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
20435 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20436 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20437 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20438
20439 addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20440 addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20441
20442 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20443 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20444
20445 /*
20446 * Set up the identity mapping for the switchover. These
20447 @@ -175,8 +187,8 @@ ENTRY(secondary_startup_64)
20448 movq $(init_level4_pgt - __START_KERNEL_map), %rax
20449 1:
20450
20451 - /* Enable PAE mode and PGE */
20452 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
20453 + /* Enable PAE mode and PSE/PGE */
20454 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
20455 movq %rcx, %cr4
20456
20457 /* Setup early boot stage 4 level pagetables. */
20458 @@ -197,10 +209,18 @@ ENTRY(secondary_startup_64)
20459 movl $MSR_EFER, %ecx
20460 rdmsr
20461 btsl $_EFER_SCE, %eax /* Enable System Call */
20462 - btl $20,%edi /* No Execute supported? */
20463 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20464 jnc 1f
20465 btsl $_EFER_NX, %eax
20466 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
20467 + leaq init_level4_pgt(%rip), %rdi
20468 +#ifndef CONFIG_EFI
20469 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20470 +#endif
20471 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20472 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20473 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20474 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20475 1: wrmsr /* Make changes effective */
20476
20477 /* Setup cr0 */
20478 @@ -280,6 +300,7 @@ ENTRY(secondary_startup_64)
20479 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
20480 * address given in m16:64.
20481 */
20482 + pax_set_fptr_mask
20483 movq initial_code(%rip),%rax
20484 pushq $0 # fake return address to stop unwinder
20485 pushq $__KERNEL_CS # set correct cs
20486 @@ -386,7 +407,7 @@ ENTRY(early_idt_handler)
20487 call dump_stack
20488 #ifdef CONFIG_KALLSYMS
20489 leaq early_idt_ripmsg(%rip),%rdi
20490 - movq 40(%rsp),%rsi # %rip again
20491 + movq 88(%rsp),%rsi # %rip again
20492 call __print_symbol
20493 #endif
20494 #endif /* EARLY_PRINTK */
20495 @@ -414,6 +435,7 @@ ENDPROC(early_idt_handler)
20496 early_recursion_flag:
20497 .long 0
20498
20499 + .section .rodata,"a",@progbits
20500 #ifdef CONFIG_EARLY_PRINTK
20501 early_idt_msg:
20502 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20503 @@ -443,27 +465,50 @@ NEXT_PAGE(early_dynamic_pgts)
20504
20505 .data
20506
20507 -#ifndef CONFIG_XEN
20508 NEXT_PAGE(init_level4_pgt)
20509 - .fill 512,8,0
20510 -#else
20511 -NEXT_PAGE(init_level4_pgt)
20512 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20513 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
20514 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20515 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
20516 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
20517 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
20518 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
20519 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
20520 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20521 .org init_level4_pgt + L4_START_KERNEL*8, 0
20522 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
20523 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
20524
20525 +#ifdef CONFIG_PAX_PER_CPU_PGD
20526 +NEXT_PAGE(cpu_pgd)
20527 + .rept NR_CPUS
20528 + .fill 512,8,0
20529 + .endr
20530 +#endif
20531 +
20532 NEXT_PAGE(level3_ident_pgt)
20533 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20534 +#ifdef CONFIG_XEN
20535 .fill 511, 8, 0
20536 +#else
20537 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
20538 + .fill 510,8,0
20539 +#endif
20540 +
20541 +NEXT_PAGE(level3_vmalloc_start_pgt)
20542 + .fill 512,8,0
20543 +
20544 +NEXT_PAGE(level3_vmalloc_end_pgt)
20545 + .fill 512,8,0
20546 +
20547 +NEXT_PAGE(level3_vmemmap_pgt)
20548 + .fill L3_VMEMMAP_START,8,0
20549 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20550 +
20551 NEXT_PAGE(level2_ident_pgt)
20552 - /* Since I easily can, map the first 1G.
20553 + /* Since I easily can, map the first 2G.
20554 * Don't set NX because code runs from these pages.
20555 */
20556 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
20557 -#endif
20558 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
20559
20560 NEXT_PAGE(level3_kernel_pgt)
20561 .fill L3_START_KERNEL,8,0
20562 @@ -471,6 +516,9 @@ NEXT_PAGE(level3_kernel_pgt)
20563 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
20564 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20565
20566 +NEXT_PAGE(level2_vmemmap_pgt)
20567 + .fill 512,8,0
20568 +
20569 NEXT_PAGE(level2_kernel_pgt)
20570 /*
20571 * 512 MB kernel mapping. We spend a full page on this pagetable
20572 @@ -486,38 +534,64 @@ NEXT_PAGE(level2_kernel_pgt)
20573 KERNEL_IMAGE_SIZE/PMD_SIZE)
20574
20575 NEXT_PAGE(level2_fixmap_pgt)
20576 - .fill 506,8,0
20577 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20578 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
20579 - .fill 5,8,0
20580 + .fill 507,8,0
20581 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
20582 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
20583 + .fill 4,8,0
20584
20585 -NEXT_PAGE(level1_fixmap_pgt)
20586 +NEXT_PAGE(level1_vsyscall_pgt)
20587 .fill 512,8,0
20588
20589 #undef PMDS
20590
20591 - .data
20592 + .align PAGE_SIZE
20593 +ENTRY(cpu_gdt_table)
20594 + .rept NR_CPUS
20595 + .quad 0x0000000000000000 /* NULL descriptor */
20596 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
20597 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
20598 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
20599 + .quad 0x00cffb000000ffff /* __USER32_CS */
20600 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
20601 + .quad 0x00affb000000ffff /* __USER_CS */
20602 +
20603 +#ifdef CONFIG_PAX_KERNEXEC
20604 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
20605 +#else
20606 + .quad 0x0 /* unused */
20607 +#endif
20608 +
20609 + .quad 0,0 /* TSS */
20610 + .quad 0,0 /* LDT */
20611 + .quad 0,0,0 /* three TLS descriptors */
20612 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
20613 + /* asm/segment.h:GDT_ENTRIES must match this */
20614 +
20615 + /* zero the remaining page */
20616 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
20617 + .endr
20618 +
20619 .align 16
20620 .globl early_gdt_descr
20621 early_gdt_descr:
20622 .word GDT_ENTRIES*8-1
20623 early_gdt_descr_base:
20624 - .quad INIT_PER_CPU_VAR(gdt_page)
20625 + .quad cpu_gdt_table
20626
20627 ENTRY(phys_base)
20628 /* This must match the first entry in level2_kernel_pgt */
20629 .quad 0x0000000000000000
20630
20631 #include "../../x86/xen/xen-head.S"
20632 -
20633 - .section .bss, "aw", @nobits
20634 +
20635 + .section .rodata,"a",@progbits
20636 .align L1_CACHE_BYTES
20637 ENTRY(idt_table)
20638 - .skip IDT_ENTRIES * 16
20639 + .fill 512,8,0
20640
20641 .align L1_CACHE_BYTES
20642 ENTRY(nmi_idt_table)
20643 - .skip IDT_ENTRIES * 16
20644 + .fill 512,8,0
20645
20646 __PAGE_ALIGNED_BSS
20647 NEXT_PAGE(empty_zero_page)
20648 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
20649 index 0fa6912..37fce70 100644
20650 --- a/arch/x86/kernel/i386_ksyms_32.c
20651 +++ b/arch/x86/kernel/i386_ksyms_32.c
20652 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
20653 EXPORT_SYMBOL(cmpxchg8b_emu);
20654 #endif
20655
20656 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
20657 +
20658 /* Networking helper routines. */
20659 EXPORT_SYMBOL(csum_partial_copy_generic);
20660 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
20661 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
20662
20663 EXPORT_SYMBOL(__get_user_1);
20664 EXPORT_SYMBOL(__get_user_2);
20665 @@ -37,3 +41,7 @@ EXPORT_SYMBOL(strstr);
20666
20667 EXPORT_SYMBOL(csum_partial);
20668 EXPORT_SYMBOL(empty_zero_page);
20669 +
20670 +#ifdef CONFIG_PAX_KERNEXEC
20671 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
20672 +#endif
20673 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
20674 index 245a71d..89d9ce4 100644
20675 --- a/arch/x86/kernel/i387.c
20676 +++ b/arch/x86/kernel/i387.c
20677 @@ -55,7 +55,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
20678 static inline bool interrupted_user_mode(void)
20679 {
20680 struct pt_regs *regs = get_irq_regs();
20681 - return regs && user_mode_vm(regs);
20682 + return regs && user_mode(regs);
20683 }
20684
20685 /*
20686 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
20687 index 9a5c460..84868423 100644
20688 --- a/arch/x86/kernel/i8259.c
20689 +++ b/arch/x86/kernel/i8259.c
20690 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
20691 static void make_8259A_irq(unsigned int irq)
20692 {
20693 disable_irq_nosync(irq);
20694 - io_apic_irqs &= ~(1<<irq);
20695 + io_apic_irqs &= ~(1UL<<irq);
20696 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
20697 i8259A_chip.name);
20698 enable_irq(irq);
20699 @@ -209,7 +209,7 @@ spurious_8259A_irq:
20700 "spurious 8259A interrupt: IRQ%d.\n", irq);
20701 spurious_irq_mask |= irqmask;
20702 }
20703 - atomic_inc(&irq_err_count);
20704 + atomic_inc_unchecked(&irq_err_count);
20705 /*
20706 * Theoretically we do not have to handle this IRQ,
20707 * but in Linux this does not cause problems and is
20708 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
20709 /* (slave's support for AEOI in flat mode is to be investigated) */
20710 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
20711
20712 + pax_open_kernel();
20713 if (auto_eoi)
20714 /*
20715 * In AEOI mode we just have to mask the interrupt
20716 * when acking.
20717 */
20718 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
20719 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
20720 else
20721 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20722 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20723 + pax_close_kernel();
20724
20725 udelay(100); /* wait for 8259A to initialize */
20726
20727 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
20728 index a979b5b..1d6db75 100644
20729 --- a/arch/x86/kernel/io_delay.c
20730 +++ b/arch/x86/kernel/io_delay.c
20731 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
20732 * Quirk table for systems that misbehave (lock up, etc.) if port
20733 * 0x80 is used:
20734 */
20735 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
20736 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
20737 {
20738 .callback = dmi_io_delay_0xed_port,
20739 .ident = "Compaq Presario V6000",
20740 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
20741 index 4ddaf66..6292f4e 100644
20742 --- a/arch/x86/kernel/ioport.c
20743 +++ b/arch/x86/kernel/ioport.c
20744 @@ -6,6 +6,7 @@
20745 #include <linux/sched.h>
20746 #include <linux/kernel.h>
20747 #include <linux/capability.h>
20748 +#include <linux/security.h>
20749 #include <linux/errno.h>
20750 #include <linux/types.h>
20751 #include <linux/ioport.h>
20752 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20753
20754 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
20755 return -EINVAL;
20756 +#ifdef CONFIG_GRKERNSEC_IO
20757 + if (turn_on && grsec_disable_privio) {
20758 + gr_handle_ioperm();
20759 + return -EPERM;
20760 + }
20761 +#endif
20762 if (turn_on && !capable(CAP_SYS_RAWIO))
20763 return -EPERM;
20764
20765 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20766 * because the ->io_bitmap_max value must match the bitmap
20767 * contents:
20768 */
20769 - tss = &per_cpu(init_tss, get_cpu());
20770 + tss = init_tss + get_cpu();
20771
20772 if (turn_on)
20773 bitmap_clear(t->io_bitmap_ptr, from, num);
20774 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
20775 return -EINVAL;
20776 /* Trying to gain more privileges? */
20777 if (level > old) {
20778 +#ifdef CONFIG_GRKERNSEC_IO
20779 + if (grsec_disable_privio) {
20780 + gr_handle_iopl();
20781 + return -EPERM;
20782 + }
20783 +#endif
20784 if (!capable(CAP_SYS_RAWIO))
20785 return -EPERM;
20786 }
20787 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
20788 index 84b7789..e65e8be 100644
20789 --- a/arch/x86/kernel/irq.c
20790 +++ b/arch/x86/kernel/irq.c
20791 @@ -18,7 +18,7 @@
20792 #include <asm/mce.h>
20793 #include <asm/hw_irq.h>
20794
20795 -atomic_t irq_err_count;
20796 +atomic_unchecked_t irq_err_count;
20797
20798 /* Function pointer for generic interrupt vector handling */
20799 void (*x86_platform_ipi_callback)(void) = NULL;
20800 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
20801 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
20802 seq_printf(p, " Machine check polls\n");
20803 #endif
20804 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
20805 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
20806 #if defined(CONFIG_X86_IO_APIC)
20807 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
20808 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
20809 #endif
20810 return 0;
20811 }
20812 @@ -164,7 +164,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
20813
20814 u64 arch_irq_stat(void)
20815 {
20816 - u64 sum = atomic_read(&irq_err_count);
20817 + u64 sum = atomic_read_unchecked(&irq_err_count);
20818 return sum;
20819 }
20820
20821 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
20822 index 344faf8..355f60d 100644
20823 --- a/arch/x86/kernel/irq_32.c
20824 +++ b/arch/x86/kernel/irq_32.c
20825 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
20826 __asm__ __volatile__("andl %%esp,%0" :
20827 "=r" (sp) : "0" (THREAD_SIZE - 1));
20828
20829 - return sp < (sizeof(struct thread_info) + STACK_WARN);
20830 + return sp < STACK_WARN;
20831 }
20832
20833 static void print_stack_overflow(void)
20834 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
20835 * per-CPU IRQ handling contexts (thread information and stack)
20836 */
20837 union irq_ctx {
20838 - struct thread_info tinfo;
20839 - u32 stack[THREAD_SIZE/sizeof(u32)];
20840 + unsigned long previous_esp;
20841 + u32 stack[THREAD_SIZE/sizeof(u32)];
20842 } __attribute__((aligned(THREAD_SIZE)));
20843
20844 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
20845 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
20846 static inline int
20847 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20848 {
20849 - union irq_ctx *curctx, *irqctx;
20850 + union irq_ctx *irqctx;
20851 u32 *isp, arg1, arg2;
20852
20853 - curctx = (union irq_ctx *) current_thread_info();
20854 irqctx = __this_cpu_read(hardirq_ctx);
20855
20856 /*
20857 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20858 * handler) we can't do that and just have to keep using the
20859 * current stack (which is the irq stack already after all)
20860 */
20861 - if (unlikely(curctx == irqctx))
20862 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
20863 return 0;
20864
20865 /* build the stack frame on the IRQ stack */
20866 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
20867 - irqctx->tinfo.task = curctx->tinfo.task;
20868 - irqctx->tinfo.previous_esp = current_stack_pointer;
20869 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
20870 + irqctx->previous_esp = current_stack_pointer;
20871
20872 - /* Copy the preempt_count so that the [soft]irq checks work. */
20873 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
20874 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20875 + __set_fs(MAKE_MM_SEG(0));
20876 +#endif
20877
20878 if (unlikely(overflow))
20879 call_on_stack(print_stack_overflow, isp);
20880 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20881 : "0" (irq), "1" (desc), "2" (isp),
20882 "D" (desc->handle_irq)
20883 : "memory", "cc", "ecx");
20884 +
20885 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20886 + __set_fs(current_thread_info()->addr_limit);
20887 +#endif
20888 +
20889 return 1;
20890 }
20891
20892 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20893 */
20894 void __cpuinit irq_ctx_init(int cpu)
20895 {
20896 - union irq_ctx *irqctx;
20897 -
20898 if (per_cpu(hardirq_ctx, cpu))
20899 return;
20900
20901 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
20902 - THREADINFO_GFP,
20903 - THREAD_SIZE_ORDER));
20904 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
20905 - irqctx->tinfo.cpu = cpu;
20906 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
20907 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
20908 -
20909 - per_cpu(hardirq_ctx, cpu) = irqctx;
20910 -
20911 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
20912 - THREADINFO_GFP,
20913 - THREAD_SIZE_ORDER));
20914 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
20915 - irqctx->tinfo.cpu = cpu;
20916 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
20917 -
20918 - per_cpu(softirq_ctx, cpu) = irqctx;
20919 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
20920 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
20921 +
20922 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
20923 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
20924
20925 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
20926 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
20927 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
20928 asmlinkage void do_softirq(void)
20929 {
20930 unsigned long flags;
20931 - struct thread_info *curctx;
20932 union irq_ctx *irqctx;
20933 u32 *isp;
20934
20935 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
20936 local_irq_save(flags);
20937
20938 if (local_softirq_pending()) {
20939 - curctx = current_thread_info();
20940 irqctx = __this_cpu_read(softirq_ctx);
20941 - irqctx->tinfo.task = curctx->task;
20942 - irqctx->tinfo.previous_esp = current_stack_pointer;
20943 + irqctx->previous_esp = current_stack_pointer;
20944
20945 /* build the stack frame on the softirq stack */
20946 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
20947 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
20948 +
20949 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20950 + __set_fs(MAKE_MM_SEG(0));
20951 +#endif
20952
20953 call_on_stack(__do_softirq, isp);
20954 +
20955 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20956 + __set_fs(current_thread_info()->addr_limit);
20957 +#endif
20958 +
20959 /*
20960 * Shouldn't happen, we returned above if in_interrupt():
20961 */
20962 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
20963 if (unlikely(!desc))
20964 return false;
20965
20966 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
20967 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
20968 if (unlikely(overflow))
20969 print_stack_overflow();
20970 desc->handle_irq(irq, desc);
20971 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
20972 index d04d3ec..ea4b374 100644
20973 --- a/arch/x86/kernel/irq_64.c
20974 +++ b/arch/x86/kernel/irq_64.c
20975 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
20976 u64 estack_top, estack_bottom;
20977 u64 curbase = (u64)task_stack_page(current);
20978
20979 - if (user_mode_vm(regs))
20980 + if (user_mode(regs))
20981 return;
20982
20983 if (regs->sp >= curbase + sizeof(struct thread_info) +
20984 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
20985 index dc1404b..bbc43e7 100644
20986 --- a/arch/x86/kernel/kdebugfs.c
20987 +++ b/arch/x86/kernel/kdebugfs.c
20988 @@ -27,7 +27,7 @@ struct setup_data_node {
20989 u32 len;
20990 };
20991
20992 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
20993 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
20994 size_t count, loff_t *ppos)
20995 {
20996 struct setup_data_node *node = file->private_data;
20997 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
20998 index 836f832..a8bda67 100644
20999 --- a/arch/x86/kernel/kgdb.c
21000 +++ b/arch/x86/kernel/kgdb.c
21001 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21002 #ifdef CONFIG_X86_32
21003 switch (regno) {
21004 case GDB_SS:
21005 - if (!user_mode_vm(regs))
21006 + if (!user_mode(regs))
21007 *(unsigned long *)mem = __KERNEL_DS;
21008 break;
21009 case GDB_SP:
21010 - if (!user_mode_vm(regs))
21011 + if (!user_mode(regs))
21012 *(unsigned long *)mem = kernel_stack_pointer(regs);
21013 break;
21014 case GDB_GS:
21015 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21016 bp->attr.bp_addr = breakinfo[breakno].addr;
21017 bp->attr.bp_len = breakinfo[breakno].len;
21018 bp->attr.bp_type = breakinfo[breakno].type;
21019 - info->address = breakinfo[breakno].addr;
21020 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21021 + info->address = ktla_ktva(breakinfo[breakno].addr);
21022 + else
21023 + info->address = breakinfo[breakno].addr;
21024 info->len = breakinfo[breakno].len;
21025 info->type = breakinfo[breakno].type;
21026 val = arch_install_hw_breakpoint(bp);
21027 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21028 case 'k':
21029 /* clear the trace bit */
21030 linux_regs->flags &= ~X86_EFLAGS_TF;
21031 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21032 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21033
21034 /* set the trace bit if we're stepping */
21035 if (remcomInBuffer[0] == 's') {
21036 linux_regs->flags |= X86_EFLAGS_TF;
21037 - atomic_set(&kgdb_cpu_doing_single_step,
21038 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21039 raw_smp_processor_id());
21040 }
21041
21042 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21043
21044 switch (cmd) {
21045 case DIE_DEBUG:
21046 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21047 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21048 if (user_mode(regs))
21049 return single_step_cont(regs, args);
21050 break;
21051 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21052 #endif /* CONFIG_DEBUG_RODATA */
21053
21054 bpt->type = BP_BREAKPOINT;
21055 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21056 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21057 BREAK_INSTR_SIZE);
21058 if (err)
21059 return err;
21060 - err = probe_kernel_write((char *)bpt->bpt_addr,
21061 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21062 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21063 #ifdef CONFIG_DEBUG_RODATA
21064 if (!err)
21065 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21066 return -EBUSY;
21067 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21068 BREAK_INSTR_SIZE);
21069 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21070 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21071 if (err)
21072 return err;
21073 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21074 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21075 if (mutex_is_locked(&text_mutex))
21076 goto knl_write;
21077 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21078 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21079 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21080 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21081 goto knl_write;
21082 return err;
21083 knl_write:
21084 #endif /* CONFIG_DEBUG_RODATA */
21085 - return probe_kernel_write((char *)bpt->bpt_addr,
21086 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21087 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21088 }
21089
21090 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
21091 index 7bfe318..383d238 100644
21092 --- a/arch/x86/kernel/kprobes/core.c
21093 +++ b/arch/x86/kernel/kprobes/core.c
21094 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21095 s32 raddr;
21096 } __packed *insn;
21097
21098 - insn = (struct __arch_relative_insn *)from;
21099 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21100 +
21101 + pax_open_kernel();
21102 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21103 insn->op = op;
21104 + pax_close_kernel();
21105 }
21106
21107 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21108 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21109 kprobe_opcode_t opcode;
21110 kprobe_opcode_t *orig_opcodes = opcodes;
21111
21112 - if (search_exception_tables((unsigned long)opcodes))
21113 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21114 return 0; /* Page fault may occur on this address. */
21115
21116 retry:
21117 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21118 * for the first byte, we can recover the original instruction
21119 * from it and kp->opcode.
21120 */
21121 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21122 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21123 buf[0] = kp->opcode;
21124 - return (unsigned long)buf;
21125 + return ktva_ktla((unsigned long)buf);
21126 }
21127
21128 /*
21129 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21130 /* Another subsystem puts a breakpoint, failed to recover */
21131 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21132 return 0;
21133 + pax_open_kernel();
21134 memcpy(dest, insn.kaddr, insn.length);
21135 + pax_close_kernel();
21136
21137 #ifdef CONFIG_X86_64
21138 if (insn_rip_relative(&insn)) {
21139 @@ -355,7 +360,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21140 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
21141 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
21142 disp = (u8 *) dest + insn_offset_displacement(&insn);
21143 + pax_open_kernel();
21144 *(s32 *) disp = (s32) newdisp;
21145 + pax_close_kernel();
21146 }
21147 #endif
21148 return insn.length;
21149 @@ -488,7 +495,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21150 * nor set current_kprobe, because it doesn't use single
21151 * stepping.
21152 */
21153 - regs->ip = (unsigned long)p->ainsn.insn;
21154 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21155 preempt_enable_no_resched();
21156 return;
21157 }
21158 @@ -505,9 +512,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21159 regs->flags &= ~X86_EFLAGS_IF;
21160 /* single step inline if the instruction is an int3 */
21161 if (p->opcode == BREAKPOINT_INSTRUCTION)
21162 - regs->ip = (unsigned long)p->addr;
21163 + regs->ip = ktla_ktva((unsigned long)p->addr);
21164 else
21165 - regs->ip = (unsigned long)p->ainsn.insn;
21166 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21167 }
21168
21169 /*
21170 @@ -586,7 +593,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21171 setup_singlestep(p, regs, kcb, 0);
21172 return 1;
21173 }
21174 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21175 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21176 /*
21177 * The breakpoint instruction was removed right
21178 * after we hit it. Another cpu has removed
21179 @@ -632,6 +639,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21180 " movq %rax, 152(%rsp)\n"
21181 RESTORE_REGS_STRING
21182 " popfq\n"
21183 +#ifdef KERNEXEC_PLUGIN
21184 + " btsq $63,(%rsp)\n"
21185 +#endif
21186 #else
21187 " pushf\n"
21188 SAVE_REGS_STRING
21189 @@ -769,7 +779,7 @@ static void __kprobes
21190 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21191 {
21192 unsigned long *tos = stack_addr(regs);
21193 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21194 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21195 unsigned long orig_ip = (unsigned long)p->addr;
21196 kprobe_opcode_t *insn = p->ainsn.insn;
21197
21198 @@ -951,7 +961,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21199 struct die_args *args = data;
21200 int ret = NOTIFY_DONE;
21201
21202 - if (args->regs && user_mode_vm(args->regs))
21203 + if (args->regs && user_mode(args->regs))
21204 return ret;
21205
21206 switch (val) {
21207 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
21208 index 76dc6f0..66bdfc3 100644
21209 --- a/arch/x86/kernel/kprobes/opt.c
21210 +++ b/arch/x86/kernel/kprobes/opt.c
21211 @@ -79,6 +79,7 @@ found:
21212 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
21213 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
21214 {
21215 + pax_open_kernel();
21216 #ifdef CONFIG_X86_64
21217 *addr++ = 0x48;
21218 *addr++ = 0xbf;
21219 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
21220 *addr++ = 0xb8;
21221 #endif
21222 *(unsigned long *)addr = val;
21223 + pax_close_kernel();
21224 }
21225
21226 static void __used __kprobes kprobes_optinsn_template_holder(void)
21227 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21228 * Verify if the address gap is in 2GB range, because this uses
21229 * a relative jump.
21230 */
21231 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21232 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21233 if (abs(rel) > 0x7fffffff)
21234 return -ERANGE;
21235
21236 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21237 op->optinsn.size = ret;
21238
21239 /* Copy arch-dep-instance from template */
21240 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21241 + pax_open_kernel();
21242 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21243 + pax_close_kernel();
21244
21245 /* Set probe information */
21246 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21247
21248 /* Set probe function call */
21249 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21250 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21251
21252 /* Set returning jmp instruction at the tail of out-of-line buffer */
21253 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21254 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21255 (u8 *)op->kp.addr + op->optinsn.size);
21256
21257 flush_icache_range((unsigned long) buf,
21258 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21259 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21260
21261 /* Backup instructions which will be replaced by jump address */
21262 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21263 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21264 RELATIVE_ADDR_SIZE);
21265
21266 insn_buf[0] = RELATIVEJUMP_OPCODE;
21267 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21268 /* This kprobe is really able to run optimized path. */
21269 op = container_of(p, struct optimized_kprobe, kp);
21270 /* Detour through copied instructions */
21271 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21272 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21273 if (!reenter)
21274 reset_current_kprobe();
21275 preempt_enable_no_resched();
21276 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21277 index b686a90..60d36fb 100644
21278 --- a/arch/x86/kernel/kvm.c
21279 +++ b/arch/x86/kernel/kvm.c
21280 @@ -453,7 +453,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21281 return NOTIFY_OK;
21282 }
21283
21284 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21285 +static struct notifier_block kvm_cpu_notifier = {
21286 .notifier_call = kvm_cpu_notify,
21287 };
21288 #endif
21289 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21290 index ebc9873..1b9724b 100644
21291 --- a/arch/x86/kernel/ldt.c
21292 +++ b/arch/x86/kernel/ldt.c
21293 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21294 if (reload) {
21295 #ifdef CONFIG_SMP
21296 preempt_disable();
21297 - load_LDT(pc);
21298 + load_LDT_nolock(pc);
21299 if (!cpumask_equal(mm_cpumask(current->mm),
21300 cpumask_of(smp_processor_id())))
21301 smp_call_function(flush_ldt, current->mm, 1);
21302 preempt_enable();
21303 #else
21304 - load_LDT(pc);
21305 + load_LDT_nolock(pc);
21306 #endif
21307 }
21308 if (oldsize) {
21309 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21310 return err;
21311
21312 for (i = 0; i < old->size; i++)
21313 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21314 + write_ldt_entry(new->ldt, i, old->ldt + i);
21315 return 0;
21316 }
21317
21318 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21319 retval = copy_ldt(&mm->context, &old_mm->context);
21320 mutex_unlock(&old_mm->context.lock);
21321 }
21322 +
21323 + if (tsk == current) {
21324 + mm->context.vdso = 0;
21325 +
21326 +#ifdef CONFIG_X86_32
21327 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21328 + mm->context.user_cs_base = 0UL;
21329 + mm->context.user_cs_limit = ~0UL;
21330 +
21331 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21332 + cpus_clear(mm->context.cpu_user_cs_mask);
21333 +#endif
21334 +
21335 +#endif
21336 +#endif
21337 +
21338 + }
21339 +
21340 return retval;
21341 }
21342
21343 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21344 }
21345 }
21346
21347 +#ifdef CONFIG_PAX_SEGMEXEC
21348 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21349 + error = -EINVAL;
21350 + goto out_unlock;
21351 + }
21352 +#endif
21353 +
21354 fill_ldt(&ldt, &ldt_info);
21355 if (oldmode)
21356 ldt.avl = 0;
21357 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21358 index 5b19e4d..6476a76 100644
21359 --- a/arch/x86/kernel/machine_kexec_32.c
21360 +++ b/arch/x86/kernel/machine_kexec_32.c
21361 @@ -26,7 +26,7 @@
21362 #include <asm/cacheflush.h>
21363 #include <asm/debugreg.h>
21364
21365 -static void set_idt(void *newidt, __u16 limit)
21366 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21367 {
21368 struct desc_ptr curidt;
21369
21370 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21371 }
21372
21373
21374 -static void set_gdt(void *newgdt, __u16 limit)
21375 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21376 {
21377 struct desc_ptr curgdt;
21378
21379 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21380 }
21381
21382 control_page = page_address(image->control_code_page);
21383 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21384 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21385
21386 relocate_kernel_ptr = control_page;
21387 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21388 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21389 index 22db92b..d546bec 100644
21390 --- a/arch/x86/kernel/microcode_core.c
21391 +++ b/arch/x86/kernel/microcode_core.c
21392 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21393 return NOTIFY_OK;
21394 }
21395
21396 -static struct notifier_block __refdata mc_cpu_notifier = {
21397 +static struct notifier_block mc_cpu_notifier = {
21398 .notifier_call = mc_cpu_callback,
21399 };
21400
21401 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21402 index 5fb2ceb..3ae90bb 100644
21403 --- a/arch/x86/kernel/microcode_intel.c
21404 +++ b/arch/x86/kernel/microcode_intel.c
21405 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21406
21407 static int get_ucode_user(void *to, const void *from, size_t n)
21408 {
21409 - return copy_from_user(to, from, n);
21410 + return copy_from_user(to, (const void __force_user *)from, n);
21411 }
21412
21413 static enum ucode_state
21414 request_microcode_user(int cpu, const void __user *buf, size_t size)
21415 {
21416 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21417 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21418 }
21419
21420 static void microcode_fini_cpu(int cpu)
21421 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21422 index 216a4d7..228255a 100644
21423 --- a/arch/x86/kernel/module.c
21424 +++ b/arch/x86/kernel/module.c
21425 @@ -43,15 +43,60 @@ do { \
21426 } while (0)
21427 #endif
21428
21429 -void *module_alloc(unsigned long size)
21430 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21431 {
21432 - if (PAGE_ALIGN(size) > MODULES_LEN)
21433 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21434 return NULL;
21435 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21436 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21437 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21438 -1, __builtin_return_address(0));
21439 }
21440
21441 +void *module_alloc(unsigned long size)
21442 +{
21443 +
21444 +#ifdef CONFIG_PAX_KERNEXEC
21445 + return __module_alloc(size, PAGE_KERNEL);
21446 +#else
21447 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21448 +#endif
21449 +
21450 +}
21451 +
21452 +#ifdef CONFIG_PAX_KERNEXEC
21453 +#ifdef CONFIG_X86_32
21454 +void *module_alloc_exec(unsigned long size)
21455 +{
21456 + struct vm_struct *area;
21457 +
21458 + if (size == 0)
21459 + return NULL;
21460 +
21461 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21462 + return area ? area->addr : NULL;
21463 +}
21464 +EXPORT_SYMBOL(module_alloc_exec);
21465 +
21466 +void module_free_exec(struct module *mod, void *module_region)
21467 +{
21468 + vunmap(module_region);
21469 +}
21470 +EXPORT_SYMBOL(module_free_exec);
21471 +#else
21472 +void module_free_exec(struct module *mod, void *module_region)
21473 +{
21474 + module_free(mod, module_region);
21475 +}
21476 +EXPORT_SYMBOL(module_free_exec);
21477 +
21478 +void *module_alloc_exec(unsigned long size)
21479 +{
21480 + return __module_alloc(size, PAGE_KERNEL_RX);
21481 +}
21482 +EXPORT_SYMBOL(module_alloc_exec);
21483 +#endif
21484 +#endif
21485 +
21486 #ifdef CONFIG_X86_32
21487 int apply_relocate(Elf32_Shdr *sechdrs,
21488 const char *strtab,
21489 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21490 unsigned int i;
21491 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21492 Elf32_Sym *sym;
21493 - uint32_t *location;
21494 + uint32_t *plocation, location;
21495
21496 DEBUGP("Applying relocate section %u to %u\n",
21497 relsec, sechdrs[relsec].sh_info);
21498 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21499 /* This is where to make the change */
21500 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21501 - + rel[i].r_offset;
21502 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21503 + location = (uint32_t)plocation;
21504 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21505 + plocation = ktla_ktva((void *)plocation);
21506 /* This is the symbol it is referring to. Note that all
21507 undefined symbols have been resolved. */
21508 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
21509 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21510 switch (ELF32_R_TYPE(rel[i].r_info)) {
21511 case R_386_32:
21512 /* We add the value into the location given */
21513 - *location += sym->st_value;
21514 + pax_open_kernel();
21515 + *plocation += sym->st_value;
21516 + pax_close_kernel();
21517 break;
21518 case R_386_PC32:
21519 /* Add the value, subtract its position */
21520 - *location += sym->st_value - (uint32_t)location;
21521 + pax_open_kernel();
21522 + *plocation += sym->st_value - location;
21523 + pax_close_kernel();
21524 break;
21525 default:
21526 pr_err("%s: Unknown relocation: %u\n",
21527 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
21528 case R_X86_64_NONE:
21529 break;
21530 case R_X86_64_64:
21531 + pax_open_kernel();
21532 *(u64 *)loc = val;
21533 + pax_close_kernel();
21534 break;
21535 case R_X86_64_32:
21536 + pax_open_kernel();
21537 *(u32 *)loc = val;
21538 + pax_close_kernel();
21539 if (val != *(u32 *)loc)
21540 goto overflow;
21541 break;
21542 case R_X86_64_32S:
21543 + pax_open_kernel();
21544 *(s32 *)loc = val;
21545 + pax_close_kernel();
21546 if ((s64)val != *(s32 *)loc)
21547 goto overflow;
21548 break;
21549 case R_X86_64_PC32:
21550 val -= (u64)loc;
21551 + pax_open_kernel();
21552 *(u32 *)loc = val;
21553 + pax_close_kernel();
21554 +
21555 #if 0
21556 if ((s64)val != *(s32 *)loc)
21557 goto overflow;
21558 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
21559 index ce13049..e2e9c3c 100644
21560 --- a/arch/x86/kernel/msr.c
21561 +++ b/arch/x86/kernel/msr.c
21562 @@ -233,7 +233,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
21563 return notifier_from_errno(err);
21564 }
21565
21566 -static struct notifier_block __refdata msr_class_cpu_notifier = {
21567 +static struct notifier_block msr_class_cpu_notifier = {
21568 .notifier_call = msr_class_cpu_callback,
21569 };
21570
21571 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
21572 index 6030805..2d33f21 100644
21573 --- a/arch/x86/kernel/nmi.c
21574 +++ b/arch/x86/kernel/nmi.c
21575 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
21576 return handled;
21577 }
21578
21579 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21580 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
21581 {
21582 struct nmi_desc *desc = nmi_to_desc(type);
21583 unsigned long flags;
21584 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21585 * event confuses some handlers (kdump uses this flag)
21586 */
21587 if (action->flags & NMI_FLAG_FIRST)
21588 - list_add_rcu(&action->list, &desc->head);
21589 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
21590 else
21591 - list_add_tail_rcu(&action->list, &desc->head);
21592 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
21593
21594 spin_unlock_irqrestore(&desc->lock, flags);
21595 return 0;
21596 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
21597 if (!strcmp(n->name, name)) {
21598 WARN(in_nmi(),
21599 "Trying to free NMI (%s) from NMI context!\n", n->name);
21600 - list_del_rcu(&n->list);
21601 + pax_list_del_rcu((struct list_head *)&n->list);
21602 break;
21603 }
21604 }
21605 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
21606 dotraplinkage notrace __kprobes void
21607 do_nmi(struct pt_regs *regs, long error_code)
21608 {
21609 +
21610 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
21611 + if (!user_mode(regs)) {
21612 + unsigned long cs = regs->cs & 0xFFFF;
21613 + unsigned long ip = ktva_ktla(regs->ip);
21614 +
21615 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
21616 + regs->ip = ip;
21617 + }
21618 +#endif
21619 +
21620 nmi_nesting_preprocess(regs);
21621
21622 nmi_enter();
21623 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
21624 index 6d9582e..f746287 100644
21625 --- a/arch/x86/kernel/nmi_selftest.c
21626 +++ b/arch/x86/kernel/nmi_selftest.c
21627 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
21628 {
21629 /* trap all the unknown NMIs we may generate */
21630 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
21631 - __initdata);
21632 + __initconst);
21633 }
21634
21635 static void __init cleanup_nmi_testsuite(void)
21636 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
21637 unsigned long timeout;
21638
21639 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
21640 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
21641 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
21642 nmi_fail = FAILURE;
21643 return;
21644 }
21645 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
21646 index 676b8c7..870ba04 100644
21647 --- a/arch/x86/kernel/paravirt-spinlocks.c
21648 +++ b/arch/x86/kernel/paravirt-spinlocks.c
21649 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
21650 arch_spin_lock(lock);
21651 }
21652
21653 -struct pv_lock_ops pv_lock_ops = {
21654 +struct pv_lock_ops pv_lock_ops __read_only = {
21655 #ifdef CONFIG_SMP
21656 .spin_is_locked = __ticket_spin_is_locked,
21657 .spin_is_contended = __ticket_spin_is_contended,
21658 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
21659 index 8bfb335..c1463c6 100644
21660 --- a/arch/x86/kernel/paravirt.c
21661 +++ b/arch/x86/kernel/paravirt.c
21662 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
21663 {
21664 return x;
21665 }
21666 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21667 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
21668 +#endif
21669
21670 void __init default_banner(void)
21671 {
21672 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
21673 if (opfunc == NULL)
21674 /* If there's no function, patch it with a ud2a (BUG) */
21675 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
21676 - else if (opfunc == _paravirt_nop)
21677 + else if (opfunc == (void *)_paravirt_nop)
21678 /* If the operation is a nop, then nop the callsite */
21679 ret = paravirt_patch_nop();
21680
21681 /* identity functions just return their single argument */
21682 - else if (opfunc == _paravirt_ident_32)
21683 + else if (opfunc == (void *)_paravirt_ident_32)
21684 ret = paravirt_patch_ident_32(insnbuf, len);
21685 - else if (opfunc == _paravirt_ident_64)
21686 + else if (opfunc == (void *)_paravirt_ident_64)
21687 ret = paravirt_patch_ident_64(insnbuf, len);
21688 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21689 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
21690 + ret = paravirt_patch_ident_64(insnbuf, len);
21691 +#endif
21692
21693 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
21694 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
21695 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
21696 if (insn_len > len || start == NULL)
21697 insn_len = len;
21698 else
21699 - memcpy(insnbuf, start, insn_len);
21700 + memcpy(insnbuf, ktla_ktva(start), insn_len);
21701
21702 return insn_len;
21703 }
21704 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
21705 return this_cpu_read(paravirt_lazy_mode);
21706 }
21707
21708 -struct pv_info pv_info = {
21709 +struct pv_info pv_info __read_only = {
21710 .name = "bare hardware",
21711 .paravirt_enabled = 0,
21712 .kernel_rpl = 0,
21713 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
21714 #endif
21715 };
21716
21717 -struct pv_init_ops pv_init_ops = {
21718 +struct pv_init_ops pv_init_ops __read_only = {
21719 .patch = native_patch,
21720 };
21721
21722 -struct pv_time_ops pv_time_ops = {
21723 +struct pv_time_ops pv_time_ops __read_only = {
21724 .sched_clock = native_sched_clock,
21725 .steal_clock = native_steal_clock,
21726 };
21727
21728 -struct pv_irq_ops pv_irq_ops = {
21729 +struct pv_irq_ops pv_irq_ops __read_only = {
21730 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
21731 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
21732 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
21733 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
21734 #endif
21735 };
21736
21737 -struct pv_cpu_ops pv_cpu_ops = {
21738 +struct pv_cpu_ops pv_cpu_ops __read_only = {
21739 .cpuid = native_cpuid,
21740 .get_debugreg = native_get_debugreg,
21741 .set_debugreg = native_set_debugreg,
21742 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
21743 .end_context_switch = paravirt_nop,
21744 };
21745
21746 -struct pv_apic_ops pv_apic_ops = {
21747 +struct pv_apic_ops pv_apic_ops __read_only= {
21748 #ifdef CONFIG_X86_LOCAL_APIC
21749 .startup_ipi_hook = paravirt_nop,
21750 #endif
21751 };
21752
21753 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
21754 +#ifdef CONFIG_X86_32
21755 +#ifdef CONFIG_X86_PAE
21756 +/* 64-bit pagetable entries */
21757 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
21758 +#else
21759 /* 32-bit pagetable entries */
21760 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
21761 +#endif
21762 #else
21763 /* 64-bit pagetable entries */
21764 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
21765 #endif
21766
21767 -struct pv_mmu_ops pv_mmu_ops = {
21768 +struct pv_mmu_ops pv_mmu_ops __read_only = {
21769
21770 .read_cr2 = native_read_cr2,
21771 .write_cr2 = native_write_cr2,
21772 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
21773 .make_pud = PTE_IDENT,
21774
21775 .set_pgd = native_set_pgd,
21776 + .set_pgd_batched = native_set_pgd_batched,
21777 #endif
21778 #endif /* PAGETABLE_LEVELS >= 3 */
21779
21780 @@ -479,6 +492,12 @@ struct pv_mmu_ops pv_mmu_ops = {
21781 },
21782
21783 .set_fixmap = native_set_fixmap,
21784 +
21785 +#ifdef CONFIG_PAX_KERNEXEC
21786 + .pax_open_kernel = native_pax_open_kernel,
21787 + .pax_close_kernel = native_pax_close_kernel,
21788 +#endif
21789 +
21790 };
21791
21792 EXPORT_SYMBOL_GPL(pv_time_ops);
21793 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
21794 index 299d493..2ccb0ee 100644
21795 --- a/arch/x86/kernel/pci-calgary_64.c
21796 +++ b/arch/x86/kernel/pci-calgary_64.c
21797 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
21798 tce_space = be64_to_cpu(readq(target));
21799 tce_space = tce_space & TAR_SW_BITS;
21800
21801 - tce_space = tce_space & (~specified_table_size);
21802 + tce_space = tce_space & (~(unsigned long)specified_table_size);
21803 info->tce_space = (u64 *)__va(tce_space);
21804 }
21805 }
21806 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
21807 index 35ccf75..7a15747 100644
21808 --- a/arch/x86/kernel/pci-iommu_table.c
21809 +++ b/arch/x86/kernel/pci-iommu_table.c
21810 @@ -2,7 +2,7 @@
21811 #include <asm/iommu_table.h>
21812 #include <linux/string.h>
21813 #include <linux/kallsyms.h>
21814 -
21815 +#include <linux/sched.h>
21816
21817 #define DEBUG 1
21818
21819 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
21820 index 6c483ba..d10ce2f 100644
21821 --- a/arch/x86/kernel/pci-swiotlb.c
21822 +++ b/arch/x86/kernel/pci-swiotlb.c
21823 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
21824 void *vaddr, dma_addr_t dma_addr,
21825 struct dma_attrs *attrs)
21826 {
21827 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
21828 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
21829 }
21830
21831 static struct dma_map_ops swiotlb_dma_ops = {
21832 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
21833 index 14ae100..752a4f6 100644
21834 --- a/arch/x86/kernel/process.c
21835 +++ b/arch/x86/kernel/process.c
21836 @@ -36,7 +36,8 @@
21837 * section. Since TSS's are completely CPU-local, we want them
21838 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
21839 */
21840 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
21841 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
21842 +EXPORT_SYMBOL(init_tss);
21843
21844 #ifdef CONFIG_X86_64
21845 static DEFINE_PER_CPU(unsigned char, is_idle);
21846 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
21847 task_xstate_cachep =
21848 kmem_cache_create("task_xstate", xstate_size,
21849 __alignof__(union thread_xstate),
21850 - SLAB_PANIC | SLAB_NOTRACK, NULL);
21851 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
21852 }
21853
21854 /*
21855 @@ -105,7 +106,7 @@ void exit_thread(void)
21856 unsigned long *bp = t->io_bitmap_ptr;
21857
21858 if (bp) {
21859 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
21860 + struct tss_struct *tss = init_tss + get_cpu();
21861
21862 t->io_bitmap_ptr = NULL;
21863 clear_thread_flag(TIF_IO_BITMAP);
21864 @@ -136,7 +137,7 @@ void show_regs_common(void)
21865 board = dmi_get_system_info(DMI_BOARD_NAME);
21866
21867 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
21868 - current->pid, current->comm, print_tainted(),
21869 + task_pid_nr(current), current->comm, print_tainted(),
21870 init_utsname()->release,
21871 (int)strcspn(init_utsname()->version, " "),
21872 init_utsname()->version,
21873 @@ -149,6 +150,9 @@ void flush_thread(void)
21874 {
21875 struct task_struct *tsk = current;
21876
21877 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
21878 + loadsegment(gs, 0);
21879 +#endif
21880 flush_ptrace_hw_breakpoint(tsk);
21881 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
21882 drop_init_fpu(tsk);
21883 @@ -295,7 +299,7 @@ static void __exit_idle(void)
21884 void exit_idle(void)
21885 {
21886 /* idle loop has pid 0 */
21887 - if (current->pid)
21888 + if (task_pid_nr(current))
21889 return;
21890 __exit_idle();
21891 }
21892 @@ -398,7 +402,7 @@ bool xen_set_default_idle(void)
21893 return ret;
21894 }
21895 #endif
21896 -void stop_this_cpu(void *dummy)
21897 +__noreturn void stop_this_cpu(void *dummy)
21898 {
21899 local_irq_disable();
21900 /*
21901 @@ -544,16 +548,37 @@ static int __init idle_setup(char *str)
21902 }
21903 early_param("idle", idle_setup);
21904
21905 -unsigned long arch_align_stack(unsigned long sp)
21906 +#ifdef CONFIG_PAX_RANDKSTACK
21907 +void pax_randomize_kstack(struct pt_regs *regs)
21908 {
21909 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
21910 - sp -= get_random_int() % 8192;
21911 - return sp & ~0xf;
21912 -}
21913 + struct thread_struct *thread = &current->thread;
21914 + unsigned long time;
21915
21916 -unsigned long arch_randomize_brk(struct mm_struct *mm)
21917 -{
21918 - unsigned long range_end = mm->brk + 0x02000000;
21919 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
21920 -}
21921 + if (!randomize_va_space)
21922 + return;
21923 +
21924 + if (v8086_mode(regs))
21925 + return;
21926
21927 + rdtscl(time);
21928 +
21929 + /* P4 seems to return a 0 LSB, ignore it */
21930 +#ifdef CONFIG_MPENTIUM4
21931 + time &= 0x3EUL;
21932 + time <<= 2;
21933 +#elif defined(CONFIG_X86_64)
21934 + time &= 0xFUL;
21935 + time <<= 4;
21936 +#else
21937 + time &= 0x1FUL;
21938 + time <<= 3;
21939 +#endif
21940 +
21941 + thread->sp0 ^= time;
21942 + load_sp0(init_tss + smp_processor_id(), thread);
21943 +
21944 +#ifdef CONFIG_X86_64
21945 + this_cpu_write(kernel_stack, thread->sp0);
21946 +#endif
21947 +}
21948 +#endif
21949 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
21950 index b5a8905..d9cacac 100644
21951 --- a/arch/x86/kernel/process_32.c
21952 +++ b/arch/x86/kernel/process_32.c
21953 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
21954 unsigned long thread_saved_pc(struct task_struct *tsk)
21955 {
21956 return ((unsigned long *)tsk->thread.sp)[3];
21957 +//XXX return tsk->thread.eip;
21958 }
21959
21960 void __show_regs(struct pt_regs *regs, int all)
21961 @@ -74,21 +75,20 @@ void __show_regs(struct pt_regs *regs, int all)
21962 unsigned long sp;
21963 unsigned short ss, gs;
21964
21965 - if (user_mode_vm(regs)) {
21966 + if (user_mode(regs)) {
21967 sp = regs->sp;
21968 ss = regs->ss & 0xffff;
21969 - gs = get_user_gs(regs);
21970 } else {
21971 sp = kernel_stack_pointer(regs);
21972 savesegment(ss, ss);
21973 - savesegment(gs, gs);
21974 }
21975 + gs = get_user_gs(regs);
21976
21977 show_regs_common();
21978
21979 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
21980 (u16)regs->cs, regs->ip, regs->flags,
21981 - smp_processor_id());
21982 + raw_smp_processor_id());
21983 print_symbol("EIP is at %s\n", regs->ip);
21984
21985 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
21986 @@ -130,20 +130,21 @@ void release_thread(struct task_struct *dead_task)
21987 int copy_thread(unsigned long clone_flags, unsigned long sp,
21988 unsigned long arg, struct task_struct *p)
21989 {
21990 - struct pt_regs *childregs = task_pt_regs(p);
21991 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
21992 struct task_struct *tsk;
21993 int err;
21994
21995 p->thread.sp = (unsigned long) childregs;
21996 p->thread.sp0 = (unsigned long) (childregs+1);
21997 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
21998
21999 if (unlikely(p->flags & PF_KTHREAD)) {
22000 /* kernel thread */
22001 memset(childregs, 0, sizeof(struct pt_regs));
22002 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22003 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22004 - childregs->ds = __USER_DS;
22005 - childregs->es = __USER_DS;
22006 + savesegment(gs, childregs->gs);
22007 + childregs->ds = __KERNEL_DS;
22008 + childregs->es = __KERNEL_DS;
22009 childregs->fs = __KERNEL_PERCPU;
22010 childregs->bx = sp; /* function */
22011 childregs->bp = arg;
22012 @@ -250,7 +251,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22013 struct thread_struct *prev = &prev_p->thread,
22014 *next = &next_p->thread;
22015 int cpu = smp_processor_id();
22016 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22017 + struct tss_struct *tss = init_tss + cpu;
22018 fpu_switch_t fpu;
22019
22020 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22021 @@ -274,6 +275,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22022 */
22023 lazy_save_gs(prev->gs);
22024
22025 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22026 + __set_fs(task_thread_info(next_p)->addr_limit);
22027 +#endif
22028 +
22029 /*
22030 * Load the per-thread Thread-Local Storage descriptor.
22031 */
22032 @@ -304,6 +309,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22033 */
22034 arch_end_context_switch(next_p);
22035
22036 + this_cpu_write(current_task, next_p);
22037 + this_cpu_write(current_tinfo, &next_p->tinfo);
22038 +
22039 /*
22040 * Restore %gs if needed (which is common)
22041 */
22042 @@ -312,8 +320,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22043
22044 switch_fpu_finish(next_p, fpu);
22045
22046 - this_cpu_write(current_task, next_p);
22047 -
22048 return prev_p;
22049 }
22050
22051 @@ -343,4 +349,3 @@ unsigned long get_wchan(struct task_struct *p)
22052 } while (count++ < 16);
22053 return 0;
22054 }
22055 -
22056 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22057 index 0f49677..fcbf88c 100644
22058 --- a/arch/x86/kernel/process_64.c
22059 +++ b/arch/x86/kernel/process_64.c
22060 @@ -152,10 +152,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22061 struct pt_regs *childregs;
22062 struct task_struct *me = current;
22063
22064 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22065 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22066 childregs = task_pt_regs(p);
22067 p->thread.sp = (unsigned long) childregs;
22068 p->thread.usersp = me->thread.usersp;
22069 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22070 set_tsk_thread_flag(p, TIF_FORK);
22071 p->fpu_counter = 0;
22072 p->thread.io_bitmap_ptr = NULL;
22073 @@ -274,7 +275,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22074 struct thread_struct *prev = &prev_p->thread;
22075 struct thread_struct *next = &next_p->thread;
22076 int cpu = smp_processor_id();
22077 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22078 + struct tss_struct *tss = init_tss + cpu;
22079 unsigned fsindex, gsindex;
22080 fpu_switch_t fpu;
22081
22082 @@ -356,10 +357,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22083 prev->usersp = this_cpu_read(old_rsp);
22084 this_cpu_write(old_rsp, next->usersp);
22085 this_cpu_write(current_task, next_p);
22086 + this_cpu_write(current_tinfo, &next_p->tinfo);
22087
22088 - this_cpu_write(kernel_stack,
22089 - (unsigned long)task_stack_page(next_p) +
22090 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22091 + this_cpu_write(kernel_stack, next->sp0);
22092
22093 /*
22094 * Now maybe reload the debug registers and handle I/O bitmaps
22095 @@ -428,12 +428,11 @@ unsigned long get_wchan(struct task_struct *p)
22096 if (!p || p == current || p->state == TASK_RUNNING)
22097 return 0;
22098 stack = (unsigned long)task_stack_page(p);
22099 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22100 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22101 return 0;
22102 fp = *(u64 *)(p->thread.sp);
22103 do {
22104 - if (fp < (unsigned long)stack ||
22105 - fp >= (unsigned long)stack+THREAD_SIZE)
22106 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22107 return 0;
22108 ip = *(u64 *)(fp+8);
22109 if (!in_sched_functions(ip))
22110 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22111 index 29a8120..a50b5ee 100644
22112 --- a/arch/x86/kernel/ptrace.c
22113 +++ b/arch/x86/kernel/ptrace.c
22114 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22115 {
22116 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22117 unsigned long sp = (unsigned long)&regs->sp;
22118 - struct thread_info *tinfo;
22119
22120 - if (context == (sp & ~(THREAD_SIZE - 1)))
22121 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22122 return sp;
22123
22124 - tinfo = (struct thread_info *)context;
22125 - if (tinfo->previous_esp)
22126 - return tinfo->previous_esp;
22127 + sp = *(unsigned long *)context;
22128 + if (sp)
22129 + return sp;
22130
22131 return (unsigned long)regs;
22132 }
22133 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22134 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22135 {
22136 int i;
22137 - int dr7 = 0;
22138 + unsigned long dr7 = 0;
22139 struct arch_hw_breakpoint *info;
22140
22141 for (i = 0; i < HBP_NUM; i++) {
22142 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22143 unsigned long addr, unsigned long data)
22144 {
22145 int ret;
22146 - unsigned long __user *datap = (unsigned long __user *)data;
22147 + unsigned long __user *datap = (__force unsigned long __user *)data;
22148
22149 switch (request) {
22150 /* read the word at location addr in the USER area. */
22151 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22152 if ((int) addr < 0)
22153 return -EIO;
22154 ret = do_get_thread_area(child, addr,
22155 - (struct user_desc __user *)data);
22156 + (__force struct user_desc __user *) data);
22157 break;
22158
22159 case PTRACE_SET_THREAD_AREA:
22160 if ((int) addr < 0)
22161 return -EIO;
22162 ret = do_set_thread_area(child, addr,
22163 - (struct user_desc __user *)data, 0);
22164 + (__force struct user_desc __user *) data, 0);
22165 break;
22166 #endif
22167
22168 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22169
22170 #ifdef CONFIG_X86_64
22171
22172 -static struct user_regset x86_64_regsets[] __read_mostly = {
22173 +static user_regset_no_const x86_64_regsets[] __read_only = {
22174 [REGSET_GENERAL] = {
22175 .core_note_type = NT_PRSTATUS,
22176 .n = sizeof(struct user_regs_struct) / sizeof(long),
22177 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22178 #endif /* CONFIG_X86_64 */
22179
22180 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22181 -static struct user_regset x86_32_regsets[] __read_mostly = {
22182 +static user_regset_no_const x86_32_regsets[] __read_only = {
22183 [REGSET_GENERAL] = {
22184 .core_note_type = NT_PRSTATUS,
22185 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22186 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22187 */
22188 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22189
22190 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22191 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22192 {
22193 #ifdef CONFIG_X86_64
22194 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22195 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22196 memset(info, 0, sizeof(*info));
22197 info->si_signo = SIGTRAP;
22198 info->si_code = si_code;
22199 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22200 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22201 }
22202
22203 void user_single_step_siginfo(struct task_struct *tsk,
22204 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22205 # define IS_IA32 0
22206 #endif
22207
22208 +#ifdef CONFIG_GRKERNSEC_SETXID
22209 +extern void gr_delayed_cred_worker(void);
22210 +#endif
22211 +
22212 /*
22213 * We must return the syscall number to actually look up in the table.
22214 * This can be -1L to skip running any syscall at all.
22215 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22216
22217 user_exit();
22218
22219 +#ifdef CONFIG_GRKERNSEC_SETXID
22220 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22221 + gr_delayed_cred_worker();
22222 +#endif
22223 +
22224 /*
22225 * If we stepped into a sysenter/syscall insn, it trapped in
22226 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22227 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22228 */
22229 user_exit();
22230
22231 +#ifdef CONFIG_GRKERNSEC_SETXID
22232 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22233 + gr_delayed_cred_worker();
22234 +#endif
22235 +
22236 audit_syscall_exit(regs);
22237
22238 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22239 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22240 index 2cb9470..ff1fd80 100644
22241 --- a/arch/x86/kernel/pvclock.c
22242 +++ b/arch/x86/kernel/pvclock.c
22243 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22244 return pv_tsc_khz;
22245 }
22246
22247 -static atomic64_t last_value = ATOMIC64_INIT(0);
22248 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22249
22250 void pvclock_resume(void)
22251 {
22252 - atomic64_set(&last_value, 0);
22253 + atomic64_set_unchecked(&last_value, 0);
22254 }
22255
22256 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22257 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22258 * updating at the same time, and one of them could be slightly behind,
22259 * making the assumption that last_value always go forward fail to hold.
22260 */
22261 - last = atomic64_read(&last_value);
22262 + last = atomic64_read_unchecked(&last_value);
22263 do {
22264 if (ret < last)
22265 return last;
22266 - last = atomic64_cmpxchg(&last_value, last, ret);
22267 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22268 } while (unlikely(last != ret));
22269
22270 return ret;
22271 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22272 index 76fa1e9..abf09ea 100644
22273 --- a/arch/x86/kernel/reboot.c
22274 +++ b/arch/x86/kernel/reboot.c
22275 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22276 EXPORT_SYMBOL(pm_power_off);
22277
22278 static const struct desc_ptr no_idt = {};
22279 -static int reboot_mode;
22280 +static unsigned short reboot_mode;
22281 enum reboot_type reboot_type = BOOT_ACPI;
22282 int reboot_force;
22283
22284 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22285
22286 void __noreturn machine_real_restart(unsigned int type)
22287 {
22288 +
22289 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22290 + struct desc_struct *gdt;
22291 +#endif
22292 +
22293 local_irq_disable();
22294
22295 /*
22296 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22297
22298 /* Jump to the identity-mapped low memory code */
22299 #ifdef CONFIG_X86_32
22300 - asm volatile("jmpl *%0" : :
22301 +
22302 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22303 + gdt = get_cpu_gdt_table(smp_processor_id());
22304 + pax_open_kernel();
22305 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22306 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22307 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22308 + loadsegment(ds, __KERNEL_DS);
22309 + loadsegment(es, __KERNEL_DS);
22310 + loadsegment(ss, __KERNEL_DS);
22311 +#endif
22312 +#ifdef CONFIG_PAX_KERNEXEC
22313 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22314 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22315 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22316 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22317 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22318 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22319 +#endif
22320 + pax_close_kernel();
22321 +#endif
22322 +
22323 + asm volatile("ljmpl *%0" : :
22324 "rm" (real_mode_header->machine_real_restart_asm),
22325 "a" (type));
22326 #else
22327 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22328 * try to force a triple fault and then cycle between hitting the keyboard
22329 * controller and doing that
22330 */
22331 -static void native_machine_emergency_restart(void)
22332 +static void __noreturn native_machine_emergency_restart(void)
22333 {
22334 int i;
22335 int attempt = 0;
22336 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22337 #endif
22338 }
22339
22340 -static void __machine_emergency_restart(int emergency)
22341 +static void __noreturn __machine_emergency_restart(int emergency)
22342 {
22343 reboot_emergency = emergency;
22344 machine_ops.emergency_restart();
22345 }
22346
22347 -static void native_machine_restart(char *__unused)
22348 +static void __noreturn native_machine_restart(char *__unused)
22349 {
22350 pr_notice("machine restart\n");
22351
22352 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22353 __machine_emergency_restart(0);
22354 }
22355
22356 -static void native_machine_halt(void)
22357 +static void __noreturn native_machine_halt(void)
22358 {
22359 /* Stop other cpus and apics */
22360 machine_shutdown();
22361 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22362 stop_this_cpu(NULL);
22363 }
22364
22365 -static void native_machine_power_off(void)
22366 +static void __noreturn native_machine_power_off(void)
22367 {
22368 if (pm_power_off) {
22369 if (!reboot_force)
22370 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22371 }
22372 /* A fallback in case there is no PM info available */
22373 tboot_shutdown(TB_SHUTDOWN_HALT);
22374 + unreachable();
22375 }
22376
22377 -struct machine_ops machine_ops = {
22378 +struct machine_ops machine_ops __read_only = {
22379 .power_off = native_machine_power_off,
22380 .shutdown = native_machine_shutdown,
22381 .emergency_restart = native_machine_emergency_restart,
22382 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22383 index 7a6f3b3..bed145d7 100644
22384 --- a/arch/x86/kernel/relocate_kernel_64.S
22385 +++ b/arch/x86/kernel/relocate_kernel_64.S
22386 @@ -11,6 +11,7 @@
22387 #include <asm/kexec.h>
22388 #include <asm/processor-flags.h>
22389 #include <asm/pgtable_types.h>
22390 +#include <asm/alternative-asm.h>
22391
22392 /*
22393 * Must be relocatable PIC code callable as a C function
22394 @@ -160,13 +161,14 @@ identity_mapped:
22395 xorq %rbp, %rbp
22396 xorq %r8, %r8
22397 xorq %r9, %r9
22398 - xorq %r10, %r9
22399 + xorq %r10, %r10
22400 xorq %r11, %r11
22401 xorq %r12, %r12
22402 xorq %r13, %r13
22403 xorq %r14, %r14
22404 xorq %r15, %r15
22405
22406 + pax_force_retaddr 0, 1
22407 ret
22408
22409 1:
22410 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22411 index fae9134..b7d4a57 100644
22412 --- a/arch/x86/kernel/setup.c
22413 +++ b/arch/x86/kernel/setup.c
22414 @@ -111,6 +111,7 @@
22415 #include <asm/mce.h>
22416 #include <asm/alternative.h>
22417 #include <asm/prom.h>
22418 +#include <asm/boot.h>
22419
22420 /*
22421 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
22422 @@ -447,7 +448,7 @@ static void __init parse_setup_data(void)
22423
22424 switch (data->type) {
22425 case SETUP_E820_EXT:
22426 - parse_e820_ext(data);
22427 + parse_e820_ext((struct setup_data __force_kernel *)data);
22428 break;
22429 case SETUP_DTB:
22430 add_dtb(pa_data);
22431 @@ -774,7 +775,7 @@ static void __init trim_bios_range(void)
22432 * area (640->1Mb) as ram even though it is not.
22433 * take them out.
22434 */
22435 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22436 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22437
22438 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22439 }
22440 @@ -844,8 +845,12 @@ static void __init trim_low_memory_range(void)
22441
22442 void __init setup_arch(char **cmdline_p)
22443 {
22444 +#ifdef CONFIG_X86_32
22445 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - ____LOAD_PHYSICAL_ADDR);
22446 +#else
22447 memblock_reserve(__pa_symbol(_text),
22448 (unsigned long)__bss_stop - (unsigned long)_text);
22449 +#endif
22450
22451 early_reserve_initrd();
22452
22453 @@ -937,14 +942,14 @@ void __init setup_arch(char **cmdline_p)
22454
22455 if (!boot_params.hdr.root_flags)
22456 root_mountflags &= ~MS_RDONLY;
22457 - init_mm.start_code = (unsigned long) _text;
22458 - init_mm.end_code = (unsigned long) _etext;
22459 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22460 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22461 init_mm.end_data = (unsigned long) _edata;
22462 init_mm.brk = _brk_end;
22463
22464 - code_resource.start = __pa_symbol(_text);
22465 - code_resource.end = __pa_symbol(_etext)-1;
22466 - data_resource.start = __pa_symbol(_etext);
22467 + code_resource.start = __pa_symbol(ktla_ktva(_text));
22468 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
22469 + data_resource.start = __pa_symbol(_sdata);
22470 data_resource.end = __pa_symbol(_edata)-1;
22471 bss_resource.start = __pa_symbol(__bss_start);
22472 bss_resource.end = __pa_symbol(__bss_stop)-1;
22473 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22474 index 5cdff03..80fa283 100644
22475 --- a/arch/x86/kernel/setup_percpu.c
22476 +++ b/arch/x86/kernel/setup_percpu.c
22477 @@ -21,19 +21,17 @@
22478 #include <asm/cpu.h>
22479 #include <asm/stackprotector.h>
22480
22481 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22482 +#ifdef CONFIG_SMP
22483 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22484 EXPORT_PER_CPU_SYMBOL(cpu_number);
22485 +#endif
22486
22487 -#ifdef CONFIG_X86_64
22488 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22489 -#else
22490 -#define BOOT_PERCPU_OFFSET 0
22491 -#endif
22492
22493 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22494 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22495
22496 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22497 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22498 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22499 };
22500 EXPORT_SYMBOL(__per_cpu_offset);
22501 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22502 {
22503 #ifdef CONFIG_NEED_MULTIPLE_NODES
22504 pg_data_t *last = NULL;
22505 - unsigned int cpu;
22506 + int cpu;
22507
22508 for_each_possible_cpu(cpu) {
22509 int node = early_cpu_to_node(cpu);
22510 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22511 {
22512 #ifdef CONFIG_X86_32
22513 struct desc_struct gdt;
22514 + unsigned long base = per_cpu_offset(cpu);
22515
22516 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22517 - 0x2 | DESCTYPE_S, 0x8);
22518 - gdt.s = 1;
22519 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22520 + 0x83 | DESCTYPE_S, 0xC);
22521 write_gdt_entry(get_cpu_gdt_table(cpu),
22522 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22523 #endif
22524 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22525 /* alrighty, percpu areas up and running */
22526 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22527 for_each_possible_cpu(cpu) {
22528 +#ifdef CONFIG_CC_STACKPROTECTOR
22529 +#ifdef CONFIG_X86_32
22530 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
22531 +#endif
22532 +#endif
22533 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
22534 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
22535 per_cpu(cpu_number, cpu) = cpu;
22536 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
22537 */
22538 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
22539 #endif
22540 +#ifdef CONFIG_CC_STACKPROTECTOR
22541 +#ifdef CONFIG_X86_32
22542 + if (!cpu)
22543 + per_cpu(stack_canary.canary, cpu) = canary;
22544 +#endif
22545 +#endif
22546 /*
22547 * Up to this point, the boot CPU has been using .init.data
22548 * area. Reload any changed state for the boot CPU.
22549 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
22550 index 6956299..6797253 100644
22551 --- a/arch/x86/kernel/signal.c
22552 +++ b/arch/x86/kernel/signal.c
22553 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
22554 * Align the stack pointer according to the i386 ABI,
22555 * i.e. so that on function entry ((sp + 4) & 15) == 0.
22556 */
22557 - sp = ((sp + 4) & -16ul) - 4;
22558 + sp = ((sp - 12) & -16ul) - 4;
22559 #else /* !CONFIG_X86_32 */
22560 sp = round_down(sp, 16) - 8;
22561 #endif
22562 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22563 }
22564
22565 if (current->mm->context.vdso)
22566 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22567 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22568 else
22569 - restorer = &frame->retcode;
22570 + restorer = (void __user *)&frame->retcode;
22571 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22572 restorer = ksig->ka.sa.sa_restorer;
22573
22574 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22575 * reasons and because gdb uses it as a signature to notice
22576 * signal handler stack frames.
22577 */
22578 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
22579 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
22580
22581 if (err)
22582 return -EFAULT;
22583 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22584 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
22585
22586 /* Set up to return from userspace. */
22587 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22588 + if (current->mm->context.vdso)
22589 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22590 + else
22591 + restorer = (void __user *)&frame->retcode;
22592 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22593 restorer = ksig->ka.sa.sa_restorer;
22594 put_user_ex(restorer, &frame->pretcode);
22595 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22596 * reasons and because gdb uses it as a signature to notice
22597 * signal handler stack frames.
22598 */
22599 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
22600 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
22601 } put_user_catch(err);
22602
22603 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
22604 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
22605 index 48d2b7d..90d328a 100644
22606 --- a/arch/x86/kernel/smp.c
22607 +++ b/arch/x86/kernel/smp.c
22608 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
22609
22610 __setup("nonmi_ipi", nonmi_ipi_setup);
22611
22612 -struct smp_ops smp_ops = {
22613 +struct smp_ops smp_ops __read_only = {
22614 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
22615 .smp_prepare_cpus = native_smp_prepare_cpus,
22616 .smp_cpus_done = native_smp_cpus_done,
22617 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
22618 index 9f190a2..90a0688 100644
22619 --- a/arch/x86/kernel/smpboot.c
22620 +++ b/arch/x86/kernel/smpboot.c
22621 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22622 idle->thread.sp = (unsigned long) (((struct pt_regs *)
22623 (THREAD_SIZE + task_stack_page(idle))) - 1);
22624 per_cpu(current_task, cpu) = idle;
22625 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
22626
22627 #ifdef CONFIG_X86_32
22628 /* Stack for startup_32 can be just as for start_secondary onwards */
22629 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22630 #else
22631 clear_tsk_thread_flag(idle, TIF_FORK);
22632 initial_gs = per_cpu_offset(cpu);
22633 - per_cpu(kernel_stack, cpu) =
22634 - (unsigned long)task_stack_page(idle) -
22635 - KERNEL_STACK_OFFSET + THREAD_SIZE;
22636 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
22637 #endif
22638 +
22639 + pax_open_kernel();
22640 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
22641 + pax_close_kernel();
22642 +
22643 initial_code = (unsigned long)start_secondary;
22644 stack_start = idle->thread.sp;
22645
22646 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
22647 /* the FPU context is blank, nobody can own it */
22648 __cpu_disable_lazy_restore(cpu);
22649
22650 +#ifdef CONFIG_PAX_PER_CPU_PGD
22651 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
22652 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
22653 + KERNEL_PGD_PTRS);
22654 +#endif
22655 +
22656 + /* the FPU context is blank, nobody can own it */
22657 + __cpu_disable_lazy_restore(cpu);
22658 +
22659 err = do_boot_cpu(apicid, cpu, tidle);
22660 if (err) {
22661 pr_debug("do_boot_cpu failed %d\n", err);
22662 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
22663 index 9b4d51d..5d28b58 100644
22664 --- a/arch/x86/kernel/step.c
22665 +++ b/arch/x86/kernel/step.c
22666 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22667 struct desc_struct *desc;
22668 unsigned long base;
22669
22670 - seg &= ~7UL;
22671 + seg >>= 3;
22672
22673 mutex_lock(&child->mm->context.lock);
22674 - if (unlikely((seg >> 3) >= child->mm->context.size))
22675 + if (unlikely(seg >= child->mm->context.size))
22676 addr = -1L; /* bogus selector, access would fault */
22677 else {
22678 desc = child->mm->context.ldt + seg;
22679 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22680 addr += base;
22681 }
22682 mutex_unlock(&child->mm->context.lock);
22683 - }
22684 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
22685 + addr = ktla_ktva(addr);
22686
22687 return addr;
22688 }
22689 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
22690 unsigned char opcode[15];
22691 unsigned long addr = convert_ip_to_linear(child, regs);
22692
22693 + if (addr == -EINVAL)
22694 + return 0;
22695 +
22696 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
22697 for (i = 0; i < copied; i++) {
22698 switch (opcode[i]) {
22699 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
22700 new file mode 100644
22701 index 0000000..207bec6
22702 --- /dev/null
22703 +++ b/arch/x86/kernel/sys_i386_32.c
22704 @@ -0,0 +1,250 @@
22705 +/*
22706 + * This file contains various random system calls that
22707 + * have a non-standard calling sequence on the Linux/i386
22708 + * platform.
22709 + */
22710 +
22711 +#include <linux/errno.h>
22712 +#include <linux/sched.h>
22713 +#include <linux/mm.h>
22714 +#include <linux/fs.h>
22715 +#include <linux/smp.h>
22716 +#include <linux/sem.h>
22717 +#include <linux/msg.h>
22718 +#include <linux/shm.h>
22719 +#include <linux/stat.h>
22720 +#include <linux/syscalls.h>
22721 +#include <linux/mman.h>
22722 +#include <linux/file.h>
22723 +#include <linux/utsname.h>
22724 +#include <linux/ipc.h>
22725 +
22726 +#include <linux/uaccess.h>
22727 +#include <linux/unistd.h>
22728 +
22729 +#include <asm/syscalls.h>
22730 +
22731 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
22732 +{
22733 + unsigned long pax_task_size = TASK_SIZE;
22734 +
22735 +#ifdef CONFIG_PAX_SEGMEXEC
22736 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
22737 + pax_task_size = SEGMEXEC_TASK_SIZE;
22738 +#endif
22739 +
22740 + if (flags & MAP_FIXED)
22741 + if (len > pax_task_size || addr > pax_task_size - len)
22742 + return -EINVAL;
22743 +
22744 + return 0;
22745 +}
22746 +
22747 +unsigned long
22748 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
22749 + unsigned long len, unsigned long pgoff, unsigned long flags)
22750 +{
22751 + struct mm_struct *mm = current->mm;
22752 + struct vm_area_struct *vma;
22753 + unsigned long start_addr, pax_task_size = TASK_SIZE;
22754 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22755 +
22756 +#ifdef CONFIG_PAX_SEGMEXEC
22757 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22758 + pax_task_size = SEGMEXEC_TASK_SIZE;
22759 +#endif
22760 +
22761 + pax_task_size -= PAGE_SIZE;
22762 +
22763 + if (len > pax_task_size)
22764 + return -ENOMEM;
22765 +
22766 + if (flags & MAP_FIXED)
22767 + return addr;
22768 +
22769 +#ifdef CONFIG_PAX_RANDMMAP
22770 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22771 +#endif
22772 +
22773 + if (addr) {
22774 + addr = PAGE_ALIGN(addr);
22775 + if (pax_task_size - len >= addr) {
22776 + vma = find_vma(mm, addr);
22777 + if (check_heap_stack_gap(vma, addr, len, offset))
22778 + return addr;
22779 + }
22780 + }
22781 + if (len > mm->cached_hole_size) {
22782 + start_addr = addr = mm->free_area_cache;
22783 + } else {
22784 + start_addr = addr = mm->mmap_base;
22785 + mm->cached_hole_size = 0;
22786 + }
22787 +
22788 +#ifdef CONFIG_PAX_PAGEEXEC
22789 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE) && start_addr >= mm->mmap_base) {
22790 + start_addr = 0x00110000UL;
22791 +
22792 +#ifdef CONFIG_PAX_RANDMMAP
22793 + if (mm->pax_flags & MF_PAX_RANDMMAP)
22794 + start_addr += mm->delta_mmap & 0x03FFF000UL;
22795 +#endif
22796 +
22797 + if (mm->start_brk <= start_addr && start_addr < mm->mmap_base)
22798 + start_addr = addr = mm->mmap_base;
22799 + else
22800 + addr = start_addr;
22801 + }
22802 +#endif
22803 +
22804 +full_search:
22805 + for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
22806 + /* At this point: (!vma || addr < vma->vm_end). */
22807 + if (pax_task_size - len < addr) {
22808 + /*
22809 + * Start a new search - just in case we missed
22810 + * some holes.
22811 + */
22812 + if (start_addr != mm->mmap_base) {
22813 + start_addr = addr = mm->mmap_base;
22814 + mm->cached_hole_size = 0;
22815 + goto full_search;
22816 + }
22817 + return -ENOMEM;
22818 + }
22819 + if (check_heap_stack_gap(vma, addr, len, offset))
22820 + break;
22821 + if (addr + mm->cached_hole_size < vma->vm_start)
22822 + mm->cached_hole_size = vma->vm_start - addr;
22823 + addr = vma->vm_end;
22824 + if (mm->start_brk <= addr && addr < mm->mmap_base) {
22825 + start_addr = addr = mm->mmap_base;
22826 + mm->cached_hole_size = 0;
22827 + goto full_search;
22828 + }
22829 + }
22830 +
22831 + /*
22832 + * Remember the place where we stopped the search:
22833 + */
22834 + mm->free_area_cache = addr + len;
22835 + return addr;
22836 +}
22837 +
22838 +unsigned long
22839 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
22840 + const unsigned long len, const unsigned long pgoff,
22841 + const unsigned long flags)
22842 +{
22843 + struct vm_area_struct *vma;
22844 + struct mm_struct *mm = current->mm;
22845 + unsigned long base = mm->mmap_base, addr = addr0, pax_task_size = TASK_SIZE;
22846 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22847 +
22848 +#ifdef CONFIG_PAX_SEGMEXEC
22849 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22850 + pax_task_size = SEGMEXEC_TASK_SIZE;
22851 +#endif
22852 +
22853 + pax_task_size -= PAGE_SIZE;
22854 +
22855 + /* requested length too big for entire address space */
22856 + if (len > pax_task_size)
22857 + return -ENOMEM;
22858 +
22859 + if (flags & MAP_FIXED)
22860 + return addr;
22861 +
22862 +#ifdef CONFIG_PAX_PAGEEXEC
22863 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
22864 + goto bottomup;
22865 +#endif
22866 +
22867 +#ifdef CONFIG_PAX_RANDMMAP
22868 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22869 +#endif
22870 +
22871 + /* requesting a specific address */
22872 + if (addr) {
22873 + addr = PAGE_ALIGN(addr);
22874 + if (pax_task_size - len >= addr) {
22875 + vma = find_vma(mm, addr);
22876 + if (check_heap_stack_gap(vma, addr, len, offset))
22877 + return addr;
22878 + }
22879 + }
22880 +
22881 + /* check if free_area_cache is useful for us */
22882 + if (len <= mm->cached_hole_size) {
22883 + mm->cached_hole_size = 0;
22884 + mm->free_area_cache = mm->mmap_base;
22885 + }
22886 +
22887 + /* either no address requested or can't fit in requested address hole */
22888 + addr = mm->free_area_cache;
22889 +
22890 + /* make sure it can fit in the remaining address space */
22891 + if (addr > len) {
22892 + vma = find_vma(mm, addr-len);
22893 + if (check_heap_stack_gap(vma, addr - len, len, offset))
22894 + /* remember the address as a hint for next time */
22895 + return (mm->free_area_cache = addr-len);
22896 + }
22897 +
22898 + if (mm->mmap_base < len)
22899 + goto bottomup;
22900 +
22901 + addr = mm->mmap_base-len;
22902 +
22903 + do {
22904 + /*
22905 + * Lookup failure means no vma is above this address,
22906 + * else if new region fits below vma->vm_start,
22907 + * return with success:
22908 + */
22909 + vma = find_vma(mm, addr);
22910 + if (check_heap_stack_gap(vma, addr, len, offset))
22911 + /* remember the address as a hint for next time */
22912 + return (mm->free_area_cache = addr);
22913 +
22914 + /* remember the largest hole we saw so far */
22915 + if (addr + mm->cached_hole_size < vma->vm_start)
22916 + mm->cached_hole_size = vma->vm_start - addr;
22917 +
22918 + /* try just below the current vma->vm_start */
22919 + addr = skip_heap_stack_gap(vma, len, offset);
22920 + } while (!IS_ERR_VALUE(addr));
22921 +
22922 +bottomup:
22923 + /*
22924 + * A failed mmap() very likely causes application failure,
22925 + * so fall back to the bottom-up function here. This scenario
22926 + * can happen with large stack limits and large mmap()
22927 + * allocations.
22928 + */
22929 +
22930 +#ifdef CONFIG_PAX_SEGMEXEC
22931 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22932 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
22933 + else
22934 +#endif
22935 +
22936 + mm->mmap_base = TASK_UNMAPPED_BASE;
22937 +
22938 +#ifdef CONFIG_PAX_RANDMMAP
22939 + if (mm->pax_flags & MF_PAX_RANDMMAP)
22940 + mm->mmap_base += mm->delta_mmap;
22941 +#endif
22942 +
22943 + mm->free_area_cache = mm->mmap_base;
22944 + mm->cached_hole_size = ~0UL;
22945 + addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
22946 + /*
22947 + * Restore the topdown base:
22948 + */
22949 + mm->mmap_base = base;
22950 + mm->free_area_cache = base;
22951 + mm->cached_hole_size = ~0UL;
22952 +
22953 + return addr;
22954 +}
22955 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
22956 index dbded5a..7916f74 100644
22957 --- a/arch/x86/kernel/sys_x86_64.c
22958 +++ b/arch/x86/kernel/sys_x86_64.c
22959 @@ -81,8 +81,8 @@ out:
22960 return error;
22961 }
22962
22963 -static void find_start_end(unsigned long flags, unsigned long *begin,
22964 - unsigned long *end)
22965 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
22966 + unsigned long *begin, unsigned long *end)
22967 {
22968 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
22969 unsigned long new_begin;
22970 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
22971 *begin = new_begin;
22972 }
22973 } else {
22974 - *begin = TASK_UNMAPPED_BASE;
22975 + *begin = mm->mmap_base;
22976 *end = TASK_SIZE;
22977 }
22978 }
22979 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
22980 struct vm_area_struct *vma;
22981 struct vm_unmapped_area_info info;
22982 unsigned long begin, end;
22983 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22984
22985 if (flags & MAP_FIXED)
22986 return addr;
22987
22988 - find_start_end(flags, &begin, &end);
22989 + find_start_end(mm, flags, &begin, &end);
22990
22991 if (len > end)
22992 return -ENOMEM;
22993
22994 +#ifdef CONFIG_PAX_RANDMMAP
22995 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22996 +#endif
22997 +
22998 if (addr) {
22999 addr = PAGE_ALIGN(addr);
23000 vma = find_vma(mm, addr);
23001 - if (end - len >= addr &&
23002 - (!vma || addr + len <= vma->vm_start))
23003 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23004 return addr;
23005 }
23006
23007 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23008 info.high_limit = end;
23009 info.align_mask = filp ? get_align_mask() : 0;
23010 info.align_offset = pgoff << PAGE_SHIFT;
23011 + info.threadstack_offset = offset;
23012 return vm_unmapped_area(&info);
23013 }
23014
23015 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23016 struct mm_struct *mm = current->mm;
23017 unsigned long addr = addr0;
23018 struct vm_unmapped_area_info info;
23019 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23020
23021 /* requested length too big for entire address space */
23022 if (len > TASK_SIZE)
23023 @@ -161,6 +167,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23024 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23025 goto bottomup;
23026
23027 +#ifdef CONFIG_PAX_RANDMMAP
23028 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23029 +#endif
23030 +
23031 /* requesting a specific address */
23032 if (addr) {
23033 addr = PAGE_ALIGN(addr);
23034 @@ -176,6 +186,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23035 info.high_limit = mm->mmap_base;
23036 info.align_mask = filp ? get_align_mask() : 0;
23037 info.align_offset = pgoff << PAGE_SHIFT;
23038 + info.threadstack_offset = offset;
23039 addr = vm_unmapped_area(&info);
23040 if (!(addr & ~PAGE_MASK))
23041 return addr;
23042 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23043 index f84fe00..f41d9f1 100644
23044 --- a/arch/x86/kernel/tboot.c
23045 +++ b/arch/x86/kernel/tboot.c
23046 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23047
23048 void tboot_shutdown(u32 shutdown_type)
23049 {
23050 - void (*shutdown)(void);
23051 + void (* __noreturn shutdown)(void);
23052
23053 if (!tboot_enabled())
23054 return;
23055 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23056
23057 switch_to_tboot_pt();
23058
23059 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23060 + shutdown = (void *)tboot->shutdown_entry;
23061 shutdown();
23062
23063 /* should not reach here */
23064 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23065 return 0;
23066 }
23067
23068 -static atomic_t ap_wfs_count;
23069 +static atomic_unchecked_t ap_wfs_count;
23070
23071 static int tboot_wait_for_aps(int num_aps)
23072 {
23073 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23074 {
23075 switch (action) {
23076 case CPU_DYING:
23077 - atomic_inc(&ap_wfs_count);
23078 + atomic_inc_unchecked(&ap_wfs_count);
23079 if (num_online_cpus() == 1)
23080 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23081 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23082 return NOTIFY_BAD;
23083 break;
23084 }
23085 return NOTIFY_OK;
23086 }
23087
23088 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23089 +static struct notifier_block tboot_cpu_notifier =
23090 {
23091 .notifier_call = tboot_cpu_callback,
23092 };
23093 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23094
23095 tboot_create_trampoline();
23096
23097 - atomic_set(&ap_wfs_count, 0);
23098 + atomic_set_unchecked(&ap_wfs_count, 0);
23099 register_hotcpu_notifier(&tboot_cpu_notifier);
23100
23101 acpi_os_set_prepare_sleep(&tboot_sleep);
23102 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23103 index 24d3c91..d06b473 100644
23104 --- a/arch/x86/kernel/time.c
23105 +++ b/arch/x86/kernel/time.c
23106 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23107 {
23108 unsigned long pc = instruction_pointer(regs);
23109
23110 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23111 + if (!user_mode(regs) && in_lock_functions(pc)) {
23112 #ifdef CONFIG_FRAME_POINTER
23113 - return *(unsigned long *)(regs->bp + sizeof(long));
23114 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23115 #else
23116 unsigned long *sp =
23117 (unsigned long *)kernel_stack_pointer(regs);
23118 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23119 * or above a saved flags. Eflags has bits 22-31 zero,
23120 * kernel addresses don't.
23121 */
23122 +
23123 +#ifdef CONFIG_PAX_KERNEXEC
23124 + return ktla_ktva(sp[0]);
23125 +#else
23126 if (sp[0] >> 22)
23127 return sp[0];
23128 if (sp[1] >> 22)
23129 return sp[1];
23130 #endif
23131 +
23132 +#endif
23133 }
23134 return pc;
23135 }
23136 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23137 index 9d9d2f9..cad418a 100644
23138 --- a/arch/x86/kernel/tls.c
23139 +++ b/arch/x86/kernel/tls.c
23140 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23141 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23142 return -EINVAL;
23143
23144 +#ifdef CONFIG_PAX_SEGMEXEC
23145 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23146 + return -EINVAL;
23147 +#endif
23148 +
23149 set_tls_desc(p, idx, &info, 1);
23150
23151 return 0;
23152 @@ -204,7 +209,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23153
23154 if (kbuf)
23155 info = kbuf;
23156 - else if (__copy_from_user(infobuf, ubuf, count))
23157 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23158 return -EFAULT;
23159 else
23160 info = infobuf;
23161 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23162 index 68bda7a..3ec7bb7 100644
23163 --- a/arch/x86/kernel/traps.c
23164 +++ b/arch/x86/kernel/traps.c
23165 @@ -68,12 +68,6 @@
23166 #include <asm/setup.h>
23167
23168 asmlinkage int system_call(void);
23169 -
23170 -/*
23171 - * The IDT has to be page-aligned to simplify the Pentium
23172 - * F0 0F bug workaround.
23173 - */
23174 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23175 #endif
23176
23177 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23178 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23179 }
23180
23181 static int __kprobes
23182 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23183 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23184 struct pt_regs *regs, long error_code)
23185 {
23186 #ifdef CONFIG_X86_32
23187 - if (regs->flags & X86_VM_MASK) {
23188 + if (v8086_mode(regs)) {
23189 /*
23190 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23191 * On nmi (interrupt 2), do_trap should not be called.
23192 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23193 return -1;
23194 }
23195 #endif
23196 - if (!user_mode(regs)) {
23197 + if (!user_mode_novm(regs)) {
23198 if (!fixup_exception(regs)) {
23199 tsk->thread.error_code = error_code;
23200 tsk->thread.trap_nr = trapnr;
23201 +
23202 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23203 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23204 + str = "PAX: suspicious stack segment fault";
23205 +#endif
23206 +
23207 die(str, regs, error_code);
23208 }
23209 +
23210 +#ifdef CONFIG_PAX_REFCOUNT
23211 + if (trapnr == 4)
23212 + pax_report_refcount_overflow(regs);
23213 +#endif
23214 +
23215 return 0;
23216 }
23217
23218 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23219 }
23220
23221 static void __kprobes
23222 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23223 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23224 long error_code, siginfo_t *info)
23225 {
23226 struct task_struct *tsk = current;
23227 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23228 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23229 printk_ratelimit()) {
23230 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23231 - tsk->comm, tsk->pid, str,
23232 + tsk->comm, task_pid_nr(tsk), str,
23233 regs->ip, regs->sp, error_code);
23234 print_vma_addr(" in ", regs->ip);
23235 pr_cont("\n");
23236 @@ -266,7 +272,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23237 conditional_sti(regs);
23238
23239 #ifdef CONFIG_X86_32
23240 - if (regs->flags & X86_VM_MASK) {
23241 + if (v8086_mode(regs)) {
23242 local_irq_enable();
23243 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23244 goto exit;
23245 @@ -274,18 +280,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23246 #endif
23247
23248 tsk = current;
23249 - if (!user_mode(regs)) {
23250 + if (!user_mode_novm(regs)) {
23251 if (fixup_exception(regs))
23252 goto exit;
23253
23254 tsk->thread.error_code = error_code;
23255 tsk->thread.trap_nr = X86_TRAP_GP;
23256 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23257 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23258 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23259 +
23260 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23261 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23262 + die("PAX: suspicious general protection fault", regs, error_code);
23263 + else
23264 +#endif
23265 +
23266 die("general protection fault", regs, error_code);
23267 + }
23268 goto exit;
23269 }
23270
23271 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23272 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23273 + struct mm_struct *mm = tsk->mm;
23274 + unsigned long limit;
23275 +
23276 + down_write(&mm->mmap_sem);
23277 + limit = mm->context.user_cs_limit;
23278 + if (limit < TASK_SIZE) {
23279 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23280 + up_write(&mm->mmap_sem);
23281 + return;
23282 + }
23283 + up_write(&mm->mmap_sem);
23284 + }
23285 +#endif
23286 +
23287 tsk->thread.error_code = error_code;
23288 tsk->thread.trap_nr = X86_TRAP_GP;
23289
23290 @@ -440,7 +470,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23291 /* It's safe to allow irq's after DR6 has been saved */
23292 preempt_conditional_sti(regs);
23293
23294 - if (regs->flags & X86_VM_MASK) {
23295 + if (v8086_mode(regs)) {
23296 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23297 X86_TRAP_DB);
23298 preempt_conditional_cli(regs);
23299 @@ -455,7 +485,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23300 * We already checked v86 mode above, so we can check for kernel mode
23301 * by just checking the CPL of CS.
23302 */
23303 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23304 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23305 tsk->thread.debugreg6 &= ~DR_STEP;
23306 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23307 regs->flags &= ~X86_EFLAGS_TF;
23308 @@ -487,7 +517,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23309 return;
23310 conditional_sti(regs);
23311
23312 - if (!user_mode_vm(regs))
23313 + if (!user_mode(regs))
23314 {
23315 if (!fixup_exception(regs)) {
23316 task->thread.error_code = error_code;
23317 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23318 index 0ba4cfb..4596bec 100644
23319 --- a/arch/x86/kernel/uprobes.c
23320 +++ b/arch/x86/kernel/uprobes.c
23321 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23322 int ret = NOTIFY_DONE;
23323
23324 /* We are only interested in userspace traps */
23325 - if (regs && !user_mode_vm(regs))
23326 + if (regs && !user_mode(regs))
23327 return NOTIFY_DONE;
23328
23329 switch (val) {
23330 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23331 index b9242ba..50c5edd 100644
23332 --- a/arch/x86/kernel/verify_cpu.S
23333 +++ b/arch/x86/kernel/verify_cpu.S
23334 @@ -20,6 +20,7 @@
23335 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23336 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23337 * arch/x86/kernel/head_32.S: processor startup
23338 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23339 *
23340 * verify_cpu, returns the status of longmode and SSE in register %eax.
23341 * 0: Success 1: Failure
23342 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23343 index 1cf5766..c0d9de7 100644
23344 --- a/arch/x86/kernel/vm86_32.c
23345 +++ b/arch/x86/kernel/vm86_32.c
23346 @@ -43,6 +43,7 @@
23347 #include <linux/ptrace.h>
23348 #include <linux/audit.h>
23349 #include <linux/stddef.h>
23350 +#include <linux/grsecurity.h>
23351
23352 #include <asm/uaccess.h>
23353 #include <asm/io.h>
23354 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23355 do_exit(SIGSEGV);
23356 }
23357
23358 - tss = &per_cpu(init_tss, get_cpu());
23359 + tss = init_tss + get_cpu();
23360 current->thread.sp0 = current->thread.saved_sp0;
23361 current->thread.sysenter_cs = __KERNEL_CS;
23362 load_sp0(tss, &current->thread);
23363 @@ -212,6 +213,13 @@ int sys_vm86old(struct vm86_struct __user *v86)
23364 struct task_struct *tsk;
23365 int tmp, ret = -EPERM;
23366
23367 +#ifdef CONFIG_GRKERNSEC_VM86
23368 + if (!capable(CAP_SYS_RAWIO)) {
23369 + gr_handle_vm86();
23370 + goto out;
23371 + }
23372 +#endif
23373 +
23374 tsk = current;
23375 if (tsk->thread.saved_sp0)
23376 goto out;
23377 @@ -242,6 +250,14 @@ int sys_vm86(unsigned long cmd, unsigned long arg)
23378 int tmp, ret;
23379 struct vm86plus_struct __user *v86;
23380
23381 +#ifdef CONFIG_GRKERNSEC_VM86
23382 + if (!capable(CAP_SYS_RAWIO)) {
23383 + gr_handle_vm86();
23384 + ret = -EPERM;
23385 + goto out;
23386 + }
23387 +#endif
23388 +
23389 tsk = current;
23390 switch (cmd) {
23391 case VM86_REQUEST_IRQ:
23392 @@ -328,7 +344,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23393 tsk->thread.saved_fs = info->regs32->fs;
23394 tsk->thread.saved_gs = get_user_gs(info->regs32);
23395
23396 - tss = &per_cpu(init_tss, get_cpu());
23397 + tss = init_tss + get_cpu();
23398 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23399 if (cpu_has_sep)
23400 tsk->thread.sysenter_cs = 0;
23401 @@ -535,7 +551,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23402 goto cannot_handle;
23403 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23404 goto cannot_handle;
23405 - intr_ptr = (unsigned long __user *) (i << 2);
23406 + intr_ptr = (__force unsigned long __user *) (i << 2);
23407 if (get_user(segoffs, intr_ptr))
23408 goto cannot_handle;
23409 if ((segoffs >> 16) == BIOSSEG)
23410 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23411 index 22a1530..8fbaaad 100644
23412 --- a/arch/x86/kernel/vmlinux.lds.S
23413 +++ b/arch/x86/kernel/vmlinux.lds.S
23414 @@ -26,6 +26,13 @@
23415 #include <asm/page_types.h>
23416 #include <asm/cache.h>
23417 #include <asm/boot.h>
23418 +#include <asm/segment.h>
23419 +
23420 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23421 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23422 +#else
23423 +#define __KERNEL_TEXT_OFFSET 0
23424 +#endif
23425
23426 #undef i386 /* in case the preprocessor is a 32bit one */
23427
23428 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23429
23430 PHDRS {
23431 text PT_LOAD FLAGS(5); /* R_E */
23432 +#ifdef CONFIG_X86_32
23433 + module PT_LOAD FLAGS(5); /* R_E */
23434 +#endif
23435 +#ifdef CONFIG_XEN
23436 + rodata PT_LOAD FLAGS(5); /* R_E */
23437 +#else
23438 + rodata PT_LOAD FLAGS(4); /* R__ */
23439 +#endif
23440 data PT_LOAD FLAGS(6); /* RW_ */
23441 -#ifdef CONFIG_X86_64
23442 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23443 #ifdef CONFIG_SMP
23444 percpu PT_LOAD FLAGS(6); /* RW_ */
23445 #endif
23446 + text.init PT_LOAD FLAGS(5); /* R_E */
23447 + text.exit PT_LOAD FLAGS(5); /* R_E */
23448 init PT_LOAD FLAGS(7); /* RWE */
23449 -#endif
23450 note PT_NOTE FLAGS(0); /* ___ */
23451 }
23452
23453 SECTIONS
23454 {
23455 #ifdef CONFIG_X86_32
23456 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23457 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23458 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23459 #else
23460 - . = __START_KERNEL;
23461 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23462 + . = __START_KERNEL;
23463 #endif
23464
23465 /* Text and read-only data */
23466 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23467 - _text = .;
23468 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23469 /* bootstrapping code */
23470 +#ifdef CONFIG_X86_32
23471 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23472 +#else
23473 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23474 +#endif
23475 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23476 + _text = .;
23477 HEAD_TEXT
23478 #ifdef CONFIG_X86_32
23479 . = ALIGN(PAGE_SIZE);
23480 @@ -108,13 +128,48 @@ SECTIONS
23481 IRQENTRY_TEXT
23482 *(.fixup)
23483 *(.gnu.warning)
23484 - /* End of text section */
23485 - _etext = .;
23486 } :text = 0x9090
23487
23488 - NOTES :text :note
23489 + . += __KERNEL_TEXT_OFFSET;
23490
23491 - EXCEPTION_TABLE(16) :text = 0x9090
23492 +#ifdef CONFIG_X86_32
23493 + . = ALIGN(PAGE_SIZE);
23494 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23495 +
23496 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_MODULES)
23497 + MODULES_EXEC_VADDR = .;
23498 + BYTE(0)
23499 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23500 + . = ALIGN(HPAGE_SIZE) - 1;
23501 + MODULES_EXEC_END = .;
23502 +#endif
23503 +
23504 + } :module
23505 +#endif
23506 +
23507 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23508 + /* End of text section */
23509 + BYTE(0)
23510 + _etext = . - __KERNEL_TEXT_OFFSET;
23511 + }
23512 +
23513 +#ifdef CONFIG_X86_32
23514 + . = ALIGN(PAGE_SIZE);
23515 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23516 + *(.idt)
23517 + . = ALIGN(PAGE_SIZE);
23518 + *(.empty_zero_page)
23519 + *(.initial_pg_fixmap)
23520 + *(.initial_pg_pmd)
23521 + *(.initial_page_table)
23522 + *(.swapper_pg_dir)
23523 + } :rodata
23524 +#endif
23525 +
23526 + . = ALIGN(PAGE_SIZE);
23527 + NOTES :rodata :note
23528 +
23529 + EXCEPTION_TABLE(16) :rodata
23530
23531 #if defined(CONFIG_DEBUG_RODATA)
23532 /* .text should occupy whole number of pages */
23533 @@ -126,16 +181,20 @@ SECTIONS
23534
23535 /* Data */
23536 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23537 +
23538 +#ifdef CONFIG_PAX_KERNEXEC
23539 + . = ALIGN(HPAGE_SIZE);
23540 +#else
23541 + . = ALIGN(PAGE_SIZE);
23542 +#endif
23543 +
23544 /* Start of data section */
23545 _sdata = .;
23546
23547 /* init_task */
23548 INIT_TASK_DATA(THREAD_SIZE)
23549
23550 -#ifdef CONFIG_X86_32
23551 - /* 32 bit has nosave before _edata */
23552 NOSAVE_DATA
23553 -#endif
23554
23555 PAGE_ALIGNED_DATA(PAGE_SIZE)
23556
23557 @@ -176,12 +235,19 @@ SECTIONS
23558 #endif /* CONFIG_X86_64 */
23559
23560 /* Init code and data - will be freed after init */
23561 - . = ALIGN(PAGE_SIZE);
23562 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
23563 + BYTE(0)
23564 +
23565 +#ifdef CONFIG_PAX_KERNEXEC
23566 + . = ALIGN(HPAGE_SIZE);
23567 +#else
23568 + . = ALIGN(PAGE_SIZE);
23569 +#endif
23570 +
23571 __init_begin = .; /* paired with __init_end */
23572 - }
23573 + } :init.begin
23574
23575 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
23576 +#ifdef CONFIG_SMP
23577 /*
23578 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
23579 * output PHDR, so the next output section - .init.text - should
23580 @@ -190,12 +256,27 @@ SECTIONS
23581 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
23582 #endif
23583
23584 - INIT_TEXT_SECTION(PAGE_SIZE)
23585 -#ifdef CONFIG_X86_64
23586 - :init
23587 -#endif
23588 + . = ALIGN(PAGE_SIZE);
23589 + init_begin = .;
23590 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
23591 + VMLINUX_SYMBOL(_sinittext) = .;
23592 + INIT_TEXT
23593 + VMLINUX_SYMBOL(_einittext) = .;
23594 + . = ALIGN(PAGE_SIZE);
23595 + } :text.init
23596
23597 - INIT_DATA_SECTION(16)
23598 + /*
23599 + * .exit.text is discard at runtime, not link time, to deal with
23600 + * references from .altinstructions and .eh_frame
23601 + */
23602 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23603 + EXIT_TEXT
23604 + . = ALIGN(16);
23605 + } :text.exit
23606 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
23607 +
23608 + . = ALIGN(PAGE_SIZE);
23609 + INIT_DATA_SECTION(16) :init
23610
23611 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
23612 __x86_cpu_dev_start = .;
23613 @@ -257,19 +338,12 @@ SECTIONS
23614 }
23615
23616 . = ALIGN(8);
23617 - /*
23618 - * .exit.text is discard at runtime, not link time, to deal with
23619 - * references from .altinstructions and .eh_frame
23620 - */
23621 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
23622 - EXIT_TEXT
23623 - }
23624
23625 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
23626 EXIT_DATA
23627 }
23628
23629 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
23630 +#ifndef CONFIG_SMP
23631 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
23632 #endif
23633
23634 @@ -288,16 +362,10 @@ SECTIONS
23635 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
23636 __smp_locks = .;
23637 *(.smp_locks)
23638 - . = ALIGN(PAGE_SIZE);
23639 __smp_locks_end = .;
23640 + . = ALIGN(PAGE_SIZE);
23641 }
23642
23643 -#ifdef CONFIG_X86_64
23644 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
23645 - NOSAVE_DATA
23646 - }
23647 -#endif
23648 -
23649 /* BSS */
23650 . = ALIGN(PAGE_SIZE);
23651 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
23652 @@ -313,6 +381,7 @@ SECTIONS
23653 __brk_base = .;
23654 . += 64 * 1024; /* 64k alignment slop space */
23655 *(.brk_reservation) /* areas brk users have reserved */
23656 + . = ALIGN(HPAGE_SIZE);
23657 __brk_limit = .;
23658 }
23659
23660 @@ -339,13 +408,12 @@ SECTIONS
23661 * for the boot processor.
23662 */
23663 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
23664 -INIT_PER_CPU(gdt_page);
23665 INIT_PER_CPU(irq_stack_union);
23666
23667 /*
23668 * Build-time check on the image size:
23669 */
23670 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
23671 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
23672 "kernel image bigger than KERNEL_IMAGE_SIZE");
23673
23674 #ifdef CONFIG_SMP
23675 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
23676 index 9a907a6..f83f921 100644
23677 --- a/arch/x86/kernel/vsyscall_64.c
23678 +++ b/arch/x86/kernel/vsyscall_64.c
23679 @@ -56,15 +56,13 @@
23680 DEFINE_VVAR(int, vgetcpu_mode);
23681 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
23682
23683 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
23684 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
23685
23686 static int __init vsyscall_setup(char *str)
23687 {
23688 if (str) {
23689 if (!strcmp("emulate", str))
23690 vsyscall_mode = EMULATE;
23691 - else if (!strcmp("native", str))
23692 - vsyscall_mode = NATIVE;
23693 else if (!strcmp("none", str))
23694 vsyscall_mode = NONE;
23695 else
23696 @@ -323,8 +321,7 @@ do_ret:
23697 return true;
23698
23699 sigsegv:
23700 - force_sig(SIGSEGV, current);
23701 - return true;
23702 + do_group_exit(SIGKILL);
23703 }
23704
23705 /*
23706 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
23707 extern char __vvar_page;
23708 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
23709
23710 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
23711 - vsyscall_mode == NATIVE
23712 - ? PAGE_KERNEL_VSYSCALL
23713 - : PAGE_KERNEL_VVAR);
23714 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
23715 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
23716 (unsigned long)VSYSCALL_START);
23717
23718 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
23719 index b014d94..6d6ca7b 100644
23720 --- a/arch/x86/kernel/x8664_ksyms_64.c
23721 +++ b/arch/x86/kernel/x8664_ksyms_64.c
23722 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
23723 EXPORT_SYMBOL(copy_user_generic_unrolled);
23724 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
23725 EXPORT_SYMBOL(__copy_user_nocache);
23726 -EXPORT_SYMBOL(_copy_from_user);
23727 -EXPORT_SYMBOL(_copy_to_user);
23728
23729 EXPORT_SYMBOL(copy_page);
23730 EXPORT_SYMBOL(clear_page);
23731 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
23732 index 45a14db..075bb9b 100644
23733 --- a/arch/x86/kernel/x86_init.c
23734 +++ b/arch/x86/kernel/x86_init.c
23735 @@ -85,7 +85,7 @@ struct x86_init_ops x86_init __initdata = {
23736 },
23737 };
23738
23739 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23740 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
23741 .early_percpu_clock_init = x86_init_noop,
23742 .setup_percpu_clockev = setup_secondary_APIC_clock,
23743 };
23744 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23745 static void default_nmi_init(void) { };
23746 static int default_i8042_detect(void) { return 1; };
23747
23748 -struct x86_platform_ops x86_platform = {
23749 +struct x86_platform_ops x86_platform __read_only = {
23750 .calibrate_tsc = native_calibrate_tsc,
23751 .get_wallclock = mach_get_cmos_time,
23752 .set_wallclock = mach_set_rtc_mmss,
23753 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
23754 };
23755
23756 EXPORT_SYMBOL_GPL(x86_platform);
23757 -struct x86_msi_ops x86_msi = {
23758 +struct x86_msi_ops x86_msi __read_only = {
23759 .setup_msi_irqs = native_setup_msi_irqs,
23760 .compose_msi_msg = native_compose_msi_msg,
23761 .teardown_msi_irq = native_teardown_msi_irq,
23762 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
23763 .setup_hpet_msi = default_setup_hpet_msi,
23764 };
23765
23766 -struct x86_io_apic_ops x86_io_apic_ops = {
23767 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
23768 .init = native_io_apic_init_mappings,
23769 .read = native_io_apic_read,
23770 .write = native_io_apic_write,
23771 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
23772 index ada87a3..afea76d 100644
23773 --- a/arch/x86/kernel/xsave.c
23774 +++ b/arch/x86/kernel/xsave.c
23775 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
23776 {
23777 int err;
23778
23779 + buf = (struct xsave_struct __user *)____m(buf);
23780 if (use_xsave())
23781 err = xsave_user(buf);
23782 else if (use_fxsr())
23783 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
23784 */
23785 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
23786 {
23787 + buf = (void __user *)____m(buf);
23788 if (use_xsave()) {
23789 if ((unsigned long)buf % 64 || fx_only) {
23790 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
23791 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
23792 index a20ecb5..d0e2194 100644
23793 --- a/arch/x86/kvm/cpuid.c
23794 +++ b/arch/x86/kvm/cpuid.c
23795 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
23796 struct kvm_cpuid2 *cpuid,
23797 struct kvm_cpuid_entry2 __user *entries)
23798 {
23799 - int r;
23800 + int r, i;
23801
23802 r = -E2BIG;
23803 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
23804 goto out;
23805 r = -EFAULT;
23806 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
23807 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23808 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23809 goto out;
23810 + for (i = 0; i < cpuid->nent; ++i) {
23811 + struct kvm_cpuid_entry2 cpuid_entry;
23812 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
23813 + goto out;
23814 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
23815 + }
23816 vcpu->arch.cpuid_nent = cpuid->nent;
23817 kvm_apic_set_version(vcpu);
23818 kvm_x86_ops->cpuid_update(vcpu);
23819 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
23820 struct kvm_cpuid2 *cpuid,
23821 struct kvm_cpuid_entry2 __user *entries)
23822 {
23823 - int r;
23824 + int r, i;
23825
23826 r = -E2BIG;
23827 if (cpuid->nent < vcpu->arch.cpuid_nent)
23828 goto out;
23829 r = -EFAULT;
23830 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
23831 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23832 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23833 goto out;
23834 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
23835 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
23836 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
23837 + goto out;
23838 + }
23839 return 0;
23840
23841 out:
23842 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
23843 index a9c9d3e..9fe214f 100644
23844 --- a/arch/x86/kvm/emulate.c
23845 +++ b/arch/x86/kvm/emulate.c
23846 @@ -326,6 +326,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23847
23848 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
23849 do { \
23850 + unsigned long _tmp; \
23851 __asm__ __volatile__ ( \
23852 _PRE_EFLAGS("0", "4", "2") \
23853 _op _suffix " %"_x"3,%1; " \
23854 @@ -340,8 +341,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23855 /* Raw emulation: instruction has two explicit operands. */
23856 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
23857 do { \
23858 - unsigned long _tmp; \
23859 - \
23860 switch ((ctxt)->dst.bytes) { \
23861 case 2: \
23862 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
23863 @@ -357,7 +356,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23864
23865 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
23866 do { \
23867 - unsigned long _tmp; \
23868 switch ((ctxt)->dst.bytes) { \
23869 case 1: \
23870 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
23871 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
23872 index f77df1c..6f20690 100644
23873 --- a/arch/x86/kvm/lapic.c
23874 +++ b/arch/x86/kvm/lapic.c
23875 @@ -55,7 +55,7 @@
23876 #define APIC_BUS_CYCLE_NS 1
23877
23878 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
23879 -#define apic_debug(fmt, arg...)
23880 +#define apic_debug(fmt, arg...) do {} while (0)
23881
23882 #define APIC_LVT_NUM 6
23883 /* 14 is the version for Xeon and Pentium 8.4.8*/
23884 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
23885 index 105dd5b..1b0ccc2 100644
23886 --- a/arch/x86/kvm/paging_tmpl.h
23887 +++ b/arch/x86/kvm/paging_tmpl.h
23888 @@ -208,7 +208,7 @@ retry_walk:
23889 if (unlikely(kvm_is_error_hva(host_addr)))
23890 goto error;
23891
23892 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
23893 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
23894 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
23895 goto error;
23896 walker->ptep_user[walker->level - 1] = ptep_user;
23897 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
23898 index e1b1ce2..f7b4b43 100644
23899 --- a/arch/x86/kvm/svm.c
23900 +++ b/arch/x86/kvm/svm.c
23901 @@ -3507,7 +3507,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
23902 int cpu = raw_smp_processor_id();
23903
23904 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
23905 +
23906 + pax_open_kernel();
23907 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
23908 + pax_close_kernel();
23909 +
23910 load_TR_desc();
23911 }
23912
23913 @@ -3901,6 +3905,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
23914 #endif
23915 #endif
23916
23917 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
23918 + __set_fs(current_thread_info()->addr_limit);
23919 +#endif
23920 +
23921 reload_tss(vcpu);
23922
23923 local_irq_disable();
23924 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
23925 index 6667042..b47ece4 100644
23926 --- a/arch/x86/kvm/vmx.c
23927 +++ b/arch/x86/kvm/vmx.c
23928 @@ -1184,12 +1184,12 @@ static void vmcs_write64(unsigned long field, u64 value)
23929 #endif
23930 }
23931
23932 -static void vmcs_clear_bits(unsigned long field, u32 mask)
23933 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
23934 {
23935 vmcs_writel(field, vmcs_readl(field) & ~mask);
23936 }
23937
23938 -static void vmcs_set_bits(unsigned long field, u32 mask)
23939 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
23940 {
23941 vmcs_writel(field, vmcs_readl(field) | mask);
23942 }
23943 @@ -1390,7 +1390,11 @@ static void reload_tss(void)
23944 struct desc_struct *descs;
23945
23946 descs = (void *)gdt->address;
23947 +
23948 + pax_open_kernel();
23949 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
23950 + pax_close_kernel();
23951 +
23952 load_TR_desc();
23953 }
23954
23955 @@ -1614,6 +1618,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
23956 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
23957 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
23958
23959 +#ifdef CONFIG_PAX_PER_CPU_PGD
23960 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
23961 +#endif
23962 +
23963 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
23964 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
23965 vmx->loaded_vmcs->cpu = cpu;
23966 @@ -2779,8 +2787,11 @@ static __init int hardware_setup(void)
23967 if (!cpu_has_vmx_flexpriority())
23968 flexpriority_enabled = 0;
23969
23970 - if (!cpu_has_vmx_tpr_shadow())
23971 - kvm_x86_ops->update_cr8_intercept = NULL;
23972 + if (!cpu_has_vmx_tpr_shadow()) {
23973 + pax_open_kernel();
23974 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
23975 + pax_close_kernel();
23976 + }
23977
23978 if (enable_ept && !cpu_has_vmx_ept_2m_page())
23979 kvm_disable_largepages();
23980 @@ -2792,10 +2803,12 @@ static __init int hardware_setup(void)
23981 !cpu_has_vmx_virtual_intr_delivery())
23982 enable_apicv_reg_vid = 0;
23983
23984 + pax_open_kernel();
23985 if (enable_apicv_reg_vid)
23986 - kvm_x86_ops->update_cr8_intercept = NULL;
23987 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
23988 else
23989 - kvm_x86_ops->hwapic_irr_update = NULL;
23990 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
23991 + pax_close_kernel();
23992
23993 if (nested)
23994 nested_vmx_setup_ctls_msrs();
23995 @@ -3883,7 +3896,10 @@ static void vmx_set_constant_host_state(void)
23996
23997 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
23998 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
23999 +
24000 +#ifndef CONFIG_PAX_PER_CPU_PGD
24001 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24002 +#endif
24003
24004 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24005 #ifdef CONFIG_X86_64
24006 @@ -3904,7 +3920,7 @@ static void vmx_set_constant_host_state(void)
24007 native_store_idt(&dt);
24008 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24009
24010 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24011 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24012
24013 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
24014 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
24015 @@ -6574,6 +6590,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24016 "jmp 2f \n\t"
24017 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
24018 "2: "
24019 +
24020 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24021 + "ljmp %[cs],$3f\n\t"
24022 + "3: "
24023 +#endif
24024 +
24025 /* Save guest registers, load host registers, keep flags */
24026 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
24027 "pop %0 \n\t"
24028 @@ -6626,6 +6648,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24029 #endif
24030 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
24031 [wordsize]"i"(sizeof(ulong))
24032 +
24033 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24034 + ,[cs]"i"(__KERNEL_CS)
24035 +#endif
24036 +
24037 : "cc", "memory"
24038 #ifdef CONFIG_X86_64
24039 , "rax", "rbx", "rdi", "rsi"
24040 @@ -6639,7 +6666,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24041 if (debugctlmsr)
24042 update_debugctlmsr(debugctlmsr);
24043
24044 -#ifndef CONFIG_X86_64
24045 +#ifdef CONFIG_X86_32
24046 /*
24047 * The sysexit path does not restore ds/es, so we must set them to
24048 * a reasonable value ourselves.
24049 @@ -6648,8 +6675,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24050 * may be executed in interrupt context, which saves and restore segments
24051 * around it, nullifying its effect.
24052 */
24053 - loadsegment(ds, __USER_DS);
24054 - loadsegment(es, __USER_DS);
24055 + loadsegment(ds, __KERNEL_DS);
24056 + loadsegment(es, __KERNEL_DS);
24057 + loadsegment(ss, __KERNEL_DS);
24058 +
24059 +#ifdef CONFIG_PAX_KERNEXEC
24060 + loadsegment(fs, __KERNEL_PERCPU);
24061 +#endif
24062 +
24063 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24064 + __set_fs(current_thread_info()->addr_limit);
24065 +#endif
24066 +
24067 #endif
24068
24069 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24070 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24071 index e172132..c3d3e27 100644
24072 --- a/arch/x86/kvm/x86.c
24073 +++ b/arch/x86/kvm/x86.c
24074 @@ -1686,8 +1686,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24075 {
24076 struct kvm *kvm = vcpu->kvm;
24077 int lm = is_long_mode(vcpu);
24078 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24079 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24080 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24081 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24082 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24083 : kvm->arch.xen_hvm_config.blob_size_32;
24084 u32 page_num = data & ~PAGE_MASK;
24085 @@ -2567,6 +2567,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24086 if (n < msr_list.nmsrs)
24087 goto out;
24088 r = -EFAULT;
24089 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24090 + goto out;
24091 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24092 num_msrs_to_save * sizeof(u32)))
24093 goto out;
24094 @@ -2696,7 +2698,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
24095 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
24096 struct kvm_interrupt *irq)
24097 {
24098 - if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS)
24099 + if (irq->irq >= KVM_NR_INTERRUPTS)
24100 return -EINVAL;
24101 if (irqchip_in_kernel(vcpu->kvm))
24102 return -ENXIO;
24103 @@ -5247,7 +5249,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24104 };
24105 #endif
24106
24107 -int kvm_arch_init(void *opaque)
24108 +int kvm_arch_init(const void *opaque)
24109 {
24110 int r;
24111 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24112 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24113 index 7114c63..a1018fc 100644
24114 --- a/arch/x86/lguest/boot.c
24115 +++ b/arch/x86/lguest/boot.c
24116 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24117 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24118 * Launcher to reboot us.
24119 */
24120 -static void lguest_restart(char *reason)
24121 +static __noreturn void lguest_restart(char *reason)
24122 {
24123 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24124 + BUG();
24125 }
24126
24127 /*G:050
24128 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24129 index 00933d5..3a64af9 100644
24130 --- a/arch/x86/lib/atomic64_386_32.S
24131 +++ b/arch/x86/lib/atomic64_386_32.S
24132 @@ -48,6 +48,10 @@ BEGIN(read)
24133 movl (v), %eax
24134 movl 4(v), %edx
24135 RET_ENDP
24136 +BEGIN(read_unchecked)
24137 + movl (v), %eax
24138 + movl 4(v), %edx
24139 +RET_ENDP
24140 #undef v
24141
24142 #define v %esi
24143 @@ -55,6 +59,10 @@ BEGIN(set)
24144 movl %ebx, (v)
24145 movl %ecx, 4(v)
24146 RET_ENDP
24147 +BEGIN(set_unchecked)
24148 + movl %ebx, (v)
24149 + movl %ecx, 4(v)
24150 +RET_ENDP
24151 #undef v
24152
24153 #define v %esi
24154 @@ -70,6 +78,20 @@ RET_ENDP
24155 BEGIN(add)
24156 addl %eax, (v)
24157 adcl %edx, 4(v)
24158 +
24159 +#ifdef CONFIG_PAX_REFCOUNT
24160 + jno 0f
24161 + subl %eax, (v)
24162 + sbbl %edx, 4(v)
24163 + int $4
24164 +0:
24165 + _ASM_EXTABLE(0b, 0b)
24166 +#endif
24167 +
24168 +RET_ENDP
24169 +BEGIN(add_unchecked)
24170 + addl %eax, (v)
24171 + adcl %edx, 4(v)
24172 RET_ENDP
24173 #undef v
24174
24175 @@ -77,6 +99,24 @@ RET_ENDP
24176 BEGIN(add_return)
24177 addl (v), %eax
24178 adcl 4(v), %edx
24179 +
24180 +#ifdef CONFIG_PAX_REFCOUNT
24181 + into
24182 +1234:
24183 + _ASM_EXTABLE(1234b, 2f)
24184 +#endif
24185 +
24186 + movl %eax, (v)
24187 + movl %edx, 4(v)
24188 +
24189 +#ifdef CONFIG_PAX_REFCOUNT
24190 +2:
24191 +#endif
24192 +
24193 +RET_ENDP
24194 +BEGIN(add_return_unchecked)
24195 + addl (v), %eax
24196 + adcl 4(v), %edx
24197 movl %eax, (v)
24198 movl %edx, 4(v)
24199 RET_ENDP
24200 @@ -86,6 +126,20 @@ RET_ENDP
24201 BEGIN(sub)
24202 subl %eax, (v)
24203 sbbl %edx, 4(v)
24204 +
24205 +#ifdef CONFIG_PAX_REFCOUNT
24206 + jno 0f
24207 + addl %eax, (v)
24208 + adcl %edx, 4(v)
24209 + int $4
24210 +0:
24211 + _ASM_EXTABLE(0b, 0b)
24212 +#endif
24213 +
24214 +RET_ENDP
24215 +BEGIN(sub_unchecked)
24216 + subl %eax, (v)
24217 + sbbl %edx, 4(v)
24218 RET_ENDP
24219 #undef v
24220
24221 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24222 sbbl $0, %edx
24223 addl (v), %eax
24224 adcl 4(v), %edx
24225 +
24226 +#ifdef CONFIG_PAX_REFCOUNT
24227 + into
24228 +1234:
24229 + _ASM_EXTABLE(1234b, 2f)
24230 +#endif
24231 +
24232 + movl %eax, (v)
24233 + movl %edx, 4(v)
24234 +
24235 +#ifdef CONFIG_PAX_REFCOUNT
24236 +2:
24237 +#endif
24238 +
24239 +RET_ENDP
24240 +BEGIN(sub_return_unchecked)
24241 + negl %edx
24242 + negl %eax
24243 + sbbl $0, %edx
24244 + addl (v), %eax
24245 + adcl 4(v), %edx
24246 movl %eax, (v)
24247 movl %edx, 4(v)
24248 RET_ENDP
24249 @@ -105,6 +180,20 @@ RET_ENDP
24250 BEGIN(inc)
24251 addl $1, (v)
24252 adcl $0, 4(v)
24253 +
24254 +#ifdef CONFIG_PAX_REFCOUNT
24255 + jno 0f
24256 + subl $1, (v)
24257 + sbbl $0, 4(v)
24258 + int $4
24259 +0:
24260 + _ASM_EXTABLE(0b, 0b)
24261 +#endif
24262 +
24263 +RET_ENDP
24264 +BEGIN(inc_unchecked)
24265 + addl $1, (v)
24266 + adcl $0, 4(v)
24267 RET_ENDP
24268 #undef v
24269
24270 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24271 movl 4(v), %edx
24272 addl $1, %eax
24273 adcl $0, %edx
24274 +
24275 +#ifdef CONFIG_PAX_REFCOUNT
24276 + into
24277 +1234:
24278 + _ASM_EXTABLE(1234b, 2f)
24279 +#endif
24280 +
24281 + movl %eax, (v)
24282 + movl %edx, 4(v)
24283 +
24284 +#ifdef CONFIG_PAX_REFCOUNT
24285 +2:
24286 +#endif
24287 +
24288 +RET_ENDP
24289 +BEGIN(inc_return_unchecked)
24290 + movl (v), %eax
24291 + movl 4(v), %edx
24292 + addl $1, %eax
24293 + adcl $0, %edx
24294 movl %eax, (v)
24295 movl %edx, 4(v)
24296 RET_ENDP
24297 @@ -123,6 +232,20 @@ RET_ENDP
24298 BEGIN(dec)
24299 subl $1, (v)
24300 sbbl $0, 4(v)
24301 +
24302 +#ifdef CONFIG_PAX_REFCOUNT
24303 + jno 0f
24304 + addl $1, (v)
24305 + adcl $0, 4(v)
24306 + int $4
24307 +0:
24308 + _ASM_EXTABLE(0b, 0b)
24309 +#endif
24310 +
24311 +RET_ENDP
24312 +BEGIN(dec_unchecked)
24313 + subl $1, (v)
24314 + sbbl $0, 4(v)
24315 RET_ENDP
24316 #undef v
24317
24318 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24319 movl 4(v), %edx
24320 subl $1, %eax
24321 sbbl $0, %edx
24322 +
24323 +#ifdef CONFIG_PAX_REFCOUNT
24324 + into
24325 +1234:
24326 + _ASM_EXTABLE(1234b, 2f)
24327 +#endif
24328 +
24329 + movl %eax, (v)
24330 + movl %edx, 4(v)
24331 +
24332 +#ifdef CONFIG_PAX_REFCOUNT
24333 +2:
24334 +#endif
24335 +
24336 +RET_ENDP
24337 +BEGIN(dec_return_unchecked)
24338 + movl (v), %eax
24339 + movl 4(v), %edx
24340 + subl $1, %eax
24341 + sbbl $0, %edx
24342 movl %eax, (v)
24343 movl %edx, 4(v)
24344 RET_ENDP
24345 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24346 adcl %edx, %edi
24347 addl (v), %eax
24348 adcl 4(v), %edx
24349 +
24350 +#ifdef CONFIG_PAX_REFCOUNT
24351 + into
24352 +1234:
24353 + _ASM_EXTABLE(1234b, 2f)
24354 +#endif
24355 +
24356 cmpl %eax, %ecx
24357 je 3f
24358 1:
24359 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24360 1:
24361 addl $1, %eax
24362 adcl $0, %edx
24363 +
24364 +#ifdef CONFIG_PAX_REFCOUNT
24365 + into
24366 +1234:
24367 + _ASM_EXTABLE(1234b, 2f)
24368 +#endif
24369 +
24370 movl %eax, (v)
24371 movl %edx, 4(v)
24372 movl $1, %eax
24373 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24374 movl 4(v), %edx
24375 subl $1, %eax
24376 sbbl $0, %edx
24377 +
24378 +#ifdef CONFIG_PAX_REFCOUNT
24379 + into
24380 +1234:
24381 + _ASM_EXTABLE(1234b, 1f)
24382 +#endif
24383 +
24384 js 1f
24385 movl %eax, (v)
24386 movl %edx, 4(v)
24387 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24388 index f5cc9eb..51fa319 100644
24389 --- a/arch/x86/lib/atomic64_cx8_32.S
24390 +++ b/arch/x86/lib/atomic64_cx8_32.S
24391 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24392 CFI_STARTPROC
24393
24394 read64 %ecx
24395 + pax_force_retaddr
24396 ret
24397 CFI_ENDPROC
24398 ENDPROC(atomic64_read_cx8)
24399
24400 +ENTRY(atomic64_read_unchecked_cx8)
24401 + CFI_STARTPROC
24402 +
24403 + read64 %ecx
24404 + pax_force_retaddr
24405 + ret
24406 + CFI_ENDPROC
24407 +ENDPROC(atomic64_read_unchecked_cx8)
24408 +
24409 ENTRY(atomic64_set_cx8)
24410 CFI_STARTPROC
24411
24412 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24413 cmpxchg8b (%esi)
24414 jne 1b
24415
24416 + pax_force_retaddr
24417 ret
24418 CFI_ENDPROC
24419 ENDPROC(atomic64_set_cx8)
24420
24421 +ENTRY(atomic64_set_unchecked_cx8)
24422 + CFI_STARTPROC
24423 +
24424 +1:
24425 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24426 + * are atomic on 586 and newer */
24427 + cmpxchg8b (%esi)
24428 + jne 1b
24429 +
24430 + pax_force_retaddr
24431 + ret
24432 + CFI_ENDPROC
24433 +ENDPROC(atomic64_set_unchecked_cx8)
24434 +
24435 ENTRY(atomic64_xchg_cx8)
24436 CFI_STARTPROC
24437
24438 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24439 cmpxchg8b (%esi)
24440 jne 1b
24441
24442 + pax_force_retaddr
24443 ret
24444 CFI_ENDPROC
24445 ENDPROC(atomic64_xchg_cx8)
24446
24447 -.macro addsub_return func ins insc
24448 -ENTRY(atomic64_\func\()_return_cx8)
24449 +.macro addsub_return func ins insc unchecked=""
24450 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24451 CFI_STARTPROC
24452 SAVE ebp
24453 SAVE ebx
24454 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24455 movl %edx, %ecx
24456 \ins\()l %esi, %ebx
24457 \insc\()l %edi, %ecx
24458 +
24459 +.ifb \unchecked
24460 +#ifdef CONFIG_PAX_REFCOUNT
24461 + into
24462 +2:
24463 + _ASM_EXTABLE(2b, 3f)
24464 +#endif
24465 +.endif
24466 +
24467 LOCK_PREFIX
24468 cmpxchg8b (%ebp)
24469 jne 1b
24470 -
24471 -10:
24472 movl %ebx, %eax
24473 movl %ecx, %edx
24474 +
24475 +.ifb \unchecked
24476 +#ifdef CONFIG_PAX_REFCOUNT
24477 +3:
24478 +#endif
24479 +.endif
24480 +
24481 RESTORE edi
24482 RESTORE esi
24483 RESTORE ebx
24484 RESTORE ebp
24485 + pax_force_retaddr
24486 ret
24487 CFI_ENDPROC
24488 -ENDPROC(atomic64_\func\()_return_cx8)
24489 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24490 .endm
24491
24492 addsub_return add add adc
24493 addsub_return sub sub sbb
24494 +addsub_return add add adc _unchecked
24495 +addsub_return sub sub sbb _unchecked
24496
24497 -.macro incdec_return func ins insc
24498 -ENTRY(atomic64_\func\()_return_cx8)
24499 +.macro incdec_return func ins insc unchecked=""
24500 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24501 CFI_STARTPROC
24502 SAVE ebx
24503
24504 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24505 movl %edx, %ecx
24506 \ins\()l $1, %ebx
24507 \insc\()l $0, %ecx
24508 +
24509 +.ifb \unchecked
24510 +#ifdef CONFIG_PAX_REFCOUNT
24511 + into
24512 +2:
24513 + _ASM_EXTABLE(2b, 3f)
24514 +#endif
24515 +.endif
24516 +
24517 LOCK_PREFIX
24518 cmpxchg8b (%esi)
24519 jne 1b
24520
24521 -10:
24522 movl %ebx, %eax
24523 movl %ecx, %edx
24524 +
24525 +.ifb \unchecked
24526 +#ifdef CONFIG_PAX_REFCOUNT
24527 +3:
24528 +#endif
24529 +.endif
24530 +
24531 RESTORE ebx
24532 + pax_force_retaddr
24533 ret
24534 CFI_ENDPROC
24535 -ENDPROC(atomic64_\func\()_return_cx8)
24536 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24537 .endm
24538
24539 incdec_return inc add adc
24540 incdec_return dec sub sbb
24541 +incdec_return inc add adc _unchecked
24542 +incdec_return dec sub sbb _unchecked
24543
24544 ENTRY(atomic64_dec_if_positive_cx8)
24545 CFI_STARTPROC
24546 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
24547 movl %edx, %ecx
24548 subl $1, %ebx
24549 sbb $0, %ecx
24550 +
24551 +#ifdef CONFIG_PAX_REFCOUNT
24552 + into
24553 +1234:
24554 + _ASM_EXTABLE(1234b, 2f)
24555 +#endif
24556 +
24557 js 2f
24558 LOCK_PREFIX
24559 cmpxchg8b (%esi)
24560 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
24561 movl %ebx, %eax
24562 movl %ecx, %edx
24563 RESTORE ebx
24564 + pax_force_retaddr
24565 ret
24566 CFI_ENDPROC
24567 ENDPROC(atomic64_dec_if_positive_cx8)
24568 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
24569 movl %edx, %ecx
24570 addl %ebp, %ebx
24571 adcl %edi, %ecx
24572 +
24573 +#ifdef CONFIG_PAX_REFCOUNT
24574 + into
24575 +1234:
24576 + _ASM_EXTABLE(1234b, 3f)
24577 +#endif
24578 +
24579 LOCK_PREFIX
24580 cmpxchg8b (%esi)
24581 jne 1b
24582 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
24583 CFI_ADJUST_CFA_OFFSET -8
24584 RESTORE ebx
24585 RESTORE ebp
24586 + pax_force_retaddr
24587 ret
24588 4:
24589 cmpl %edx, 4(%esp)
24590 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
24591 xorl %ecx, %ecx
24592 addl $1, %ebx
24593 adcl %edx, %ecx
24594 +
24595 +#ifdef CONFIG_PAX_REFCOUNT
24596 + into
24597 +1234:
24598 + _ASM_EXTABLE(1234b, 3f)
24599 +#endif
24600 +
24601 LOCK_PREFIX
24602 cmpxchg8b (%esi)
24603 jne 1b
24604 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
24605 movl $1, %eax
24606 3:
24607 RESTORE ebx
24608 + pax_force_retaddr
24609 ret
24610 CFI_ENDPROC
24611 ENDPROC(atomic64_inc_not_zero_cx8)
24612 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
24613 index 2af5df3..62b1a5a 100644
24614 --- a/arch/x86/lib/checksum_32.S
24615 +++ b/arch/x86/lib/checksum_32.S
24616 @@ -29,7 +29,8 @@
24617 #include <asm/dwarf2.h>
24618 #include <asm/errno.h>
24619 #include <asm/asm.h>
24620 -
24621 +#include <asm/segment.h>
24622 +
24623 /*
24624 * computes a partial checksum, e.g. for TCP/UDP fragments
24625 */
24626 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
24627
24628 #define ARGBASE 16
24629 #define FP 12
24630 -
24631 -ENTRY(csum_partial_copy_generic)
24632 +
24633 +ENTRY(csum_partial_copy_generic_to_user)
24634 CFI_STARTPROC
24635 +
24636 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24637 + pushl_cfi %gs
24638 + popl_cfi %es
24639 + jmp csum_partial_copy_generic
24640 +#endif
24641 +
24642 +ENTRY(csum_partial_copy_generic_from_user)
24643 +
24644 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24645 + pushl_cfi %gs
24646 + popl_cfi %ds
24647 +#endif
24648 +
24649 +ENTRY(csum_partial_copy_generic)
24650 subl $4,%esp
24651 CFI_ADJUST_CFA_OFFSET 4
24652 pushl_cfi %edi
24653 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
24654 jmp 4f
24655 SRC(1: movw (%esi), %bx )
24656 addl $2, %esi
24657 -DST( movw %bx, (%edi) )
24658 +DST( movw %bx, %es:(%edi) )
24659 addl $2, %edi
24660 addw %bx, %ax
24661 adcl $0, %eax
24662 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
24663 SRC(1: movl (%esi), %ebx )
24664 SRC( movl 4(%esi), %edx )
24665 adcl %ebx, %eax
24666 -DST( movl %ebx, (%edi) )
24667 +DST( movl %ebx, %es:(%edi) )
24668 adcl %edx, %eax
24669 -DST( movl %edx, 4(%edi) )
24670 +DST( movl %edx, %es:4(%edi) )
24671
24672 SRC( movl 8(%esi), %ebx )
24673 SRC( movl 12(%esi), %edx )
24674 adcl %ebx, %eax
24675 -DST( movl %ebx, 8(%edi) )
24676 +DST( movl %ebx, %es:8(%edi) )
24677 adcl %edx, %eax
24678 -DST( movl %edx, 12(%edi) )
24679 +DST( movl %edx, %es:12(%edi) )
24680
24681 SRC( movl 16(%esi), %ebx )
24682 SRC( movl 20(%esi), %edx )
24683 adcl %ebx, %eax
24684 -DST( movl %ebx, 16(%edi) )
24685 +DST( movl %ebx, %es:16(%edi) )
24686 adcl %edx, %eax
24687 -DST( movl %edx, 20(%edi) )
24688 +DST( movl %edx, %es:20(%edi) )
24689
24690 SRC( movl 24(%esi), %ebx )
24691 SRC( movl 28(%esi), %edx )
24692 adcl %ebx, %eax
24693 -DST( movl %ebx, 24(%edi) )
24694 +DST( movl %ebx, %es:24(%edi) )
24695 adcl %edx, %eax
24696 -DST( movl %edx, 28(%edi) )
24697 +DST( movl %edx, %es:28(%edi) )
24698
24699 lea 32(%esi), %esi
24700 lea 32(%edi), %edi
24701 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
24702 shrl $2, %edx # This clears CF
24703 SRC(3: movl (%esi), %ebx )
24704 adcl %ebx, %eax
24705 -DST( movl %ebx, (%edi) )
24706 +DST( movl %ebx, %es:(%edi) )
24707 lea 4(%esi), %esi
24708 lea 4(%edi), %edi
24709 dec %edx
24710 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
24711 jb 5f
24712 SRC( movw (%esi), %cx )
24713 leal 2(%esi), %esi
24714 -DST( movw %cx, (%edi) )
24715 +DST( movw %cx, %es:(%edi) )
24716 leal 2(%edi), %edi
24717 je 6f
24718 shll $16,%ecx
24719 SRC(5: movb (%esi), %cl )
24720 -DST( movb %cl, (%edi) )
24721 +DST( movb %cl, %es:(%edi) )
24722 6: addl %ecx, %eax
24723 adcl $0, %eax
24724 7:
24725 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
24726
24727 6001:
24728 movl ARGBASE+20(%esp), %ebx # src_err_ptr
24729 - movl $-EFAULT, (%ebx)
24730 + movl $-EFAULT, %ss:(%ebx)
24731
24732 # zero the complete destination - computing the rest
24733 # is too much work
24734 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
24735
24736 6002:
24737 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24738 - movl $-EFAULT,(%ebx)
24739 + movl $-EFAULT,%ss:(%ebx)
24740 jmp 5000b
24741
24742 .previous
24743
24744 + pushl_cfi %ss
24745 + popl_cfi %ds
24746 + pushl_cfi %ss
24747 + popl_cfi %es
24748 popl_cfi %ebx
24749 CFI_RESTORE ebx
24750 popl_cfi %esi
24751 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
24752 popl_cfi %ecx # equivalent to addl $4,%esp
24753 ret
24754 CFI_ENDPROC
24755 -ENDPROC(csum_partial_copy_generic)
24756 +ENDPROC(csum_partial_copy_generic_to_user)
24757
24758 #else
24759
24760 /* Version for PentiumII/PPro */
24761
24762 #define ROUND1(x) \
24763 + nop; nop; nop; \
24764 SRC(movl x(%esi), %ebx ) ; \
24765 addl %ebx, %eax ; \
24766 - DST(movl %ebx, x(%edi) ) ;
24767 + DST(movl %ebx, %es:x(%edi)) ;
24768
24769 #define ROUND(x) \
24770 + nop; nop; nop; \
24771 SRC(movl x(%esi), %ebx ) ; \
24772 adcl %ebx, %eax ; \
24773 - DST(movl %ebx, x(%edi) ) ;
24774 + DST(movl %ebx, %es:x(%edi)) ;
24775
24776 #define ARGBASE 12
24777 -
24778 -ENTRY(csum_partial_copy_generic)
24779 +
24780 +ENTRY(csum_partial_copy_generic_to_user)
24781 CFI_STARTPROC
24782 +
24783 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24784 + pushl_cfi %gs
24785 + popl_cfi %es
24786 + jmp csum_partial_copy_generic
24787 +#endif
24788 +
24789 +ENTRY(csum_partial_copy_generic_from_user)
24790 +
24791 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24792 + pushl_cfi %gs
24793 + popl_cfi %ds
24794 +#endif
24795 +
24796 +ENTRY(csum_partial_copy_generic)
24797 pushl_cfi %ebx
24798 CFI_REL_OFFSET ebx, 0
24799 pushl_cfi %edi
24800 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
24801 subl %ebx, %edi
24802 lea -1(%esi),%edx
24803 andl $-32,%edx
24804 - lea 3f(%ebx,%ebx), %ebx
24805 + lea 3f(%ebx,%ebx,2), %ebx
24806 testl %esi, %esi
24807 jmp *%ebx
24808 1: addl $64,%esi
24809 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
24810 jb 5f
24811 SRC( movw (%esi), %dx )
24812 leal 2(%esi), %esi
24813 -DST( movw %dx, (%edi) )
24814 +DST( movw %dx, %es:(%edi) )
24815 leal 2(%edi), %edi
24816 je 6f
24817 shll $16,%edx
24818 5:
24819 SRC( movb (%esi), %dl )
24820 -DST( movb %dl, (%edi) )
24821 +DST( movb %dl, %es:(%edi) )
24822 6: addl %edx, %eax
24823 adcl $0, %eax
24824 7:
24825 .section .fixup, "ax"
24826 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
24827 - movl $-EFAULT, (%ebx)
24828 + movl $-EFAULT, %ss:(%ebx)
24829 # zero the complete destination (computing the rest is too much work)
24830 movl ARGBASE+8(%esp),%edi # dst
24831 movl ARGBASE+12(%esp),%ecx # len
24832 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
24833 rep; stosb
24834 jmp 7b
24835 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24836 - movl $-EFAULT, (%ebx)
24837 + movl $-EFAULT, %ss:(%ebx)
24838 jmp 7b
24839 .previous
24840
24841 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24842 + pushl_cfi %ss
24843 + popl_cfi %ds
24844 + pushl_cfi %ss
24845 + popl_cfi %es
24846 +#endif
24847 +
24848 popl_cfi %esi
24849 CFI_RESTORE esi
24850 popl_cfi %edi
24851 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
24852 CFI_RESTORE ebx
24853 ret
24854 CFI_ENDPROC
24855 -ENDPROC(csum_partial_copy_generic)
24856 +ENDPROC(csum_partial_copy_generic_to_user)
24857
24858 #undef ROUND
24859 #undef ROUND1
24860 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
24861 index f2145cf..cea889d 100644
24862 --- a/arch/x86/lib/clear_page_64.S
24863 +++ b/arch/x86/lib/clear_page_64.S
24864 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
24865 movl $4096/8,%ecx
24866 xorl %eax,%eax
24867 rep stosq
24868 + pax_force_retaddr
24869 ret
24870 CFI_ENDPROC
24871 ENDPROC(clear_page_c)
24872 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
24873 movl $4096,%ecx
24874 xorl %eax,%eax
24875 rep stosb
24876 + pax_force_retaddr
24877 ret
24878 CFI_ENDPROC
24879 ENDPROC(clear_page_c_e)
24880 @@ -43,6 +45,7 @@ ENTRY(clear_page)
24881 leaq 64(%rdi),%rdi
24882 jnz .Lloop
24883 nop
24884 + pax_force_retaddr
24885 ret
24886 CFI_ENDPROC
24887 .Lclear_page_end:
24888 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
24889
24890 #include <asm/cpufeature.h>
24891
24892 - .section .altinstr_replacement,"ax"
24893 + .section .altinstr_replacement,"a"
24894 1: .byte 0xeb /* jmp <disp8> */
24895 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
24896 2: .byte 0xeb /* jmp <disp8> */
24897 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
24898 index 1e572c5..2a162cd 100644
24899 --- a/arch/x86/lib/cmpxchg16b_emu.S
24900 +++ b/arch/x86/lib/cmpxchg16b_emu.S
24901 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
24902
24903 popf
24904 mov $1, %al
24905 + pax_force_retaddr
24906 ret
24907
24908 not_same:
24909 popf
24910 xor %al,%al
24911 + pax_force_retaddr
24912 ret
24913
24914 CFI_ENDPROC
24915 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
24916 index 176cca6..1166c50 100644
24917 --- a/arch/x86/lib/copy_page_64.S
24918 +++ b/arch/x86/lib/copy_page_64.S
24919 @@ -9,6 +9,7 @@ copy_page_rep:
24920 CFI_STARTPROC
24921 movl $4096/8, %ecx
24922 rep movsq
24923 + pax_force_retaddr
24924 ret
24925 CFI_ENDPROC
24926 ENDPROC(copy_page_rep)
24927 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
24928
24929 ENTRY(copy_page)
24930 CFI_STARTPROC
24931 - subq $2*8, %rsp
24932 - CFI_ADJUST_CFA_OFFSET 2*8
24933 + subq $3*8, %rsp
24934 + CFI_ADJUST_CFA_OFFSET 3*8
24935 movq %rbx, (%rsp)
24936 CFI_REL_OFFSET rbx, 0
24937 movq %r12, 1*8(%rsp)
24938 CFI_REL_OFFSET r12, 1*8
24939 + movq %r13, 2*8(%rsp)
24940 + CFI_REL_OFFSET r13, 2*8
24941
24942 movl $(4096/64)-5, %ecx
24943 .p2align 4
24944 @@ -36,7 +39,7 @@ ENTRY(copy_page)
24945 movq 0x8*2(%rsi), %rdx
24946 movq 0x8*3(%rsi), %r8
24947 movq 0x8*4(%rsi), %r9
24948 - movq 0x8*5(%rsi), %r10
24949 + movq 0x8*5(%rsi), %r13
24950 movq 0x8*6(%rsi), %r11
24951 movq 0x8*7(%rsi), %r12
24952
24953 @@ -47,7 +50,7 @@ ENTRY(copy_page)
24954 movq %rdx, 0x8*2(%rdi)
24955 movq %r8, 0x8*3(%rdi)
24956 movq %r9, 0x8*4(%rdi)
24957 - movq %r10, 0x8*5(%rdi)
24958 + movq %r13, 0x8*5(%rdi)
24959 movq %r11, 0x8*6(%rdi)
24960 movq %r12, 0x8*7(%rdi)
24961
24962 @@ -66,7 +69,7 @@ ENTRY(copy_page)
24963 movq 0x8*2(%rsi), %rdx
24964 movq 0x8*3(%rsi), %r8
24965 movq 0x8*4(%rsi), %r9
24966 - movq 0x8*5(%rsi), %r10
24967 + movq 0x8*5(%rsi), %r13
24968 movq 0x8*6(%rsi), %r11
24969 movq 0x8*7(%rsi), %r12
24970
24971 @@ -75,7 +78,7 @@ ENTRY(copy_page)
24972 movq %rdx, 0x8*2(%rdi)
24973 movq %r8, 0x8*3(%rdi)
24974 movq %r9, 0x8*4(%rdi)
24975 - movq %r10, 0x8*5(%rdi)
24976 + movq %r13, 0x8*5(%rdi)
24977 movq %r11, 0x8*6(%rdi)
24978 movq %r12, 0x8*7(%rdi)
24979
24980 @@ -87,8 +90,11 @@ ENTRY(copy_page)
24981 CFI_RESTORE rbx
24982 movq 1*8(%rsp), %r12
24983 CFI_RESTORE r12
24984 - addq $2*8, %rsp
24985 - CFI_ADJUST_CFA_OFFSET -2*8
24986 + movq 2*8(%rsp), %r13
24987 + CFI_RESTORE r13
24988 + addq $3*8, %rsp
24989 + CFI_ADJUST_CFA_OFFSET -3*8
24990 + pax_force_retaddr
24991 ret
24992 .Lcopy_page_end:
24993 CFI_ENDPROC
24994 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
24995
24996 #include <asm/cpufeature.h>
24997
24998 - .section .altinstr_replacement,"ax"
24999 + .section .altinstr_replacement,"a"
25000 1: .byte 0xeb /* jmp <disp8> */
25001 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25002 2:
25003 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25004 index a30ca15..d25fab6 100644
25005 --- a/arch/x86/lib/copy_user_64.S
25006 +++ b/arch/x86/lib/copy_user_64.S
25007 @@ -18,6 +18,7 @@
25008 #include <asm/alternative-asm.h>
25009 #include <asm/asm.h>
25010 #include <asm/smap.h>
25011 +#include <asm/pgtable.h>
25012
25013 /*
25014 * By placing feature2 after feature1 in altinstructions section, we logically
25015 @@ -31,7 +32,7 @@
25016 .byte 0xe9 /* 32bit jump */
25017 .long \orig-1f /* by default jump to orig */
25018 1:
25019 - .section .altinstr_replacement,"ax"
25020 + .section .altinstr_replacement,"a"
25021 2: .byte 0xe9 /* near jump with 32bit immediate */
25022 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25023 3: .byte 0xe9 /* near jump with 32bit immediate */
25024 @@ -70,47 +71,20 @@
25025 #endif
25026 .endm
25027
25028 -/* Standard copy_to_user with segment limit checking */
25029 -ENTRY(_copy_to_user)
25030 - CFI_STARTPROC
25031 - GET_THREAD_INFO(%rax)
25032 - movq %rdi,%rcx
25033 - addq %rdx,%rcx
25034 - jc bad_to_user
25035 - cmpq TI_addr_limit(%rax),%rcx
25036 - ja bad_to_user
25037 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25038 - copy_user_generic_unrolled,copy_user_generic_string, \
25039 - copy_user_enhanced_fast_string
25040 - CFI_ENDPROC
25041 -ENDPROC(_copy_to_user)
25042 -
25043 -/* Standard copy_from_user with segment limit checking */
25044 -ENTRY(_copy_from_user)
25045 - CFI_STARTPROC
25046 - GET_THREAD_INFO(%rax)
25047 - movq %rsi,%rcx
25048 - addq %rdx,%rcx
25049 - jc bad_from_user
25050 - cmpq TI_addr_limit(%rax),%rcx
25051 - ja bad_from_user
25052 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25053 - copy_user_generic_unrolled,copy_user_generic_string, \
25054 - copy_user_enhanced_fast_string
25055 - CFI_ENDPROC
25056 -ENDPROC(_copy_from_user)
25057 -
25058 .section .fixup,"ax"
25059 /* must zero dest */
25060 ENTRY(bad_from_user)
25061 bad_from_user:
25062 CFI_STARTPROC
25063 + testl %edx,%edx
25064 + js bad_to_user
25065 movl %edx,%ecx
25066 xorl %eax,%eax
25067 rep
25068 stosb
25069 bad_to_user:
25070 movl %edx,%eax
25071 + pax_force_retaddr
25072 ret
25073 CFI_ENDPROC
25074 ENDPROC(bad_from_user)
25075 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25076 jz 17f
25077 1: movq (%rsi),%r8
25078 2: movq 1*8(%rsi),%r9
25079 -3: movq 2*8(%rsi),%r10
25080 +3: movq 2*8(%rsi),%rax
25081 4: movq 3*8(%rsi),%r11
25082 5: movq %r8,(%rdi)
25083 6: movq %r9,1*8(%rdi)
25084 -7: movq %r10,2*8(%rdi)
25085 +7: movq %rax,2*8(%rdi)
25086 8: movq %r11,3*8(%rdi)
25087 9: movq 4*8(%rsi),%r8
25088 10: movq 5*8(%rsi),%r9
25089 -11: movq 6*8(%rsi),%r10
25090 +11: movq 6*8(%rsi),%rax
25091 12: movq 7*8(%rsi),%r11
25092 13: movq %r8,4*8(%rdi)
25093 14: movq %r9,5*8(%rdi)
25094 -15: movq %r10,6*8(%rdi)
25095 +15: movq %rax,6*8(%rdi)
25096 16: movq %r11,7*8(%rdi)
25097 leaq 64(%rsi),%rsi
25098 leaq 64(%rdi),%rdi
25099 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25100 jnz 21b
25101 23: xor %eax,%eax
25102 ASM_CLAC
25103 + pax_force_retaddr
25104 ret
25105
25106 .section .fixup,"ax"
25107 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25108 movsb
25109 4: xorl %eax,%eax
25110 ASM_CLAC
25111 + pax_force_retaddr
25112 ret
25113
25114 .section .fixup,"ax"
25115 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25116 movsb
25117 2: xorl %eax,%eax
25118 ASM_CLAC
25119 + pax_force_retaddr
25120 ret
25121
25122 .section .fixup,"ax"
25123 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25124 index 6a4f43c..f08b4a2 100644
25125 --- a/arch/x86/lib/copy_user_nocache_64.S
25126 +++ b/arch/x86/lib/copy_user_nocache_64.S
25127 @@ -8,6 +8,7 @@
25128
25129 #include <linux/linkage.h>
25130 #include <asm/dwarf2.h>
25131 +#include <asm/alternative-asm.h>
25132
25133 #define FIX_ALIGNMENT 1
25134
25135 @@ -16,6 +17,7 @@
25136 #include <asm/thread_info.h>
25137 #include <asm/asm.h>
25138 #include <asm/smap.h>
25139 +#include <asm/pgtable.h>
25140
25141 .macro ALIGN_DESTINATION
25142 #ifdef FIX_ALIGNMENT
25143 @@ -49,6 +51,15 @@
25144 */
25145 ENTRY(__copy_user_nocache)
25146 CFI_STARTPROC
25147 +
25148 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25149 + mov pax_user_shadow_base,%rcx
25150 + cmp %rcx,%rsi
25151 + jae 1f
25152 + add %rcx,%rsi
25153 +1:
25154 +#endif
25155 +
25156 ASM_STAC
25157 cmpl $8,%edx
25158 jb 20f /* less then 8 bytes, go to byte copy loop */
25159 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25160 jz 17f
25161 1: movq (%rsi),%r8
25162 2: movq 1*8(%rsi),%r9
25163 -3: movq 2*8(%rsi),%r10
25164 +3: movq 2*8(%rsi),%rax
25165 4: movq 3*8(%rsi),%r11
25166 5: movnti %r8,(%rdi)
25167 6: movnti %r9,1*8(%rdi)
25168 -7: movnti %r10,2*8(%rdi)
25169 +7: movnti %rax,2*8(%rdi)
25170 8: movnti %r11,3*8(%rdi)
25171 9: movq 4*8(%rsi),%r8
25172 10: movq 5*8(%rsi),%r9
25173 -11: movq 6*8(%rsi),%r10
25174 +11: movq 6*8(%rsi),%rax
25175 12: movq 7*8(%rsi),%r11
25176 13: movnti %r8,4*8(%rdi)
25177 14: movnti %r9,5*8(%rdi)
25178 -15: movnti %r10,6*8(%rdi)
25179 +15: movnti %rax,6*8(%rdi)
25180 16: movnti %r11,7*8(%rdi)
25181 leaq 64(%rsi),%rsi
25182 leaq 64(%rdi),%rdi
25183 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25184 23: xorl %eax,%eax
25185 ASM_CLAC
25186 sfence
25187 + pax_force_retaddr
25188 ret
25189
25190 .section .fixup,"ax"
25191 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25192 index 2419d5f..953ee51 100644
25193 --- a/arch/x86/lib/csum-copy_64.S
25194 +++ b/arch/x86/lib/csum-copy_64.S
25195 @@ -9,6 +9,7 @@
25196 #include <asm/dwarf2.h>
25197 #include <asm/errno.h>
25198 #include <asm/asm.h>
25199 +#include <asm/alternative-asm.h>
25200
25201 /*
25202 * Checksum copy with exception handling.
25203 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25204 CFI_RESTORE rbp
25205 addq $7*8, %rsp
25206 CFI_ADJUST_CFA_OFFSET -7*8
25207 + pax_force_retaddr 0, 1
25208 ret
25209 CFI_RESTORE_STATE
25210
25211 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25212 index 25b7ae8..169fafc 100644
25213 --- a/arch/x86/lib/csum-wrappers_64.c
25214 +++ b/arch/x86/lib/csum-wrappers_64.c
25215 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25216 len -= 2;
25217 }
25218 }
25219 - isum = csum_partial_copy_generic((__force const void *)src,
25220 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25221 dst, len, isum, errp, NULL);
25222 if (unlikely(*errp))
25223 goto out_err;
25224 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25225 }
25226
25227 *errp = 0;
25228 - return csum_partial_copy_generic(src, (void __force *)dst,
25229 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25230 len, isum, NULL, errp);
25231 }
25232 EXPORT_SYMBOL(csum_partial_copy_to_user);
25233 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25234 index a451235..79fb5cf 100644
25235 --- a/arch/x86/lib/getuser.S
25236 +++ b/arch/x86/lib/getuser.S
25237 @@ -33,17 +33,40 @@
25238 #include <asm/thread_info.h>
25239 #include <asm/asm.h>
25240 #include <asm/smap.h>
25241 +#include <asm/segment.h>
25242 +#include <asm/pgtable.h>
25243 +#include <asm/alternative-asm.h>
25244 +
25245 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25246 +#define __copyuser_seg gs;
25247 +#else
25248 +#define __copyuser_seg
25249 +#endif
25250
25251 .text
25252 ENTRY(__get_user_1)
25253 CFI_STARTPROC
25254 +
25255 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25256 GET_THREAD_INFO(%_ASM_DX)
25257 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25258 jae bad_get_user
25259 ASM_STAC
25260 -1: movzbl (%_ASM_AX),%edx
25261 +
25262 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25263 + mov pax_user_shadow_base,%_ASM_DX
25264 + cmp %_ASM_DX,%_ASM_AX
25265 + jae 1234f
25266 + add %_ASM_DX,%_ASM_AX
25267 +1234:
25268 +#endif
25269 +
25270 +#endif
25271 +
25272 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
25273 xor %eax,%eax
25274 ASM_CLAC
25275 + pax_force_retaddr
25276 ret
25277 CFI_ENDPROC
25278 ENDPROC(__get_user_1)
25279 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
25280 ENTRY(__get_user_2)
25281 CFI_STARTPROC
25282 add $1,%_ASM_AX
25283 +
25284 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25285 jc bad_get_user
25286 GET_THREAD_INFO(%_ASM_DX)
25287 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25288 jae bad_get_user
25289 ASM_STAC
25290 -2: movzwl -1(%_ASM_AX),%edx
25291 +
25292 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25293 + mov pax_user_shadow_base,%_ASM_DX
25294 + cmp %_ASM_DX,%_ASM_AX
25295 + jae 1234f
25296 + add %_ASM_DX,%_ASM_AX
25297 +1234:
25298 +#endif
25299 +
25300 +#endif
25301 +
25302 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25303 xor %eax,%eax
25304 ASM_CLAC
25305 + pax_force_retaddr
25306 ret
25307 CFI_ENDPROC
25308 ENDPROC(__get_user_2)
25309 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
25310 ENTRY(__get_user_4)
25311 CFI_STARTPROC
25312 add $3,%_ASM_AX
25313 +
25314 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25315 jc bad_get_user
25316 GET_THREAD_INFO(%_ASM_DX)
25317 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25318 jae bad_get_user
25319 ASM_STAC
25320 -3: movl -3(%_ASM_AX),%edx
25321 +
25322 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25323 + mov pax_user_shadow_base,%_ASM_DX
25324 + cmp %_ASM_DX,%_ASM_AX
25325 + jae 1234f
25326 + add %_ASM_DX,%_ASM_AX
25327 +1234:
25328 +#endif
25329 +
25330 +#endif
25331 +
25332 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
25333 xor %eax,%eax
25334 ASM_CLAC
25335 + pax_force_retaddr
25336 ret
25337 CFI_ENDPROC
25338 ENDPROC(__get_user_4)
25339 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
25340 GET_THREAD_INFO(%_ASM_DX)
25341 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25342 jae bad_get_user
25343 +
25344 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25345 + mov pax_user_shadow_base,%_ASM_DX
25346 + cmp %_ASM_DX,%_ASM_AX
25347 + jae 1234f
25348 + add %_ASM_DX,%_ASM_AX
25349 +1234:
25350 +#endif
25351 +
25352 ASM_STAC
25353 4: movq -7(%_ASM_AX),%rdx
25354 xor %eax,%eax
25355 ASM_CLAC
25356 + pax_force_retaddr
25357 ret
25358 #else
25359 add $7,%_ASM_AX
25360 @@ -102,6 +163,7 @@ ENTRY(__get_user_8)
25361 5: movl -3(%_ASM_AX),%ecx
25362 xor %eax,%eax
25363 ASM_CLAC
25364 + pax_force_retaddr
25365 ret
25366 #endif
25367 CFI_ENDPROC
25368 @@ -113,6 +175,7 @@ bad_get_user:
25369 xor %edx,%edx
25370 mov $(-EFAULT),%_ASM_AX
25371 ASM_CLAC
25372 + pax_force_retaddr
25373 ret
25374 CFI_ENDPROC
25375 END(bad_get_user)
25376 @@ -124,6 +187,7 @@ bad_get_user_8:
25377 xor %ecx,%ecx
25378 mov $(-EFAULT),%_ASM_AX
25379 ASM_CLAC
25380 + pax_force_retaddr
25381 ret
25382 CFI_ENDPROC
25383 END(bad_get_user_8)
25384 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25385 index 54fcffe..7be149e 100644
25386 --- a/arch/x86/lib/insn.c
25387 +++ b/arch/x86/lib/insn.c
25388 @@ -20,8 +20,10 @@
25389
25390 #ifdef __KERNEL__
25391 #include <linux/string.h>
25392 +#include <asm/pgtable_types.h>
25393 #else
25394 #include <string.h>
25395 +#define ktla_ktva(addr) addr
25396 #endif
25397 #include <asm/inat.h>
25398 #include <asm/insn.h>
25399 @@ -53,8 +55,8 @@
25400 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25401 {
25402 memset(insn, 0, sizeof(*insn));
25403 - insn->kaddr = kaddr;
25404 - insn->next_byte = kaddr;
25405 + insn->kaddr = ktla_ktva(kaddr);
25406 + insn->next_byte = ktla_ktva(kaddr);
25407 insn->x86_64 = x86_64 ? 1 : 0;
25408 insn->opnd_bytes = 4;
25409 if (x86_64)
25410 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25411 index 05a95e7..326f2fa 100644
25412 --- a/arch/x86/lib/iomap_copy_64.S
25413 +++ b/arch/x86/lib/iomap_copy_64.S
25414 @@ -17,6 +17,7 @@
25415
25416 #include <linux/linkage.h>
25417 #include <asm/dwarf2.h>
25418 +#include <asm/alternative-asm.h>
25419
25420 /*
25421 * override generic version in lib/iomap_copy.c
25422 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25423 CFI_STARTPROC
25424 movl %edx,%ecx
25425 rep movsd
25426 + pax_force_retaddr
25427 ret
25428 CFI_ENDPROC
25429 ENDPROC(__iowrite32_copy)
25430 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25431 index 1c273be..da9cc0e 100644
25432 --- a/arch/x86/lib/memcpy_64.S
25433 +++ b/arch/x86/lib/memcpy_64.S
25434 @@ -33,6 +33,7 @@
25435 rep movsq
25436 movl %edx, %ecx
25437 rep movsb
25438 + pax_force_retaddr
25439 ret
25440 .Lmemcpy_e:
25441 .previous
25442 @@ -49,6 +50,7 @@
25443 movq %rdi, %rax
25444 movq %rdx, %rcx
25445 rep movsb
25446 + pax_force_retaddr
25447 ret
25448 .Lmemcpy_e_e:
25449 .previous
25450 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25451 */
25452 movq 0*8(%rsi), %r8
25453 movq 1*8(%rsi), %r9
25454 - movq 2*8(%rsi), %r10
25455 + movq 2*8(%rsi), %rcx
25456 movq 3*8(%rsi), %r11
25457 leaq 4*8(%rsi), %rsi
25458
25459 movq %r8, 0*8(%rdi)
25460 movq %r9, 1*8(%rdi)
25461 - movq %r10, 2*8(%rdi)
25462 + movq %rcx, 2*8(%rdi)
25463 movq %r11, 3*8(%rdi)
25464 leaq 4*8(%rdi), %rdi
25465 jae .Lcopy_forward_loop
25466 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25467 subq $0x20, %rdx
25468 movq -1*8(%rsi), %r8
25469 movq -2*8(%rsi), %r9
25470 - movq -3*8(%rsi), %r10
25471 + movq -3*8(%rsi), %rcx
25472 movq -4*8(%rsi), %r11
25473 leaq -4*8(%rsi), %rsi
25474 movq %r8, -1*8(%rdi)
25475 movq %r9, -2*8(%rdi)
25476 - movq %r10, -3*8(%rdi)
25477 + movq %rcx, -3*8(%rdi)
25478 movq %r11, -4*8(%rdi)
25479 leaq -4*8(%rdi), %rdi
25480 jae .Lcopy_backward_loop
25481 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25482 */
25483 movq 0*8(%rsi), %r8
25484 movq 1*8(%rsi), %r9
25485 - movq -2*8(%rsi, %rdx), %r10
25486 + movq -2*8(%rsi, %rdx), %rcx
25487 movq -1*8(%rsi, %rdx), %r11
25488 movq %r8, 0*8(%rdi)
25489 movq %r9, 1*8(%rdi)
25490 - movq %r10, -2*8(%rdi, %rdx)
25491 + movq %rcx, -2*8(%rdi, %rdx)
25492 movq %r11, -1*8(%rdi, %rdx)
25493 + pax_force_retaddr
25494 retq
25495 .p2align 4
25496 .Lless_16bytes:
25497 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25498 movq -1*8(%rsi, %rdx), %r9
25499 movq %r8, 0*8(%rdi)
25500 movq %r9, -1*8(%rdi, %rdx)
25501 + pax_force_retaddr
25502 retq
25503 .p2align 4
25504 .Lless_8bytes:
25505 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25506 movl -4(%rsi, %rdx), %r8d
25507 movl %ecx, (%rdi)
25508 movl %r8d, -4(%rdi, %rdx)
25509 + pax_force_retaddr
25510 retq
25511 .p2align 4
25512 .Lless_3bytes:
25513 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25514 movb %cl, (%rdi)
25515
25516 .Lend:
25517 + pax_force_retaddr
25518 retq
25519 CFI_ENDPROC
25520 ENDPROC(memcpy)
25521 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25522 index ee16461..c39c199 100644
25523 --- a/arch/x86/lib/memmove_64.S
25524 +++ b/arch/x86/lib/memmove_64.S
25525 @@ -61,13 +61,13 @@ ENTRY(memmove)
25526 5:
25527 sub $0x20, %rdx
25528 movq 0*8(%rsi), %r11
25529 - movq 1*8(%rsi), %r10
25530 + movq 1*8(%rsi), %rcx
25531 movq 2*8(%rsi), %r9
25532 movq 3*8(%rsi), %r8
25533 leaq 4*8(%rsi), %rsi
25534
25535 movq %r11, 0*8(%rdi)
25536 - movq %r10, 1*8(%rdi)
25537 + movq %rcx, 1*8(%rdi)
25538 movq %r9, 2*8(%rdi)
25539 movq %r8, 3*8(%rdi)
25540 leaq 4*8(%rdi), %rdi
25541 @@ -81,10 +81,10 @@ ENTRY(memmove)
25542 4:
25543 movq %rdx, %rcx
25544 movq -8(%rsi, %rdx), %r11
25545 - lea -8(%rdi, %rdx), %r10
25546 + lea -8(%rdi, %rdx), %r9
25547 shrq $3, %rcx
25548 rep movsq
25549 - movq %r11, (%r10)
25550 + movq %r11, (%r9)
25551 jmp 13f
25552 .Lmemmove_end_forward:
25553
25554 @@ -95,14 +95,14 @@ ENTRY(memmove)
25555 7:
25556 movq %rdx, %rcx
25557 movq (%rsi), %r11
25558 - movq %rdi, %r10
25559 + movq %rdi, %r9
25560 leaq -8(%rsi, %rdx), %rsi
25561 leaq -8(%rdi, %rdx), %rdi
25562 shrq $3, %rcx
25563 std
25564 rep movsq
25565 cld
25566 - movq %r11, (%r10)
25567 + movq %r11, (%r9)
25568 jmp 13f
25569
25570 /*
25571 @@ -127,13 +127,13 @@ ENTRY(memmove)
25572 8:
25573 subq $0x20, %rdx
25574 movq -1*8(%rsi), %r11
25575 - movq -2*8(%rsi), %r10
25576 + movq -2*8(%rsi), %rcx
25577 movq -3*8(%rsi), %r9
25578 movq -4*8(%rsi), %r8
25579 leaq -4*8(%rsi), %rsi
25580
25581 movq %r11, -1*8(%rdi)
25582 - movq %r10, -2*8(%rdi)
25583 + movq %rcx, -2*8(%rdi)
25584 movq %r9, -3*8(%rdi)
25585 movq %r8, -4*8(%rdi)
25586 leaq -4*8(%rdi), %rdi
25587 @@ -151,11 +151,11 @@ ENTRY(memmove)
25588 * Move data from 16 bytes to 31 bytes.
25589 */
25590 movq 0*8(%rsi), %r11
25591 - movq 1*8(%rsi), %r10
25592 + movq 1*8(%rsi), %rcx
25593 movq -2*8(%rsi, %rdx), %r9
25594 movq -1*8(%rsi, %rdx), %r8
25595 movq %r11, 0*8(%rdi)
25596 - movq %r10, 1*8(%rdi)
25597 + movq %rcx, 1*8(%rdi)
25598 movq %r9, -2*8(%rdi, %rdx)
25599 movq %r8, -1*8(%rdi, %rdx)
25600 jmp 13f
25601 @@ -167,9 +167,9 @@ ENTRY(memmove)
25602 * Move data from 8 bytes to 15 bytes.
25603 */
25604 movq 0*8(%rsi), %r11
25605 - movq -1*8(%rsi, %rdx), %r10
25606 + movq -1*8(%rsi, %rdx), %r9
25607 movq %r11, 0*8(%rdi)
25608 - movq %r10, -1*8(%rdi, %rdx)
25609 + movq %r9, -1*8(%rdi, %rdx)
25610 jmp 13f
25611 10:
25612 cmpq $4, %rdx
25613 @@ -178,9 +178,9 @@ ENTRY(memmove)
25614 * Move data from 4 bytes to 7 bytes.
25615 */
25616 movl (%rsi), %r11d
25617 - movl -4(%rsi, %rdx), %r10d
25618 + movl -4(%rsi, %rdx), %r9d
25619 movl %r11d, (%rdi)
25620 - movl %r10d, -4(%rdi, %rdx)
25621 + movl %r9d, -4(%rdi, %rdx)
25622 jmp 13f
25623 11:
25624 cmp $2, %rdx
25625 @@ -189,9 +189,9 @@ ENTRY(memmove)
25626 * Move data from 2 bytes to 3 bytes.
25627 */
25628 movw (%rsi), %r11w
25629 - movw -2(%rsi, %rdx), %r10w
25630 + movw -2(%rsi, %rdx), %r9w
25631 movw %r11w, (%rdi)
25632 - movw %r10w, -2(%rdi, %rdx)
25633 + movw %r9w, -2(%rdi, %rdx)
25634 jmp 13f
25635 12:
25636 cmp $1, %rdx
25637 @@ -202,6 +202,7 @@ ENTRY(memmove)
25638 movb (%rsi), %r11b
25639 movb %r11b, (%rdi)
25640 13:
25641 + pax_force_retaddr
25642 retq
25643 CFI_ENDPROC
25644
25645 @@ -210,6 +211,7 @@ ENTRY(memmove)
25646 /* Forward moving data. */
25647 movq %rdx, %rcx
25648 rep movsb
25649 + pax_force_retaddr
25650 retq
25651 .Lmemmove_end_forward_efs:
25652 .previous
25653 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
25654 index 2dcb380..963660a 100644
25655 --- a/arch/x86/lib/memset_64.S
25656 +++ b/arch/x86/lib/memset_64.S
25657 @@ -30,6 +30,7 @@
25658 movl %edx,%ecx
25659 rep stosb
25660 movq %r9,%rax
25661 + pax_force_retaddr
25662 ret
25663 .Lmemset_e:
25664 .previous
25665 @@ -52,6 +53,7 @@
25666 movq %rdx,%rcx
25667 rep stosb
25668 movq %r9,%rax
25669 + pax_force_retaddr
25670 ret
25671 .Lmemset_e_e:
25672 .previous
25673 @@ -59,7 +61,7 @@
25674 ENTRY(memset)
25675 ENTRY(__memset)
25676 CFI_STARTPROC
25677 - movq %rdi,%r10
25678 + movq %rdi,%r11
25679
25680 /* expand byte value */
25681 movzbl %sil,%ecx
25682 @@ -117,7 +119,8 @@ ENTRY(__memset)
25683 jnz .Lloop_1
25684
25685 .Lende:
25686 - movq %r10,%rax
25687 + movq %r11,%rax
25688 + pax_force_retaddr
25689 ret
25690
25691 CFI_RESTORE_STATE
25692 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
25693 index c9f2d9b..e7fd2c0 100644
25694 --- a/arch/x86/lib/mmx_32.c
25695 +++ b/arch/x86/lib/mmx_32.c
25696 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25697 {
25698 void *p;
25699 int i;
25700 + unsigned long cr0;
25701
25702 if (unlikely(in_interrupt()))
25703 return __memcpy(to, from, len);
25704 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25705 kernel_fpu_begin();
25706
25707 __asm__ __volatile__ (
25708 - "1: prefetch (%0)\n" /* This set is 28 bytes */
25709 - " prefetch 64(%0)\n"
25710 - " prefetch 128(%0)\n"
25711 - " prefetch 192(%0)\n"
25712 - " prefetch 256(%0)\n"
25713 + "1: prefetch (%1)\n" /* This set is 28 bytes */
25714 + " prefetch 64(%1)\n"
25715 + " prefetch 128(%1)\n"
25716 + " prefetch 192(%1)\n"
25717 + " prefetch 256(%1)\n"
25718 "2: \n"
25719 ".section .fixup, \"ax\"\n"
25720 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25721 + "3: \n"
25722 +
25723 +#ifdef CONFIG_PAX_KERNEXEC
25724 + " movl %%cr0, %0\n"
25725 + " movl %0, %%eax\n"
25726 + " andl $0xFFFEFFFF, %%eax\n"
25727 + " movl %%eax, %%cr0\n"
25728 +#endif
25729 +
25730 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25731 +
25732 +#ifdef CONFIG_PAX_KERNEXEC
25733 + " movl %0, %%cr0\n"
25734 +#endif
25735 +
25736 " jmp 2b\n"
25737 ".previous\n"
25738 _ASM_EXTABLE(1b, 3b)
25739 - : : "r" (from));
25740 + : "=&r" (cr0) : "r" (from) : "ax");
25741
25742 for ( ; i > 5; i--) {
25743 __asm__ __volatile__ (
25744 - "1: prefetch 320(%0)\n"
25745 - "2: movq (%0), %%mm0\n"
25746 - " movq 8(%0), %%mm1\n"
25747 - " movq 16(%0), %%mm2\n"
25748 - " movq 24(%0), %%mm3\n"
25749 - " movq %%mm0, (%1)\n"
25750 - " movq %%mm1, 8(%1)\n"
25751 - " movq %%mm2, 16(%1)\n"
25752 - " movq %%mm3, 24(%1)\n"
25753 - " movq 32(%0), %%mm0\n"
25754 - " movq 40(%0), %%mm1\n"
25755 - " movq 48(%0), %%mm2\n"
25756 - " movq 56(%0), %%mm3\n"
25757 - " movq %%mm0, 32(%1)\n"
25758 - " movq %%mm1, 40(%1)\n"
25759 - " movq %%mm2, 48(%1)\n"
25760 - " movq %%mm3, 56(%1)\n"
25761 + "1: prefetch 320(%1)\n"
25762 + "2: movq (%1), %%mm0\n"
25763 + " movq 8(%1), %%mm1\n"
25764 + " movq 16(%1), %%mm2\n"
25765 + " movq 24(%1), %%mm3\n"
25766 + " movq %%mm0, (%2)\n"
25767 + " movq %%mm1, 8(%2)\n"
25768 + " movq %%mm2, 16(%2)\n"
25769 + " movq %%mm3, 24(%2)\n"
25770 + " movq 32(%1), %%mm0\n"
25771 + " movq 40(%1), %%mm1\n"
25772 + " movq 48(%1), %%mm2\n"
25773 + " movq 56(%1), %%mm3\n"
25774 + " movq %%mm0, 32(%2)\n"
25775 + " movq %%mm1, 40(%2)\n"
25776 + " movq %%mm2, 48(%2)\n"
25777 + " movq %%mm3, 56(%2)\n"
25778 ".section .fixup, \"ax\"\n"
25779 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25780 + "3:\n"
25781 +
25782 +#ifdef CONFIG_PAX_KERNEXEC
25783 + " movl %%cr0, %0\n"
25784 + " movl %0, %%eax\n"
25785 + " andl $0xFFFEFFFF, %%eax\n"
25786 + " movl %%eax, %%cr0\n"
25787 +#endif
25788 +
25789 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25790 +
25791 +#ifdef CONFIG_PAX_KERNEXEC
25792 + " movl %0, %%cr0\n"
25793 +#endif
25794 +
25795 " jmp 2b\n"
25796 ".previous\n"
25797 _ASM_EXTABLE(1b, 3b)
25798 - : : "r" (from), "r" (to) : "memory");
25799 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
25800
25801 from += 64;
25802 to += 64;
25803 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
25804 static void fast_copy_page(void *to, void *from)
25805 {
25806 int i;
25807 + unsigned long cr0;
25808
25809 kernel_fpu_begin();
25810
25811 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
25812 * but that is for later. -AV
25813 */
25814 __asm__ __volatile__(
25815 - "1: prefetch (%0)\n"
25816 - " prefetch 64(%0)\n"
25817 - " prefetch 128(%0)\n"
25818 - " prefetch 192(%0)\n"
25819 - " prefetch 256(%0)\n"
25820 + "1: prefetch (%1)\n"
25821 + " prefetch 64(%1)\n"
25822 + " prefetch 128(%1)\n"
25823 + " prefetch 192(%1)\n"
25824 + " prefetch 256(%1)\n"
25825 "2: \n"
25826 ".section .fixup, \"ax\"\n"
25827 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25828 + "3: \n"
25829 +
25830 +#ifdef CONFIG_PAX_KERNEXEC
25831 + " movl %%cr0, %0\n"
25832 + " movl %0, %%eax\n"
25833 + " andl $0xFFFEFFFF, %%eax\n"
25834 + " movl %%eax, %%cr0\n"
25835 +#endif
25836 +
25837 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25838 +
25839 +#ifdef CONFIG_PAX_KERNEXEC
25840 + " movl %0, %%cr0\n"
25841 +#endif
25842 +
25843 " jmp 2b\n"
25844 ".previous\n"
25845 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
25846 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
25847
25848 for (i = 0; i < (4096-320)/64; i++) {
25849 __asm__ __volatile__ (
25850 - "1: prefetch 320(%0)\n"
25851 - "2: movq (%0), %%mm0\n"
25852 - " movntq %%mm0, (%1)\n"
25853 - " movq 8(%0), %%mm1\n"
25854 - " movntq %%mm1, 8(%1)\n"
25855 - " movq 16(%0), %%mm2\n"
25856 - " movntq %%mm2, 16(%1)\n"
25857 - " movq 24(%0), %%mm3\n"
25858 - " movntq %%mm3, 24(%1)\n"
25859 - " movq 32(%0), %%mm4\n"
25860 - " movntq %%mm4, 32(%1)\n"
25861 - " movq 40(%0), %%mm5\n"
25862 - " movntq %%mm5, 40(%1)\n"
25863 - " movq 48(%0), %%mm6\n"
25864 - " movntq %%mm6, 48(%1)\n"
25865 - " movq 56(%0), %%mm7\n"
25866 - " movntq %%mm7, 56(%1)\n"
25867 + "1: prefetch 320(%1)\n"
25868 + "2: movq (%1), %%mm0\n"
25869 + " movntq %%mm0, (%2)\n"
25870 + " movq 8(%1), %%mm1\n"
25871 + " movntq %%mm1, 8(%2)\n"
25872 + " movq 16(%1), %%mm2\n"
25873 + " movntq %%mm2, 16(%2)\n"
25874 + " movq 24(%1), %%mm3\n"
25875 + " movntq %%mm3, 24(%2)\n"
25876 + " movq 32(%1), %%mm4\n"
25877 + " movntq %%mm4, 32(%2)\n"
25878 + " movq 40(%1), %%mm5\n"
25879 + " movntq %%mm5, 40(%2)\n"
25880 + " movq 48(%1), %%mm6\n"
25881 + " movntq %%mm6, 48(%2)\n"
25882 + " movq 56(%1), %%mm7\n"
25883 + " movntq %%mm7, 56(%2)\n"
25884 ".section .fixup, \"ax\"\n"
25885 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25886 + "3:\n"
25887 +
25888 +#ifdef CONFIG_PAX_KERNEXEC
25889 + " movl %%cr0, %0\n"
25890 + " movl %0, %%eax\n"
25891 + " andl $0xFFFEFFFF, %%eax\n"
25892 + " movl %%eax, %%cr0\n"
25893 +#endif
25894 +
25895 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25896 +
25897 +#ifdef CONFIG_PAX_KERNEXEC
25898 + " movl %0, %%cr0\n"
25899 +#endif
25900 +
25901 " jmp 2b\n"
25902 ".previous\n"
25903 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
25904 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
25905
25906 from += 64;
25907 to += 64;
25908 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
25909 static void fast_copy_page(void *to, void *from)
25910 {
25911 int i;
25912 + unsigned long cr0;
25913
25914 kernel_fpu_begin();
25915
25916 __asm__ __volatile__ (
25917 - "1: prefetch (%0)\n"
25918 - " prefetch 64(%0)\n"
25919 - " prefetch 128(%0)\n"
25920 - " prefetch 192(%0)\n"
25921 - " prefetch 256(%0)\n"
25922 + "1: prefetch (%1)\n"
25923 + " prefetch 64(%1)\n"
25924 + " prefetch 128(%1)\n"
25925 + " prefetch 192(%1)\n"
25926 + " prefetch 256(%1)\n"
25927 "2: \n"
25928 ".section .fixup, \"ax\"\n"
25929 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25930 + "3: \n"
25931 +
25932 +#ifdef CONFIG_PAX_KERNEXEC
25933 + " movl %%cr0, %0\n"
25934 + " movl %0, %%eax\n"
25935 + " andl $0xFFFEFFFF, %%eax\n"
25936 + " movl %%eax, %%cr0\n"
25937 +#endif
25938 +
25939 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25940 +
25941 +#ifdef CONFIG_PAX_KERNEXEC
25942 + " movl %0, %%cr0\n"
25943 +#endif
25944 +
25945 " jmp 2b\n"
25946 ".previous\n"
25947 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
25948 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
25949
25950 for (i = 0; i < 4096/64; i++) {
25951 __asm__ __volatile__ (
25952 - "1: prefetch 320(%0)\n"
25953 - "2: movq (%0), %%mm0\n"
25954 - " movq 8(%0), %%mm1\n"
25955 - " movq 16(%0), %%mm2\n"
25956 - " movq 24(%0), %%mm3\n"
25957 - " movq %%mm0, (%1)\n"
25958 - " movq %%mm1, 8(%1)\n"
25959 - " movq %%mm2, 16(%1)\n"
25960 - " movq %%mm3, 24(%1)\n"
25961 - " movq 32(%0), %%mm0\n"
25962 - " movq 40(%0), %%mm1\n"
25963 - " movq 48(%0), %%mm2\n"
25964 - " movq 56(%0), %%mm3\n"
25965 - " movq %%mm0, 32(%1)\n"
25966 - " movq %%mm1, 40(%1)\n"
25967 - " movq %%mm2, 48(%1)\n"
25968 - " movq %%mm3, 56(%1)\n"
25969 + "1: prefetch 320(%1)\n"
25970 + "2: movq (%1), %%mm0\n"
25971 + " movq 8(%1), %%mm1\n"
25972 + " movq 16(%1), %%mm2\n"
25973 + " movq 24(%1), %%mm3\n"
25974 + " movq %%mm0, (%2)\n"
25975 + " movq %%mm1, 8(%2)\n"
25976 + " movq %%mm2, 16(%2)\n"
25977 + " movq %%mm3, 24(%2)\n"
25978 + " movq 32(%1), %%mm0\n"
25979 + " movq 40(%1), %%mm1\n"
25980 + " movq 48(%1), %%mm2\n"
25981 + " movq 56(%1), %%mm3\n"
25982 + " movq %%mm0, 32(%2)\n"
25983 + " movq %%mm1, 40(%2)\n"
25984 + " movq %%mm2, 48(%2)\n"
25985 + " movq %%mm3, 56(%2)\n"
25986 ".section .fixup, \"ax\"\n"
25987 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25988 + "3:\n"
25989 +
25990 +#ifdef CONFIG_PAX_KERNEXEC
25991 + " movl %%cr0, %0\n"
25992 + " movl %0, %%eax\n"
25993 + " andl $0xFFFEFFFF, %%eax\n"
25994 + " movl %%eax, %%cr0\n"
25995 +#endif
25996 +
25997 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25998 +
25999 +#ifdef CONFIG_PAX_KERNEXEC
26000 + " movl %0, %%cr0\n"
26001 +#endif
26002 +
26003 " jmp 2b\n"
26004 ".previous\n"
26005 _ASM_EXTABLE(1b, 3b)
26006 - : : "r" (from), "r" (to) : "memory");
26007 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26008
26009 from += 64;
26010 to += 64;
26011 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26012 index f6d13ee..aca5f0b 100644
26013 --- a/arch/x86/lib/msr-reg.S
26014 +++ b/arch/x86/lib/msr-reg.S
26015 @@ -3,6 +3,7 @@
26016 #include <asm/dwarf2.h>
26017 #include <asm/asm.h>
26018 #include <asm/msr.h>
26019 +#include <asm/alternative-asm.h>
26020
26021 #ifdef CONFIG_X86_64
26022 /*
26023 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26024 CFI_STARTPROC
26025 pushq_cfi %rbx
26026 pushq_cfi %rbp
26027 - movq %rdi, %r10 /* Save pointer */
26028 + movq %rdi, %r9 /* Save pointer */
26029 xorl %r11d, %r11d /* Return value */
26030 movl (%rdi), %eax
26031 movl 4(%rdi), %ecx
26032 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26033 movl 28(%rdi), %edi
26034 CFI_REMEMBER_STATE
26035 1: \op
26036 -2: movl %eax, (%r10)
26037 +2: movl %eax, (%r9)
26038 movl %r11d, %eax /* Return value */
26039 - movl %ecx, 4(%r10)
26040 - movl %edx, 8(%r10)
26041 - movl %ebx, 12(%r10)
26042 - movl %ebp, 20(%r10)
26043 - movl %esi, 24(%r10)
26044 - movl %edi, 28(%r10)
26045 + movl %ecx, 4(%r9)
26046 + movl %edx, 8(%r9)
26047 + movl %ebx, 12(%r9)
26048 + movl %ebp, 20(%r9)
26049 + movl %esi, 24(%r9)
26050 + movl %edi, 28(%r9)
26051 popq_cfi %rbp
26052 popq_cfi %rbx
26053 + pax_force_retaddr
26054 ret
26055 3:
26056 CFI_RESTORE_STATE
26057 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26058 index fc6ba17..d4d989d 100644
26059 --- a/arch/x86/lib/putuser.S
26060 +++ b/arch/x86/lib/putuser.S
26061 @@ -16,7 +16,9 @@
26062 #include <asm/errno.h>
26063 #include <asm/asm.h>
26064 #include <asm/smap.h>
26065 -
26066 +#include <asm/segment.h>
26067 +#include <asm/pgtable.h>
26068 +#include <asm/alternative-asm.h>
26069
26070 /*
26071 * __put_user_X
26072 @@ -30,57 +32,125 @@
26073 * as they get called from within inline assembly.
26074 */
26075
26076 -#define ENTER CFI_STARTPROC ; \
26077 - GET_THREAD_INFO(%_ASM_BX)
26078 -#define EXIT ASM_CLAC ; \
26079 - ret ; \
26080 +#define ENTER CFI_STARTPROC
26081 +#define EXIT ASM_CLAC ; \
26082 + pax_force_retaddr ; \
26083 + ret ; \
26084 CFI_ENDPROC
26085
26086 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26087 +#define _DEST %_ASM_CX,%_ASM_BX
26088 +#else
26089 +#define _DEST %_ASM_CX
26090 +#endif
26091 +
26092 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26093 +#define __copyuser_seg gs;
26094 +#else
26095 +#define __copyuser_seg
26096 +#endif
26097 +
26098 .text
26099 ENTRY(__put_user_1)
26100 ENTER
26101 +
26102 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26103 + GET_THREAD_INFO(%_ASM_BX)
26104 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26105 jae bad_put_user
26106 ASM_STAC
26107 -1: movb %al,(%_ASM_CX)
26108 +
26109 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26110 + mov pax_user_shadow_base,%_ASM_BX
26111 + cmp %_ASM_BX,%_ASM_CX
26112 + jb 1234f
26113 + xor %ebx,%ebx
26114 +1234:
26115 +#endif
26116 +
26117 +#endif
26118 +
26119 +1: __copyuser_seg movb %al,(_DEST)
26120 xor %eax,%eax
26121 EXIT
26122 ENDPROC(__put_user_1)
26123
26124 ENTRY(__put_user_2)
26125 ENTER
26126 +
26127 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26128 + GET_THREAD_INFO(%_ASM_BX)
26129 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26130 sub $1,%_ASM_BX
26131 cmp %_ASM_BX,%_ASM_CX
26132 jae bad_put_user
26133 ASM_STAC
26134 -2: movw %ax,(%_ASM_CX)
26135 +
26136 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26137 + mov pax_user_shadow_base,%_ASM_BX
26138 + cmp %_ASM_BX,%_ASM_CX
26139 + jb 1234f
26140 + xor %ebx,%ebx
26141 +1234:
26142 +#endif
26143 +
26144 +#endif
26145 +
26146 +2: __copyuser_seg movw %ax,(_DEST)
26147 xor %eax,%eax
26148 EXIT
26149 ENDPROC(__put_user_2)
26150
26151 ENTRY(__put_user_4)
26152 ENTER
26153 +
26154 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26155 + GET_THREAD_INFO(%_ASM_BX)
26156 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26157 sub $3,%_ASM_BX
26158 cmp %_ASM_BX,%_ASM_CX
26159 jae bad_put_user
26160 ASM_STAC
26161 -3: movl %eax,(%_ASM_CX)
26162 +
26163 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26164 + mov pax_user_shadow_base,%_ASM_BX
26165 + cmp %_ASM_BX,%_ASM_CX
26166 + jb 1234f
26167 + xor %ebx,%ebx
26168 +1234:
26169 +#endif
26170 +
26171 +#endif
26172 +
26173 +3: __copyuser_seg movl %eax,(_DEST)
26174 xor %eax,%eax
26175 EXIT
26176 ENDPROC(__put_user_4)
26177
26178 ENTRY(__put_user_8)
26179 ENTER
26180 +
26181 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26182 + GET_THREAD_INFO(%_ASM_BX)
26183 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26184 sub $7,%_ASM_BX
26185 cmp %_ASM_BX,%_ASM_CX
26186 jae bad_put_user
26187 ASM_STAC
26188 -4: mov %_ASM_AX,(%_ASM_CX)
26189 +
26190 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26191 + mov pax_user_shadow_base,%_ASM_BX
26192 + cmp %_ASM_BX,%_ASM_CX
26193 + jb 1234f
26194 + xor %ebx,%ebx
26195 +1234:
26196 +#endif
26197 +
26198 +#endif
26199 +
26200 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26201 #ifdef CONFIG_X86_32
26202 -5: movl %edx,4(%_ASM_CX)
26203 +5: __copyuser_seg movl %edx,4(_DEST)
26204 #endif
26205 xor %eax,%eax
26206 EXIT
26207 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26208 index 1cad221..de671ee 100644
26209 --- a/arch/x86/lib/rwlock.S
26210 +++ b/arch/x86/lib/rwlock.S
26211 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26212 FRAME
26213 0: LOCK_PREFIX
26214 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26215 +
26216 +#ifdef CONFIG_PAX_REFCOUNT
26217 + jno 1234f
26218 + LOCK_PREFIX
26219 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26220 + int $4
26221 +1234:
26222 + _ASM_EXTABLE(1234b, 1234b)
26223 +#endif
26224 +
26225 1: rep; nop
26226 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26227 jne 1b
26228 LOCK_PREFIX
26229 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26230 +
26231 +#ifdef CONFIG_PAX_REFCOUNT
26232 + jno 1234f
26233 + LOCK_PREFIX
26234 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26235 + int $4
26236 +1234:
26237 + _ASM_EXTABLE(1234b, 1234b)
26238 +#endif
26239 +
26240 jnz 0b
26241 ENDFRAME
26242 + pax_force_retaddr
26243 ret
26244 CFI_ENDPROC
26245 END(__write_lock_failed)
26246 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26247 FRAME
26248 0: LOCK_PREFIX
26249 READ_LOCK_SIZE(inc) (%__lock_ptr)
26250 +
26251 +#ifdef CONFIG_PAX_REFCOUNT
26252 + jno 1234f
26253 + LOCK_PREFIX
26254 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26255 + int $4
26256 +1234:
26257 + _ASM_EXTABLE(1234b, 1234b)
26258 +#endif
26259 +
26260 1: rep; nop
26261 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26262 js 1b
26263 LOCK_PREFIX
26264 READ_LOCK_SIZE(dec) (%__lock_ptr)
26265 +
26266 +#ifdef CONFIG_PAX_REFCOUNT
26267 + jno 1234f
26268 + LOCK_PREFIX
26269 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26270 + int $4
26271 +1234:
26272 + _ASM_EXTABLE(1234b, 1234b)
26273 +#endif
26274 +
26275 js 0b
26276 ENDFRAME
26277 + pax_force_retaddr
26278 ret
26279 CFI_ENDPROC
26280 END(__read_lock_failed)
26281 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26282 index 5dff5f0..cadebf4 100644
26283 --- a/arch/x86/lib/rwsem.S
26284 +++ b/arch/x86/lib/rwsem.S
26285 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26286 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26287 CFI_RESTORE __ASM_REG(dx)
26288 restore_common_regs
26289 + pax_force_retaddr
26290 ret
26291 CFI_ENDPROC
26292 ENDPROC(call_rwsem_down_read_failed)
26293 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26294 movq %rax,%rdi
26295 call rwsem_down_write_failed
26296 restore_common_regs
26297 + pax_force_retaddr
26298 ret
26299 CFI_ENDPROC
26300 ENDPROC(call_rwsem_down_write_failed)
26301 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26302 movq %rax,%rdi
26303 call rwsem_wake
26304 restore_common_regs
26305 -1: ret
26306 +1: pax_force_retaddr
26307 + ret
26308 CFI_ENDPROC
26309 ENDPROC(call_rwsem_wake)
26310
26311 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26312 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26313 CFI_RESTORE __ASM_REG(dx)
26314 restore_common_regs
26315 + pax_force_retaddr
26316 ret
26317 CFI_ENDPROC
26318 ENDPROC(call_rwsem_downgrade_wake)
26319 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26320 index a63efd6..ccecad8 100644
26321 --- a/arch/x86/lib/thunk_64.S
26322 +++ b/arch/x86/lib/thunk_64.S
26323 @@ -8,6 +8,7 @@
26324 #include <linux/linkage.h>
26325 #include <asm/dwarf2.h>
26326 #include <asm/calling.h>
26327 +#include <asm/alternative-asm.h>
26328
26329 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26330 .macro THUNK name, func, put_ret_addr_in_rdi=0
26331 @@ -41,5 +42,6 @@
26332 SAVE_ARGS
26333 restore:
26334 RESTORE_ARGS
26335 + pax_force_retaddr
26336 ret
26337 CFI_ENDPROC
26338 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26339 index f0312d7..9c39d63 100644
26340 --- a/arch/x86/lib/usercopy_32.c
26341 +++ b/arch/x86/lib/usercopy_32.c
26342 @@ -42,11 +42,13 @@ do { \
26343 int __d0; \
26344 might_fault(); \
26345 __asm__ __volatile__( \
26346 + __COPYUSER_SET_ES \
26347 ASM_STAC "\n" \
26348 "0: rep; stosl\n" \
26349 " movl %2,%0\n" \
26350 "1: rep; stosb\n" \
26351 "2: " ASM_CLAC "\n" \
26352 + __COPYUSER_RESTORE_ES \
26353 ".section .fixup,\"ax\"\n" \
26354 "3: lea 0(%2,%0,4),%0\n" \
26355 " jmp 2b\n" \
26356 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26357
26358 #ifdef CONFIG_X86_INTEL_USERCOPY
26359 static unsigned long
26360 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26361 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26362 {
26363 int d0, d1;
26364 __asm__ __volatile__(
26365 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26366 " .align 2,0x90\n"
26367 "3: movl 0(%4), %%eax\n"
26368 "4: movl 4(%4), %%edx\n"
26369 - "5: movl %%eax, 0(%3)\n"
26370 - "6: movl %%edx, 4(%3)\n"
26371 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26372 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26373 "7: movl 8(%4), %%eax\n"
26374 "8: movl 12(%4),%%edx\n"
26375 - "9: movl %%eax, 8(%3)\n"
26376 - "10: movl %%edx, 12(%3)\n"
26377 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26378 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26379 "11: movl 16(%4), %%eax\n"
26380 "12: movl 20(%4), %%edx\n"
26381 - "13: movl %%eax, 16(%3)\n"
26382 - "14: movl %%edx, 20(%3)\n"
26383 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26384 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26385 "15: movl 24(%4), %%eax\n"
26386 "16: movl 28(%4), %%edx\n"
26387 - "17: movl %%eax, 24(%3)\n"
26388 - "18: movl %%edx, 28(%3)\n"
26389 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26390 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26391 "19: movl 32(%4), %%eax\n"
26392 "20: movl 36(%4), %%edx\n"
26393 - "21: movl %%eax, 32(%3)\n"
26394 - "22: movl %%edx, 36(%3)\n"
26395 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26396 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26397 "23: movl 40(%4), %%eax\n"
26398 "24: movl 44(%4), %%edx\n"
26399 - "25: movl %%eax, 40(%3)\n"
26400 - "26: movl %%edx, 44(%3)\n"
26401 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26402 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26403 "27: movl 48(%4), %%eax\n"
26404 "28: movl 52(%4), %%edx\n"
26405 - "29: movl %%eax, 48(%3)\n"
26406 - "30: movl %%edx, 52(%3)\n"
26407 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26408 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26409 "31: movl 56(%4), %%eax\n"
26410 "32: movl 60(%4), %%edx\n"
26411 - "33: movl %%eax, 56(%3)\n"
26412 - "34: movl %%edx, 60(%3)\n"
26413 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26414 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26415 " addl $-64, %0\n"
26416 " addl $64, %4\n"
26417 " addl $64, %3\n"
26418 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26419 " shrl $2, %0\n"
26420 " andl $3, %%eax\n"
26421 " cld\n"
26422 + __COPYUSER_SET_ES
26423 "99: rep; movsl\n"
26424 "36: movl %%eax, %0\n"
26425 "37: rep; movsb\n"
26426 "100:\n"
26427 + __COPYUSER_RESTORE_ES
26428 ".section .fixup,\"ax\"\n"
26429 "101: lea 0(%%eax,%0,4),%0\n"
26430 " jmp 100b\n"
26431 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26432 }
26433
26434 static unsigned long
26435 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26436 +{
26437 + int d0, d1;
26438 + __asm__ __volatile__(
26439 + " .align 2,0x90\n"
26440 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26441 + " cmpl $67, %0\n"
26442 + " jbe 3f\n"
26443 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26444 + " .align 2,0x90\n"
26445 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26446 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26447 + "5: movl %%eax, 0(%3)\n"
26448 + "6: movl %%edx, 4(%3)\n"
26449 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26450 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26451 + "9: movl %%eax, 8(%3)\n"
26452 + "10: movl %%edx, 12(%3)\n"
26453 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26454 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26455 + "13: movl %%eax, 16(%3)\n"
26456 + "14: movl %%edx, 20(%3)\n"
26457 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26458 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26459 + "17: movl %%eax, 24(%3)\n"
26460 + "18: movl %%edx, 28(%3)\n"
26461 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26462 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26463 + "21: movl %%eax, 32(%3)\n"
26464 + "22: movl %%edx, 36(%3)\n"
26465 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26466 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26467 + "25: movl %%eax, 40(%3)\n"
26468 + "26: movl %%edx, 44(%3)\n"
26469 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26470 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26471 + "29: movl %%eax, 48(%3)\n"
26472 + "30: movl %%edx, 52(%3)\n"
26473 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26474 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26475 + "33: movl %%eax, 56(%3)\n"
26476 + "34: movl %%edx, 60(%3)\n"
26477 + " addl $-64, %0\n"
26478 + " addl $64, %4\n"
26479 + " addl $64, %3\n"
26480 + " cmpl $63, %0\n"
26481 + " ja 1b\n"
26482 + "35: movl %0, %%eax\n"
26483 + " shrl $2, %0\n"
26484 + " andl $3, %%eax\n"
26485 + " cld\n"
26486 + "99: rep; "__copyuser_seg" movsl\n"
26487 + "36: movl %%eax, %0\n"
26488 + "37: rep; "__copyuser_seg" movsb\n"
26489 + "100:\n"
26490 + ".section .fixup,\"ax\"\n"
26491 + "101: lea 0(%%eax,%0,4),%0\n"
26492 + " jmp 100b\n"
26493 + ".previous\n"
26494 + _ASM_EXTABLE(1b,100b)
26495 + _ASM_EXTABLE(2b,100b)
26496 + _ASM_EXTABLE(3b,100b)
26497 + _ASM_EXTABLE(4b,100b)
26498 + _ASM_EXTABLE(5b,100b)
26499 + _ASM_EXTABLE(6b,100b)
26500 + _ASM_EXTABLE(7b,100b)
26501 + _ASM_EXTABLE(8b,100b)
26502 + _ASM_EXTABLE(9b,100b)
26503 + _ASM_EXTABLE(10b,100b)
26504 + _ASM_EXTABLE(11b,100b)
26505 + _ASM_EXTABLE(12b,100b)
26506 + _ASM_EXTABLE(13b,100b)
26507 + _ASM_EXTABLE(14b,100b)
26508 + _ASM_EXTABLE(15b,100b)
26509 + _ASM_EXTABLE(16b,100b)
26510 + _ASM_EXTABLE(17b,100b)
26511 + _ASM_EXTABLE(18b,100b)
26512 + _ASM_EXTABLE(19b,100b)
26513 + _ASM_EXTABLE(20b,100b)
26514 + _ASM_EXTABLE(21b,100b)
26515 + _ASM_EXTABLE(22b,100b)
26516 + _ASM_EXTABLE(23b,100b)
26517 + _ASM_EXTABLE(24b,100b)
26518 + _ASM_EXTABLE(25b,100b)
26519 + _ASM_EXTABLE(26b,100b)
26520 + _ASM_EXTABLE(27b,100b)
26521 + _ASM_EXTABLE(28b,100b)
26522 + _ASM_EXTABLE(29b,100b)
26523 + _ASM_EXTABLE(30b,100b)
26524 + _ASM_EXTABLE(31b,100b)
26525 + _ASM_EXTABLE(32b,100b)
26526 + _ASM_EXTABLE(33b,100b)
26527 + _ASM_EXTABLE(34b,100b)
26528 + _ASM_EXTABLE(35b,100b)
26529 + _ASM_EXTABLE(36b,100b)
26530 + _ASM_EXTABLE(37b,100b)
26531 + _ASM_EXTABLE(99b,101b)
26532 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26533 + : "1"(to), "2"(from), "0"(size)
26534 + : "eax", "edx", "memory");
26535 + return size;
26536 +}
26537 +
26538 +static unsigned long __size_overflow(3)
26539 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26540 {
26541 int d0, d1;
26542 __asm__ __volatile__(
26543 " .align 2,0x90\n"
26544 - "0: movl 32(%4), %%eax\n"
26545 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26546 " cmpl $67, %0\n"
26547 " jbe 2f\n"
26548 - "1: movl 64(%4), %%eax\n"
26549 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26550 " .align 2,0x90\n"
26551 - "2: movl 0(%4), %%eax\n"
26552 - "21: movl 4(%4), %%edx\n"
26553 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26554 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26555 " movl %%eax, 0(%3)\n"
26556 " movl %%edx, 4(%3)\n"
26557 - "3: movl 8(%4), %%eax\n"
26558 - "31: movl 12(%4),%%edx\n"
26559 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26560 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26561 " movl %%eax, 8(%3)\n"
26562 " movl %%edx, 12(%3)\n"
26563 - "4: movl 16(%4), %%eax\n"
26564 - "41: movl 20(%4), %%edx\n"
26565 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26566 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26567 " movl %%eax, 16(%3)\n"
26568 " movl %%edx, 20(%3)\n"
26569 - "10: movl 24(%4), %%eax\n"
26570 - "51: movl 28(%4), %%edx\n"
26571 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26572 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26573 " movl %%eax, 24(%3)\n"
26574 " movl %%edx, 28(%3)\n"
26575 - "11: movl 32(%4), %%eax\n"
26576 - "61: movl 36(%4), %%edx\n"
26577 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26578 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26579 " movl %%eax, 32(%3)\n"
26580 " movl %%edx, 36(%3)\n"
26581 - "12: movl 40(%4), %%eax\n"
26582 - "71: movl 44(%4), %%edx\n"
26583 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26584 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26585 " movl %%eax, 40(%3)\n"
26586 " movl %%edx, 44(%3)\n"
26587 - "13: movl 48(%4), %%eax\n"
26588 - "81: movl 52(%4), %%edx\n"
26589 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26590 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26591 " movl %%eax, 48(%3)\n"
26592 " movl %%edx, 52(%3)\n"
26593 - "14: movl 56(%4), %%eax\n"
26594 - "91: movl 60(%4), %%edx\n"
26595 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26596 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26597 " movl %%eax, 56(%3)\n"
26598 " movl %%edx, 60(%3)\n"
26599 " addl $-64, %0\n"
26600 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26601 " shrl $2, %0\n"
26602 " andl $3, %%eax\n"
26603 " cld\n"
26604 - "6: rep; movsl\n"
26605 + "6: rep; "__copyuser_seg" movsl\n"
26606 " movl %%eax,%0\n"
26607 - "7: rep; movsb\n"
26608 + "7: rep; "__copyuser_seg" movsb\n"
26609 "8:\n"
26610 ".section .fixup,\"ax\"\n"
26611 "9: lea 0(%%eax,%0,4),%0\n"
26612 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26613 * hyoshiok@miraclelinux.com
26614 */
26615
26616 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26617 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
26618 const void __user *from, unsigned long size)
26619 {
26620 int d0, d1;
26621
26622 __asm__ __volatile__(
26623 " .align 2,0x90\n"
26624 - "0: movl 32(%4), %%eax\n"
26625 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26626 " cmpl $67, %0\n"
26627 " jbe 2f\n"
26628 - "1: movl 64(%4), %%eax\n"
26629 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26630 " .align 2,0x90\n"
26631 - "2: movl 0(%4), %%eax\n"
26632 - "21: movl 4(%4), %%edx\n"
26633 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26634 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26635 " movnti %%eax, 0(%3)\n"
26636 " movnti %%edx, 4(%3)\n"
26637 - "3: movl 8(%4), %%eax\n"
26638 - "31: movl 12(%4),%%edx\n"
26639 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26640 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26641 " movnti %%eax, 8(%3)\n"
26642 " movnti %%edx, 12(%3)\n"
26643 - "4: movl 16(%4), %%eax\n"
26644 - "41: movl 20(%4), %%edx\n"
26645 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26646 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26647 " movnti %%eax, 16(%3)\n"
26648 " movnti %%edx, 20(%3)\n"
26649 - "10: movl 24(%4), %%eax\n"
26650 - "51: movl 28(%4), %%edx\n"
26651 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26652 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26653 " movnti %%eax, 24(%3)\n"
26654 " movnti %%edx, 28(%3)\n"
26655 - "11: movl 32(%4), %%eax\n"
26656 - "61: movl 36(%4), %%edx\n"
26657 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26658 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26659 " movnti %%eax, 32(%3)\n"
26660 " movnti %%edx, 36(%3)\n"
26661 - "12: movl 40(%4), %%eax\n"
26662 - "71: movl 44(%4), %%edx\n"
26663 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26664 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26665 " movnti %%eax, 40(%3)\n"
26666 " movnti %%edx, 44(%3)\n"
26667 - "13: movl 48(%4), %%eax\n"
26668 - "81: movl 52(%4), %%edx\n"
26669 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26670 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26671 " movnti %%eax, 48(%3)\n"
26672 " movnti %%edx, 52(%3)\n"
26673 - "14: movl 56(%4), %%eax\n"
26674 - "91: movl 60(%4), %%edx\n"
26675 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26676 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26677 " movnti %%eax, 56(%3)\n"
26678 " movnti %%edx, 60(%3)\n"
26679 " addl $-64, %0\n"
26680 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26681 " shrl $2, %0\n"
26682 " andl $3, %%eax\n"
26683 " cld\n"
26684 - "6: rep; movsl\n"
26685 + "6: rep; "__copyuser_seg" movsl\n"
26686 " movl %%eax,%0\n"
26687 - "7: rep; movsb\n"
26688 + "7: rep; "__copyuser_seg" movsb\n"
26689 "8:\n"
26690 ".section .fixup,\"ax\"\n"
26691 "9: lea 0(%%eax,%0,4),%0\n"
26692 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26693 return size;
26694 }
26695
26696 -static unsigned long __copy_user_intel_nocache(void *to,
26697 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
26698 const void __user *from, unsigned long size)
26699 {
26700 int d0, d1;
26701
26702 __asm__ __volatile__(
26703 " .align 2,0x90\n"
26704 - "0: movl 32(%4), %%eax\n"
26705 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26706 " cmpl $67, %0\n"
26707 " jbe 2f\n"
26708 - "1: movl 64(%4), %%eax\n"
26709 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26710 " .align 2,0x90\n"
26711 - "2: movl 0(%4), %%eax\n"
26712 - "21: movl 4(%4), %%edx\n"
26713 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26714 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26715 " movnti %%eax, 0(%3)\n"
26716 " movnti %%edx, 4(%3)\n"
26717 - "3: movl 8(%4), %%eax\n"
26718 - "31: movl 12(%4),%%edx\n"
26719 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26720 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26721 " movnti %%eax, 8(%3)\n"
26722 " movnti %%edx, 12(%3)\n"
26723 - "4: movl 16(%4), %%eax\n"
26724 - "41: movl 20(%4), %%edx\n"
26725 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26726 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26727 " movnti %%eax, 16(%3)\n"
26728 " movnti %%edx, 20(%3)\n"
26729 - "10: movl 24(%4), %%eax\n"
26730 - "51: movl 28(%4), %%edx\n"
26731 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26732 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26733 " movnti %%eax, 24(%3)\n"
26734 " movnti %%edx, 28(%3)\n"
26735 - "11: movl 32(%4), %%eax\n"
26736 - "61: movl 36(%4), %%edx\n"
26737 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26738 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26739 " movnti %%eax, 32(%3)\n"
26740 " movnti %%edx, 36(%3)\n"
26741 - "12: movl 40(%4), %%eax\n"
26742 - "71: movl 44(%4), %%edx\n"
26743 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26744 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26745 " movnti %%eax, 40(%3)\n"
26746 " movnti %%edx, 44(%3)\n"
26747 - "13: movl 48(%4), %%eax\n"
26748 - "81: movl 52(%4), %%edx\n"
26749 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26750 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26751 " movnti %%eax, 48(%3)\n"
26752 " movnti %%edx, 52(%3)\n"
26753 - "14: movl 56(%4), %%eax\n"
26754 - "91: movl 60(%4), %%edx\n"
26755 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26756 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26757 " movnti %%eax, 56(%3)\n"
26758 " movnti %%edx, 60(%3)\n"
26759 " addl $-64, %0\n"
26760 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
26761 " shrl $2, %0\n"
26762 " andl $3, %%eax\n"
26763 " cld\n"
26764 - "6: rep; movsl\n"
26765 + "6: rep; "__copyuser_seg" movsl\n"
26766 " movl %%eax,%0\n"
26767 - "7: rep; movsb\n"
26768 + "7: rep; "__copyuser_seg" movsb\n"
26769 "8:\n"
26770 ".section .fixup,\"ax\"\n"
26771 "9: lea 0(%%eax,%0,4),%0\n"
26772 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
26773 */
26774 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
26775 unsigned long size);
26776 -unsigned long __copy_user_intel(void __user *to, const void *from,
26777 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
26778 + unsigned long size);
26779 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
26780 unsigned long size);
26781 unsigned long __copy_user_zeroing_intel_nocache(void *to,
26782 const void __user *from, unsigned long size);
26783 #endif /* CONFIG_X86_INTEL_USERCOPY */
26784
26785 /* Generic arbitrary sized copy. */
26786 -#define __copy_user(to, from, size) \
26787 +#define __copy_user(to, from, size, prefix, set, restore) \
26788 do { \
26789 int __d0, __d1, __d2; \
26790 __asm__ __volatile__( \
26791 + set \
26792 " cmp $7,%0\n" \
26793 " jbe 1f\n" \
26794 " movl %1,%0\n" \
26795 " negl %0\n" \
26796 " andl $7,%0\n" \
26797 " subl %0,%3\n" \
26798 - "4: rep; movsb\n" \
26799 + "4: rep; "prefix"movsb\n" \
26800 " movl %3,%0\n" \
26801 " shrl $2,%0\n" \
26802 " andl $3,%3\n" \
26803 " .align 2,0x90\n" \
26804 - "0: rep; movsl\n" \
26805 + "0: rep; "prefix"movsl\n" \
26806 " movl %3,%0\n" \
26807 - "1: rep; movsb\n" \
26808 + "1: rep; "prefix"movsb\n" \
26809 "2:\n" \
26810 + restore \
26811 ".section .fixup,\"ax\"\n" \
26812 "5: addl %3,%0\n" \
26813 " jmp 2b\n" \
26814 @@ -538,14 +650,14 @@ do { \
26815 " negl %0\n" \
26816 " andl $7,%0\n" \
26817 " subl %0,%3\n" \
26818 - "4: rep; movsb\n" \
26819 + "4: rep; "__copyuser_seg"movsb\n" \
26820 " movl %3,%0\n" \
26821 " shrl $2,%0\n" \
26822 " andl $3,%3\n" \
26823 " .align 2,0x90\n" \
26824 - "0: rep; movsl\n" \
26825 + "0: rep; "__copyuser_seg"movsl\n" \
26826 " movl %3,%0\n" \
26827 - "1: rep; movsb\n" \
26828 + "1: rep; "__copyuser_seg"movsb\n" \
26829 "2:\n" \
26830 ".section .fixup,\"ax\"\n" \
26831 "5: addl %3,%0\n" \
26832 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
26833 {
26834 stac();
26835 if (movsl_is_ok(to, from, n))
26836 - __copy_user(to, from, n);
26837 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
26838 else
26839 - n = __copy_user_intel(to, from, n);
26840 + n = __generic_copy_to_user_intel(to, from, n);
26841 clac();
26842 return n;
26843 }
26844 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
26845 {
26846 stac();
26847 if (movsl_is_ok(to, from, n))
26848 - __copy_user(to, from, n);
26849 + __copy_user(to, from, n, __copyuser_seg, "", "");
26850 else
26851 - n = __copy_user_intel((void __user *)to,
26852 - (const void *)from, n);
26853 + n = __generic_copy_from_user_intel(to, from, n);
26854 clac();
26855 return n;
26856 }
26857 @@ -632,66 +743,51 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
26858 if (n > 64 && cpu_has_xmm2)
26859 n = __copy_user_intel_nocache(to, from, n);
26860 else
26861 - __copy_user(to, from, n);
26862 + __copy_user(to, from, n, __copyuser_seg, "", "");
26863 #else
26864 - __copy_user(to, from, n);
26865 + __copy_user(to, from, n, __copyuser_seg, "", "");
26866 #endif
26867 clac();
26868 return n;
26869 }
26870 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
26871
26872 -/**
26873 - * copy_to_user: - Copy a block of data into user space.
26874 - * @to: Destination address, in user space.
26875 - * @from: Source address, in kernel space.
26876 - * @n: Number of bytes to copy.
26877 - *
26878 - * Context: User context only. This function may sleep.
26879 - *
26880 - * Copy data from kernel space to user space.
26881 - *
26882 - * Returns number of bytes that could not be copied.
26883 - * On success, this will be zero.
26884 - */
26885 -unsigned long
26886 -copy_to_user(void __user *to, const void *from, unsigned long n)
26887 -{
26888 - if (access_ok(VERIFY_WRITE, to, n))
26889 - n = __copy_to_user(to, from, n);
26890 - return n;
26891 -}
26892 -EXPORT_SYMBOL(copy_to_user);
26893 -
26894 -/**
26895 - * copy_from_user: - Copy a block of data from user space.
26896 - * @to: Destination address, in kernel space.
26897 - * @from: Source address, in user space.
26898 - * @n: Number of bytes to copy.
26899 - *
26900 - * Context: User context only. This function may sleep.
26901 - *
26902 - * Copy data from user space to kernel space.
26903 - *
26904 - * Returns number of bytes that could not be copied.
26905 - * On success, this will be zero.
26906 - *
26907 - * If some data could not be copied, this function will pad the copied
26908 - * data to the requested size using zero bytes.
26909 - */
26910 -unsigned long
26911 -_copy_from_user(void *to, const void __user *from, unsigned long n)
26912 -{
26913 - if (access_ok(VERIFY_READ, from, n))
26914 - n = __copy_from_user(to, from, n);
26915 - else
26916 - memset(to, 0, n);
26917 - return n;
26918 -}
26919 -EXPORT_SYMBOL(_copy_from_user);
26920 -
26921 void copy_from_user_overflow(void)
26922 {
26923 WARN(1, "Buffer overflow detected!\n");
26924 }
26925 EXPORT_SYMBOL(copy_from_user_overflow);
26926 +
26927 +void copy_to_user_overflow(void)
26928 +{
26929 + WARN(1, "Buffer overflow detected!\n");
26930 +}
26931 +EXPORT_SYMBOL(copy_to_user_overflow);
26932 +
26933 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26934 +void __set_fs(mm_segment_t x)
26935 +{
26936 + switch (x.seg) {
26937 + case 0:
26938 + loadsegment(gs, 0);
26939 + break;
26940 + case TASK_SIZE_MAX:
26941 + loadsegment(gs, __USER_DS);
26942 + break;
26943 + case -1UL:
26944 + loadsegment(gs, __KERNEL_DS);
26945 + break;
26946 + default:
26947 + BUG();
26948 + }
26949 + return;
26950 +}
26951 +EXPORT_SYMBOL(__set_fs);
26952 +
26953 +void set_fs(mm_segment_t x)
26954 +{
26955 + current_thread_info()->addr_limit = x;
26956 + __set_fs(x);
26957 +}
26958 +EXPORT_SYMBOL(set_fs);
26959 +#endif
26960 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
26961 index 906fea3..ee8a097 100644
26962 --- a/arch/x86/lib/usercopy_64.c
26963 +++ b/arch/x86/lib/usercopy_64.c
26964 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
26965 _ASM_EXTABLE(0b,3b)
26966 _ASM_EXTABLE(1b,2b)
26967 : [size8] "=&c"(size), [dst] "=&D" (__d0)
26968 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
26969 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
26970 [zero] "r" (0UL), [eight] "r" (8UL));
26971 clac();
26972 return size;
26973 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
26974 }
26975 EXPORT_SYMBOL(clear_user);
26976
26977 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
26978 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
26979 {
26980 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
26981 - return copy_user_generic((__force void *)to, (__force void *)from, len);
26982 - }
26983 - return len;
26984 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
26985 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
26986 + return len;
26987 }
26988 EXPORT_SYMBOL(copy_in_user);
26989
26990 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
26991 * it is not necessary to optimize tail handling.
26992 */
26993 unsigned long
26994 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
26995 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
26996 {
26997 char c;
26998 unsigned zero_len;
26999 @@ -87,3 +86,15 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27000 clac();
27001 return len;
27002 }
27003 +
27004 +void copy_from_user_overflow(void)
27005 +{
27006 + WARN(1, "Buffer overflow detected!\n");
27007 +}
27008 +EXPORT_SYMBOL(copy_from_user_overflow);
27009 +
27010 +void copy_to_user_overflow(void)
27011 +{
27012 + WARN(1, "Buffer overflow detected!\n");
27013 +}
27014 +EXPORT_SYMBOL(copy_to_user_overflow);
27015 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27016 index 903ec1e..c4166b2 100644
27017 --- a/arch/x86/mm/extable.c
27018 +++ b/arch/x86/mm/extable.c
27019 @@ -6,12 +6,24 @@
27020 static inline unsigned long
27021 ex_insn_addr(const struct exception_table_entry *x)
27022 {
27023 - return (unsigned long)&x->insn + x->insn;
27024 + unsigned long reloc = 0;
27025 +
27026 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27027 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27028 +#endif
27029 +
27030 + return (unsigned long)&x->insn + x->insn + reloc;
27031 }
27032 static inline unsigned long
27033 ex_fixup_addr(const struct exception_table_entry *x)
27034 {
27035 - return (unsigned long)&x->fixup + x->fixup;
27036 + unsigned long reloc = 0;
27037 +
27038 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27039 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27040 +#endif
27041 +
27042 + return (unsigned long)&x->fixup + x->fixup + reloc;
27043 }
27044
27045 int fixup_exception(struct pt_regs *regs)
27046 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27047 unsigned long new_ip;
27048
27049 #ifdef CONFIG_PNPBIOS
27050 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27051 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27052 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27053 extern u32 pnp_bios_is_utter_crap;
27054 pnp_bios_is_utter_crap = 1;
27055 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27056 i += 4;
27057 p->fixup -= i;
27058 i += 4;
27059 +
27060 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27061 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27062 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27063 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27064 +#endif
27065 +
27066 }
27067 }
27068
27069 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27070 index 0e88336..2bb9777 100644
27071 --- a/arch/x86/mm/fault.c
27072 +++ b/arch/x86/mm/fault.c
27073 @@ -13,12 +13,19 @@
27074 #include <linux/perf_event.h> /* perf_sw_event */
27075 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27076 #include <linux/prefetch.h> /* prefetchw */
27077 +#include <linux/unistd.h>
27078 +#include <linux/compiler.h>
27079
27080 #include <asm/traps.h> /* dotraplinkage, ... */
27081 #include <asm/pgalloc.h> /* pgd_*(), ... */
27082 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27083 #include <asm/fixmap.h> /* VSYSCALL_START */
27084 #include <asm/context_tracking.h> /* exception_enter(), ... */
27085 +#include <asm/tlbflush.h>
27086 +
27087 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27088 +#include <asm/stacktrace.h>
27089 +#endif
27090
27091 /*
27092 * Page fault error code bits:
27093 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27094 int ret = 0;
27095
27096 /* kprobe_running() needs smp_processor_id() */
27097 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27098 + if (kprobes_built_in() && !user_mode(regs)) {
27099 preempt_disable();
27100 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27101 ret = 1;
27102 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27103 return !instr_lo || (instr_lo>>1) == 1;
27104 case 0x00:
27105 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27106 - if (probe_kernel_address(instr, opcode))
27107 + if (user_mode(regs)) {
27108 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27109 + return 0;
27110 + } else if (probe_kernel_address(instr, opcode))
27111 return 0;
27112
27113 *prefetch = (instr_lo == 0xF) &&
27114 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27115 while (instr < max_instr) {
27116 unsigned char opcode;
27117
27118 - if (probe_kernel_address(instr, opcode))
27119 + if (user_mode(regs)) {
27120 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27121 + break;
27122 + } else if (probe_kernel_address(instr, opcode))
27123 break;
27124
27125 instr++;
27126 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27127 force_sig_info(si_signo, &info, tsk);
27128 }
27129
27130 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27131 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27132 +#endif
27133 +
27134 +#ifdef CONFIG_PAX_EMUTRAMP
27135 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27136 +#endif
27137 +
27138 +#ifdef CONFIG_PAX_PAGEEXEC
27139 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27140 +{
27141 + pgd_t *pgd;
27142 + pud_t *pud;
27143 + pmd_t *pmd;
27144 +
27145 + pgd = pgd_offset(mm, address);
27146 + if (!pgd_present(*pgd))
27147 + return NULL;
27148 + pud = pud_offset(pgd, address);
27149 + if (!pud_present(*pud))
27150 + return NULL;
27151 + pmd = pmd_offset(pud, address);
27152 + if (!pmd_present(*pmd))
27153 + return NULL;
27154 + return pmd;
27155 +}
27156 +#endif
27157 +
27158 DEFINE_SPINLOCK(pgd_lock);
27159 LIST_HEAD(pgd_list);
27160
27161 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27162 for (address = VMALLOC_START & PMD_MASK;
27163 address >= TASK_SIZE && address < FIXADDR_TOP;
27164 address += PMD_SIZE) {
27165 +
27166 +#ifdef CONFIG_PAX_PER_CPU_PGD
27167 + unsigned long cpu;
27168 +#else
27169 struct page *page;
27170 +#endif
27171
27172 spin_lock(&pgd_lock);
27173 +
27174 +#ifdef CONFIG_PAX_PER_CPU_PGD
27175 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27176 + pgd_t *pgd = get_cpu_pgd(cpu);
27177 + pmd_t *ret;
27178 +#else
27179 list_for_each_entry(page, &pgd_list, lru) {
27180 + pgd_t *pgd;
27181 spinlock_t *pgt_lock;
27182 pmd_t *ret;
27183
27184 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27185 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27186
27187 spin_lock(pgt_lock);
27188 - ret = vmalloc_sync_one(page_address(page), address);
27189 + pgd = page_address(page);
27190 +#endif
27191 +
27192 + ret = vmalloc_sync_one(pgd, address);
27193 +
27194 +#ifndef CONFIG_PAX_PER_CPU_PGD
27195 spin_unlock(pgt_lock);
27196 +#endif
27197
27198 if (!ret)
27199 break;
27200 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27201 * an interrupt in the middle of a task switch..
27202 */
27203 pgd_paddr = read_cr3();
27204 +
27205 +#ifdef CONFIG_PAX_PER_CPU_PGD
27206 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27207 +#endif
27208 +
27209 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27210 if (!pmd_k)
27211 return -1;
27212 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27213 * happen within a race in page table update. In the later
27214 * case just flush:
27215 */
27216 +
27217 +#ifdef CONFIG_PAX_PER_CPU_PGD
27218 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27219 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27220 +#else
27221 pgd = pgd_offset(current->active_mm, address);
27222 +#endif
27223 +
27224 pgd_ref = pgd_offset_k(address);
27225 if (pgd_none(*pgd_ref))
27226 return -1;
27227 @@ -543,7 +614,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27228 static int is_errata100(struct pt_regs *regs, unsigned long address)
27229 {
27230 #ifdef CONFIG_X86_64
27231 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27232 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27233 return 1;
27234 #endif
27235 return 0;
27236 @@ -570,7 +641,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27237 }
27238
27239 static const char nx_warning[] = KERN_CRIT
27240 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27241 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27242
27243 static void
27244 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27245 @@ -579,15 +650,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27246 if (!oops_may_print())
27247 return;
27248
27249 - if (error_code & PF_INSTR) {
27250 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27251 unsigned int level;
27252
27253 pte_t *pte = lookup_address(address, &level);
27254
27255 if (pte && pte_present(*pte) && !pte_exec(*pte))
27256 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27257 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27258 }
27259
27260 +#ifdef CONFIG_PAX_KERNEXEC
27261 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27262 + if (current->signal->curr_ip)
27263 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27264 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27265 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27266 + else
27267 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27268 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27269 + }
27270 +#endif
27271 +
27272 printk(KERN_ALERT "BUG: unable to handle kernel ");
27273 if (address < PAGE_SIZE)
27274 printk(KERN_CONT "NULL pointer dereference");
27275 @@ -750,6 +833,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27276 return;
27277 }
27278 #endif
27279 +
27280 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27281 + if (pax_is_fetch_fault(regs, error_code, address)) {
27282 +
27283 +#ifdef CONFIG_PAX_EMUTRAMP
27284 + switch (pax_handle_fetch_fault(regs)) {
27285 + case 2:
27286 + return;
27287 + }
27288 +#endif
27289 +
27290 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27291 + do_group_exit(SIGKILL);
27292 + }
27293 +#endif
27294 +
27295 /* Kernel addresses are always protection faults: */
27296 if (address >= TASK_SIZE)
27297 error_code |= PF_PROT;
27298 @@ -835,7 +934,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27299 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27300 printk(KERN_ERR
27301 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27302 - tsk->comm, tsk->pid, address);
27303 + tsk->comm, task_pid_nr(tsk), address);
27304 code = BUS_MCEERR_AR;
27305 }
27306 #endif
27307 @@ -898,6 +997,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27308 return 1;
27309 }
27310
27311 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27312 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27313 +{
27314 + pte_t *pte;
27315 + pmd_t *pmd;
27316 + spinlock_t *ptl;
27317 + unsigned char pte_mask;
27318 +
27319 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27320 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27321 + return 0;
27322 +
27323 + /* PaX: it's our fault, let's handle it if we can */
27324 +
27325 + /* PaX: take a look at read faults before acquiring any locks */
27326 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27327 + /* instruction fetch attempt from a protected page in user mode */
27328 + up_read(&mm->mmap_sem);
27329 +
27330 +#ifdef CONFIG_PAX_EMUTRAMP
27331 + switch (pax_handle_fetch_fault(regs)) {
27332 + case 2:
27333 + return 1;
27334 + }
27335 +#endif
27336 +
27337 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27338 + do_group_exit(SIGKILL);
27339 + }
27340 +
27341 + pmd = pax_get_pmd(mm, address);
27342 + if (unlikely(!pmd))
27343 + return 0;
27344 +
27345 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27346 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27347 + pte_unmap_unlock(pte, ptl);
27348 + return 0;
27349 + }
27350 +
27351 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27352 + /* write attempt to a protected page in user mode */
27353 + pte_unmap_unlock(pte, ptl);
27354 + return 0;
27355 + }
27356 +
27357 +#ifdef CONFIG_SMP
27358 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27359 +#else
27360 + if (likely(address > get_limit(regs->cs)))
27361 +#endif
27362 + {
27363 + set_pte(pte, pte_mkread(*pte));
27364 + __flush_tlb_one(address);
27365 + pte_unmap_unlock(pte, ptl);
27366 + up_read(&mm->mmap_sem);
27367 + return 1;
27368 + }
27369 +
27370 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27371 +
27372 + /*
27373 + * PaX: fill DTLB with user rights and retry
27374 + */
27375 + __asm__ __volatile__ (
27376 + "orb %2,(%1)\n"
27377 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27378 +/*
27379 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27380 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27381 + * page fault when examined during a TLB load attempt. this is true not only
27382 + * for PTEs holding a non-present entry but also present entries that will
27383 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27384 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27385 + * for our target pages since their PTEs are simply not in the TLBs at all.
27386 +
27387 + * the best thing in omitting it is that we gain around 15-20% speed in the
27388 + * fast path of the page fault handler and can get rid of tracing since we
27389 + * can no longer flush unintended entries.
27390 + */
27391 + "invlpg (%0)\n"
27392 +#endif
27393 + __copyuser_seg"testb $0,(%0)\n"
27394 + "xorb %3,(%1)\n"
27395 + :
27396 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27397 + : "memory", "cc");
27398 + pte_unmap_unlock(pte, ptl);
27399 + up_read(&mm->mmap_sem);
27400 + return 1;
27401 +}
27402 +#endif
27403 +
27404 /*
27405 * Handle a spurious fault caused by a stale TLB entry.
27406 *
27407 @@ -964,6 +1156,9 @@ int show_unhandled_signals = 1;
27408 static inline int
27409 access_error(unsigned long error_code, struct vm_area_struct *vma)
27410 {
27411 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27412 + return 1;
27413 +
27414 if (error_code & PF_WRITE) {
27415 /* write, present and write, not present: */
27416 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27417 @@ -992,7 +1187,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27418 if (error_code & PF_USER)
27419 return false;
27420
27421 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27422 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27423 return false;
27424
27425 return true;
27426 @@ -1008,18 +1203,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27427 {
27428 struct vm_area_struct *vma;
27429 struct task_struct *tsk;
27430 - unsigned long address;
27431 struct mm_struct *mm;
27432 int fault;
27433 int write = error_code & PF_WRITE;
27434 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27435 (write ? FAULT_FLAG_WRITE : 0);
27436
27437 - tsk = current;
27438 - mm = tsk->mm;
27439 -
27440 /* Get the faulting address: */
27441 - address = read_cr2();
27442 + unsigned long address = read_cr2();
27443 +
27444 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27445 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
27446 + if (!search_exception_tables(regs->ip)) {
27447 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27448 + bad_area_nosemaphore(regs, error_code, address);
27449 + return;
27450 + }
27451 + if (address < pax_user_shadow_base) {
27452 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27453 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27454 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27455 + } else
27456 + address -= pax_user_shadow_base;
27457 + }
27458 +#endif
27459 +
27460 + tsk = current;
27461 + mm = tsk->mm;
27462
27463 /*
27464 * Detect and handle instructions that would cause a page fault for
27465 @@ -1080,7 +1290,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27466 * User-mode registers count as a user access even for any
27467 * potential system fault or CPU buglet:
27468 */
27469 - if (user_mode_vm(regs)) {
27470 + if (user_mode(regs)) {
27471 local_irq_enable();
27472 error_code |= PF_USER;
27473 } else {
27474 @@ -1142,6 +1352,11 @@ retry:
27475 might_sleep();
27476 }
27477
27478 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27479 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27480 + return;
27481 +#endif
27482 +
27483 vma = find_vma(mm, address);
27484 if (unlikely(!vma)) {
27485 bad_area(regs, error_code, address);
27486 @@ -1153,18 +1368,24 @@ retry:
27487 bad_area(regs, error_code, address);
27488 return;
27489 }
27490 - if (error_code & PF_USER) {
27491 - /*
27492 - * Accessing the stack below %sp is always a bug.
27493 - * The large cushion allows instructions like enter
27494 - * and pusha to work. ("enter $65535, $31" pushes
27495 - * 32 pointers and then decrements %sp by 65535.)
27496 - */
27497 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27498 - bad_area(regs, error_code, address);
27499 - return;
27500 - }
27501 + /*
27502 + * Accessing the stack below %sp is always a bug.
27503 + * The large cushion allows instructions like enter
27504 + * and pusha to work. ("enter $65535, $31" pushes
27505 + * 32 pointers and then decrements %sp by 65535.)
27506 + */
27507 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27508 + bad_area(regs, error_code, address);
27509 + return;
27510 }
27511 +
27512 +#ifdef CONFIG_PAX_SEGMEXEC
27513 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27514 + bad_area(regs, error_code, address);
27515 + return;
27516 + }
27517 +#endif
27518 +
27519 if (unlikely(expand_stack(vma, address))) {
27520 bad_area(regs, error_code, address);
27521 return;
27522 @@ -1228,3 +1449,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27523 __do_page_fault(regs, error_code);
27524 exception_exit(regs);
27525 }
27526 +
27527 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27528 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27529 +{
27530 + struct mm_struct *mm = current->mm;
27531 + unsigned long ip = regs->ip;
27532 +
27533 + if (v8086_mode(regs))
27534 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27535 +
27536 +#ifdef CONFIG_PAX_PAGEEXEC
27537 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27538 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27539 + return true;
27540 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27541 + return true;
27542 + return false;
27543 + }
27544 +#endif
27545 +
27546 +#ifdef CONFIG_PAX_SEGMEXEC
27547 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27548 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27549 + return true;
27550 + return false;
27551 + }
27552 +#endif
27553 +
27554 + return false;
27555 +}
27556 +#endif
27557 +
27558 +#ifdef CONFIG_PAX_EMUTRAMP
27559 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
27560 +{
27561 + int err;
27562 +
27563 + do { /* PaX: libffi trampoline emulation */
27564 + unsigned char mov, jmp;
27565 + unsigned int addr1, addr2;
27566 +
27567 +#ifdef CONFIG_X86_64
27568 + if ((regs->ip + 9) >> 32)
27569 + break;
27570 +#endif
27571 +
27572 + err = get_user(mov, (unsigned char __user *)regs->ip);
27573 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27574 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27575 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27576 +
27577 + if (err)
27578 + break;
27579 +
27580 + if (mov == 0xB8 && jmp == 0xE9) {
27581 + regs->ax = addr1;
27582 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27583 + return 2;
27584 + }
27585 + } while (0);
27586 +
27587 + do { /* PaX: gcc trampoline emulation #1 */
27588 + unsigned char mov1, mov2;
27589 + unsigned short jmp;
27590 + unsigned int addr1, addr2;
27591 +
27592 +#ifdef CONFIG_X86_64
27593 + if ((regs->ip + 11) >> 32)
27594 + break;
27595 +#endif
27596 +
27597 + err = get_user(mov1, (unsigned char __user *)regs->ip);
27598 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27599 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
27600 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27601 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
27602 +
27603 + if (err)
27604 + break;
27605 +
27606 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
27607 + regs->cx = addr1;
27608 + regs->ax = addr2;
27609 + regs->ip = addr2;
27610 + return 2;
27611 + }
27612 + } while (0);
27613 +
27614 + do { /* PaX: gcc trampoline emulation #2 */
27615 + unsigned char mov, jmp;
27616 + unsigned int addr1, addr2;
27617 +
27618 +#ifdef CONFIG_X86_64
27619 + if ((regs->ip + 9) >> 32)
27620 + break;
27621 +#endif
27622 +
27623 + err = get_user(mov, (unsigned char __user *)regs->ip);
27624 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27625 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27626 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27627 +
27628 + if (err)
27629 + break;
27630 +
27631 + if (mov == 0xB9 && jmp == 0xE9) {
27632 + regs->cx = addr1;
27633 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27634 + return 2;
27635 + }
27636 + } while (0);
27637 +
27638 + return 1; /* PaX in action */
27639 +}
27640 +
27641 +#ifdef CONFIG_X86_64
27642 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
27643 +{
27644 + int err;
27645 +
27646 + do { /* PaX: libffi trampoline emulation */
27647 + unsigned short mov1, mov2, jmp1;
27648 + unsigned char stcclc, jmp2;
27649 + unsigned long addr1, addr2;
27650 +
27651 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27652 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27653 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27654 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27655 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
27656 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
27657 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
27658 +
27659 + if (err)
27660 + break;
27661 +
27662 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27663 + regs->r11 = addr1;
27664 + regs->r10 = addr2;
27665 + if (stcclc == 0xF8)
27666 + regs->flags &= ~X86_EFLAGS_CF;
27667 + else
27668 + regs->flags |= X86_EFLAGS_CF;
27669 + regs->ip = addr1;
27670 + return 2;
27671 + }
27672 + } while (0);
27673 +
27674 + do { /* PaX: gcc trampoline emulation #1 */
27675 + unsigned short mov1, mov2, jmp1;
27676 + unsigned char jmp2;
27677 + unsigned int addr1;
27678 + unsigned long addr2;
27679 +
27680 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27681 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
27682 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
27683 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
27684 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
27685 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
27686 +
27687 + if (err)
27688 + break;
27689 +
27690 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27691 + regs->r11 = addr1;
27692 + regs->r10 = addr2;
27693 + regs->ip = addr1;
27694 + return 2;
27695 + }
27696 + } while (0);
27697 +
27698 + do { /* PaX: gcc trampoline emulation #2 */
27699 + unsigned short mov1, mov2, jmp1;
27700 + unsigned char jmp2;
27701 + unsigned long addr1, addr2;
27702 +
27703 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27704 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27705 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27706 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27707 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
27708 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
27709 +
27710 + if (err)
27711 + break;
27712 +
27713 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27714 + regs->r11 = addr1;
27715 + regs->r10 = addr2;
27716 + regs->ip = addr1;
27717 + return 2;
27718 + }
27719 + } while (0);
27720 +
27721 + return 1; /* PaX in action */
27722 +}
27723 +#endif
27724 +
27725 +/*
27726 + * PaX: decide what to do with offenders (regs->ip = fault address)
27727 + *
27728 + * returns 1 when task should be killed
27729 + * 2 when gcc trampoline was detected
27730 + */
27731 +static int pax_handle_fetch_fault(struct pt_regs *regs)
27732 +{
27733 + if (v8086_mode(regs))
27734 + return 1;
27735 +
27736 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
27737 + return 1;
27738 +
27739 +#ifdef CONFIG_X86_32
27740 + return pax_handle_fetch_fault_32(regs);
27741 +#else
27742 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
27743 + return pax_handle_fetch_fault_32(regs);
27744 + else
27745 + return pax_handle_fetch_fault_64(regs);
27746 +#endif
27747 +}
27748 +#endif
27749 +
27750 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27751 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
27752 +{
27753 + long i;
27754 +
27755 + printk(KERN_ERR "PAX: bytes at PC: ");
27756 + for (i = 0; i < 20; i++) {
27757 + unsigned char c;
27758 + if (get_user(c, (unsigned char __force_user *)pc+i))
27759 + printk(KERN_CONT "?? ");
27760 + else
27761 + printk(KERN_CONT "%02x ", c);
27762 + }
27763 + printk("\n");
27764 +
27765 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
27766 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
27767 + unsigned long c;
27768 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
27769 +#ifdef CONFIG_X86_32
27770 + printk(KERN_CONT "???????? ");
27771 +#else
27772 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
27773 + printk(KERN_CONT "???????? ???????? ");
27774 + else
27775 + printk(KERN_CONT "???????????????? ");
27776 +#endif
27777 + } else {
27778 +#ifdef CONFIG_X86_64
27779 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
27780 + printk(KERN_CONT "%08x ", (unsigned int)c);
27781 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
27782 + } else
27783 +#endif
27784 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
27785 + }
27786 + }
27787 + printk("\n");
27788 +}
27789 +#endif
27790 +
27791 +/**
27792 + * probe_kernel_write(): safely attempt to write to a location
27793 + * @dst: address to write to
27794 + * @src: pointer to the data that shall be written
27795 + * @size: size of the data chunk
27796 + *
27797 + * Safely write to address @dst from the buffer at @src. If a kernel fault
27798 + * happens, handle that and return -EFAULT.
27799 + */
27800 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
27801 +{
27802 + long ret;
27803 + mm_segment_t old_fs = get_fs();
27804 +
27805 + set_fs(KERNEL_DS);
27806 + pagefault_disable();
27807 + pax_open_kernel();
27808 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
27809 + pax_close_kernel();
27810 + pagefault_enable();
27811 + set_fs(old_fs);
27812 +
27813 + return ret ? -EFAULT : 0;
27814 +}
27815 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
27816 index dd74e46..7d26398 100644
27817 --- a/arch/x86/mm/gup.c
27818 +++ b/arch/x86/mm/gup.c
27819 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
27820 addr = start;
27821 len = (unsigned long) nr_pages << PAGE_SHIFT;
27822 end = start + len;
27823 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27824 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27825 (void __user *)start, len)))
27826 return 0;
27827
27828 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
27829 index 6f31ee5..8ee4164 100644
27830 --- a/arch/x86/mm/highmem_32.c
27831 +++ b/arch/x86/mm/highmem_32.c
27832 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
27833 idx = type + KM_TYPE_NR*smp_processor_id();
27834 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
27835 BUG_ON(!pte_none(*(kmap_pte-idx)));
27836 +
27837 + pax_open_kernel();
27838 set_pte(kmap_pte-idx, mk_pte(page, prot));
27839 + pax_close_kernel();
27840 +
27841 arch_flush_lazy_mmu_mode();
27842
27843 return (void *)vaddr;
27844 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
27845 index ae1aa71..d9bea75 100644
27846 --- a/arch/x86/mm/hugetlbpage.c
27847 +++ b/arch/x86/mm/hugetlbpage.c
27848 @@ -271,23 +271,30 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
27849 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
27850 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
27851 unsigned long addr, unsigned long len,
27852 - unsigned long pgoff, unsigned long flags)
27853 + unsigned long pgoff, unsigned long flags, unsigned long offset)
27854 {
27855 struct hstate *h = hstate_file(file);
27856 struct vm_unmapped_area_info info;
27857 -
27858 +
27859 info.flags = 0;
27860 info.length = len;
27861 info.low_limit = TASK_UNMAPPED_BASE;
27862 +
27863 +#ifdef CONFIG_PAX_RANDMMAP
27864 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
27865 + info.low_limit += current->mm->delta_mmap;
27866 +#endif
27867 +
27868 info.high_limit = TASK_SIZE;
27869 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
27870 info.align_offset = 0;
27871 + info.threadstack_offset = offset;
27872 return vm_unmapped_area(&info);
27873 }
27874
27875 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
27876 unsigned long addr0, unsigned long len,
27877 - unsigned long pgoff, unsigned long flags)
27878 + unsigned long pgoff, unsigned long flags, unsigned long offset)
27879 {
27880 struct hstate *h = hstate_file(file);
27881 struct vm_unmapped_area_info info;
27882 @@ -299,6 +306,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
27883 info.high_limit = current->mm->mmap_base;
27884 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
27885 info.align_offset = 0;
27886 + info.threadstack_offset = offset;
27887 addr = vm_unmapped_area(&info);
27888
27889 /*
27890 @@ -311,6 +319,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
27891 VM_BUG_ON(addr != -ENOMEM);
27892 info.flags = 0;
27893 info.low_limit = TASK_UNMAPPED_BASE;
27894 +
27895 +#ifdef CONFIG_PAX_RANDMMAP
27896 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
27897 + info.low_limit += current->mm->delta_mmap;
27898 +#endif
27899 +
27900 info.high_limit = TASK_SIZE;
27901 addr = vm_unmapped_area(&info);
27902 }
27903 @@ -325,10 +339,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
27904 struct hstate *h = hstate_file(file);
27905 struct mm_struct *mm = current->mm;
27906 struct vm_area_struct *vma;
27907 + unsigned long pax_task_size = TASK_SIZE;
27908 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
27909
27910 if (len & ~huge_page_mask(h))
27911 return -EINVAL;
27912 - if (len > TASK_SIZE)
27913 +
27914 +#ifdef CONFIG_PAX_SEGMEXEC
27915 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
27916 + pax_task_size = SEGMEXEC_TASK_SIZE;
27917 +#endif
27918 +
27919 + pax_task_size -= PAGE_SIZE;
27920 +
27921 + if (len > pax_task_size)
27922 return -ENOMEM;
27923
27924 if (flags & MAP_FIXED) {
27925 @@ -337,19 +361,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
27926 return addr;
27927 }
27928
27929 +#ifdef CONFIG_PAX_RANDMMAP
27930 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
27931 +#endif
27932 +
27933 if (addr) {
27934 addr = ALIGN(addr, huge_page_size(h));
27935 vma = find_vma(mm, addr);
27936 - if (TASK_SIZE - len >= addr &&
27937 - (!vma || addr + len <= vma->vm_start))
27938 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
27939 return addr;
27940 }
27941 if (mm->get_unmapped_area == arch_get_unmapped_area)
27942 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
27943 - pgoff, flags);
27944 + pgoff, flags, offset);
27945 else
27946 return hugetlb_get_unmapped_area_topdown(file, addr, len,
27947 - pgoff, flags);
27948 + pgoff, flags, offset);
27949 }
27950
27951 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
27952 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
27953 index 59b7fc4..b1dd75f 100644
27954 --- a/arch/x86/mm/init.c
27955 +++ b/arch/x86/mm/init.c
27956 @@ -4,6 +4,7 @@
27957 #include <linux/swap.h>
27958 #include <linux/memblock.h>
27959 #include <linux/bootmem.h> /* for max_low_pfn */
27960 +#include <linux/tboot.h>
27961
27962 #include <asm/cacheflush.h>
27963 #include <asm/e820.h>
27964 @@ -17,6 +18,8 @@
27965 #include <asm/proto.h>
27966 #include <asm/dma.h> /* for MAX_DMA_PFN */
27967 #include <asm/microcode.h>
27968 +#include <asm/desc.h>
27969 +#include <asm/bios_ebda.h>
27970
27971 #include "mm_internal.h"
27972
27973 @@ -464,10 +467,40 @@ void __init init_mem_mapping(void)
27974 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
27975 * mmio resources as well as potential bios/acpi data regions.
27976 */
27977 +
27978 +#ifdef CONFIG_GRKERNSEC_KMEM
27979 +static unsigned int ebda_start __read_only;
27980 +static unsigned int ebda_end __read_only;
27981 +#endif
27982 +
27983 int devmem_is_allowed(unsigned long pagenr)
27984 {
27985 - if (pagenr < 256)
27986 +#ifdef CONFIG_GRKERNSEC_KMEM
27987 + /* allow BDA */
27988 + if (!pagenr)
27989 return 1;
27990 + /* allow EBDA */
27991 + if (pagenr >= ebda_start && pagenr < ebda_end)
27992 + return 1;
27993 + /* if tboot is in use, allow access to its hardcoded serial log range */
27994 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
27995 + return 1;
27996 +#else
27997 + if (!pagenr)
27998 + return 1;
27999 +#ifdef CONFIG_VM86
28000 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28001 + return 1;
28002 +#endif
28003 +#endif
28004 +
28005 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28006 + return 1;
28007 +#ifdef CONFIG_GRKERNSEC_KMEM
28008 + /* throw out everything else below 1MB */
28009 + if (pagenr <= 256)
28010 + return 0;
28011 +#endif
28012 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28013 return 0;
28014 if (!page_is_ram(pagenr))
28015 @@ -524,8 +557,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28016 #endif
28017 }
28018
28019 +#ifdef CONFIG_GRKERNSEC_KMEM
28020 +static inline void gr_init_ebda(void)
28021 +{
28022 + unsigned int ebda_addr;
28023 + unsigned int ebda_size = 0;
28024 +
28025 + ebda_addr = get_bios_ebda();
28026 + if (ebda_addr) {
28027 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28028 + ebda_size <<= 10;
28029 + }
28030 + if (ebda_addr && ebda_size) {
28031 + ebda_start = ebda_addr >> PAGE_SHIFT;
28032 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28033 + } else {
28034 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28035 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28036 + }
28037 +}
28038 +#else
28039 +static inline void gr_init_ebda(void) { }
28040 +#endif
28041 +
28042 void free_initmem(void)
28043 {
28044 +#ifdef CONFIG_PAX_KERNEXEC
28045 +#ifdef CONFIG_X86_32
28046 + /* PaX: limit KERNEL_CS to actual size */
28047 + unsigned long addr, limit;
28048 + struct desc_struct d;
28049 + int cpu;
28050 +#else
28051 + pgd_t *pgd;
28052 + pud_t *pud;
28053 + pmd_t *pmd;
28054 + unsigned long addr, end;
28055 +#endif
28056 +#endif
28057 +
28058 + gr_init_ebda();
28059 +
28060 +#ifdef CONFIG_PAX_KERNEXEC
28061 +#ifdef CONFIG_X86_32
28062 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28063 + limit = (limit - 1UL) >> PAGE_SHIFT;
28064 +
28065 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28066 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28067 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28068 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28069 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28070 + }
28071 +
28072 + /* PaX: make KERNEL_CS read-only */
28073 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28074 + if (!paravirt_enabled())
28075 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28076 +/*
28077 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28078 + pgd = pgd_offset_k(addr);
28079 + pud = pud_offset(pgd, addr);
28080 + pmd = pmd_offset(pud, addr);
28081 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28082 + }
28083 +*/
28084 +#ifdef CONFIG_X86_PAE
28085 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28086 +/*
28087 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28088 + pgd = pgd_offset_k(addr);
28089 + pud = pud_offset(pgd, addr);
28090 + pmd = pmd_offset(pud, addr);
28091 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28092 + }
28093 +*/
28094 +#endif
28095 +
28096 +#ifdef CONFIG_MODULES
28097 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28098 +#endif
28099 +
28100 +#else
28101 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28102 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28103 + pgd = pgd_offset_k(addr);
28104 + pud = pud_offset(pgd, addr);
28105 + pmd = pmd_offset(pud, addr);
28106 + if (!pmd_present(*pmd))
28107 + continue;
28108 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28109 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28110 + else
28111 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28112 + }
28113 +
28114 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28115 + end = addr + KERNEL_IMAGE_SIZE;
28116 + for (; addr < end; addr += PMD_SIZE) {
28117 + pgd = pgd_offset_k(addr);
28118 + pud = pud_offset(pgd, addr);
28119 + pmd = pmd_offset(pud, addr);
28120 + if (!pmd_present(*pmd))
28121 + continue;
28122 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28123 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28124 + }
28125 +#endif
28126 +
28127 + flush_tlb_all();
28128 +#endif
28129 +
28130 free_init_pages("unused kernel memory",
28131 (unsigned long)(&__init_begin),
28132 (unsigned long)(&__init_end));
28133 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28134 index 2d19001..6a1046c 100644
28135 --- a/arch/x86/mm/init_32.c
28136 +++ b/arch/x86/mm/init_32.c
28137 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
28138 bool __read_mostly __vmalloc_start_set = false;
28139
28140 /*
28141 - * Creates a middle page table and puts a pointer to it in the
28142 - * given global directory entry. This only returns the gd entry
28143 - * in non-PAE compilation mode, since the middle layer is folded.
28144 - */
28145 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28146 -{
28147 - pud_t *pud;
28148 - pmd_t *pmd_table;
28149 -
28150 -#ifdef CONFIG_X86_PAE
28151 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28152 - pmd_table = (pmd_t *)alloc_low_page();
28153 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28154 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28155 - pud = pud_offset(pgd, 0);
28156 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28157 -
28158 - return pmd_table;
28159 - }
28160 -#endif
28161 - pud = pud_offset(pgd, 0);
28162 - pmd_table = pmd_offset(pud, 0);
28163 -
28164 - return pmd_table;
28165 -}
28166 -
28167 -/*
28168 * Create a page table and place a pointer to it in a middle page
28169 * directory entry:
28170 */
28171 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28172 pte_t *page_table = (pte_t *)alloc_low_page();
28173
28174 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28175 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28176 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28177 +#else
28178 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28179 +#endif
28180 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28181 }
28182
28183 return pte_offset_kernel(pmd, 0);
28184 }
28185
28186 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28187 +{
28188 + pud_t *pud;
28189 + pmd_t *pmd_table;
28190 +
28191 + pud = pud_offset(pgd, 0);
28192 + pmd_table = pmd_offset(pud, 0);
28193 +
28194 + return pmd_table;
28195 +}
28196 +
28197 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28198 {
28199 int pgd_idx = pgd_index(vaddr);
28200 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28201 int pgd_idx, pmd_idx;
28202 unsigned long vaddr;
28203 pgd_t *pgd;
28204 + pud_t *pud;
28205 pmd_t *pmd;
28206 pte_t *pte = NULL;
28207 unsigned long count = page_table_range_init_count(start, end);
28208 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28209 pgd = pgd_base + pgd_idx;
28210
28211 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28212 - pmd = one_md_table_init(pgd);
28213 - pmd = pmd + pmd_index(vaddr);
28214 + pud = pud_offset(pgd, vaddr);
28215 + pmd = pmd_offset(pud, vaddr);
28216 +
28217 +#ifdef CONFIG_X86_PAE
28218 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28219 +#endif
28220 +
28221 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28222 pmd++, pmd_idx++) {
28223 pte = page_table_kmap_check(one_page_table_init(pmd),
28224 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28225 }
28226 }
28227
28228 -static inline int is_kernel_text(unsigned long addr)
28229 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28230 {
28231 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28232 - return 1;
28233 - return 0;
28234 + if ((start > ktla_ktva((unsigned long)_etext) ||
28235 + end <= ktla_ktva((unsigned long)_stext)) &&
28236 + (start > ktla_ktva((unsigned long)_einittext) ||
28237 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28238 +
28239 +#ifdef CONFIG_ACPI_SLEEP
28240 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28241 +#endif
28242 +
28243 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28244 + return 0;
28245 + return 1;
28246 }
28247
28248 /*
28249 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
28250 unsigned long last_map_addr = end;
28251 unsigned long start_pfn, end_pfn;
28252 pgd_t *pgd_base = swapper_pg_dir;
28253 - int pgd_idx, pmd_idx, pte_ofs;
28254 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28255 unsigned long pfn;
28256 pgd_t *pgd;
28257 + pud_t *pud;
28258 pmd_t *pmd;
28259 pte_t *pte;
28260 unsigned pages_2m, pages_4k;
28261 @@ -291,8 +295,13 @@ repeat:
28262 pfn = start_pfn;
28263 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28264 pgd = pgd_base + pgd_idx;
28265 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28266 - pmd = one_md_table_init(pgd);
28267 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28268 + pud = pud_offset(pgd, 0);
28269 + pmd = pmd_offset(pud, 0);
28270 +
28271 +#ifdef CONFIG_X86_PAE
28272 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28273 +#endif
28274
28275 if (pfn >= end_pfn)
28276 continue;
28277 @@ -304,14 +313,13 @@ repeat:
28278 #endif
28279 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28280 pmd++, pmd_idx++) {
28281 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28282 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28283
28284 /*
28285 * Map with big pages if possible, otherwise
28286 * create normal page tables:
28287 */
28288 if (use_pse) {
28289 - unsigned int addr2;
28290 pgprot_t prot = PAGE_KERNEL_LARGE;
28291 /*
28292 * first pass will use the same initial
28293 @@ -322,11 +330,7 @@ repeat:
28294 _PAGE_PSE);
28295
28296 pfn &= PMD_MASK >> PAGE_SHIFT;
28297 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28298 - PAGE_OFFSET + PAGE_SIZE-1;
28299 -
28300 - if (is_kernel_text(addr) ||
28301 - is_kernel_text(addr2))
28302 + if (is_kernel_text(address, address + PMD_SIZE))
28303 prot = PAGE_KERNEL_LARGE_EXEC;
28304
28305 pages_2m++;
28306 @@ -343,7 +347,7 @@ repeat:
28307 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28308 pte += pte_ofs;
28309 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28310 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28311 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28312 pgprot_t prot = PAGE_KERNEL;
28313 /*
28314 * first pass will use the same initial
28315 @@ -351,7 +355,7 @@ repeat:
28316 */
28317 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28318
28319 - if (is_kernel_text(addr))
28320 + if (is_kernel_text(address, address + PAGE_SIZE))
28321 prot = PAGE_KERNEL_EXEC;
28322
28323 pages_4k++;
28324 @@ -482,7 +486,7 @@ void __init native_pagetable_init(void)
28325
28326 pud = pud_offset(pgd, va);
28327 pmd = pmd_offset(pud, va);
28328 - if (!pmd_present(*pmd))
28329 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
28330 break;
28331
28332 /* should not be large page here */
28333 @@ -540,12 +544,10 @@ void __init early_ioremap_page_table_range_init(void)
28334
28335 static void __init pagetable_init(void)
28336 {
28337 - pgd_t *pgd_base = swapper_pg_dir;
28338 -
28339 - permanent_kmaps_init(pgd_base);
28340 + permanent_kmaps_init(swapper_pg_dir);
28341 }
28342
28343 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28344 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28345 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28346
28347 /* user-defined highmem size */
28348 @@ -752,6 +754,12 @@ void __init mem_init(void)
28349
28350 pci_iommu_alloc();
28351
28352 +#ifdef CONFIG_PAX_PER_CPU_PGD
28353 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28354 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28355 + KERNEL_PGD_PTRS);
28356 +#endif
28357 +
28358 #ifdef CONFIG_FLATMEM
28359 BUG_ON(!mem_map);
28360 #endif
28361 @@ -780,7 +788,7 @@ void __init mem_init(void)
28362 after_bootmem = 1;
28363
28364 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28365 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28366 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28367 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28368
28369 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28370 @@ -821,10 +829,10 @@ void __init mem_init(void)
28371 ((unsigned long)&__init_end -
28372 (unsigned long)&__init_begin) >> 10,
28373
28374 - (unsigned long)&_etext, (unsigned long)&_edata,
28375 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28376 + (unsigned long)&_sdata, (unsigned long)&_edata,
28377 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28378
28379 - (unsigned long)&_text, (unsigned long)&_etext,
28380 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28381 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28382
28383 /*
28384 @@ -914,6 +922,7 @@ void set_kernel_text_rw(void)
28385 if (!kernel_set_to_readonly)
28386 return;
28387
28388 + start = ktla_ktva(start);
28389 pr_debug("Set kernel text: %lx - %lx for read write\n",
28390 start, start+size);
28391
28392 @@ -928,6 +937,7 @@ void set_kernel_text_ro(void)
28393 if (!kernel_set_to_readonly)
28394 return;
28395
28396 + start = ktla_ktva(start);
28397 pr_debug("Set kernel text: %lx - %lx for read only\n",
28398 start, start+size);
28399
28400 @@ -956,6 +966,7 @@ void mark_rodata_ro(void)
28401 unsigned long start = PFN_ALIGN(_text);
28402 unsigned long size = PFN_ALIGN(_etext) - start;
28403
28404 + start = ktla_ktva(start);
28405 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28406 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28407 size >> 10);
28408 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28409 index 474e28f..647dd12 100644
28410 --- a/arch/x86/mm/init_64.c
28411 +++ b/arch/x86/mm/init_64.c
28412 @@ -150,7 +150,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28413 * around without checking the pgd every time.
28414 */
28415
28416 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28417 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28418 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28419
28420 int force_personality32;
28421 @@ -183,12 +183,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28422
28423 for (address = start; address <= end; address += PGDIR_SIZE) {
28424 const pgd_t *pgd_ref = pgd_offset_k(address);
28425 +
28426 +#ifdef CONFIG_PAX_PER_CPU_PGD
28427 + unsigned long cpu;
28428 +#else
28429 struct page *page;
28430 +#endif
28431
28432 if (pgd_none(*pgd_ref))
28433 continue;
28434
28435 spin_lock(&pgd_lock);
28436 +
28437 +#ifdef CONFIG_PAX_PER_CPU_PGD
28438 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28439 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28440 +#else
28441 list_for_each_entry(page, &pgd_list, lru) {
28442 pgd_t *pgd;
28443 spinlock_t *pgt_lock;
28444 @@ -197,6 +207,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28445 /* the pgt_lock only for Xen */
28446 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28447 spin_lock(pgt_lock);
28448 +#endif
28449
28450 if (pgd_none(*pgd))
28451 set_pgd(pgd, *pgd_ref);
28452 @@ -204,7 +215,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28453 BUG_ON(pgd_page_vaddr(*pgd)
28454 != pgd_page_vaddr(*pgd_ref));
28455
28456 +#ifndef CONFIG_PAX_PER_CPU_PGD
28457 spin_unlock(pgt_lock);
28458 +#endif
28459 +
28460 }
28461 spin_unlock(&pgd_lock);
28462 }
28463 @@ -237,7 +251,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28464 {
28465 if (pgd_none(*pgd)) {
28466 pud_t *pud = (pud_t *)spp_getpage();
28467 - pgd_populate(&init_mm, pgd, pud);
28468 + pgd_populate_kernel(&init_mm, pgd, pud);
28469 if (pud != pud_offset(pgd, 0))
28470 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28471 pud, pud_offset(pgd, 0));
28472 @@ -249,7 +263,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28473 {
28474 if (pud_none(*pud)) {
28475 pmd_t *pmd = (pmd_t *) spp_getpage();
28476 - pud_populate(&init_mm, pud, pmd);
28477 + pud_populate_kernel(&init_mm, pud, pmd);
28478 if (pmd != pmd_offset(pud, 0))
28479 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28480 pmd, pmd_offset(pud, 0));
28481 @@ -278,7 +292,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28482 pmd = fill_pmd(pud, vaddr);
28483 pte = fill_pte(pmd, vaddr);
28484
28485 + pax_open_kernel();
28486 set_pte(pte, new_pte);
28487 + pax_close_kernel();
28488
28489 /*
28490 * It's enough to flush this one mapping.
28491 @@ -337,14 +353,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28492 pgd = pgd_offset_k((unsigned long)__va(phys));
28493 if (pgd_none(*pgd)) {
28494 pud = (pud_t *) spp_getpage();
28495 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28496 - _PAGE_USER));
28497 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28498 }
28499 pud = pud_offset(pgd, (unsigned long)__va(phys));
28500 if (pud_none(*pud)) {
28501 pmd = (pmd_t *) spp_getpage();
28502 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28503 - _PAGE_USER));
28504 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28505 }
28506 pmd = pmd_offset(pud, phys);
28507 BUG_ON(!pmd_none(*pmd));
28508 @@ -585,7 +599,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28509 prot);
28510
28511 spin_lock(&init_mm.page_table_lock);
28512 - pud_populate(&init_mm, pud, pmd);
28513 + pud_populate_kernel(&init_mm, pud, pmd);
28514 spin_unlock(&init_mm.page_table_lock);
28515 }
28516 __flush_tlb_all();
28517 @@ -626,7 +640,7 @@ kernel_physical_mapping_init(unsigned long start,
28518 page_size_mask);
28519
28520 spin_lock(&init_mm.page_table_lock);
28521 - pgd_populate(&init_mm, pgd, pud);
28522 + pgd_populate_kernel(&init_mm, pgd, pud);
28523 spin_unlock(&init_mm.page_table_lock);
28524 pgd_changed = true;
28525 }
28526 @@ -1065,6 +1079,12 @@ void __init mem_init(void)
28527
28528 pci_iommu_alloc();
28529
28530 +#ifdef CONFIG_PAX_PER_CPU_PGD
28531 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28532 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28533 + KERNEL_PGD_PTRS);
28534 +#endif
28535 +
28536 /* clear_bss() already clear the empty_zero_page */
28537
28538 reservedpages = 0;
28539 @@ -1224,8 +1244,8 @@ int kern_addr_valid(unsigned long addr)
28540 static struct vm_area_struct gate_vma = {
28541 .vm_start = VSYSCALL_START,
28542 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28543 - .vm_page_prot = PAGE_READONLY_EXEC,
28544 - .vm_flags = VM_READ | VM_EXEC
28545 + .vm_page_prot = PAGE_READONLY,
28546 + .vm_flags = VM_READ
28547 };
28548
28549 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28550 @@ -1259,7 +1279,7 @@ int in_gate_area_no_mm(unsigned long addr)
28551
28552 const char *arch_vma_name(struct vm_area_struct *vma)
28553 {
28554 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28555 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28556 return "[vdso]";
28557 if (vma == &gate_vma)
28558 return "[vsyscall]";
28559 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28560 index 7b179b4..6bd17777 100644
28561 --- a/arch/x86/mm/iomap_32.c
28562 +++ b/arch/x86/mm/iomap_32.c
28563 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
28564 type = kmap_atomic_idx_push();
28565 idx = type + KM_TYPE_NR * smp_processor_id();
28566 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28567 +
28568 + pax_open_kernel();
28569 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
28570 + pax_close_kernel();
28571 +
28572 arch_flush_lazy_mmu_mode();
28573
28574 return (void *)vaddr;
28575 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
28576 index 78fe3f1..73b95e2 100644
28577 --- a/arch/x86/mm/ioremap.c
28578 +++ b/arch/x86/mm/ioremap.c
28579 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
28580 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
28581 int is_ram = page_is_ram(pfn);
28582
28583 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
28584 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
28585 return NULL;
28586 WARN_ON_ONCE(is_ram);
28587 }
28588 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
28589 *
28590 * Caller must ensure there is only one unmapping for the same pointer.
28591 */
28592 -void iounmap(volatile void __iomem *addr)
28593 +void iounmap(const volatile void __iomem *addr)
28594 {
28595 struct vm_struct *p, *o;
28596
28597 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28598
28599 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
28600 if (page_is_ram(start >> PAGE_SHIFT))
28601 +#ifdef CONFIG_HIGHMEM
28602 + if ((start >> PAGE_SHIFT) < max_low_pfn)
28603 +#endif
28604 return __va(phys);
28605
28606 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
28607 @@ -327,6 +330,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28608 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
28609 {
28610 if (page_is_ram(phys >> PAGE_SHIFT))
28611 +#ifdef CONFIG_HIGHMEM
28612 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
28613 +#endif
28614 return;
28615
28616 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
28617 @@ -344,7 +350,7 @@ static int __init early_ioremap_debug_setup(char *str)
28618 early_param("early_ioremap_debug", early_ioremap_debug_setup);
28619
28620 static __initdata int after_paging_init;
28621 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
28622 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
28623
28624 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
28625 {
28626 @@ -381,8 +387,7 @@ void __init early_ioremap_init(void)
28627 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
28628
28629 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
28630 - memset(bm_pte, 0, sizeof(bm_pte));
28631 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
28632 + pmd_populate_user(&init_mm, pmd, bm_pte);
28633
28634 /*
28635 * The boot-ioremap range spans multiple pmds, for which
28636 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
28637 index d87dd6d..bf3fa66 100644
28638 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
28639 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
28640 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
28641 * memory (e.g. tracked pages)? For now, we need this to avoid
28642 * invoking kmemcheck for PnP BIOS calls.
28643 */
28644 - if (regs->flags & X86_VM_MASK)
28645 + if (v8086_mode(regs))
28646 return false;
28647 - if (regs->cs != __KERNEL_CS)
28648 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
28649 return false;
28650
28651 pte = kmemcheck_pte_lookup(address);
28652 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
28653 index 845df68..1d8d29f 100644
28654 --- a/arch/x86/mm/mmap.c
28655 +++ b/arch/x86/mm/mmap.c
28656 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
28657 * Leave an at least ~128 MB hole with possible stack randomization.
28658 */
28659 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
28660 -#define MAX_GAP (TASK_SIZE/6*5)
28661 +#define MAX_GAP (pax_task_size/6*5)
28662
28663 static int mmap_is_legacy(void)
28664 {
28665 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
28666 return rnd << PAGE_SHIFT;
28667 }
28668
28669 -static unsigned long mmap_base(void)
28670 +static unsigned long mmap_base(struct mm_struct *mm)
28671 {
28672 unsigned long gap = rlimit(RLIMIT_STACK);
28673 + unsigned long pax_task_size = TASK_SIZE;
28674 +
28675 +#ifdef CONFIG_PAX_SEGMEXEC
28676 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28677 + pax_task_size = SEGMEXEC_TASK_SIZE;
28678 +#endif
28679
28680 if (gap < MIN_GAP)
28681 gap = MIN_GAP;
28682 else if (gap > MAX_GAP)
28683 gap = MAX_GAP;
28684
28685 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
28686 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
28687 }
28688
28689 /*
28690 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
28691 * does, but not when emulating X86_32
28692 */
28693 -static unsigned long mmap_legacy_base(void)
28694 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
28695 {
28696 - if (mmap_is_ia32())
28697 + if (mmap_is_ia32()) {
28698 +
28699 +#ifdef CONFIG_PAX_SEGMEXEC
28700 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28701 + return SEGMEXEC_TASK_UNMAPPED_BASE;
28702 + else
28703 +#endif
28704 +
28705 return TASK_UNMAPPED_BASE;
28706 - else
28707 + } else
28708 return TASK_UNMAPPED_BASE + mmap_rnd();
28709 }
28710
28711 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
28712 void arch_pick_mmap_layout(struct mm_struct *mm)
28713 {
28714 if (mmap_is_legacy()) {
28715 - mm->mmap_base = mmap_legacy_base();
28716 + mm->mmap_base = mmap_legacy_base(mm);
28717 +
28718 +#ifdef CONFIG_PAX_RANDMMAP
28719 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28720 + mm->mmap_base += mm->delta_mmap;
28721 +#endif
28722 +
28723 mm->get_unmapped_area = arch_get_unmapped_area;
28724 mm->unmap_area = arch_unmap_area;
28725 } else {
28726 - mm->mmap_base = mmap_base();
28727 + mm->mmap_base = mmap_base(mm);
28728 +
28729 +#ifdef CONFIG_PAX_RANDMMAP
28730 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28731 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
28732 +#endif
28733 +
28734 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
28735 mm->unmap_area = arch_unmap_area_topdown;
28736 }
28737 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
28738 index dc0b727..f612039 100644
28739 --- a/arch/x86/mm/mmio-mod.c
28740 +++ b/arch/x86/mm/mmio-mod.c
28741 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
28742 break;
28743 default:
28744 {
28745 - unsigned char *ip = (unsigned char *)instptr;
28746 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
28747 my_trace->opcode = MMIO_UNKNOWN_OP;
28748 my_trace->width = 0;
28749 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
28750 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
28751 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28752 void __iomem *addr)
28753 {
28754 - static atomic_t next_id;
28755 + static atomic_unchecked_t next_id;
28756 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
28757 /* These are page-unaligned. */
28758 struct mmiotrace_map map = {
28759 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28760 .private = trace
28761 },
28762 .phys = offset,
28763 - .id = atomic_inc_return(&next_id)
28764 + .id = atomic_inc_return_unchecked(&next_id)
28765 };
28766 map.map_id = trace->id;
28767
28768 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
28769 ioremap_trace_core(offset, size, addr);
28770 }
28771
28772 -static void iounmap_trace_core(volatile void __iomem *addr)
28773 +static void iounmap_trace_core(const volatile void __iomem *addr)
28774 {
28775 struct mmiotrace_map map = {
28776 .phys = 0,
28777 @@ -328,7 +328,7 @@ not_enabled:
28778 }
28779 }
28780
28781 -void mmiotrace_iounmap(volatile void __iomem *addr)
28782 +void mmiotrace_iounmap(const volatile void __iomem *addr)
28783 {
28784 might_sleep();
28785 if (is_enabled()) /* recheck and proper locking in *_core() */
28786 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
28787 index 72fe01e..f1a8daa 100644
28788 --- a/arch/x86/mm/numa.c
28789 +++ b/arch/x86/mm/numa.c
28790 @@ -477,7 +477,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
28791 return true;
28792 }
28793
28794 -static int __init numa_register_memblks(struct numa_meminfo *mi)
28795 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
28796 {
28797 unsigned long uninitialized_var(pfn_align);
28798 int i, nid;
28799 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
28800 index 0e38951..4ca8458 100644
28801 --- a/arch/x86/mm/pageattr-test.c
28802 +++ b/arch/x86/mm/pageattr-test.c
28803 @@ -36,7 +36,7 @@ enum {
28804
28805 static int pte_testbit(pte_t pte)
28806 {
28807 - return pte_flags(pte) & _PAGE_UNUSED1;
28808 + return pte_flags(pte) & _PAGE_CPA_TEST;
28809 }
28810
28811 struct split_state {
28812 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
28813 index fb4e73e..43f7238 100644
28814 --- a/arch/x86/mm/pageattr.c
28815 +++ b/arch/x86/mm/pageattr.c
28816 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28817 */
28818 #ifdef CONFIG_PCI_BIOS
28819 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
28820 - pgprot_val(forbidden) |= _PAGE_NX;
28821 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28822 #endif
28823
28824 /*
28825 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28826 * Does not cover __inittext since that is gone later on. On
28827 * 64bit we do not enforce !NX on the low mapping
28828 */
28829 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
28830 - pgprot_val(forbidden) |= _PAGE_NX;
28831 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
28832 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28833
28834 +#ifdef CONFIG_DEBUG_RODATA
28835 /*
28836 * The .rodata section needs to be read-only. Using the pfn
28837 * catches all aliases.
28838 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28839 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
28840 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
28841 pgprot_val(forbidden) |= _PAGE_RW;
28842 +#endif
28843
28844 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
28845 /*
28846 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28847 }
28848 #endif
28849
28850 +#ifdef CONFIG_PAX_KERNEXEC
28851 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
28852 + pgprot_val(forbidden) |= _PAGE_RW;
28853 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28854 + }
28855 +#endif
28856 +
28857 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
28858
28859 return prot;
28860 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
28861 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
28862 {
28863 /* change init_mm */
28864 + pax_open_kernel();
28865 set_pte_atomic(kpte, pte);
28866 +
28867 #ifdef CONFIG_X86_32
28868 if (!SHARED_KERNEL_PMD) {
28869 +
28870 +#ifdef CONFIG_PAX_PER_CPU_PGD
28871 + unsigned long cpu;
28872 +#else
28873 struct page *page;
28874 +#endif
28875
28876 +#ifdef CONFIG_PAX_PER_CPU_PGD
28877 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28878 + pgd_t *pgd = get_cpu_pgd(cpu);
28879 +#else
28880 list_for_each_entry(page, &pgd_list, lru) {
28881 - pgd_t *pgd;
28882 + pgd_t *pgd = (pgd_t *)page_address(page);
28883 +#endif
28884 +
28885 pud_t *pud;
28886 pmd_t *pmd;
28887
28888 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
28889 + pgd += pgd_index(address);
28890 pud = pud_offset(pgd, address);
28891 pmd = pmd_offset(pud, address);
28892 set_pte_atomic((pte_t *)pmd, pte);
28893 }
28894 }
28895 #endif
28896 + pax_close_kernel();
28897 }
28898
28899 static int
28900 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
28901 index 6574388..87e9bef 100644
28902 --- a/arch/x86/mm/pat.c
28903 +++ b/arch/x86/mm/pat.c
28904 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
28905
28906 if (!entry) {
28907 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
28908 - current->comm, current->pid, start, end - 1);
28909 + current->comm, task_pid_nr(current), start, end - 1);
28910 return -EINVAL;
28911 }
28912
28913 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
28914
28915 while (cursor < to) {
28916 if (!devmem_is_allowed(pfn)) {
28917 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
28918 - current->comm, from, to - 1);
28919 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
28920 + current->comm, from, to - 1, cursor);
28921 return 0;
28922 }
28923 cursor += PAGE_SIZE;
28924 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
28925 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
28926 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
28927 "for [mem %#010Lx-%#010Lx]\n",
28928 - current->comm, current->pid,
28929 + current->comm, task_pid_nr(current),
28930 cattr_name(flags),
28931 base, (unsigned long long)(base + size-1));
28932 return -EINVAL;
28933 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
28934 flags = lookup_memtype(paddr);
28935 if (want_flags != flags) {
28936 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
28937 - current->comm, current->pid,
28938 + current->comm, task_pid_nr(current),
28939 cattr_name(want_flags),
28940 (unsigned long long)paddr,
28941 (unsigned long long)(paddr + size - 1),
28942 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
28943 free_memtype(paddr, paddr + size);
28944 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
28945 " for [mem %#010Lx-%#010Lx], got %s\n",
28946 - current->comm, current->pid,
28947 + current->comm, task_pid_nr(current),
28948 cattr_name(want_flags),
28949 (unsigned long long)paddr,
28950 (unsigned long long)(paddr + size - 1),
28951 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
28952 index 9f0614d..92ae64a 100644
28953 --- a/arch/x86/mm/pf_in.c
28954 +++ b/arch/x86/mm/pf_in.c
28955 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
28956 int i;
28957 enum reason_type rv = OTHERS;
28958
28959 - p = (unsigned char *)ins_addr;
28960 + p = (unsigned char *)ktla_ktva(ins_addr);
28961 p += skip_prefix(p, &prf);
28962 p += get_opcode(p, &opcode);
28963
28964 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
28965 struct prefix_bits prf;
28966 int i;
28967
28968 - p = (unsigned char *)ins_addr;
28969 + p = (unsigned char *)ktla_ktva(ins_addr);
28970 p += skip_prefix(p, &prf);
28971 p += get_opcode(p, &opcode);
28972
28973 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
28974 struct prefix_bits prf;
28975 int i;
28976
28977 - p = (unsigned char *)ins_addr;
28978 + p = (unsigned char *)ktla_ktva(ins_addr);
28979 p += skip_prefix(p, &prf);
28980 p += get_opcode(p, &opcode);
28981
28982 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
28983 struct prefix_bits prf;
28984 int i;
28985
28986 - p = (unsigned char *)ins_addr;
28987 + p = (unsigned char *)ktla_ktva(ins_addr);
28988 p += skip_prefix(p, &prf);
28989 p += get_opcode(p, &opcode);
28990 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
28991 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
28992 struct prefix_bits prf;
28993 int i;
28994
28995 - p = (unsigned char *)ins_addr;
28996 + p = (unsigned char *)ktla_ktva(ins_addr);
28997 p += skip_prefix(p, &prf);
28998 p += get_opcode(p, &opcode);
28999 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29000 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29001 index 17fda6a..489c74a 100644
29002 --- a/arch/x86/mm/pgtable.c
29003 +++ b/arch/x86/mm/pgtable.c
29004 @@ -91,10 +91,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29005 list_del(&page->lru);
29006 }
29007
29008 -#define UNSHARED_PTRS_PER_PGD \
29009 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29010 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29011 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29012
29013 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29014 +{
29015 + unsigned int count = USER_PGD_PTRS;
29016
29017 + while (count--)
29018 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29019 +}
29020 +#endif
29021 +
29022 +#ifdef CONFIG_PAX_PER_CPU_PGD
29023 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29024 +{
29025 + unsigned int count = USER_PGD_PTRS;
29026 +
29027 + while (count--) {
29028 + pgd_t pgd;
29029 +
29030 +#ifdef CONFIG_X86_64
29031 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29032 +#else
29033 + pgd = *src++;
29034 +#endif
29035 +
29036 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29037 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29038 +#endif
29039 +
29040 + *dst++ = pgd;
29041 + }
29042 +
29043 +}
29044 +#endif
29045 +
29046 +#ifdef CONFIG_X86_64
29047 +#define pxd_t pud_t
29048 +#define pyd_t pgd_t
29049 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29050 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29051 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29052 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29053 +#define PYD_SIZE PGDIR_SIZE
29054 +#else
29055 +#define pxd_t pmd_t
29056 +#define pyd_t pud_t
29057 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29058 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29059 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29060 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29061 +#define PYD_SIZE PUD_SIZE
29062 +#endif
29063 +
29064 +#ifdef CONFIG_PAX_PER_CPU_PGD
29065 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29066 +static inline void pgd_dtor(pgd_t *pgd) {}
29067 +#else
29068 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29069 {
29070 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29071 @@ -135,6 +189,7 @@ static void pgd_dtor(pgd_t *pgd)
29072 pgd_list_del(pgd);
29073 spin_unlock(&pgd_lock);
29074 }
29075 +#endif
29076
29077 /*
29078 * List of all pgd's needed for non-PAE so it can invalidate entries
29079 @@ -147,7 +202,7 @@ static void pgd_dtor(pgd_t *pgd)
29080 * -- nyc
29081 */
29082
29083 -#ifdef CONFIG_X86_PAE
29084 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29085 /*
29086 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29087 * updating the top-level pagetable entries to guarantee the
29088 @@ -159,7 +214,7 @@ static void pgd_dtor(pgd_t *pgd)
29089 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29090 * and initialize the kernel pmds here.
29091 */
29092 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29093 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29094
29095 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29096 {
29097 @@ -177,36 +232,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29098 */
29099 flush_tlb_mm(mm);
29100 }
29101 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29102 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29103 #else /* !CONFIG_X86_PAE */
29104
29105 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29106 -#define PREALLOCATED_PMDS 0
29107 +#define PREALLOCATED_PXDS 0
29108
29109 #endif /* CONFIG_X86_PAE */
29110
29111 -static void free_pmds(pmd_t *pmds[])
29112 +static void free_pxds(pxd_t *pxds[])
29113 {
29114 int i;
29115
29116 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29117 - if (pmds[i])
29118 - free_page((unsigned long)pmds[i]);
29119 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29120 + if (pxds[i])
29121 + free_page((unsigned long)pxds[i]);
29122 }
29123
29124 -static int preallocate_pmds(pmd_t *pmds[])
29125 +static int preallocate_pxds(pxd_t *pxds[])
29126 {
29127 int i;
29128 bool failed = false;
29129
29130 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29131 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29132 - if (pmd == NULL)
29133 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29134 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29135 + if (pxd == NULL)
29136 failed = true;
29137 - pmds[i] = pmd;
29138 + pxds[i] = pxd;
29139 }
29140
29141 if (failed) {
29142 - free_pmds(pmds);
29143 + free_pxds(pxds);
29144 return -ENOMEM;
29145 }
29146
29147 @@ -219,51 +276,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29148 * preallocate which never got a corresponding vma will need to be
29149 * freed manually.
29150 */
29151 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29152 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29153 {
29154 int i;
29155
29156 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29157 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29158 pgd_t pgd = pgdp[i];
29159
29160 if (pgd_val(pgd) != 0) {
29161 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29162 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29163
29164 - pgdp[i] = native_make_pgd(0);
29165 + set_pgd(pgdp + i, native_make_pgd(0));
29166
29167 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29168 - pmd_free(mm, pmd);
29169 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29170 + pxd_free(mm, pxd);
29171 }
29172 }
29173 }
29174
29175 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29176 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29177 {
29178 - pud_t *pud;
29179 + pyd_t *pyd;
29180 unsigned long addr;
29181 int i;
29182
29183 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29184 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29185 return;
29186
29187 - pud = pud_offset(pgd, 0);
29188 +#ifdef CONFIG_X86_64
29189 + pyd = pyd_offset(mm, 0L);
29190 +#else
29191 + pyd = pyd_offset(pgd, 0L);
29192 +#endif
29193
29194 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29195 - i++, pud++, addr += PUD_SIZE) {
29196 - pmd_t *pmd = pmds[i];
29197 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29198 + i++, pyd++, addr += PYD_SIZE) {
29199 + pxd_t *pxd = pxds[i];
29200
29201 if (i >= KERNEL_PGD_BOUNDARY)
29202 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29203 - sizeof(pmd_t) * PTRS_PER_PMD);
29204 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29205 + sizeof(pxd_t) * PTRS_PER_PMD);
29206
29207 - pud_populate(mm, pud, pmd);
29208 + pyd_populate(mm, pyd, pxd);
29209 }
29210 }
29211
29212 pgd_t *pgd_alloc(struct mm_struct *mm)
29213 {
29214 pgd_t *pgd;
29215 - pmd_t *pmds[PREALLOCATED_PMDS];
29216 + pxd_t *pxds[PREALLOCATED_PXDS];
29217
29218 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29219
29220 @@ -272,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29221
29222 mm->pgd = pgd;
29223
29224 - if (preallocate_pmds(pmds) != 0)
29225 + if (preallocate_pxds(pxds) != 0)
29226 goto out_free_pgd;
29227
29228 if (paravirt_pgd_alloc(mm) != 0)
29229 - goto out_free_pmds;
29230 + goto out_free_pxds;
29231
29232 /*
29233 * Make sure that pre-populating the pmds is atomic with
29234 @@ -286,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29235 spin_lock(&pgd_lock);
29236
29237 pgd_ctor(mm, pgd);
29238 - pgd_prepopulate_pmd(mm, pgd, pmds);
29239 + pgd_prepopulate_pxd(mm, pgd, pxds);
29240
29241 spin_unlock(&pgd_lock);
29242
29243 return pgd;
29244
29245 -out_free_pmds:
29246 - free_pmds(pmds);
29247 +out_free_pxds:
29248 + free_pxds(pxds);
29249 out_free_pgd:
29250 free_page((unsigned long)pgd);
29251 out:
29252 @@ -302,7 +363,7 @@ out:
29253
29254 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29255 {
29256 - pgd_mop_up_pmds(mm, pgd);
29257 + pgd_mop_up_pxds(mm, pgd);
29258 pgd_dtor(pgd);
29259 paravirt_pgd_free(mm, pgd);
29260 free_page((unsigned long)pgd);
29261 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29262 index a69bcb8..19068ab 100644
29263 --- a/arch/x86/mm/pgtable_32.c
29264 +++ b/arch/x86/mm/pgtable_32.c
29265 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29266 return;
29267 }
29268 pte = pte_offset_kernel(pmd, vaddr);
29269 +
29270 + pax_open_kernel();
29271 if (pte_val(pteval))
29272 set_pte_at(&init_mm, vaddr, pte, pteval);
29273 else
29274 pte_clear(&init_mm, vaddr, pte);
29275 + pax_close_kernel();
29276
29277 /*
29278 * It's enough to flush this one mapping.
29279 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29280 index e666cbb..61788c45 100644
29281 --- a/arch/x86/mm/physaddr.c
29282 +++ b/arch/x86/mm/physaddr.c
29283 @@ -10,7 +10,7 @@
29284 #ifdef CONFIG_X86_64
29285
29286 #ifdef CONFIG_DEBUG_VIRTUAL
29287 -unsigned long __phys_addr(unsigned long x)
29288 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29289 {
29290 unsigned long y = x - __START_KERNEL_map;
29291
29292 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29293 #else
29294
29295 #ifdef CONFIG_DEBUG_VIRTUAL
29296 -unsigned long __phys_addr(unsigned long x)
29297 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29298 {
29299 unsigned long phys_addr = x - PAGE_OFFSET;
29300 /* VMALLOC_* aren't constants */
29301 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29302 index 410531d..0f16030 100644
29303 --- a/arch/x86/mm/setup_nx.c
29304 +++ b/arch/x86/mm/setup_nx.c
29305 @@ -5,8 +5,10 @@
29306 #include <asm/pgtable.h>
29307 #include <asm/proto.h>
29308
29309 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29310 static int disable_nx __cpuinitdata;
29311
29312 +#ifndef CONFIG_PAX_PAGEEXEC
29313 /*
29314 * noexec = on|off
29315 *
29316 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29317 return 0;
29318 }
29319 early_param("noexec", noexec_setup);
29320 +#endif
29321 +
29322 +#endif
29323
29324 void __cpuinit x86_configure_nx(void)
29325 {
29326 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29327 if (cpu_has_nx && !disable_nx)
29328 __supported_pte_mask |= _PAGE_NX;
29329 else
29330 +#endif
29331 __supported_pte_mask &= ~_PAGE_NX;
29332 }
29333
29334 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29335 index 282375f..e03a98f 100644
29336 --- a/arch/x86/mm/tlb.c
29337 +++ b/arch/x86/mm/tlb.c
29338 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29339 BUG();
29340 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29341 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29342 +
29343 +#ifndef CONFIG_PAX_PER_CPU_PGD
29344 load_cr3(swapper_pg_dir);
29345 +#endif
29346 +
29347 }
29348 }
29349 EXPORT_SYMBOL_GPL(leave_mm);
29350 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29351 index 877b9a1..a8ecf42 100644
29352 --- a/arch/x86/net/bpf_jit.S
29353 +++ b/arch/x86/net/bpf_jit.S
29354 @@ -9,6 +9,7 @@
29355 */
29356 #include <linux/linkage.h>
29357 #include <asm/dwarf2.h>
29358 +#include <asm/alternative-asm.h>
29359
29360 /*
29361 * Calling convention :
29362 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29363 jle bpf_slow_path_word
29364 mov (SKBDATA,%rsi),%eax
29365 bswap %eax /* ntohl() */
29366 + pax_force_retaddr
29367 ret
29368
29369 sk_load_half:
29370 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29371 jle bpf_slow_path_half
29372 movzwl (SKBDATA,%rsi),%eax
29373 rol $8,%ax # ntohs()
29374 + pax_force_retaddr
29375 ret
29376
29377 sk_load_byte:
29378 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29379 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29380 jle bpf_slow_path_byte
29381 movzbl (SKBDATA,%rsi),%eax
29382 + pax_force_retaddr
29383 ret
29384
29385 /**
29386 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29387 movzbl (SKBDATA,%rsi),%ebx
29388 and $15,%bl
29389 shl $2,%bl
29390 + pax_force_retaddr
29391 ret
29392
29393 /* rsi contains offset and can be scratched */
29394 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29395 js bpf_error
29396 mov -12(%rbp),%eax
29397 bswap %eax
29398 + pax_force_retaddr
29399 ret
29400
29401 bpf_slow_path_half:
29402 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29403 mov -12(%rbp),%ax
29404 rol $8,%ax
29405 movzwl %ax,%eax
29406 + pax_force_retaddr
29407 ret
29408
29409 bpf_slow_path_byte:
29410 bpf_slow_path_common(1)
29411 js bpf_error
29412 movzbl -12(%rbp),%eax
29413 + pax_force_retaddr
29414 ret
29415
29416 bpf_slow_path_byte_msh:
29417 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29418 and $15,%al
29419 shl $2,%al
29420 xchg %eax,%ebx
29421 + pax_force_retaddr
29422 ret
29423
29424 #define sk_negative_common(SIZE) \
29425 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29426 sk_negative_common(4)
29427 mov (%rax), %eax
29428 bswap %eax
29429 + pax_force_retaddr
29430 ret
29431
29432 bpf_slow_path_half_neg:
29433 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29434 mov (%rax),%ax
29435 rol $8,%ax
29436 movzwl %ax,%eax
29437 + pax_force_retaddr
29438 ret
29439
29440 bpf_slow_path_byte_neg:
29441 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29442 .globl sk_load_byte_negative_offset
29443 sk_negative_common(1)
29444 movzbl (%rax), %eax
29445 + pax_force_retaddr
29446 ret
29447
29448 bpf_slow_path_byte_msh_neg:
29449 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29450 and $15,%al
29451 shl $2,%al
29452 xchg %eax,%ebx
29453 + pax_force_retaddr
29454 ret
29455
29456 bpf_error:
29457 @@ -197,4 +210,5 @@ bpf_error:
29458 xor %eax,%eax
29459 mov -8(%rbp),%rbx
29460 leaveq
29461 + pax_force_retaddr
29462 ret
29463 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29464 index 3cbe4538..fd756dc 100644
29465 --- a/arch/x86/net/bpf_jit_comp.c
29466 +++ b/arch/x86/net/bpf_jit_comp.c
29467 @@ -12,6 +12,7 @@
29468 #include <linux/netdevice.h>
29469 #include <linux/filter.h>
29470 #include <linux/if_vlan.h>
29471 +#include <linux/random.h>
29472
29473 /*
29474 * Conventions :
29475 @@ -49,13 +50,87 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29476 return ptr + len;
29477 }
29478
29479 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29480 +#define MAX_INSTR_CODE_SIZE 96
29481 +#else
29482 +#define MAX_INSTR_CODE_SIZE 64
29483 +#endif
29484 +
29485 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29486
29487 #define EMIT1(b1) EMIT(b1, 1)
29488 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29489 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29490 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29491 +
29492 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29493 +/* original constant will appear in ecx */
29494 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29495 +do { \
29496 + /* mov ecx, randkey */ \
29497 + EMIT1(0xb9); \
29498 + EMIT(_key, 4); \
29499 + /* xor ecx, randkey ^ off */ \
29500 + EMIT2(0x81, 0xf1); \
29501 + EMIT((_key) ^ (_off), 4); \
29502 +} while (0)
29503 +
29504 +#define EMIT1_off32(b1, _off) \
29505 +do { \
29506 + switch (b1) { \
29507 + case 0x05: /* add eax, imm32 */ \
29508 + case 0x2d: /* sub eax, imm32 */ \
29509 + case 0x25: /* and eax, imm32 */ \
29510 + case 0x0d: /* or eax, imm32 */ \
29511 + case 0xb8: /* mov eax, imm32 */ \
29512 + case 0x3d: /* cmp eax, imm32 */ \
29513 + case 0xa9: /* test eax, imm32 */ \
29514 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29515 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29516 + break; \
29517 + case 0xbb: /* mov ebx, imm32 */ \
29518 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29519 + /* mov ebx, ecx */ \
29520 + EMIT2(0x89, 0xcb); \
29521 + break; \
29522 + case 0xbe: /* mov esi, imm32 */ \
29523 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29524 + /* mov esi, ecx */ \
29525 + EMIT2(0x89, 0xce); \
29526 + break; \
29527 + case 0xe9: /* jmp rel imm32 */ \
29528 + EMIT1(b1); \
29529 + EMIT(_off, 4); \
29530 + /* prevent fall-through, we're not called if off = 0 */ \
29531 + EMIT(0xcccccccc, 4); \
29532 + EMIT(0xcccccccc, 4); \
29533 + break; \
29534 + default: \
29535 + EMIT1(b1); \
29536 + EMIT(_off, 4); \
29537 + } \
29538 +} while (0)
29539 +
29540 +#define EMIT2_off32(b1, b2, _off) \
29541 +do { \
29542 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29543 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29544 + EMIT(randkey, 4); \
29545 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29546 + EMIT((_off) - randkey, 4); \
29547 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29548 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29549 + /* imul eax, ecx */ \
29550 + EMIT3(0x0f, 0xaf, 0xc1); \
29551 + } else { \
29552 + EMIT2(b1, b2); \
29553 + EMIT(_off, 4); \
29554 + } \
29555 +} while (0)
29556 +#else
29557 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
29558 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
29559 +#endif
29560
29561 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
29562 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
29563 @@ -90,6 +165,24 @@ do { \
29564 #define X86_JBE 0x76
29565 #define X86_JA 0x77
29566
29567 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29568 +#define APPEND_FLOW_VERIFY() \
29569 +do { \
29570 + /* mov ecx, randkey */ \
29571 + EMIT1(0xb9); \
29572 + EMIT(randkey, 4); \
29573 + /* cmp ecx, randkey */ \
29574 + EMIT2(0x81, 0xf9); \
29575 + EMIT(randkey, 4); \
29576 + /* jz after 8 int 3s */ \
29577 + EMIT2(0x74, 0x08); \
29578 + EMIT(0xcccccccc, 4); \
29579 + EMIT(0xcccccccc, 4); \
29580 +} while (0)
29581 +#else
29582 +#define APPEND_FLOW_VERIFY() do { } while (0)
29583 +#endif
29584 +
29585 #define EMIT_COND_JMP(op, offset) \
29586 do { \
29587 if (is_near(offset)) \
29588 @@ -97,6 +190,7 @@ do { \
29589 else { \
29590 EMIT2(0x0f, op + 0x10); \
29591 EMIT(offset, 4); /* jxx .+off32 */ \
29592 + APPEND_FLOW_VERIFY(); \
29593 } \
29594 } while (0)
29595
29596 @@ -121,6 +215,11 @@ static inline void bpf_flush_icache(void *start, void *end)
29597 set_fs(old_fs);
29598 }
29599
29600 +struct bpf_jit_work {
29601 + struct work_struct work;
29602 + void *image;
29603 +};
29604 +
29605 #define CHOOSE_LOAD_FUNC(K, func) \
29606 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
29607
29608 @@ -146,7 +245,7 @@ static int pkt_type_offset(void)
29609
29610 void bpf_jit_compile(struct sk_filter *fp)
29611 {
29612 - u8 temp[64];
29613 + u8 temp[MAX_INSTR_CODE_SIZE];
29614 u8 *prog;
29615 unsigned int proglen, oldproglen = 0;
29616 int ilen, i;
29617 @@ -159,6 +258,9 @@ void bpf_jit_compile(struct sk_filter *fp)
29618 unsigned int *addrs;
29619 const struct sock_filter *filter = fp->insns;
29620 int flen = fp->len;
29621 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29622 + unsigned int randkey;
29623 +#endif
29624
29625 if (!bpf_jit_enable)
29626 return;
29627 @@ -167,11 +269,19 @@ void bpf_jit_compile(struct sk_filter *fp)
29628 if (addrs == NULL)
29629 return;
29630
29631 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
29632 + if (!fp->work)
29633 + goto out;
29634 +
29635 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29636 + randkey = get_random_int();
29637 +#endif
29638 +
29639 /* Before first pass, make a rough estimation of addrs[]
29640 - * each bpf instruction is translated to less than 64 bytes
29641 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
29642 */
29643 for (proglen = 0, i = 0; i < flen; i++) {
29644 - proglen += 64;
29645 + proglen += MAX_INSTR_CODE_SIZE;
29646 addrs[i] = proglen;
29647 }
29648 cleanup_addr = proglen; /* epilogue address */
29649 @@ -282,10 +392,8 @@ void bpf_jit_compile(struct sk_filter *fp)
29650 case BPF_S_ALU_MUL_K: /* A *= K */
29651 if (is_imm8(K))
29652 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
29653 - else {
29654 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
29655 - EMIT(K, 4);
29656 - }
29657 + else
29658 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
29659 break;
29660 case BPF_S_ALU_DIV_X: /* A /= X; */
29661 seen |= SEEN_XREG;
29662 @@ -325,13 +433,23 @@ void bpf_jit_compile(struct sk_filter *fp)
29663 break;
29664 case BPF_S_ALU_MOD_K: /* A %= K; */
29665 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
29666 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29667 + DILUTE_CONST_SEQUENCE(K, randkey);
29668 +#else
29669 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
29670 +#endif
29671 EMIT2(0xf7, 0xf1); /* div %ecx */
29672 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
29673 break;
29674 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
29675 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29676 + DILUTE_CONST_SEQUENCE(K, randkey);
29677 + // imul rax, rcx
29678 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
29679 +#else
29680 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
29681 EMIT(K, 4);
29682 +#endif
29683 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
29684 break;
29685 case BPF_S_ALU_AND_X:
29686 @@ -602,8 +720,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
29687 if (is_imm8(K)) {
29688 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
29689 } else {
29690 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
29691 - EMIT(K, 4);
29692 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
29693 }
29694 } else {
29695 EMIT2(0x89,0xde); /* mov %ebx,%esi */
29696 @@ -686,17 +803,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29697 break;
29698 default:
29699 /* hmm, too complex filter, give up with jit compiler */
29700 - goto out;
29701 + goto error;
29702 }
29703 ilen = prog - temp;
29704 if (image) {
29705 if (unlikely(proglen + ilen > oldproglen)) {
29706 pr_err("bpb_jit_compile fatal error\n");
29707 - kfree(addrs);
29708 - module_free(NULL, image);
29709 - return;
29710 + module_free_exec(NULL, image);
29711 + goto error;
29712 }
29713 + pax_open_kernel();
29714 memcpy(image + proglen, temp, ilen);
29715 + pax_close_kernel();
29716 }
29717 proglen += ilen;
29718 addrs[i] = proglen;
29719 @@ -717,11 +835,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29720 break;
29721 }
29722 if (proglen == oldproglen) {
29723 - image = module_alloc(max_t(unsigned int,
29724 - proglen,
29725 - sizeof(struct work_struct)));
29726 + image = module_alloc_exec(proglen);
29727 if (!image)
29728 - goto out;
29729 + goto error;
29730 }
29731 oldproglen = proglen;
29732 }
29733 @@ -737,7 +853,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29734 bpf_flush_icache(image, image + proglen);
29735
29736 fp->bpf_func = (void *)image;
29737 - }
29738 + } else
29739 +error:
29740 + kfree(fp->work);
29741 +
29742 out:
29743 kfree(addrs);
29744 return;
29745 @@ -745,18 +864,20 @@ out:
29746
29747 static void jit_free_defer(struct work_struct *arg)
29748 {
29749 - module_free(NULL, arg);
29750 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
29751 + kfree(arg);
29752 }
29753
29754 /* run from softirq, we must use a work_struct to call
29755 - * module_free() from process context
29756 + * module_free_exec() from process context
29757 */
29758 void bpf_jit_free(struct sk_filter *fp)
29759 {
29760 if (fp->bpf_func != sk_run_filter) {
29761 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
29762 + struct work_struct *work = &fp->work->work;
29763
29764 INIT_WORK(work, jit_free_defer);
29765 + fp->work->image = fp->bpf_func;
29766 schedule_work(work);
29767 }
29768 }
29769 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
29770 index d6aa6e8..266395a 100644
29771 --- a/arch/x86/oprofile/backtrace.c
29772 +++ b/arch/x86/oprofile/backtrace.c
29773 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
29774 struct stack_frame_ia32 *fp;
29775 unsigned long bytes;
29776
29777 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29778 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29779 if (bytes != sizeof(bufhead))
29780 return NULL;
29781
29782 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
29783 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
29784
29785 oprofile_add_trace(bufhead[0].return_address);
29786
29787 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
29788 struct stack_frame bufhead[2];
29789 unsigned long bytes;
29790
29791 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29792 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29793 if (bytes != sizeof(bufhead))
29794 return NULL;
29795
29796 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
29797 {
29798 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
29799
29800 - if (!user_mode_vm(regs)) {
29801 + if (!user_mode(regs)) {
29802 unsigned long stack = kernel_stack_pointer(regs);
29803 if (depth)
29804 dump_trace(NULL, regs, (unsigned long *)stack, 0,
29805 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
29806 index 48768df..ba9143c 100644
29807 --- a/arch/x86/oprofile/nmi_int.c
29808 +++ b/arch/x86/oprofile/nmi_int.c
29809 @@ -23,6 +23,7 @@
29810 #include <asm/nmi.h>
29811 #include <asm/msr.h>
29812 #include <asm/apic.h>
29813 +#include <asm/pgtable.h>
29814
29815 #include "op_counter.h"
29816 #include "op_x86_model.h"
29817 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
29818 if (ret)
29819 return ret;
29820
29821 - if (!model->num_virt_counters)
29822 - model->num_virt_counters = model->num_counters;
29823 + if (!model->num_virt_counters) {
29824 + pax_open_kernel();
29825 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
29826 + pax_close_kernel();
29827 + }
29828
29829 mux_init(ops);
29830
29831 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
29832 index b2b9443..be58856 100644
29833 --- a/arch/x86/oprofile/op_model_amd.c
29834 +++ b/arch/x86/oprofile/op_model_amd.c
29835 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
29836 num_counters = AMD64_NUM_COUNTERS;
29837 }
29838
29839 - op_amd_spec.num_counters = num_counters;
29840 - op_amd_spec.num_controls = num_counters;
29841 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29842 + pax_open_kernel();
29843 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
29844 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
29845 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29846 + pax_close_kernel();
29847
29848 return 0;
29849 }
29850 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
29851 index d90528e..0127e2b 100644
29852 --- a/arch/x86/oprofile/op_model_ppro.c
29853 +++ b/arch/x86/oprofile/op_model_ppro.c
29854 @@ -19,6 +19,7 @@
29855 #include <asm/msr.h>
29856 #include <asm/apic.h>
29857 #include <asm/nmi.h>
29858 +#include <asm/pgtable.h>
29859
29860 #include "op_x86_model.h"
29861 #include "op_counter.h"
29862 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
29863
29864 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
29865
29866 - op_arch_perfmon_spec.num_counters = num_counters;
29867 - op_arch_perfmon_spec.num_controls = num_counters;
29868 + pax_open_kernel();
29869 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
29870 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
29871 + pax_close_kernel();
29872 }
29873
29874 static int arch_perfmon_init(struct oprofile_operations *ignore)
29875 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
29876 index 71e8a67..6a313bb 100644
29877 --- a/arch/x86/oprofile/op_x86_model.h
29878 +++ b/arch/x86/oprofile/op_x86_model.h
29879 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
29880 void (*switch_ctrl)(struct op_x86_model_spec const *model,
29881 struct op_msrs const * const msrs);
29882 #endif
29883 -};
29884 +} __do_const;
29885
29886 struct op_counter_config;
29887
29888 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
29889 index e9e6ed5..e47ae67 100644
29890 --- a/arch/x86/pci/amd_bus.c
29891 +++ b/arch/x86/pci/amd_bus.c
29892 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
29893 return NOTIFY_OK;
29894 }
29895
29896 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
29897 +static struct notifier_block amd_cpu_notifier = {
29898 .notifier_call = amd_cpu_notify,
29899 };
29900
29901 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
29902 index 372e9b8..e775a6c 100644
29903 --- a/arch/x86/pci/irq.c
29904 +++ b/arch/x86/pci/irq.c
29905 @@ -50,7 +50,7 @@ struct irq_router {
29906 struct irq_router_handler {
29907 u16 vendor;
29908 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
29909 -};
29910 +} __do_const;
29911
29912 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
29913 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
29914 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
29915 return 0;
29916 }
29917
29918 -static __initdata struct irq_router_handler pirq_routers[] = {
29919 +static __initconst const struct irq_router_handler pirq_routers[] = {
29920 { PCI_VENDOR_ID_INTEL, intel_router_probe },
29921 { PCI_VENDOR_ID_AL, ali_router_probe },
29922 { PCI_VENDOR_ID_ITE, ite_router_probe },
29923 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
29924 static void __init pirq_find_router(struct irq_router *r)
29925 {
29926 struct irq_routing_table *rt = pirq_table;
29927 - struct irq_router_handler *h;
29928 + const struct irq_router_handler *h;
29929
29930 #ifdef CONFIG_PCI_BIOS
29931 if (!rt->signature) {
29932 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
29933 return 0;
29934 }
29935
29936 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
29937 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
29938 {
29939 .callback = fix_broken_hp_bios_irq9,
29940 .ident = "HP Pavilion N5400 Series Laptop",
29941 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
29942 index 6eb18c4..20d83de 100644
29943 --- a/arch/x86/pci/mrst.c
29944 +++ b/arch/x86/pci/mrst.c
29945 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
29946 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
29947 pci_mmcfg_late_init();
29948 pcibios_enable_irq = mrst_pci_irq_enable;
29949 - pci_root_ops = pci_mrst_ops;
29950 + pax_open_kernel();
29951 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
29952 + pax_close_kernel();
29953 pci_soc_mode = 1;
29954 /* Continue with standard init */
29955 return 1;
29956 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
29957 index c77b24a..c979855 100644
29958 --- a/arch/x86/pci/pcbios.c
29959 +++ b/arch/x86/pci/pcbios.c
29960 @@ -79,7 +79,7 @@ union bios32 {
29961 static struct {
29962 unsigned long address;
29963 unsigned short segment;
29964 -} bios32_indirect = { 0, __KERNEL_CS };
29965 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
29966
29967 /*
29968 * Returns the entry point for the given service, NULL on error
29969 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
29970 unsigned long length; /* %ecx */
29971 unsigned long entry; /* %edx */
29972 unsigned long flags;
29973 + struct desc_struct d, *gdt;
29974
29975 local_irq_save(flags);
29976 - __asm__("lcall *(%%edi); cld"
29977 +
29978 + gdt = get_cpu_gdt_table(smp_processor_id());
29979 +
29980 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
29981 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
29982 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
29983 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
29984 +
29985 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
29986 : "=a" (return_code),
29987 "=b" (address),
29988 "=c" (length),
29989 "=d" (entry)
29990 : "0" (service),
29991 "1" (0),
29992 - "D" (&bios32_indirect));
29993 + "D" (&bios32_indirect),
29994 + "r"(__PCIBIOS_DS)
29995 + : "memory");
29996 +
29997 + pax_open_kernel();
29998 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
29999 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30000 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30001 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30002 + pax_close_kernel();
30003 +
30004 local_irq_restore(flags);
30005
30006 switch (return_code) {
30007 - case 0:
30008 - return address + entry;
30009 - case 0x80: /* Not present */
30010 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30011 - return 0;
30012 - default: /* Shouldn't happen */
30013 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30014 - service, return_code);
30015 + case 0: {
30016 + int cpu;
30017 + unsigned char flags;
30018 +
30019 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30020 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30021 + printk(KERN_WARNING "bios32_service: not valid\n");
30022 return 0;
30023 + }
30024 + address = address + PAGE_OFFSET;
30025 + length += 16UL; /* some BIOSs underreport this... */
30026 + flags = 4;
30027 + if (length >= 64*1024*1024) {
30028 + length >>= PAGE_SHIFT;
30029 + flags |= 8;
30030 + }
30031 +
30032 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30033 + gdt = get_cpu_gdt_table(cpu);
30034 + pack_descriptor(&d, address, length, 0x9b, flags);
30035 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30036 + pack_descriptor(&d, address, length, 0x93, flags);
30037 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30038 + }
30039 + return entry;
30040 + }
30041 + case 0x80: /* Not present */
30042 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30043 + return 0;
30044 + default: /* Shouldn't happen */
30045 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30046 + service, return_code);
30047 + return 0;
30048 }
30049 }
30050
30051 static struct {
30052 unsigned long address;
30053 unsigned short segment;
30054 -} pci_indirect = { 0, __KERNEL_CS };
30055 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30056
30057 -static int pci_bios_present;
30058 +static int pci_bios_present __read_only;
30059
30060 static int check_pcibios(void)
30061 {
30062 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30063 unsigned long flags, pcibios_entry;
30064
30065 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30066 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30067 + pci_indirect.address = pcibios_entry;
30068
30069 local_irq_save(flags);
30070 - __asm__(
30071 - "lcall *(%%edi); cld\n\t"
30072 + __asm__("movw %w6, %%ds\n\t"
30073 + "lcall *%%ss:(%%edi); cld\n\t"
30074 + "push %%ss\n\t"
30075 + "pop %%ds\n\t"
30076 "jc 1f\n\t"
30077 "xor %%ah, %%ah\n"
30078 "1:"
30079 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30080 "=b" (ebx),
30081 "=c" (ecx)
30082 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30083 - "D" (&pci_indirect)
30084 + "D" (&pci_indirect),
30085 + "r" (__PCIBIOS_DS)
30086 : "memory");
30087 local_irq_restore(flags);
30088
30089 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30090
30091 switch (len) {
30092 case 1:
30093 - __asm__("lcall *(%%esi); cld\n\t"
30094 + __asm__("movw %w6, %%ds\n\t"
30095 + "lcall *%%ss:(%%esi); cld\n\t"
30096 + "push %%ss\n\t"
30097 + "pop %%ds\n\t"
30098 "jc 1f\n\t"
30099 "xor %%ah, %%ah\n"
30100 "1:"
30101 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30102 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30103 "b" (bx),
30104 "D" ((long)reg),
30105 - "S" (&pci_indirect));
30106 + "S" (&pci_indirect),
30107 + "r" (__PCIBIOS_DS));
30108 /*
30109 * Zero-extend the result beyond 8 bits, do not trust the
30110 * BIOS having done it:
30111 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30112 *value &= 0xff;
30113 break;
30114 case 2:
30115 - __asm__("lcall *(%%esi); cld\n\t"
30116 + __asm__("movw %w6, %%ds\n\t"
30117 + "lcall *%%ss:(%%esi); cld\n\t"
30118 + "push %%ss\n\t"
30119 + "pop %%ds\n\t"
30120 "jc 1f\n\t"
30121 "xor %%ah, %%ah\n"
30122 "1:"
30123 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30124 : "1" (PCIBIOS_READ_CONFIG_WORD),
30125 "b" (bx),
30126 "D" ((long)reg),
30127 - "S" (&pci_indirect));
30128 + "S" (&pci_indirect),
30129 + "r" (__PCIBIOS_DS));
30130 /*
30131 * Zero-extend the result beyond 16 bits, do not trust the
30132 * BIOS having done it:
30133 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30134 *value &= 0xffff;
30135 break;
30136 case 4:
30137 - __asm__("lcall *(%%esi); cld\n\t"
30138 + __asm__("movw %w6, %%ds\n\t"
30139 + "lcall *%%ss:(%%esi); cld\n\t"
30140 + "push %%ss\n\t"
30141 + "pop %%ds\n\t"
30142 "jc 1f\n\t"
30143 "xor %%ah, %%ah\n"
30144 "1:"
30145 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30146 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30147 "b" (bx),
30148 "D" ((long)reg),
30149 - "S" (&pci_indirect));
30150 + "S" (&pci_indirect),
30151 + "r" (__PCIBIOS_DS));
30152 break;
30153 }
30154
30155 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30156
30157 switch (len) {
30158 case 1:
30159 - __asm__("lcall *(%%esi); cld\n\t"
30160 + __asm__("movw %w6, %%ds\n\t"
30161 + "lcall *%%ss:(%%esi); cld\n\t"
30162 + "push %%ss\n\t"
30163 + "pop %%ds\n\t"
30164 "jc 1f\n\t"
30165 "xor %%ah, %%ah\n"
30166 "1:"
30167 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30168 "c" (value),
30169 "b" (bx),
30170 "D" ((long)reg),
30171 - "S" (&pci_indirect));
30172 + "S" (&pci_indirect),
30173 + "r" (__PCIBIOS_DS));
30174 break;
30175 case 2:
30176 - __asm__("lcall *(%%esi); cld\n\t"
30177 + __asm__("movw %w6, %%ds\n\t"
30178 + "lcall *%%ss:(%%esi); cld\n\t"
30179 + "push %%ss\n\t"
30180 + "pop %%ds\n\t"
30181 "jc 1f\n\t"
30182 "xor %%ah, %%ah\n"
30183 "1:"
30184 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30185 "c" (value),
30186 "b" (bx),
30187 "D" ((long)reg),
30188 - "S" (&pci_indirect));
30189 + "S" (&pci_indirect),
30190 + "r" (__PCIBIOS_DS));
30191 break;
30192 case 4:
30193 - __asm__("lcall *(%%esi); cld\n\t"
30194 + __asm__("movw %w6, %%ds\n\t"
30195 + "lcall *%%ss:(%%esi); cld\n\t"
30196 + "push %%ss\n\t"
30197 + "pop %%ds\n\t"
30198 "jc 1f\n\t"
30199 "xor %%ah, %%ah\n"
30200 "1:"
30201 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30202 "c" (value),
30203 "b" (bx),
30204 "D" ((long)reg),
30205 - "S" (&pci_indirect));
30206 + "S" (&pci_indirect),
30207 + "r" (__PCIBIOS_DS));
30208 break;
30209 }
30210
30211 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30212
30213 DBG("PCI: Fetching IRQ routing table... ");
30214 __asm__("push %%es\n\t"
30215 + "movw %w8, %%ds\n\t"
30216 "push %%ds\n\t"
30217 "pop %%es\n\t"
30218 - "lcall *(%%esi); cld\n\t"
30219 + "lcall *%%ss:(%%esi); cld\n\t"
30220 "pop %%es\n\t"
30221 + "push %%ss\n\t"
30222 + "pop %%ds\n"
30223 "jc 1f\n\t"
30224 "xor %%ah, %%ah\n"
30225 "1:"
30226 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30227 "1" (0),
30228 "D" ((long) &opt),
30229 "S" (&pci_indirect),
30230 - "m" (opt)
30231 + "m" (opt),
30232 + "r" (__PCIBIOS_DS)
30233 : "memory");
30234 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30235 if (ret & 0xff00)
30236 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30237 {
30238 int ret;
30239
30240 - __asm__("lcall *(%%esi); cld\n\t"
30241 + __asm__("movw %w5, %%ds\n\t"
30242 + "lcall *%%ss:(%%esi); cld\n\t"
30243 + "push %%ss\n\t"
30244 + "pop %%ds\n"
30245 "jc 1f\n\t"
30246 "xor %%ah, %%ah\n"
30247 "1:"
30248 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30249 : "0" (PCIBIOS_SET_PCI_HW_INT),
30250 "b" ((dev->bus->number << 8) | dev->devfn),
30251 "c" ((irq << 8) | (pin + 10)),
30252 - "S" (&pci_indirect));
30253 + "S" (&pci_indirect),
30254 + "r" (__PCIBIOS_DS));
30255 return !(ret & 0xff00);
30256 }
30257 EXPORT_SYMBOL(pcibios_set_irq_routing);
30258 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30259 index 40e4469..1ab536e 100644
30260 --- a/arch/x86/platform/efi/efi_32.c
30261 +++ b/arch/x86/platform/efi/efi_32.c
30262 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30263 {
30264 struct desc_ptr gdt_descr;
30265
30266 +#ifdef CONFIG_PAX_KERNEXEC
30267 + struct desc_struct d;
30268 +#endif
30269 +
30270 local_irq_save(efi_rt_eflags);
30271
30272 load_cr3(initial_page_table);
30273 __flush_tlb_all();
30274
30275 +#ifdef CONFIG_PAX_KERNEXEC
30276 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30277 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30278 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30279 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30280 +#endif
30281 +
30282 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30283 gdt_descr.size = GDT_SIZE - 1;
30284 load_gdt(&gdt_descr);
30285 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
30286 {
30287 struct desc_ptr gdt_descr;
30288
30289 +#ifdef CONFIG_PAX_KERNEXEC
30290 + struct desc_struct d;
30291 +
30292 + memset(&d, 0, sizeof d);
30293 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30294 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30295 +#endif
30296 +
30297 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30298 gdt_descr.size = GDT_SIZE - 1;
30299 load_gdt(&gdt_descr);
30300 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30301 index fbe66e6..eae5e38 100644
30302 --- a/arch/x86/platform/efi/efi_stub_32.S
30303 +++ b/arch/x86/platform/efi/efi_stub_32.S
30304 @@ -6,7 +6,9 @@
30305 */
30306
30307 #include <linux/linkage.h>
30308 +#include <linux/init.h>
30309 #include <asm/page_types.h>
30310 +#include <asm/segment.h>
30311
30312 /*
30313 * efi_call_phys(void *, ...) is a function with variable parameters.
30314 @@ -20,7 +22,7 @@
30315 * service functions will comply with gcc calling convention, too.
30316 */
30317
30318 -.text
30319 +__INIT
30320 ENTRY(efi_call_phys)
30321 /*
30322 * 0. The function can only be called in Linux kernel. So CS has been
30323 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30324 * The mapping of lower virtual memory has been created in prelog and
30325 * epilog.
30326 */
30327 - movl $1f, %edx
30328 - subl $__PAGE_OFFSET, %edx
30329 - jmp *%edx
30330 +#ifdef CONFIG_PAX_KERNEXEC
30331 + movl $(__KERNEXEC_EFI_DS), %edx
30332 + mov %edx, %ds
30333 + mov %edx, %es
30334 + mov %edx, %ss
30335 + addl $2f,(1f)
30336 + ljmp *(1f)
30337 +
30338 +__INITDATA
30339 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30340 +.previous
30341 +
30342 +2:
30343 + subl $2b,(1b)
30344 +#else
30345 + jmp 1f-__PAGE_OFFSET
30346 1:
30347 +#endif
30348
30349 /*
30350 * 2. Now on the top of stack is the return
30351 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30352 * parameter 2, ..., param n. To make things easy, we save the return
30353 * address of efi_call_phys in a global variable.
30354 */
30355 - popl %edx
30356 - movl %edx, saved_return_addr
30357 - /* get the function pointer into ECX*/
30358 - popl %ecx
30359 - movl %ecx, efi_rt_function_ptr
30360 - movl $2f, %edx
30361 - subl $__PAGE_OFFSET, %edx
30362 - pushl %edx
30363 + popl (saved_return_addr)
30364 + popl (efi_rt_function_ptr)
30365
30366 /*
30367 * 3. Clear PG bit in %CR0.
30368 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30369 /*
30370 * 5. Call the physical function.
30371 */
30372 - jmp *%ecx
30373 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30374
30375 -2:
30376 /*
30377 * 6. After EFI runtime service returns, control will return to
30378 * following instruction. We'd better readjust stack pointer first.
30379 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30380 movl %cr0, %edx
30381 orl $0x80000000, %edx
30382 movl %edx, %cr0
30383 - jmp 1f
30384 -1:
30385 +
30386 /*
30387 * 8. Now restore the virtual mode from flat mode by
30388 * adding EIP with PAGE_OFFSET.
30389 */
30390 - movl $1f, %edx
30391 - jmp *%edx
30392 +#ifdef CONFIG_PAX_KERNEXEC
30393 + movl $(__KERNEL_DS), %edx
30394 + mov %edx, %ds
30395 + mov %edx, %es
30396 + mov %edx, %ss
30397 + ljmp $(__KERNEL_CS),$1f
30398 +#else
30399 + jmp 1f+__PAGE_OFFSET
30400 +#endif
30401 1:
30402
30403 /*
30404 * 9. Balance the stack. And because EAX contain the return value,
30405 * we'd better not clobber it.
30406 */
30407 - leal efi_rt_function_ptr, %edx
30408 - movl (%edx), %ecx
30409 - pushl %ecx
30410 + pushl (efi_rt_function_ptr)
30411
30412 /*
30413 - * 10. Push the saved return address onto the stack and return.
30414 + * 10. Return to the saved return address.
30415 */
30416 - leal saved_return_addr, %edx
30417 - movl (%edx), %ecx
30418 - pushl %ecx
30419 - ret
30420 + jmpl *(saved_return_addr)
30421 ENDPROC(efi_call_phys)
30422 .previous
30423
30424 -.data
30425 +__INITDATA
30426 saved_return_addr:
30427 .long 0
30428 efi_rt_function_ptr:
30429 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30430 index 4c07cca..2c8427d 100644
30431 --- a/arch/x86/platform/efi/efi_stub_64.S
30432 +++ b/arch/x86/platform/efi/efi_stub_64.S
30433 @@ -7,6 +7,7 @@
30434 */
30435
30436 #include <linux/linkage.h>
30437 +#include <asm/alternative-asm.h>
30438
30439 #define SAVE_XMM \
30440 mov %rsp, %rax; \
30441 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30442 call *%rdi
30443 addq $32, %rsp
30444 RESTORE_XMM
30445 + pax_force_retaddr 0, 1
30446 ret
30447 ENDPROC(efi_call0)
30448
30449 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30450 call *%rdi
30451 addq $32, %rsp
30452 RESTORE_XMM
30453 + pax_force_retaddr 0, 1
30454 ret
30455 ENDPROC(efi_call1)
30456
30457 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30458 call *%rdi
30459 addq $32, %rsp
30460 RESTORE_XMM
30461 + pax_force_retaddr 0, 1
30462 ret
30463 ENDPROC(efi_call2)
30464
30465 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30466 call *%rdi
30467 addq $32, %rsp
30468 RESTORE_XMM
30469 + pax_force_retaddr 0, 1
30470 ret
30471 ENDPROC(efi_call3)
30472
30473 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30474 call *%rdi
30475 addq $32, %rsp
30476 RESTORE_XMM
30477 + pax_force_retaddr 0, 1
30478 ret
30479 ENDPROC(efi_call4)
30480
30481 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30482 call *%rdi
30483 addq $48, %rsp
30484 RESTORE_XMM
30485 + pax_force_retaddr 0, 1
30486 ret
30487 ENDPROC(efi_call5)
30488
30489 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30490 call *%rdi
30491 addq $48, %rsp
30492 RESTORE_XMM
30493 + pax_force_retaddr 0, 1
30494 ret
30495 ENDPROC(efi_call6)
30496 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30497 index e31bcd8..f12dc46 100644
30498 --- a/arch/x86/platform/mrst/mrst.c
30499 +++ b/arch/x86/platform/mrst/mrst.c
30500 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30501 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30502 int sfi_mrtc_num;
30503
30504 -static void mrst_power_off(void)
30505 +static __noreturn void mrst_power_off(void)
30506 {
30507 + BUG();
30508 }
30509
30510 -static void mrst_reboot(void)
30511 +static __noreturn void mrst_reboot(void)
30512 {
30513 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30514 + BUG();
30515 }
30516
30517 /* parse all the mtimer info to a static mtimer array */
30518 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30519 index d6ee929..3637cb5 100644
30520 --- a/arch/x86/platform/olpc/olpc_dt.c
30521 +++ b/arch/x86/platform/olpc/olpc_dt.c
30522 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30523 return res;
30524 }
30525
30526 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30527 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30528 .nextprop = olpc_dt_nextprop,
30529 .getproplen = olpc_dt_getproplen,
30530 .getproperty = olpc_dt_getproperty,
30531 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30532 index 3c68768..07e82b8 100644
30533 --- a/arch/x86/power/cpu.c
30534 +++ b/arch/x86/power/cpu.c
30535 @@ -134,7 +134,7 @@ static void do_fpu_end(void)
30536 static void fix_processor_context(void)
30537 {
30538 int cpu = smp_processor_id();
30539 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30540 + struct tss_struct *t = init_tss + cpu;
30541
30542 set_tss_desc(cpu, t); /*
30543 * This just modifies memory; should not be
30544 @@ -144,8 +144,6 @@ static void fix_processor_context(void)
30545 */
30546
30547 #ifdef CONFIG_X86_64
30548 - get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
30549 -
30550 syscall_init(); /* This sets MSR_*STAR and related */
30551 #endif
30552 load_TR_desc(); /* This does ltr */
30553 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30554 index a44f457..9140171 100644
30555 --- a/arch/x86/realmode/init.c
30556 +++ b/arch/x86/realmode/init.c
30557 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
30558 __va(real_mode_header->trampoline_header);
30559
30560 #ifdef CONFIG_X86_32
30561 - trampoline_header->start = __pa_symbol(startup_32_smp);
30562 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
30563 +
30564 +#ifdef CONFIG_PAX_KERNEXEC
30565 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
30566 +#endif
30567 +
30568 + trampoline_header->boot_cs = __BOOT_CS;
30569 trampoline_header->gdt_limit = __BOOT_DS + 7;
30570 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
30571 #else
30572 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
30573 *trampoline_cr4_features = read_cr4();
30574
30575 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
30576 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
30577 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
30578 trampoline_pgd[511] = init_level4_pgt[511].pgd;
30579 #endif
30580 }
30581 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
30582 index 8869287..d577672 100644
30583 --- a/arch/x86/realmode/rm/Makefile
30584 +++ b/arch/x86/realmode/rm/Makefile
30585 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
30586 $(call cc-option, -fno-unit-at-a-time)) \
30587 $(call cc-option, -fno-stack-protector) \
30588 $(call cc-option, -mpreferred-stack-boundary=2)
30589 +ifdef CONSTIFY_PLUGIN
30590 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
30591 +endif
30592 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
30593 GCOV_PROFILE := n
30594 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
30595 index a28221d..93c40f1 100644
30596 --- a/arch/x86/realmode/rm/header.S
30597 +++ b/arch/x86/realmode/rm/header.S
30598 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
30599 #endif
30600 /* APM/BIOS reboot */
30601 .long pa_machine_real_restart_asm
30602 -#ifdef CONFIG_X86_64
30603 +#ifdef CONFIG_X86_32
30604 + .long __KERNEL_CS
30605 +#else
30606 .long __KERNEL32_CS
30607 #endif
30608 END(real_mode_header)
30609 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
30610 index c1b2791..f9e31c7 100644
30611 --- a/arch/x86/realmode/rm/trampoline_32.S
30612 +++ b/arch/x86/realmode/rm/trampoline_32.S
30613 @@ -25,6 +25,12 @@
30614 #include <asm/page_types.h>
30615 #include "realmode.h"
30616
30617 +#ifdef CONFIG_PAX_KERNEXEC
30618 +#define ta(X) (X)
30619 +#else
30620 +#define ta(X) (pa_ ## X)
30621 +#endif
30622 +
30623 .text
30624 .code16
30625
30626 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
30627
30628 cli # We should be safe anyway
30629
30630 - movl tr_start, %eax # where we need to go
30631 -
30632 movl $0xA5A5A5A5, trampoline_status
30633 # write marker for master knows we're running
30634
30635 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
30636 movw $1, %dx # protected mode (PE) bit
30637 lmsw %dx # into protected mode
30638
30639 - ljmpl $__BOOT_CS, $pa_startup_32
30640 + ljmpl *(trampoline_header)
30641
30642 .section ".text32","ax"
30643 .code32
30644 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
30645 .balign 8
30646 GLOBAL(trampoline_header)
30647 tr_start: .space 4
30648 - tr_gdt_pad: .space 2
30649 + tr_boot_cs: .space 2
30650 tr_gdt: .space 6
30651 END(trampoline_header)
30652
30653 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
30654 index bb360dc..3e5945f 100644
30655 --- a/arch/x86/realmode/rm/trampoline_64.S
30656 +++ b/arch/x86/realmode/rm/trampoline_64.S
30657 @@ -107,7 +107,7 @@ ENTRY(startup_32)
30658 wrmsr
30659
30660 # Enable paging and in turn activate Long Mode
30661 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
30662 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
30663 movl %eax, %cr0
30664
30665 /*
30666 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
30667 index 79d67bd..c7e1b90 100644
30668 --- a/arch/x86/tools/relocs.c
30669 +++ b/arch/x86/tools/relocs.c
30670 @@ -12,10 +12,13 @@
30671 #include <regex.h>
30672 #include <tools/le_byteshift.h>
30673
30674 +#include "../../../include/generated/autoconf.h"
30675 +
30676 static void die(char *fmt, ...);
30677
30678 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
30679 static Elf32_Ehdr ehdr;
30680 +static Elf32_Phdr *phdr;
30681 static unsigned long reloc_count, reloc_idx;
30682 static unsigned long *relocs;
30683 static unsigned long reloc16_count, reloc16_idx;
30684 @@ -330,9 +333,39 @@ static void read_ehdr(FILE *fp)
30685 }
30686 }
30687
30688 +static void read_phdrs(FILE *fp)
30689 +{
30690 + unsigned int i;
30691 +
30692 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
30693 + if (!phdr) {
30694 + die("Unable to allocate %d program headers\n",
30695 + ehdr.e_phnum);
30696 + }
30697 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
30698 + die("Seek to %d failed: %s\n",
30699 + ehdr.e_phoff, strerror(errno));
30700 + }
30701 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
30702 + die("Cannot read ELF program headers: %s\n",
30703 + strerror(errno));
30704 + }
30705 + for(i = 0; i < ehdr.e_phnum; i++) {
30706 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
30707 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
30708 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
30709 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
30710 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
30711 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
30712 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
30713 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
30714 + }
30715 +
30716 +}
30717 +
30718 static void read_shdrs(FILE *fp)
30719 {
30720 - int i;
30721 + unsigned int i;
30722 Elf32_Shdr shdr;
30723
30724 secs = calloc(ehdr.e_shnum, sizeof(struct section));
30725 @@ -367,7 +400,7 @@ static void read_shdrs(FILE *fp)
30726
30727 static void read_strtabs(FILE *fp)
30728 {
30729 - int i;
30730 + unsigned int i;
30731 for (i = 0; i < ehdr.e_shnum; i++) {
30732 struct section *sec = &secs[i];
30733 if (sec->shdr.sh_type != SHT_STRTAB) {
30734 @@ -392,7 +425,7 @@ static void read_strtabs(FILE *fp)
30735
30736 static void read_symtabs(FILE *fp)
30737 {
30738 - int i,j;
30739 + unsigned int i,j;
30740 for (i = 0; i < ehdr.e_shnum; i++) {
30741 struct section *sec = &secs[i];
30742 if (sec->shdr.sh_type != SHT_SYMTAB) {
30743 @@ -423,9 +456,11 @@ static void read_symtabs(FILE *fp)
30744 }
30745
30746
30747 -static void read_relocs(FILE *fp)
30748 +static void read_relocs(FILE *fp, int use_real_mode)
30749 {
30750 - int i,j;
30751 + unsigned int i,j;
30752 + uint32_t base;
30753 +
30754 for (i = 0; i < ehdr.e_shnum; i++) {
30755 struct section *sec = &secs[i];
30756 if (sec->shdr.sh_type != SHT_REL) {
30757 @@ -445,9 +480,22 @@ static void read_relocs(FILE *fp)
30758 die("Cannot read symbol table: %s\n",
30759 strerror(errno));
30760 }
30761 + base = 0;
30762 +
30763 +#ifdef CONFIG_X86_32
30764 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
30765 + if (phdr[j].p_type != PT_LOAD )
30766 + continue;
30767 + 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)
30768 + continue;
30769 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
30770 + break;
30771 + }
30772 +#endif
30773 +
30774 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
30775 Elf32_Rel *rel = &sec->reltab[j];
30776 - rel->r_offset = elf32_to_cpu(rel->r_offset);
30777 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
30778 rel->r_info = elf32_to_cpu(rel->r_info);
30779 }
30780 }
30781 @@ -456,13 +504,13 @@ static void read_relocs(FILE *fp)
30782
30783 static void print_absolute_symbols(void)
30784 {
30785 - int i;
30786 + unsigned int i;
30787 printf("Absolute symbols\n");
30788 printf(" Num: Value Size Type Bind Visibility Name\n");
30789 for (i = 0; i < ehdr.e_shnum; i++) {
30790 struct section *sec = &secs[i];
30791 char *sym_strtab;
30792 - int j;
30793 + unsigned int j;
30794
30795 if (sec->shdr.sh_type != SHT_SYMTAB) {
30796 continue;
30797 @@ -489,14 +537,14 @@ static void print_absolute_symbols(void)
30798
30799 static void print_absolute_relocs(void)
30800 {
30801 - int i, printed = 0;
30802 + unsigned int i, printed = 0;
30803
30804 for (i = 0; i < ehdr.e_shnum; i++) {
30805 struct section *sec = &secs[i];
30806 struct section *sec_applies, *sec_symtab;
30807 char *sym_strtab;
30808 Elf32_Sym *sh_symtab;
30809 - int j;
30810 + unsigned int j;
30811 if (sec->shdr.sh_type != SHT_REL) {
30812 continue;
30813 }
30814 @@ -558,13 +606,13 @@ static void print_absolute_relocs(void)
30815 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
30816 int use_real_mode)
30817 {
30818 - int i;
30819 + unsigned int i;
30820 /* Walk through the relocations */
30821 for (i = 0; i < ehdr.e_shnum; i++) {
30822 char *sym_strtab;
30823 Elf32_Sym *sh_symtab;
30824 struct section *sec_applies, *sec_symtab;
30825 - int j;
30826 + unsigned int j;
30827 struct section *sec = &secs[i];
30828
30829 if (sec->shdr.sh_type != SHT_REL) {
30830 @@ -588,6 +636,24 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
30831 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
30832 r_type = ELF32_R_TYPE(rel->r_info);
30833
30834 + if (!use_real_mode) {
30835 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
30836 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
30837 + continue;
30838 +
30839 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
30840 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
30841 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
30842 + continue;
30843 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
30844 + continue;
30845 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
30846 + continue;
30847 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
30848 + continue;
30849 +#endif
30850 + }
30851 +
30852 shn_abs = sym->st_shndx == SHN_ABS;
30853
30854 switch (r_type) {
30855 @@ -681,7 +747,7 @@ static int write32(unsigned int v, FILE *f)
30856
30857 static void emit_relocs(int as_text, int use_real_mode)
30858 {
30859 - int i;
30860 + unsigned int i;
30861 /* Count how many relocations I have and allocate space for them. */
30862 reloc_count = 0;
30863 walk_relocs(count_reloc, use_real_mode);
30864 @@ -808,10 +874,11 @@ int main(int argc, char **argv)
30865 fname, strerror(errno));
30866 }
30867 read_ehdr(fp);
30868 + read_phdrs(fp);
30869 read_shdrs(fp);
30870 read_strtabs(fp);
30871 read_symtabs(fp);
30872 - read_relocs(fp);
30873 + read_relocs(fp, use_real_mode);
30874 if (show_absolute_syms) {
30875 print_absolute_symbols();
30876 goto out;
30877 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
30878 index fd14be1..e3c79c0 100644
30879 --- a/arch/x86/vdso/Makefile
30880 +++ b/arch/x86/vdso/Makefile
30881 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
30882 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
30883 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
30884
30885 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
30886 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
30887 GCOV_PROFILE := n
30888
30889 #
30890 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
30891 index 0faad64..39ef157 100644
30892 --- a/arch/x86/vdso/vdso32-setup.c
30893 +++ b/arch/x86/vdso/vdso32-setup.c
30894 @@ -25,6 +25,7 @@
30895 #include <asm/tlbflush.h>
30896 #include <asm/vdso.h>
30897 #include <asm/proto.h>
30898 +#include <asm/mman.h>
30899
30900 enum {
30901 VDSO_DISABLED = 0,
30902 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
30903 void enable_sep_cpu(void)
30904 {
30905 int cpu = get_cpu();
30906 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
30907 + struct tss_struct *tss = init_tss + cpu;
30908
30909 if (!boot_cpu_has(X86_FEATURE_SEP)) {
30910 put_cpu();
30911 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
30912 gate_vma.vm_start = FIXADDR_USER_START;
30913 gate_vma.vm_end = FIXADDR_USER_END;
30914 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
30915 - gate_vma.vm_page_prot = __P101;
30916 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
30917
30918 return 0;
30919 }
30920 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
30921 if (compat)
30922 addr = VDSO_HIGH_BASE;
30923 else {
30924 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
30925 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
30926 if (IS_ERR_VALUE(addr)) {
30927 ret = addr;
30928 goto up_fail;
30929 }
30930 }
30931
30932 - current->mm->context.vdso = (void *)addr;
30933 + current->mm->context.vdso = addr;
30934
30935 if (compat_uses_vma || !compat) {
30936 /*
30937 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
30938 }
30939
30940 current_thread_info()->sysenter_return =
30941 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
30942 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
30943
30944 up_fail:
30945 if (ret)
30946 - current->mm->context.vdso = NULL;
30947 + current->mm->context.vdso = 0;
30948
30949 up_write(&mm->mmap_sem);
30950
30951 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
30952
30953 const char *arch_vma_name(struct vm_area_struct *vma)
30954 {
30955 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
30956 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
30957 return "[vdso]";
30958 +
30959 +#ifdef CONFIG_PAX_SEGMEXEC
30960 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
30961 + return "[vdso]";
30962 +#endif
30963 +
30964 return NULL;
30965 }
30966
30967 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
30968 * Check to see if the corresponding task was created in compat vdso
30969 * mode.
30970 */
30971 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
30972 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
30973 return &gate_vma;
30974 return NULL;
30975 }
30976 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
30977 index 431e875..cbb23f3 100644
30978 --- a/arch/x86/vdso/vma.c
30979 +++ b/arch/x86/vdso/vma.c
30980 @@ -16,8 +16,6 @@
30981 #include <asm/vdso.h>
30982 #include <asm/page.h>
30983
30984 -unsigned int __read_mostly vdso_enabled = 1;
30985 -
30986 extern char vdso_start[], vdso_end[];
30987 extern unsigned short vdso_sync_cpuid;
30988
30989 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
30990 * unaligned here as a result of stack start randomization.
30991 */
30992 addr = PAGE_ALIGN(addr);
30993 - addr = align_vdso_addr(addr);
30994
30995 return addr;
30996 }
30997 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
30998 unsigned size)
30999 {
31000 struct mm_struct *mm = current->mm;
31001 - unsigned long addr;
31002 + unsigned long addr = 0;
31003 int ret;
31004
31005 - if (!vdso_enabled)
31006 - return 0;
31007 -
31008 down_write(&mm->mmap_sem);
31009 +
31010 +#ifdef CONFIG_PAX_RANDMMAP
31011 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31012 +#endif
31013 +
31014 addr = vdso_addr(mm->start_stack, size);
31015 + addr = align_vdso_addr(addr);
31016 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31017 if (IS_ERR_VALUE(addr)) {
31018 ret = addr;
31019 goto up_fail;
31020 }
31021
31022 - current->mm->context.vdso = (void *)addr;
31023 + mm->context.vdso = addr;
31024
31025 ret = install_special_mapping(mm, addr, size,
31026 VM_READ|VM_EXEC|
31027 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31028 pages);
31029 - if (ret) {
31030 - current->mm->context.vdso = NULL;
31031 - goto up_fail;
31032 - }
31033 + if (ret)
31034 + mm->context.vdso = 0;
31035
31036 up_fail:
31037 up_write(&mm->mmap_sem);
31038 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31039 vdsox32_size);
31040 }
31041 #endif
31042 -
31043 -static __init int vdso_setup(char *s)
31044 -{
31045 - vdso_enabled = simple_strtoul(s, NULL, 0);
31046 - return 0;
31047 -}
31048 -__setup("vdso=", vdso_setup);
31049 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31050 index 2363127..ec09d96 100644
31051 --- a/arch/x86/xen/enlighten.c
31052 +++ b/arch/x86/xen/enlighten.c
31053 @@ -100,8 +100,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31054
31055 struct shared_info xen_dummy_shared_info;
31056
31057 -void *xen_initial_gdt;
31058 -
31059 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31060 __read_mostly int xen_have_vector_callback;
31061 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31062 @@ -496,8 +494,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31063 {
31064 unsigned long va = dtr->address;
31065 unsigned int size = dtr->size + 1;
31066 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31067 - unsigned long frames[pages];
31068 + unsigned long frames[65536 / PAGE_SIZE];
31069 int f;
31070
31071 /*
31072 @@ -545,8 +542,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31073 {
31074 unsigned long va = dtr->address;
31075 unsigned int size = dtr->size + 1;
31076 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31077 - unsigned long frames[pages];
31078 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
31079 int f;
31080
31081 /*
31082 @@ -554,7 +550,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31083 * 8-byte entries, or 16 4k pages..
31084 */
31085
31086 - BUG_ON(size > 65536);
31087 + BUG_ON(size > GDT_SIZE);
31088 BUG_ON(va & ~PAGE_MASK);
31089
31090 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
31091 @@ -939,7 +935,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31092 return 0;
31093 }
31094
31095 -static void set_xen_basic_apic_ops(void)
31096 +static void __init set_xen_basic_apic_ops(void)
31097 {
31098 apic->read = xen_apic_read;
31099 apic->write = xen_apic_write;
31100 @@ -1245,30 +1241,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31101 #endif
31102 };
31103
31104 -static void xen_reboot(int reason)
31105 +static __noreturn void xen_reboot(int reason)
31106 {
31107 struct sched_shutdown r = { .reason = reason };
31108
31109 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31110 - BUG();
31111 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31112 + BUG();
31113 }
31114
31115 -static void xen_restart(char *msg)
31116 +static __noreturn void xen_restart(char *msg)
31117 {
31118 xen_reboot(SHUTDOWN_reboot);
31119 }
31120
31121 -static void xen_emergency_restart(void)
31122 +static __noreturn void xen_emergency_restart(void)
31123 {
31124 xen_reboot(SHUTDOWN_reboot);
31125 }
31126
31127 -static void xen_machine_halt(void)
31128 +static __noreturn void xen_machine_halt(void)
31129 {
31130 xen_reboot(SHUTDOWN_poweroff);
31131 }
31132
31133 -static void xen_machine_power_off(void)
31134 +static __noreturn void xen_machine_power_off(void)
31135 {
31136 if (pm_power_off)
31137 pm_power_off();
31138 @@ -1370,7 +1366,17 @@ asmlinkage void __init xen_start_kernel(void)
31139 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31140
31141 /* Work out if we support NX */
31142 - x86_configure_nx();
31143 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31144 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31145 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31146 + unsigned l, h;
31147 +
31148 + __supported_pte_mask |= _PAGE_NX;
31149 + rdmsr(MSR_EFER, l, h);
31150 + l |= EFER_NX;
31151 + wrmsr(MSR_EFER, l, h);
31152 + }
31153 +#endif
31154
31155 xen_setup_features();
31156
31157 @@ -1401,13 +1407,6 @@ asmlinkage void __init xen_start_kernel(void)
31158
31159 machine_ops = xen_machine_ops;
31160
31161 - /*
31162 - * The only reliable way to retain the initial address of the
31163 - * percpu gdt_page is to remember it here, so we can go and
31164 - * mark it RW later, when the initial percpu area is freed.
31165 - */
31166 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31167 -
31168 xen_smp_init();
31169
31170 #ifdef CONFIG_ACPI_NUMA
31171 @@ -1601,7 +1600,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31172 return NOTIFY_OK;
31173 }
31174
31175 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31176 +static struct notifier_block xen_hvm_cpu_notifier = {
31177 .notifier_call = xen_hvm_cpu_notify,
31178 };
31179
31180 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31181 index e006c18..b9a7d6c 100644
31182 --- a/arch/x86/xen/mmu.c
31183 +++ b/arch/x86/xen/mmu.c
31184 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31185 /* L3_k[510] -> level2_kernel_pgt
31186 * L3_i[511] -> level2_fixmap_pgt */
31187 convert_pfn_mfn(level3_kernel_pgt);
31188 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31189 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31190 + convert_pfn_mfn(level3_vmemmap_pgt);
31191
31192 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31193 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31194 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31195 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31196 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31197 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31198 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31199 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31200 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31201 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31202 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31203 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31204 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31205 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31206
31207 @@ -2110,6 +2117,7 @@ static void __init xen_post_allocator_init(void)
31208 pv_mmu_ops.set_pud = xen_set_pud;
31209 #if PAGETABLE_LEVELS == 4
31210 pv_mmu_ops.set_pgd = xen_set_pgd;
31211 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31212 #endif
31213
31214 /* This will work as long as patching hasn't happened yet
31215 @@ -2188,6 +2196,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31216 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31217 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31218 .set_pgd = xen_set_pgd_hyper,
31219 + .set_pgd_batched = xen_set_pgd_hyper,
31220
31221 .alloc_pud = xen_alloc_pmd_init,
31222 .release_pud = xen_release_pmd_init,
31223 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31224 index 22c800a..8915f1e 100644
31225 --- a/arch/x86/xen/smp.c
31226 +++ b/arch/x86/xen/smp.c
31227 @@ -229,11 +229,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31228 {
31229 BUG_ON(smp_processor_id() != 0);
31230 native_smp_prepare_boot_cpu();
31231 -
31232 - /* We've switched to the "real" per-cpu gdt, so make sure the
31233 - old memory can be recycled */
31234 - make_lowmem_page_readwrite(xen_initial_gdt);
31235 -
31236 xen_filter_cpu_maps();
31237 xen_setup_vcpu_info_placement();
31238 }
31239 @@ -303,7 +298,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31240 ctxt->user_regs.ss = __KERNEL_DS;
31241 #ifdef CONFIG_X86_32
31242 ctxt->user_regs.fs = __KERNEL_PERCPU;
31243 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31244 + savesegment(gs, ctxt->user_regs.gs);
31245 #else
31246 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31247 #endif
31248 @@ -313,8 +308,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31249
31250 {
31251 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
31252 - ctxt->user_regs.ds = __USER_DS;
31253 - ctxt->user_regs.es = __USER_DS;
31254 + ctxt->user_regs.ds = __KERNEL_DS;
31255 + ctxt->user_regs.es = __KERNEL_DS;
31256
31257 xen_copy_trap_info(ctxt->trap_ctxt);
31258
31259 @@ -359,13 +354,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31260 int rc;
31261
31262 per_cpu(current_task, cpu) = idle;
31263 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31264 #ifdef CONFIG_X86_32
31265 irq_ctx_init(cpu);
31266 #else
31267 clear_tsk_thread_flag(idle, TIF_FORK);
31268 - per_cpu(kernel_stack, cpu) =
31269 - (unsigned long)task_stack_page(idle) -
31270 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31271 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31272 #endif
31273 xen_setup_runstate_info(cpu);
31274 xen_setup_timer(cpu);
31275 @@ -634,7 +628,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31276
31277 void __init xen_smp_init(void)
31278 {
31279 - smp_ops = xen_smp_ops;
31280 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31281 xen_fill_possible_map();
31282 xen_init_spinlocks();
31283 }
31284 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31285 index 33ca6e4..0ded929 100644
31286 --- a/arch/x86/xen/xen-asm_32.S
31287 +++ b/arch/x86/xen/xen-asm_32.S
31288 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31289 ESP_OFFSET=4 # bytes pushed onto stack
31290
31291 /*
31292 - * Store vcpu_info pointer for easy access. Do it this way to
31293 - * avoid having to reload %fs
31294 + * Store vcpu_info pointer for easy access.
31295 */
31296 #ifdef CONFIG_SMP
31297 - GET_THREAD_INFO(%eax)
31298 - movl %ss:TI_cpu(%eax), %eax
31299 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31300 - mov %ss:xen_vcpu(%eax), %eax
31301 + push %fs
31302 + mov $(__KERNEL_PERCPU), %eax
31303 + mov %eax, %fs
31304 + mov PER_CPU_VAR(xen_vcpu), %eax
31305 + pop %fs
31306 #else
31307 movl %ss:xen_vcpu, %eax
31308 #endif
31309 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31310 index 7faed58..ba4427c 100644
31311 --- a/arch/x86/xen/xen-head.S
31312 +++ b/arch/x86/xen/xen-head.S
31313 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31314 #ifdef CONFIG_X86_32
31315 mov %esi,xen_start_info
31316 mov $init_thread_union+THREAD_SIZE,%esp
31317 +#ifdef CONFIG_SMP
31318 + movl $cpu_gdt_table,%edi
31319 + movl $__per_cpu_load,%eax
31320 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31321 + rorl $16,%eax
31322 + movb %al,__KERNEL_PERCPU + 4(%edi)
31323 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31324 + movl $__per_cpu_end - 1,%eax
31325 + subl $__per_cpu_start,%eax
31326 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31327 +#endif
31328 #else
31329 mov %rsi,xen_start_info
31330 mov $init_thread_union+THREAD_SIZE,%rsp
31331 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31332 index a95b417..b6dbd0b 100644
31333 --- a/arch/x86/xen/xen-ops.h
31334 +++ b/arch/x86/xen/xen-ops.h
31335 @@ -10,8 +10,6 @@
31336 extern const char xen_hypervisor_callback[];
31337 extern const char xen_failsafe_callback[];
31338
31339 -extern void *xen_initial_gdt;
31340 -
31341 struct trap_info;
31342 void xen_copy_trap_info(struct trap_info *traps);
31343
31344 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31345 index 525bd3d..ef888b1 100644
31346 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31347 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31348 @@ -119,9 +119,9 @@
31349 ----------------------------------------------------------------------*/
31350
31351 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31352 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31353 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31354 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31355 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31356
31357 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31358 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31359 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31360 index 2f33760..835e50a 100644
31361 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31362 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31363 @@ -11,6 +11,7 @@
31364 #ifndef _XTENSA_CORE_H
31365 #define _XTENSA_CORE_H
31366
31367 +#include <linux/const.h>
31368
31369 /****************************************************************************
31370 Parameters Useful for Any Code, USER or PRIVILEGED
31371 @@ -112,9 +113,9 @@
31372 ----------------------------------------------------------------------*/
31373
31374 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31375 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31376 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31377 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31378 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31379
31380 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31381 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31382 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31383 index af00795..2bb8105 100644
31384 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31385 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31386 @@ -11,6 +11,7 @@
31387 #ifndef _XTENSA_CORE_CONFIGURATION_H
31388 #define _XTENSA_CORE_CONFIGURATION_H
31389
31390 +#include <linux/const.h>
31391
31392 /****************************************************************************
31393 Parameters Useful for Any Code, USER or PRIVILEGED
31394 @@ -118,9 +119,9 @@
31395 ----------------------------------------------------------------------*/
31396
31397 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31398 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31399 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31400 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31401 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31402
31403 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31404 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31405 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31406 index 58916af..eb9dbcf6 100644
31407 --- a/block/blk-iopoll.c
31408 +++ b/block/blk-iopoll.c
31409 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31410 }
31411 EXPORT_SYMBOL(blk_iopoll_complete);
31412
31413 -static void blk_iopoll_softirq(struct softirq_action *h)
31414 +static void blk_iopoll_softirq(void)
31415 {
31416 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31417 int rearm = 0, budget = blk_iopoll_budget;
31418 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31419 return NOTIFY_OK;
31420 }
31421
31422 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31423 +static struct notifier_block blk_iopoll_cpu_notifier = {
31424 .notifier_call = blk_iopoll_cpu_notify,
31425 };
31426
31427 diff --git a/block/blk-map.c b/block/blk-map.c
31428 index 623e1cd..ca1e109 100644
31429 --- a/block/blk-map.c
31430 +++ b/block/blk-map.c
31431 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31432 if (!len || !kbuf)
31433 return -EINVAL;
31434
31435 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31436 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31437 if (do_copy)
31438 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31439 else
31440 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31441 index 467c8de..f3628c5 100644
31442 --- a/block/blk-softirq.c
31443 +++ b/block/blk-softirq.c
31444 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31445 * Softirq action handler - move entries to local list and loop over them
31446 * while passing them to the queue registered handler.
31447 */
31448 -static void blk_done_softirq(struct softirq_action *h)
31449 +static void blk_done_softirq(void)
31450 {
31451 struct list_head *cpu_list, local_list;
31452
31453 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31454 return NOTIFY_OK;
31455 }
31456
31457 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31458 +static struct notifier_block blk_cpu_notifier = {
31459 .notifier_call = blk_cpu_notify,
31460 };
31461
31462 diff --git a/block/bsg.c b/block/bsg.c
31463 index 420a5a9..23834aa 100644
31464 --- a/block/bsg.c
31465 +++ b/block/bsg.c
31466 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31467 struct sg_io_v4 *hdr, struct bsg_device *bd,
31468 fmode_t has_write_perm)
31469 {
31470 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31471 + unsigned char *cmdptr;
31472 +
31473 if (hdr->request_len > BLK_MAX_CDB) {
31474 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31475 if (!rq->cmd)
31476 return -ENOMEM;
31477 - }
31478 + cmdptr = rq->cmd;
31479 + } else
31480 + cmdptr = tmpcmd;
31481
31482 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31483 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31484 hdr->request_len))
31485 return -EFAULT;
31486
31487 + if (cmdptr != rq->cmd)
31488 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31489 +
31490 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31491 if (blk_verify_command(rq->cmd, has_write_perm))
31492 return -EPERM;
31493 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31494 index 7c668c8..db3521c 100644
31495 --- a/block/compat_ioctl.c
31496 +++ b/block/compat_ioctl.c
31497 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31498 err |= __get_user(f->spec1, &uf->spec1);
31499 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31500 err |= __get_user(name, &uf->name);
31501 - f->name = compat_ptr(name);
31502 + f->name = (void __force_kernel *)compat_ptr(name);
31503 if (err) {
31504 err = -EFAULT;
31505 goto out;
31506 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31507 index ff5804e..a88acad 100644
31508 --- a/block/partitions/efi.c
31509 +++ b/block/partitions/efi.c
31510 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31511 if (!gpt)
31512 return NULL;
31513
31514 + if (!le32_to_cpu(gpt->num_partition_entries))
31515 + return NULL;
31516 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31517 + if (!pte)
31518 + return NULL;
31519 +
31520 count = le32_to_cpu(gpt->num_partition_entries) *
31521 le32_to_cpu(gpt->sizeof_partition_entry);
31522 - if (!count)
31523 - return NULL;
31524 - pte = kzalloc(count, GFP_KERNEL);
31525 - if (!pte)
31526 - return NULL;
31527 -
31528 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31529 (u8 *) pte,
31530 count) < count) {
31531 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
31532 index 9a87daa..fb17486 100644
31533 --- a/block/scsi_ioctl.c
31534 +++ b/block/scsi_ioctl.c
31535 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
31536 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
31537 struct sg_io_hdr *hdr, fmode_t mode)
31538 {
31539 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
31540 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31541 + unsigned char *cmdptr;
31542 +
31543 + if (rq->cmd != rq->__cmd)
31544 + cmdptr = rq->cmd;
31545 + else
31546 + cmdptr = tmpcmd;
31547 +
31548 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
31549 return -EFAULT;
31550 +
31551 + if (cmdptr != rq->cmd)
31552 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
31553 +
31554 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
31555 return -EPERM;
31556
31557 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31558 int err;
31559 unsigned int in_len, out_len, bytes, opcode, cmdlen;
31560 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
31561 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31562 + unsigned char *cmdptr;
31563
31564 if (!sic)
31565 return -EINVAL;
31566 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31567 */
31568 err = -EFAULT;
31569 rq->cmd_len = cmdlen;
31570 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
31571 +
31572 + if (rq->cmd != rq->__cmd)
31573 + cmdptr = rq->cmd;
31574 + else
31575 + cmdptr = tmpcmd;
31576 +
31577 + if (copy_from_user(cmdptr, sic->data, cmdlen))
31578 goto error;
31579
31580 + if (rq->cmd != cmdptr)
31581 + memcpy(rq->cmd, cmdptr, cmdlen);
31582 +
31583 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
31584 goto error;
31585
31586 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
31587 index 7bdd61b..afec999 100644
31588 --- a/crypto/cryptd.c
31589 +++ b/crypto/cryptd.c
31590 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
31591
31592 struct cryptd_blkcipher_request_ctx {
31593 crypto_completion_t complete;
31594 -};
31595 +} __no_const;
31596
31597 struct cryptd_hash_ctx {
31598 struct crypto_shash *child;
31599 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
31600
31601 struct cryptd_aead_request_ctx {
31602 crypto_completion_t complete;
31603 -};
31604 +} __no_const;
31605
31606 static void cryptd_queue_worker(struct work_struct *work);
31607
31608 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
31609 index f220d64..d359ad6 100644
31610 --- a/drivers/acpi/apei/apei-internal.h
31611 +++ b/drivers/acpi/apei/apei-internal.h
31612 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
31613 struct apei_exec_ins_type {
31614 u32 flags;
31615 apei_exec_ins_func_t run;
31616 -};
31617 +} __do_const;
31618
31619 struct apei_exec_context {
31620 u32 ip;
31621 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
31622 index fefc2ca..12a535d 100644
31623 --- a/drivers/acpi/apei/cper.c
31624 +++ b/drivers/acpi/apei/cper.c
31625 @@ -39,12 +39,12 @@
31626 */
31627 u64 cper_next_record_id(void)
31628 {
31629 - static atomic64_t seq;
31630 + static atomic64_unchecked_t seq;
31631
31632 - if (!atomic64_read(&seq))
31633 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
31634 + if (!atomic64_read_unchecked(&seq))
31635 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
31636
31637 - return atomic64_inc_return(&seq);
31638 + return atomic64_inc_return_unchecked(&seq);
31639 }
31640 EXPORT_SYMBOL_GPL(cper_next_record_id);
31641
31642 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
31643 index be60399..778b33e8 100644
31644 --- a/drivers/acpi/bgrt.c
31645 +++ b/drivers/acpi/bgrt.c
31646 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
31647 return -ENODEV;
31648
31649 sysfs_bin_attr_init(&image_attr);
31650 - image_attr.private = bgrt_image;
31651 - image_attr.size = bgrt_image_size;
31652 + pax_open_kernel();
31653 + *(void **)&image_attr.private = bgrt_image;
31654 + *(size_t *)&image_attr.size = bgrt_image_size;
31655 + pax_close_kernel();
31656
31657 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
31658 if (!bgrt_kobj)
31659 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
31660 index cb96296..b81293b 100644
31661 --- a/drivers/acpi/blacklist.c
31662 +++ b/drivers/acpi/blacklist.c
31663 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
31664 u32 is_critical_error;
31665 };
31666
31667 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
31668 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
31669
31670 /*
31671 * POLICY: If *anything* doesn't work, put it on the blacklist.
31672 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
31673 return 0;
31674 }
31675
31676 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
31677 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
31678 {
31679 .callback = dmi_disable_osi_vista,
31680 .ident = "Fujitsu Siemens",
31681 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
31682 index 7586544..636a2f0 100644
31683 --- a/drivers/acpi/ec_sys.c
31684 +++ b/drivers/acpi/ec_sys.c
31685 @@ -12,6 +12,7 @@
31686 #include <linux/acpi.h>
31687 #include <linux/debugfs.h>
31688 #include <linux/module.h>
31689 +#include <linux/uaccess.h>
31690 #include "internal.h"
31691
31692 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
31693 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31694 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
31695 */
31696 unsigned int size = EC_SPACE_SIZE;
31697 - u8 *data = (u8 *) buf;
31698 + u8 data;
31699 loff_t init_off = *off;
31700 int err = 0;
31701
31702 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31703 size = count;
31704
31705 while (size) {
31706 - err = ec_read(*off, &data[*off - init_off]);
31707 + err = ec_read(*off, &data);
31708 if (err)
31709 return err;
31710 + if (put_user(data, &buf[*off - init_off]))
31711 + return -EFAULT;
31712 *off += 1;
31713 size--;
31714 }
31715 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31716
31717 unsigned int size = count;
31718 loff_t init_off = *off;
31719 - u8 *data = (u8 *) buf;
31720 int err = 0;
31721
31722 if (*off >= EC_SPACE_SIZE)
31723 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31724 }
31725
31726 while (size) {
31727 - u8 byte_write = data[*off - init_off];
31728 + u8 byte_write;
31729 + if (get_user(byte_write, &buf[*off - init_off]))
31730 + return -EFAULT;
31731 err = ec_write(*off, byte_write);
31732 if (err)
31733 return err;
31734 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
31735 index ee255c6..747c68b 100644
31736 --- a/drivers/acpi/processor_idle.c
31737 +++ b/drivers/acpi/processor_idle.c
31738 @@ -986,7 +986,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
31739 {
31740 int i, count = CPUIDLE_DRIVER_STATE_START;
31741 struct acpi_processor_cx *cx;
31742 - struct cpuidle_state *state;
31743 + cpuidle_state_no_const *state;
31744 struct cpuidle_driver *drv = &acpi_idle_driver;
31745
31746 if (!pr->flags.power_setup_done)
31747 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
31748 index 41c0504..f8c0836 100644
31749 --- a/drivers/acpi/sysfs.c
31750 +++ b/drivers/acpi/sysfs.c
31751 @@ -420,11 +420,11 @@ static u32 num_counters;
31752 static struct attribute **all_attrs;
31753 static u32 acpi_gpe_count;
31754
31755 -static struct attribute_group interrupt_stats_attr_group = {
31756 +static attribute_group_no_const interrupt_stats_attr_group = {
31757 .name = "interrupts",
31758 };
31759
31760 -static struct kobj_attribute *counter_attrs;
31761 +static kobj_attribute_no_const *counter_attrs;
31762
31763 static void delete_gpe_attr_array(void)
31764 {
31765 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
31766 index 34c8216..f56c828 100644
31767 --- a/drivers/ata/libahci.c
31768 +++ b/drivers/ata/libahci.c
31769 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
31770 }
31771 EXPORT_SYMBOL_GPL(ahci_kick_engine);
31772
31773 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
31774 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
31775 struct ata_taskfile *tf, int is_cmd, u16 flags,
31776 unsigned long timeout_msec)
31777 {
31778 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
31779 index 63c743b..0422dc6 100644
31780 --- a/drivers/ata/libata-core.c
31781 +++ b/drivers/ata/libata-core.c
31782 @@ -4786,7 +4786,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
31783 struct ata_port *ap;
31784 unsigned int tag;
31785
31786 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31787 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31788 ap = qc->ap;
31789
31790 qc->flags = 0;
31791 @@ -4802,7 +4802,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
31792 struct ata_port *ap;
31793 struct ata_link *link;
31794
31795 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31796 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31797 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
31798 ap = qc->ap;
31799 link = qc->dev->link;
31800 @@ -5920,6 +5920,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
31801 return;
31802
31803 spin_lock(&lock);
31804 + pax_open_kernel();
31805
31806 for (cur = ops->inherits; cur; cur = cur->inherits) {
31807 void **inherit = (void **)cur;
31808 @@ -5933,8 +5934,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
31809 if (IS_ERR(*pp))
31810 *pp = NULL;
31811
31812 - ops->inherits = NULL;
31813 + *(struct ata_port_operations **)&ops->inherits = NULL;
31814
31815 + pax_close_kernel();
31816 spin_unlock(&lock);
31817 }
31818
31819 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
31820 index 405022d..fb70e53 100644
31821 --- a/drivers/ata/pata_arasan_cf.c
31822 +++ b/drivers/ata/pata_arasan_cf.c
31823 @@ -864,7 +864,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
31824 /* Handle platform specific quirks */
31825 if (pdata->quirk) {
31826 if (pdata->quirk & CF_BROKEN_PIO) {
31827 - ap->ops->set_piomode = NULL;
31828 + pax_open_kernel();
31829 + *(void **)&ap->ops->set_piomode = NULL;
31830 + pax_close_kernel();
31831 ap->pio_mask = 0;
31832 }
31833 if (pdata->quirk & CF_BROKEN_MWDMA)
31834 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
31835 index f9b983a..887b9d8 100644
31836 --- a/drivers/atm/adummy.c
31837 +++ b/drivers/atm/adummy.c
31838 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
31839 vcc->pop(vcc, skb);
31840 else
31841 dev_kfree_skb_any(skb);
31842 - atomic_inc(&vcc->stats->tx);
31843 + atomic_inc_unchecked(&vcc->stats->tx);
31844
31845 return 0;
31846 }
31847 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
31848 index 77a7480..05cde58 100644
31849 --- a/drivers/atm/ambassador.c
31850 +++ b/drivers/atm/ambassador.c
31851 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
31852 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
31853
31854 // VC layer stats
31855 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
31856 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
31857
31858 // free the descriptor
31859 kfree (tx_descr);
31860 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
31861 dump_skb ("<<<", vc, skb);
31862
31863 // VC layer stats
31864 - atomic_inc(&atm_vcc->stats->rx);
31865 + atomic_inc_unchecked(&atm_vcc->stats->rx);
31866 __net_timestamp(skb);
31867 // end of our responsibility
31868 atm_vcc->push (atm_vcc, skb);
31869 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
31870 } else {
31871 PRINTK (KERN_INFO, "dropped over-size frame");
31872 // should we count this?
31873 - atomic_inc(&atm_vcc->stats->rx_drop);
31874 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
31875 }
31876
31877 } else {
31878 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
31879 }
31880
31881 if (check_area (skb->data, skb->len)) {
31882 - atomic_inc(&atm_vcc->stats->tx_err);
31883 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
31884 return -ENOMEM; // ?
31885 }
31886
31887 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
31888 index 0e3f8f9..765a7a5 100644
31889 --- a/drivers/atm/atmtcp.c
31890 +++ b/drivers/atm/atmtcp.c
31891 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
31892 if (vcc->pop) vcc->pop(vcc,skb);
31893 else dev_kfree_skb(skb);
31894 if (dev_data) return 0;
31895 - atomic_inc(&vcc->stats->tx_err);
31896 + atomic_inc_unchecked(&vcc->stats->tx_err);
31897 return -ENOLINK;
31898 }
31899 size = skb->len+sizeof(struct atmtcp_hdr);
31900 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
31901 if (!new_skb) {
31902 if (vcc->pop) vcc->pop(vcc,skb);
31903 else dev_kfree_skb(skb);
31904 - atomic_inc(&vcc->stats->tx_err);
31905 + atomic_inc_unchecked(&vcc->stats->tx_err);
31906 return -ENOBUFS;
31907 }
31908 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
31909 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
31910 if (vcc->pop) vcc->pop(vcc,skb);
31911 else dev_kfree_skb(skb);
31912 out_vcc->push(out_vcc,new_skb);
31913 - atomic_inc(&vcc->stats->tx);
31914 - atomic_inc(&out_vcc->stats->rx);
31915 + atomic_inc_unchecked(&vcc->stats->tx);
31916 + atomic_inc_unchecked(&out_vcc->stats->rx);
31917 return 0;
31918 }
31919
31920 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
31921 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
31922 read_unlock(&vcc_sklist_lock);
31923 if (!out_vcc) {
31924 - atomic_inc(&vcc->stats->tx_err);
31925 + atomic_inc_unchecked(&vcc->stats->tx_err);
31926 goto done;
31927 }
31928 skb_pull(skb,sizeof(struct atmtcp_hdr));
31929 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
31930 __net_timestamp(new_skb);
31931 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
31932 out_vcc->push(out_vcc,new_skb);
31933 - atomic_inc(&vcc->stats->tx);
31934 - atomic_inc(&out_vcc->stats->rx);
31935 + atomic_inc_unchecked(&vcc->stats->tx);
31936 + atomic_inc_unchecked(&out_vcc->stats->rx);
31937 done:
31938 if (vcc->pop) vcc->pop(vcc,skb);
31939 else dev_kfree_skb(skb);
31940 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
31941 index b1955ba..b179940 100644
31942 --- a/drivers/atm/eni.c
31943 +++ b/drivers/atm/eni.c
31944 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
31945 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
31946 vcc->dev->number);
31947 length = 0;
31948 - atomic_inc(&vcc->stats->rx_err);
31949 + atomic_inc_unchecked(&vcc->stats->rx_err);
31950 }
31951 else {
31952 length = ATM_CELL_SIZE-1; /* no HEC */
31953 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
31954 size);
31955 }
31956 eff = length = 0;
31957 - atomic_inc(&vcc->stats->rx_err);
31958 + atomic_inc_unchecked(&vcc->stats->rx_err);
31959 }
31960 else {
31961 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
31962 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
31963 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
31964 vcc->dev->number,vcc->vci,length,size << 2,descr);
31965 length = eff = 0;
31966 - atomic_inc(&vcc->stats->rx_err);
31967 + atomic_inc_unchecked(&vcc->stats->rx_err);
31968 }
31969 }
31970 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
31971 @@ -767,7 +767,7 @@ rx_dequeued++;
31972 vcc->push(vcc,skb);
31973 pushed++;
31974 }
31975 - atomic_inc(&vcc->stats->rx);
31976 + atomic_inc_unchecked(&vcc->stats->rx);
31977 }
31978 wake_up(&eni_dev->rx_wait);
31979 }
31980 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
31981 PCI_DMA_TODEVICE);
31982 if (vcc->pop) vcc->pop(vcc,skb);
31983 else dev_kfree_skb_irq(skb);
31984 - atomic_inc(&vcc->stats->tx);
31985 + atomic_inc_unchecked(&vcc->stats->tx);
31986 wake_up(&eni_dev->tx_wait);
31987 dma_complete++;
31988 }
31989 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
31990 index b41c948..a002b17 100644
31991 --- a/drivers/atm/firestream.c
31992 +++ b/drivers/atm/firestream.c
31993 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
31994 }
31995 }
31996
31997 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
31998 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
31999
32000 fs_dprintk (FS_DEBUG_TXMEM, "i");
32001 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32002 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32003 #endif
32004 skb_put (skb, qe->p1 & 0xffff);
32005 ATM_SKB(skb)->vcc = atm_vcc;
32006 - atomic_inc(&atm_vcc->stats->rx);
32007 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32008 __net_timestamp(skb);
32009 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32010 atm_vcc->push (atm_vcc, skb);
32011 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32012 kfree (pe);
32013 }
32014 if (atm_vcc)
32015 - atomic_inc(&atm_vcc->stats->rx_drop);
32016 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32017 break;
32018 case 0x1f: /* Reassembly abort: no buffers. */
32019 /* Silently increment error counter. */
32020 if (atm_vcc)
32021 - atomic_inc(&atm_vcc->stats->rx_drop);
32022 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32023 break;
32024 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32025 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32026 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32027 index 204814e..cede831 100644
32028 --- a/drivers/atm/fore200e.c
32029 +++ b/drivers/atm/fore200e.c
32030 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32031 #endif
32032 /* check error condition */
32033 if (*entry->status & STATUS_ERROR)
32034 - atomic_inc(&vcc->stats->tx_err);
32035 + atomic_inc_unchecked(&vcc->stats->tx_err);
32036 else
32037 - atomic_inc(&vcc->stats->tx);
32038 + atomic_inc_unchecked(&vcc->stats->tx);
32039 }
32040 }
32041
32042 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32043 if (skb == NULL) {
32044 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32045
32046 - atomic_inc(&vcc->stats->rx_drop);
32047 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32048 return -ENOMEM;
32049 }
32050
32051 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32052
32053 dev_kfree_skb_any(skb);
32054
32055 - atomic_inc(&vcc->stats->rx_drop);
32056 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32057 return -ENOMEM;
32058 }
32059
32060 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32061
32062 vcc->push(vcc, skb);
32063 - atomic_inc(&vcc->stats->rx);
32064 + atomic_inc_unchecked(&vcc->stats->rx);
32065
32066 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32067
32068 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32069 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32070 fore200e->atm_dev->number,
32071 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32072 - atomic_inc(&vcc->stats->rx_err);
32073 + atomic_inc_unchecked(&vcc->stats->rx_err);
32074 }
32075 }
32076
32077 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32078 goto retry_here;
32079 }
32080
32081 - atomic_inc(&vcc->stats->tx_err);
32082 + atomic_inc_unchecked(&vcc->stats->tx_err);
32083
32084 fore200e->tx_sat++;
32085 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32086 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32087 index d689126..e78e412 100644
32088 --- a/drivers/atm/he.c
32089 +++ b/drivers/atm/he.c
32090 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32091
32092 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32093 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32094 - atomic_inc(&vcc->stats->rx_drop);
32095 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32096 goto return_host_buffers;
32097 }
32098
32099 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32100 RBRQ_LEN_ERR(he_dev->rbrq_head)
32101 ? "LEN_ERR" : "",
32102 vcc->vpi, vcc->vci);
32103 - atomic_inc(&vcc->stats->rx_err);
32104 + atomic_inc_unchecked(&vcc->stats->rx_err);
32105 goto return_host_buffers;
32106 }
32107
32108 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32109 vcc->push(vcc, skb);
32110 spin_lock(&he_dev->global_lock);
32111
32112 - atomic_inc(&vcc->stats->rx);
32113 + atomic_inc_unchecked(&vcc->stats->rx);
32114
32115 return_host_buffers:
32116 ++pdus_assembled;
32117 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32118 tpd->vcc->pop(tpd->vcc, tpd->skb);
32119 else
32120 dev_kfree_skb_any(tpd->skb);
32121 - atomic_inc(&tpd->vcc->stats->tx_err);
32122 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32123 }
32124 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32125 return;
32126 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32127 vcc->pop(vcc, skb);
32128 else
32129 dev_kfree_skb_any(skb);
32130 - atomic_inc(&vcc->stats->tx_err);
32131 + atomic_inc_unchecked(&vcc->stats->tx_err);
32132 return -EINVAL;
32133 }
32134
32135 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32136 vcc->pop(vcc, skb);
32137 else
32138 dev_kfree_skb_any(skb);
32139 - atomic_inc(&vcc->stats->tx_err);
32140 + atomic_inc_unchecked(&vcc->stats->tx_err);
32141 return -EINVAL;
32142 }
32143 #endif
32144 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32145 vcc->pop(vcc, skb);
32146 else
32147 dev_kfree_skb_any(skb);
32148 - atomic_inc(&vcc->stats->tx_err);
32149 + atomic_inc_unchecked(&vcc->stats->tx_err);
32150 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32151 return -ENOMEM;
32152 }
32153 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32154 vcc->pop(vcc, skb);
32155 else
32156 dev_kfree_skb_any(skb);
32157 - atomic_inc(&vcc->stats->tx_err);
32158 + atomic_inc_unchecked(&vcc->stats->tx_err);
32159 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32160 return -ENOMEM;
32161 }
32162 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32163 __enqueue_tpd(he_dev, tpd, cid);
32164 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32165
32166 - atomic_inc(&vcc->stats->tx);
32167 + atomic_inc_unchecked(&vcc->stats->tx);
32168
32169 return 0;
32170 }
32171 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32172 index 1dc0519..1aadaf7 100644
32173 --- a/drivers/atm/horizon.c
32174 +++ b/drivers/atm/horizon.c
32175 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32176 {
32177 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32178 // VC layer stats
32179 - atomic_inc(&vcc->stats->rx);
32180 + atomic_inc_unchecked(&vcc->stats->rx);
32181 __net_timestamp(skb);
32182 // end of our responsibility
32183 vcc->push (vcc, skb);
32184 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32185 dev->tx_iovec = NULL;
32186
32187 // VC layer stats
32188 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32189 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32190
32191 // free the skb
32192 hrz_kfree_skb (skb);
32193 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32194 index 272f009..a18ba55 100644
32195 --- a/drivers/atm/idt77252.c
32196 +++ b/drivers/atm/idt77252.c
32197 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32198 else
32199 dev_kfree_skb(skb);
32200
32201 - atomic_inc(&vcc->stats->tx);
32202 + atomic_inc_unchecked(&vcc->stats->tx);
32203 }
32204
32205 atomic_dec(&scq->used);
32206 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32207 if ((sb = dev_alloc_skb(64)) == NULL) {
32208 printk("%s: Can't allocate buffers for aal0.\n",
32209 card->name);
32210 - atomic_add(i, &vcc->stats->rx_drop);
32211 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32212 break;
32213 }
32214 if (!atm_charge(vcc, sb->truesize)) {
32215 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32216 card->name);
32217 - atomic_add(i - 1, &vcc->stats->rx_drop);
32218 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32219 dev_kfree_skb(sb);
32220 break;
32221 }
32222 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32223 ATM_SKB(sb)->vcc = vcc;
32224 __net_timestamp(sb);
32225 vcc->push(vcc, sb);
32226 - atomic_inc(&vcc->stats->rx);
32227 + atomic_inc_unchecked(&vcc->stats->rx);
32228
32229 cell += ATM_CELL_PAYLOAD;
32230 }
32231 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32232 "(CDC: %08x)\n",
32233 card->name, len, rpp->len, readl(SAR_REG_CDC));
32234 recycle_rx_pool_skb(card, rpp);
32235 - atomic_inc(&vcc->stats->rx_err);
32236 + atomic_inc_unchecked(&vcc->stats->rx_err);
32237 return;
32238 }
32239 if (stat & SAR_RSQE_CRC) {
32240 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32241 recycle_rx_pool_skb(card, rpp);
32242 - atomic_inc(&vcc->stats->rx_err);
32243 + atomic_inc_unchecked(&vcc->stats->rx_err);
32244 return;
32245 }
32246 if (skb_queue_len(&rpp->queue) > 1) {
32247 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32248 RXPRINTK("%s: Can't alloc RX skb.\n",
32249 card->name);
32250 recycle_rx_pool_skb(card, rpp);
32251 - atomic_inc(&vcc->stats->rx_err);
32252 + atomic_inc_unchecked(&vcc->stats->rx_err);
32253 return;
32254 }
32255 if (!atm_charge(vcc, skb->truesize)) {
32256 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32257 __net_timestamp(skb);
32258
32259 vcc->push(vcc, skb);
32260 - atomic_inc(&vcc->stats->rx);
32261 + atomic_inc_unchecked(&vcc->stats->rx);
32262
32263 return;
32264 }
32265 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32266 __net_timestamp(skb);
32267
32268 vcc->push(vcc, skb);
32269 - atomic_inc(&vcc->stats->rx);
32270 + atomic_inc_unchecked(&vcc->stats->rx);
32271
32272 if (skb->truesize > SAR_FB_SIZE_3)
32273 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32274 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32275 if (vcc->qos.aal != ATM_AAL0) {
32276 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32277 card->name, vpi, vci);
32278 - atomic_inc(&vcc->stats->rx_drop);
32279 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32280 goto drop;
32281 }
32282
32283 if ((sb = dev_alloc_skb(64)) == NULL) {
32284 printk("%s: Can't allocate buffers for AAL0.\n",
32285 card->name);
32286 - atomic_inc(&vcc->stats->rx_err);
32287 + atomic_inc_unchecked(&vcc->stats->rx_err);
32288 goto drop;
32289 }
32290
32291 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32292 ATM_SKB(sb)->vcc = vcc;
32293 __net_timestamp(sb);
32294 vcc->push(vcc, sb);
32295 - atomic_inc(&vcc->stats->rx);
32296 + atomic_inc_unchecked(&vcc->stats->rx);
32297
32298 drop:
32299 skb_pull(queue, 64);
32300 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32301
32302 if (vc == NULL) {
32303 printk("%s: NULL connection in send().\n", card->name);
32304 - atomic_inc(&vcc->stats->tx_err);
32305 + atomic_inc_unchecked(&vcc->stats->tx_err);
32306 dev_kfree_skb(skb);
32307 return -EINVAL;
32308 }
32309 if (!test_bit(VCF_TX, &vc->flags)) {
32310 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32311 - atomic_inc(&vcc->stats->tx_err);
32312 + atomic_inc_unchecked(&vcc->stats->tx_err);
32313 dev_kfree_skb(skb);
32314 return -EINVAL;
32315 }
32316 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32317 break;
32318 default:
32319 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32320 - atomic_inc(&vcc->stats->tx_err);
32321 + atomic_inc_unchecked(&vcc->stats->tx_err);
32322 dev_kfree_skb(skb);
32323 return -EINVAL;
32324 }
32325
32326 if (skb_shinfo(skb)->nr_frags != 0) {
32327 printk("%s: No scatter-gather yet.\n", card->name);
32328 - atomic_inc(&vcc->stats->tx_err);
32329 + atomic_inc_unchecked(&vcc->stats->tx_err);
32330 dev_kfree_skb(skb);
32331 return -EINVAL;
32332 }
32333 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32334
32335 err = queue_skb(card, vc, skb, oam);
32336 if (err) {
32337 - atomic_inc(&vcc->stats->tx_err);
32338 + atomic_inc_unchecked(&vcc->stats->tx_err);
32339 dev_kfree_skb(skb);
32340 return err;
32341 }
32342 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32343 skb = dev_alloc_skb(64);
32344 if (!skb) {
32345 printk("%s: Out of memory in send_oam().\n", card->name);
32346 - atomic_inc(&vcc->stats->tx_err);
32347 + atomic_inc_unchecked(&vcc->stats->tx_err);
32348 return -ENOMEM;
32349 }
32350 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32351 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32352 index 4217f29..88f547a 100644
32353 --- a/drivers/atm/iphase.c
32354 +++ b/drivers/atm/iphase.c
32355 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32356 status = (u_short) (buf_desc_ptr->desc_mode);
32357 if (status & (RX_CER | RX_PTE | RX_OFL))
32358 {
32359 - atomic_inc(&vcc->stats->rx_err);
32360 + atomic_inc_unchecked(&vcc->stats->rx_err);
32361 IF_ERR(printk("IA: bad packet, dropping it");)
32362 if (status & RX_CER) {
32363 IF_ERR(printk(" cause: packet CRC error\n");)
32364 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32365 len = dma_addr - buf_addr;
32366 if (len > iadev->rx_buf_sz) {
32367 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32368 - atomic_inc(&vcc->stats->rx_err);
32369 + atomic_inc_unchecked(&vcc->stats->rx_err);
32370 goto out_free_desc;
32371 }
32372
32373 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32374 ia_vcc = INPH_IA_VCC(vcc);
32375 if (ia_vcc == NULL)
32376 {
32377 - atomic_inc(&vcc->stats->rx_err);
32378 + atomic_inc_unchecked(&vcc->stats->rx_err);
32379 atm_return(vcc, skb->truesize);
32380 dev_kfree_skb_any(skb);
32381 goto INCR_DLE;
32382 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32383 if ((length > iadev->rx_buf_sz) || (length >
32384 (skb->len - sizeof(struct cpcs_trailer))))
32385 {
32386 - atomic_inc(&vcc->stats->rx_err);
32387 + atomic_inc_unchecked(&vcc->stats->rx_err);
32388 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32389 length, skb->len);)
32390 atm_return(vcc, skb->truesize);
32391 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32392
32393 IF_RX(printk("rx_dle_intr: skb push");)
32394 vcc->push(vcc,skb);
32395 - atomic_inc(&vcc->stats->rx);
32396 + atomic_inc_unchecked(&vcc->stats->rx);
32397 iadev->rx_pkt_cnt++;
32398 }
32399 INCR_DLE:
32400 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32401 {
32402 struct k_sonet_stats *stats;
32403 stats = &PRIV(_ia_dev[board])->sonet_stats;
32404 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32405 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32406 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32407 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32408 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32409 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32410 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32411 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32412 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32413 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32414 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32415 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32416 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32417 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32418 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32419 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32420 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32421 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32422 }
32423 ia_cmds.status = 0;
32424 break;
32425 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32426 if ((desc == 0) || (desc > iadev->num_tx_desc))
32427 {
32428 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32429 - atomic_inc(&vcc->stats->tx);
32430 + atomic_inc_unchecked(&vcc->stats->tx);
32431 if (vcc->pop)
32432 vcc->pop(vcc, skb);
32433 else
32434 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32435 ATM_DESC(skb) = vcc->vci;
32436 skb_queue_tail(&iadev->tx_dma_q, skb);
32437
32438 - atomic_inc(&vcc->stats->tx);
32439 + atomic_inc_unchecked(&vcc->stats->tx);
32440 iadev->tx_pkt_cnt++;
32441 /* Increment transaction counter */
32442 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32443
32444 #if 0
32445 /* add flow control logic */
32446 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32447 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32448 if (iavcc->vc_desc_cnt > 10) {
32449 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32450 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32451 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32452 index fa7d701..1e404c7 100644
32453 --- a/drivers/atm/lanai.c
32454 +++ b/drivers/atm/lanai.c
32455 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32456 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32457 lanai_endtx(lanai, lvcc);
32458 lanai_free_skb(lvcc->tx.atmvcc, skb);
32459 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32460 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32461 }
32462
32463 /* Try to fill the buffer - don't call unless there is backlog */
32464 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
32465 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
32466 __net_timestamp(skb);
32467 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
32468 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
32469 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
32470 out:
32471 lvcc->rx.buf.ptr = end;
32472 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
32473 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32474 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
32475 "vcc %d\n", lanai->number, (unsigned int) s, vci);
32476 lanai->stats.service_rxnotaal5++;
32477 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32478 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32479 return 0;
32480 }
32481 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
32482 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32483 int bytes;
32484 read_unlock(&vcc_sklist_lock);
32485 DPRINTK("got trashed rx pdu on vci %d\n", vci);
32486 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32487 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32488 lvcc->stats.x.aal5.service_trash++;
32489 bytes = (SERVICE_GET_END(s) * 16) -
32490 (((unsigned long) lvcc->rx.buf.ptr) -
32491 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32492 }
32493 if (s & SERVICE_STREAM) {
32494 read_unlock(&vcc_sklist_lock);
32495 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32496 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32497 lvcc->stats.x.aal5.service_stream++;
32498 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
32499 "PDU on VCI %d!\n", lanai->number, vci);
32500 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32501 return 0;
32502 }
32503 DPRINTK("got rx crc error on vci %d\n", vci);
32504 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32505 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32506 lvcc->stats.x.aal5.service_rxcrc++;
32507 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
32508 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
32509 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
32510 index 6587dc2..149833d 100644
32511 --- a/drivers/atm/nicstar.c
32512 +++ b/drivers/atm/nicstar.c
32513 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32514 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
32515 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
32516 card->index);
32517 - atomic_inc(&vcc->stats->tx_err);
32518 + atomic_inc_unchecked(&vcc->stats->tx_err);
32519 dev_kfree_skb_any(skb);
32520 return -EINVAL;
32521 }
32522 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32523 if (!vc->tx) {
32524 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
32525 card->index);
32526 - atomic_inc(&vcc->stats->tx_err);
32527 + atomic_inc_unchecked(&vcc->stats->tx_err);
32528 dev_kfree_skb_any(skb);
32529 return -EINVAL;
32530 }
32531 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32532 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
32533 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
32534 card->index);
32535 - atomic_inc(&vcc->stats->tx_err);
32536 + atomic_inc_unchecked(&vcc->stats->tx_err);
32537 dev_kfree_skb_any(skb);
32538 return -EINVAL;
32539 }
32540
32541 if (skb_shinfo(skb)->nr_frags != 0) {
32542 printk("nicstar%d: No scatter-gather yet.\n", card->index);
32543 - atomic_inc(&vcc->stats->tx_err);
32544 + atomic_inc_unchecked(&vcc->stats->tx_err);
32545 dev_kfree_skb_any(skb);
32546 return -EINVAL;
32547 }
32548 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32549 }
32550
32551 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
32552 - atomic_inc(&vcc->stats->tx_err);
32553 + atomic_inc_unchecked(&vcc->stats->tx_err);
32554 dev_kfree_skb_any(skb);
32555 return -EIO;
32556 }
32557 - atomic_inc(&vcc->stats->tx);
32558 + atomic_inc_unchecked(&vcc->stats->tx);
32559
32560 return 0;
32561 }
32562 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32563 printk
32564 ("nicstar%d: Can't allocate buffers for aal0.\n",
32565 card->index);
32566 - atomic_add(i, &vcc->stats->rx_drop);
32567 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32568 break;
32569 }
32570 if (!atm_charge(vcc, sb->truesize)) {
32571 RXPRINTK
32572 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
32573 card->index);
32574 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32575 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32576 dev_kfree_skb_any(sb);
32577 break;
32578 }
32579 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32580 ATM_SKB(sb)->vcc = vcc;
32581 __net_timestamp(sb);
32582 vcc->push(vcc, sb);
32583 - atomic_inc(&vcc->stats->rx);
32584 + atomic_inc_unchecked(&vcc->stats->rx);
32585 cell += ATM_CELL_PAYLOAD;
32586 }
32587
32588 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32589 if (iovb == NULL) {
32590 printk("nicstar%d: Out of iovec buffers.\n",
32591 card->index);
32592 - atomic_inc(&vcc->stats->rx_drop);
32593 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32594 recycle_rx_buf(card, skb);
32595 return;
32596 }
32597 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32598 small or large buffer itself. */
32599 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
32600 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
32601 - atomic_inc(&vcc->stats->rx_err);
32602 + atomic_inc_unchecked(&vcc->stats->rx_err);
32603 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32604 NS_MAX_IOVECS);
32605 NS_PRV_IOVCNT(iovb) = 0;
32606 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32607 ("nicstar%d: Expected a small buffer, and this is not one.\n",
32608 card->index);
32609 which_list(card, skb);
32610 - atomic_inc(&vcc->stats->rx_err);
32611 + atomic_inc_unchecked(&vcc->stats->rx_err);
32612 recycle_rx_buf(card, skb);
32613 vc->rx_iov = NULL;
32614 recycle_iov_buf(card, iovb);
32615 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32616 ("nicstar%d: Expected a large buffer, and this is not one.\n",
32617 card->index);
32618 which_list(card, skb);
32619 - atomic_inc(&vcc->stats->rx_err);
32620 + atomic_inc_unchecked(&vcc->stats->rx_err);
32621 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32622 NS_PRV_IOVCNT(iovb));
32623 vc->rx_iov = NULL;
32624 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32625 printk(" - PDU size mismatch.\n");
32626 else
32627 printk(".\n");
32628 - atomic_inc(&vcc->stats->rx_err);
32629 + atomic_inc_unchecked(&vcc->stats->rx_err);
32630 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32631 NS_PRV_IOVCNT(iovb));
32632 vc->rx_iov = NULL;
32633 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32634 /* skb points to a small buffer */
32635 if (!atm_charge(vcc, skb->truesize)) {
32636 push_rxbufs(card, skb);
32637 - atomic_inc(&vcc->stats->rx_drop);
32638 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32639 } else {
32640 skb_put(skb, len);
32641 dequeue_sm_buf(card, skb);
32642 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32643 ATM_SKB(skb)->vcc = vcc;
32644 __net_timestamp(skb);
32645 vcc->push(vcc, skb);
32646 - atomic_inc(&vcc->stats->rx);
32647 + atomic_inc_unchecked(&vcc->stats->rx);
32648 }
32649 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
32650 struct sk_buff *sb;
32651 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32652 if (len <= NS_SMBUFSIZE) {
32653 if (!atm_charge(vcc, sb->truesize)) {
32654 push_rxbufs(card, sb);
32655 - atomic_inc(&vcc->stats->rx_drop);
32656 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32657 } else {
32658 skb_put(sb, len);
32659 dequeue_sm_buf(card, sb);
32660 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32661 ATM_SKB(sb)->vcc = vcc;
32662 __net_timestamp(sb);
32663 vcc->push(vcc, sb);
32664 - atomic_inc(&vcc->stats->rx);
32665 + atomic_inc_unchecked(&vcc->stats->rx);
32666 }
32667
32668 push_rxbufs(card, skb);
32669 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32670
32671 if (!atm_charge(vcc, skb->truesize)) {
32672 push_rxbufs(card, skb);
32673 - atomic_inc(&vcc->stats->rx_drop);
32674 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32675 } else {
32676 dequeue_lg_buf(card, skb);
32677 #ifdef NS_USE_DESTRUCTORS
32678 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32679 ATM_SKB(skb)->vcc = vcc;
32680 __net_timestamp(skb);
32681 vcc->push(vcc, skb);
32682 - atomic_inc(&vcc->stats->rx);
32683 + atomic_inc_unchecked(&vcc->stats->rx);
32684 }
32685
32686 push_rxbufs(card, sb);
32687 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32688 printk
32689 ("nicstar%d: Out of huge buffers.\n",
32690 card->index);
32691 - atomic_inc(&vcc->stats->rx_drop);
32692 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32693 recycle_iovec_rx_bufs(card,
32694 (struct iovec *)
32695 iovb->data,
32696 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32697 card->hbpool.count++;
32698 } else
32699 dev_kfree_skb_any(hb);
32700 - atomic_inc(&vcc->stats->rx_drop);
32701 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32702 } else {
32703 /* Copy the small buffer to the huge buffer */
32704 sb = (struct sk_buff *)iov->iov_base;
32705 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32706 #endif /* NS_USE_DESTRUCTORS */
32707 __net_timestamp(hb);
32708 vcc->push(vcc, hb);
32709 - atomic_inc(&vcc->stats->rx);
32710 + atomic_inc_unchecked(&vcc->stats->rx);
32711 }
32712 }
32713
32714 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
32715 index 32784d1..4a8434a 100644
32716 --- a/drivers/atm/solos-pci.c
32717 +++ b/drivers/atm/solos-pci.c
32718 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
32719 }
32720 atm_charge(vcc, skb->truesize);
32721 vcc->push(vcc, skb);
32722 - atomic_inc(&vcc->stats->rx);
32723 + atomic_inc_unchecked(&vcc->stats->rx);
32724 break;
32725
32726 case PKT_STATUS:
32727 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
32728 vcc = SKB_CB(oldskb)->vcc;
32729
32730 if (vcc) {
32731 - atomic_inc(&vcc->stats->tx);
32732 + atomic_inc_unchecked(&vcc->stats->tx);
32733 solos_pop(vcc, oldskb);
32734 } else {
32735 dev_kfree_skb_irq(oldskb);
32736 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
32737 index 0215934..ce9f5b1 100644
32738 --- a/drivers/atm/suni.c
32739 +++ b/drivers/atm/suni.c
32740 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
32741
32742
32743 #define ADD_LIMITED(s,v) \
32744 - atomic_add((v),&stats->s); \
32745 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
32746 + atomic_add_unchecked((v),&stats->s); \
32747 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
32748
32749
32750 static void suni_hz(unsigned long from_timer)
32751 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
32752 index 5120a96..e2572bd 100644
32753 --- a/drivers/atm/uPD98402.c
32754 +++ b/drivers/atm/uPD98402.c
32755 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
32756 struct sonet_stats tmp;
32757 int error = 0;
32758
32759 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
32760 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
32761 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
32762 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
32763 if (zero && !error) {
32764 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
32765
32766
32767 #define ADD_LIMITED(s,v) \
32768 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
32769 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
32770 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
32771 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
32772 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
32773 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
32774
32775
32776 static void stat_event(struct atm_dev *dev)
32777 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
32778 if (reason & uPD98402_INT_PFM) stat_event(dev);
32779 if (reason & uPD98402_INT_PCO) {
32780 (void) GET(PCOCR); /* clear interrupt cause */
32781 - atomic_add(GET(HECCT),
32782 + atomic_add_unchecked(GET(HECCT),
32783 &PRIV(dev)->sonet_stats.uncorr_hcs);
32784 }
32785 if ((reason & uPD98402_INT_RFO) &&
32786 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
32787 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
32788 uPD98402_INT_LOS),PIMR); /* enable them */
32789 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
32790 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
32791 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
32792 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
32793 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
32794 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
32795 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
32796 return 0;
32797 }
32798
32799 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
32800 index 969c3c2..9b72956 100644
32801 --- a/drivers/atm/zatm.c
32802 +++ b/drivers/atm/zatm.c
32803 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
32804 }
32805 if (!size) {
32806 dev_kfree_skb_irq(skb);
32807 - if (vcc) atomic_inc(&vcc->stats->rx_err);
32808 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
32809 continue;
32810 }
32811 if (!atm_charge(vcc,skb->truesize)) {
32812 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
32813 skb->len = size;
32814 ATM_SKB(skb)->vcc = vcc;
32815 vcc->push(vcc,skb);
32816 - atomic_inc(&vcc->stats->rx);
32817 + atomic_inc_unchecked(&vcc->stats->rx);
32818 }
32819 zout(pos & 0xffff,MTA(mbx));
32820 #if 0 /* probably a stupid idea */
32821 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
32822 skb_queue_head(&zatm_vcc->backlog,skb);
32823 break;
32824 }
32825 - atomic_inc(&vcc->stats->tx);
32826 + atomic_inc_unchecked(&vcc->stats->tx);
32827 wake_up(&zatm_vcc->tx_wait);
32828 }
32829
32830 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
32831 index 519865b..e540db3 100644
32832 --- a/drivers/base/bus.c
32833 +++ b/drivers/base/bus.c
32834 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
32835 return -EINVAL;
32836
32837 mutex_lock(&subsys->p->mutex);
32838 - list_add_tail(&sif->node, &subsys->p->interfaces);
32839 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
32840 if (sif->add_dev) {
32841 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
32842 while ((dev = subsys_dev_iter_next(&iter)))
32843 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
32844 subsys = sif->subsys;
32845
32846 mutex_lock(&subsys->p->mutex);
32847 - list_del_init(&sif->node);
32848 + pax_list_del_init((struct list_head *)&sif->node);
32849 if (sif->remove_dev) {
32850 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
32851 while ((dev = subsys_dev_iter_next(&iter)))
32852 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
32853 index 01fc5b0..d0ed716 100644
32854 --- a/drivers/base/devtmpfs.c
32855 +++ b/drivers/base/devtmpfs.c
32856 @@ -348,7 +348,7 @@ int devtmpfs_mount(const char *mntdir)
32857 if (!thread)
32858 return 0;
32859
32860 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
32861 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
32862 if (err)
32863 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
32864 else
32865 diff --git a/drivers/base/node.c b/drivers/base/node.c
32866 index fac124a..66bd4ab 100644
32867 --- a/drivers/base/node.c
32868 +++ b/drivers/base/node.c
32869 @@ -625,7 +625,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
32870 struct node_attr {
32871 struct device_attribute attr;
32872 enum node_states state;
32873 -};
32874 +} __do_const;
32875
32876 static ssize_t show_node_state(struct device *dev,
32877 struct device_attribute *attr, char *buf)
32878 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
32879 index 9a6b05a..2fc8fb9 100644
32880 --- a/drivers/base/power/domain.c
32881 +++ b/drivers/base/power/domain.c
32882 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
32883 {
32884 struct cpuidle_driver *cpuidle_drv;
32885 struct gpd_cpu_data *cpu_data;
32886 - struct cpuidle_state *idle_state;
32887 + cpuidle_state_no_const *idle_state;
32888 int ret = 0;
32889
32890 if (IS_ERR_OR_NULL(genpd) || state < 0)
32891 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
32892 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
32893 {
32894 struct gpd_cpu_data *cpu_data;
32895 - struct cpuidle_state *idle_state;
32896 + cpuidle_state_no_const *idle_state;
32897 int ret = 0;
32898
32899 if (IS_ERR_OR_NULL(genpd))
32900 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
32901 index 79715e7..df06b3b 100644
32902 --- a/drivers/base/power/wakeup.c
32903 +++ b/drivers/base/power/wakeup.c
32904 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
32905 * They need to be modified together atomically, so it's better to use one
32906 * atomic variable to hold them both.
32907 */
32908 -static atomic_t combined_event_count = ATOMIC_INIT(0);
32909 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
32910
32911 #define IN_PROGRESS_BITS (sizeof(int) * 4)
32912 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
32913
32914 static void split_counters(unsigned int *cnt, unsigned int *inpr)
32915 {
32916 - unsigned int comb = atomic_read(&combined_event_count);
32917 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
32918
32919 *cnt = (comb >> IN_PROGRESS_BITS);
32920 *inpr = comb & MAX_IN_PROGRESS;
32921 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
32922 ws->start_prevent_time = ws->last_time;
32923
32924 /* Increment the counter of events in progress. */
32925 - cec = atomic_inc_return(&combined_event_count);
32926 + cec = atomic_inc_return_unchecked(&combined_event_count);
32927
32928 trace_wakeup_source_activate(ws->name, cec);
32929 }
32930 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
32931 * Increment the counter of registered wakeup events and decrement the
32932 * couter of wakeup events in progress simultaneously.
32933 */
32934 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
32935 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
32936 trace_wakeup_source_deactivate(ws->name, cec);
32937
32938 split_counters(&cnt, &inpr);
32939 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
32940 index e8d11b6..7b1b36f 100644
32941 --- a/drivers/base/syscore.c
32942 +++ b/drivers/base/syscore.c
32943 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
32944 void register_syscore_ops(struct syscore_ops *ops)
32945 {
32946 mutex_lock(&syscore_ops_lock);
32947 - list_add_tail(&ops->node, &syscore_ops_list);
32948 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
32949 mutex_unlock(&syscore_ops_lock);
32950 }
32951 EXPORT_SYMBOL_GPL(register_syscore_ops);
32952 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
32953 void unregister_syscore_ops(struct syscore_ops *ops)
32954 {
32955 mutex_lock(&syscore_ops_lock);
32956 - list_del(&ops->node);
32957 + pax_list_del((struct list_head *)&ops->node);
32958 mutex_unlock(&syscore_ops_lock);
32959 }
32960 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
32961 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
32962 index 1c1b8e5..b7fc681 100644
32963 --- a/drivers/block/cciss.c
32964 +++ b/drivers/block/cciss.c
32965 @@ -1196,6 +1196,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
32966 int err;
32967 u32 cp;
32968
32969 + memset(&arg64, 0, sizeof(arg64));
32970 +
32971 err = 0;
32972 err |=
32973 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
32974 @@ -3005,7 +3007,7 @@ static void start_io(ctlr_info_t *h)
32975 while (!list_empty(&h->reqQ)) {
32976 c = list_entry(h->reqQ.next, CommandList_struct, list);
32977 /* can't do anything if fifo is full */
32978 - if ((h->access.fifo_full(h))) {
32979 + if ((h->access->fifo_full(h))) {
32980 dev_warn(&h->pdev->dev, "fifo full\n");
32981 break;
32982 }
32983 @@ -3015,7 +3017,7 @@ static void start_io(ctlr_info_t *h)
32984 h->Qdepth--;
32985
32986 /* Tell the controller execute command */
32987 - h->access.submit_command(h, c);
32988 + h->access->submit_command(h, c);
32989
32990 /* Put job onto the completed Q */
32991 addQ(&h->cmpQ, c);
32992 @@ -3441,17 +3443,17 @@ startio:
32993
32994 static inline unsigned long get_next_completion(ctlr_info_t *h)
32995 {
32996 - return h->access.command_completed(h);
32997 + return h->access->command_completed(h);
32998 }
32999
33000 static inline int interrupt_pending(ctlr_info_t *h)
33001 {
33002 - return h->access.intr_pending(h);
33003 + return h->access->intr_pending(h);
33004 }
33005
33006 static inline long interrupt_not_for_us(ctlr_info_t *h)
33007 {
33008 - return ((h->access.intr_pending(h) == 0) ||
33009 + return ((h->access->intr_pending(h) == 0) ||
33010 (h->interrupts_enabled == 0));
33011 }
33012
33013 @@ -3484,7 +3486,7 @@ static inline u32 next_command(ctlr_info_t *h)
33014 u32 a;
33015
33016 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33017 - return h->access.command_completed(h);
33018 + return h->access->command_completed(h);
33019
33020 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33021 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33022 @@ -4041,7 +4043,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33023 trans_support & CFGTBL_Trans_use_short_tags);
33024
33025 /* Change the access methods to the performant access methods */
33026 - h->access = SA5_performant_access;
33027 + h->access = &SA5_performant_access;
33028 h->transMethod = CFGTBL_Trans_Performant;
33029
33030 return;
33031 @@ -4310,7 +4312,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33032 if (prod_index < 0)
33033 return -ENODEV;
33034 h->product_name = products[prod_index].product_name;
33035 - h->access = *(products[prod_index].access);
33036 + h->access = products[prod_index].access;
33037
33038 if (cciss_board_disabled(h)) {
33039 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33040 @@ -5032,7 +5034,7 @@ reinit_after_soft_reset:
33041 }
33042
33043 /* make sure the board interrupts are off */
33044 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33045 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33046 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33047 if (rc)
33048 goto clean2;
33049 @@ -5082,7 +5084,7 @@ reinit_after_soft_reset:
33050 * fake ones to scoop up any residual completions.
33051 */
33052 spin_lock_irqsave(&h->lock, flags);
33053 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33054 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33055 spin_unlock_irqrestore(&h->lock, flags);
33056 free_irq(h->intr[h->intr_mode], h);
33057 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33058 @@ -5102,9 +5104,9 @@ reinit_after_soft_reset:
33059 dev_info(&h->pdev->dev, "Board READY.\n");
33060 dev_info(&h->pdev->dev,
33061 "Waiting for stale completions to drain.\n");
33062 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33063 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33064 msleep(10000);
33065 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33066 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33067
33068 rc = controller_reset_failed(h->cfgtable);
33069 if (rc)
33070 @@ -5127,7 +5129,7 @@ reinit_after_soft_reset:
33071 cciss_scsi_setup(h);
33072
33073 /* Turn the interrupts on so we can service requests */
33074 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33075 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33076
33077 /* Get the firmware version */
33078 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33079 @@ -5199,7 +5201,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33080 kfree(flush_buf);
33081 if (return_code != IO_OK)
33082 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33083 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33084 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33085 free_irq(h->intr[h->intr_mode], h);
33086 }
33087
33088 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33089 index 7fda30e..eb5dfe0 100644
33090 --- a/drivers/block/cciss.h
33091 +++ b/drivers/block/cciss.h
33092 @@ -101,7 +101,7 @@ struct ctlr_info
33093 /* information about each logical volume */
33094 drive_info_struct *drv[CISS_MAX_LUN];
33095
33096 - struct access_method access;
33097 + struct access_method *access;
33098
33099 /* queue and queue Info */
33100 struct list_head reqQ;
33101 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33102 index 3f08713..56a586a 100644
33103 --- a/drivers/block/cpqarray.c
33104 +++ b/drivers/block/cpqarray.c
33105 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33106 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33107 goto Enomem4;
33108 }
33109 - hba[i]->access.set_intr_mask(hba[i], 0);
33110 + hba[i]->access->set_intr_mask(hba[i], 0);
33111 if (request_irq(hba[i]->intr, do_ida_intr,
33112 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33113 {
33114 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33115 add_timer(&hba[i]->timer);
33116
33117 /* Enable IRQ now that spinlock and rate limit timer are set up */
33118 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33119 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33120
33121 for(j=0; j<NWD; j++) {
33122 struct gendisk *disk = ida_gendisk[i][j];
33123 @@ -694,7 +694,7 @@ DBGINFO(
33124 for(i=0; i<NR_PRODUCTS; i++) {
33125 if (board_id == products[i].board_id) {
33126 c->product_name = products[i].product_name;
33127 - c->access = *(products[i].access);
33128 + c->access = products[i].access;
33129 break;
33130 }
33131 }
33132 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33133 hba[ctlr]->intr = intr;
33134 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33135 hba[ctlr]->product_name = products[j].product_name;
33136 - hba[ctlr]->access = *(products[j].access);
33137 + hba[ctlr]->access = products[j].access;
33138 hba[ctlr]->ctlr = ctlr;
33139 hba[ctlr]->board_id = board_id;
33140 hba[ctlr]->pci_dev = NULL; /* not PCI */
33141 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
33142
33143 while((c = h->reqQ) != NULL) {
33144 /* Can't do anything if we're busy */
33145 - if (h->access.fifo_full(h) == 0)
33146 + if (h->access->fifo_full(h) == 0)
33147 return;
33148
33149 /* Get the first entry from the request Q */
33150 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
33151 h->Qdepth--;
33152
33153 /* Tell the controller to do our bidding */
33154 - h->access.submit_command(h, c);
33155 + h->access->submit_command(h, c);
33156
33157 /* Get onto the completion Q */
33158 addQ(&h->cmpQ, c);
33159 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33160 unsigned long flags;
33161 __u32 a,a1;
33162
33163 - istat = h->access.intr_pending(h);
33164 + istat = h->access->intr_pending(h);
33165 /* Is this interrupt for us? */
33166 if (istat == 0)
33167 return IRQ_NONE;
33168 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33169 */
33170 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33171 if (istat & FIFO_NOT_EMPTY) {
33172 - while((a = h->access.command_completed(h))) {
33173 + while((a = h->access->command_completed(h))) {
33174 a1 = a; a &= ~3;
33175 if ((c = h->cmpQ) == NULL)
33176 {
33177 @@ -1449,11 +1449,11 @@ static int sendcmd(
33178 /*
33179 * Disable interrupt
33180 */
33181 - info_p->access.set_intr_mask(info_p, 0);
33182 + info_p->access->set_intr_mask(info_p, 0);
33183 /* Make sure there is room in the command FIFO */
33184 /* Actually it should be completely empty at this time. */
33185 for (i = 200000; i > 0; i--) {
33186 - temp = info_p->access.fifo_full(info_p);
33187 + temp = info_p->access->fifo_full(info_p);
33188 if (temp != 0) {
33189 break;
33190 }
33191 @@ -1466,7 +1466,7 @@ DBG(
33192 /*
33193 * Send the cmd
33194 */
33195 - info_p->access.submit_command(info_p, c);
33196 + info_p->access->submit_command(info_p, c);
33197 complete = pollcomplete(ctlr);
33198
33199 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33200 @@ -1549,9 +1549,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33201 * we check the new geometry. Then turn interrupts back on when
33202 * we're done.
33203 */
33204 - host->access.set_intr_mask(host, 0);
33205 + host->access->set_intr_mask(host, 0);
33206 getgeometry(ctlr);
33207 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33208 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33209
33210 for(i=0; i<NWD; i++) {
33211 struct gendisk *disk = ida_gendisk[ctlr][i];
33212 @@ -1591,7 +1591,7 @@ static int pollcomplete(int ctlr)
33213 /* Wait (up to 2 seconds) for a command to complete */
33214
33215 for (i = 200000; i > 0; i--) {
33216 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33217 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33218 if (done == 0) {
33219 udelay(10); /* a short fixed delay */
33220 } else
33221 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33222 index be73e9d..7fbf140 100644
33223 --- a/drivers/block/cpqarray.h
33224 +++ b/drivers/block/cpqarray.h
33225 @@ -99,7 +99,7 @@ struct ctlr_info {
33226 drv_info_t drv[NWD];
33227 struct proc_dir_entry *proc;
33228
33229 - struct access_method access;
33230 + struct access_method *access;
33231
33232 cmdlist_t *reqQ;
33233 cmdlist_t *cmpQ;
33234 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33235 index 6b51afa..17e1191 100644
33236 --- a/drivers/block/drbd/drbd_int.h
33237 +++ b/drivers/block/drbd/drbd_int.h
33238 @@ -582,7 +582,7 @@ struct drbd_epoch {
33239 struct drbd_tconn *tconn;
33240 struct list_head list;
33241 unsigned int barrier_nr;
33242 - atomic_t epoch_size; /* increased on every request added. */
33243 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33244 atomic_t active; /* increased on every req. added, and dec on every finished. */
33245 unsigned long flags;
33246 };
33247 @@ -1011,7 +1011,7 @@ struct drbd_conf {
33248 int al_tr_cycle;
33249 int al_tr_pos; /* position of the next transaction in the journal */
33250 wait_queue_head_t seq_wait;
33251 - atomic_t packet_seq;
33252 + atomic_unchecked_t packet_seq;
33253 unsigned int peer_seq;
33254 spinlock_t peer_seq_lock;
33255 unsigned int minor;
33256 @@ -1527,7 +1527,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33257 char __user *uoptval;
33258 int err;
33259
33260 - uoptval = (char __user __force *)optval;
33261 + uoptval = (char __force_user *)optval;
33262
33263 set_fs(KERNEL_DS);
33264 if (level == SOL_SOCKET)
33265 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33266 index e98da67..1181716b 100644
33267 --- a/drivers/block/drbd/drbd_main.c
33268 +++ b/drivers/block/drbd/drbd_main.c
33269 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33270 p->sector = sector;
33271 p->block_id = block_id;
33272 p->blksize = blksize;
33273 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33274 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33275 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33276 }
33277
33278 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33279 return -EIO;
33280 p->sector = cpu_to_be64(req->i.sector);
33281 p->block_id = (unsigned long)req;
33282 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33283 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33284 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33285 if (mdev->state.conn >= C_SYNC_SOURCE &&
33286 mdev->state.conn <= C_PAUSED_SYNC_T)
33287 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33288 {
33289 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33290
33291 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33292 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33293 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33294 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33295 kfree(tconn->current_epoch);
33296
33297 idr_destroy(&tconn->volumes);
33298 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33299 index a9eccfc..f5efe87 100644
33300 --- a/drivers/block/drbd/drbd_receiver.c
33301 +++ b/drivers/block/drbd/drbd_receiver.c
33302 @@ -833,7 +833,7 @@ int drbd_connected(struct drbd_conf *mdev)
33303 {
33304 int err;
33305
33306 - atomic_set(&mdev->packet_seq, 0);
33307 + atomic_set_unchecked(&mdev->packet_seq, 0);
33308 mdev->peer_seq = 0;
33309
33310 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33311 @@ -1191,7 +1191,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33312 do {
33313 next_epoch = NULL;
33314
33315 - epoch_size = atomic_read(&epoch->epoch_size);
33316 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33317
33318 switch (ev & ~EV_CLEANUP) {
33319 case EV_PUT:
33320 @@ -1231,7 +1231,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33321 rv = FE_DESTROYED;
33322 } else {
33323 epoch->flags = 0;
33324 - atomic_set(&epoch->epoch_size, 0);
33325 + atomic_set_unchecked(&epoch->epoch_size, 0);
33326 /* atomic_set(&epoch->active, 0); is already zero */
33327 if (rv == FE_STILL_LIVE)
33328 rv = FE_RECYCLED;
33329 @@ -1449,7 +1449,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33330 conn_wait_active_ee_empty(tconn);
33331 drbd_flush(tconn);
33332
33333 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33334 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33335 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33336 if (epoch)
33337 break;
33338 @@ -1462,11 +1462,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33339 }
33340
33341 epoch->flags = 0;
33342 - atomic_set(&epoch->epoch_size, 0);
33343 + atomic_set_unchecked(&epoch->epoch_size, 0);
33344 atomic_set(&epoch->active, 0);
33345
33346 spin_lock(&tconn->epoch_lock);
33347 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33348 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33349 list_add(&epoch->list, &tconn->current_epoch->list);
33350 tconn->current_epoch = epoch;
33351 tconn->epochs++;
33352 @@ -2170,7 +2170,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33353
33354 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33355 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33356 - atomic_inc(&tconn->current_epoch->epoch_size);
33357 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33358 err2 = drbd_drain_block(mdev, pi->size);
33359 if (!err)
33360 err = err2;
33361 @@ -2204,7 +2204,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33362
33363 spin_lock(&tconn->epoch_lock);
33364 peer_req->epoch = tconn->current_epoch;
33365 - atomic_inc(&peer_req->epoch->epoch_size);
33366 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33367 atomic_inc(&peer_req->epoch->active);
33368 spin_unlock(&tconn->epoch_lock);
33369
33370 @@ -4346,7 +4346,7 @@ struct data_cmd {
33371 int expect_payload;
33372 size_t pkt_size;
33373 int (*fn)(struct drbd_tconn *, struct packet_info *);
33374 -};
33375 +} __do_const;
33376
33377 static struct data_cmd drbd_cmd_handler[] = {
33378 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33379 @@ -4466,7 +4466,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33380 if (!list_empty(&tconn->current_epoch->list))
33381 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33382 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33383 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33384 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33385 tconn->send.seen_any_write_yet = false;
33386
33387 conn_info(tconn, "Connection closed\n");
33388 @@ -5222,7 +5222,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33389 struct asender_cmd {
33390 size_t pkt_size;
33391 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33392 -};
33393 +} __do_const;
33394
33395 static struct asender_cmd asender_tbl[] = {
33396 [P_PING] = { 0, got_Ping },
33397 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33398 index dfe7583..83768bb 100644
33399 --- a/drivers/block/loop.c
33400 +++ b/drivers/block/loop.c
33401 @@ -231,7 +231,7 @@ static int __do_lo_send_write(struct file *file,
33402 mm_segment_t old_fs = get_fs();
33403
33404 set_fs(get_ds());
33405 - bw = file->f_op->write(file, buf, len, &pos);
33406 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33407 set_fs(old_fs);
33408 if (likely(bw == len))
33409 return 0;
33410 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
33411 index 2e7de7a..ed86dc0 100644
33412 --- a/drivers/block/pktcdvd.c
33413 +++ b/drivers/block/pktcdvd.c
33414 @@ -83,7 +83,7 @@
33415
33416 #define MAX_SPEED 0xffff
33417
33418 -#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1))
33419 +#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1UL))
33420
33421 static DEFINE_MUTEX(pktcdvd_mutex);
33422 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
33423 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33424 index d620b44..587561e 100644
33425 --- a/drivers/cdrom/cdrom.c
33426 +++ b/drivers/cdrom/cdrom.c
33427 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33428 ENSURE(reset, CDC_RESET);
33429 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33430 cdi->mc_flags = 0;
33431 - cdo->n_minors = 0;
33432 cdi->options = CDO_USE_FFLAGS;
33433
33434 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33435 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33436 else
33437 cdi->cdda_method = CDDA_OLD;
33438
33439 - if (!cdo->generic_packet)
33440 - cdo->generic_packet = cdrom_dummy_generic_packet;
33441 + if (!cdo->generic_packet) {
33442 + pax_open_kernel();
33443 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33444 + pax_close_kernel();
33445 + }
33446
33447 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33448 mutex_lock(&cdrom_mutex);
33449 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33450 if (cdi->exit)
33451 cdi->exit(cdi);
33452
33453 - cdi->ops->n_minors--;
33454 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33455 }
33456
33457 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33458 index d59cdcb..11afddf 100644
33459 --- a/drivers/cdrom/gdrom.c
33460 +++ b/drivers/cdrom/gdrom.c
33461 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33462 .audio_ioctl = gdrom_audio_ioctl,
33463 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33464 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33465 - .n_minors = 1,
33466 };
33467
33468 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33469 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33470 index 3bb6fa3..34013fb 100644
33471 --- a/drivers/char/Kconfig
33472 +++ b/drivers/char/Kconfig
33473 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
33474
33475 config DEVKMEM
33476 bool "/dev/kmem virtual device support"
33477 - default y
33478 + default n
33479 + depends on !GRKERNSEC_KMEM
33480 help
33481 Say Y here if you want to support the /dev/kmem device. The
33482 /dev/kmem device is rarely used, but can be used for certain
33483 @@ -582,6 +583,7 @@ config DEVPORT
33484 bool
33485 depends on !M68K
33486 depends on ISA || PCI
33487 + depends on !GRKERNSEC_KMEM
33488 default y
33489
33490 source "drivers/s390/char/Kconfig"
33491 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
33492 index 2e04433..22afc64 100644
33493 --- a/drivers/char/agp/frontend.c
33494 +++ b/drivers/char/agp/frontend.c
33495 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33496 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
33497 return -EFAULT;
33498
33499 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
33500 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
33501 return -EFAULT;
33502
33503 client = agp_find_client_by_pid(reserve.pid);
33504 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
33505 index 21cb980..f15107c 100644
33506 --- a/drivers/char/genrtc.c
33507 +++ b/drivers/char/genrtc.c
33508 @@ -272,6 +272,7 @@ static int gen_rtc_ioctl(struct file *file,
33509 switch (cmd) {
33510
33511 case RTC_PLL_GET:
33512 + memset(&pll, 0, sizeof(pll));
33513 if (get_rtc_pll(&pll))
33514 return -EINVAL;
33515 else
33516 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
33517 index d784650..e8bfd69 100644
33518 --- a/drivers/char/hpet.c
33519 +++ b/drivers/char/hpet.c
33520 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
33521 }
33522
33523 static int
33524 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
33525 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
33526 struct hpet_info *info)
33527 {
33528 struct hpet_timer __iomem *timer;
33529 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
33530 index 053201b0..8335cce 100644
33531 --- a/drivers/char/ipmi/ipmi_msghandler.c
33532 +++ b/drivers/char/ipmi/ipmi_msghandler.c
33533 @@ -420,7 +420,7 @@ struct ipmi_smi {
33534 struct proc_dir_entry *proc_dir;
33535 char proc_dir_name[10];
33536
33537 - atomic_t stats[IPMI_NUM_STATS];
33538 + atomic_unchecked_t stats[IPMI_NUM_STATS];
33539
33540 /*
33541 * run_to_completion duplicate of smb_info, smi_info
33542 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
33543
33544
33545 #define ipmi_inc_stat(intf, stat) \
33546 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
33547 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
33548 #define ipmi_get_stat(intf, stat) \
33549 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
33550 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
33551
33552 static int is_lan_addr(struct ipmi_addr *addr)
33553 {
33554 @@ -2884,7 +2884,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
33555 INIT_LIST_HEAD(&intf->cmd_rcvrs);
33556 init_waitqueue_head(&intf->waitq);
33557 for (i = 0; i < IPMI_NUM_STATS; i++)
33558 - atomic_set(&intf->stats[i], 0);
33559 + atomic_set_unchecked(&intf->stats[i], 0);
33560
33561 intf->proc_dir = NULL;
33562
33563 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
33564 index 0ac9b45..6179fb5 100644
33565 --- a/drivers/char/ipmi/ipmi_si_intf.c
33566 +++ b/drivers/char/ipmi/ipmi_si_intf.c
33567 @@ -275,7 +275,7 @@ struct smi_info {
33568 unsigned char slave_addr;
33569
33570 /* Counters and things for the proc filesystem. */
33571 - atomic_t stats[SI_NUM_STATS];
33572 + atomic_unchecked_t stats[SI_NUM_STATS];
33573
33574 struct task_struct *thread;
33575
33576 @@ -284,9 +284,9 @@ struct smi_info {
33577 };
33578
33579 #define smi_inc_stat(smi, stat) \
33580 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
33581 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
33582 #define smi_get_stat(smi, stat) \
33583 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
33584 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
33585
33586 #define SI_MAX_PARMS 4
33587
33588 @@ -3254,7 +3254,7 @@ static int try_smi_init(struct smi_info *new_smi)
33589 atomic_set(&new_smi->req_events, 0);
33590 new_smi->run_to_completion = 0;
33591 for (i = 0; i < SI_NUM_STATS; i++)
33592 - atomic_set(&new_smi->stats[i], 0);
33593 + atomic_set_unchecked(&new_smi->stats[i], 0);
33594
33595 new_smi->interrupt_disabled = 1;
33596 atomic_set(&new_smi->stop_operation, 0);
33597 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
33598 index 2c644af..b867b3e 100644
33599 --- a/drivers/char/mem.c
33600 +++ b/drivers/char/mem.c
33601 @@ -18,6 +18,7 @@
33602 #include <linux/raw.h>
33603 #include <linux/tty.h>
33604 #include <linux/capability.h>
33605 +#include <linux/security.h>
33606 #include <linux/ptrace.h>
33607 #include <linux/device.h>
33608 #include <linux/highmem.h>
33609 @@ -37,6 +38,10 @@
33610
33611 #define DEVPORT_MINOR 4
33612
33613 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33614 +extern const struct file_operations grsec_fops;
33615 +#endif
33616 +
33617 static inline unsigned long size_inside_page(unsigned long start,
33618 unsigned long size)
33619 {
33620 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33621
33622 while (cursor < to) {
33623 if (!devmem_is_allowed(pfn)) {
33624 +#ifdef CONFIG_GRKERNSEC_KMEM
33625 + gr_handle_mem_readwrite(from, to);
33626 +#else
33627 printk(KERN_INFO
33628 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
33629 current->comm, from, to);
33630 +#endif
33631 return 0;
33632 }
33633 cursor += PAGE_SIZE;
33634 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33635 }
33636 return 1;
33637 }
33638 +#elif defined(CONFIG_GRKERNSEC_KMEM)
33639 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33640 +{
33641 + return 0;
33642 +}
33643 #else
33644 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33645 {
33646 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33647
33648 while (count > 0) {
33649 unsigned long remaining;
33650 + char *temp;
33651
33652 sz = size_inside_page(p, count);
33653
33654 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33655 if (!ptr)
33656 return -EFAULT;
33657
33658 - remaining = copy_to_user(buf, ptr, sz);
33659 +#ifdef CONFIG_PAX_USERCOPY
33660 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
33661 + if (!temp) {
33662 + unxlate_dev_mem_ptr(p, ptr);
33663 + return -ENOMEM;
33664 + }
33665 + memcpy(temp, ptr, sz);
33666 +#else
33667 + temp = ptr;
33668 +#endif
33669 +
33670 + remaining = copy_to_user(buf, temp, sz);
33671 +
33672 +#ifdef CONFIG_PAX_USERCOPY
33673 + kfree(temp);
33674 +#endif
33675 +
33676 unxlate_dev_mem_ptr(p, ptr);
33677 if (remaining)
33678 return -EFAULT;
33679 @@ -398,9 +429,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33680 size_t count, loff_t *ppos)
33681 {
33682 unsigned long p = *ppos;
33683 - ssize_t low_count, read, sz;
33684 + ssize_t low_count, read, sz, err = 0;
33685 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
33686 - int err = 0;
33687
33688 read = 0;
33689 if (p < (unsigned long) high_memory) {
33690 @@ -422,6 +452,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33691 }
33692 #endif
33693 while (low_count > 0) {
33694 + char *temp;
33695 +
33696 sz = size_inside_page(p, low_count);
33697
33698 /*
33699 @@ -431,7 +463,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33700 */
33701 kbuf = xlate_dev_kmem_ptr((char *)p);
33702
33703 - if (copy_to_user(buf, kbuf, sz))
33704 +#ifdef CONFIG_PAX_USERCOPY
33705 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
33706 + if (!temp)
33707 + return -ENOMEM;
33708 + memcpy(temp, kbuf, sz);
33709 +#else
33710 + temp = kbuf;
33711 +#endif
33712 +
33713 + err = copy_to_user(buf, temp, sz);
33714 +
33715 +#ifdef CONFIG_PAX_USERCOPY
33716 + kfree(temp);
33717 +#endif
33718 +
33719 + if (err)
33720 return -EFAULT;
33721 buf += sz;
33722 p += sz;
33723 @@ -833,6 +880,9 @@ static const struct memdev {
33724 #ifdef CONFIG_CRASH_DUMP
33725 [12] = { "oldmem", 0, &oldmem_fops, NULL },
33726 #endif
33727 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33728 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
33729 +#endif
33730 };
33731
33732 static int memory_open(struct inode *inode, struct file *filp)
33733 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
33734 index 9df78e2..01ba9ae 100644
33735 --- a/drivers/char/nvram.c
33736 +++ b/drivers/char/nvram.c
33737 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
33738
33739 spin_unlock_irq(&rtc_lock);
33740
33741 - if (copy_to_user(buf, contents, tmp - contents))
33742 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
33743 return -EFAULT;
33744
33745 *ppos = i;
33746 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
33747 index 5c5cc00..ac9edb7 100644
33748 --- a/drivers/char/pcmcia/synclink_cs.c
33749 +++ b/drivers/char/pcmcia/synclink_cs.c
33750 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
33751
33752 if (debug_level >= DEBUG_LEVEL_INFO)
33753 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
33754 - __FILE__, __LINE__, info->device_name, port->count);
33755 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
33756
33757 - WARN_ON(!port->count);
33758 + WARN_ON(!atomic_read(&port->count));
33759
33760 if (tty_port_close_start(port, tty, filp) == 0)
33761 goto cleanup;
33762 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
33763 cleanup:
33764 if (debug_level >= DEBUG_LEVEL_INFO)
33765 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
33766 - tty->driver->name, port->count);
33767 + tty->driver->name, atomic_read(&port->count));
33768 }
33769
33770 /* Wait until the transmitter is empty.
33771 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
33772
33773 if (debug_level >= DEBUG_LEVEL_INFO)
33774 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
33775 - __FILE__, __LINE__, tty->driver->name, port->count);
33776 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
33777
33778 /* If port is closing, signal caller to try again */
33779 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
33780 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
33781 goto cleanup;
33782 }
33783 spin_lock(&port->lock);
33784 - port->count++;
33785 + atomic_inc(&port->count);
33786 spin_unlock(&port->lock);
33787 spin_unlock_irqrestore(&info->netlock, flags);
33788
33789 - if (port->count == 1) {
33790 + if (atomic_read(&port->count) == 1) {
33791 /* 1st open on this device, init hardware */
33792 retval = startup(info, tty);
33793 if (retval < 0)
33794 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
33795 unsigned short new_crctype;
33796
33797 /* return error if TTY interface open */
33798 - if (info->port.count)
33799 + if (atomic_read(&info->port.count))
33800 return -EBUSY;
33801
33802 switch (encoding)
33803 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
33804
33805 /* arbitrate between network and tty opens */
33806 spin_lock_irqsave(&info->netlock, flags);
33807 - if (info->port.count != 0 || info->netcount != 0) {
33808 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
33809 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
33810 spin_unlock_irqrestore(&info->netlock, flags);
33811 return -EBUSY;
33812 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
33813 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
33814
33815 /* return error if TTY interface open */
33816 - if (info->port.count)
33817 + if (atomic_read(&info->port.count))
33818 return -EBUSY;
33819
33820 if (cmd != SIOCWANDEV)
33821 diff --git a/drivers/char/random.c b/drivers/char/random.c
33822 index 32a6c57..e7f0f7b 100644
33823 --- a/drivers/char/random.c
33824 +++ b/drivers/char/random.c
33825 @@ -272,8 +272,13 @@
33826 /*
33827 * Configuration information
33828 */
33829 +#ifdef CONFIG_GRKERNSEC_RANDNET
33830 +#define INPUT_POOL_WORDS 512
33831 +#define OUTPUT_POOL_WORDS 128
33832 +#else
33833 #define INPUT_POOL_WORDS 128
33834 #define OUTPUT_POOL_WORDS 32
33835 +#endif
33836 #define SEC_XFER_SIZE 512
33837 #define EXTRACT_SIZE 10
33838
33839 @@ -313,10 +318,17 @@ static struct poolinfo {
33840 int poolwords;
33841 int tap1, tap2, tap3, tap4, tap5;
33842 } poolinfo_table[] = {
33843 +#ifdef CONFIG_GRKERNSEC_RANDNET
33844 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
33845 + { 512, 411, 308, 208, 104, 1 },
33846 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
33847 + { 128, 103, 76, 51, 25, 1 },
33848 +#else
33849 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
33850 { 128, 103, 76, 51, 25, 1 },
33851 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
33852 { 32, 26, 20, 14, 7, 1 },
33853 +#endif
33854 #if 0
33855 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
33856 { 2048, 1638, 1231, 819, 411, 1 },
33857 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
33858 input_rotate += i ? 7 : 14;
33859 }
33860
33861 - ACCESS_ONCE(r->input_rotate) = input_rotate;
33862 - ACCESS_ONCE(r->add_ptr) = i;
33863 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
33864 + ACCESS_ONCE_RW(r->add_ptr) = i;
33865 smp_wmb();
33866
33867 if (out)
33868 @@ -1024,7 +1036,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
33869
33870 extract_buf(r, tmp);
33871 i = min_t(int, nbytes, EXTRACT_SIZE);
33872 - if (copy_to_user(buf, tmp, i)) {
33873 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
33874 ret = -EFAULT;
33875 break;
33876 }
33877 @@ -1360,7 +1372,7 @@ EXPORT_SYMBOL(generate_random_uuid);
33878 #include <linux/sysctl.h>
33879
33880 static int min_read_thresh = 8, min_write_thresh;
33881 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
33882 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
33883 static int max_write_thresh = INPUT_POOL_WORDS * 32;
33884 static char sysctl_bootid[16];
33885
33886 @@ -1376,7 +1388,7 @@ static char sysctl_bootid[16];
33887 static int proc_do_uuid(ctl_table *table, int write,
33888 void __user *buffer, size_t *lenp, loff_t *ppos)
33889 {
33890 - ctl_table fake_table;
33891 + ctl_table_no_const fake_table;
33892 unsigned char buf[64], tmp_uuid[16], *uuid;
33893
33894 uuid = table->data;
33895 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
33896 index bf2349db..5456d53 100644
33897 --- a/drivers/char/sonypi.c
33898 +++ b/drivers/char/sonypi.c
33899 @@ -54,6 +54,7 @@
33900
33901 #include <asm/uaccess.h>
33902 #include <asm/io.h>
33903 +#include <asm/local.h>
33904
33905 #include <linux/sonypi.h>
33906
33907 @@ -490,7 +491,7 @@ static struct sonypi_device {
33908 spinlock_t fifo_lock;
33909 wait_queue_head_t fifo_proc_list;
33910 struct fasync_struct *fifo_async;
33911 - int open_count;
33912 + local_t open_count;
33913 int model;
33914 struct input_dev *input_jog_dev;
33915 struct input_dev *input_key_dev;
33916 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
33917 static int sonypi_misc_release(struct inode *inode, struct file *file)
33918 {
33919 mutex_lock(&sonypi_device.lock);
33920 - sonypi_device.open_count--;
33921 + local_dec(&sonypi_device.open_count);
33922 mutex_unlock(&sonypi_device.lock);
33923 return 0;
33924 }
33925 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
33926 {
33927 mutex_lock(&sonypi_device.lock);
33928 /* Flush input queue on first open */
33929 - if (!sonypi_device.open_count)
33930 + if (!local_read(&sonypi_device.open_count))
33931 kfifo_reset(&sonypi_device.fifo);
33932 - sonypi_device.open_count++;
33933 + local_inc(&sonypi_device.open_count);
33934 mutex_unlock(&sonypi_device.lock);
33935
33936 return 0;
33937 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
33938 index 64420b3..5c40b56 100644
33939 --- a/drivers/char/tpm/tpm_acpi.c
33940 +++ b/drivers/char/tpm/tpm_acpi.c
33941 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
33942 virt = acpi_os_map_memory(start, len);
33943 if (!virt) {
33944 kfree(log->bios_event_log);
33945 + log->bios_event_log = NULL;
33946 printk("%s: ERROR - Unable to map memory\n", __func__);
33947 return -EIO;
33948 }
33949
33950 - memcpy_fromio(log->bios_event_log, virt, len);
33951 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
33952
33953 acpi_os_unmap_memory(virt, len);
33954 return 0;
33955 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
33956 index 84ddc55..1d32f1e 100644
33957 --- a/drivers/char/tpm/tpm_eventlog.c
33958 +++ b/drivers/char/tpm/tpm_eventlog.c
33959 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
33960 event = addr;
33961
33962 if ((event->event_type == 0 && event->event_size == 0) ||
33963 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
33964 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
33965 return NULL;
33966
33967 return addr;
33968 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
33969 return NULL;
33970
33971 if ((event->event_type == 0 && event->event_size == 0) ||
33972 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
33973 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
33974 return NULL;
33975
33976 (*pos)++;
33977 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
33978 int i;
33979
33980 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
33981 - seq_putc(m, data[i]);
33982 + if (!seq_putc(m, data[i]))
33983 + return -EFAULT;
33984
33985 return 0;
33986 }
33987 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
33988 index ce5f3fc..e2d3e55 100644
33989 --- a/drivers/char/virtio_console.c
33990 +++ b/drivers/char/virtio_console.c
33991 @@ -679,7 +679,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
33992 if (to_user) {
33993 ssize_t ret;
33994
33995 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
33996 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
33997 if (ret)
33998 return -EFAULT;
33999 } else {
34000 @@ -778,7 +778,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34001 if (!port_has_data(port) && !port->host_connected)
34002 return 0;
34003
34004 - return fill_readbuf(port, ubuf, count, true);
34005 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34006 }
34007
34008 static int wait_port_writable(struct port *port, bool nonblock)
34009 diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
34010 index d7ad425..3e3f81f 100644
34011 --- a/drivers/clocksource/arm_arch_timer.c
34012 +++ b/drivers/clocksource/arm_arch_timer.c
34013 @@ -262,7 +262,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34014 return NOTIFY_OK;
34015 }
34016
34017 -static struct notifier_block arch_timer_cpu_nb __cpuinitdata = {
34018 +static struct notifier_block arch_timer_cpu_nb = {
34019 .notifier_call = arch_timer_cpu_notify,
34020 };
34021
34022 diff --git a/drivers/clocksource/metag_generic.c b/drivers/clocksource/metag_generic.c
34023 index ade7513..069445f 100644
34024 --- a/drivers/clocksource/metag_generic.c
34025 +++ b/drivers/clocksource/metag_generic.c
34026 @@ -169,7 +169,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34027 return NOTIFY_OK;
34028 }
34029
34030 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34031 +static struct notifier_block arch_timer_cpu_nb = {
34032 .notifier_call = arch_timer_cpu_notify,
34033 };
34034
34035 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34036 index 57a8774..545e993 100644
34037 --- a/drivers/cpufreq/acpi-cpufreq.c
34038 +++ b/drivers/cpufreq/acpi-cpufreq.c
34039 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34040 return sprintf(buf, "%u\n", boost_enabled);
34041 }
34042
34043 -static struct global_attr global_boost = __ATTR(boost, 0644,
34044 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34045 show_global_boost,
34046 store_global_boost);
34047
34048 @@ -712,8 +712,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34049 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34050 per_cpu(acfreq_data, cpu) = data;
34051
34052 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34053 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34054 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34055 + pax_open_kernel();
34056 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34057 + pax_close_kernel();
34058 + }
34059
34060 result = acpi_processor_register_performance(data->acpi_data, cpu);
34061 if (result)
34062 @@ -839,7 +842,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34063 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34064 break;
34065 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34066 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34067 + pax_open_kernel();
34068 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34069 + pax_close_kernel();
34070 policy->cur = get_cur_freq_on_cpu(cpu);
34071 break;
34072 default:
34073 @@ -850,8 +855,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34074 acpi_processor_notify_smm(THIS_MODULE);
34075
34076 /* Check for APERF/MPERF support in hardware */
34077 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34078 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34079 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34080 + pax_open_kernel();
34081 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34082 + pax_close_kernel();
34083 + }
34084
34085 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34086 for (i = 0; i < perf->state_count; i++)
34087 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34088 index b02824d..51e44aa 100644
34089 --- a/drivers/cpufreq/cpufreq.c
34090 +++ b/drivers/cpufreq/cpufreq.c
34091 @@ -1813,7 +1813,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34092 return NOTIFY_OK;
34093 }
34094
34095 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34096 +static struct notifier_block cpufreq_cpu_notifier = {
34097 .notifier_call = cpufreq_cpu_callback,
34098 };
34099
34100 @@ -1845,8 +1845,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34101
34102 pr_debug("trying to register driver %s\n", driver_data->name);
34103
34104 - if (driver_data->setpolicy)
34105 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34106 + if (driver_data->setpolicy) {
34107 + pax_open_kernel();
34108 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34109 + pax_close_kernel();
34110 + }
34111
34112 spin_lock_irqsave(&cpufreq_driver_lock, flags);
34113 if (cpufreq_driver) {
34114 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34115 index 5a76086..0f4d394 100644
34116 --- a/drivers/cpufreq/cpufreq_governor.c
34117 +++ b/drivers/cpufreq/cpufreq_governor.c
34118 @@ -201,8 +201,8 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34119 {
34120 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
34121 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
34122 - struct cs_ops *cs_ops = NULL;
34123 - struct od_ops *od_ops = NULL;
34124 + const struct cs_ops *cs_ops = NULL;
34125 + const struct od_ops *od_ops = NULL;
34126 struct od_dbs_tuners *od_tuners = dbs_data->tuners;
34127 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
34128 struct cpu_dbs_common_info *cpu_cdbs;
34129 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34130 index cc4bd2f..ad142bc 100644
34131 --- a/drivers/cpufreq/cpufreq_governor.h
34132 +++ b/drivers/cpufreq/cpufreq_governor.h
34133 @@ -142,7 +142,7 @@ struct dbs_data {
34134 void (*gov_check_cpu)(int cpu, unsigned int load);
34135
34136 /* Governor specific ops, see below */
34137 - void *gov_ops;
34138 + const void *gov_ops;
34139 };
34140
34141 /* Governor specific ops, will be passed to dbs_data->gov_ops */
34142 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34143 index bfd6273..e39dd63 100644
34144 --- a/drivers/cpufreq/cpufreq_stats.c
34145 +++ b/drivers/cpufreq/cpufreq_stats.c
34146 @@ -365,7 +365,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34147 }
34148
34149 /* priority=1 so this will get called before cpufreq_remove_dev */
34150 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34151 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34152 .notifier_call = cpufreq_stat_cpu_callback,
34153 .priority = 1,
34154 };
34155 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34156 index 827629c9..0bc6a03 100644
34157 --- a/drivers/cpufreq/p4-clockmod.c
34158 +++ b/drivers/cpufreq/p4-clockmod.c
34159 @@ -167,10 +167,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34160 case 0x0F: /* Core Duo */
34161 case 0x16: /* Celeron Core */
34162 case 0x1C: /* Atom */
34163 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34164 + pax_open_kernel();
34165 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34166 + pax_close_kernel();
34167 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34168 case 0x0D: /* Pentium M (Dothan) */
34169 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34170 + pax_open_kernel();
34171 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34172 + pax_close_kernel();
34173 /* fall through */
34174 case 0x09: /* Pentium M (Banias) */
34175 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34176 @@ -182,7 +186,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34177
34178 /* on P-4s, the TSC runs with constant frequency independent whether
34179 * throttling is active or not. */
34180 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34181 + pax_open_kernel();
34182 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34183 + pax_close_kernel();
34184
34185 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34186 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34187 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34188 index 3a953d5..f5993f6 100644
34189 --- a/drivers/cpufreq/speedstep-centrino.c
34190 +++ b/drivers/cpufreq/speedstep-centrino.c
34191 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34192 !cpu_has(cpu, X86_FEATURE_EST))
34193 return -ENODEV;
34194
34195 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34196 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34197 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34198 + pax_open_kernel();
34199 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34200 + pax_close_kernel();
34201 + }
34202
34203 if (policy->cpu != 0)
34204 return -ENODEV;
34205 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34206 index eba6929..0f53baf 100644
34207 --- a/drivers/cpuidle/cpuidle.c
34208 +++ b/drivers/cpuidle/cpuidle.c
34209 @@ -277,7 +277,7 @@ static int poll_idle(struct cpuidle_device *dev,
34210
34211 static void poll_idle_init(struct cpuidle_driver *drv)
34212 {
34213 - struct cpuidle_state *state = &drv->states[0];
34214 + cpuidle_state_no_const *state = &drv->states[0];
34215
34216 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34217 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34218 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34219 index ea2f8e7..70ac501 100644
34220 --- a/drivers/cpuidle/governor.c
34221 +++ b/drivers/cpuidle/governor.c
34222 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34223 mutex_lock(&cpuidle_lock);
34224 if (__cpuidle_find_governor(gov->name) == NULL) {
34225 ret = 0;
34226 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34227 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34228 if (!cpuidle_curr_governor ||
34229 cpuidle_curr_governor->rating < gov->rating)
34230 cpuidle_switch_governor(gov);
34231 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34232 new_gov = cpuidle_replace_governor(gov->rating);
34233 cpuidle_switch_governor(new_gov);
34234 }
34235 - list_del(&gov->governor_list);
34236 + pax_list_del((struct list_head *)&gov->governor_list);
34237 mutex_unlock(&cpuidle_lock);
34238 }
34239
34240 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34241 index 428754a..8bdf9cc 100644
34242 --- a/drivers/cpuidle/sysfs.c
34243 +++ b/drivers/cpuidle/sysfs.c
34244 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34245 NULL
34246 };
34247
34248 -static struct attribute_group cpuidle_attr_group = {
34249 +static attribute_group_no_const cpuidle_attr_group = {
34250 .attrs = cpuidle_default_attrs,
34251 .name = "cpuidle",
34252 };
34253 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34254 index 3b36797..289c16a 100644
34255 --- a/drivers/devfreq/devfreq.c
34256 +++ b/drivers/devfreq/devfreq.c
34257 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34258 goto err_out;
34259 }
34260
34261 - list_add(&governor->node, &devfreq_governor_list);
34262 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34263
34264 list_for_each_entry(devfreq, &devfreq_list, node) {
34265 int ret = 0;
34266 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34267 }
34268 }
34269
34270 - list_del(&governor->node);
34271 + pax_list_del((struct list_head *)&governor->node);
34272 err_out:
34273 mutex_unlock(&devfreq_list_lock);
34274
34275 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34276 index b70709b..1d8d02a 100644
34277 --- a/drivers/dma/sh/shdma.c
34278 +++ b/drivers/dma/sh/shdma.c
34279 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34280 return ret;
34281 }
34282
34283 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34284 +static struct notifier_block sh_dmae_nmi_notifier = {
34285 .notifier_call = sh_dmae_nmi_handler,
34286
34287 /* Run before NMI debug handler and KGDB */
34288 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34289 index 769d92e..a3dcc1e 100644
34290 --- a/drivers/edac/edac_mc_sysfs.c
34291 +++ b/drivers/edac/edac_mc_sysfs.c
34292 @@ -148,7 +148,7 @@ static const char *edac_caps[] = {
34293 struct dev_ch_attribute {
34294 struct device_attribute attr;
34295 int channel;
34296 -};
34297 +} __do_const;
34298
34299 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34300 struct dev_ch_attribute dev_attr_legacy_##_name = \
34301 @@ -1003,14 +1003,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
34302 }
34303
34304 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
34305 + pax_open_kernel();
34306 if (mci->get_sdram_scrub_rate) {
34307 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34308 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34309 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34310 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34311 }
34312 if (mci->set_sdram_scrub_rate) {
34313 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34314 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34315 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34316 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34317 }
34318 + pax_close_kernel();
34319 err = device_create_file(&mci->dev,
34320 &dev_attr_sdram_scrub_rate);
34321 if (err) {
34322 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34323 index e8658e4..22746d6 100644
34324 --- a/drivers/edac/edac_pci_sysfs.c
34325 +++ b/drivers/edac/edac_pci_sysfs.c
34326 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34327 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34328 static int edac_pci_poll_msec = 1000; /* one second workq period */
34329
34330 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34331 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34332 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34333 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34334
34335 static struct kobject *edac_pci_top_main_kobj;
34336 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34337 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34338 void *value;
34339 ssize_t(*show) (void *, char *);
34340 ssize_t(*store) (void *, const char *, size_t);
34341 -};
34342 +} __do_const;
34343
34344 /* Set of show/store abstract level functions for PCI Parity object */
34345 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34346 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34347 edac_printk(KERN_CRIT, EDAC_PCI,
34348 "Signaled System Error on %s\n",
34349 pci_name(dev));
34350 - atomic_inc(&pci_nonparity_count);
34351 + atomic_inc_unchecked(&pci_nonparity_count);
34352 }
34353
34354 if (status & (PCI_STATUS_PARITY)) {
34355 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34356 "Master Data Parity Error on %s\n",
34357 pci_name(dev));
34358
34359 - atomic_inc(&pci_parity_count);
34360 + atomic_inc_unchecked(&pci_parity_count);
34361 }
34362
34363 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34364 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34365 "Detected Parity Error on %s\n",
34366 pci_name(dev));
34367
34368 - atomic_inc(&pci_parity_count);
34369 + atomic_inc_unchecked(&pci_parity_count);
34370 }
34371 }
34372
34373 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34374 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
34375 "Signaled System Error on %s\n",
34376 pci_name(dev));
34377 - atomic_inc(&pci_nonparity_count);
34378 + atomic_inc_unchecked(&pci_nonparity_count);
34379 }
34380
34381 if (status & (PCI_STATUS_PARITY)) {
34382 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34383 "Master Data Parity Error on "
34384 "%s\n", pci_name(dev));
34385
34386 - atomic_inc(&pci_parity_count);
34387 + atomic_inc_unchecked(&pci_parity_count);
34388 }
34389
34390 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34391 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34392 "Detected Parity Error on %s\n",
34393 pci_name(dev));
34394
34395 - atomic_inc(&pci_parity_count);
34396 + atomic_inc_unchecked(&pci_parity_count);
34397 }
34398 }
34399 }
34400 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
34401 if (!check_pci_errors)
34402 return;
34403
34404 - before_count = atomic_read(&pci_parity_count);
34405 + before_count = atomic_read_unchecked(&pci_parity_count);
34406
34407 /* scan all PCI devices looking for a Parity Error on devices and
34408 * bridges.
34409 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
34410 /* Only if operator has selected panic on PCI Error */
34411 if (edac_pci_get_panic_on_pe()) {
34412 /* If the count is different 'after' from 'before' */
34413 - if (before_count != atomic_read(&pci_parity_count))
34414 + if (before_count != atomic_read_unchecked(&pci_parity_count))
34415 panic("EDAC: PCI Parity Error");
34416 }
34417 }
34418 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
34419 index 51b7e3a..aa8a3e8 100644
34420 --- a/drivers/edac/mce_amd.h
34421 +++ b/drivers/edac/mce_amd.h
34422 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
34423 bool (*mc0_mce)(u16, u8);
34424 bool (*mc1_mce)(u16, u8);
34425 bool (*mc2_mce)(u16, u8);
34426 -};
34427 +} __no_const;
34428
34429 void amd_report_gart_errors(bool);
34430 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
34431 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
34432 index 57ea7f4..789e3c3 100644
34433 --- a/drivers/firewire/core-card.c
34434 +++ b/drivers/firewire/core-card.c
34435 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
34436
34437 void fw_core_remove_card(struct fw_card *card)
34438 {
34439 - struct fw_card_driver dummy_driver = dummy_driver_template;
34440 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
34441
34442 card->driver->update_phy_reg(card, 4,
34443 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
34444 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
34445 index 27ac423..13573e8 100644
34446 --- a/drivers/firewire/core-cdev.c
34447 +++ b/drivers/firewire/core-cdev.c
34448 @@ -1366,8 +1366,7 @@ static int init_iso_resource(struct client *client,
34449 int ret;
34450
34451 if ((request->channels == 0 && request->bandwidth == 0) ||
34452 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
34453 - request->bandwidth < 0)
34454 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
34455 return -EINVAL;
34456
34457 r = kmalloc(sizeof(*r), GFP_KERNEL);
34458 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
34459 index 03ce7d9..b70f5da 100644
34460 --- a/drivers/firewire/core-device.c
34461 +++ b/drivers/firewire/core-device.c
34462 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
34463 struct config_rom_attribute {
34464 struct device_attribute attr;
34465 u32 key;
34466 -};
34467 +} __do_const;
34468
34469 static ssize_t show_immediate(struct device *dev,
34470 struct device_attribute *dattr, char *buf)
34471 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
34472 index 28a94c7..58da63a 100644
34473 --- a/drivers/firewire/core-transaction.c
34474 +++ b/drivers/firewire/core-transaction.c
34475 @@ -38,6 +38,7 @@
34476 #include <linux/timer.h>
34477 #include <linux/types.h>
34478 #include <linux/workqueue.h>
34479 +#include <linux/sched.h>
34480
34481 #include <asm/byteorder.h>
34482
34483 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
34484 index 515a42c..5ecf3ba 100644
34485 --- a/drivers/firewire/core.h
34486 +++ b/drivers/firewire/core.h
34487 @@ -111,6 +111,7 @@ struct fw_card_driver {
34488
34489 int (*stop_iso)(struct fw_iso_context *ctx);
34490 };
34491 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
34492
34493 void fw_card_initialize(struct fw_card *card,
34494 const struct fw_card_driver *driver, struct device *device);
34495 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
34496 index 94a58a0..f5eba42 100644
34497 --- a/drivers/firmware/dmi-id.c
34498 +++ b/drivers/firmware/dmi-id.c
34499 @@ -16,7 +16,7 @@
34500 struct dmi_device_attribute{
34501 struct device_attribute dev_attr;
34502 int field;
34503 -};
34504 +} __do_const;
34505 #define to_dmi_dev_attr(_dev_attr) \
34506 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
34507
34508 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
34509 index 4cd392d..4b629e1 100644
34510 --- a/drivers/firmware/dmi_scan.c
34511 +++ b/drivers/firmware/dmi_scan.c
34512 @@ -490,11 +490,6 @@ void __init dmi_scan_machine(void)
34513 }
34514 }
34515 else {
34516 - /*
34517 - * no iounmap() for that ioremap(); it would be a no-op, but
34518 - * it's so early in setup that sucker gets confused into doing
34519 - * what it shouldn't if we actually call it.
34520 - */
34521 p = dmi_ioremap(0xF0000, 0x10000);
34522 if (p == NULL)
34523 goto error;
34524 @@ -769,7 +764,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
34525 if (buf == NULL)
34526 return -1;
34527
34528 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
34529 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
34530
34531 iounmap(buf);
34532 return 0;
34533 diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
34534 index f4baa11..7970c3a 100644
34535 --- a/drivers/firmware/efivars.c
34536 +++ b/drivers/firmware/efivars.c
34537 @@ -139,7 +139,7 @@ struct efivar_attribute {
34538 };
34539
34540 static struct efivars __efivars;
34541 -static struct efivar_operations ops;
34542 +static efivar_operations_no_const ops __read_only;
34543
34544 #define PSTORE_EFI_ATTRIBUTES \
34545 (EFI_VARIABLE_NON_VOLATILE | \
34546 @@ -1844,7 +1844,7 @@ efivar_create_sysfs_entry(struct efivars *efivars,
34547 static int
34548 create_efivars_bin_attributes(struct efivars *efivars)
34549 {
34550 - struct bin_attribute *attr;
34551 + bin_attribute_no_const *attr;
34552 int error;
34553
34554 /* new_var */
34555 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
34556 index 2a90ba6..07f3733 100644
34557 --- a/drivers/firmware/google/memconsole.c
34558 +++ b/drivers/firmware/google/memconsole.c
34559 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
34560 if (!found_memconsole())
34561 return -ENODEV;
34562
34563 - memconsole_bin_attr.size = memconsole_length;
34564 + pax_open_kernel();
34565 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
34566 + pax_close_kernel();
34567
34568 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
34569
34570 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
34571 index de3c317..b7cd029 100644
34572 --- a/drivers/gpio/gpio-ich.c
34573 +++ b/drivers/gpio/gpio-ich.c
34574 @@ -69,7 +69,7 @@ struct ichx_desc {
34575 /* Some chipsets have quirks, let these use their own request/get */
34576 int (*request)(struct gpio_chip *chip, unsigned offset);
34577 int (*get)(struct gpio_chip *chip, unsigned offset);
34578 -};
34579 +} __do_const;
34580
34581 static struct {
34582 spinlock_t lock;
34583 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
34584 index 9902732..64b62dd 100644
34585 --- a/drivers/gpio/gpio-vr41xx.c
34586 +++ b/drivers/gpio/gpio-vr41xx.c
34587 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
34588 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
34589 maskl, pendl, maskh, pendh);
34590
34591 - atomic_inc(&irq_err_count);
34592 + atomic_inc_unchecked(&irq_err_count);
34593
34594 return -EINVAL;
34595 }
34596 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
34597 index 7b2d378..cc947ea 100644
34598 --- a/drivers/gpu/drm/drm_crtc_helper.c
34599 +++ b/drivers/gpu/drm/drm_crtc_helper.c
34600 @@ -319,7 +319,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
34601 struct drm_crtc *tmp;
34602 int crtc_mask = 1;
34603
34604 - WARN(!crtc, "checking null crtc?\n");
34605 + BUG_ON(!crtc);
34606
34607 dev = crtc->dev;
34608
34609 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
34610 index 25f91cd..a376f55 100644
34611 --- a/drivers/gpu/drm/drm_drv.c
34612 +++ b/drivers/gpu/drm/drm_drv.c
34613 @@ -306,7 +306,7 @@ module_exit(drm_core_exit);
34614 /**
34615 * Copy and IOCTL return string to user space
34616 */
34617 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
34618 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
34619 {
34620 int len;
34621
34622 @@ -376,7 +376,7 @@ long drm_ioctl(struct file *filp,
34623 struct drm_file *file_priv = filp->private_data;
34624 struct drm_device *dev;
34625 struct drm_ioctl_desc *ioctl;
34626 - drm_ioctl_t *func;
34627 + drm_ioctl_no_const_t func;
34628 unsigned int nr = DRM_IOCTL_NR(cmd);
34629 int retcode = -EINVAL;
34630 char stack_kdata[128];
34631 @@ -389,7 +389,7 @@ long drm_ioctl(struct file *filp,
34632 return -ENODEV;
34633
34634 atomic_inc(&dev->ioctl_count);
34635 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
34636 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
34637 ++file_priv->ioctl_count;
34638
34639 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
34640 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
34641 index 429e07d..e681a2c 100644
34642 --- a/drivers/gpu/drm/drm_fops.c
34643 +++ b/drivers/gpu/drm/drm_fops.c
34644 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
34645 }
34646
34647 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
34648 - atomic_set(&dev->counts[i], 0);
34649 + atomic_set_unchecked(&dev->counts[i], 0);
34650
34651 dev->sigdata.lock = NULL;
34652
34653 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
34654 if (drm_device_is_unplugged(dev))
34655 return -ENODEV;
34656
34657 - if (!dev->open_count++)
34658 + if (local_inc_return(&dev->open_count) == 1)
34659 need_setup = 1;
34660 mutex_lock(&dev->struct_mutex);
34661 old_imapping = inode->i_mapping;
34662 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
34663 retcode = drm_open_helper(inode, filp, dev);
34664 if (retcode)
34665 goto err_undo;
34666 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
34667 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
34668 if (need_setup) {
34669 retcode = drm_setup(dev);
34670 if (retcode)
34671 @@ -166,7 +166,7 @@ err_undo:
34672 iput(container_of(dev->dev_mapping, struct inode, i_data));
34673 dev->dev_mapping = old_mapping;
34674 mutex_unlock(&dev->struct_mutex);
34675 - dev->open_count--;
34676 + local_dec(&dev->open_count);
34677 return retcode;
34678 }
34679 EXPORT_SYMBOL(drm_open);
34680 @@ -441,7 +441,7 @@ int drm_release(struct inode *inode, struct file *filp)
34681
34682 mutex_lock(&drm_global_mutex);
34683
34684 - DRM_DEBUG("open_count = %d\n", dev->open_count);
34685 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
34686
34687 if (dev->driver->preclose)
34688 dev->driver->preclose(dev, file_priv);
34689 @@ -450,10 +450,10 @@ int drm_release(struct inode *inode, struct file *filp)
34690 * Begin inline drm_release
34691 */
34692
34693 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
34694 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
34695 task_pid_nr(current),
34696 (long)old_encode_dev(file_priv->minor->device),
34697 - dev->open_count);
34698 + local_read(&dev->open_count));
34699
34700 /* Release any auth tokens that might point to this file_priv,
34701 (do that under the drm_global_mutex) */
34702 @@ -550,8 +550,8 @@ int drm_release(struct inode *inode, struct file *filp)
34703 * End inline drm_release
34704 */
34705
34706 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
34707 - if (!--dev->open_count) {
34708 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
34709 + if (local_dec_and_test(&dev->open_count)) {
34710 if (atomic_read(&dev->ioctl_count)) {
34711 DRM_ERROR("Device busy: %d\n",
34712 atomic_read(&dev->ioctl_count));
34713 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
34714 index f731116..629842c 100644
34715 --- a/drivers/gpu/drm/drm_global.c
34716 +++ b/drivers/gpu/drm/drm_global.c
34717 @@ -36,7 +36,7 @@
34718 struct drm_global_item {
34719 struct mutex mutex;
34720 void *object;
34721 - int refcount;
34722 + atomic_t refcount;
34723 };
34724
34725 static struct drm_global_item glob[DRM_GLOBAL_NUM];
34726 @@ -49,7 +49,7 @@ void drm_global_init(void)
34727 struct drm_global_item *item = &glob[i];
34728 mutex_init(&item->mutex);
34729 item->object = NULL;
34730 - item->refcount = 0;
34731 + atomic_set(&item->refcount, 0);
34732 }
34733 }
34734
34735 @@ -59,7 +59,7 @@ void drm_global_release(void)
34736 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
34737 struct drm_global_item *item = &glob[i];
34738 BUG_ON(item->object != NULL);
34739 - BUG_ON(item->refcount != 0);
34740 + BUG_ON(atomic_read(&item->refcount) != 0);
34741 }
34742 }
34743
34744 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
34745 void *object;
34746
34747 mutex_lock(&item->mutex);
34748 - if (item->refcount == 0) {
34749 + if (atomic_read(&item->refcount) == 0) {
34750 item->object = kzalloc(ref->size, GFP_KERNEL);
34751 if (unlikely(item->object == NULL)) {
34752 ret = -ENOMEM;
34753 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
34754 goto out_err;
34755
34756 }
34757 - ++item->refcount;
34758 + atomic_inc(&item->refcount);
34759 ref->object = item->object;
34760 object = item->object;
34761 mutex_unlock(&item->mutex);
34762 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
34763 struct drm_global_item *item = &glob[ref->global_type];
34764
34765 mutex_lock(&item->mutex);
34766 - BUG_ON(item->refcount == 0);
34767 + BUG_ON(atomic_read(&item->refcount) == 0);
34768 BUG_ON(ref->object != item->object);
34769 - if (--item->refcount == 0) {
34770 + if (atomic_dec_and_test(&item->refcount)) {
34771 ref->release(ref);
34772 item->object = NULL;
34773 }
34774 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
34775 index d4b20ce..77a8d41 100644
34776 --- a/drivers/gpu/drm/drm_info.c
34777 +++ b/drivers/gpu/drm/drm_info.c
34778 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
34779 struct drm_local_map *map;
34780 struct drm_map_list *r_list;
34781
34782 - /* Hardcoded from _DRM_FRAME_BUFFER,
34783 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
34784 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
34785 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
34786 + static const char * const types[] = {
34787 + [_DRM_FRAME_BUFFER] = "FB",
34788 + [_DRM_REGISTERS] = "REG",
34789 + [_DRM_SHM] = "SHM",
34790 + [_DRM_AGP] = "AGP",
34791 + [_DRM_SCATTER_GATHER] = "SG",
34792 + [_DRM_CONSISTENT] = "PCI",
34793 + [_DRM_GEM] = "GEM" };
34794 const char *type;
34795 int i;
34796
34797 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
34798 map = r_list->map;
34799 if (!map)
34800 continue;
34801 - if (map->type < 0 || map->type > 5)
34802 + if (map->type >= ARRAY_SIZE(types))
34803 type = "??";
34804 else
34805 type = types[map->type];
34806 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
34807 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
34808 vma->vm_flags & VM_LOCKED ? 'l' : '-',
34809 vma->vm_flags & VM_IO ? 'i' : '-',
34810 +#ifdef CONFIG_GRKERNSEC_HIDESYM
34811 + 0);
34812 +#else
34813 vma->vm_pgoff);
34814 +#endif
34815
34816 #if defined(__i386__)
34817 pgprot = pgprot_val(vma->vm_page_prot);
34818 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
34819 index 2f4c434..dd12cd2 100644
34820 --- a/drivers/gpu/drm/drm_ioc32.c
34821 +++ b/drivers/gpu/drm/drm_ioc32.c
34822 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
34823 request = compat_alloc_user_space(nbytes);
34824 if (!access_ok(VERIFY_WRITE, request, nbytes))
34825 return -EFAULT;
34826 - list = (struct drm_buf_desc *) (request + 1);
34827 + list = (struct drm_buf_desc __user *) (request + 1);
34828
34829 if (__put_user(count, &request->count)
34830 || __put_user(list, &request->list))
34831 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
34832 request = compat_alloc_user_space(nbytes);
34833 if (!access_ok(VERIFY_WRITE, request, nbytes))
34834 return -EFAULT;
34835 - list = (struct drm_buf_pub *) (request + 1);
34836 + list = (struct drm_buf_pub __user *) (request + 1);
34837
34838 if (__put_user(count, &request->count)
34839 || __put_user(list, &request->list))
34840 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
34841 return 0;
34842 }
34843
34844 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
34845 +drm_ioctl_compat_t drm_compat_ioctls[] = {
34846 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
34847 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
34848 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
34849 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
34850 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
34851 {
34852 unsigned int nr = DRM_IOCTL_NR(cmd);
34853 - drm_ioctl_compat_t *fn;
34854 int ret;
34855
34856 /* Assume that ioctls without an explicit compat routine will just
34857 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
34858 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
34859 return drm_ioctl(filp, cmd, arg);
34860
34861 - fn = drm_compat_ioctls[nr];
34862 -
34863 - if (fn != NULL)
34864 - ret = (*fn) (filp, cmd, arg);
34865 + if (drm_compat_ioctls[nr] != NULL)
34866 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
34867 else
34868 ret = drm_ioctl(filp, cmd, arg);
34869
34870 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
34871 index e77bd8b..1571b85 100644
34872 --- a/drivers/gpu/drm/drm_ioctl.c
34873 +++ b/drivers/gpu/drm/drm_ioctl.c
34874 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
34875 stats->data[i].value =
34876 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
34877 else
34878 - stats->data[i].value = atomic_read(&dev->counts[i]);
34879 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
34880 stats->data[i].type = dev->types[i];
34881 }
34882
34883 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
34884 index d752c96..fe08455 100644
34885 --- a/drivers/gpu/drm/drm_lock.c
34886 +++ b/drivers/gpu/drm/drm_lock.c
34887 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
34888 if (drm_lock_take(&master->lock, lock->context)) {
34889 master->lock.file_priv = file_priv;
34890 master->lock.lock_time = jiffies;
34891 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
34892 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
34893 break; /* Got lock */
34894 }
34895
34896 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
34897 return -EINVAL;
34898 }
34899
34900 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
34901 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
34902
34903 if (drm_lock_free(&master->lock, lock->context)) {
34904 /* FIXME: Should really bail out here. */
34905 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
34906 index 7d30802..42c6cbb 100644
34907 --- a/drivers/gpu/drm/drm_stub.c
34908 +++ b/drivers/gpu/drm/drm_stub.c
34909 @@ -501,7 +501,7 @@ void drm_unplug_dev(struct drm_device *dev)
34910
34911 drm_device_set_unplugged(dev);
34912
34913 - if (dev->open_count == 0) {
34914 + if (local_read(&dev->open_count) == 0) {
34915 drm_put_dev(dev);
34916 }
34917 mutex_unlock(&drm_global_mutex);
34918 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
34919 index 004ecdf..db1f6e0 100644
34920 --- a/drivers/gpu/drm/i810/i810_dma.c
34921 +++ b/drivers/gpu/drm/i810/i810_dma.c
34922 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
34923 dma->buflist[vertex->idx],
34924 vertex->discard, vertex->used);
34925
34926 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
34927 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
34928 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
34929 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
34930 sarea_priv->last_enqueue = dev_priv->counter - 1;
34931 sarea_priv->last_dispatch = (int)hw_status[5];
34932
34933 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
34934 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
34935 mc->last_render);
34936
34937 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
34938 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
34939 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
34940 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
34941 sarea_priv->last_enqueue = dev_priv->counter - 1;
34942 sarea_priv->last_dispatch = (int)hw_status[5];
34943
34944 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
34945 index 6e0acad..93c8289 100644
34946 --- a/drivers/gpu/drm/i810/i810_drv.h
34947 +++ b/drivers/gpu/drm/i810/i810_drv.h
34948 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
34949 int page_flipping;
34950
34951 wait_queue_head_t irq_queue;
34952 - atomic_t irq_received;
34953 - atomic_t irq_emitted;
34954 + atomic_unchecked_t irq_received;
34955 + atomic_unchecked_t irq_emitted;
34956
34957 int front_offset;
34958 } drm_i810_private_t;
34959 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
34960 index 7299ea4..5314487 100644
34961 --- a/drivers/gpu/drm/i915/i915_debugfs.c
34962 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
34963 @@ -499,7 +499,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
34964 I915_READ(GTIMR));
34965 }
34966 seq_printf(m, "Interrupts received: %d\n",
34967 - atomic_read(&dev_priv->irq_received));
34968 + atomic_read_unchecked(&dev_priv->irq_received));
34969 for_each_ring(ring, dev_priv, i) {
34970 if (IS_GEN6(dev) || IS_GEN7(dev)) {
34971 seq_printf(m,
34972 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
34973 index 4fa6beb..f930fec 100644
34974 --- a/drivers/gpu/drm/i915/i915_dma.c
34975 +++ b/drivers/gpu/drm/i915/i915_dma.c
34976 @@ -1259,7 +1259,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
34977 bool can_switch;
34978
34979 spin_lock(&dev->count_lock);
34980 - can_switch = (dev->open_count == 0);
34981 + can_switch = (local_read(&dev->open_count) == 0);
34982 spin_unlock(&dev->count_lock);
34983 return can_switch;
34984 }
34985 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
34986 index ef99b1c..09ce7fb 100644
34987 --- a/drivers/gpu/drm/i915/i915_drv.h
34988 +++ b/drivers/gpu/drm/i915/i915_drv.h
34989 @@ -893,7 +893,7 @@ typedef struct drm_i915_private {
34990 drm_dma_handle_t *status_page_dmah;
34991 struct resource mch_res;
34992
34993 - atomic_t irq_received;
34994 + atomic_unchecked_t irq_received;
34995
34996 /* protects the irq masks */
34997 spinlock_t irq_lock;
34998 @@ -1775,7 +1775,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
34999 struct drm_i915_private *dev_priv, unsigned port);
35000 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35001 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35002 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35003 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35004 {
35005 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35006 }
35007 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35008 index 9a48e1a..f0cbc3e 100644
35009 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35010 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35011 @@ -729,9 +729,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35012
35013 static int
35014 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35015 - int count)
35016 + unsigned int count)
35017 {
35018 - int i;
35019 + unsigned int i;
35020 int relocs_total = 0;
35021 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35022
35023 @@ -1195,7 +1195,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
35024 return -ENOMEM;
35025 }
35026 ret = copy_from_user(exec2_list,
35027 - (struct drm_i915_relocation_entry __user *)
35028 + (struct drm_i915_gem_exec_object2 __user *)
35029 (uintptr_t) args->buffers_ptr,
35030 sizeof(*exec2_list) * args->buffer_count);
35031 if (ret != 0) {
35032 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35033 index 3c59584..500f2e9 100644
35034 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35035 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35036 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35037 (unsigned long)request);
35038 }
35039
35040 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35041 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35042 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35043 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35044 [DRM_I915_GETPARAM] = compat_i915_getparam,
35045 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35046 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35047 {
35048 unsigned int nr = DRM_IOCTL_NR(cmd);
35049 - drm_ioctl_compat_t *fn = NULL;
35050 int ret;
35051
35052 if (nr < DRM_COMMAND_BASE)
35053 return drm_compat_ioctl(filp, cmd, arg);
35054
35055 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35056 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35057 -
35058 - if (fn != NULL)
35059 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35060 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35061 ret = (*fn) (filp, cmd, arg);
35062 - else
35063 + } else
35064 ret = drm_ioctl(filp, cmd, arg);
35065
35066 return ret;
35067 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35068 index 3c7bb04..182e049 100644
35069 --- a/drivers/gpu/drm/i915/i915_irq.c
35070 +++ b/drivers/gpu/drm/i915/i915_irq.c
35071 @@ -549,7 +549,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35072 int pipe;
35073 u32 pipe_stats[I915_MAX_PIPES];
35074
35075 - atomic_inc(&dev_priv->irq_received);
35076 + atomic_inc_unchecked(&dev_priv->irq_received);
35077
35078 while (true) {
35079 iir = I915_READ(VLV_IIR);
35080 @@ -705,7 +705,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35081 irqreturn_t ret = IRQ_NONE;
35082 int i;
35083
35084 - atomic_inc(&dev_priv->irq_received);
35085 + atomic_inc_unchecked(&dev_priv->irq_received);
35086
35087 /* disable master interrupt before clearing iir */
35088 de_ier = I915_READ(DEIER);
35089 @@ -791,7 +791,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35090 int ret = IRQ_NONE;
35091 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
35092
35093 - atomic_inc(&dev_priv->irq_received);
35094 + atomic_inc_unchecked(&dev_priv->irq_received);
35095
35096 /* disable master interrupt before clearing iir */
35097 de_ier = I915_READ(DEIER);
35098 @@ -1886,7 +1886,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35099 {
35100 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35101
35102 - atomic_set(&dev_priv->irq_received, 0);
35103 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35104
35105 I915_WRITE(HWSTAM, 0xeffe);
35106
35107 @@ -1912,7 +1912,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35108 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35109 int pipe;
35110
35111 - atomic_set(&dev_priv->irq_received, 0);
35112 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35113
35114 /* VLV magic */
35115 I915_WRITE(VLV_IMR, 0);
35116 @@ -2208,7 +2208,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35117 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35118 int pipe;
35119
35120 - atomic_set(&dev_priv->irq_received, 0);
35121 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35122
35123 for_each_pipe(pipe)
35124 I915_WRITE(PIPESTAT(pipe), 0);
35125 @@ -2259,7 +2259,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35126 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35127 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35128
35129 - atomic_inc(&dev_priv->irq_received);
35130 + atomic_inc_unchecked(&dev_priv->irq_received);
35131
35132 iir = I915_READ16(IIR);
35133 if (iir == 0)
35134 @@ -2344,7 +2344,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35135 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35136 int pipe;
35137
35138 - atomic_set(&dev_priv->irq_received, 0);
35139 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35140
35141 if (I915_HAS_HOTPLUG(dev)) {
35142 I915_WRITE(PORT_HOTPLUG_EN, 0);
35143 @@ -2448,7 +2448,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35144 };
35145 int pipe, ret = IRQ_NONE;
35146
35147 - atomic_inc(&dev_priv->irq_received);
35148 + atomic_inc_unchecked(&dev_priv->irq_received);
35149
35150 iir = I915_READ(IIR);
35151 do {
35152 @@ -2574,7 +2574,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35153 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35154 int pipe;
35155
35156 - atomic_set(&dev_priv->irq_received, 0);
35157 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35158
35159 I915_WRITE(PORT_HOTPLUG_EN, 0);
35160 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35161 @@ -2690,7 +2690,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35162 int irq_received;
35163 int ret = IRQ_NONE, pipe;
35164
35165 - atomic_inc(&dev_priv->irq_received);
35166 + atomic_inc_unchecked(&dev_priv->irq_received);
35167
35168 iir = I915_READ(IIR);
35169
35170 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35171 index c2d173a..f4357cc 100644
35172 --- a/drivers/gpu/drm/i915/intel_display.c
35173 +++ b/drivers/gpu/drm/i915/intel_display.c
35174 @@ -8722,13 +8722,13 @@ struct intel_quirk {
35175 int subsystem_vendor;
35176 int subsystem_device;
35177 void (*hook)(struct drm_device *dev);
35178 -};
35179 +} __do_const;
35180
35181 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35182 struct intel_dmi_quirk {
35183 void (*hook)(struct drm_device *dev);
35184 const struct dmi_system_id (*dmi_id_list)[];
35185 -};
35186 +} __do_const;
35187
35188 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35189 {
35190 @@ -8736,18 +8736,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35191 return 1;
35192 }
35193
35194 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35195 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35196 {
35197 - .dmi_id_list = &(const struct dmi_system_id[]) {
35198 - {
35199 - .callback = intel_dmi_reverse_brightness,
35200 - .ident = "NCR Corporation",
35201 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35202 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35203 - },
35204 - },
35205 - { } /* terminating entry */
35206 + .callback = intel_dmi_reverse_brightness,
35207 + .ident = "NCR Corporation",
35208 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35209 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35210 },
35211 + },
35212 + { } /* terminating entry */
35213 +};
35214 +
35215 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35216 + {
35217 + .dmi_id_list = &intel_dmi_quirks_table,
35218 .hook = quirk_invert_brightness,
35219 },
35220 };
35221 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35222 index 54558a0..2d97005 100644
35223 --- a/drivers/gpu/drm/mga/mga_drv.h
35224 +++ b/drivers/gpu/drm/mga/mga_drv.h
35225 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35226 u32 clear_cmd;
35227 u32 maccess;
35228
35229 - atomic_t vbl_received; /**< Number of vblanks received. */
35230 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35231 wait_queue_head_t fence_queue;
35232 - atomic_t last_fence_retired;
35233 + atomic_unchecked_t last_fence_retired;
35234 u32 next_fence_to_post;
35235
35236 unsigned int fb_cpp;
35237 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35238 index 709e90d..89a1c0d 100644
35239 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35240 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35241 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35242 return 0;
35243 }
35244
35245 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35246 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35247 [DRM_MGA_INIT] = compat_mga_init,
35248 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35249 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35250 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35251 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35252 {
35253 unsigned int nr = DRM_IOCTL_NR(cmd);
35254 - drm_ioctl_compat_t *fn = NULL;
35255 int ret;
35256
35257 if (nr < DRM_COMMAND_BASE)
35258 return drm_compat_ioctl(filp, cmd, arg);
35259
35260 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35261 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35262 -
35263 - if (fn != NULL)
35264 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35265 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35266 ret = (*fn) (filp, cmd, arg);
35267 - else
35268 + } else
35269 ret = drm_ioctl(filp, cmd, arg);
35270
35271 return ret;
35272 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35273 index 598c281..60d590e 100644
35274 --- a/drivers/gpu/drm/mga/mga_irq.c
35275 +++ b/drivers/gpu/drm/mga/mga_irq.c
35276 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35277 if (crtc != 0)
35278 return 0;
35279
35280 - return atomic_read(&dev_priv->vbl_received);
35281 + return atomic_read_unchecked(&dev_priv->vbl_received);
35282 }
35283
35284
35285 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35286 /* VBLANK interrupt */
35287 if (status & MGA_VLINEPEN) {
35288 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35289 - atomic_inc(&dev_priv->vbl_received);
35290 + atomic_inc_unchecked(&dev_priv->vbl_received);
35291 drm_handle_vblank(dev, 0);
35292 handled = 1;
35293 }
35294 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35295 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35296 MGA_WRITE(MGA_PRIMEND, prim_end);
35297
35298 - atomic_inc(&dev_priv->last_fence_retired);
35299 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35300 DRM_WAKEUP(&dev_priv->fence_queue);
35301 handled = 1;
35302 }
35303 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35304 * using fences.
35305 */
35306 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35307 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35308 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35309 - *sequence) <= (1 << 23)));
35310
35311 *sequence = cur_fence;
35312 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35313 index 50a6dd0..ea66ed8 100644
35314 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35315 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35316 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35317 struct bit_table {
35318 const char id;
35319 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35320 -};
35321 +} __no_const;
35322
35323 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35324
35325 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35326 index 9c39baf..30a22be 100644
35327 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35328 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35329 @@ -81,7 +81,7 @@ struct nouveau_drm {
35330 struct drm_global_reference mem_global_ref;
35331 struct ttm_bo_global_ref bo_global_ref;
35332 struct ttm_bo_device bdev;
35333 - atomic_t validate_sequence;
35334 + atomic_unchecked_t validate_sequence;
35335 int (*move)(struct nouveau_channel *,
35336 struct ttm_buffer_object *,
35337 struct ttm_mem_reg *, struct ttm_mem_reg *);
35338 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35339 index b4b4d0c..b7edc15 100644
35340 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35341 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35342 @@ -322,7 +322,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35343 int ret, i;
35344 struct nouveau_bo *res_bo = NULL;
35345
35346 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35347 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35348 retry:
35349 if (++trycnt > 100000) {
35350 NV_ERROR(cli, "%s failed and gave up.\n", __func__);
35351 @@ -359,7 +359,7 @@ retry:
35352 if (ret) {
35353 validate_fini(op, NULL);
35354 if (unlikely(ret == -EAGAIN)) {
35355 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35356 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35357 ret = ttm_bo_reserve_slowpath(&nvbo->bo, true,
35358 sequence);
35359 if (!ret)
35360 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35361 index 08214bc..9208577 100644
35362 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35363 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35364 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35365 unsigned long arg)
35366 {
35367 unsigned int nr = DRM_IOCTL_NR(cmd);
35368 - drm_ioctl_compat_t *fn = NULL;
35369 + drm_ioctl_compat_t fn = NULL;
35370 int ret;
35371
35372 if (nr < DRM_COMMAND_BASE)
35373 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35374 index 25d3495..d81aaf6 100644
35375 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35376 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35377 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35378 bool can_switch;
35379
35380 spin_lock(&dev->count_lock);
35381 - can_switch = (dev->open_count == 0);
35382 + can_switch = (local_read(&dev->open_count) == 0);
35383 spin_unlock(&dev->count_lock);
35384 return can_switch;
35385 }
35386 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
35387 index d4660cf..70dbe65 100644
35388 --- a/drivers/gpu/drm/r128/r128_cce.c
35389 +++ b/drivers/gpu/drm/r128/r128_cce.c
35390 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
35391
35392 /* GH: Simple idle check.
35393 */
35394 - atomic_set(&dev_priv->idle_count, 0);
35395 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35396
35397 /* We don't support anything other than bus-mastering ring mode,
35398 * but the ring can be in either AGP or PCI space for the ring
35399 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
35400 index 930c71b..499aded 100644
35401 --- a/drivers/gpu/drm/r128/r128_drv.h
35402 +++ b/drivers/gpu/drm/r128/r128_drv.h
35403 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
35404 int is_pci;
35405 unsigned long cce_buffers_offset;
35406
35407 - atomic_t idle_count;
35408 + atomic_unchecked_t idle_count;
35409
35410 int page_flipping;
35411 int current_page;
35412 u32 crtc_offset;
35413 u32 crtc_offset_cntl;
35414
35415 - atomic_t vbl_received;
35416 + atomic_unchecked_t vbl_received;
35417
35418 u32 color_fmt;
35419 unsigned int front_offset;
35420 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
35421 index a954c54..9cc595c 100644
35422 --- a/drivers/gpu/drm/r128/r128_ioc32.c
35423 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
35424 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
35425 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
35426 }
35427
35428 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
35429 +drm_ioctl_compat_t r128_compat_ioctls[] = {
35430 [DRM_R128_INIT] = compat_r128_init,
35431 [DRM_R128_DEPTH] = compat_r128_depth,
35432 [DRM_R128_STIPPLE] = compat_r128_stipple,
35433 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
35434 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35435 {
35436 unsigned int nr = DRM_IOCTL_NR(cmd);
35437 - drm_ioctl_compat_t *fn = NULL;
35438 int ret;
35439
35440 if (nr < DRM_COMMAND_BASE)
35441 return drm_compat_ioctl(filp, cmd, arg);
35442
35443 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
35444 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35445 -
35446 - if (fn != NULL)
35447 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
35448 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35449 ret = (*fn) (filp, cmd, arg);
35450 - else
35451 + } else
35452 ret = drm_ioctl(filp, cmd, arg);
35453
35454 return ret;
35455 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
35456 index 2ea4f09..d391371 100644
35457 --- a/drivers/gpu/drm/r128/r128_irq.c
35458 +++ b/drivers/gpu/drm/r128/r128_irq.c
35459 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
35460 if (crtc != 0)
35461 return 0;
35462
35463 - return atomic_read(&dev_priv->vbl_received);
35464 + return atomic_read_unchecked(&dev_priv->vbl_received);
35465 }
35466
35467 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35468 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35469 /* VBLANK interrupt */
35470 if (status & R128_CRTC_VBLANK_INT) {
35471 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
35472 - atomic_inc(&dev_priv->vbl_received);
35473 + atomic_inc_unchecked(&dev_priv->vbl_received);
35474 drm_handle_vblank(dev, 0);
35475 return IRQ_HANDLED;
35476 }
35477 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
35478 index 19bb7e6..de7e2a2 100644
35479 --- a/drivers/gpu/drm/r128/r128_state.c
35480 +++ b/drivers/gpu/drm/r128/r128_state.c
35481 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
35482
35483 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
35484 {
35485 - if (atomic_read(&dev_priv->idle_count) == 0)
35486 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
35487 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
35488 else
35489 - atomic_set(&dev_priv->idle_count, 0);
35490 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35491 }
35492
35493 #endif
35494 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
35495 index 5a82b6b..9e69c73 100644
35496 --- a/drivers/gpu/drm/radeon/mkregtable.c
35497 +++ b/drivers/gpu/drm/radeon/mkregtable.c
35498 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
35499 regex_t mask_rex;
35500 regmatch_t match[4];
35501 char buf[1024];
35502 - size_t end;
35503 + long end;
35504 int len;
35505 int done = 0;
35506 int r;
35507 unsigned o;
35508 struct offset *offset;
35509 char last_reg_s[10];
35510 - int last_reg;
35511 + unsigned long last_reg;
35512
35513 if (regcomp
35514 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
35515 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
35516 index 44b8034..cc722fd 100644
35517 --- a/drivers/gpu/drm/radeon/radeon_device.c
35518 +++ b/drivers/gpu/drm/radeon/radeon_device.c
35519 @@ -977,7 +977,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
35520 bool can_switch;
35521
35522 spin_lock(&dev->count_lock);
35523 - can_switch = (dev->open_count == 0);
35524 + can_switch = (local_read(&dev->open_count) == 0);
35525 spin_unlock(&dev->count_lock);
35526 return can_switch;
35527 }
35528 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
35529 index b369d42..8dd04eb 100644
35530 --- a/drivers/gpu/drm/radeon/radeon_drv.h
35531 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
35532 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
35533
35534 /* SW interrupt */
35535 wait_queue_head_t swi_queue;
35536 - atomic_t swi_emitted;
35537 + atomic_unchecked_t swi_emitted;
35538 int vblank_crtc;
35539 uint32_t irq_enable_reg;
35540 uint32_t r500_disp_irq_reg;
35541 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
35542 index c180df8..5fd8186 100644
35543 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
35544 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
35545 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35546 request = compat_alloc_user_space(sizeof(*request));
35547 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
35548 || __put_user(req32.param, &request->param)
35549 - || __put_user((void __user *)(unsigned long)req32.value,
35550 + || __put_user((unsigned long)req32.value,
35551 &request->value))
35552 return -EFAULT;
35553
35554 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35555 #define compat_radeon_cp_setparam NULL
35556 #endif /* X86_64 || IA64 */
35557
35558 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35559 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
35560 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
35561 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
35562 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
35563 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35564 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35565 {
35566 unsigned int nr = DRM_IOCTL_NR(cmd);
35567 - drm_ioctl_compat_t *fn = NULL;
35568 int ret;
35569
35570 if (nr < DRM_COMMAND_BASE)
35571 return drm_compat_ioctl(filp, cmd, arg);
35572
35573 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
35574 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35575 -
35576 - if (fn != NULL)
35577 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
35578 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35579 ret = (*fn) (filp, cmd, arg);
35580 - else
35581 + } else
35582 ret = drm_ioctl(filp, cmd, arg);
35583
35584 return ret;
35585 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
35586 index 8d68e97..9dcfed8 100644
35587 --- a/drivers/gpu/drm/radeon/radeon_irq.c
35588 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
35589 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
35590 unsigned int ret;
35591 RING_LOCALS;
35592
35593 - atomic_inc(&dev_priv->swi_emitted);
35594 - ret = atomic_read(&dev_priv->swi_emitted);
35595 + atomic_inc_unchecked(&dev_priv->swi_emitted);
35596 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
35597
35598 BEGIN_RING(4);
35599 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
35600 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
35601 drm_radeon_private_t *dev_priv =
35602 (drm_radeon_private_t *) dev->dev_private;
35603
35604 - atomic_set(&dev_priv->swi_emitted, 0);
35605 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
35606 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
35607
35608 dev->max_vblank_count = 0x001fffff;
35609 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
35610 index 4d20910..6726b6d 100644
35611 --- a/drivers/gpu/drm/radeon/radeon_state.c
35612 +++ b/drivers/gpu/drm/radeon/radeon_state.c
35613 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
35614 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
35615 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
35616
35617 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
35618 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
35619 sarea_priv->nbox * sizeof(depth_boxes[0])))
35620 return -EFAULT;
35621
35622 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
35623 {
35624 drm_radeon_private_t *dev_priv = dev->dev_private;
35625 drm_radeon_getparam_t *param = data;
35626 - int value;
35627 + int value = 0;
35628
35629 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
35630
35631 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
35632 index 93f760e..8088227 100644
35633 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
35634 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
35635 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
35636 man->size = size >> PAGE_SHIFT;
35637 }
35638
35639 -static struct vm_operations_struct radeon_ttm_vm_ops;
35640 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
35641 static const struct vm_operations_struct *ttm_vm_ops = NULL;
35642
35643 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
35644 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
35645 }
35646 if (unlikely(ttm_vm_ops == NULL)) {
35647 ttm_vm_ops = vma->vm_ops;
35648 + pax_open_kernel();
35649 radeon_ttm_vm_ops = *ttm_vm_ops;
35650 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
35651 + pax_close_kernel();
35652 }
35653 vma->vm_ops = &radeon_ttm_vm_ops;
35654 return 0;
35655 @@ -862,28 +864,33 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
35656 sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
35657 else
35658 sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
35659 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35660 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
35661 - radeon_mem_types_list[i].driver_features = 0;
35662 + pax_open_kernel();
35663 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35664 + *(void **)&radeon_mem_types_list[i].show = &radeon_mm_dump_table;
35665 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35666 if (i == 0)
35667 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
35668 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
35669 else
35670 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
35671 -
35672 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
35673 + pax_close_kernel();
35674 }
35675 /* Add ttm page pool to debugfs */
35676 sprintf(radeon_mem_types_names[i], "ttm_page_pool");
35677 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35678 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
35679 - radeon_mem_types_list[i].driver_features = 0;
35680 - radeon_mem_types_list[i++].data = NULL;
35681 + pax_open_kernel();
35682 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35683 + *(void **)&radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
35684 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35685 + *(void **)&radeon_mem_types_list[i++].data = NULL;
35686 + pax_close_kernel();
35687 #ifdef CONFIG_SWIOTLB
35688 if (swiotlb_nr_tbl()) {
35689 sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
35690 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35691 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
35692 - radeon_mem_types_list[i].driver_features = 0;
35693 - radeon_mem_types_list[i++].data = NULL;
35694 + pax_open_kernel();
35695 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35696 + *(void **)&radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
35697 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35698 + *(void **)&radeon_mem_types_list[i++].data = NULL;
35699 + pax_close_kernel();
35700 }
35701 #endif
35702 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
35703 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
35704 index 5706d2a..17aedaa 100644
35705 --- a/drivers/gpu/drm/radeon/rs690.c
35706 +++ b/drivers/gpu/drm/radeon/rs690.c
35707 @@ -304,9 +304,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
35708 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
35709 rdev->pm.sideport_bandwidth.full)
35710 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
35711 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
35712 + read_delay_latency.full = dfixed_const(800 * 1000);
35713 read_delay_latency.full = dfixed_div(read_delay_latency,
35714 rdev->pm.igp_sideport_mclk);
35715 + a.full = dfixed_const(370);
35716 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
35717 } else {
35718 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
35719 rdev->pm.k8_bandwidth.full)
35720 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
35721 index bd2a3b4..122d9ad 100644
35722 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
35723 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
35724 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
35725 static int ttm_pool_mm_shrink(struct shrinker *shrink,
35726 struct shrink_control *sc)
35727 {
35728 - static atomic_t start_pool = ATOMIC_INIT(0);
35729 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
35730 unsigned i;
35731 - unsigned pool_offset = atomic_add_return(1, &start_pool);
35732 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
35733 struct ttm_page_pool *pool;
35734 int shrink_pages = sc->nr_to_scan;
35735
35736 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
35737 index 9f4be3d..cbc9fcc 100644
35738 --- a/drivers/gpu/drm/udl/udl_fb.c
35739 +++ b/drivers/gpu/drm/udl/udl_fb.c
35740 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
35741 fb_deferred_io_cleanup(info);
35742 kfree(info->fbdefio);
35743 info->fbdefio = NULL;
35744 - info->fbops->fb_mmap = udl_fb_mmap;
35745 }
35746
35747 pr_warn("released /dev/fb%d user=%d count=%d\n",
35748 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
35749 index 893a650..6190d3b 100644
35750 --- a/drivers/gpu/drm/via/via_drv.h
35751 +++ b/drivers/gpu/drm/via/via_drv.h
35752 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
35753 typedef uint32_t maskarray_t[5];
35754
35755 typedef struct drm_via_irq {
35756 - atomic_t irq_received;
35757 + atomic_unchecked_t irq_received;
35758 uint32_t pending_mask;
35759 uint32_t enable_mask;
35760 wait_queue_head_t irq_queue;
35761 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
35762 struct timeval last_vblank;
35763 int last_vblank_valid;
35764 unsigned usec_per_vblank;
35765 - atomic_t vbl_received;
35766 + atomic_unchecked_t vbl_received;
35767 drm_via_state_t hc_state;
35768 char pci_buf[VIA_PCI_BUF_SIZE];
35769 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
35770 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
35771 index ac98964..5dbf512 100644
35772 --- a/drivers/gpu/drm/via/via_irq.c
35773 +++ b/drivers/gpu/drm/via/via_irq.c
35774 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
35775 if (crtc != 0)
35776 return 0;
35777
35778 - return atomic_read(&dev_priv->vbl_received);
35779 + return atomic_read_unchecked(&dev_priv->vbl_received);
35780 }
35781
35782 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
35783 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
35784
35785 status = VIA_READ(VIA_REG_INTERRUPT);
35786 if (status & VIA_IRQ_VBLANK_PENDING) {
35787 - atomic_inc(&dev_priv->vbl_received);
35788 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
35789 + atomic_inc_unchecked(&dev_priv->vbl_received);
35790 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
35791 do_gettimeofday(&cur_vblank);
35792 if (dev_priv->last_vblank_valid) {
35793 dev_priv->usec_per_vblank =
35794 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
35795 dev_priv->last_vblank = cur_vblank;
35796 dev_priv->last_vblank_valid = 1;
35797 }
35798 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
35799 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
35800 DRM_DEBUG("US per vblank is: %u\n",
35801 dev_priv->usec_per_vblank);
35802 }
35803 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
35804
35805 for (i = 0; i < dev_priv->num_irqs; ++i) {
35806 if (status & cur_irq->pending_mask) {
35807 - atomic_inc(&cur_irq->irq_received);
35808 + atomic_inc_unchecked(&cur_irq->irq_received);
35809 DRM_WAKEUP(&cur_irq->irq_queue);
35810 handled = 1;
35811 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
35812 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
35813 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
35814 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
35815 masks[irq][4]));
35816 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
35817 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
35818 } else {
35819 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
35820 (((cur_irq_sequence =
35821 - atomic_read(&cur_irq->irq_received)) -
35822 + atomic_read_unchecked(&cur_irq->irq_received)) -
35823 *sequence) <= (1 << 23)));
35824 }
35825 *sequence = cur_irq_sequence;
35826 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
35827 }
35828
35829 for (i = 0; i < dev_priv->num_irqs; ++i) {
35830 - atomic_set(&cur_irq->irq_received, 0);
35831 + atomic_set_unchecked(&cur_irq->irq_received, 0);
35832 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
35833 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
35834 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
35835 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
35836 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
35837 case VIA_IRQ_RELATIVE:
35838 irqwait->request.sequence +=
35839 - atomic_read(&cur_irq->irq_received);
35840 + atomic_read_unchecked(&cur_irq->irq_received);
35841 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
35842 case VIA_IRQ_ABSOLUTE:
35843 break;
35844 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
35845 index 13aeda7..4a952d1 100644
35846 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
35847 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
35848 @@ -290,7 +290,7 @@ struct vmw_private {
35849 * Fencing and IRQs.
35850 */
35851
35852 - atomic_t marker_seq;
35853 + atomic_unchecked_t marker_seq;
35854 wait_queue_head_t fence_queue;
35855 wait_queue_head_t fifo_queue;
35856 int fence_queue_waiters; /* Protected by hw_mutex */
35857 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
35858 index 3eb1486..0a47ee9 100644
35859 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
35860 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
35861 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
35862 (unsigned int) min,
35863 (unsigned int) fifo->capabilities);
35864
35865 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
35866 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
35867 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
35868 vmw_marker_queue_init(&fifo->marker_queue);
35869 return vmw_fifo_send_fence(dev_priv, &dummy);
35870 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
35871 if (reserveable)
35872 iowrite32(bytes, fifo_mem +
35873 SVGA_FIFO_RESERVED);
35874 - return fifo_mem + (next_cmd >> 2);
35875 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
35876 } else {
35877 need_bounce = true;
35878 }
35879 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
35880
35881 fm = vmw_fifo_reserve(dev_priv, bytes);
35882 if (unlikely(fm == NULL)) {
35883 - *seqno = atomic_read(&dev_priv->marker_seq);
35884 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
35885 ret = -ENOMEM;
35886 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
35887 false, 3*HZ);
35888 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
35889 }
35890
35891 do {
35892 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
35893 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
35894 } while (*seqno == 0);
35895
35896 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
35897 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
35898 index 4640adb..e1384ed 100644
35899 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
35900 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
35901 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
35902 * emitted. Then the fence is stale and signaled.
35903 */
35904
35905 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
35906 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
35907 > VMW_FENCE_WRAP);
35908
35909 return ret;
35910 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
35911
35912 if (fifo_idle)
35913 down_read(&fifo_state->rwsem);
35914 - signal_seq = atomic_read(&dev_priv->marker_seq);
35915 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
35916 ret = 0;
35917
35918 for (;;) {
35919 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
35920 index 8a8725c..afed796 100644
35921 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
35922 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
35923 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
35924 while (!vmw_lag_lt(queue, us)) {
35925 spin_lock(&queue->lock);
35926 if (list_empty(&queue->head))
35927 - seqno = atomic_read(&dev_priv->marker_seq);
35928 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
35929 else {
35930 marker = list_first_entry(&queue->head,
35931 struct vmw_marker, head);
35932 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
35933 index aa341d1..ef07090 100644
35934 --- a/drivers/hid/hid-core.c
35935 +++ b/drivers/hid/hid-core.c
35936 @@ -2267,7 +2267,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
35937
35938 int hid_add_device(struct hid_device *hdev)
35939 {
35940 - static atomic_t id = ATOMIC_INIT(0);
35941 + static atomic_unchecked_t id = ATOMIC_INIT(0);
35942 int ret;
35943
35944 if (WARN_ON(hdev->status & HID_STAT_ADDED))
35945 @@ -2301,7 +2301,7 @@ int hid_add_device(struct hid_device *hdev)
35946 /* XXX hack, any other cleaner solution after the driver core
35947 * is converted to allow more than 20 bytes as the device name? */
35948 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
35949 - hdev->vendor, hdev->product, atomic_inc_return(&id));
35950 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
35951
35952 hid_debug_register(hdev, dev_name(&hdev->dev));
35953 ret = device_add(&hdev->dev);
35954 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
35955 index 90124ff..3761764 100644
35956 --- a/drivers/hid/hid-wiimote-debug.c
35957 +++ b/drivers/hid/hid-wiimote-debug.c
35958 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
35959 else if (size == 0)
35960 return -EIO;
35961
35962 - if (copy_to_user(u, buf, size))
35963 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
35964 return -EFAULT;
35965
35966 *off += size;
35967 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
35968 index 0b122f8..b1d8160 100644
35969 --- a/drivers/hv/channel.c
35970 +++ b/drivers/hv/channel.c
35971 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
35972 int ret = 0;
35973 int t;
35974
35975 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
35976 - atomic_inc(&vmbus_connection.next_gpadl_handle);
35977 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
35978 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
35979
35980 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
35981 if (ret)
35982 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
35983 index 7311589..861e9ef 100644
35984 --- a/drivers/hv/hv.c
35985 +++ b/drivers/hv/hv.c
35986 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
35987 u64 output_address = (output) ? virt_to_phys(output) : 0;
35988 u32 output_address_hi = output_address >> 32;
35989 u32 output_address_lo = output_address & 0xFFFFFFFF;
35990 - void *hypercall_page = hv_context.hypercall_page;
35991 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
35992
35993 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
35994 "=a"(hv_status_lo) : "d" (control_hi),
35995 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
35996 index 12f2f9e..679603c 100644
35997 --- a/drivers/hv/hyperv_vmbus.h
35998 +++ b/drivers/hv/hyperv_vmbus.h
35999 @@ -591,7 +591,7 @@ enum vmbus_connect_state {
36000 struct vmbus_connection {
36001 enum vmbus_connect_state conn_state;
36002
36003 - atomic_t next_gpadl_handle;
36004 + atomic_unchecked_t next_gpadl_handle;
36005
36006 /*
36007 * Represents channel interrupts. Each bit position represents a
36008 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36009 index bf421e0..ce2c897 100644
36010 --- a/drivers/hv/vmbus_drv.c
36011 +++ b/drivers/hv/vmbus_drv.c
36012 @@ -668,10 +668,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36013 {
36014 int ret = 0;
36015
36016 - static atomic_t device_num = ATOMIC_INIT(0);
36017 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36018
36019 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36020 - atomic_inc_return(&device_num));
36021 + atomic_inc_return_unchecked(&device_num));
36022
36023 child_device_obj->device.bus = &hv_bus;
36024 child_device_obj->device.parent = &hv_acpi_dev->dev;
36025 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36026 index 6351aba..dc4aaf4 100644
36027 --- a/drivers/hwmon/acpi_power_meter.c
36028 +++ b/drivers/hwmon/acpi_power_meter.c
36029 @@ -117,7 +117,7 @@ struct sensor_template {
36030 struct device_attribute *devattr,
36031 const char *buf, size_t count);
36032 int index;
36033 -};
36034 +} __do_const;
36035
36036 /* Averaging interval */
36037 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36038 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36039 struct sensor_template *attrs)
36040 {
36041 struct device *dev = &resource->acpi_dev->dev;
36042 - struct sensor_device_attribute *sensors =
36043 + sensor_device_attribute_no_const *sensors =
36044 &resource->sensors[resource->num_sensors];
36045 int res = 0;
36046
36047 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36048 index b41baff..4953e4d 100644
36049 --- a/drivers/hwmon/applesmc.c
36050 +++ b/drivers/hwmon/applesmc.c
36051 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36052 {
36053 struct applesmc_node_group *grp;
36054 struct applesmc_dev_attr *node;
36055 - struct attribute *attr;
36056 + attribute_no_const *attr;
36057 int ret, i;
36058
36059 for (grp = groups; grp->format; grp++) {
36060 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36061 index b25c643..a13460d 100644
36062 --- a/drivers/hwmon/asus_atk0110.c
36063 +++ b/drivers/hwmon/asus_atk0110.c
36064 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36065 struct atk_sensor_data {
36066 struct list_head list;
36067 struct atk_data *data;
36068 - struct device_attribute label_attr;
36069 - struct device_attribute input_attr;
36070 - struct device_attribute limit1_attr;
36071 - struct device_attribute limit2_attr;
36072 + device_attribute_no_const label_attr;
36073 + device_attribute_no_const input_attr;
36074 + device_attribute_no_const limit1_attr;
36075 + device_attribute_no_const limit2_attr;
36076 char label_attr_name[ATTR_NAME_SIZE];
36077 char input_attr_name[ATTR_NAME_SIZE];
36078 char limit1_attr_name[ATTR_NAME_SIZE];
36079 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36080 static struct device_attribute atk_name_attr =
36081 __ATTR(name, 0444, atk_name_show, NULL);
36082
36083 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36084 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36085 sysfs_show_func show)
36086 {
36087 sysfs_attr_init(&attr->attr);
36088 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36089 index 3f1e297..a6cafb5 100644
36090 --- a/drivers/hwmon/coretemp.c
36091 +++ b/drivers/hwmon/coretemp.c
36092 @@ -791,7 +791,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36093 return NOTIFY_OK;
36094 }
36095
36096 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36097 +static struct notifier_block coretemp_cpu_notifier = {
36098 .notifier_call = coretemp_cpu_callback,
36099 };
36100
36101 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36102 index a14f634..2916ee2 100644
36103 --- a/drivers/hwmon/ibmaem.c
36104 +++ b/drivers/hwmon/ibmaem.c
36105 @@ -925,7 +925,7 @@ static int aem_register_sensors(struct aem_data *data,
36106 struct aem_rw_sensor_template *rw)
36107 {
36108 struct device *dev = &data->pdev->dev;
36109 - struct sensor_device_attribute *sensors = data->sensors;
36110 + sensor_device_attribute_no_const *sensors = data->sensors;
36111 int err;
36112
36113 /* Set up read-only sensors */
36114 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36115 index 2507f90..1645765 100644
36116 --- a/drivers/hwmon/sht15.c
36117 +++ b/drivers/hwmon/sht15.c
36118 @@ -169,7 +169,7 @@ struct sht15_data {
36119 int supply_uv;
36120 bool supply_uv_valid;
36121 struct work_struct update_supply_work;
36122 - atomic_t interrupt_handled;
36123 + atomic_unchecked_t interrupt_handled;
36124 };
36125
36126 /**
36127 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
36128 ret = gpio_direction_input(data->pdata->gpio_data);
36129 if (ret)
36130 return ret;
36131 - atomic_set(&data->interrupt_handled, 0);
36132 + atomic_set_unchecked(&data->interrupt_handled, 0);
36133
36134 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36135 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36136 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36137 /* Only relevant if the interrupt hasn't occurred. */
36138 - if (!atomic_read(&data->interrupt_handled))
36139 + if (!atomic_read_unchecked(&data->interrupt_handled))
36140 schedule_work(&data->read_work);
36141 }
36142 ret = wait_event_timeout(data->wait_queue,
36143 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36144
36145 /* First disable the interrupt */
36146 disable_irq_nosync(irq);
36147 - atomic_inc(&data->interrupt_handled);
36148 + atomic_inc_unchecked(&data->interrupt_handled);
36149 /* Then schedule a reading work struct */
36150 if (data->state != SHT15_READING_NOTHING)
36151 schedule_work(&data->read_work);
36152 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36153 * If not, then start the interrupt again - care here as could
36154 * have gone low in meantime so verify it hasn't!
36155 */
36156 - atomic_set(&data->interrupt_handled, 0);
36157 + atomic_set_unchecked(&data->interrupt_handled, 0);
36158 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36159 /* If still not occurred or another handler was scheduled */
36160 if (gpio_get_value(data->pdata->gpio_data)
36161 - || atomic_read(&data->interrupt_handled))
36162 + || atomic_read_unchecked(&data->interrupt_handled))
36163 return;
36164 }
36165
36166 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36167 index 76f157b..9c0db1b 100644
36168 --- a/drivers/hwmon/via-cputemp.c
36169 +++ b/drivers/hwmon/via-cputemp.c
36170 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36171 return NOTIFY_OK;
36172 }
36173
36174 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36175 +static struct notifier_block via_cputemp_cpu_notifier = {
36176 .notifier_call = via_cputemp_cpu_callback,
36177 };
36178
36179 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36180 index 378fcb5..5e91fa8 100644
36181 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36182 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36183 @@ -43,7 +43,7 @@
36184 extern struct i2c_adapter amd756_smbus;
36185
36186 static struct i2c_adapter *s4882_adapter;
36187 -static struct i2c_algorithm *s4882_algo;
36188 +static i2c_algorithm_no_const *s4882_algo;
36189
36190 /* Wrapper access functions for multiplexed SMBus */
36191 static DEFINE_MUTEX(amd756_lock);
36192 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36193 index 29015eb..af2d8e9 100644
36194 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36195 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36196 @@ -41,7 +41,7 @@
36197 extern struct i2c_adapter *nforce2_smbus;
36198
36199 static struct i2c_adapter *s4985_adapter;
36200 -static struct i2c_algorithm *s4985_algo;
36201 +static i2c_algorithm_no_const *s4985_algo;
36202
36203 /* Wrapper access functions for multiplexed SMBus */
36204 static DEFINE_MUTEX(nforce2_lock);
36205 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
36206 index 8126824..55a2798 100644
36207 --- a/drivers/ide/ide-cd.c
36208 +++ b/drivers/ide/ide-cd.c
36209 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
36210 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
36211 if ((unsigned long)buf & alignment
36212 || blk_rq_bytes(rq) & q->dma_pad_mask
36213 - || object_is_on_stack(buf))
36214 + || object_starts_on_stack(buf))
36215 drive->dma = 0;
36216 }
36217 }
36218 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
36219 index 8848f16..f8e6dd8 100644
36220 --- a/drivers/iio/industrialio-core.c
36221 +++ b/drivers/iio/industrialio-core.c
36222 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
36223 }
36224
36225 static
36226 -int __iio_device_attr_init(struct device_attribute *dev_attr,
36227 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
36228 const char *postfix,
36229 struct iio_chan_spec const *chan,
36230 ssize_t (*readfunc)(struct device *dev,
36231 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
36232 index 784b97c..c9ceadf 100644
36233 --- a/drivers/infiniband/core/cm.c
36234 +++ b/drivers/infiniband/core/cm.c
36235 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
36236
36237 struct cm_counter_group {
36238 struct kobject obj;
36239 - atomic_long_t counter[CM_ATTR_COUNT];
36240 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
36241 };
36242
36243 struct cm_counter_attribute {
36244 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
36245 struct ib_mad_send_buf *msg = NULL;
36246 int ret;
36247
36248 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36249 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36250 counter[CM_REQ_COUNTER]);
36251
36252 /* Quick state check to discard duplicate REQs. */
36253 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
36254 if (!cm_id_priv)
36255 return;
36256
36257 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36258 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36259 counter[CM_REP_COUNTER]);
36260 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
36261 if (ret)
36262 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
36263 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
36264 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
36265 spin_unlock_irq(&cm_id_priv->lock);
36266 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36267 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36268 counter[CM_RTU_COUNTER]);
36269 goto out;
36270 }
36271 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
36272 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
36273 dreq_msg->local_comm_id);
36274 if (!cm_id_priv) {
36275 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36276 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36277 counter[CM_DREQ_COUNTER]);
36278 cm_issue_drep(work->port, work->mad_recv_wc);
36279 return -EINVAL;
36280 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
36281 case IB_CM_MRA_REP_RCVD:
36282 break;
36283 case IB_CM_TIMEWAIT:
36284 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36285 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36286 counter[CM_DREQ_COUNTER]);
36287 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36288 goto unlock;
36289 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
36290 cm_free_msg(msg);
36291 goto deref;
36292 case IB_CM_DREQ_RCVD:
36293 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36294 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36295 counter[CM_DREQ_COUNTER]);
36296 goto unlock;
36297 default:
36298 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
36299 ib_modify_mad(cm_id_priv->av.port->mad_agent,
36300 cm_id_priv->msg, timeout)) {
36301 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
36302 - atomic_long_inc(&work->port->
36303 + atomic_long_inc_unchecked(&work->port->
36304 counter_group[CM_RECV_DUPLICATES].
36305 counter[CM_MRA_COUNTER]);
36306 goto out;
36307 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
36308 break;
36309 case IB_CM_MRA_REQ_RCVD:
36310 case IB_CM_MRA_REP_RCVD:
36311 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36312 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36313 counter[CM_MRA_COUNTER]);
36314 /* fall through */
36315 default:
36316 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
36317 case IB_CM_LAP_IDLE:
36318 break;
36319 case IB_CM_MRA_LAP_SENT:
36320 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36321 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36322 counter[CM_LAP_COUNTER]);
36323 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36324 goto unlock;
36325 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
36326 cm_free_msg(msg);
36327 goto deref;
36328 case IB_CM_LAP_RCVD:
36329 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36330 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36331 counter[CM_LAP_COUNTER]);
36332 goto unlock;
36333 default:
36334 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
36335 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
36336 if (cur_cm_id_priv) {
36337 spin_unlock_irq(&cm.lock);
36338 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36339 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36340 counter[CM_SIDR_REQ_COUNTER]);
36341 goto out; /* Duplicate message. */
36342 }
36343 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
36344 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
36345 msg->retries = 1;
36346
36347 - atomic_long_add(1 + msg->retries,
36348 + atomic_long_add_unchecked(1 + msg->retries,
36349 &port->counter_group[CM_XMIT].counter[attr_index]);
36350 if (msg->retries)
36351 - atomic_long_add(msg->retries,
36352 + atomic_long_add_unchecked(msg->retries,
36353 &port->counter_group[CM_XMIT_RETRIES].
36354 counter[attr_index]);
36355
36356 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
36357 }
36358
36359 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
36360 - atomic_long_inc(&port->counter_group[CM_RECV].
36361 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
36362 counter[attr_id - CM_ATTR_ID_OFFSET]);
36363
36364 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
36365 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
36366 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
36367
36368 return sprintf(buf, "%ld\n",
36369 - atomic_long_read(&group->counter[cm_attr->index]));
36370 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
36371 }
36372
36373 static const struct sysfs_ops cm_counter_ops = {
36374 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
36375 index 9f5ad7c..588cd84 100644
36376 --- a/drivers/infiniband/core/fmr_pool.c
36377 +++ b/drivers/infiniband/core/fmr_pool.c
36378 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
36379
36380 struct task_struct *thread;
36381
36382 - atomic_t req_ser;
36383 - atomic_t flush_ser;
36384 + atomic_unchecked_t req_ser;
36385 + atomic_unchecked_t flush_ser;
36386
36387 wait_queue_head_t force_wait;
36388 };
36389 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36390 struct ib_fmr_pool *pool = pool_ptr;
36391
36392 do {
36393 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
36394 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
36395 ib_fmr_batch_release(pool);
36396
36397 - atomic_inc(&pool->flush_ser);
36398 + atomic_inc_unchecked(&pool->flush_ser);
36399 wake_up_interruptible(&pool->force_wait);
36400
36401 if (pool->flush_function)
36402 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36403 }
36404
36405 set_current_state(TASK_INTERRUPTIBLE);
36406 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
36407 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
36408 !kthread_should_stop())
36409 schedule();
36410 __set_current_state(TASK_RUNNING);
36411 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
36412 pool->dirty_watermark = params->dirty_watermark;
36413 pool->dirty_len = 0;
36414 spin_lock_init(&pool->pool_lock);
36415 - atomic_set(&pool->req_ser, 0);
36416 - atomic_set(&pool->flush_ser, 0);
36417 + atomic_set_unchecked(&pool->req_ser, 0);
36418 + atomic_set_unchecked(&pool->flush_ser, 0);
36419 init_waitqueue_head(&pool->force_wait);
36420
36421 pool->thread = kthread_run(ib_fmr_cleanup_thread,
36422 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
36423 }
36424 spin_unlock_irq(&pool->pool_lock);
36425
36426 - serial = atomic_inc_return(&pool->req_ser);
36427 + serial = atomic_inc_return_unchecked(&pool->req_ser);
36428 wake_up_process(pool->thread);
36429
36430 if (wait_event_interruptible(pool->force_wait,
36431 - atomic_read(&pool->flush_ser) - serial >= 0))
36432 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
36433 return -EINTR;
36434
36435 return 0;
36436 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
36437 } else {
36438 list_add_tail(&fmr->list, &pool->dirty_list);
36439 if (++pool->dirty_len >= pool->dirty_watermark) {
36440 - atomic_inc(&pool->req_ser);
36441 + atomic_inc_unchecked(&pool->req_ser);
36442 wake_up_process(pool->thread);
36443 }
36444 }
36445 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
36446 index 903a92d..9262548 100644
36447 --- a/drivers/infiniband/hw/cxgb4/mem.c
36448 +++ b/drivers/infiniband/hw/cxgb4/mem.c
36449 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36450 int err;
36451 struct fw_ri_tpte tpt;
36452 u32 stag_idx;
36453 - static atomic_t key;
36454 + static atomic_unchecked_t key;
36455
36456 if (c4iw_fatal_error(rdev))
36457 return -EIO;
36458 @@ -139,7 +139,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36459 if (rdev->stats.stag.cur > rdev->stats.stag.max)
36460 rdev->stats.stag.max = rdev->stats.stag.cur;
36461 mutex_unlock(&rdev->stats.lock);
36462 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
36463 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
36464 }
36465 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
36466 __func__, stag_state, type, pdid, stag_idx);
36467 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
36468 index 79b3dbc..96e5fcc 100644
36469 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
36470 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
36471 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36472 struct ib_atomic_eth *ateth;
36473 struct ipath_ack_entry *e;
36474 u64 vaddr;
36475 - atomic64_t *maddr;
36476 + atomic64_unchecked_t *maddr;
36477 u64 sdata;
36478 u32 rkey;
36479 u8 next;
36480 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36481 IB_ACCESS_REMOTE_ATOMIC)))
36482 goto nack_acc_unlck;
36483 /* Perform atomic OP and save result. */
36484 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
36485 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
36486 sdata = be64_to_cpu(ateth->swap_data);
36487 e = &qp->s_ack_queue[qp->r_head_ack_queue];
36488 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
36489 - (u64) atomic64_add_return(sdata, maddr) - sdata :
36490 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
36491 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
36492 be64_to_cpu(ateth->compare_data),
36493 sdata);
36494 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
36495 index 1f95bba..9530f87 100644
36496 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
36497 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
36498 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
36499 unsigned long flags;
36500 struct ib_wc wc;
36501 u64 sdata;
36502 - atomic64_t *maddr;
36503 + atomic64_unchecked_t *maddr;
36504 enum ib_wc_status send_status;
36505
36506 /*
36507 @@ -382,11 +382,11 @@ again:
36508 IB_ACCESS_REMOTE_ATOMIC)))
36509 goto acc_err;
36510 /* Perform atomic OP and save result. */
36511 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
36512 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
36513 sdata = wqe->wr.wr.atomic.compare_add;
36514 *(u64 *) sqp->s_sge.sge.vaddr =
36515 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
36516 - (u64) atomic64_add_return(sdata, maddr) - sdata :
36517 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
36518 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
36519 sdata, wqe->wr.wr.atomic.swap);
36520 goto send_comp;
36521 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
36522 index 9d3e5c1..d9afe4a 100644
36523 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
36524 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
36525 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
36526 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
36527 }
36528
36529 -int mthca_QUERY_FW(struct mthca_dev *dev)
36530 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
36531 {
36532 struct mthca_mailbox *mailbox;
36533 u32 *outbox;
36534 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
36535 index ed9a989..e0c5871 100644
36536 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
36537 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
36538 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
36539 return key;
36540 }
36541
36542 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
36543 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
36544 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
36545 {
36546 struct mthca_mailbox *mailbox;
36547 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
36548 index 4291410..d2ab1fb 100644
36549 --- a/drivers/infiniband/hw/nes/nes.c
36550 +++ b/drivers/infiniband/hw/nes/nes.c
36551 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
36552 LIST_HEAD(nes_adapter_list);
36553 static LIST_HEAD(nes_dev_list);
36554
36555 -atomic_t qps_destroyed;
36556 +atomic_unchecked_t qps_destroyed;
36557
36558 static unsigned int ee_flsh_adapter;
36559 static unsigned int sysfs_nonidx_addr;
36560 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
36561 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
36562 struct nes_adapter *nesadapter = nesdev->nesadapter;
36563
36564 - atomic_inc(&qps_destroyed);
36565 + atomic_inc_unchecked(&qps_destroyed);
36566
36567 /* Free the control structures */
36568
36569 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
36570 index 33cc589..3bd6538 100644
36571 --- a/drivers/infiniband/hw/nes/nes.h
36572 +++ b/drivers/infiniband/hw/nes/nes.h
36573 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
36574 extern unsigned int wqm_quanta;
36575 extern struct list_head nes_adapter_list;
36576
36577 -extern atomic_t cm_connects;
36578 -extern atomic_t cm_accepts;
36579 -extern atomic_t cm_disconnects;
36580 -extern atomic_t cm_closes;
36581 -extern atomic_t cm_connecteds;
36582 -extern atomic_t cm_connect_reqs;
36583 -extern atomic_t cm_rejects;
36584 -extern atomic_t mod_qp_timouts;
36585 -extern atomic_t qps_created;
36586 -extern atomic_t qps_destroyed;
36587 -extern atomic_t sw_qps_destroyed;
36588 +extern atomic_unchecked_t cm_connects;
36589 +extern atomic_unchecked_t cm_accepts;
36590 +extern atomic_unchecked_t cm_disconnects;
36591 +extern atomic_unchecked_t cm_closes;
36592 +extern atomic_unchecked_t cm_connecteds;
36593 +extern atomic_unchecked_t cm_connect_reqs;
36594 +extern atomic_unchecked_t cm_rejects;
36595 +extern atomic_unchecked_t mod_qp_timouts;
36596 +extern atomic_unchecked_t qps_created;
36597 +extern atomic_unchecked_t qps_destroyed;
36598 +extern atomic_unchecked_t sw_qps_destroyed;
36599 extern u32 mh_detected;
36600 extern u32 mh_pauses_sent;
36601 extern u32 cm_packets_sent;
36602 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
36603 extern u32 cm_packets_received;
36604 extern u32 cm_packets_dropped;
36605 extern u32 cm_packets_retrans;
36606 -extern atomic_t cm_listens_created;
36607 -extern atomic_t cm_listens_destroyed;
36608 +extern atomic_unchecked_t cm_listens_created;
36609 +extern atomic_unchecked_t cm_listens_destroyed;
36610 extern u32 cm_backlog_drops;
36611 -extern atomic_t cm_loopbacks;
36612 -extern atomic_t cm_nodes_created;
36613 -extern atomic_t cm_nodes_destroyed;
36614 -extern atomic_t cm_accel_dropped_pkts;
36615 -extern atomic_t cm_resets_recvd;
36616 -extern atomic_t pau_qps_created;
36617 -extern atomic_t pau_qps_destroyed;
36618 +extern atomic_unchecked_t cm_loopbacks;
36619 +extern atomic_unchecked_t cm_nodes_created;
36620 +extern atomic_unchecked_t cm_nodes_destroyed;
36621 +extern atomic_unchecked_t cm_accel_dropped_pkts;
36622 +extern atomic_unchecked_t cm_resets_recvd;
36623 +extern atomic_unchecked_t pau_qps_created;
36624 +extern atomic_unchecked_t pau_qps_destroyed;
36625
36626 extern u32 int_mod_timer_init;
36627 extern u32 int_mod_cq_depth_256;
36628 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
36629 index 24b9f1a..00fd004 100644
36630 --- a/drivers/infiniband/hw/nes/nes_cm.c
36631 +++ b/drivers/infiniband/hw/nes/nes_cm.c
36632 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
36633 u32 cm_packets_retrans;
36634 u32 cm_packets_created;
36635 u32 cm_packets_received;
36636 -atomic_t cm_listens_created;
36637 -atomic_t cm_listens_destroyed;
36638 +atomic_unchecked_t cm_listens_created;
36639 +atomic_unchecked_t cm_listens_destroyed;
36640 u32 cm_backlog_drops;
36641 -atomic_t cm_loopbacks;
36642 -atomic_t cm_nodes_created;
36643 -atomic_t cm_nodes_destroyed;
36644 -atomic_t cm_accel_dropped_pkts;
36645 -atomic_t cm_resets_recvd;
36646 +atomic_unchecked_t cm_loopbacks;
36647 +atomic_unchecked_t cm_nodes_created;
36648 +atomic_unchecked_t cm_nodes_destroyed;
36649 +atomic_unchecked_t cm_accel_dropped_pkts;
36650 +atomic_unchecked_t cm_resets_recvd;
36651
36652 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
36653 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
36654 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
36655
36656 static struct nes_cm_core *g_cm_core;
36657
36658 -atomic_t cm_connects;
36659 -atomic_t cm_accepts;
36660 -atomic_t cm_disconnects;
36661 -atomic_t cm_closes;
36662 -atomic_t cm_connecteds;
36663 -atomic_t cm_connect_reqs;
36664 -atomic_t cm_rejects;
36665 +atomic_unchecked_t cm_connects;
36666 +atomic_unchecked_t cm_accepts;
36667 +atomic_unchecked_t cm_disconnects;
36668 +atomic_unchecked_t cm_closes;
36669 +atomic_unchecked_t cm_connecteds;
36670 +atomic_unchecked_t cm_connect_reqs;
36671 +atomic_unchecked_t cm_rejects;
36672
36673 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
36674 {
36675 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
36676 kfree(listener);
36677 listener = NULL;
36678 ret = 0;
36679 - atomic_inc(&cm_listens_destroyed);
36680 + atomic_inc_unchecked(&cm_listens_destroyed);
36681 } else {
36682 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
36683 }
36684 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
36685 cm_node->rem_mac);
36686
36687 add_hte_node(cm_core, cm_node);
36688 - atomic_inc(&cm_nodes_created);
36689 + atomic_inc_unchecked(&cm_nodes_created);
36690
36691 return cm_node;
36692 }
36693 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
36694 }
36695
36696 atomic_dec(&cm_core->node_cnt);
36697 - atomic_inc(&cm_nodes_destroyed);
36698 + atomic_inc_unchecked(&cm_nodes_destroyed);
36699 nesqp = cm_node->nesqp;
36700 if (nesqp) {
36701 nesqp->cm_node = NULL;
36702 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
36703
36704 static void drop_packet(struct sk_buff *skb)
36705 {
36706 - atomic_inc(&cm_accel_dropped_pkts);
36707 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
36708 dev_kfree_skb_any(skb);
36709 }
36710
36711 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
36712 {
36713
36714 int reset = 0; /* whether to send reset in case of err.. */
36715 - atomic_inc(&cm_resets_recvd);
36716 + atomic_inc_unchecked(&cm_resets_recvd);
36717 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
36718 " refcnt=%d\n", cm_node, cm_node->state,
36719 atomic_read(&cm_node->ref_count));
36720 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
36721 rem_ref_cm_node(cm_node->cm_core, cm_node);
36722 return NULL;
36723 }
36724 - atomic_inc(&cm_loopbacks);
36725 + atomic_inc_unchecked(&cm_loopbacks);
36726 loopbackremotenode->loopbackpartner = cm_node;
36727 loopbackremotenode->tcp_cntxt.rcv_wscale =
36728 NES_CM_DEFAULT_RCV_WND_SCALE;
36729 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
36730 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
36731 else {
36732 rem_ref_cm_node(cm_core, cm_node);
36733 - atomic_inc(&cm_accel_dropped_pkts);
36734 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
36735 dev_kfree_skb_any(skb);
36736 }
36737 break;
36738 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
36739
36740 if ((cm_id) && (cm_id->event_handler)) {
36741 if (issue_disconn) {
36742 - atomic_inc(&cm_disconnects);
36743 + atomic_inc_unchecked(&cm_disconnects);
36744 cm_event.event = IW_CM_EVENT_DISCONNECT;
36745 cm_event.status = disconn_status;
36746 cm_event.local_addr = cm_id->local_addr;
36747 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
36748 }
36749
36750 if (issue_close) {
36751 - atomic_inc(&cm_closes);
36752 + atomic_inc_unchecked(&cm_closes);
36753 nes_disconnect(nesqp, 1);
36754
36755 cm_id->provider_data = nesqp;
36756 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
36757
36758 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
36759 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
36760 - atomic_inc(&cm_accepts);
36761 + atomic_inc_unchecked(&cm_accepts);
36762
36763 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
36764 netdev_refcnt_read(nesvnic->netdev));
36765 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
36766 struct nes_cm_core *cm_core;
36767 u8 *start_buff;
36768
36769 - atomic_inc(&cm_rejects);
36770 + atomic_inc_unchecked(&cm_rejects);
36771 cm_node = (struct nes_cm_node *)cm_id->provider_data;
36772 loopback = cm_node->loopbackpartner;
36773 cm_core = cm_node->cm_core;
36774 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
36775 ntohl(cm_id->local_addr.sin_addr.s_addr),
36776 ntohs(cm_id->local_addr.sin_port));
36777
36778 - atomic_inc(&cm_connects);
36779 + atomic_inc_unchecked(&cm_connects);
36780 nesqp->active_conn = 1;
36781
36782 /* cache the cm_id in the qp */
36783 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
36784 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
36785 return err;
36786 }
36787 - atomic_inc(&cm_listens_created);
36788 + atomic_inc_unchecked(&cm_listens_created);
36789 }
36790
36791 cm_id->add_ref(cm_id);
36792 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
36793
36794 if (nesqp->destroyed)
36795 return;
36796 - atomic_inc(&cm_connecteds);
36797 + atomic_inc_unchecked(&cm_connecteds);
36798 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
36799 " local port 0x%04X. jiffies = %lu.\n",
36800 nesqp->hwqp.qp_id,
36801 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
36802
36803 cm_id->add_ref(cm_id);
36804 ret = cm_id->event_handler(cm_id, &cm_event);
36805 - atomic_inc(&cm_closes);
36806 + atomic_inc_unchecked(&cm_closes);
36807 cm_event.event = IW_CM_EVENT_CLOSE;
36808 cm_event.status = 0;
36809 cm_event.provider_data = cm_id->provider_data;
36810 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
36811 return;
36812 cm_id = cm_node->cm_id;
36813
36814 - atomic_inc(&cm_connect_reqs);
36815 + atomic_inc_unchecked(&cm_connect_reqs);
36816 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
36817 cm_node, cm_id, jiffies);
36818
36819 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
36820 return;
36821 cm_id = cm_node->cm_id;
36822
36823 - atomic_inc(&cm_connect_reqs);
36824 + atomic_inc_unchecked(&cm_connect_reqs);
36825 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
36826 cm_node, cm_id, jiffies);
36827
36828 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
36829 index 4166452..fc952c3 100644
36830 --- a/drivers/infiniband/hw/nes/nes_mgt.c
36831 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
36832 @@ -40,8 +40,8 @@
36833 #include "nes.h"
36834 #include "nes_mgt.h"
36835
36836 -atomic_t pau_qps_created;
36837 -atomic_t pau_qps_destroyed;
36838 +atomic_unchecked_t pau_qps_created;
36839 +atomic_unchecked_t pau_qps_destroyed;
36840
36841 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
36842 {
36843 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
36844 {
36845 struct sk_buff *skb;
36846 unsigned long flags;
36847 - atomic_inc(&pau_qps_destroyed);
36848 + atomic_inc_unchecked(&pau_qps_destroyed);
36849
36850 /* Free packets that have not yet been forwarded */
36851 /* Lock is acquired by skb_dequeue when removing the skb */
36852 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
36853 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
36854 skb_queue_head_init(&nesqp->pau_list);
36855 spin_lock_init(&nesqp->pau_lock);
36856 - atomic_inc(&pau_qps_created);
36857 + atomic_inc_unchecked(&pau_qps_created);
36858 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
36859 }
36860
36861 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
36862 index 85cf4d1..05d8e71 100644
36863 --- a/drivers/infiniband/hw/nes/nes_nic.c
36864 +++ b/drivers/infiniband/hw/nes/nes_nic.c
36865 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
36866 target_stat_values[++index] = mh_detected;
36867 target_stat_values[++index] = mh_pauses_sent;
36868 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
36869 - target_stat_values[++index] = atomic_read(&cm_connects);
36870 - target_stat_values[++index] = atomic_read(&cm_accepts);
36871 - target_stat_values[++index] = atomic_read(&cm_disconnects);
36872 - target_stat_values[++index] = atomic_read(&cm_connecteds);
36873 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
36874 - target_stat_values[++index] = atomic_read(&cm_rejects);
36875 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
36876 - target_stat_values[++index] = atomic_read(&qps_created);
36877 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
36878 - target_stat_values[++index] = atomic_read(&qps_destroyed);
36879 - target_stat_values[++index] = atomic_read(&cm_closes);
36880 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
36881 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
36882 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
36883 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
36884 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
36885 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
36886 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
36887 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
36888 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
36889 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
36890 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
36891 target_stat_values[++index] = cm_packets_sent;
36892 target_stat_values[++index] = cm_packets_bounced;
36893 target_stat_values[++index] = cm_packets_created;
36894 target_stat_values[++index] = cm_packets_received;
36895 target_stat_values[++index] = cm_packets_dropped;
36896 target_stat_values[++index] = cm_packets_retrans;
36897 - target_stat_values[++index] = atomic_read(&cm_listens_created);
36898 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
36899 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
36900 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
36901 target_stat_values[++index] = cm_backlog_drops;
36902 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
36903 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
36904 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
36905 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
36906 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
36907 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
36908 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
36909 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
36910 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
36911 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
36912 target_stat_values[++index] = nesadapter->free_4kpbl;
36913 target_stat_values[++index] = nesadapter->free_256pbl;
36914 target_stat_values[++index] = int_mod_timer_init;
36915 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
36916 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
36917 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
36918 - target_stat_values[++index] = atomic_read(&pau_qps_created);
36919 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
36920 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
36921 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
36922 }
36923
36924 /**
36925 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
36926 index 8f67fe2..8960859 100644
36927 --- a/drivers/infiniband/hw/nes/nes_verbs.c
36928 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
36929 @@ -46,9 +46,9 @@
36930
36931 #include <rdma/ib_umem.h>
36932
36933 -atomic_t mod_qp_timouts;
36934 -atomic_t qps_created;
36935 -atomic_t sw_qps_destroyed;
36936 +atomic_unchecked_t mod_qp_timouts;
36937 +atomic_unchecked_t qps_created;
36938 +atomic_unchecked_t sw_qps_destroyed;
36939
36940 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
36941
36942 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
36943 if (init_attr->create_flags)
36944 return ERR_PTR(-EINVAL);
36945
36946 - atomic_inc(&qps_created);
36947 + atomic_inc_unchecked(&qps_created);
36948 switch (init_attr->qp_type) {
36949 case IB_QPT_RC:
36950 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
36951 @@ -1465,7 +1465,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
36952 struct iw_cm_event cm_event;
36953 int ret = 0;
36954
36955 - atomic_inc(&sw_qps_destroyed);
36956 + atomic_inc_unchecked(&sw_qps_destroyed);
36957 nesqp->destroyed = 1;
36958
36959 /* Blow away the connection if it exists. */
36960 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
36961 index 4d11575..3e890e5 100644
36962 --- a/drivers/infiniband/hw/qib/qib.h
36963 +++ b/drivers/infiniband/hw/qib/qib.h
36964 @@ -51,6 +51,7 @@
36965 #include <linux/completion.h>
36966 #include <linux/kref.h>
36967 #include <linux/sched.h>
36968 +#include <linux/slab.h>
36969
36970 #include "qib_common.h"
36971 #include "qib_verbs.h"
36972 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
36973 index da739d9..da1c7f4 100644
36974 --- a/drivers/input/gameport/gameport.c
36975 +++ b/drivers/input/gameport/gameport.c
36976 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
36977 */
36978 static void gameport_init_port(struct gameport *gameport)
36979 {
36980 - static atomic_t gameport_no = ATOMIC_INIT(0);
36981 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
36982
36983 __module_get(THIS_MODULE);
36984
36985 mutex_init(&gameport->drv_mutex);
36986 device_initialize(&gameport->dev);
36987 dev_set_name(&gameport->dev, "gameport%lu",
36988 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
36989 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
36990 gameport->dev.bus = &gameport_bus;
36991 gameport->dev.release = gameport_release_port;
36992 if (gameport->parent)
36993 diff --git a/drivers/input/input.c b/drivers/input/input.c
36994 index c044699..174d71a 100644
36995 --- a/drivers/input/input.c
36996 +++ b/drivers/input/input.c
36997 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
36998 */
36999 int input_register_device(struct input_dev *dev)
37000 {
37001 - static atomic_t input_no = ATOMIC_INIT(0);
37002 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37003 struct input_devres *devres = NULL;
37004 struct input_handler *handler;
37005 unsigned int packet_size;
37006 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37007 dev->setkeycode = input_default_setkeycode;
37008
37009 dev_set_name(&dev->dev, "input%ld",
37010 - (unsigned long) atomic_inc_return(&input_no) - 1);
37011 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37012
37013 error = device_add(&dev->dev);
37014 if (error)
37015 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37016 index 04c69af..5f92d00 100644
37017 --- a/drivers/input/joystick/sidewinder.c
37018 +++ b/drivers/input/joystick/sidewinder.c
37019 @@ -30,6 +30,7 @@
37020 #include <linux/kernel.h>
37021 #include <linux/module.h>
37022 #include <linux/slab.h>
37023 +#include <linux/sched.h>
37024 #include <linux/init.h>
37025 #include <linux/input.h>
37026 #include <linux/gameport.h>
37027 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37028 index d6cbfe9..6225402 100644
37029 --- a/drivers/input/joystick/xpad.c
37030 +++ b/drivers/input/joystick/xpad.c
37031 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37032
37033 static int xpad_led_probe(struct usb_xpad *xpad)
37034 {
37035 - static atomic_t led_seq = ATOMIC_INIT(0);
37036 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37037 long led_no;
37038 struct xpad_led *led;
37039 struct led_classdev *led_cdev;
37040 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37041 if (!led)
37042 return -ENOMEM;
37043
37044 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37045 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37046
37047 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37048 led->xpad = xpad;
37049 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37050 index 2f0b39d..7370f13 100644
37051 --- a/drivers/input/mouse/psmouse.h
37052 +++ b/drivers/input/mouse/psmouse.h
37053 @@ -116,7 +116,7 @@ struct psmouse_attribute {
37054 ssize_t (*set)(struct psmouse *psmouse, void *data,
37055 const char *buf, size_t count);
37056 bool protect;
37057 -};
37058 +} __do_const;
37059 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37060
37061 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37062 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37063 index 4c842c3..590b0bf 100644
37064 --- a/drivers/input/mousedev.c
37065 +++ b/drivers/input/mousedev.c
37066 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37067
37068 spin_unlock_irq(&client->packet_lock);
37069
37070 - if (copy_to_user(buffer, data, count))
37071 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37072 return -EFAULT;
37073
37074 return count;
37075 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37076 index 25fc597..558bf3b3 100644
37077 --- a/drivers/input/serio/serio.c
37078 +++ b/drivers/input/serio/serio.c
37079 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37080 */
37081 static void serio_init_port(struct serio *serio)
37082 {
37083 - static atomic_t serio_no = ATOMIC_INIT(0);
37084 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37085
37086 __module_get(THIS_MODULE);
37087
37088 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37089 mutex_init(&serio->drv_mutex);
37090 device_initialize(&serio->dev);
37091 dev_set_name(&serio->dev, "serio%ld",
37092 - (long)atomic_inc_return(&serio_no) - 1);
37093 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37094 serio->dev.bus = &serio_bus;
37095 serio->dev.release = serio_release_port;
37096 serio->dev.groups = serio_device_attr_groups;
37097 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37098 index b972d43..8943713 100644
37099 --- a/drivers/iommu/iommu.c
37100 +++ b/drivers/iommu/iommu.c
37101 @@ -554,7 +554,7 @@ static struct notifier_block iommu_bus_nb = {
37102 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37103 {
37104 bus_register_notifier(bus, &iommu_bus_nb);
37105 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37106 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37107 }
37108
37109 /**
37110 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
37111 index 7c11ff3..5b2d7a7 100644
37112 --- a/drivers/iommu/irq_remapping.c
37113 +++ b/drivers/iommu/irq_remapping.c
37114 @@ -369,10 +369,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
37115
37116 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
37117 {
37118 - chip->irq_print_chip = ir_print_prefix;
37119 - chip->irq_ack = ir_ack_apic_edge;
37120 - chip->irq_eoi = ir_ack_apic_level;
37121 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37122 + pax_open_kernel();
37123 + *(void **)&chip->irq_print_chip = ir_print_prefix;
37124 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
37125 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
37126 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37127 + pax_close_kernel();
37128 }
37129
37130 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
37131 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
37132 index fc6aebf..94d5248 100644
37133 --- a/drivers/irqchip/irq-gic.c
37134 +++ b/drivers/irqchip/irq-gic.c
37135 @@ -83,7 +83,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
37136 * Supported arch specific GIC irq extension.
37137 * Default make them NULL.
37138 */
37139 -struct irq_chip gic_arch_extn = {
37140 +irq_chip_no_const gic_arch_extn __read_only = {
37141 .irq_eoi = NULL,
37142 .irq_mask = NULL,
37143 .irq_unmask = NULL,
37144 @@ -332,7 +332,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
37145 chained_irq_exit(chip, desc);
37146 }
37147
37148 -static struct irq_chip gic_chip = {
37149 +static irq_chip_no_const gic_chip __read_only = {
37150 .name = "GIC",
37151 .irq_mask = gic_mask_irq,
37152 .irq_unmask = gic_unmask_irq,
37153 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37154 index 89562a8..218999b 100644
37155 --- a/drivers/isdn/capi/capi.c
37156 +++ b/drivers/isdn/capi/capi.c
37157 @@ -81,8 +81,8 @@ struct capiminor {
37158
37159 struct capi20_appl *ap;
37160 u32 ncci;
37161 - atomic_t datahandle;
37162 - atomic_t msgid;
37163 + atomic_unchecked_t datahandle;
37164 + atomic_unchecked_t msgid;
37165
37166 struct tty_port port;
37167 int ttyinstop;
37168 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37169 capimsg_setu16(s, 2, mp->ap->applid);
37170 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37171 capimsg_setu8 (s, 5, CAPI_RESP);
37172 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37173 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37174 capimsg_setu32(s, 8, mp->ncci);
37175 capimsg_setu16(s, 12, datahandle);
37176 }
37177 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
37178 mp->outbytes -= len;
37179 spin_unlock_bh(&mp->outlock);
37180
37181 - datahandle = atomic_inc_return(&mp->datahandle);
37182 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
37183 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
37184 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37185 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37186 capimsg_setu16(skb->data, 2, mp->ap->applid);
37187 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
37188 capimsg_setu8 (skb->data, 5, CAPI_REQ);
37189 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
37190 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
37191 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
37192 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
37193 capimsg_setu16(skb->data, 16, len); /* Data length */
37194 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
37195 index e2b5396..c5486dc 100644
37196 --- a/drivers/isdn/gigaset/interface.c
37197 +++ b/drivers/isdn/gigaset/interface.c
37198 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
37199 }
37200 tty->driver_data = cs;
37201
37202 - ++cs->port.count;
37203 + atomic_inc(&cs->port.count);
37204
37205 - if (cs->port.count == 1) {
37206 + if (atomic_read(&cs->port.count) == 1) {
37207 tty_port_tty_set(&cs->port, tty);
37208 cs->port.low_latency = 1;
37209 }
37210 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
37211
37212 if (!cs->connected)
37213 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
37214 - else if (!cs->port.count)
37215 + else if (!atomic_read(&cs->port.count))
37216 dev_warn(cs->dev, "%s: device not opened\n", __func__);
37217 - else if (!--cs->port.count)
37218 + else if (!atomic_dec_return(&cs->port.count))
37219 tty_port_tty_set(&cs->port, NULL);
37220
37221 mutex_unlock(&cs->mutex);
37222 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
37223 index 821f7ac..28d4030 100644
37224 --- a/drivers/isdn/hardware/avm/b1.c
37225 +++ b/drivers/isdn/hardware/avm/b1.c
37226 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
37227 }
37228 if (left) {
37229 if (t4file->user) {
37230 - if (copy_from_user(buf, dp, left))
37231 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37232 return -EFAULT;
37233 } else {
37234 memcpy(buf, dp, left);
37235 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
37236 }
37237 if (left) {
37238 if (config->user) {
37239 - if (copy_from_user(buf, dp, left))
37240 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37241 return -EFAULT;
37242 } else {
37243 memcpy(buf, dp, left);
37244 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
37245 index ebaebdf..acd4405 100644
37246 --- a/drivers/isdn/i4l/isdn_tty.c
37247 +++ b/drivers/isdn/i4l/isdn_tty.c
37248 @@ -1511,9 +1511,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
37249
37250 #ifdef ISDN_DEBUG_MODEM_OPEN
37251 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
37252 - port->count);
37253 + atomic_read(&port->count));
37254 #endif
37255 - port->count++;
37256 + atomic_inc(&port->count);
37257 port->tty = tty;
37258 /*
37259 * Start up serial port
37260 @@ -1557,7 +1557,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37261 #endif
37262 return;
37263 }
37264 - if ((tty->count == 1) && (port->count != 1)) {
37265 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
37266 /*
37267 * Uh, oh. tty->count is 1, which means that the tty
37268 * structure will be freed. Info->count should always
37269 @@ -1566,15 +1566,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37270 * serial port won't be shutdown.
37271 */
37272 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
37273 - "info->count is %d\n", port->count);
37274 - port->count = 1;
37275 + "info->count is %d\n", atomic_read(&port->count));
37276 + atomic_set(&port->count, 1);
37277 }
37278 - if (--port->count < 0) {
37279 + if (atomic_dec_return(&port->count) < 0) {
37280 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
37281 - info->line, port->count);
37282 - port->count = 0;
37283 + info->line, atomic_read(&port->count));
37284 + atomic_set(&port->count, 0);
37285 }
37286 - if (port->count) {
37287 + if (atomic_read(&port->count)) {
37288 #ifdef ISDN_DEBUG_MODEM_OPEN
37289 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
37290 #endif
37291 @@ -1628,7 +1628,7 @@ isdn_tty_hangup(struct tty_struct *tty)
37292 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
37293 return;
37294 isdn_tty_shutdown(info);
37295 - port->count = 0;
37296 + atomic_set(&port->count, 0);
37297 port->flags &= ~ASYNC_NORMAL_ACTIVE;
37298 port->tty = NULL;
37299 wake_up_interruptible(&port->open_wait);
37300 @@ -1973,7 +1973,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
37301 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
37302 modem_info *info = &dev->mdm.info[i];
37303
37304 - if (info->port.count == 0)
37305 + if (atomic_read(&info->port.count) == 0)
37306 continue;
37307 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
37308 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
37309 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
37310 index e74df7c..03a03ba 100644
37311 --- a/drivers/isdn/icn/icn.c
37312 +++ b/drivers/isdn/icn/icn.c
37313 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
37314 if (count > len)
37315 count = len;
37316 if (user) {
37317 - if (copy_from_user(msg, buf, count))
37318 + if (count > sizeof msg || copy_from_user(msg, buf, count))
37319 return -EFAULT;
37320 } else
37321 memcpy(msg, buf, count);
37322 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
37323 index 6a8405d..0bd1c7e 100644
37324 --- a/drivers/leds/leds-clevo-mail.c
37325 +++ b/drivers/leds/leds-clevo-mail.c
37326 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
37327 * detected as working, but in reality it is not) as low as
37328 * possible.
37329 */
37330 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
37331 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
37332 {
37333 .callback = clevo_mail_led_dmi_callback,
37334 .ident = "Clevo D410J",
37335 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
37336 index 64e204e..c6bf189 100644
37337 --- a/drivers/leds/leds-ss4200.c
37338 +++ b/drivers/leds/leds-ss4200.c
37339 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
37340 * detected as working, but in reality it is not) as low as
37341 * possible.
37342 */
37343 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
37344 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
37345 {
37346 .callback = ss4200_led_dmi_callback,
37347 .ident = "Intel SS4200-E",
37348 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
37349 index a5ebc00..982886f 100644
37350 --- a/drivers/lguest/core.c
37351 +++ b/drivers/lguest/core.c
37352 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
37353 * it's worked so far. The end address needs +1 because __get_vm_area
37354 * allocates an extra guard page, so we need space for that.
37355 */
37356 +
37357 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
37358 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37359 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
37360 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37361 +#else
37362 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37363 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
37364 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37365 +#endif
37366 +
37367 if (!switcher_vma) {
37368 err = -ENOMEM;
37369 printk("lguest: could not map switcher pages high\n");
37370 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
37371 * Now the Switcher is mapped at the right address, we can't fail!
37372 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
37373 */
37374 - memcpy(switcher_vma->addr, start_switcher_text,
37375 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
37376 end_switcher_text - start_switcher_text);
37377
37378 printk(KERN_INFO "lguest: mapped switcher at %p\n",
37379 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
37380 index 3b62be16..e33134a 100644
37381 --- a/drivers/lguest/page_tables.c
37382 +++ b/drivers/lguest/page_tables.c
37383 @@ -532,7 +532,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
37384 /*:*/
37385
37386 #ifdef CONFIG_X86_PAE
37387 -static void release_pmd(pmd_t *spmd)
37388 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
37389 {
37390 /* If the entry's not present, there's nothing to release. */
37391 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
37392 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
37393 index 4af12e1..0e89afe 100644
37394 --- a/drivers/lguest/x86/core.c
37395 +++ b/drivers/lguest/x86/core.c
37396 @@ -59,7 +59,7 @@ static struct {
37397 /* Offset from where switcher.S was compiled to where we've copied it */
37398 static unsigned long switcher_offset(void)
37399 {
37400 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
37401 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
37402 }
37403
37404 /* This cpu's struct lguest_pages. */
37405 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
37406 * These copies are pretty cheap, so we do them unconditionally: */
37407 /* Save the current Host top-level page directory.
37408 */
37409 +
37410 +#ifdef CONFIG_PAX_PER_CPU_PGD
37411 + pages->state.host_cr3 = read_cr3();
37412 +#else
37413 pages->state.host_cr3 = __pa(current->mm->pgd);
37414 +#endif
37415 +
37416 /*
37417 * Set up the Guest's page tables to see this CPU's pages (and no
37418 * other CPU's pages).
37419 @@ -476,7 +482,7 @@ void __init lguest_arch_host_init(void)
37420 * compiled-in switcher code and the high-mapped copy we just made.
37421 */
37422 for (i = 0; i < IDT_ENTRIES; i++)
37423 - default_idt_entries[i] += switcher_offset();
37424 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
37425
37426 /*
37427 * Set up the Switcher's per-cpu areas.
37428 @@ -559,7 +565,7 @@ void __init lguest_arch_host_init(void)
37429 * it will be undisturbed when we switch. To change %cs and jump we
37430 * need this structure to feed to Intel's "lcall" instruction.
37431 */
37432 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
37433 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
37434 lguest_entry.segment = LGUEST_CS;
37435
37436 /*
37437 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
37438 index 40634b0..4f5855e 100644
37439 --- a/drivers/lguest/x86/switcher_32.S
37440 +++ b/drivers/lguest/x86/switcher_32.S
37441 @@ -87,6 +87,7 @@
37442 #include <asm/page.h>
37443 #include <asm/segment.h>
37444 #include <asm/lguest.h>
37445 +#include <asm/processor-flags.h>
37446
37447 // We mark the start of the code to copy
37448 // It's placed in .text tho it's never run here
37449 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
37450 // Changes type when we load it: damn Intel!
37451 // For after we switch over our page tables
37452 // That entry will be read-only: we'd crash.
37453 +
37454 +#ifdef CONFIG_PAX_KERNEXEC
37455 + mov %cr0, %edx
37456 + xor $X86_CR0_WP, %edx
37457 + mov %edx, %cr0
37458 +#endif
37459 +
37460 movl $(GDT_ENTRY_TSS*8), %edx
37461 ltr %dx
37462
37463 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
37464 // Let's clear it again for our return.
37465 // The GDT descriptor of the Host
37466 // Points to the table after two "size" bytes
37467 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
37468 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
37469 // Clear "used" from type field (byte 5, bit 2)
37470 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
37471 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
37472 +
37473 +#ifdef CONFIG_PAX_KERNEXEC
37474 + mov %cr0, %eax
37475 + xor $X86_CR0_WP, %eax
37476 + mov %eax, %cr0
37477 +#endif
37478
37479 // Once our page table's switched, the Guest is live!
37480 // The Host fades as we run this final step.
37481 @@ -295,13 +309,12 @@ deliver_to_host:
37482 // I consulted gcc, and it gave
37483 // These instructions, which I gladly credit:
37484 leal (%edx,%ebx,8), %eax
37485 - movzwl (%eax),%edx
37486 - movl 4(%eax), %eax
37487 - xorw %ax, %ax
37488 - orl %eax, %edx
37489 + movl 4(%eax), %edx
37490 + movw (%eax), %dx
37491 // Now the address of the handler's in %edx
37492 // We call it now: its "iret" drops us home.
37493 - jmp *%edx
37494 + ljmp $__KERNEL_CS, $1f
37495 +1: jmp *%edx
37496
37497 // Every interrupt can come to us here
37498 // But we must truly tell each apart.
37499 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
37500 index 4fd9d6a..834fa03 100644
37501 --- a/drivers/md/bitmap.c
37502 +++ b/drivers/md/bitmap.c
37503 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
37504 chunk_kb ? "KB" : "B");
37505 if (bitmap->storage.file) {
37506 seq_printf(seq, ", file: ");
37507 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
37508 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
37509 }
37510
37511 seq_printf(seq, "\n");
37512 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
37513 index aa04f02..2a1309e 100644
37514 --- a/drivers/md/dm-ioctl.c
37515 +++ b/drivers/md/dm-ioctl.c
37516 @@ -1694,7 +1694,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
37517 cmd == DM_LIST_VERSIONS_CMD)
37518 return 0;
37519
37520 - if ((cmd == DM_DEV_CREATE_CMD)) {
37521 + if (cmd == DM_DEV_CREATE_CMD) {
37522 if (!*param->name) {
37523 DMWARN("name not supplied when creating device");
37524 return -EINVAL;
37525 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
37526 index d053098..05cc375 100644
37527 --- a/drivers/md/dm-raid1.c
37528 +++ b/drivers/md/dm-raid1.c
37529 @@ -40,7 +40,7 @@ enum dm_raid1_error {
37530
37531 struct mirror {
37532 struct mirror_set *ms;
37533 - atomic_t error_count;
37534 + atomic_unchecked_t error_count;
37535 unsigned long error_type;
37536 struct dm_dev *dev;
37537 sector_t offset;
37538 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
37539 struct mirror *m;
37540
37541 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
37542 - if (!atomic_read(&m->error_count))
37543 + if (!atomic_read_unchecked(&m->error_count))
37544 return m;
37545
37546 return NULL;
37547 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
37548 * simple way to tell if a device has encountered
37549 * errors.
37550 */
37551 - atomic_inc(&m->error_count);
37552 + atomic_inc_unchecked(&m->error_count);
37553
37554 if (test_and_set_bit(error_type, &m->error_type))
37555 return;
37556 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
37557 struct mirror *m = get_default_mirror(ms);
37558
37559 do {
37560 - if (likely(!atomic_read(&m->error_count)))
37561 + if (likely(!atomic_read_unchecked(&m->error_count)))
37562 return m;
37563
37564 if (m-- == ms->mirror)
37565 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
37566 {
37567 struct mirror *default_mirror = get_default_mirror(m->ms);
37568
37569 - return !atomic_read(&default_mirror->error_count);
37570 + return !atomic_read_unchecked(&default_mirror->error_count);
37571 }
37572
37573 static int mirror_available(struct mirror_set *ms, struct bio *bio)
37574 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
37575 */
37576 if (likely(region_in_sync(ms, region, 1)))
37577 m = choose_mirror(ms, bio->bi_sector);
37578 - else if (m && atomic_read(&m->error_count))
37579 + else if (m && atomic_read_unchecked(&m->error_count))
37580 m = NULL;
37581
37582 if (likely(m))
37583 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
37584 }
37585
37586 ms->mirror[mirror].ms = ms;
37587 - atomic_set(&(ms->mirror[mirror].error_count), 0);
37588 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
37589 ms->mirror[mirror].error_type = 0;
37590 ms->mirror[mirror].offset = offset;
37591
37592 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
37593 */
37594 static char device_status_char(struct mirror *m)
37595 {
37596 - if (!atomic_read(&(m->error_count)))
37597 + if (!atomic_read_unchecked(&(m->error_count)))
37598 return 'A';
37599
37600 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
37601 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
37602 index d8837d3..1f7c341 100644
37603 --- a/drivers/md/dm-stripe.c
37604 +++ b/drivers/md/dm-stripe.c
37605 @@ -20,7 +20,7 @@ struct stripe {
37606 struct dm_dev *dev;
37607 sector_t physical_start;
37608
37609 - atomic_t error_count;
37610 + atomic_unchecked_t error_count;
37611 };
37612
37613 struct stripe_c {
37614 @@ -184,7 +184,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
37615 kfree(sc);
37616 return r;
37617 }
37618 - atomic_set(&(sc->stripe[i].error_count), 0);
37619 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
37620 }
37621
37622 ti->private = sc;
37623 @@ -325,7 +325,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
37624 DMEMIT("%d ", sc->stripes);
37625 for (i = 0; i < sc->stripes; i++) {
37626 DMEMIT("%s ", sc->stripe[i].dev->name);
37627 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
37628 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
37629 'D' : 'A';
37630 }
37631 buffer[i] = '\0';
37632 @@ -370,8 +370,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
37633 */
37634 for (i = 0; i < sc->stripes; i++)
37635 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
37636 - atomic_inc(&(sc->stripe[i].error_count));
37637 - if (atomic_read(&(sc->stripe[i].error_count)) <
37638 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
37639 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
37640 DM_IO_ERROR_THRESHOLD)
37641 schedule_work(&sc->trigger_event);
37642 }
37643 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
37644 index e50dad0..d9575e2 100644
37645 --- a/drivers/md/dm-table.c
37646 +++ b/drivers/md/dm-table.c
37647 @@ -389,7 +389,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
37648 if (!dev_size)
37649 return 0;
37650
37651 - if ((start >= dev_size) || (start + len > dev_size)) {
37652 + if ((start >= dev_size) || (len > dev_size - start)) {
37653 DMWARN("%s: %s too small for target: "
37654 "start=%llu, len=%llu, dev_size=%llu",
37655 dm_device_name(ti->table->md), bdevname(bdev, b),
37656 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
37657 index 00cee02..b89a29d 100644
37658 --- a/drivers/md/dm-thin-metadata.c
37659 +++ b/drivers/md/dm-thin-metadata.c
37660 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
37661 {
37662 pmd->info.tm = pmd->tm;
37663 pmd->info.levels = 2;
37664 - pmd->info.value_type.context = pmd->data_sm;
37665 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
37666 pmd->info.value_type.size = sizeof(__le64);
37667 pmd->info.value_type.inc = data_block_inc;
37668 pmd->info.value_type.dec = data_block_dec;
37669 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
37670
37671 pmd->bl_info.tm = pmd->tm;
37672 pmd->bl_info.levels = 1;
37673 - pmd->bl_info.value_type.context = pmd->data_sm;
37674 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
37675 pmd->bl_info.value_type.size = sizeof(__le64);
37676 pmd->bl_info.value_type.inc = data_block_inc;
37677 pmd->bl_info.value_type.dec = data_block_dec;
37678 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
37679 index 9a0bdad..4df9543 100644
37680 --- a/drivers/md/dm.c
37681 +++ b/drivers/md/dm.c
37682 @@ -169,9 +169,9 @@ struct mapped_device {
37683 /*
37684 * Event handling.
37685 */
37686 - atomic_t event_nr;
37687 + atomic_unchecked_t event_nr;
37688 wait_queue_head_t eventq;
37689 - atomic_t uevent_seq;
37690 + atomic_unchecked_t uevent_seq;
37691 struct list_head uevent_list;
37692 spinlock_t uevent_lock; /* Protect access to uevent_list */
37693
37694 @@ -1879,8 +1879,8 @@ static struct mapped_device *alloc_dev(int minor)
37695 rwlock_init(&md->map_lock);
37696 atomic_set(&md->holders, 1);
37697 atomic_set(&md->open_count, 0);
37698 - atomic_set(&md->event_nr, 0);
37699 - atomic_set(&md->uevent_seq, 0);
37700 + atomic_set_unchecked(&md->event_nr, 0);
37701 + atomic_set_unchecked(&md->uevent_seq, 0);
37702 INIT_LIST_HEAD(&md->uevent_list);
37703 spin_lock_init(&md->uevent_lock);
37704
37705 @@ -2028,7 +2028,7 @@ static void event_callback(void *context)
37706
37707 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
37708
37709 - atomic_inc(&md->event_nr);
37710 + atomic_inc_unchecked(&md->event_nr);
37711 wake_up(&md->eventq);
37712 }
37713
37714 @@ -2685,18 +2685,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
37715
37716 uint32_t dm_next_uevent_seq(struct mapped_device *md)
37717 {
37718 - return atomic_add_return(1, &md->uevent_seq);
37719 + return atomic_add_return_unchecked(1, &md->uevent_seq);
37720 }
37721
37722 uint32_t dm_get_event_nr(struct mapped_device *md)
37723 {
37724 - return atomic_read(&md->event_nr);
37725 + return atomic_read_unchecked(&md->event_nr);
37726 }
37727
37728 int dm_wait_event(struct mapped_device *md, int event_nr)
37729 {
37730 return wait_event_interruptible(md->eventq,
37731 - (event_nr != atomic_read(&md->event_nr)));
37732 + (event_nr != atomic_read_unchecked(&md->event_nr)));
37733 }
37734
37735 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
37736 diff --git a/drivers/md/md.c b/drivers/md/md.c
37737 index a4a93b9..4747b63 100644
37738 --- a/drivers/md/md.c
37739 +++ b/drivers/md/md.c
37740 @@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
37741 * start build, activate spare
37742 */
37743 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
37744 -static atomic_t md_event_count;
37745 +static atomic_unchecked_t md_event_count;
37746 void md_new_event(struct mddev *mddev)
37747 {
37748 - atomic_inc(&md_event_count);
37749 + atomic_inc_unchecked(&md_event_count);
37750 wake_up(&md_event_waiters);
37751 }
37752 EXPORT_SYMBOL_GPL(md_new_event);
37753 @@ -253,7 +253,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
37754 */
37755 static void md_new_event_inintr(struct mddev *mddev)
37756 {
37757 - atomic_inc(&md_event_count);
37758 + atomic_inc_unchecked(&md_event_count);
37759 wake_up(&md_event_waiters);
37760 }
37761
37762 @@ -1507,7 +1507,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
37763 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
37764 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
37765 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
37766 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
37767 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
37768
37769 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
37770 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
37771 @@ -1751,7 +1751,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
37772 else
37773 sb->resync_offset = cpu_to_le64(0);
37774
37775 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
37776 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
37777
37778 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
37779 sb->size = cpu_to_le64(mddev->dev_sectors);
37780 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
37781 static ssize_t
37782 errors_show(struct md_rdev *rdev, char *page)
37783 {
37784 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
37785 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
37786 }
37787
37788 static ssize_t
37789 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
37790 char *e;
37791 unsigned long n = simple_strtoul(buf, &e, 10);
37792 if (*buf && (*e == 0 || *e == '\n')) {
37793 - atomic_set(&rdev->corrected_errors, n);
37794 + atomic_set_unchecked(&rdev->corrected_errors, n);
37795 return len;
37796 }
37797 return -EINVAL;
37798 @@ -3210,8 +3210,8 @@ int md_rdev_init(struct md_rdev *rdev)
37799 rdev->sb_loaded = 0;
37800 rdev->bb_page = NULL;
37801 atomic_set(&rdev->nr_pending, 0);
37802 - atomic_set(&rdev->read_errors, 0);
37803 - atomic_set(&rdev->corrected_errors, 0);
37804 + atomic_set_unchecked(&rdev->read_errors, 0);
37805 + atomic_set_unchecked(&rdev->corrected_errors, 0);
37806
37807 INIT_LIST_HEAD(&rdev->same_set);
37808 init_waitqueue_head(&rdev->blocked_wait);
37809 @@ -6994,7 +6994,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
37810
37811 spin_unlock(&pers_lock);
37812 seq_printf(seq, "\n");
37813 - seq->poll_event = atomic_read(&md_event_count);
37814 + seq->poll_event = atomic_read_unchecked(&md_event_count);
37815 return 0;
37816 }
37817 if (v == (void*)2) {
37818 @@ -7097,7 +7097,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
37819 return error;
37820
37821 seq = file->private_data;
37822 - seq->poll_event = atomic_read(&md_event_count);
37823 + seq->poll_event = atomic_read_unchecked(&md_event_count);
37824 return error;
37825 }
37826
37827 @@ -7111,7 +7111,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
37828 /* always allow read */
37829 mask = POLLIN | POLLRDNORM;
37830
37831 - if (seq->poll_event != atomic_read(&md_event_count))
37832 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
37833 mask |= POLLERR | POLLPRI;
37834 return mask;
37835 }
37836 @@ -7155,7 +7155,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
37837 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
37838 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
37839 (int)part_stat_read(&disk->part0, sectors[1]) -
37840 - atomic_read(&disk->sync_io);
37841 + atomic_read_unchecked(&disk->sync_io);
37842 /* sync IO will cause sync_io to increase before the disk_stats
37843 * as sync_io is counted when a request starts, and
37844 * disk_stats is counted when it completes.
37845 diff --git a/drivers/md/md.h b/drivers/md/md.h
37846 index d90fb1a..4174a2b 100644
37847 --- a/drivers/md/md.h
37848 +++ b/drivers/md/md.h
37849 @@ -94,13 +94,13 @@ struct md_rdev {
37850 * only maintained for arrays that
37851 * support hot removal
37852 */
37853 - atomic_t read_errors; /* number of consecutive read errors that
37854 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
37855 * we have tried to ignore.
37856 */
37857 struct timespec last_read_error; /* monotonic time since our
37858 * last read error
37859 */
37860 - atomic_t corrected_errors; /* number of corrected read errors,
37861 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
37862 * for reporting to userspace and storing
37863 * in superblock.
37864 */
37865 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
37866
37867 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
37868 {
37869 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
37870 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
37871 }
37872
37873 struct md_personality
37874 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
37875 index 1cbfc6b..56e1dbb 100644
37876 --- a/drivers/md/persistent-data/dm-space-map.h
37877 +++ b/drivers/md/persistent-data/dm-space-map.h
37878 @@ -60,6 +60,7 @@ struct dm_space_map {
37879 int (*root_size)(struct dm_space_map *sm, size_t *result);
37880 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
37881 };
37882 +typedef struct dm_space_map __no_const dm_space_map_no_const;
37883
37884 /*----------------------------------------------------------------*/
37885
37886 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
37887 index 6af167f..40c25a1 100644
37888 --- a/drivers/md/raid1.c
37889 +++ b/drivers/md/raid1.c
37890 @@ -1826,7 +1826,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
37891 if (r1_sync_page_io(rdev, sect, s,
37892 bio->bi_io_vec[idx].bv_page,
37893 READ) != 0)
37894 - atomic_add(s, &rdev->corrected_errors);
37895 + atomic_add_unchecked(s, &rdev->corrected_errors);
37896 }
37897 sectors -= s;
37898 sect += s;
37899 @@ -2048,7 +2048,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
37900 test_bit(In_sync, &rdev->flags)) {
37901 if (r1_sync_page_io(rdev, sect, s,
37902 conf->tmppage, READ)) {
37903 - atomic_add(s, &rdev->corrected_errors);
37904 + atomic_add_unchecked(s, &rdev->corrected_errors);
37905 printk(KERN_INFO
37906 "md/raid1:%s: read error corrected "
37907 "(%d sectors at %llu on %s)\n",
37908 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
37909 index 46c14e5..4db5966 100644
37910 --- a/drivers/md/raid10.c
37911 +++ b/drivers/md/raid10.c
37912 @@ -1932,7 +1932,7 @@ static void end_sync_read(struct bio *bio, int error)
37913 /* The write handler will notice the lack of
37914 * R10BIO_Uptodate and record any errors etc
37915 */
37916 - atomic_add(r10_bio->sectors,
37917 + atomic_add_unchecked(r10_bio->sectors,
37918 &conf->mirrors[d].rdev->corrected_errors);
37919
37920 /* for reconstruct, we always reschedule after a read.
37921 @@ -2281,7 +2281,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
37922 {
37923 struct timespec cur_time_mon;
37924 unsigned long hours_since_last;
37925 - unsigned int read_errors = atomic_read(&rdev->read_errors);
37926 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
37927
37928 ktime_get_ts(&cur_time_mon);
37929
37930 @@ -2303,9 +2303,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
37931 * overflowing the shift of read_errors by hours_since_last.
37932 */
37933 if (hours_since_last >= 8 * sizeof(read_errors))
37934 - atomic_set(&rdev->read_errors, 0);
37935 + atomic_set_unchecked(&rdev->read_errors, 0);
37936 else
37937 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
37938 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
37939 }
37940
37941 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
37942 @@ -2359,8 +2359,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
37943 return;
37944
37945 check_decay_read_errors(mddev, rdev);
37946 - atomic_inc(&rdev->read_errors);
37947 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
37948 + atomic_inc_unchecked(&rdev->read_errors);
37949 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
37950 char b[BDEVNAME_SIZE];
37951 bdevname(rdev->bdev, b);
37952
37953 @@ -2368,7 +2368,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
37954 "md/raid10:%s: %s: Raid device exceeded "
37955 "read_error threshold [cur %d:max %d]\n",
37956 mdname(mddev), b,
37957 - atomic_read(&rdev->read_errors), max_read_errors);
37958 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
37959 printk(KERN_NOTICE
37960 "md/raid10:%s: %s: Failing raid device\n",
37961 mdname(mddev), b);
37962 @@ -2523,7 +2523,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
37963 sect +
37964 choose_data_offset(r10_bio, rdev)),
37965 bdevname(rdev->bdev, b));
37966 - atomic_add(s, &rdev->corrected_errors);
37967 + atomic_add_unchecked(s, &rdev->corrected_errors);
37968 }
37969
37970 rdev_dec_pending(rdev, mddev);
37971 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
37972 index f4e87bf..0d4ad3f 100644
37973 --- a/drivers/md/raid5.c
37974 +++ b/drivers/md/raid5.c
37975 @@ -1763,21 +1763,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
37976 mdname(conf->mddev), STRIPE_SECTORS,
37977 (unsigned long long)s,
37978 bdevname(rdev->bdev, b));
37979 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
37980 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
37981 clear_bit(R5_ReadError, &sh->dev[i].flags);
37982 clear_bit(R5_ReWrite, &sh->dev[i].flags);
37983 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
37984 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
37985
37986 - if (atomic_read(&rdev->read_errors))
37987 - atomic_set(&rdev->read_errors, 0);
37988 + if (atomic_read_unchecked(&rdev->read_errors))
37989 + atomic_set_unchecked(&rdev->read_errors, 0);
37990 } else {
37991 const char *bdn = bdevname(rdev->bdev, b);
37992 int retry = 0;
37993 int set_bad = 0;
37994
37995 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
37996 - atomic_inc(&rdev->read_errors);
37997 + atomic_inc_unchecked(&rdev->read_errors);
37998 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
37999 printk_ratelimited(
38000 KERN_WARNING
38001 @@ -1805,7 +1805,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38002 mdname(conf->mddev),
38003 (unsigned long long)s,
38004 bdn);
38005 - } else if (atomic_read(&rdev->read_errors)
38006 + } else if (atomic_read_unchecked(&rdev->read_errors)
38007 > conf->max_nr_stripes)
38008 printk(KERN_WARNING
38009 "md/raid:%s: Too many read errors, failing device %s.\n",
38010 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38011 index 401ef64..836e563 100644
38012 --- a/drivers/media/dvb-core/dvbdev.c
38013 +++ b/drivers/media/dvb-core/dvbdev.c
38014 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38015 const struct dvb_device *template, void *priv, int type)
38016 {
38017 struct dvb_device *dvbdev;
38018 - struct file_operations *dvbdevfops;
38019 + file_operations_no_const *dvbdevfops;
38020 struct device *clsdev;
38021 int minor;
38022 int id;
38023 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38024 index 9b6c3bb..baeb5c7 100644
38025 --- a/drivers/media/dvb-frontends/dib3000.h
38026 +++ b/drivers/media/dvb-frontends/dib3000.h
38027 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38028 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38029 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38030 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38031 -};
38032 +} __no_const;
38033
38034 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
38035 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38036 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38037 index bc78354..42c9459 100644
38038 --- a/drivers/media/pci/cx88/cx88-video.c
38039 +++ b/drivers/media/pci/cx88/cx88-video.c
38040 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38041
38042 /* ------------------------------------------------------------------ */
38043
38044 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38045 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38046 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38047 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38048 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38049 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38050
38051 module_param_array(video_nr, int, NULL, 0444);
38052 module_param_array(vbi_nr, int, NULL, 0444);
38053 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38054 index 96c4a17..1305a79 100644
38055 --- a/drivers/media/platform/omap/omap_vout.c
38056 +++ b/drivers/media/platform/omap/omap_vout.c
38057 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38058 OMAP_VIDEO2,
38059 };
38060
38061 -static struct videobuf_queue_ops video_vbq_ops;
38062 /* Variables configurable through module params*/
38063 static u32 video1_numbuffers = 3;
38064 static u32 video2_numbuffers = 3;
38065 @@ -1012,6 +1011,12 @@ static int omap_vout_open(struct file *file)
38066 {
38067 struct videobuf_queue *q;
38068 struct omap_vout_device *vout = NULL;
38069 + static struct videobuf_queue_ops video_vbq_ops = {
38070 + .buf_setup = omap_vout_buffer_setup,
38071 + .buf_prepare = omap_vout_buffer_prepare,
38072 + .buf_release = omap_vout_buffer_release,
38073 + .buf_queue = omap_vout_buffer_queue,
38074 + };
38075
38076 vout = video_drvdata(file);
38077 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38078 @@ -1029,10 +1034,6 @@ static int omap_vout_open(struct file *file)
38079 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38080
38081 q = &vout->vbq;
38082 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38083 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38084 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38085 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38086 spin_lock_init(&vout->vbq_lock);
38087
38088 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38089 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38090 index 04e6490..2df65bf 100644
38091 --- a/drivers/media/platform/s5p-tv/mixer.h
38092 +++ b/drivers/media/platform/s5p-tv/mixer.h
38093 @@ -156,7 +156,7 @@ struct mxr_layer {
38094 /** layer index (unique identifier) */
38095 int idx;
38096 /** callbacks for layer methods */
38097 - struct mxr_layer_ops ops;
38098 + struct mxr_layer_ops *ops;
38099 /** format array */
38100 const struct mxr_format **fmt_array;
38101 /** size of format array */
38102 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38103 index b93a21f..2535195 100644
38104 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38105 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38106 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38107 {
38108 struct mxr_layer *layer;
38109 int ret;
38110 - struct mxr_layer_ops ops = {
38111 + static struct mxr_layer_ops ops = {
38112 .release = mxr_graph_layer_release,
38113 .buffer_set = mxr_graph_buffer_set,
38114 .stream_set = mxr_graph_stream_set,
38115 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38116 index b713403..53cb5ad 100644
38117 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38118 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38119 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38120 layer->update_buf = next;
38121 }
38122
38123 - layer->ops.buffer_set(layer, layer->update_buf);
38124 + layer->ops->buffer_set(layer, layer->update_buf);
38125
38126 if (done && done != layer->shadow_buf)
38127 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38128 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38129 index 82142a2..6de47e8 100644
38130 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38131 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38132 @@ -209,7 +209,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38133 layer->geo.src.height = layer->geo.src.full_height;
38134
38135 mxr_geometry_dump(mdev, &layer->geo);
38136 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38137 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38138 mxr_geometry_dump(mdev, &layer->geo);
38139 }
38140
38141 @@ -227,7 +227,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38142 layer->geo.dst.full_width = mbus_fmt.width;
38143 layer->geo.dst.full_height = mbus_fmt.height;
38144 layer->geo.dst.field = mbus_fmt.field;
38145 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38146 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38147
38148 mxr_geometry_dump(mdev, &layer->geo);
38149 }
38150 @@ -333,7 +333,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38151 /* set source size to highest accepted value */
38152 geo->src.full_width = max(geo->dst.full_width, pix->width);
38153 geo->src.full_height = max(geo->dst.full_height, pix->height);
38154 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38155 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38156 mxr_geometry_dump(mdev, &layer->geo);
38157 /* set cropping to total visible screen */
38158 geo->src.width = pix->width;
38159 @@ -341,12 +341,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38160 geo->src.x_offset = 0;
38161 geo->src.y_offset = 0;
38162 /* assure consistency of geometry */
38163 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38164 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38165 mxr_geometry_dump(mdev, &layer->geo);
38166 /* set full size to lowest possible value */
38167 geo->src.full_width = 0;
38168 geo->src.full_height = 0;
38169 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38170 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38171 mxr_geometry_dump(mdev, &layer->geo);
38172
38173 /* returning results */
38174 @@ -473,7 +473,7 @@ static int mxr_s_selection(struct file *file, void *fh,
38175 target->width = s->r.width;
38176 target->height = s->r.height;
38177
38178 - layer->ops.fix_geometry(layer, stage, s->flags);
38179 + layer->ops->fix_geometry(layer, stage, s->flags);
38180
38181 /* retrieve update selection rectangle */
38182 res.left = target->x_offset;
38183 @@ -938,13 +938,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
38184 mxr_output_get(mdev);
38185
38186 mxr_layer_update_output(layer);
38187 - layer->ops.format_set(layer);
38188 + layer->ops->format_set(layer);
38189 /* enabling layer in hardware */
38190 spin_lock_irqsave(&layer->enq_slock, flags);
38191 layer->state = MXR_LAYER_STREAMING;
38192 spin_unlock_irqrestore(&layer->enq_slock, flags);
38193
38194 - layer->ops.stream_set(layer, MXR_ENABLE);
38195 + layer->ops->stream_set(layer, MXR_ENABLE);
38196 mxr_streamer_get(mdev);
38197
38198 return 0;
38199 @@ -1014,7 +1014,7 @@ static int stop_streaming(struct vb2_queue *vq)
38200 spin_unlock_irqrestore(&layer->enq_slock, flags);
38201
38202 /* disabling layer in hardware */
38203 - layer->ops.stream_set(layer, MXR_DISABLE);
38204 + layer->ops->stream_set(layer, MXR_DISABLE);
38205 /* remove one streamer */
38206 mxr_streamer_put(mdev);
38207 /* allow changes in output configuration */
38208 @@ -1053,8 +1053,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
38209
38210 void mxr_layer_release(struct mxr_layer *layer)
38211 {
38212 - if (layer->ops.release)
38213 - layer->ops.release(layer);
38214 + if (layer->ops->release)
38215 + layer->ops->release(layer);
38216 }
38217
38218 void mxr_base_layer_release(struct mxr_layer *layer)
38219 @@ -1080,7 +1080,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
38220
38221 layer->mdev = mdev;
38222 layer->idx = idx;
38223 - layer->ops = *ops;
38224 + layer->ops = ops;
38225
38226 spin_lock_init(&layer->enq_slock);
38227 INIT_LIST_HEAD(&layer->enq_list);
38228 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38229 index 3d13a63..da31bf1 100644
38230 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38231 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38232 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
38233 {
38234 struct mxr_layer *layer;
38235 int ret;
38236 - struct mxr_layer_ops ops = {
38237 + static struct mxr_layer_ops ops = {
38238 .release = mxr_vp_layer_release,
38239 .buffer_set = mxr_vp_buffer_set,
38240 .stream_set = mxr_vp_stream_set,
38241 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
38242 index 643d80a..56bb96b 100644
38243 --- a/drivers/media/radio/radio-cadet.c
38244 +++ b/drivers/media/radio/radio-cadet.c
38245 @@ -302,6 +302,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38246 unsigned char readbuf[RDS_BUFFER];
38247 int i = 0;
38248
38249 + if (count > RDS_BUFFER)
38250 + return -EFAULT;
38251 mutex_lock(&dev->lock);
38252 if (dev->rdsstat == 0)
38253 cadet_start_rds(dev);
38254 @@ -317,7 +319,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38255 while (i < count && dev->rdsin != dev->rdsout)
38256 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
38257
38258 - if (i && copy_to_user(data, readbuf, i))
38259 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
38260 i = -EFAULT;
38261 unlock:
38262 mutex_unlock(&dev->lock);
38263 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
38264 index 3940bb0..fb3952a 100644
38265 --- a/drivers/media/usb/dvb-usb/cxusb.c
38266 +++ b/drivers/media/usb/dvb-usb/cxusb.c
38267 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
38268
38269 struct dib0700_adapter_state {
38270 int (*set_param_save) (struct dvb_frontend *);
38271 -};
38272 +} __no_const;
38273
38274 static int dib7070_set_param_override(struct dvb_frontend *fe)
38275 {
38276 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
38277 index 9578a67..31aa652 100644
38278 --- a/drivers/media/usb/dvb-usb/dw2102.c
38279 +++ b/drivers/media/usb/dvb-usb/dw2102.c
38280 @@ -115,7 +115,7 @@ struct su3000_state {
38281
38282 struct s6x0_state {
38283 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
38284 -};
38285 +} __no_const;
38286
38287 /* debug */
38288 static int dvb_usb_dw2102_debug;
38289 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
38290 index aa6e7c7..4cd8061 100644
38291 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
38292 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
38293 @@ -1923,7 +1923,8 @@ struct v4l2_ioctl_info {
38294 struct file *file, void *fh, void *p);
38295 } u;
38296 void (*debug)(const void *arg, bool write_only);
38297 -};
38298 +} __do_const;
38299 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
38300
38301 /* This control needs a priority check */
38302 #define INFO_FL_PRIO (1 << 0)
38303 @@ -2108,7 +2109,7 @@ static long __video_do_ioctl(struct file *file,
38304 struct video_device *vfd = video_devdata(file);
38305 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
38306 bool write_only = false;
38307 - struct v4l2_ioctl_info default_info;
38308 + v4l2_ioctl_info_no_const default_info;
38309 const struct v4l2_ioctl_info *info;
38310 void *fh = file->private_data;
38311 struct v4l2_fh *vfh = NULL;
38312 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
38313 index fb69baa..3aeea2e 100644
38314 --- a/drivers/message/fusion/mptbase.c
38315 +++ b/drivers/message/fusion/mptbase.c
38316 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38317 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
38318 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
38319
38320 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38321 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
38322 +#else
38323 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
38324 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
38325 +#endif
38326 +
38327 /*
38328 * Rounding UP to nearest 4-kB boundary here...
38329 */
38330 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38331 ioc->facts.GlobalCredits);
38332
38333 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
38334 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38335 + NULL, NULL);
38336 +#else
38337 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
38338 +#endif
38339 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
38340 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
38341 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
38342 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
38343 index fa43c39..daeb158 100644
38344 --- a/drivers/message/fusion/mptsas.c
38345 +++ b/drivers/message/fusion/mptsas.c
38346 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
38347 return 0;
38348 }
38349
38350 +static inline void
38351 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38352 +{
38353 + if (phy_info->port_details) {
38354 + phy_info->port_details->rphy = rphy;
38355 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38356 + ioc->name, rphy));
38357 + }
38358 +
38359 + if (rphy) {
38360 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38361 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38362 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38363 + ioc->name, rphy, rphy->dev.release));
38364 + }
38365 +}
38366 +
38367 /* no mutex */
38368 static void
38369 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
38370 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
38371 return NULL;
38372 }
38373
38374 -static inline void
38375 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38376 -{
38377 - if (phy_info->port_details) {
38378 - phy_info->port_details->rphy = rphy;
38379 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38380 - ioc->name, rphy));
38381 - }
38382 -
38383 - if (rphy) {
38384 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38385 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38386 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38387 - ioc->name, rphy, rphy->dev.release));
38388 - }
38389 -}
38390 -
38391 static inline struct sas_port *
38392 mptsas_get_port(struct mptsas_phyinfo *phy_info)
38393 {
38394 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
38395 index 164afa7..b6b2e74 100644
38396 --- a/drivers/message/fusion/mptscsih.c
38397 +++ b/drivers/message/fusion/mptscsih.c
38398 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
38399
38400 h = shost_priv(SChost);
38401
38402 - if (h) {
38403 - if (h->info_kbuf == NULL)
38404 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38405 - return h->info_kbuf;
38406 - h->info_kbuf[0] = '\0';
38407 + if (!h)
38408 + return NULL;
38409
38410 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38411 - h->info_kbuf[size-1] = '\0';
38412 - }
38413 + if (h->info_kbuf == NULL)
38414 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38415 + return h->info_kbuf;
38416 + h->info_kbuf[0] = '\0';
38417 +
38418 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38419 + h->info_kbuf[size-1] = '\0';
38420
38421 return h->info_kbuf;
38422 }
38423 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
38424 index 8001aa6..b137580 100644
38425 --- a/drivers/message/i2o/i2o_proc.c
38426 +++ b/drivers/message/i2o/i2o_proc.c
38427 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
38428 "Array Controller Device"
38429 };
38430
38431 -static char *chtostr(char *tmp, u8 *chars, int n)
38432 -{
38433 - tmp[0] = 0;
38434 - return strncat(tmp, (char *)chars, n);
38435 -}
38436 -
38437 static int i2o_report_query_status(struct seq_file *seq, int block_status,
38438 char *group)
38439 {
38440 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38441 } *result;
38442
38443 i2o_exec_execute_ddm_table ddm_table;
38444 - char tmp[28 + 1];
38445
38446 result = kmalloc(sizeof(*result), GFP_KERNEL);
38447 if (!result)
38448 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38449
38450 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
38451 seq_printf(seq, "%-#8x", ddm_table.module_id);
38452 - seq_printf(seq, "%-29s",
38453 - chtostr(tmp, ddm_table.module_name_version, 28));
38454 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
38455 seq_printf(seq, "%9d ", ddm_table.data_size);
38456 seq_printf(seq, "%8d", ddm_table.code_size);
38457
38458 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38459
38460 i2o_driver_result_table *result;
38461 i2o_driver_store_table *dst;
38462 - char tmp[28 + 1];
38463
38464 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
38465 if (result == NULL)
38466 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38467
38468 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
38469 seq_printf(seq, "%-#8x", dst->module_id);
38470 - seq_printf(seq, "%-29s",
38471 - chtostr(tmp, dst->module_name_version, 28));
38472 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
38473 + seq_printf(seq, "%-.28s", dst->module_name_version);
38474 + seq_printf(seq, "%-.8s", dst->date);
38475 seq_printf(seq, "%8d ", dst->module_size);
38476 seq_printf(seq, "%8d ", dst->mpb_size);
38477 seq_printf(seq, "0x%04x", dst->module_flags);
38478 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
38479 // == (allow) 512d bytes (max)
38480 static u16 *work16 = (u16 *) work32;
38481 int token;
38482 - char tmp[16 + 1];
38483
38484 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
38485
38486 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
38487 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
38488 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
38489 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
38490 - seq_printf(seq, "Vendor info : %s\n",
38491 - chtostr(tmp, (u8 *) (work32 + 2), 16));
38492 - seq_printf(seq, "Product info : %s\n",
38493 - chtostr(tmp, (u8 *) (work32 + 6), 16));
38494 - seq_printf(seq, "Description : %s\n",
38495 - chtostr(tmp, (u8 *) (work32 + 10), 16));
38496 - seq_printf(seq, "Product rev. : %s\n",
38497 - chtostr(tmp, (u8 *) (work32 + 14), 8));
38498 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
38499 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
38500 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
38501 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
38502
38503 seq_printf(seq, "Serial number : ");
38504 print_serial_number(seq, (u8 *) (work32 + 16),
38505 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
38506 u8 pad[256]; // allow up to 256 byte (max) serial number
38507 } result;
38508
38509 - char tmp[24 + 1];
38510 -
38511 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
38512
38513 if (token < 0) {
38514 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
38515 }
38516
38517 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
38518 - seq_printf(seq, "Module name : %s\n",
38519 - chtostr(tmp, result.module_name, 24));
38520 - seq_printf(seq, "Module revision : %s\n",
38521 - chtostr(tmp, result.module_rev, 8));
38522 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
38523 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
38524
38525 seq_printf(seq, "Serial number : ");
38526 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
38527 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
38528 u8 instance_number[4];
38529 } result;
38530
38531 - char tmp[64 + 1];
38532 -
38533 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
38534
38535 if (token < 0) {
38536 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
38537 return 0;
38538 }
38539
38540 - seq_printf(seq, "Device name : %s\n",
38541 - chtostr(tmp, result.device_name, 64));
38542 - seq_printf(seq, "Service name : %s\n",
38543 - chtostr(tmp, result.service_name, 64));
38544 - seq_printf(seq, "Physical name : %s\n",
38545 - chtostr(tmp, result.physical_location, 64));
38546 - seq_printf(seq, "Instance number : %s\n",
38547 - chtostr(tmp, result.instance_number, 4));
38548 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
38549 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
38550 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
38551 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
38552
38553 return 0;
38554 }
38555 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
38556 index a8c08f3..155fe3d 100644
38557 --- a/drivers/message/i2o/iop.c
38558 +++ b/drivers/message/i2o/iop.c
38559 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
38560
38561 spin_lock_irqsave(&c->context_list_lock, flags);
38562
38563 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
38564 - atomic_inc(&c->context_list_counter);
38565 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
38566 + atomic_inc_unchecked(&c->context_list_counter);
38567
38568 - entry->context = atomic_read(&c->context_list_counter);
38569 + entry->context = atomic_read_unchecked(&c->context_list_counter);
38570
38571 list_add(&entry->list, &c->context_list);
38572
38573 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
38574
38575 #if BITS_PER_LONG == 64
38576 spin_lock_init(&c->context_list_lock);
38577 - atomic_set(&c->context_list_counter, 0);
38578 + atomic_set_unchecked(&c->context_list_counter, 0);
38579 INIT_LIST_HEAD(&c->context_list);
38580 #endif
38581
38582 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
38583 index 45ece11..8efa218 100644
38584 --- a/drivers/mfd/janz-cmodio.c
38585 +++ b/drivers/mfd/janz-cmodio.c
38586 @@ -13,6 +13,7 @@
38587
38588 #include <linux/kernel.h>
38589 #include <linux/module.h>
38590 +#include <linux/slab.h>
38591 #include <linux/init.h>
38592 #include <linux/pci.h>
38593 #include <linux/interrupt.h>
38594 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
38595 index a5f9888..1c0ed56 100644
38596 --- a/drivers/mfd/twl4030-irq.c
38597 +++ b/drivers/mfd/twl4030-irq.c
38598 @@ -35,6 +35,7 @@
38599 #include <linux/of.h>
38600 #include <linux/irqdomain.h>
38601 #include <linux/i2c/twl.h>
38602 +#include <asm/pgtable.h>
38603
38604 #include "twl-core.h"
38605
38606 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
38607 * Install an irq handler for each of the SIH modules;
38608 * clone dummy irq_chip since PIH can't *do* anything
38609 */
38610 - twl4030_irq_chip = dummy_irq_chip;
38611 - twl4030_irq_chip.name = "twl4030";
38612 + pax_open_kernel();
38613 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
38614 + *(const char **)&twl4030_irq_chip.name = "twl4030";
38615
38616 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
38617 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
38618 + pax_close_kernel();
38619
38620 for (i = irq_base; i < irq_end; i++) {
38621 irq_set_chip_and_handler(i, &twl4030_irq_chip,
38622 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
38623 index 277a8db..0e0b754 100644
38624 --- a/drivers/mfd/twl6030-irq.c
38625 +++ b/drivers/mfd/twl6030-irq.c
38626 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
38627 * install an irq handler for each of the modules;
38628 * clone dummy irq_chip since PIH can't *do* anything
38629 */
38630 - twl6030_irq_chip = dummy_irq_chip;
38631 - twl6030_irq_chip.name = "twl6030";
38632 - twl6030_irq_chip.irq_set_type = NULL;
38633 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
38634 + pax_open_kernel();
38635 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
38636 + *(const char **)&twl6030_irq_chip.name = "twl6030";
38637 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
38638 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
38639 + pax_close_kernel();
38640
38641 for (i = irq_base; i < irq_end; i++) {
38642 irq_set_chip_and_handler(i, &twl6030_irq_chip,
38643 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
38644 index f32550a..e3e52a2 100644
38645 --- a/drivers/misc/c2port/core.c
38646 +++ b/drivers/misc/c2port/core.c
38647 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
38648 mutex_init(&c2dev->mutex);
38649
38650 /* Create binary file */
38651 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
38652 + pax_open_kernel();
38653 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
38654 + pax_close_kernel();
38655 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
38656 if (unlikely(ret))
38657 goto error_device_create_bin_file;
38658 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
38659 index 36f5d52..32311c3 100644
38660 --- a/drivers/misc/kgdbts.c
38661 +++ b/drivers/misc/kgdbts.c
38662 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
38663 char before[BREAK_INSTR_SIZE];
38664 char after[BREAK_INSTR_SIZE];
38665
38666 - probe_kernel_read(before, (char *)kgdbts_break_test,
38667 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
38668 BREAK_INSTR_SIZE);
38669 init_simple_test();
38670 ts.tst = plant_and_detach_test;
38671 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
38672 /* Activate test with initial breakpoint */
38673 if (!is_early)
38674 kgdb_breakpoint();
38675 - probe_kernel_read(after, (char *)kgdbts_break_test,
38676 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
38677 BREAK_INSTR_SIZE);
38678 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
38679 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
38680 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
38681 index 4a87e5c..76bdf5c 100644
38682 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
38683 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
38684 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
38685 * the lid is closed. This leads to interrupts as soon as a little move
38686 * is done.
38687 */
38688 - atomic_inc(&lis3->count);
38689 + atomic_inc_unchecked(&lis3->count);
38690
38691 wake_up_interruptible(&lis3->misc_wait);
38692 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
38693 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
38694 if (lis3->pm_dev)
38695 pm_runtime_get_sync(lis3->pm_dev);
38696
38697 - atomic_set(&lis3->count, 0);
38698 + atomic_set_unchecked(&lis3->count, 0);
38699 return 0;
38700 }
38701
38702 @@ -617,7 +617,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
38703 add_wait_queue(&lis3->misc_wait, &wait);
38704 while (true) {
38705 set_current_state(TASK_INTERRUPTIBLE);
38706 - data = atomic_xchg(&lis3->count, 0);
38707 + data = atomic_xchg_unchecked(&lis3->count, 0);
38708 if (data)
38709 break;
38710
38711 @@ -658,7 +658,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
38712 struct lis3lv02d, miscdev);
38713
38714 poll_wait(file, &lis3->misc_wait, wait);
38715 - if (atomic_read(&lis3->count))
38716 + if (atomic_read_unchecked(&lis3->count))
38717 return POLLIN | POLLRDNORM;
38718 return 0;
38719 }
38720 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
38721 index c439c82..1f20f57 100644
38722 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
38723 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
38724 @@ -297,7 +297,7 @@ struct lis3lv02d {
38725 struct input_polled_dev *idev; /* input device */
38726 struct platform_device *pdev; /* platform device */
38727 struct regulator_bulk_data regulators[2];
38728 - atomic_t count; /* interrupt count after last read */
38729 + atomic_unchecked_t count; /* interrupt count after last read */
38730 union axis_conversion ac; /* hw -> logical axis */
38731 int mapped_btns[3];
38732
38733 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
38734 index 2f30bad..c4c13d0 100644
38735 --- a/drivers/misc/sgi-gru/gruhandles.c
38736 +++ b/drivers/misc/sgi-gru/gruhandles.c
38737 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
38738 unsigned long nsec;
38739
38740 nsec = CLKS2NSEC(clks);
38741 - atomic_long_inc(&mcs_op_statistics[op].count);
38742 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
38743 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
38744 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
38745 if (mcs_op_statistics[op].max < nsec)
38746 mcs_op_statistics[op].max = nsec;
38747 }
38748 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
38749 index 950dbe9..eeef0f8 100644
38750 --- a/drivers/misc/sgi-gru/gruprocfs.c
38751 +++ b/drivers/misc/sgi-gru/gruprocfs.c
38752 @@ -32,9 +32,9 @@
38753
38754 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
38755
38756 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
38757 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
38758 {
38759 - unsigned long val = atomic_long_read(v);
38760 + unsigned long val = atomic_long_read_unchecked(v);
38761
38762 seq_printf(s, "%16lu %s\n", val, id);
38763 }
38764 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
38765
38766 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
38767 for (op = 0; op < mcsop_last; op++) {
38768 - count = atomic_long_read(&mcs_op_statistics[op].count);
38769 - total = atomic_long_read(&mcs_op_statistics[op].total);
38770 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
38771 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
38772 max = mcs_op_statistics[op].max;
38773 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
38774 count ? total / count : 0, max);
38775 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
38776 index 5c3ce24..4915ccb 100644
38777 --- a/drivers/misc/sgi-gru/grutables.h
38778 +++ b/drivers/misc/sgi-gru/grutables.h
38779 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
38780 * GRU statistics.
38781 */
38782 struct gru_stats_s {
38783 - atomic_long_t vdata_alloc;
38784 - atomic_long_t vdata_free;
38785 - atomic_long_t gts_alloc;
38786 - atomic_long_t gts_free;
38787 - atomic_long_t gms_alloc;
38788 - atomic_long_t gms_free;
38789 - atomic_long_t gts_double_allocate;
38790 - atomic_long_t assign_context;
38791 - atomic_long_t assign_context_failed;
38792 - atomic_long_t free_context;
38793 - atomic_long_t load_user_context;
38794 - atomic_long_t load_kernel_context;
38795 - atomic_long_t lock_kernel_context;
38796 - atomic_long_t unlock_kernel_context;
38797 - atomic_long_t steal_user_context;
38798 - atomic_long_t steal_kernel_context;
38799 - atomic_long_t steal_context_failed;
38800 - atomic_long_t nopfn;
38801 - atomic_long_t asid_new;
38802 - atomic_long_t asid_next;
38803 - atomic_long_t asid_wrap;
38804 - atomic_long_t asid_reuse;
38805 - atomic_long_t intr;
38806 - atomic_long_t intr_cbr;
38807 - atomic_long_t intr_tfh;
38808 - atomic_long_t intr_spurious;
38809 - atomic_long_t intr_mm_lock_failed;
38810 - atomic_long_t call_os;
38811 - atomic_long_t call_os_wait_queue;
38812 - atomic_long_t user_flush_tlb;
38813 - atomic_long_t user_unload_context;
38814 - atomic_long_t user_exception;
38815 - atomic_long_t set_context_option;
38816 - atomic_long_t check_context_retarget_intr;
38817 - atomic_long_t check_context_unload;
38818 - atomic_long_t tlb_dropin;
38819 - atomic_long_t tlb_preload_page;
38820 - atomic_long_t tlb_dropin_fail_no_asid;
38821 - atomic_long_t tlb_dropin_fail_upm;
38822 - atomic_long_t tlb_dropin_fail_invalid;
38823 - atomic_long_t tlb_dropin_fail_range_active;
38824 - atomic_long_t tlb_dropin_fail_idle;
38825 - atomic_long_t tlb_dropin_fail_fmm;
38826 - atomic_long_t tlb_dropin_fail_no_exception;
38827 - atomic_long_t tfh_stale_on_fault;
38828 - atomic_long_t mmu_invalidate_range;
38829 - atomic_long_t mmu_invalidate_page;
38830 - atomic_long_t flush_tlb;
38831 - atomic_long_t flush_tlb_gru;
38832 - atomic_long_t flush_tlb_gru_tgh;
38833 - atomic_long_t flush_tlb_gru_zero_asid;
38834 + atomic_long_unchecked_t vdata_alloc;
38835 + atomic_long_unchecked_t vdata_free;
38836 + atomic_long_unchecked_t gts_alloc;
38837 + atomic_long_unchecked_t gts_free;
38838 + atomic_long_unchecked_t gms_alloc;
38839 + atomic_long_unchecked_t gms_free;
38840 + atomic_long_unchecked_t gts_double_allocate;
38841 + atomic_long_unchecked_t assign_context;
38842 + atomic_long_unchecked_t assign_context_failed;
38843 + atomic_long_unchecked_t free_context;
38844 + atomic_long_unchecked_t load_user_context;
38845 + atomic_long_unchecked_t load_kernel_context;
38846 + atomic_long_unchecked_t lock_kernel_context;
38847 + atomic_long_unchecked_t unlock_kernel_context;
38848 + atomic_long_unchecked_t steal_user_context;
38849 + atomic_long_unchecked_t steal_kernel_context;
38850 + atomic_long_unchecked_t steal_context_failed;
38851 + atomic_long_unchecked_t nopfn;
38852 + atomic_long_unchecked_t asid_new;
38853 + atomic_long_unchecked_t asid_next;
38854 + atomic_long_unchecked_t asid_wrap;
38855 + atomic_long_unchecked_t asid_reuse;
38856 + atomic_long_unchecked_t intr;
38857 + atomic_long_unchecked_t intr_cbr;
38858 + atomic_long_unchecked_t intr_tfh;
38859 + atomic_long_unchecked_t intr_spurious;
38860 + atomic_long_unchecked_t intr_mm_lock_failed;
38861 + atomic_long_unchecked_t call_os;
38862 + atomic_long_unchecked_t call_os_wait_queue;
38863 + atomic_long_unchecked_t user_flush_tlb;
38864 + atomic_long_unchecked_t user_unload_context;
38865 + atomic_long_unchecked_t user_exception;
38866 + atomic_long_unchecked_t set_context_option;
38867 + atomic_long_unchecked_t check_context_retarget_intr;
38868 + atomic_long_unchecked_t check_context_unload;
38869 + atomic_long_unchecked_t tlb_dropin;
38870 + atomic_long_unchecked_t tlb_preload_page;
38871 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
38872 + atomic_long_unchecked_t tlb_dropin_fail_upm;
38873 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
38874 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
38875 + atomic_long_unchecked_t tlb_dropin_fail_idle;
38876 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
38877 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
38878 + atomic_long_unchecked_t tfh_stale_on_fault;
38879 + atomic_long_unchecked_t mmu_invalidate_range;
38880 + atomic_long_unchecked_t mmu_invalidate_page;
38881 + atomic_long_unchecked_t flush_tlb;
38882 + atomic_long_unchecked_t flush_tlb_gru;
38883 + atomic_long_unchecked_t flush_tlb_gru_tgh;
38884 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
38885
38886 - atomic_long_t copy_gpa;
38887 - atomic_long_t read_gpa;
38888 + atomic_long_unchecked_t copy_gpa;
38889 + atomic_long_unchecked_t read_gpa;
38890
38891 - atomic_long_t mesq_receive;
38892 - atomic_long_t mesq_receive_none;
38893 - atomic_long_t mesq_send;
38894 - atomic_long_t mesq_send_failed;
38895 - atomic_long_t mesq_noop;
38896 - atomic_long_t mesq_send_unexpected_error;
38897 - atomic_long_t mesq_send_lb_overflow;
38898 - atomic_long_t mesq_send_qlimit_reached;
38899 - atomic_long_t mesq_send_amo_nacked;
38900 - atomic_long_t mesq_send_put_nacked;
38901 - atomic_long_t mesq_page_overflow;
38902 - atomic_long_t mesq_qf_locked;
38903 - atomic_long_t mesq_qf_noop_not_full;
38904 - atomic_long_t mesq_qf_switch_head_failed;
38905 - atomic_long_t mesq_qf_unexpected_error;
38906 - atomic_long_t mesq_noop_unexpected_error;
38907 - atomic_long_t mesq_noop_lb_overflow;
38908 - atomic_long_t mesq_noop_qlimit_reached;
38909 - atomic_long_t mesq_noop_amo_nacked;
38910 - atomic_long_t mesq_noop_put_nacked;
38911 - atomic_long_t mesq_noop_page_overflow;
38912 + atomic_long_unchecked_t mesq_receive;
38913 + atomic_long_unchecked_t mesq_receive_none;
38914 + atomic_long_unchecked_t mesq_send;
38915 + atomic_long_unchecked_t mesq_send_failed;
38916 + atomic_long_unchecked_t mesq_noop;
38917 + atomic_long_unchecked_t mesq_send_unexpected_error;
38918 + atomic_long_unchecked_t mesq_send_lb_overflow;
38919 + atomic_long_unchecked_t mesq_send_qlimit_reached;
38920 + atomic_long_unchecked_t mesq_send_amo_nacked;
38921 + atomic_long_unchecked_t mesq_send_put_nacked;
38922 + atomic_long_unchecked_t mesq_page_overflow;
38923 + atomic_long_unchecked_t mesq_qf_locked;
38924 + atomic_long_unchecked_t mesq_qf_noop_not_full;
38925 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
38926 + atomic_long_unchecked_t mesq_qf_unexpected_error;
38927 + atomic_long_unchecked_t mesq_noop_unexpected_error;
38928 + atomic_long_unchecked_t mesq_noop_lb_overflow;
38929 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
38930 + atomic_long_unchecked_t mesq_noop_amo_nacked;
38931 + atomic_long_unchecked_t mesq_noop_put_nacked;
38932 + atomic_long_unchecked_t mesq_noop_page_overflow;
38933
38934 };
38935
38936 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
38937 tghop_invalidate, mcsop_last};
38938
38939 struct mcs_op_statistic {
38940 - atomic_long_t count;
38941 - atomic_long_t total;
38942 + atomic_long_unchecked_t count;
38943 + atomic_long_unchecked_t total;
38944 unsigned long max;
38945 };
38946
38947 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
38948
38949 #define STAT(id) do { \
38950 if (gru_options & OPT_STATS) \
38951 - atomic_long_inc(&gru_stats.id); \
38952 + atomic_long_inc_unchecked(&gru_stats.id); \
38953 } while (0)
38954
38955 #ifdef CONFIG_SGI_GRU_DEBUG
38956 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
38957 index c862cd4..0d176fe 100644
38958 --- a/drivers/misc/sgi-xp/xp.h
38959 +++ b/drivers/misc/sgi-xp/xp.h
38960 @@ -288,7 +288,7 @@ struct xpc_interface {
38961 xpc_notify_func, void *);
38962 void (*received) (short, int, void *);
38963 enum xp_retval (*partid_to_nasids) (short, void *);
38964 -};
38965 +} __no_const;
38966
38967 extern struct xpc_interface xpc_interface;
38968
38969 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
38970 index b94d5f7..7f494c5 100644
38971 --- a/drivers/misc/sgi-xp/xpc.h
38972 +++ b/drivers/misc/sgi-xp/xpc.h
38973 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
38974 void (*received_payload) (struct xpc_channel *, void *);
38975 void (*notify_senders_of_disconnect) (struct xpc_channel *);
38976 };
38977 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
38978
38979 /* struct xpc_partition act_state values (for XPC HB) */
38980
38981 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
38982 /* found in xpc_main.c */
38983 extern struct device *xpc_part;
38984 extern struct device *xpc_chan;
38985 -extern struct xpc_arch_operations xpc_arch_ops;
38986 +extern xpc_arch_operations_no_const xpc_arch_ops;
38987 extern int xpc_disengage_timelimit;
38988 extern int xpc_disengage_timedout;
38989 extern int xpc_activate_IRQ_rcvd;
38990 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
38991 index d971817..33bdca5 100644
38992 --- a/drivers/misc/sgi-xp/xpc_main.c
38993 +++ b/drivers/misc/sgi-xp/xpc_main.c
38994 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
38995 .notifier_call = xpc_system_die,
38996 };
38997
38998 -struct xpc_arch_operations xpc_arch_ops;
38999 +xpc_arch_operations_no_const xpc_arch_ops;
39000
39001 /*
39002 * Timer function to enforce the timelimit on the partition disengage.
39003 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39004
39005 if (((die_args->trapnr == X86_TRAP_MF) ||
39006 (die_args->trapnr == X86_TRAP_XF)) &&
39007 - !user_mode_vm(die_args->regs))
39008 + !user_mode(die_args->regs))
39009 xpc_die_deactivate();
39010
39011 break;
39012 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39013 index 49f04bc..65660c2 100644
39014 --- a/drivers/mmc/core/mmc_ops.c
39015 +++ b/drivers/mmc/core/mmc_ops.c
39016 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39017 void *data_buf;
39018 int is_on_stack;
39019
39020 - is_on_stack = object_is_on_stack(buf);
39021 + is_on_stack = object_starts_on_stack(buf);
39022 if (is_on_stack) {
39023 /*
39024 * dma onto stack is unsafe/nonportable, but callers to this
39025 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39026 index 53b8fd9..615b462 100644
39027 --- a/drivers/mmc/host/dw_mmc.h
39028 +++ b/drivers/mmc/host/dw_mmc.h
39029 @@ -205,5 +205,5 @@ struct dw_mci_drv_data {
39030 int (*parse_dt)(struct dw_mci *host);
39031 int (*setup_bus)(struct dw_mci *host,
39032 struct device_node *slot_np, u8 bus_width);
39033 -};
39034 +} __do_const;
39035 #endif /* _DW_MMC_H_ */
39036 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39037 index 7363efe..681558e 100644
39038 --- a/drivers/mmc/host/sdhci-s3c.c
39039 +++ b/drivers/mmc/host/sdhci-s3c.c
39040 @@ -720,9 +720,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39041 * we can use overriding functions instead of default.
39042 */
39043 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39044 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39045 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39046 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39047 + pax_open_kernel();
39048 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39049 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39050 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39051 + pax_close_kernel();
39052 }
39053
39054 /* It supports additional host capabilities if needed */
39055 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
39056 index a4eb8b5..8c0628f 100644
39057 --- a/drivers/mtd/devices/doc2000.c
39058 +++ b/drivers/mtd/devices/doc2000.c
39059 @@ -753,7 +753,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
39060
39061 /* The ECC will not be calculated correctly if less than 512 is written */
39062 /* DBB-
39063 - if (len != 0x200 && eccbuf)
39064 + if (len != 0x200)
39065 printk(KERN_WARNING
39066 "ECC needs a full sector write (adr: %lx size %lx)\n",
39067 (long) to, (long) len);
39068 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39069 index 0c8bb6b..6f35deb 100644
39070 --- a/drivers/mtd/nand/denali.c
39071 +++ b/drivers/mtd/nand/denali.c
39072 @@ -24,6 +24,7 @@
39073 #include <linux/slab.h>
39074 #include <linux/mtd/mtd.h>
39075 #include <linux/module.h>
39076 +#include <linux/slab.h>
39077
39078 #include "denali.h"
39079
39080 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39081 index 51b9d6a..52af9a7 100644
39082 --- a/drivers/mtd/nftlmount.c
39083 +++ b/drivers/mtd/nftlmount.c
39084 @@ -24,6 +24,7 @@
39085 #include <asm/errno.h>
39086 #include <linux/delay.h>
39087 #include <linux/slab.h>
39088 +#include <linux/sched.h>
39089 #include <linux/mtd/mtd.h>
39090 #include <linux/mtd/nand.h>
39091 #include <linux/mtd/nftl.h>
39092 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39093 index 8dd6ba5..419cc1d 100644
39094 --- a/drivers/mtd/sm_ftl.c
39095 +++ b/drivers/mtd/sm_ftl.c
39096 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39097 #define SM_CIS_VENDOR_OFFSET 0x59
39098 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39099 {
39100 - struct attribute_group *attr_group;
39101 + attribute_group_no_const *attr_group;
39102 struct attribute **attributes;
39103 struct sm_sysfs_attribute *vendor_attribute;
39104
39105 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39106 index dbbea0e..3f4a0b1 100644
39107 --- a/drivers/net/bonding/bond_main.c
39108 +++ b/drivers/net/bonding/bond_main.c
39109 @@ -4822,7 +4822,7 @@ static unsigned int bond_get_num_tx_queues(void)
39110 return tx_queues;
39111 }
39112
39113 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39114 +static struct rtnl_link_ops bond_link_ops = {
39115 .kind = "bond",
39116 .priv_size = sizeof(struct bonding),
39117 .setup = bond_setup,
39118 @@ -4947,8 +4947,8 @@ static void __exit bonding_exit(void)
39119
39120 bond_destroy_debugfs();
39121
39122 - rtnl_link_unregister(&bond_link_ops);
39123 unregister_pernet_subsys(&bond_net_ops);
39124 + rtnl_link_unregister(&bond_link_ops);
39125
39126 #ifdef CONFIG_NET_POLL_CONTROLLER
39127 /*
39128 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
39129 index e1d2643..7f4133b 100644
39130 --- a/drivers/net/ethernet/8390/ax88796.c
39131 +++ b/drivers/net/ethernet/8390/ax88796.c
39132 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
39133 if (ax->plat->reg_offsets)
39134 ei_local->reg_offset = ax->plat->reg_offsets;
39135 else {
39136 + resource_size_t _mem_size = mem_size;
39137 + do_div(_mem_size, 0x18);
39138 ei_local->reg_offset = ax->reg_offsets;
39139 for (ret = 0; ret < 0x18; ret++)
39140 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
39141 + ax->reg_offsets[ret] = _mem_size * ret;
39142 }
39143
39144 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
39145 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39146 index aee7671..3ca2651 100644
39147 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39148 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39149 @@ -1093,7 +1093,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
39150 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
39151 {
39152 /* RX_MODE controlling object */
39153 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
39154 + bnx2x_init_rx_mode_obj(bp);
39155
39156 /* multicast configuration controlling object */
39157 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
39158 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39159 index 7306416..5fb7fb5 100644
39160 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39161 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39162 @@ -2381,15 +2381,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
39163 return rc;
39164 }
39165
39166 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39167 - struct bnx2x_rx_mode_obj *o)
39168 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
39169 {
39170 if (CHIP_IS_E1x(bp)) {
39171 - o->wait_comp = bnx2x_empty_rx_mode_wait;
39172 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
39173 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
39174 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
39175 } else {
39176 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
39177 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
39178 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
39179 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
39180 }
39181 }
39182
39183 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39184 index ff90760..08d8aed 100644
39185 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39186 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39187 @@ -1306,8 +1306,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
39188
39189 /********************* RX MODE ****************/
39190
39191 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39192 - struct bnx2x_rx_mode_obj *o);
39193 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
39194
39195 /**
39196 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
39197 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
39198 index 8d7d4c2..95f7681 100644
39199 --- a/drivers/net/ethernet/broadcom/tg3.h
39200 +++ b/drivers/net/ethernet/broadcom/tg3.h
39201 @@ -147,6 +147,7 @@
39202 #define CHIPREV_ID_5750_A0 0x4000
39203 #define CHIPREV_ID_5750_A1 0x4001
39204 #define CHIPREV_ID_5750_A3 0x4003
39205 +#define CHIPREV_ID_5750_C1 0x4201
39206 #define CHIPREV_ID_5750_C2 0x4202
39207 #define CHIPREV_ID_5752_A0_HW 0x5000
39208 #define CHIPREV_ID_5752_A0 0x6000
39209 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39210 index 8cffcdf..aadf043 100644
39211 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39212 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39213 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
39214 */
39215 struct l2t_skb_cb {
39216 arp_failure_handler_func arp_failure_handler;
39217 -};
39218 +} __no_const;
39219
39220 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
39221
39222 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
39223 index 4c83003..2a2a5b9 100644
39224 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
39225 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
39226 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39227 for (i=0; i<ETH_ALEN; i++) {
39228 tmp.addr[i] = dev->dev_addr[i];
39229 }
39230 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39231 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39232 break;
39233
39234 case DE4X5_SET_HWADDR: /* Set the hardware address */
39235 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39236 spin_lock_irqsave(&lp->lock, flags);
39237 memcpy(&statbuf, &lp->pktStats, ioc->len);
39238 spin_unlock_irqrestore(&lp->lock, flags);
39239 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
39240 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
39241 return -EFAULT;
39242 break;
39243 }
39244 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
39245 index 2886c9b..db71673 100644
39246 --- a/drivers/net/ethernet/emulex/benet/be_main.c
39247 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
39248 @@ -455,7 +455,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
39249
39250 if (wrapped)
39251 newacc += 65536;
39252 - ACCESS_ONCE(*acc) = newacc;
39253 + ACCESS_ONCE_RW(*acc) = newacc;
39254 }
39255
39256 void be_parse_stats(struct be_adapter *adapter)
39257 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
39258 index 7c361d1..57e3ff1 100644
39259 --- a/drivers/net/ethernet/faraday/ftgmac100.c
39260 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
39261 @@ -31,6 +31,8 @@
39262 #include <linux/netdevice.h>
39263 #include <linux/phy.h>
39264 #include <linux/platform_device.h>
39265 +#include <linux/interrupt.h>
39266 +#include <linux/irqreturn.h>
39267 #include <net/ip.h>
39268
39269 #include "ftgmac100.h"
39270 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
39271 index b5ea8fb..bd25e9a 100644
39272 --- a/drivers/net/ethernet/faraday/ftmac100.c
39273 +++ b/drivers/net/ethernet/faraday/ftmac100.c
39274 @@ -31,6 +31,8 @@
39275 #include <linux/module.h>
39276 #include <linux/netdevice.h>
39277 #include <linux/platform_device.h>
39278 +#include <linux/interrupt.h>
39279 +#include <linux/irqreturn.h>
39280
39281 #include "ftmac100.h"
39282
39283 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39284 index 331987d..3be1135 100644
39285 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39286 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39287 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
39288 }
39289
39290 /* update the base incval used to calculate frequency adjustment */
39291 - ACCESS_ONCE(adapter->base_incval) = incval;
39292 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
39293 smp_mb();
39294
39295 /* need lock to prevent incorrect read while modifying cyclecounter */
39296 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39297 index fbe5363..266b4e3 100644
39298 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
39299 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39300 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39301 struct __vxge_hw_fifo *fifo;
39302 struct vxge_hw_fifo_config *config;
39303 u32 txdl_size, txdl_per_memblock;
39304 - struct vxge_hw_mempool_cbs fifo_mp_callback;
39305 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
39306 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
39307 + };
39308 +
39309 struct __vxge_hw_virtualpath *vpath;
39310
39311 if ((vp == NULL) || (attr == NULL)) {
39312 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39313 goto exit;
39314 }
39315
39316 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
39317 -
39318 fifo->mempool =
39319 __vxge_hw_mempool_create(vpath->hldev,
39320 fifo->config->memblock_size,
39321 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
39322 index 15ba8c4..3f56838 100644
39323 --- a/drivers/net/ethernet/realtek/r8169.c
39324 +++ b/drivers/net/ethernet/realtek/r8169.c
39325 @@ -740,22 +740,22 @@ struct rtl8169_private {
39326 struct mdio_ops {
39327 void (*write)(struct rtl8169_private *, int, int);
39328 int (*read)(struct rtl8169_private *, int);
39329 - } mdio_ops;
39330 + } __no_const mdio_ops;
39331
39332 struct pll_power_ops {
39333 void (*down)(struct rtl8169_private *);
39334 void (*up)(struct rtl8169_private *);
39335 - } pll_power_ops;
39336 + } __no_const pll_power_ops;
39337
39338 struct jumbo_ops {
39339 void (*enable)(struct rtl8169_private *);
39340 void (*disable)(struct rtl8169_private *);
39341 - } jumbo_ops;
39342 + } __no_const jumbo_ops;
39343
39344 struct csi_ops {
39345 void (*write)(struct rtl8169_private *, int, int);
39346 u32 (*read)(struct rtl8169_private *, int);
39347 - } csi_ops;
39348 + } __no_const csi_ops;
39349
39350 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
39351 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
39352 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
39353 index 3f93624..cf01144 100644
39354 --- a/drivers/net/ethernet/sfc/ptp.c
39355 +++ b/drivers/net/ethernet/sfc/ptp.c
39356 @@ -553,7 +553,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
39357 (u32)((u64)ptp->start.dma_addr >> 32));
39358
39359 /* Clear flag that signals MC ready */
39360 - ACCESS_ONCE(*start) = 0;
39361 + ACCESS_ONCE_RW(*start) = 0;
39362 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
39363 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
39364
39365 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39366 index 50617c5..b13724c 100644
39367 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39368 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39369 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
39370
39371 writel(value, ioaddr + MMC_CNTRL);
39372
39373 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
39374 - MMC_CNTRL, value);
39375 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
39376 +// MMC_CNTRL, value);
39377 }
39378
39379 /* To mask all all interrupts.*/
39380 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
39381 index e6fe0d8..2b7d752 100644
39382 --- a/drivers/net/hyperv/hyperv_net.h
39383 +++ b/drivers/net/hyperv/hyperv_net.h
39384 @@ -101,7 +101,7 @@ struct rndis_device {
39385
39386 enum rndis_device_state state;
39387 bool link_state;
39388 - atomic_t new_req_id;
39389 + atomic_unchecked_t new_req_id;
39390
39391 spinlock_t request_lock;
39392 struct list_head req_list;
39393 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
39394 index 0775f0a..d4fb316 100644
39395 --- a/drivers/net/hyperv/rndis_filter.c
39396 +++ b/drivers/net/hyperv/rndis_filter.c
39397 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
39398 * template
39399 */
39400 set = &rndis_msg->msg.set_req;
39401 - set->req_id = atomic_inc_return(&dev->new_req_id);
39402 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
39403
39404 /* Add to the request list */
39405 spin_lock_irqsave(&dev->request_lock, flags);
39406 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
39407
39408 /* Setup the rndis set */
39409 halt = &request->request_msg.msg.halt_req;
39410 - halt->req_id = atomic_inc_return(&dev->new_req_id);
39411 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
39412
39413 /* Ignore return since this msg is optional. */
39414 rndis_filter_send_request(dev, request);
39415 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
39416 index 8f1c256..a2991d1 100644
39417 --- a/drivers/net/ieee802154/fakehard.c
39418 +++ b/drivers/net/ieee802154/fakehard.c
39419 @@ -385,7 +385,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
39420 phy->transmit_power = 0xbf;
39421
39422 dev->netdev_ops = &fake_ops;
39423 - dev->ml_priv = &fake_mlme;
39424 + dev->ml_priv = (void *)&fake_mlme;
39425
39426 priv = netdev_priv(dev);
39427 priv->phy = phy;
39428 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
39429 index 73abbc1..f25db7c 100644
39430 --- a/drivers/net/macvlan.c
39431 +++ b/drivers/net/macvlan.c
39432 @@ -891,13 +891,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
39433 int macvlan_link_register(struct rtnl_link_ops *ops)
39434 {
39435 /* common fields */
39436 - ops->priv_size = sizeof(struct macvlan_dev);
39437 - ops->validate = macvlan_validate;
39438 - ops->maxtype = IFLA_MACVLAN_MAX;
39439 - ops->policy = macvlan_policy;
39440 - ops->changelink = macvlan_changelink;
39441 - ops->get_size = macvlan_get_size;
39442 - ops->fill_info = macvlan_fill_info;
39443 + pax_open_kernel();
39444 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
39445 + *(void **)&ops->validate = macvlan_validate;
39446 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
39447 + *(const void **)&ops->policy = macvlan_policy;
39448 + *(void **)&ops->changelink = macvlan_changelink;
39449 + *(void **)&ops->get_size = macvlan_get_size;
39450 + *(void **)&ops->fill_info = macvlan_fill_info;
39451 + pax_close_kernel();
39452
39453 return rtnl_link_register(ops);
39454 };
39455 @@ -953,7 +955,7 @@ static int macvlan_device_event(struct notifier_block *unused,
39456 return NOTIFY_DONE;
39457 }
39458
39459 -static struct notifier_block macvlan_notifier_block __read_mostly = {
39460 +static struct notifier_block macvlan_notifier_block = {
39461 .notifier_call = macvlan_device_event,
39462 };
39463
39464 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
39465 index a449439..1e468fe 100644
39466 --- a/drivers/net/macvtap.c
39467 +++ b/drivers/net/macvtap.c
39468 @@ -1090,7 +1090,7 @@ static int macvtap_device_event(struct notifier_block *unused,
39469 return NOTIFY_DONE;
39470 }
39471
39472 -static struct notifier_block macvtap_notifier_block __read_mostly = {
39473 +static struct notifier_block macvtap_notifier_block = {
39474 .notifier_call = macvtap_device_event,
39475 };
39476
39477 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
39478 index daec9b0..6428fcb 100644
39479 --- a/drivers/net/phy/mdio-bitbang.c
39480 +++ b/drivers/net/phy/mdio-bitbang.c
39481 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
39482 struct mdiobb_ctrl *ctrl = bus->priv;
39483
39484 module_put(ctrl->ops->owner);
39485 + mdiobus_unregister(bus);
39486 mdiobus_free(bus);
39487 }
39488 EXPORT_SYMBOL(free_mdio_bitbang);
39489 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
39490 index 72ff14b..11d442d 100644
39491 --- a/drivers/net/ppp/ppp_generic.c
39492 +++ b/drivers/net/ppp/ppp_generic.c
39493 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
39494 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
39495 struct ppp_stats stats;
39496 struct ppp_comp_stats cstats;
39497 - char *vers;
39498
39499 switch (cmd) {
39500 case SIOCGPPPSTATS:
39501 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
39502 break;
39503
39504 case SIOCGPPPVER:
39505 - vers = PPP_VERSION;
39506 - if (copy_to_user(addr, vers, strlen(vers) + 1))
39507 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
39508 break;
39509 err = 0;
39510 break;
39511 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
39512 index 1252d9c..80e660b 100644
39513 --- a/drivers/net/slip/slhc.c
39514 +++ b/drivers/net/slip/slhc.c
39515 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
39516 register struct tcphdr *thp;
39517 register struct iphdr *ip;
39518 register struct cstate *cs;
39519 - int len, hdrlen;
39520 + long len, hdrlen;
39521 unsigned char *cp = icp;
39522
39523 /* We've got a compressed packet; read the change byte */
39524 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
39525 index bf34192..fba3500 100644
39526 --- a/drivers/net/team/team.c
39527 +++ b/drivers/net/team/team.c
39528 @@ -2668,7 +2668,7 @@ static int team_device_event(struct notifier_block *unused,
39529 return NOTIFY_DONE;
39530 }
39531
39532 -static struct notifier_block team_notifier_block __read_mostly = {
39533 +static struct notifier_block team_notifier_block = {
39534 .notifier_call = team_device_event,
39535 };
39536
39537 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
39538 index 729ed53..9453f99 100644
39539 --- a/drivers/net/tun.c
39540 +++ b/drivers/net/tun.c
39541 @@ -1838,7 +1838,7 @@ unlock:
39542 }
39543
39544 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
39545 - unsigned long arg, int ifreq_len)
39546 + unsigned long arg, size_t ifreq_len)
39547 {
39548 struct tun_file *tfile = file->private_data;
39549 struct tun_struct *tun;
39550 @@ -1850,6 +1850,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
39551 int vnet_hdr_sz;
39552 int ret;
39553
39554 + if (ifreq_len > sizeof ifr)
39555 + return -EFAULT;
39556 +
39557 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
39558 if (copy_from_user(&ifr, argp, ifreq_len))
39559 return -EFAULT;
39560 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
39561 index e2dd324..be92fcf 100644
39562 --- a/drivers/net/usb/hso.c
39563 +++ b/drivers/net/usb/hso.c
39564 @@ -71,7 +71,7 @@
39565 #include <asm/byteorder.h>
39566 #include <linux/serial_core.h>
39567 #include <linux/serial.h>
39568 -
39569 +#include <asm/local.h>
39570
39571 #define MOD_AUTHOR "Option Wireless"
39572 #define MOD_DESCRIPTION "USB High Speed Option driver"
39573 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
39574 struct urb *urb;
39575
39576 urb = serial->rx_urb[0];
39577 - if (serial->port.count > 0) {
39578 + if (atomic_read(&serial->port.count) > 0) {
39579 count = put_rxbuf_data(urb, serial);
39580 if (count == -1)
39581 return;
39582 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
39583 DUMP1(urb->transfer_buffer, urb->actual_length);
39584
39585 /* Anyone listening? */
39586 - if (serial->port.count == 0)
39587 + if (atomic_read(&serial->port.count) == 0)
39588 return;
39589
39590 if (status == 0) {
39591 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
39592 tty_port_tty_set(&serial->port, tty);
39593
39594 /* check for port already opened, if not set the termios */
39595 - serial->port.count++;
39596 - if (serial->port.count == 1) {
39597 + if (atomic_inc_return(&serial->port.count) == 1) {
39598 serial->rx_state = RX_IDLE;
39599 /* Force default termio settings */
39600 _hso_serial_set_termios(tty, NULL);
39601 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
39602 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
39603 if (result) {
39604 hso_stop_serial_device(serial->parent);
39605 - serial->port.count--;
39606 + atomic_dec(&serial->port.count);
39607 kref_put(&serial->parent->ref, hso_serial_ref_free);
39608 }
39609 } else {
39610 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
39611
39612 /* reset the rts and dtr */
39613 /* do the actual close */
39614 - serial->port.count--;
39615 + atomic_dec(&serial->port.count);
39616
39617 - if (serial->port.count <= 0) {
39618 - serial->port.count = 0;
39619 + if (atomic_read(&serial->port.count) <= 0) {
39620 + atomic_set(&serial->port.count, 0);
39621 tty_port_tty_set(&serial->port, NULL);
39622 if (!usb_gone)
39623 hso_stop_serial_device(serial->parent);
39624 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
39625
39626 /* the actual setup */
39627 spin_lock_irqsave(&serial->serial_lock, flags);
39628 - if (serial->port.count)
39629 + if (atomic_read(&serial->port.count))
39630 _hso_serial_set_termios(tty, old);
39631 else
39632 tty->termios = *old;
39633 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
39634 D1("Pending read interrupt on port %d\n", i);
39635 spin_lock(&serial->serial_lock);
39636 if (serial->rx_state == RX_IDLE &&
39637 - serial->port.count > 0) {
39638 + atomic_read(&serial->port.count) > 0) {
39639 /* Setup and send a ctrl req read on
39640 * port i */
39641 if (!serial->rx_urb_filled[0]) {
39642 @@ -3066,7 +3065,7 @@ static int hso_resume(struct usb_interface *iface)
39643 /* Start all serial ports */
39644 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
39645 if (serial_table[i] && (serial_table[i]->interface == iface)) {
39646 - if (dev2ser(serial_table[i])->port.count) {
39647 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
39648 result =
39649 hso_start_serial_device(serial_table[i], GFP_NOIO);
39650 hso_kick_transmit(dev2ser(serial_table[i]));
39651 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
39652 index 7cee7a3..1eb9f3b 100644
39653 --- a/drivers/net/vxlan.c
39654 +++ b/drivers/net/vxlan.c
39655 @@ -1443,7 +1443,7 @@ nla_put_failure:
39656 return -EMSGSIZE;
39657 }
39658
39659 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
39660 +static struct rtnl_link_ops vxlan_link_ops = {
39661 .kind = "vxlan",
39662 .maxtype = IFLA_VXLAN_MAX,
39663 .policy = vxlan_policy,
39664 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
39665 index 5ac5f7a..5f82012 100644
39666 --- a/drivers/net/wireless/at76c50x-usb.c
39667 +++ b/drivers/net/wireless/at76c50x-usb.c
39668 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
39669 }
39670
39671 /* Convert timeout from the DFU status to jiffies */
39672 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
39673 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
39674 {
39675 return msecs_to_jiffies((s->poll_timeout[2] << 16)
39676 | (s->poll_timeout[1] << 8)
39677 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
39678 index 8d78253..bebbb68 100644
39679 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
39680 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
39681 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39682 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
39683 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
39684
39685 - ACCESS_ONCE(ads->ds_link) = i->link;
39686 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
39687 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
39688 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
39689
39690 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
39691 ctl6 = SM(i->keytype, AR_EncrType);
39692 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39693
39694 if ((i->is_first || i->is_last) &&
39695 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
39696 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
39697 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
39698 | set11nTries(i->rates, 1)
39699 | set11nTries(i->rates, 2)
39700 | set11nTries(i->rates, 3)
39701 | (i->dur_update ? AR_DurUpdateEna : 0)
39702 | SM(0, AR_BurstDur);
39703
39704 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
39705 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
39706 | set11nRate(i->rates, 1)
39707 | set11nRate(i->rates, 2)
39708 | set11nRate(i->rates, 3);
39709 } else {
39710 - ACCESS_ONCE(ads->ds_ctl2) = 0;
39711 - ACCESS_ONCE(ads->ds_ctl3) = 0;
39712 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
39713 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
39714 }
39715
39716 if (!i->is_first) {
39717 - ACCESS_ONCE(ads->ds_ctl0) = 0;
39718 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
39719 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
39720 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
39721 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
39722 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
39723 return;
39724 }
39725
39726 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39727 break;
39728 }
39729
39730 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
39731 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
39732 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
39733 | SM(i->txpower, AR_XmitPower)
39734 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
39735 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39736 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
39737 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
39738
39739 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
39740 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
39741 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
39742 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
39743
39744 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
39745 return;
39746
39747 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
39748 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
39749 | set11nPktDurRTSCTS(i->rates, 1);
39750
39751 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
39752 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
39753 | set11nPktDurRTSCTS(i->rates, 3);
39754
39755 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
39756 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
39757 | set11nRateFlags(i->rates, 1)
39758 | set11nRateFlags(i->rates, 2)
39759 | set11nRateFlags(i->rates, 3)
39760 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
39761 index 301bf72..3f5654f 100644
39762 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
39763 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
39764 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39765 (i->qcu << AR_TxQcuNum_S) | desc_len;
39766
39767 checksum += val;
39768 - ACCESS_ONCE(ads->info) = val;
39769 + ACCESS_ONCE_RW(ads->info) = val;
39770
39771 checksum += i->link;
39772 - ACCESS_ONCE(ads->link) = i->link;
39773 + ACCESS_ONCE_RW(ads->link) = i->link;
39774
39775 checksum += i->buf_addr[0];
39776 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
39777 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
39778 checksum += i->buf_addr[1];
39779 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
39780 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
39781 checksum += i->buf_addr[2];
39782 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
39783 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
39784 checksum += i->buf_addr[3];
39785 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
39786 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
39787
39788 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
39789 - ACCESS_ONCE(ads->ctl3) = val;
39790 + ACCESS_ONCE_RW(ads->ctl3) = val;
39791 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
39792 - ACCESS_ONCE(ads->ctl5) = val;
39793 + ACCESS_ONCE_RW(ads->ctl5) = val;
39794 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
39795 - ACCESS_ONCE(ads->ctl7) = val;
39796 + ACCESS_ONCE_RW(ads->ctl7) = val;
39797 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
39798 - ACCESS_ONCE(ads->ctl9) = val;
39799 + ACCESS_ONCE_RW(ads->ctl9) = val;
39800
39801 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
39802 - ACCESS_ONCE(ads->ctl10) = checksum;
39803 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
39804
39805 if (i->is_first || i->is_last) {
39806 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
39807 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
39808 | set11nTries(i->rates, 1)
39809 | set11nTries(i->rates, 2)
39810 | set11nTries(i->rates, 3)
39811 | (i->dur_update ? AR_DurUpdateEna : 0)
39812 | SM(0, AR_BurstDur);
39813
39814 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
39815 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
39816 | set11nRate(i->rates, 1)
39817 | set11nRate(i->rates, 2)
39818 | set11nRate(i->rates, 3);
39819 } else {
39820 - ACCESS_ONCE(ads->ctl13) = 0;
39821 - ACCESS_ONCE(ads->ctl14) = 0;
39822 + ACCESS_ONCE_RW(ads->ctl13) = 0;
39823 + ACCESS_ONCE_RW(ads->ctl14) = 0;
39824 }
39825
39826 ads->ctl20 = 0;
39827 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39828
39829 ctl17 = SM(i->keytype, AR_EncrType);
39830 if (!i->is_first) {
39831 - ACCESS_ONCE(ads->ctl11) = 0;
39832 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
39833 - ACCESS_ONCE(ads->ctl15) = 0;
39834 - ACCESS_ONCE(ads->ctl16) = 0;
39835 - ACCESS_ONCE(ads->ctl17) = ctl17;
39836 - ACCESS_ONCE(ads->ctl18) = 0;
39837 - ACCESS_ONCE(ads->ctl19) = 0;
39838 + ACCESS_ONCE_RW(ads->ctl11) = 0;
39839 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
39840 + ACCESS_ONCE_RW(ads->ctl15) = 0;
39841 + ACCESS_ONCE_RW(ads->ctl16) = 0;
39842 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
39843 + ACCESS_ONCE_RW(ads->ctl18) = 0;
39844 + ACCESS_ONCE_RW(ads->ctl19) = 0;
39845 return;
39846 }
39847
39848 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
39849 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
39850 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
39851 | SM(i->txpower, AR_XmitPower)
39852 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
39853 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
39854 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
39855 ctl12 |= SM(val, AR_PAPRDChainMask);
39856
39857 - ACCESS_ONCE(ads->ctl12) = ctl12;
39858 - ACCESS_ONCE(ads->ctl17) = ctl17;
39859 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
39860 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
39861
39862 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
39863 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
39864 | set11nPktDurRTSCTS(i->rates, 1);
39865
39866 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
39867 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
39868 | set11nPktDurRTSCTS(i->rates, 3);
39869
39870 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
39871 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
39872 | set11nRateFlags(i->rates, 1)
39873 | set11nRateFlags(i->rates, 2)
39874 | set11nRateFlags(i->rates, 3)
39875 | SM(i->rtscts_rate, AR_RTSCTSRate);
39876
39877 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
39878 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
39879 }
39880
39881 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
39882 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
39883 index 784e81c..349e01e 100644
39884 --- a/drivers/net/wireless/ath/ath9k/hw.h
39885 +++ b/drivers/net/wireless/ath/ath9k/hw.h
39886 @@ -653,7 +653,7 @@ struct ath_hw_private_ops {
39887
39888 /* ANI */
39889 void (*ani_cache_ini_regs)(struct ath_hw *ah);
39890 -};
39891 +} __no_const;
39892
39893 /**
39894 * struct ath_spec_scan - parameters for Atheros spectral scan
39895 @@ -722,7 +722,7 @@ struct ath_hw_ops {
39896 struct ath_spec_scan *param);
39897 void (*spectral_scan_trigger)(struct ath_hw *ah);
39898 void (*spectral_scan_wait)(struct ath_hw *ah);
39899 -};
39900 +} __no_const;
39901
39902 struct ath_nf_limits {
39903 s16 max;
39904 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
39905 index c353b5f..62aaca2 100644
39906 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
39907 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
39908 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
39909 */
39910 if (il3945_mod_params.disable_hw_scan) {
39911 D_INFO("Disabling hw_scan\n");
39912 - il3945_mac_ops.hw_scan = NULL;
39913 + pax_open_kernel();
39914 + *(void **)&il3945_mac_ops.hw_scan = NULL;
39915 + pax_close_kernel();
39916 }
39917
39918 D_INFO("*** LOAD DRIVER ***\n");
39919 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
39920 index 81d4071..f2071ea 100644
39921 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
39922 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
39923 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
39924 {
39925 struct iwl_priv *priv = file->private_data;
39926 char buf[64];
39927 - int buf_size;
39928 + size_t buf_size;
39929 u32 offset, len;
39930
39931 memset(buf, 0, sizeof(buf));
39932 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
39933 struct iwl_priv *priv = file->private_data;
39934
39935 char buf[8];
39936 - int buf_size;
39937 + size_t buf_size;
39938 u32 reset_flag;
39939
39940 memset(buf, 0, sizeof(buf));
39941 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
39942 {
39943 struct iwl_priv *priv = file->private_data;
39944 char buf[8];
39945 - int buf_size;
39946 + size_t buf_size;
39947 int ht40;
39948
39949 memset(buf, 0, sizeof(buf));
39950 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
39951 {
39952 struct iwl_priv *priv = file->private_data;
39953 char buf[8];
39954 - int buf_size;
39955 + size_t buf_size;
39956 int value;
39957
39958 memset(buf, 0, sizeof(buf));
39959 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
39960 {
39961 struct iwl_priv *priv = file->private_data;
39962 char buf[8];
39963 - int buf_size;
39964 + size_t buf_size;
39965 int clear;
39966
39967 memset(buf, 0, sizeof(buf));
39968 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
39969 {
39970 struct iwl_priv *priv = file->private_data;
39971 char buf[8];
39972 - int buf_size;
39973 + size_t buf_size;
39974 int trace;
39975
39976 memset(buf, 0, sizeof(buf));
39977 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
39978 {
39979 struct iwl_priv *priv = file->private_data;
39980 char buf[8];
39981 - int buf_size;
39982 + size_t buf_size;
39983 int missed;
39984
39985 memset(buf, 0, sizeof(buf));
39986 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
39987
39988 struct iwl_priv *priv = file->private_data;
39989 char buf[8];
39990 - int buf_size;
39991 + size_t buf_size;
39992 int plcp;
39993
39994 memset(buf, 0, sizeof(buf));
39995 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
39996
39997 struct iwl_priv *priv = file->private_data;
39998 char buf[8];
39999 - int buf_size;
40000 + size_t buf_size;
40001 int flush;
40002
40003 memset(buf, 0, sizeof(buf));
40004 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
40005
40006 struct iwl_priv *priv = file->private_data;
40007 char buf[8];
40008 - int buf_size;
40009 + size_t buf_size;
40010 int rts;
40011
40012 if (!priv->cfg->ht_params)
40013 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
40014 {
40015 struct iwl_priv *priv = file->private_data;
40016 char buf[8];
40017 - int buf_size;
40018 + size_t buf_size;
40019
40020 memset(buf, 0, sizeof(buf));
40021 buf_size = min(count, sizeof(buf) - 1);
40022 @@ -2256,7 +2256,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
40023 struct iwl_priv *priv = file->private_data;
40024 u32 event_log_flag;
40025 char buf[8];
40026 - int buf_size;
40027 + size_t buf_size;
40028
40029 /* check that the interface is up */
40030 if (!iwl_is_ready(priv))
40031 @@ -2310,7 +2310,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
40032 struct iwl_priv *priv = file->private_data;
40033 char buf[8];
40034 u32 calib_disabled;
40035 - int buf_size;
40036 + size_t buf_size;
40037
40038 memset(buf, 0, sizeof(buf));
40039 buf_size = min(count, sizeof(buf) - 1);
40040 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
40041 index 12c4f31..484d948 100644
40042 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
40043 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
40044 @@ -1328,7 +1328,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
40045 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
40046
40047 char buf[8];
40048 - int buf_size;
40049 + size_t buf_size;
40050 u32 reset_flag;
40051
40052 memset(buf, 0, sizeof(buf));
40053 @@ -1349,7 +1349,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
40054 {
40055 struct iwl_trans *trans = file->private_data;
40056 char buf[8];
40057 - int buf_size;
40058 + size_t buf_size;
40059 int csr;
40060
40061 memset(buf, 0, sizeof(buf));
40062 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
40063 index cffdf4f..7cefb69 100644
40064 --- a/drivers/net/wireless/mac80211_hwsim.c
40065 +++ b/drivers/net/wireless/mac80211_hwsim.c
40066 @@ -2144,25 +2144,19 @@ static int __init init_mac80211_hwsim(void)
40067
40068 if (channels > 1) {
40069 hwsim_if_comb.num_different_channels = channels;
40070 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40071 - mac80211_hwsim_ops.cancel_hw_scan =
40072 - mac80211_hwsim_cancel_hw_scan;
40073 - mac80211_hwsim_ops.sw_scan_start = NULL;
40074 - mac80211_hwsim_ops.sw_scan_complete = NULL;
40075 - mac80211_hwsim_ops.remain_on_channel =
40076 - mac80211_hwsim_roc;
40077 - mac80211_hwsim_ops.cancel_remain_on_channel =
40078 - mac80211_hwsim_croc;
40079 - mac80211_hwsim_ops.add_chanctx =
40080 - mac80211_hwsim_add_chanctx;
40081 - mac80211_hwsim_ops.remove_chanctx =
40082 - mac80211_hwsim_remove_chanctx;
40083 - mac80211_hwsim_ops.change_chanctx =
40084 - mac80211_hwsim_change_chanctx;
40085 - mac80211_hwsim_ops.assign_vif_chanctx =
40086 - mac80211_hwsim_assign_vif_chanctx;
40087 - mac80211_hwsim_ops.unassign_vif_chanctx =
40088 - mac80211_hwsim_unassign_vif_chanctx;
40089 + pax_open_kernel();
40090 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40091 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
40092 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
40093 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
40094 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
40095 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
40096 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
40097 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
40098 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
40099 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
40100 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
40101 + pax_close_kernel();
40102 }
40103
40104 spin_lock_init(&hwsim_radio_lock);
40105 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
40106 index 525fd75..6c9f791 100644
40107 --- a/drivers/net/wireless/rndis_wlan.c
40108 +++ b/drivers/net/wireless/rndis_wlan.c
40109 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
40110
40111 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
40112
40113 - if (rts_threshold < 0 || rts_threshold > 2347)
40114 + if (rts_threshold > 2347)
40115 rts_threshold = 2347;
40116
40117 tmp = cpu_to_le32(rts_threshold);
40118 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
40119 index 086abb4..8279c30 100644
40120 --- a/drivers/net/wireless/rt2x00/rt2x00.h
40121 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
40122 @@ -396,7 +396,7 @@ struct rt2x00_intf {
40123 * for hardware which doesn't support hardware
40124 * sequence counting.
40125 */
40126 - atomic_t seqno;
40127 + atomic_unchecked_t seqno;
40128 };
40129
40130 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
40131 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
40132 index 4d91795..62fccff 100644
40133 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
40134 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
40135 @@ -251,9 +251,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
40136 * sequence counter given by mac80211.
40137 */
40138 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
40139 - seqno = atomic_add_return(0x10, &intf->seqno);
40140 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
40141 else
40142 - seqno = atomic_read(&intf->seqno);
40143 + seqno = atomic_read_unchecked(&intf->seqno);
40144
40145 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
40146 hdr->seq_ctrl |= cpu_to_le16(seqno);
40147 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
40148 index e57ee48..541cf6c 100644
40149 --- a/drivers/net/wireless/ti/wl1251/sdio.c
40150 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
40151 @@ -269,13 +269,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
40152
40153 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
40154
40155 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40156 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40157 + pax_open_kernel();
40158 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40159 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40160 + pax_close_kernel();
40161
40162 wl1251_info("using dedicated interrupt line");
40163 } else {
40164 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40165 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40166 + pax_open_kernel();
40167 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40168 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40169 + pax_close_kernel();
40170
40171 wl1251_info("using SDIO interrupt");
40172 }
40173 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
40174 index 09694e3..24ccec7 100644
40175 --- a/drivers/net/wireless/ti/wl12xx/main.c
40176 +++ b/drivers/net/wireless/ti/wl12xx/main.c
40177 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40178 sizeof(wl->conf.mem));
40179
40180 /* read data preparation is only needed by wl127x */
40181 - wl->ops->prepare_read = wl127x_prepare_read;
40182 + pax_open_kernel();
40183 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40184 + pax_close_kernel();
40185
40186 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
40187 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
40188 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40189 sizeof(wl->conf.mem));
40190
40191 /* read data preparation is only needed by wl127x */
40192 - wl->ops->prepare_read = wl127x_prepare_read;
40193 + pax_open_kernel();
40194 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40195 + pax_close_kernel();
40196
40197 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
40198 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
40199 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
40200 index da3ef1b..4790b95 100644
40201 --- a/drivers/net/wireless/ti/wl18xx/main.c
40202 +++ b/drivers/net/wireless/ti/wl18xx/main.c
40203 @@ -1664,8 +1664,10 @@ static int wl18xx_setup(struct wl1271 *wl)
40204 }
40205
40206 if (!checksum_param) {
40207 - wl18xx_ops.set_rx_csum = NULL;
40208 - wl18xx_ops.init_vif = NULL;
40209 + pax_open_kernel();
40210 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
40211 + *(void **)&wl18xx_ops.init_vif = NULL;
40212 + pax_close_kernel();
40213 }
40214
40215 /* Enable 11a Band only if we have 5G antennas */
40216 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
40217 index 7ef0b4a..ff65c28 100644
40218 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
40219 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
40220 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
40221 {
40222 struct zd_usb *usb = urb->context;
40223 struct zd_usb_interrupt *intr = &usb->intr;
40224 - int len;
40225 + unsigned int len;
40226 u16 int_num;
40227
40228 ZD_ASSERT(in_interrupt());
40229 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
40230 index d93b2b6..ae50401 100644
40231 --- a/drivers/oprofile/buffer_sync.c
40232 +++ b/drivers/oprofile/buffer_sync.c
40233 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
40234 if (cookie == NO_COOKIE)
40235 offset = pc;
40236 if (cookie == INVALID_COOKIE) {
40237 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
40238 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
40239 offset = pc;
40240 }
40241 if (cookie != last_cookie) {
40242 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
40243 /* add userspace sample */
40244
40245 if (!mm) {
40246 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
40247 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
40248 return 0;
40249 }
40250
40251 cookie = lookup_dcookie(mm, s->eip, &offset);
40252
40253 if (cookie == INVALID_COOKIE) {
40254 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
40255 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
40256 return 0;
40257 }
40258
40259 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
40260 /* ignore backtraces if failed to add a sample */
40261 if (state == sb_bt_start) {
40262 state = sb_bt_ignore;
40263 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
40264 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
40265 }
40266 }
40267 release_mm(mm);
40268 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
40269 index c0cc4e7..44d4e54 100644
40270 --- a/drivers/oprofile/event_buffer.c
40271 +++ b/drivers/oprofile/event_buffer.c
40272 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
40273 }
40274
40275 if (buffer_pos == buffer_size) {
40276 - atomic_inc(&oprofile_stats.event_lost_overflow);
40277 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
40278 return;
40279 }
40280
40281 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
40282 index ed2c3ec..deda85a 100644
40283 --- a/drivers/oprofile/oprof.c
40284 +++ b/drivers/oprofile/oprof.c
40285 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
40286 if (oprofile_ops.switch_events())
40287 return;
40288
40289 - atomic_inc(&oprofile_stats.multiplex_counter);
40290 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
40291 start_switch_worker();
40292 }
40293
40294 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
40295 index 84a208d..d61b0a1 100644
40296 --- a/drivers/oprofile/oprofile_files.c
40297 +++ b/drivers/oprofile/oprofile_files.c
40298 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
40299
40300 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
40301
40302 -static ssize_t timeout_read(struct file *file, char __user *buf,
40303 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
40304 size_t count, loff_t *offset)
40305 {
40306 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
40307 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
40308 index 917d28e..d62d981 100644
40309 --- a/drivers/oprofile/oprofile_stats.c
40310 +++ b/drivers/oprofile/oprofile_stats.c
40311 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
40312 cpu_buf->sample_invalid_eip = 0;
40313 }
40314
40315 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
40316 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
40317 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
40318 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
40319 - atomic_set(&oprofile_stats.multiplex_counter, 0);
40320 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
40321 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
40322 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
40323 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
40324 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
40325 }
40326
40327
40328 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
40329 index 38b6fc0..b5cbfce 100644
40330 --- a/drivers/oprofile/oprofile_stats.h
40331 +++ b/drivers/oprofile/oprofile_stats.h
40332 @@ -13,11 +13,11 @@
40333 #include <linux/atomic.h>
40334
40335 struct oprofile_stat_struct {
40336 - atomic_t sample_lost_no_mm;
40337 - atomic_t sample_lost_no_mapping;
40338 - atomic_t bt_lost_no_mapping;
40339 - atomic_t event_lost_overflow;
40340 - atomic_t multiplex_counter;
40341 + atomic_unchecked_t sample_lost_no_mm;
40342 + atomic_unchecked_t sample_lost_no_mapping;
40343 + atomic_unchecked_t bt_lost_no_mapping;
40344 + atomic_unchecked_t event_lost_overflow;
40345 + atomic_unchecked_t multiplex_counter;
40346 };
40347
40348 extern struct oprofile_stat_struct oprofile_stats;
40349 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
40350 index 7c12d9c..558bf3bb 100644
40351 --- a/drivers/oprofile/oprofilefs.c
40352 +++ b/drivers/oprofile/oprofilefs.c
40353 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
40354
40355
40356 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
40357 - char const *name, atomic_t *val)
40358 + char const *name, atomic_unchecked_t *val)
40359 {
40360 return __oprofilefs_create_file(sb, root, name,
40361 &atomic_ro_fops, 0444, val);
40362 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
40363 index 93404f7..4a313d8 100644
40364 --- a/drivers/oprofile/timer_int.c
40365 +++ b/drivers/oprofile/timer_int.c
40366 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
40367 return NOTIFY_OK;
40368 }
40369
40370 -static struct notifier_block __refdata oprofile_cpu_notifier = {
40371 +static struct notifier_block oprofile_cpu_notifier = {
40372 .notifier_call = oprofile_cpu_notify,
40373 };
40374
40375 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
40376 index 3f56bc0..707d642 100644
40377 --- a/drivers/parport/procfs.c
40378 +++ b/drivers/parport/procfs.c
40379 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
40380
40381 *ppos += len;
40382
40383 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
40384 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
40385 }
40386
40387 #ifdef CONFIG_PARPORT_1284
40388 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
40389
40390 *ppos += len;
40391
40392 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
40393 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
40394 }
40395 #endif /* IEEE1284.3 support. */
40396
40397 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
40398 index c35e8ad..fc33beb 100644
40399 --- a/drivers/pci/hotplug/acpiphp_ibm.c
40400 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
40401 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
40402 goto init_cleanup;
40403 }
40404
40405 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
40406 + pax_open_kernel();
40407 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
40408 + pax_close_kernel();
40409 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
40410
40411 return retval;
40412 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
40413 index a6a71c4..c91097b 100644
40414 --- a/drivers/pci/hotplug/cpcihp_generic.c
40415 +++ b/drivers/pci/hotplug/cpcihp_generic.c
40416 @@ -73,7 +73,6 @@ static u16 port;
40417 static unsigned int enum_bit;
40418 static u8 enum_mask;
40419
40420 -static struct cpci_hp_controller_ops generic_hpc_ops;
40421 static struct cpci_hp_controller generic_hpc;
40422
40423 static int __init validate_parameters(void)
40424 @@ -139,6 +138,10 @@ static int query_enum(void)
40425 return ((value & enum_mask) == enum_mask);
40426 }
40427
40428 +static struct cpci_hp_controller_ops generic_hpc_ops = {
40429 + .query_enum = query_enum,
40430 +};
40431 +
40432 static int __init cpcihp_generic_init(void)
40433 {
40434 int status;
40435 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
40436 pci_dev_put(dev);
40437
40438 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
40439 - generic_hpc_ops.query_enum = query_enum;
40440 generic_hpc.ops = &generic_hpc_ops;
40441
40442 status = cpci_hp_register_controller(&generic_hpc);
40443 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
40444 index 449b4bb..257e2e8 100644
40445 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
40446 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
40447 @@ -59,7 +59,6 @@
40448 /* local variables */
40449 static bool debug;
40450 static bool poll;
40451 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
40452 static struct cpci_hp_controller zt5550_hpc;
40453
40454 /* Primary cPCI bus bridge device */
40455 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
40456 return 0;
40457 }
40458
40459 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
40460 + .query_enum = zt5550_hc_query_enum,
40461 +};
40462 +
40463 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
40464 {
40465 int status;
40466 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
40467 dbg("returned from zt5550_hc_config");
40468
40469 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
40470 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
40471 zt5550_hpc.ops = &zt5550_hpc_ops;
40472 if(!poll) {
40473 zt5550_hpc.irq = hc_dev->irq;
40474 zt5550_hpc.irq_flags = IRQF_SHARED;
40475 zt5550_hpc.dev_id = hc_dev;
40476
40477 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
40478 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
40479 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
40480 + pax_open_kernel();
40481 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
40482 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
40483 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
40484 + pax_open_kernel();
40485 } else {
40486 info("using ENUM# polling mode");
40487 }
40488 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
40489 index 76ba8a1..20ca857 100644
40490 --- a/drivers/pci/hotplug/cpqphp_nvram.c
40491 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
40492 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
40493
40494 void compaq_nvram_init (void __iomem *rom_start)
40495 {
40496 +
40497 +#ifndef CONFIG_PAX_KERNEXEC
40498 if (rom_start) {
40499 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
40500 }
40501 +#endif
40502 +
40503 dbg("int15 entry = %p\n", compaq_int15_entry_point);
40504
40505 /* initialize our int15 lock */
40506 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
40507 index 202f4a9..8ee47d0 100644
40508 --- a/drivers/pci/hotplug/pci_hotplug_core.c
40509 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
40510 @@ -448,8 +448,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
40511 return -EINVAL;
40512 }
40513
40514 - slot->ops->owner = owner;
40515 - slot->ops->mod_name = mod_name;
40516 + pax_open_kernel();
40517 + *(struct module **)&slot->ops->owner = owner;
40518 + *(const char **)&slot->ops->mod_name = mod_name;
40519 + pax_close_kernel();
40520
40521 mutex_lock(&pci_hp_mutex);
40522 /*
40523 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
40524 index 7d72c5e..edce02c 100644
40525 --- a/drivers/pci/hotplug/pciehp_core.c
40526 +++ b/drivers/pci/hotplug/pciehp_core.c
40527 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
40528 struct slot *slot = ctrl->slot;
40529 struct hotplug_slot *hotplug = NULL;
40530 struct hotplug_slot_info *info = NULL;
40531 - struct hotplug_slot_ops *ops = NULL;
40532 + hotplug_slot_ops_no_const *ops = NULL;
40533 char name[SLOT_NAME_SIZE];
40534 int retval = -ENOMEM;
40535
40536 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
40537 index 9c6e9bb..2916736 100644
40538 --- a/drivers/pci/pci-sysfs.c
40539 +++ b/drivers/pci/pci-sysfs.c
40540 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
40541 {
40542 /* allocate attribute structure, piggyback attribute name */
40543 int name_len = write_combine ? 13 : 10;
40544 - struct bin_attribute *res_attr;
40545 + bin_attribute_no_const *res_attr;
40546 int retval;
40547
40548 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
40549 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
40550 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
40551 {
40552 int retval;
40553 - struct bin_attribute *attr;
40554 + bin_attribute_no_const *attr;
40555
40556 /* If the device has VPD, try to expose it in sysfs. */
40557 if (dev->vpd) {
40558 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
40559 {
40560 int retval;
40561 int rom_size = 0;
40562 - struct bin_attribute *attr;
40563 + bin_attribute_no_const *attr;
40564
40565 if (!sysfs_initialized)
40566 return -EACCES;
40567 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
40568 index 7346ee6..41520eb 100644
40569 --- a/drivers/pci/pci.h
40570 +++ b/drivers/pci/pci.h
40571 @@ -93,7 +93,7 @@ struct pci_vpd_ops {
40572 struct pci_vpd {
40573 unsigned int len;
40574 const struct pci_vpd_ops *ops;
40575 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
40576 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
40577 };
40578
40579 extern int pci_vpd_pci22_init(struct pci_dev *dev);
40580 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
40581 index d320df6..ca9a8f6 100644
40582 --- a/drivers/pci/pcie/aspm.c
40583 +++ b/drivers/pci/pcie/aspm.c
40584 @@ -27,9 +27,9 @@
40585 #define MODULE_PARAM_PREFIX "pcie_aspm."
40586
40587 /* Note: those are not register definitions */
40588 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
40589 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
40590 -#define ASPM_STATE_L1 (4) /* L1 state */
40591 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
40592 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
40593 +#define ASPM_STATE_L1 (4U) /* L1 state */
40594 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
40595 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
40596
40597 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
40598 index 5427787..8df273b 100644
40599 --- a/drivers/pci/probe.c
40600 +++ b/drivers/pci/probe.c
40601 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
40602 struct pci_bus_region region;
40603 bool bar_too_big = false, bar_disabled = false;
40604
40605 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
40606 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
40607
40608 /* No printks while decoding is disabled! */
40609 if (!dev->mmio_always_on) {
40610 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
40611 index 0b00947..64f7c0a 100644
40612 --- a/drivers/pci/proc.c
40613 +++ b/drivers/pci/proc.c
40614 @@ -465,7 +465,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
40615 static int __init pci_proc_init(void)
40616 {
40617 struct pci_dev *dev = NULL;
40618 +
40619 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
40620 +#ifdef CONFIG_GRKERNSEC_PROC_USER
40621 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
40622 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
40623 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
40624 +#endif
40625 +#else
40626 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
40627 +#endif
40628 proc_create("devices", 0, proc_bus_pci_dir,
40629 &proc_bus_pci_dev_operations);
40630 proc_initialized = 1;
40631 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
40632 index 6b22938..bc9700e 100644
40633 --- a/drivers/platform/x86/msi-laptop.c
40634 +++ b/drivers/platform/x86/msi-laptop.c
40635 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
40636
40637 if (!quirks->ec_read_only) {
40638 /* allow userland write sysfs file */
40639 - dev_attr_bluetooth.store = store_bluetooth;
40640 - dev_attr_wlan.store = store_wlan;
40641 - dev_attr_threeg.store = store_threeg;
40642 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
40643 - dev_attr_wlan.attr.mode |= S_IWUSR;
40644 - dev_attr_threeg.attr.mode |= S_IWUSR;
40645 + pax_open_kernel();
40646 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
40647 + *(void **)&dev_attr_wlan.store = store_wlan;
40648 + *(void **)&dev_attr_threeg.store = store_threeg;
40649 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
40650 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
40651 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
40652 + pax_close_kernel();
40653 }
40654
40655 /* disable hardware control by fn key */
40656 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
40657 index 14d4dce..b129917 100644
40658 --- a/drivers/platform/x86/sony-laptop.c
40659 +++ b/drivers/platform/x86/sony-laptop.c
40660 @@ -2465,7 +2465,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
40661 }
40662
40663 /* High speed charging function */
40664 -static struct device_attribute *hsc_handle;
40665 +static device_attribute_no_const *hsc_handle;
40666
40667 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
40668 struct device_attribute *attr,
40669 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
40670 index edec135..59a24a3 100644
40671 --- a/drivers/platform/x86/thinkpad_acpi.c
40672 +++ b/drivers/platform/x86/thinkpad_acpi.c
40673 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
40674 return 0;
40675 }
40676
40677 -void static hotkey_mask_warn_incomplete_mask(void)
40678 +static void hotkey_mask_warn_incomplete_mask(void)
40679 {
40680 /* log only what the user can fix... */
40681 const u32 wantedmask = hotkey_driver_mask &
40682 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
40683 }
40684 }
40685
40686 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40687 - struct tp_nvram_state *newn,
40688 - const u32 event_mask)
40689 -{
40690 -
40691 #define TPACPI_COMPARE_KEY(__scancode, __member) \
40692 do { \
40693 if ((event_mask & (1 << __scancode)) && \
40694 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40695 tpacpi_hotkey_send_key(__scancode); \
40696 } while (0)
40697
40698 - void issue_volchange(const unsigned int oldvol,
40699 - const unsigned int newvol)
40700 - {
40701 - unsigned int i = oldvol;
40702 +static void issue_volchange(const unsigned int oldvol,
40703 + const unsigned int newvol,
40704 + const u32 event_mask)
40705 +{
40706 + unsigned int i = oldvol;
40707
40708 - while (i > newvol) {
40709 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
40710 - i--;
40711 - }
40712 - while (i < newvol) {
40713 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
40714 - i++;
40715 - }
40716 + while (i > newvol) {
40717 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
40718 + i--;
40719 }
40720 + while (i < newvol) {
40721 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
40722 + i++;
40723 + }
40724 +}
40725
40726 - void issue_brightnesschange(const unsigned int oldbrt,
40727 - const unsigned int newbrt)
40728 - {
40729 - unsigned int i = oldbrt;
40730 +static void issue_brightnesschange(const unsigned int oldbrt,
40731 + const unsigned int newbrt,
40732 + const u32 event_mask)
40733 +{
40734 + unsigned int i = oldbrt;
40735
40736 - while (i > newbrt) {
40737 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
40738 - i--;
40739 - }
40740 - while (i < newbrt) {
40741 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
40742 - i++;
40743 - }
40744 + while (i > newbrt) {
40745 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
40746 + i--;
40747 + }
40748 + while (i < newbrt) {
40749 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
40750 + i++;
40751 }
40752 +}
40753
40754 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40755 + struct tp_nvram_state *newn,
40756 + const u32 event_mask)
40757 +{
40758 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
40759 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
40760 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
40761 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40762 oldn->volume_level != newn->volume_level) {
40763 /* recently muted, or repeated mute keypress, or
40764 * multiple presses ending in mute */
40765 - issue_volchange(oldn->volume_level, newn->volume_level);
40766 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
40767 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
40768 }
40769 } else {
40770 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40771 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
40772 }
40773 if (oldn->volume_level != newn->volume_level) {
40774 - issue_volchange(oldn->volume_level, newn->volume_level);
40775 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
40776 } else if (oldn->volume_toggle != newn->volume_toggle) {
40777 /* repeated vol up/down keypress at end of scale ? */
40778 if (newn->volume_level == 0)
40779 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40780 /* handle brightness */
40781 if (oldn->brightness_level != newn->brightness_level) {
40782 issue_brightnesschange(oldn->brightness_level,
40783 - newn->brightness_level);
40784 + newn->brightness_level,
40785 + event_mask);
40786 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
40787 /* repeated key presses that didn't change state */
40788 if (newn->brightness_level == 0)
40789 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
40790 && !tp_features.bright_unkfw)
40791 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
40792 }
40793 +}
40794
40795 #undef TPACPI_COMPARE_KEY
40796 #undef TPACPI_MAY_SEND_KEY
40797 -}
40798
40799 /*
40800 * Polling driver
40801 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
40802 index 769d265..a3a05ca 100644
40803 --- a/drivers/pnp/pnpbios/bioscalls.c
40804 +++ b/drivers/pnp/pnpbios/bioscalls.c
40805 @@ -58,7 +58,7 @@ do { \
40806 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
40807 } while(0)
40808
40809 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
40810 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
40811 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
40812
40813 /*
40814 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
40815
40816 cpu = get_cpu();
40817 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
40818 +
40819 + pax_open_kernel();
40820 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
40821 + pax_close_kernel();
40822
40823 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
40824 spin_lock_irqsave(&pnp_bios_lock, flags);
40825 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
40826 :"memory");
40827 spin_unlock_irqrestore(&pnp_bios_lock, flags);
40828
40829 + pax_open_kernel();
40830 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
40831 + pax_close_kernel();
40832 +
40833 put_cpu();
40834
40835 /* If we get here and this is set then the PnP BIOS faulted on us. */
40836 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
40837 return status;
40838 }
40839
40840 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
40841 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
40842 {
40843 int i;
40844
40845 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
40846 pnp_bios_callpoint.offset = header->fields.pm16offset;
40847 pnp_bios_callpoint.segment = PNP_CS16;
40848
40849 + pax_open_kernel();
40850 +
40851 for_each_possible_cpu(i) {
40852 struct desc_struct *gdt = get_cpu_gdt_table(i);
40853 if (!gdt)
40854 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
40855 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
40856 (unsigned long)__va(header->fields.pm16dseg));
40857 }
40858 +
40859 + pax_close_kernel();
40860 }
40861 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
40862 index 3e6db1c..1fbbdae 100644
40863 --- a/drivers/pnp/resource.c
40864 +++ b/drivers/pnp/resource.c
40865 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
40866 return 1;
40867
40868 /* check if the resource is valid */
40869 - if (*irq < 0 || *irq > 15)
40870 + if (*irq > 15)
40871 return 0;
40872
40873 /* check if the resource is reserved */
40874 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
40875 return 1;
40876
40877 /* check if the resource is valid */
40878 - if (*dma < 0 || *dma == 4 || *dma > 7)
40879 + if (*dma == 4 || *dma > 7)
40880 return 0;
40881
40882 /* check if the resource is reserved */
40883 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
40884 index 7df7c5f..bd48c47 100644
40885 --- a/drivers/power/pda_power.c
40886 +++ b/drivers/power/pda_power.c
40887 @@ -37,7 +37,11 @@ static int polling;
40888
40889 #ifdef CONFIG_USB_OTG_UTILS
40890 static struct usb_phy *transceiver;
40891 -static struct notifier_block otg_nb;
40892 +static int otg_handle_notification(struct notifier_block *nb,
40893 + unsigned long event, void *unused);
40894 +static struct notifier_block otg_nb = {
40895 + .notifier_call = otg_handle_notification
40896 +};
40897 #endif
40898
40899 static struct regulator *ac_draw;
40900 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
40901
40902 #ifdef CONFIG_USB_OTG_UTILS
40903 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
40904 - otg_nb.notifier_call = otg_handle_notification;
40905 ret = usb_register_notifier(transceiver, &otg_nb);
40906 if (ret) {
40907 dev_err(dev, "failure to register otg notifier\n");
40908 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
40909 index cc439fd..8fa30df 100644
40910 --- a/drivers/power/power_supply.h
40911 +++ b/drivers/power/power_supply.h
40912 @@ -16,12 +16,12 @@ struct power_supply;
40913
40914 #ifdef CONFIG_SYSFS
40915
40916 -extern void power_supply_init_attrs(struct device_type *dev_type);
40917 +extern void power_supply_init_attrs(void);
40918 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
40919
40920 #else
40921
40922 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
40923 +static inline void power_supply_init_attrs(void) {}
40924 #define power_supply_uevent NULL
40925
40926 #endif /* CONFIG_SYSFS */
40927 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
40928 index 5deac43..608c5ff 100644
40929 --- a/drivers/power/power_supply_core.c
40930 +++ b/drivers/power/power_supply_core.c
40931 @@ -24,7 +24,10 @@
40932 struct class *power_supply_class;
40933 EXPORT_SYMBOL_GPL(power_supply_class);
40934
40935 -static struct device_type power_supply_dev_type;
40936 +extern const struct attribute_group *power_supply_attr_groups[];
40937 +static struct device_type power_supply_dev_type = {
40938 + .groups = power_supply_attr_groups,
40939 +};
40940
40941 static int __power_supply_changed_work(struct device *dev, void *data)
40942 {
40943 @@ -393,7 +396,7 @@ static int __init power_supply_class_init(void)
40944 return PTR_ERR(power_supply_class);
40945
40946 power_supply_class->dev_uevent = power_supply_uevent;
40947 - power_supply_init_attrs(&power_supply_dev_type);
40948 + power_supply_init_attrs();
40949
40950 return 0;
40951 }
40952 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
40953 index 29178f7..c65f324 100644
40954 --- a/drivers/power/power_supply_sysfs.c
40955 +++ b/drivers/power/power_supply_sysfs.c
40956 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
40957 .is_visible = power_supply_attr_is_visible,
40958 };
40959
40960 -static const struct attribute_group *power_supply_attr_groups[] = {
40961 +const struct attribute_group *power_supply_attr_groups[] = {
40962 &power_supply_attr_group,
40963 NULL,
40964 };
40965
40966 -void power_supply_init_attrs(struct device_type *dev_type)
40967 +void power_supply_init_attrs(void)
40968 {
40969 int i;
40970
40971 - dev_type->groups = power_supply_attr_groups;
40972 -
40973 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
40974 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
40975 }
40976 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
40977 index 4d7c635..9860196 100644
40978 --- a/drivers/regulator/max8660.c
40979 +++ b/drivers/regulator/max8660.c
40980 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
40981 max8660->shadow_regs[MAX8660_OVER1] = 5;
40982 } else {
40983 /* Otherwise devices can be toggled via software */
40984 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
40985 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
40986 + pax_open_kernel();
40987 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
40988 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
40989 + pax_close_kernel();
40990 }
40991
40992 /*
40993 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
40994 index 9a8ea91..c483dd9 100644
40995 --- a/drivers/regulator/max8973-regulator.c
40996 +++ b/drivers/regulator/max8973-regulator.c
40997 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
40998 if (!pdata->enable_ext_control) {
40999 max->desc.enable_reg = MAX8973_VOUT;
41000 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
41001 - max8973_dcdc_ops.enable = regulator_enable_regmap;
41002 - max8973_dcdc_ops.disable = regulator_disable_regmap;
41003 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41004 + pax_open_kernel();
41005 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
41006 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
41007 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41008 + pax_close_kernel();
41009 }
41010
41011 max->enable_external_control = pdata->enable_ext_control;
41012 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
41013 index 9891aec..beb3083 100644
41014 --- a/drivers/regulator/mc13892-regulator.c
41015 +++ b/drivers/regulator/mc13892-regulator.c
41016 @@ -583,10 +583,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
41017 }
41018 mc13xxx_unlock(mc13892);
41019
41020 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41021 + pax_open_kernel();
41022 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41023 = mc13892_vcam_set_mode;
41024 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41025 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41026 = mc13892_vcam_get_mode;
41027 + pax_close_kernel();
41028
41029 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
41030 ARRAY_SIZE(mc13892_regulators),
41031 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
41032 index cc5bea9..689f7d9 100644
41033 --- a/drivers/rtc/rtc-cmos.c
41034 +++ b/drivers/rtc/rtc-cmos.c
41035 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
41036 hpet_rtc_timer_init();
41037
41038 /* export at least the first block of NVRAM */
41039 - nvram.size = address_space - NVRAM_OFFSET;
41040 + pax_open_kernel();
41041 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
41042 + pax_close_kernel();
41043 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
41044 if (retval < 0) {
41045 dev_dbg(dev, "can't create nvram file? %d\n", retval);
41046 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
41047 index d049393..bb20be0 100644
41048 --- a/drivers/rtc/rtc-dev.c
41049 +++ b/drivers/rtc/rtc-dev.c
41050 @@ -16,6 +16,7 @@
41051 #include <linux/module.h>
41052 #include <linux/rtc.h>
41053 #include <linux/sched.h>
41054 +#include <linux/grsecurity.h>
41055 #include "rtc-core.h"
41056
41057 static dev_t rtc_devt;
41058 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
41059 if (copy_from_user(&tm, uarg, sizeof(tm)))
41060 return -EFAULT;
41061
41062 + gr_log_timechange();
41063 +
41064 return rtc_set_time(rtc, &tm);
41065
41066 case RTC_PIE_ON:
41067 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
41068 index 970a236..3613169 100644
41069 --- a/drivers/rtc/rtc-ds1307.c
41070 +++ b/drivers/rtc/rtc-ds1307.c
41071 @@ -106,7 +106,7 @@ struct ds1307 {
41072 u8 offset; /* register's offset */
41073 u8 regs[11];
41074 u16 nvram_offset;
41075 - struct bin_attribute *nvram;
41076 + bin_attribute_no_const *nvram;
41077 enum ds_type type;
41078 unsigned long flags;
41079 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
41080 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
41081 index 130f29a..6179d03 100644
41082 --- a/drivers/rtc/rtc-m48t59.c
41083 +++ b/drivers/rtc/rtc-m48t59.c
41084 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
41085 goto out;
41086 }
41087
41088 - m48t59_nvram_attr.size = pdata->offset;
41089 + pax_open_kernel();
41090 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
41091 + pax_close_kernel();
41092
41093 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
41094 if (ret) {
41095 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
41096 index e693af6..2e525b6 100644
41097 --- a/drivers/scsi/bfa/bfa_fcpim.h
41098 +++ b/drivers/scsi/bfa/bfa_fcpim.h
41099 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
41100
41101 struct bfa_itn_s {
41102 bfa_isr_func_t isr;
41103 -};
41104 +} __no_const;
41105
41106 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
41107 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
41108 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
41109 index 23a90e7..9cf04ee 100644
41110 --- a/drivers/scsi/bfa/bfa_ioc.h
41111 +++ b/drivers/scsi/bfa/bfa_ioc.h
41112 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
41113 bfa_ioc_disable_cbfn_t disable_cbfn;
41114 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
41115 bfa_ioc_reset_cbfn_t reset_cbfn;
41116 -};
41117 +} __no_const;
41118
41119 /*
41120 * IOC event notification mechanism.
41121 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
41122 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
41123 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
41124 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
41125 -};
41126 +} __no_const;
41127
41128 /*
41129 * Queue element to wait for room in request queue. FIFO order is
41130 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
41131 index df0c3c7..b00e1d0 100644
41132 --- a/drivers/scsi/hosts.c
41133 +++ b/drivers/scsi/hosts.c
41134 @@ -42,7 +42,7 @@
41135 #include "scsi_logging.h"
41136
41137
41138 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41139 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41140
41141
41142 static void scsi_host_cls_release(struct device *dev)
41143 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
41144 * subtract one because we increment first then return, but we need to
41145 * know what the next host number was before increment
41146 */
41147 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
41148 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
41149 shost->dma_channel = 0xff;
41150
41151 /* These three are default values which can be overridden */
41152 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
41153 index 7f4f790..b75b92a 100644
41154 --- a/drivers/scsi/hpsa.c
41155 +++ b/drivers/scsi/hpsa.c
41156 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
41157 unsigned long flags;
41158
41159 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
41160 - return h->access.command_completed(h, q);
41161 + return h->access->command_completed(h, q);
41162
41163 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
41164 a = rq->head[rq->current_entry];
41165 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
41166 while (!list_empty(&h->reqQ)) {
41167 c = list_entry(h->reqQ.next, struct CommandList, list);
41168 /* can't do anything if fifo is full */
41169 - if ((h->access.fifo_full(h))) {
41170 + if ((h->access->fifo_full(h))) {
41171 dev_warn(&h->pdev->dev, "fifo full\n");
41172 break;
41173 }
41174 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
41175
41176 /* Tell the controller execute command */
41177 spin_unlock_irqrestore(&h->lock, flags);
41178 - h->access.submit_command(h, c);
41179 + h->access->submit_command(h, c);
41180 spin_lock_irqsave(&h->lock, flags);
41181 }
41182 spin_unlock_irqrestore(&h->lock, flags);
41183 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
41184
41185 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
41186 {
41187 - return h->access.command_completed(h, q);
41188 + return h->access->command_completed(h, q);
41189 }
41190
41191 static inline bool interrupt_pending(struct ctlr_info *h)
41192 {
41193 - return h->access.intr_pending(h);
41194 + return h->access->intr_pending(h);
41195 }
41196
41197 static inline long interrupt_not_for_us(struct ctlr_info *h)
41198 {
41199 - return (h->access.intr_pending(h) == 0) ||
41200 + return (h->access->intr_pending(h) == 0) ||
41201 (h->interrupts_enabled == 0);
41202 }
41203
41204 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
41205 if (prod_index < 0)
41206 return -ENODEV;
41207 h->product_name = products[prod_index].product_name;
41208 - h->access = *(products[prod_index].access);
41209 + h->access = products[prod_index].access;
41210
41211 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
41212 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
41213 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
41214
41215 assert_spin_locked(&lockup_detector_lock);
41216 remove_ctlr_from_lockup_detector_list(h);
41217 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41218 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41219 spin_lock_irqsave(&h->lock, flags);
41220 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
41221 spin_unlock_irqrestore(&h->lock, flags);
41222 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
41223 }
41224
41225 /* make sure the board interrupts are off */
41226 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41227 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41228
41229 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
41230 goto clean2;
41231 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
41232 * fake ones to scoop up any residual completions.
41233 */
41234 spin_lock_irqsave(&h->lock, flags);
41235 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41236 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41237 spin_unlock_irqrestore(&h->lock, flags);
41238 free_irqs(h);
41239 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
41240 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
41241 dev_info(&h->pdev->dev, "Board READY.\n");
41242 dev_info(&h->pdev->dev,
41243 "Waiting for stale completions to drain.\n");
41244 - h->access.set_intr_mask(h, HPSA_INTR_ON);
41245 + h->access->set_intr_mask(h, HPSA_INTR_ON);
41246 msleep(10000);
41247 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41248 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41249
41250 rc = controller_reset_failed(h->cfgtable);
41251 if (rc)
41252 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
41253 }
41254
41255 /* Turn the interrupts on so we can service requests */
41256 - h->access.set_intr_mask(h, HPSA_INTR_ON);
41257 + h->access->set_intr_mask(h, HPSA_INTR_ON);
41258
41259 hpsa_hba_inquiry(h);
41260 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
41261 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
41262 * To write all data in the battery backed cache to disks
41263 */
41264 hpsa_flush_cache(h);
41265 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41266 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41267 hpsa_free_irqs_and_disable_msix(h);
41268 }
41269
41270 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
41271 return;
41272 }
41273 /* Change the access methods to the performant access methods */
41274 - h->access = SA5_performant_access;
41275 + h->access = &SA5_performant_access;
41276 h->transMethod = CFGTBL_Trans_Performant;
41277 }
41278
41279 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
41280 index 9816479..c5d4e97 100644
41281 --- a/drivers/scsi/hpsa.h
41282 +++ b/drivers/scsi/hpsa.h
41283 @@ -79,7 +79,7 @@ struct ctlr_info {
41284 unsigned int msix_vector;
41285 unsigned int msi_vector;
41286 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
41287 - struct access_method access;
41288 + struct access_method *access;
41289
41290 /* queue and queue Info */
41291 struct list_head reqQ;
41292 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
41293 index c772d8d..35c362c 100644
41294 --- a/drivers/scsi/libfc/fc_exch.c
41295 +++ b/drivers/scsi/libfc/fc_exch.c
41296 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
41297 u16 pool_max_index;
41298
41299 struct {
41300 - atomic_t no_free_exch;
41301 - atomic_t no_free_exch_xid;
41302 - atomic_t xid_not_found;
41303 - atomic_t xid_busy;
41304 - atomic_t seq_not_found;
41305 - atomic_t non_bls_resp;
41306 + atomic_unchecked_t no_free_exch;
41307 + atomic_unchecked_t no_free_exch_xid;
41308 + atomic_unchecked_t xid_not_found;
41309 + atomic_unchecked_t xid_busy;
41310 + atomic_unchecked_t seq_not_found;
41311 + atomic_unchecked_t non_bls_resp;
41312 } stats;
41313 };
41314
41315 @@ -725,7 +725,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
41316 /* allocate memory for exchange */
41317 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
41318 if (!ep) {
41319 - atomic_inc(&mp->stats.no_free_exch);
41320 + atomic_inc_unchecked(&mp->stats.no_free_exch);
41321 goto out;
41322 }
41323 memset(ep, 0, sizeof(*ep));
41324 @@ -786,7 +786,7 @@ out:
41325 return ep;
41326 err:
41327 spin_unlock_bh(&pool->lock);
41328 - atomic_inc(&mp->stats.no_free_exch_xid);
41329 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
41330 mempool_free(ep, mp->ep_pool);
41331 return NULL;
41332 }
41333 @@ -929,7 +929,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41334 xid = ntohs(fh->fh_ox_id); /* we originated exch */
41335 ep = fc_exch_find(mp, xid);
41336 if (!ep) {
41337 - atomic_inc(&mp->stats.xid_not_found);
41338 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41339 reject = FC_RJT_OX_ID;
41340 goto out;
41341 }
41342 @@ -959,7 +959,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41343 ep = fc_exch_find(mp, xid);
41344 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
41345 if (ep) {
41346 - atomic_inc(&mp->stats.xid_busy);
41347 + atomic_inc_unchecked(&mp->stats.xid_busy);
41348 reject = FC_RJT_RX_ID;
41349 goto rel;
41350 }
41351 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41352 }
41353 xid = ep->xid; /* get our XID */
41354 } else if (!ep) {
41355 - atomic_inc(&mp->stats.xid_not_found);
41356 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41357 reject = FC_RJT_RX_ID; /* XID not found */
41358 goto out;
41359 }
41360 @@ -987,7 +987,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41361 } else {
41362 sp = &ep->seq;
41363 if (sp->id != fh->fh_seq_id) {
41364 - atomic_inc(&mp->stats.seq_not_found);
41365 + atomic_inc_unchecked(&mp->stats.seq_not_found);
41366 if (f_ctl & FC_FC_END_SEQ) {
41367 /*
41368 * Update sequence_id based on incoming last
41369 @@ -1437,22 +1437,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41370
41371 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
41372 if (!ep) {
41373 - atomic_inc(&mp->stats.xid_not_found);
41374 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41375 goto out;
41376 }
41377 if (ep->esb_stat & ESB_ST_COMPLETE) {
41378 - atomic_inc(&mp->stats.xid_not_found);
41379 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41380 goto rel;
41381 }
41382 if (ep->rxid == FC_XID_UNKNOWN)
41383 ep->rxid = ntohs(fh->fh_rx_id);
41384 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
41385 - atomic_inc(&mp->stats.xid_not_found);
41386 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41387 goto rel;
41388 }
41389 if (ep->did != ntoh24(fh->fh_s_id) &&
41390 ep->did != FC_FID_FLOGI) {
41391 - atomic_inc(&mp->stats.xid_not_found);
41392 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41393 goto rel;
41394 }
41395 sof = fr_sof(fp);
41396 @@ -1461,7 +1461,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41397 sp->ssb_stat |= SSB_ST_RESP;
41398 sp->id = fh->fh_seq_id;
41399 } else if (sp->id != fh->fh_seq_id) {
41400 - atomic_inc(&mp->stats.seq_not_found);
41401 + atomic_inc_unchecked(&mp->stats.seq_not_found);
41402 goto rel;
41403 }
41404
41405 @@ -1525,9 +1525,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41406 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
41407
41408 if (!sp)
41409 - atomic_inc(&mp->stats.xid_not_found);
41410 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41411 else
41412 - atomic_inc(&mp->stats.non_bls_resp);
41413 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
41414
41415 fc_frame_free(fp);
41416 }
41417 @@ -2174,13 +2174,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
41418
41419 list_for_each_entry(ema, &lport->ema_list, ema_list) {
41420 mp = ema->mp;
41421 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
41422 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
41423 st->fc_no_free_exch_xid +=
41424 - atomic_read(&mp->stats.no_free_exch_xid);
41425 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
41426 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
41427 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
41428 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
41429 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
41430 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
41431 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
41432 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
41433 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
41434 }
41435 }
41436 EXPORT_SYMBOL(fc_exch_update_stats);
41437 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
41438 index bdb81cd..d3c7c2c 100644
41439 --- a/drivers/scsi/libsas/sas_ata.c
41440 +++ b/drivers/scsi/libsas/sas_ata.c
41441 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
41442 .postreset = ata_std_postreset,
41443 .error_handler = ata_std_error_handler,
41444 .post_internal_cmd = sas_ata_post_internal,
41445 - .qc_defer = ata_std_qc_defer,
41446 + .qc_defer = ata_std_qc_defer,
41447 .qc_prep = ata_noop_qc_prep,
41448 .qc_issue = sas_ata_qc_issue,
41449 .qc_fill_rtf = sas_ata_qc_fill_rtf,
41450 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
41451 index 7706c99..3b4fc0c 100644
41452 --- a/drivers/scsi/lpfc/lpfc.h
41453 +++ b/drivers/scsi/lpfc/lpfc.h
41454 @@ -424,7 +424,7 @@ struct lpfc_vport {
41455 struct dentry *debug_nodelist;
41456 struct dentry *vport_debugfs_root;
41457 struct lpfc_debugfs_trc *disc_trc;
41458 - atomic_t disc_trc_cnt;
41459 + atomic_unchecked_t disc_trc_cnt;
41460 #endif
41461 uint8_t stat_data_enabled;
41462 uint8_t stat_data_blocked;
41463 @@ -853,8 +853,8 @@ struct lpfc_hba {
41464 struct timer_list fabric_block_timer;
41465 unsigned long bit_flags;
41466 #define FABRIC_COMANDS_BLOCKED 0
41467 - atomic_t num_rsrc_err;
41468 - atomic_t num_cmd_success;
41469 + atomic_unchecked_t num_rsrc_err;
41470 + atomic_unchecked_t num_cmd_success;
41471 unsigned long last_rsrc_error_time;
41472 unsigned long last_ramp_down_time;
41473 unsigned long last_ramp_up_time;
41474 @@ -890,7 +890,7 @@ struct lpfc_hba {
41475
41476 struct dentry *debug_slow_ring_trc;
41477 struct lpfc_debugfs_trc *slow_ring_trc;
41478 - atomic_t slow_ring_trc_cnt;
41479 + atomic_unchecked_t slow_ring_trc_cnt;
41480 /* iDiag debugfs sub-directory */
41481 struct dentry *idiag_root;
41482 struct dentry *idiag_pci_cfg;
41483 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
41484 index f63f5ff..de29189 100644
41485 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
41486 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
41487 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
41488
41489 #include <linux/debugfs.h>
41490
41491 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
41492 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
41493 static unsigned long lpfc_debugfs_start_time = 0L;
41494
41495 /* iDiag */
41496 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
41497 lpfc_debugfs_enable = 0;
41498
41499 len = 0;
41500 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
41501 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
41502 (lpfc_debugfs_max_disc_trc - 1);
41503 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
41504 dtp = vport->disc_trc + i;
41505 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
41506 lpfc_debugfs_enable = 0;
41507
41508 len = 0;
41509 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
41510 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
41511 (lpfc_debugfs_max_slow_ring_trc - 1);
41512 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
41513 dtp = phba->slow_ring_trc + i;
41514 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
41515 !vport || !vport->disc_trc)
41516 return;
41517
41518 - index = atomic_inc_return(&vport->disc_trc_cnt) &
41519 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
41520 (lpfc_debugfs_max_disc_trc - 1);
41521 dtp = vport->disc_trc + index;
41522 dtp->fmt = fmt;
41523 dtp->data1 = data1;
41524 dtp->data2 = data2;
41525 dtp->data3 = data3;
41526 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
41527 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
41528 dtp->jif = jiffies;
41529 #endif
41530 return;
41531 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
41532 !phba || !phba->slow_ring_trc)
41533 return;
41534
41535 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
41536 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
41537 (lpfc_debugfs_max_slow_ring_trc - 1);
41538 dtp = phba->slow_ring_trc + index;
41539 dtp->fmt = fmt;
41540 dtp->data1 = data1;
41541 dtp->data2 = data2;
41542 dtp->data3 = data3;
41543 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
41544 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
41545 dtp->jif = jiffies;
41546 #endif
41547 return;
41548 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
41549 "slow_ring buffer\n");
41550 goto debug_failed;
41551 }
41552 - atomic_set(&phba->slow_ring_trc_cnt, 0);
41553 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
41554 memset(phba->slow_ring_trc, 0,
41555 (sizeof(struct lpfc_debugfs_trc) *
41556 lpfc_debugfs_max_slow_ring_trc));
41557 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
41558 "buffer\n");
41559 goto debug_failed;
41560 }
41561 - atomic_set(&vport->disc_trc_cnt, 0);
41562 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
41563
41564 snprintf(name, sizeof(name), "discovery_trace");
41565 vport->debug_disc_trc =
41566 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
41567 index 314b4f6..7005d10 100644
41568 --- a/drivers/scsi/lpfc/lpfc_init.c
41569 +++ b/drivers/scsi/lpfc/lpfc_init.c
41570 @@ -10551,8 +10551,10 @@ lpfc_init(void)
41571 "misc_register returned with status %d", error);
41572
41573 if (lpfc_enable_npiv) {
41574 - lpfc_transport_functions.vport_create = lpfc_vport_create;
41575 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
41576 + pax_open_kernel();
41577 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
41578 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
41579 + pax_close_kernel();
41580 }
41581 lpfc_transport_template =
41582 fc_attach_transport(&lpfc_transport_functions);
41583 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
41584 index 98af07c..7625fb5 100644
41585 --- a/drivers/scsi/lpfc/lpfc_scsi.c
41586 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
41587 @@ -325,7 +325,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
41588 uint32_t evt_posted;
41589
41590 spin_lock_irqsave(&phba->hbalock, flags);
41591 - atomic_inc(&phba->num_rsrc_err);
41592 + atomic_inc_unchecked(&phba->num_rsrc_err);
41593 phba->last_rsrc_error_time = jiffies;
41594
41595 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
41596 @@ -366,7 +366,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
41597 unsigned long flags;
41598 struct lpfc_hba *phba = vport->phba;
41599 uint32_t evt_posted;
41600 - atomic_inc(&phba->num_cmd_success);
41601 + atomic_inc_unchecked(&phba->num_cmd_success);
41602
41603 if (vport->cfg_lun_queue_depth <= queue_depth)
41604 return;
41605 @@ -410,8 +410,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
41606 unsigned long num_rsrc_err, num_cmd_success;
41607 int i;
41608
41609 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
41610 - num_cmd_success = atomic_read(&phba->num_cmd_success);
41611 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
41612 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
41613
41614 /*
41615 * The error and success command counters are global per
41616 @@ -439,8 +439,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
41617 }
41618 }
41619 lpfc_destroy_vport_work_array(phba, vports);
41620 - atomic_set(&phba->num_rsrc_err, 0);
41621 - atomic_set(&phba->num_cmd_success, 0);
41622 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
41623 + atomic_set_unchecked(&phba->num_cmd_success, 0);
41624 }
41625
41626 /**
41627 @@ -474,8 +474,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
41628 }
41629 }
41630 lpfc_destroy_vport_work_array(phba, vports);
41631 - atomic_set(&phba->num_rsrc_err, 0);
41632 - atomic_set(&phba->num_cmd_success, 0);
41633 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
41634 + atomic_set_unchecked(&phba->num_cmd_success, 0);
41635 }
41636
41637 /**
41638 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
41639 index b46f5e9..c4c4ccb 100644
41640 --- a/drivers/scsi/pmcraid.c
41641 +++ b/drivers/scsi/pmcraid.c
41642 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
41643 res->scsi_dev = scsi_dev;
41644 scsi_dev->hostdata = res;
41645 res->change_detected = 0;
41646 - atomic_set(&res->read_failures, 0);
41647 - atomic_set(&res->write_failures, 0);
41648 + atomic_set_unchecked(&res->read_failures, 0);
41649 + atomic_set_unchecked(&res->write_failures, 0);
41650 rc = 0;
41651 }
41652 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
41653 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
41654
41655 /* If this was a SCSI read/write command keep count of errors */
41656 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
41657 - atomic_inc(&res->read_failures);
41658 + atomic_inc_unchecked(&res->read_failures);
41659 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
41660 - atomic_inc(&res->write_failures);
41661 + atomic_inc_unchecked(&res->write_failures);
41662
41663 if (!RES_IS_GSCSI(res->cfg_entry) &&
41664 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
41665 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
41666 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
41667 * hrrq_id assigned here in queuecommand
41668 */
41669 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
41670 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
41671 pinstance->num_hrrq;
41672 cmd->cmd_done = pmcraid_io_done;
41673
41674 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
41675 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
41676 * hrrq_id assigned here in queuecommand
41677 */
41678 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
41679 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
41680 pinstance->num_hrrq;
41681
41682 if (request_size) {
41683 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
41684
41685 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
41686 /* add resources only after host is added into system */
41687 - if (!atomic_read(&pinstance->expose_resources))
41688 + if (!atomic_read_unchecked(&pinstance->expose_resources))
41689 return;
41690
41691 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
41692 @@ -5324,8 +5324,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
41693 init_waitqueue_head(&pinstance->reset_wait_q);
41694
41695 atomic_set(&pinstance->outstanding_cmds, 0);
41696 - atomic_set(&pinstance->last_message_id, 0);
41697 - atomic_set(&pinstance->expose_resources, 0);
41698 + atomic_set_unchecked(&pinstance->last_message_id, 0);
41699 + atomic_set_unchecked(&pinstance->expose_resources, 0);
41700
41701 INIT_LIST_HEAD(&pinstance->free_res_q);
41702 INIT_LIST_HEAD(&pinstance->used_res_q);
41703 @@ -6038,7 +6038,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
41704 /* Schedule worker thread to handle CCN and take care of adding and
41705 * removing devices to OS
41706 */
41707 - atomic_set(&pinstance->expose_resources, 1);
41708 + atomic_set_unchecked(&pinstance->expose_resources, 1);
41709 schedule_work(&pinstance->worker_q);
41710 return rc;
41711
41712 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
41713 index e1d150f..6c6df44 100644
41714 --- a/drivers/scsi/pmcraid.h
41715 +++ b/drivers/scsi/pmcraid.h
41716 @@ -748,7 +748,7 @@ struct pmcraid_instance {
41717 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
41718
41719 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
41720 - atomic_t last_message_id;
41721 + atomic_unchecked_t last_message_id;
41722
41723 /* configuration table */
41724 struct pmcraid_config_table *cfg_table;
41725 @@ -777,7 +777,7 @@ struct pmcraid_instance {
41726 atomic_t outstanding_cmds;
41727
41728 /* should add/delete resources to mid-layer now ?*/
41729 - atomic_t expose_resources;
41730 + atomic_unchecked_t expose_resources;
41731
41732
41733
41734 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
41735 struct pmcraid_config_table_entry_ext cfg_entry_ext;
41736 };
41737 struct scsi_device *scsi_dev; /* Link scsi_device structure */
41738 - atomic_t read_failures; /* count of failed READ commands */
41739 - atomic_t write_failures; /* count of failed WRITE commands */
41740 + atomic_unchecked_t read_failures; /* count of failed READ commands */
41741 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
41742
41743 /* To indicate add/delete/modify during CCN */
41744 u8 change_detected;
41745 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
41746 index b3db9dc..c3b1756 100644
41747 --- a/drivers/scsi/qla2xxx/qla_attr.c
41748 +++ b/drivers/scsi/qla2xxx/qla_attr.c
41749 @@ -1971,7 +1971,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
41750 return 0;
41751 }
41752
41753 -struct fc_function_template qla2xxx_transport_functions = {
41754 +fc_function_template_no_const qla2xxx_transport_functions = {
41755
41756 .show_host_node_name = 1,
41757 .show_host_port_name = 1,
41758 @@ -2018,7 +2018,7 @@ struct fc_function_template qla2xxx_transport_functions = {
41759 .bsg_timeout = qla24xx_bsg_timeout,
41760 };
41761
41762 -struct fc_function_template qla2xxx_transport_vport_functions = {
41763 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
41764
41765 .show_host_node_name = 1,
41766 .show_host_port_name = 1,
41767 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
41768 index b310fa9..b9b3944 100644
41769 --- a/drivers/scsi/qla2xxx/qla_gbl.h
41770 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
41771 @@ -523,8 +523,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
41772 struct device_attribute;
41773 extern struct device_attribute *qla2x00_host_attrs[];
41774 struct fc_function_template;
41775 -extern struct fc_function_template qla2xxx_transport_functions;
41776 -extern struct fc_function_template qla2xxx_transport_vport_functions;
41777 +extern fc_function_template_no_const qla2xxx_transport_functions;
41778 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
41779 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
41780 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
41781 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
41782 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
41783 index 2c6dd3d..e5ecd82 100644
41784 --- a/drivers/scsi/qla2xxx/qla_os.c
41785 +++ b/drivers/scsi/qla2xxx/qla_os.c
41786 @@ -1554,8 +1554,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
41787 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
41788 /* Ok, a 64bit DMA mask is applicable. */
41789 ha->flags.enable_64bit_addressing = 1;
41790 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
41791 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
41792 + pax_open_kernel();
41793 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
41794 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
41795 + pax_close_kernel();
41796 return;
41797 }
41798 }
41799 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
41800 index 129f5dd..ade53e8 100644
41801 --- a/drivers/scsi/qla4xxx/ql4_def.h
41802 +++ b/drivers/scsi/qla4xxx/ql4_def.h
41803 @@ -275,7 +275,7 @@ struct ddb_entry {
41804 * (4000 only) */
41805 atomic_t relogin_timer; /* Max Time to wait for
41806 * relogin to complete */
41807 - atomic_t relogin_retry_count; /* Num of times relogin has been
41808 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
41809 * retried */
41810 uint32_t default_time2wait; /* Default Min time between
41811 * relogins (+aens) */
41812 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
41813 index 6142729..b6a85c9 100644
41814 --- a/drivers/scsi/qla4xxx/ql4_os.c
41815 +++ b/drivers/scsi/qla4xxx/ql4_os.c
41816 @@ -2622,12 +2622,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
41817 */
41818 if (!iscsi_is_session_online(cls_sess)) {
41819 /* Reset retry relogin timer */
41820 - atomic_inc(&ddb_entry->relogin_retry_count);
41821 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
41822 DEBUG2(ql4_printk(KERN_INFO, ha,
41823 "%s: index[%d] relogin timed out-retrying"
41824 " relogin (%d), retry (%d)\n", __func__,
41825 ddb_entry->fw_ddb_index,
41826 - atomic_read(&ddb_entry->relogin_retry_count),
41827 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
41828 ddb_entry->default_time2wait + 4));
41829 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
41830 atomic_set(&ddb_entry->retry_relogin_timer,
41831 @@ -4742,7 +4742,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
41832
41833 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
41834 atomic_set(&ddb_entry->relogin_timer, 0);
41835 - atomic_set(&ddb_entry->relogin_retry_count, 0);
41836 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
41837 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
41838 ddb_entry->default_relogin_timeout =
41839 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
41840 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
41841 index 2c0d0ec..4e8681a 100644
41842 --- a/drivers/scsi/scsi.c
41843 +++ b/drivers/scsi/scsi.c
41844 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
41845 unsigned long timeout;
41846 int rtn = 0;
41847
41848 - atomic_inc(&cmd->device->iorequest_cnt);
41849 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
41850
41851 /* check if the device is still usable */
41852 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
41853 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
41854 index c31187d..0ead8c3 100644
41855 --- a/drivers/scsi/scsi_lib.c
41856 +++ b/drivers/scsi/scsi_lib.c
41857 @@ -1459,7 +1459,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
41858 shost = sdev->host;
41859 scsi_init_cmd_errh(cmd);
41860 cmd->result = DID_NO_CONNECT << 16;
41861 - atomic_inc(&cmd->device->iorequest_cnt);
41862 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
41863
41864 /*
41865 * SCSI request completion path will do scsi_device_unbusy(),
41866 @@ -1485,9 +1485,9 @@ static void scsi_softirq_done(struct request *rq)
41867
41868 INIT_LIST_HEAD(&cmd->eh_entry);
41869
41870 - atomic_inc(&cmd->device->iodone_cnt);
41871 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
41872 if (cmd->result)
41873 - atomic_inc(&cmd->device->ioerr_cnt);
41874 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
41875
41876 disposition = scsi_decide_disposition(cmd);
41877 if (disposition != SUCCESS &&
41878 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
41879 index 931a7d9..0c2a754 100644
41880 --- a/drivers/scsi/scsi_sysfs.c
41881 +++ b/drivers/scsi/scsi_sysfs.c
41882 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
41883 char *buf) \
41884 { \
41885 struct scsi_device *sdev = to_scsi_device(dev); \
41886 - unsigned long long count = atomic_read(&sdev->field); \
41887 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
41888 return snprintf(buf, 20, "0x%llx\n", count); \
41889 } \
41890 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
41891 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
41892 index 84a1fdf..693b0d6 100644
41893 --- a/drivers/scsi/scsi_tgt_lib.c
41894 +++ b/drivers/scsi/scsi_tgt_lib.c
41895 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
41896 int err;
41897
41898 dprintk("%lx %u\n", uaddr, len);
41899 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
41900 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
41901 if (err) {
41902 /*
41903 * TODO: need to fixup sg_tablesize, max_segment_size,
41904 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
41905 index e894ca7..de9d7660 100644
41906 --- a/drivers/scsi/scsi_transport_fc.c
41907 +++ b/drivers/scsi/scsi_transport_fc.c
41908 @@ -498,7 +498,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
41909 * Netlink Infrastructure
41910 */
41911
41912 -static atomic_t fc_event_seq;
41913 +static atomic_unchecked_t fc_event_seq;
41914
41915 /**
41916 * fc_get_event_number - Obtain the next sequential FC event number
41917 @@ -511,7 +511,7 @@ static atomic_t fc_event_seq;
41918 u32
41919 fc_get_event_number(void)
41920 {
41921 - return atomic_add_return(1, &fc_event_seq);
41922 + return atomic_add_return_unchecked(1, &fc_event_seq);
41923 }
41924 EXPORT_SYMBOL(fc_get_event_number);
41925
41926 @@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
41927 {
41928 int error;
41929
41930 - atomic_set(&fc_event_seq, 0);
41931 + atomic_set_unchecked(&fc_event_seq, 0);
41932
41933 error = transport_class_register(&fc_host_class);
41934 if (error)
41935 @@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
41936 char *cp;
41937
41938 *val = simple_strtoul(buf, &cp, 0);
41939 - if ((*cp && (*cp != '\n')) || (*val < 0))
41940 + if (*cp && (*cp != '\n'))
41941 return -EINVAL;
41942 /*
41943 * Check for overflow; dev_loss_tmo is u32
41944 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
41945 index 0a74b97..fa8d648 100644
41946 --- a/drivers/scsi/scsi_transport_iscsi.c
41947 +++ b/drivers/scsi/scsi_transport_iscsi.c
41948 @@ -79,7 +79,7 @@ struct iscsi_internal {
41949 struct transport_container session_cont;
41950 };
41951
41952 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
41953 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
41954 static struct workqueue_struct *iscsi_eh_timer_workq;
41955
41956 static DEFINE_IDA(iscsi_sess_ida);
41957 @@ -1064,7 +1064,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
41958 int err;
41959
41960 ihost = shost->shost_data;
41961 - session->sid = atomic_add_return(1, &iscsi_session_nr);
41962 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
41963
41964 if (target_id == ISCSI_MAX_TARGET) {
41965 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
41966 @@ -2955,7 +2955,7 @@ static __init int iscsi_transport_init(void)
41967 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
41968 ISCSI_TRANSPORT_VERSION);
41969
41970 - atomic_set(&iscsi_session_nr, 0);
41971 + atomic_set_unchecked(&iscsi_session_nr, 0);
41972
41973 err = class_register(&iscsi_transport_class);
41974 if (err)
41975 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
41976 index f379c7f..e8fc69c 100644
41977 --- a/drivers/scsi/scsi_transport_srp.c
41978 +++ b/drivers/scsi/scsi_transport_srp.c
41979 @@ -33,7 +33,7 @@
41980 #include "scsi_transport_srp_internal.h"
41981
41982 struct srp_host_attrs {
41983 - atomic_t next_port_id;
41984 + atomic_unchecked_t next_port_id;
41985 };
41986 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
41987
41988 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
41989 struct Scsi_Host *shost = dev_to_shost(dev);
41990 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
41991
41992 - atomic_set(&srp_host->next_port_id, 0);
41993 + atomic_set_unchecked(&srp_host->next_port_id, 0);
41994 return 0;
41995 }
41996
41997 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
41998 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
41999 rport->roles = ids->roles;
42000
42001 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
42002 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
42003 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
42004
42005 transport_setup_device(&rport->dev);
42006 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
42007 index 7992635..609faf8 100644
42008 --- a/drivers/scsi/sd.c
42009 +++ b/drivers/scsi/sd.c
42010 @@ -2909,7 +2909,7 @@ static int sd_probe(struct device *dev)
42011 sdkp->disk = gd;
42012 sdkp->index = index;
42013 atomic_set(&sdkp->openers, 0);
42014 - atomic_set(&sdkp->device->ioerr_cnt, 0);
42015 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
42016
42017 if (!sdp->request_queue->rq_timeout) {
42018 if (sdp->type != TYPE_MOD)
42019 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
42020 index 9f0c465..47194ee 100644
42021 --- a/drivers/scsi/sg.c
42022 +++ b/drivers/scsi/sg.c
42023 @@ -1101,7 +1101,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
42024 sdp->disk->disk_name,
42025 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
42026 NULL,
42027 - (char *)arg);
42028 + (char __user *)arg);
42029 case BLKTRACESTART:
42030 return blk_trace_startstop(sdp->device->request_queue, 1);
42031 case BLKTRACESTOP:
42032 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
42033 index 004b10f..7c98d51 100644
42034 --- a/drivers/spi/spi.c
42035 +++ b/drivers/spi/spi.c
42036 @@ -1620,7 +1620,7 @@ int spi_bus_unlock(struct spi_master *master)
42037 EXPORT_SYMBOL_GPL(spi_bus_unlock);
42038
42039 /* portable code must never pass more than 32 bytes */
42040 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
42041 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
42042
42043 static u8 *buf;
42044
42045 diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
42046 index 93af756..a4bc5bf 100644
42047 --- a/drivers/staging/iio/iio_hwmon.c
42048 +++ b/drivers/staging/iio/iio_hwmon.c
42049 @@ -67,7 +67,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
42050 {
42051 struct device *dev = &pdev->dev;
42052 struct iio_hwmon_state *st;
42053 - struct sensor_device_attribute *a;
42054 + sensor_device_attribute_no_const *a;
42055 int ret, i;
42056 int in_i = 1, temp_i = 1, curr_i = 1;
42057 enum iio_chan_type type;
42058 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
42059 index 34afc16..ffe44dd 100644
42060 --- a/drivers/staging/octeon/ethernet-rx.c
42061 +++ b/drivers/staging/octeon/ethernet-rx.c
42062 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42063 /* Increment RX stats for virtual ports */
42064 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
42065 #ifdef CONFIG_64BIT
42066 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
42067 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
42068 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
42069 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
42070 #else
42071 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
42072 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
42073 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
42074 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
42075 #endif
42076 }
42077 netif_receive_skb(skb);
42078 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42079 dev->name);
42080 */
42081 #ifdef CONFIG_64BIT
42082 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
42083 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42084 #else
42085 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
42086 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
42087 #endif
42088 dev_kfree_skb_irq(skb);
42089 }
42090 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
42091 index c3a90e7..023619a 100644
42092 --- a/drivers/staging/octeon/ethernet.c
42093 +++ b/drivers/staging/octeon/ethernet.c
42094 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
42095 * since the RX tasklet also increments it.
42096 */
42097 #ifdef CONFIG_64BIT
42098 - atomic64_add(rx_status.dropped_packets,
42099 - (atomic64_t *)&priv->stats.rx_dropped);
42100 + atomic64_add_unchecked(rx_status.dropped_packets,
42101 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42102 #else
42103 - atomic_add(rx_status.dropped_packets,
42104 - (atomic_t *)&priv->stats.rx_dropped);
42105 + atomic_add_unchecked(rx_status.dropped_packets,
42106 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
42107 #endif
42108 }
42109
42110 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
42111 index dc23395..cf7e9b1 100644
42112 --- a/drivers/staging/rtl8712/rtl871x_io.h
42113 +++ b/drivers/staging/rtl8712/rtl871x_io.h
42114 @@ -108,7 +108,7 @@ struct _io_ops {
42115 u8 *pmem);
42116 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
42117 u8 *pmem);
42118 -};
42119 +} __no_const;
42120
42121 struct io_req {
42122 struct list_head list;
42123 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
42124 index 1f5088b..0e59820 100644
42125 --- a/drivers/staging/sbe-2t3e3/netdev.c
42126 +++ b/drivers/staging/sbe-2t3e3/netdev.c
42127 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
42128 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
42129
42130 if (rlen)
42131 - if (copy_to_user(data, &resp, rlen))
42132 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
42133 return -EFAULT;
42134
42135 return 0;
42136 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
42137 index 5dddc4d..34fcb2f 100644
42138 --- a/drivers/staging/usbip/vhci.h
42139 +++ b/drivers/staging/usbip/vhci.h
42140 @@ -83,7 +83,7 @@ struct vhci_hcd {
42141 unsigned resuming:1;
42142 unsigned long re_timeout;
42143
42144 - atomic_t seqnum;
42145 + atomic_unchecked_t seqnum;
42146
42147 /*
42148 * NOTE:
42149 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
42150 index f1ca084..7b5c0c3 100644
42151 --- a/drivers/staging/usbip/vhci_hcd.c
42152 +++ b/drivers/staging/usbip/vhci_hcd.c
42153 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
42154
42155 spin_lock(&vdev->priv_lock);
42156
42157 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
42158 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
42159 if (priv->seqnum == 0xffff)
42160 dev_info(&urb->dev->dev, "seqnum max\n");
42161
42162 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
42163 return -ENOMEM;
42164 }
42165
42166 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
42167 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
42168 if (unlink->seqnum == 0xffff)
42169 pr_info("seqnum max\n");
42170
42171 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
42172 vdev->rhport = rhport;
42173 }
42174
42175 - atomic_set(&vhci->seqnum, 0);
42176 + atomic_set_unchecked(&vhci->seqnum, 0);
42177 spin_lock_init(&vhci->lock);
42178
42179 hcd->power_budget = 0; /* no limit */
42180 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
42181 index faf8e60..c46f8ab 100644
42182 --- a/drivers/staging/usbip/vhci_rx.c
42183 +++ b/drivers/staging/usbip/vhci_rx.c
42184 @@ -76,7 +76,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
42185 if (!urb) {
42186 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
42187 pr_info("max seqnum %d\n",
42188 - atomic_read(&the_controller->seqnum));
42189 + atomic_read_unchecked(&the_controller->seqnum));
42190 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
42191 return;
42192 }
42193 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
42194 index 5f13890..36a044b 100644
42195 --- a/drivers/staging/vt6655/hostap.c
42196 +++ b/drivers/staging/vt6655/hostap.c
42197 @@ -73,14 +73,13 @@ static int msglevel =MSG_LEVEL_INFO;
42198 *
42199 */
42200
42201 +static net_device_ops_no_const apdev_netdev_ops;
42202 +
42203 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42204 {
42205 PSDevice apdev_priv;
42206 struct net_device *dev = pDevice->dev;
42207 int ret;
42208 - const struct net_device_ops apdev_netdev_ops = {
42209 - .ndo_start_xmit = pDevice->tx_80211,
42210 - };
42211
42212 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
42213
42214 @@ -92,6 +91,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42215 *apdev_priv = *pDevice;
42216 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
42217
42218 + /* only half broken now */
42219 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
42220 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
42221
42222 pDevice->apdev->type = ARPHRD_IEEE80211;
42223 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
42224 index bc5e9da..dacd556 100644
42225 --- a/drivers/staging/vt6656/hostap.c
42226 +++ b/drivers/staging/vt6656/hostap.c
42227 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
42228 *
42229 */
42230
42231 +static net_device_ops_no_const apdev_netdev_ops;
42232 +
42233 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
42234 {
42235 struct vnt_private *apdev_priv;
42236 struct net_device *dev = pDevice->dev;
42237 int ret;
42238 - const struct net_device_ops apdev_netdev_ops = {
42239 - .ndo_start_xmit = pDevice->tx_80211,
42240 - };
42241
42242 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
42243
42244 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
42245 *apdev_priv = *pDevice;
42246 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
42247
42248 + /* only half broken now */
42249 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
42250 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
42251
42252 pDevice->apdev->type = ARPHRD_IEEE80211;
42253 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
42254 index a2b7e03..9ff4bbd 100644
42255 --- a/drivers/staging/zcache/tmem.c
42256 +++ b/drivers/staging/zcache/tmem.c
42257 @@ -50,7 +50,7 @@
42258 * A tmem host implementation must use this function to register callbacks
42259 * for memory allocation.
42260 */
42261 -static struct tmem_hostops tmem_hostops;
42262 +static tmem_hostops_no_const tmem_hostops;
42263
42264 static void tmem_objnode_tree_init(void);
42265
42266 @@ -64,7 +64,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
42267 * A tmem host implementation must use this function to register
42268 * callbacks for a page-accessible memory (PAM) implementation.
42269 */
42270 -static struct tmem_pamops tmem_pamops;
42271 +static tmem_pamops_no_const tmem_pamops;
42272
42273 void tmem_register_pamops(struct tmem_pamops *m)
42274 {
42275 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
42276 index adbe5a8..d387359 100644
42277 --- a/drivers/staging/zcache/tmem.h
42278 +++ b/drivers/staging/zcache/tmem.h
42279 @@ -226,6 +226,7 @@ struct tmem_pamops {
42280 int (*replace_in_obj)(void *, struct tmem_obj *);
42281 #endif
42282 };
42283 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
42284 extern void tmem_register_pamops(struct tmem_pamops *m);
42285
42286 /* memory allocation methods provided by the host implementation */
42287 @@ -235,6 +236,7 @@ struct tmem_hostops {
42288 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
42289 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
42290 };
42291 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
42292 extern void tmem_register_hostops(struct tmem_hostops *m);
42293
42294 /* core tmem accessor functions */
42295 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
42296 index 2e4d655..fd72e68 100644
42297 --- a/drivers/target/target_core_device.c
42298 +++ b/drivers/target/target_core_device.c
42299 @@ -1414,7 +1414,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
42300 spin_lock_init(&dev->se_port_lock);
42301 spin_lock_init(&dev->se_tmr_lock);
42302 spin_lock_init(&dev->qf_cmd_lock);
42303 - atomic_set(&dev->dev_ordered_id, 0);
42304 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
42305 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
42306 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
42307 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
42308 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
42309 index 3243ea7..4f19a6e 100644
42310 --- a/drivers/target/target_core_transport.c
42311 +++ b/drivers/target/target_core_transport.c
42312 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
42313 * Used to determine when ORDERED commands should go from
42314 * Dormant to Active status.
42315 */
42316 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
42317 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
42318 smp_mb__after_atomic_inc();
42319 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
42320 cmd->se_ordered_id, cmd->sam_task_attr,
42321 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
42322 index 345bd0e..61d5375 100644
42323 --- a/drivers/tty/cyclades.c
42324 +++ b/drivers/tty/cyclades.c
42325 @@ -1576,10 +1576,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
42326 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
42327 info->port.count);
42328 #endif
42329 - info->port.count++;
42330 + atomic_inc(&info->port.count);
42331 #ifdef CY_DEBUG_COUNT
42332 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
42333 - current->pid, info->port.count);
42334 + current->pid, atomic_read(&info->port.count));
42335 #endif
42336
42337 /*
42338 @@ -3978,7 +3978,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
42339 for (j = 0; j < cy_card[i].nports; j++) {
42340 info = &cy_card[i].ports[j];
42341
42342 - if (info->port.count) {
42343 + if (atomic_read(&info->port.count)) {
42344 /* XXX is the ldisc num worth this? */
42345 struct tty_struct *tty;
42346 struct tty_ldisc *ld;
42347 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
42348 index eb255e8..f637a57 100644
42349 --- a/drivers/tty/hvc/hvc_console.c
42350 +++ b/drivers/tty/hvc/hvc_console.c
42351 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
42352
42353 spin_lock_irqsave(&hp->port.lock, flags);
42354 /* Check and then increment for fast path open. */
42355 - if (hp->port.count++ > 0) {
42356 + if (atomic_inc_return(&hp->port.count) > 1) {
42357 spin_unlock_irqrestore(&hp->port.lock, flags);
42358 hvc_kick();
42359 return 0;
42360 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
42361
42362 spin_lock_irqsave(&hp->port.lock, flags);
42363
42364 - if (--hp->port.count == 0) {
42365 + if (atomic_dec_return(&hp->port.count) == 0) {
42366 spin_unlock_irqrestore(&hp->port.lock, flags);
42367 /* We are done with the tty pointer now. */
42368 tty_port_tty_set(&hp->port, NULL);
42369 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
42370 */
42371 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
42372 } else {
42373 - if (hp->port.count < 0)
42374 + if (atomic_read(&hp->port.count) < 0)
42375 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
42376 - hp->vtermno, hp->port.count);
42377 + hp->vtermno, atomic_read(&hp->port.count));
42378 spin_unlock_irqrestore(&hp->port.lock, flags);
42379 }
42380 }
42381 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
42382 * open->hangup case this can be called after the final close so prevent
42383 * that from happening for now.
42384 */
42385 - if (hp->port.count <= 0) {
42386 + if (atomic_read(&hp->port.count) <= 0) {
42387 spin_unlock_irqrestore(&hp->port.lock, flags);
42388 return;
42389 }
42390
42391 - hp->port.count = 0;
42392 + atomic_set(&hp->port.count, 0);
42393 spin_unlock_irqrestore(&hp->port.lock, flags);
42394 tty_port_tty_set(&hp->port, NULL);
42395
42396 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
42397 return -EPIPE;
42398
42399 /* FIXME what's this (unprotected) check for? */
42400 - if (hp->port.count <= 0)
42401 + if (atomic_read(&hp->port.count) <= 0)
42402 return -EIO;
42403
42404 spin_lock_irqsave(&hp->lock, flags);
42405 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
42406 index 81e939e..95ead10 100644
42407 --- a/drivers/tty/hvc/hvcs.c
42408 +++ b/drivers/tty/hvc/hvcs.c
42409 @@ -83,6 +83,7 @@
42410 #include <asm/hvcserver.h>
42411 #include <asm/uaccess.h>
42412 #include <asm/vio.h>
42413 +#include <asm/local.h>
42414
42415 /*
42416 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
42417 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
42418
42419 spin_lock_irqsave(&hvcsd->lock, flags);
42420
42421 - if (hvcsd->port.count > 0) {
42422 + if (atomic_read(&hvcsd->port.count) > 0) {
42423 spin_unlock_irqrestore(&hvcsd->lock, flags);
42424 printk(KERN_INFO "HVCS: vterm state unchanged. "
42425 "The hvcs device node is still in use.\n");
42426 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
42427 }
42428 }
42429
42430 - hvcsd->port.count = 0;
42431 + atomic_set(&hvcsd->port.count, 0);
42432 hvcsd->port.tty = tty;
42433 tty->driver_data = hvcsd;
42434
42435 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
42436 unsigned long flags;
42437
42438 spin_lock_irqsave(&hvcsd->lock, flags);
42439 - hvcsd->port.count++;
42440 + atomic_inc(&hvcsd->port.count);
42441 hvcsd->todo_mask |= HVCS_SCHED_READ;
42442 spin_unlock_irqrestore(&hvcsd->lock, flags);
42443
42444 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
42445 hvcsd = tty->driver_data;
42446
42447 spin_lock_irqsave(&hvcsd->lock, flags);
42448 - if (--hvcsd->port.count == 0) {
42449 + if (atomic_dec_and_test(&hvcsd->port.count)) {
42450
42451 vio_disable_interrupts(hvcsd->vdev);
42452
42453 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
42454
42455 free_irq(irq, hvcsd);
42456 return;
42457 - } else if (hvcsd->port.count < 0) {
42458 + } else if (atomic_read(&hvcsd->port.count) < 0) {
42459 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
42460 " is missmanaged.\n",
42461 - hvcsd->vdev->unit_address, hvcsd->port.count);
42462 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
42463 }
42464
42465 spin_unlock_irqrestore(&hvcsd->lock, flags);
42466 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
42467
42468 spin_lock_irqsave(&hvcsd->lock, flags);
42469 /* Preserve this so that we know how many kref refs to put */
42470 - temp_open_count = hvcsd->port.count;
42471 + temp_open_count = atomic_read(&hvcsd->port.count);
42472
42473 /*
42474 * Don't kref put inside the spinlock because the destruction
42475 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
42476 tty->driver_data = NULL;
42477 hvcsd->port.tty = NULL;
42478
42479 - hvcsd->port.count = 0;
42480 + atomic_set(&hvcsd->port.count, 0);
42481
42482 /* This will drop any buffered data on the floor which is OK in a hangup
42483 * scenario. */
42484 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
42485 * the middle of a write operation? This is a crummy place to do this
42486 * but we want to keep it all in the spinlock.
42487 */
42488 - if (hvcsd->port.count <= 0) {
42489 + if (atomic_read(&hvcsd->port.count) <= 0) {
42490 spin_unlock_irqrestore(&hvcsd->lock, flags);
42491 return -ENODEV;
42492 }
42493 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
42494 {
42495 struct hvcs_struct *hvcsd = tty->driver_data;
42496
42497 - if (!hvcsd || hvcsd->port.count <= 0)
42498 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
42499 return 0;
42500
42501 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
42502 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
42503 index 8fd72ff..34a0bed 100644
42504 --- a/drivers/tty/ipwireless/tty.c
42505 +++ b/drivers/tty/ipwireless/tty.c
42506 @@ -29,6 +29,7 @@
42507 #include <linux/tty_driver.h>
42508 #include <linux/tty_flip.h>
42509 #include <linux/uaccess.h>
42510 +#include <asm/local.h>
42511
42512 #include "tty.h"
42513 #include "network.h"
42514 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
42515 mutex_unlock(&tty->ipw_tty_mutex);
42516 return -ENODEV;
42517 }
42518 - if (tty->port.count == 0)
42519 + if (atomic_read(&tty->port.count) == 0)
42520 tty->tx_bytes_queued = 0;
42521
42522 - tty->port.count++;
42523 + atomic_inc(&tty->port.count);
42524
42525 tty->port.tty = linux_tty;
42526 linux_tty->driver_data = tty;
42527 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
42528
42529 static void do_ipw_close(struct ipw_tty *tty)
42530 {
42531 - tty->port.count--;
42532 -
42533 - if (tty->port.count == 0) {
42534 + if (atomic_dec_return(&tty->port.count) == 0) {
42535 struct tty_struct *linux_tty = tty->port.tty;
42536
42537 if (linux_tty != NULL) {
42538 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
42539 return;
42540
42541 mutex_lock(&tty->ipw_tty_mutex);
42542 - if (tty->port.count == 0) {
42543 + if (atomic_read(&tty->port.count) == 0) {
42544 mutex_unlock(&tty->ipw_tty_mutex);
42545 return;
42546 }
42547 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
42548
42549 mutex_lock(&tty->ipw_tty_mutex);
42550
42551 - if (!tty->port.count) {
42552 + if (!atomic_read(&tty->port.count)) {
42553 mutex_unlock(&tty->ipw_tty_mutex);
42554 return;
42555 }
42556 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
42557 return -ENODEV;
42558
42559 mutex_lock(&tty->ipw_tty_mutex);
42560 - if (!tty->port.count) {
42561 + if (!atomic_read(&tty->port.count)) {
42562 mutex_unlock(&tty->ipw_tty_mutex);
42563 return -EINVAL;
42564 }
42565 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
42566 if (!tty)
42567 return -ENODEV;
42568
42569 - if (!tty->port.count)
42570 + if (!atomic_read(&tty->port.count))
42571 return -EINVAL;
42572
42573 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
42574 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
42575 if (!tty)
42576 return 0;
42577
42578 - if (!tty->port.count)
42579 + if (!atomic_read(&tty->port.count))
42580 return 0;
42581
42582 return tty->tx_bytes_queued;
42583 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
42584 if (!tty)
42585 return -ENODEV;
42586
42587 - if (!tty->port.count)
42588 + if (!atomic_read(&tty->port.count))
42589 return -EINVAL;
42590
42591 return get_control_lines(tty);
42592 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
42593 if (!tty)
42594 return -ENODEV;
42595
42596 - if (!tty->port.count)
42597 + if (!atomic_read(&tty->port.count))
42598 return -EINVAL;
42599
42600 return set_control_lines(tty, set, clear);
42601 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
42602 if (!tty)
42603 return -ENODEV;
42604
42605 - if (!tty->port.count)
42606 + if (!atomic_read(&tty->port.count))
42607 return -EINVAL;
42608
42609 /* FIXME: Exactly how is the tty object locked here .. */
42610 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
42611 * are gone */
42612 mutex_lock(&ttyj->ipw_tty_mutex);
42613 }
42614 - while (ttyj->port.count)
42615 + while (atomic_read(&ttyj->port.count))
42616 do_ipw_close(ttyj);
42617 ipwireless_disassociate_network_ttys(network,
42618 ttyj->channel_idx);
42619 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
42620 index adeac25..787a0a1 100644
42621 --- a/drivers/tty/moxa.c
42622 +++ b/drivers/tty/moxa.c
42623 @@ -1193,7 +1193,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
42624 }
42625
42626 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
42627 - ch->port.count++;
42628 + atomic_inc(&ch->port.count);
42629 tty->driver_data = ch;
42630 tty_port_tty_set(&ch->port, tty);
42631 mutex_lock(&ch->port.mutex);
42632 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
42633 index 4a43ef5d7..aa71f27 100644
42634 --- a/drivers/tty/n_gsm.c
42635 +++ b/drivers/tty/n_gsm.c
42636 @@ -1636,7 +1636,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
42637 spin_lock_init(&dlci->lock);
42638 mutex_init(&dlci->mutex);
42639 dlci->fifo = &dlci->_fifo;
42640 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
42641 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
42642 kfree(dlci);
42643 return NULL;
42644 }
42645 @@ -2936,7 +2936,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
42646 struct gsm_dlci *dlci = tty->driver_data;
42647 struct tty_port *port = &dlci->port;
42648
42649 - port->count++;
42650 + atomic_inc(&port->count);
42651 dlci_get(dlci);
42652 dlci_get(dlci->gsm->dlci[0]);
42653 mux_get(dlci->gsm);
42654 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
42655 index 05e72be..67f6a0f 100644
42656 --- a/drivers/tty/n_tty.c
42657 +++ b/drivers/tty/n_tty.c
42658 @@ -2197,6 +2197,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
42659 {
42660 *ops = tty_ldisc_N_TTY;
42661 ops->owner = NULL;
42662 - ops->refcount = ops->flags = 0;
42663 + atomic_set(&ops->refcount, 0);
42664 + ops->flags = 0;
42665 }
42666 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
42667 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
42668 index 125e0fd..8c50690 100644
42669 --- a/drivers/tty/pty.c
42670 +++ b/drivers/tty/pty.c
42671 @@ -800,8 +800,10 @@ static void __init unix98_pty_init(void)
42672 panic("Couldn't register Unix98 pts driver");
42673
42674 /* Now create the /dev/ptmx special device */
42675 + pax_open_kernel();
42676 tty_default_fops(&ptmx_fops);
42677 - ptmx_fops.open = ptmx_open;
42678 + *(void **)&ptmx_fops.open = ptmx_open;
42679 + pax_close_kernel();
42680
42681 cdev_init(&ptmx_cdev, &ptmx_fops);
42682 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
42683 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
42684 index 1d27003..959f452 100644
42685 --- a/drivers/tty/rocket.c
42686 +++ b/drivers/tty/rocket.c
42687 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
42688 tty->driver_data = info;
42689 tty_port_tty_set(port, tty);
42690
42691 - if (port->count++ == 0) {
42692 + if (atomic_inc_return(&port->count) == 1) {
42693 atomic_inc(&rp_num_ports_open);
42694
42695 #ifdef ROCKET_DEBUG_OPEN
42696 @@ -932,7 +932,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
42697 #endif
42698 }
42699 #ifdef ROCKET_DEBUG_OPEN
42700 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
42701 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
42702 #endif
42703
42704 /*
42705 @@ -1527,7 +1527,7 @@ static void rp_hangup(struct tty_struct *tty)
42706 spin_unlock_irqrestore(&info->port.lock, flags);
42707 return;
42708 }
42709 - if (info->port.count)
42710 + if (atomic_read(&info->port.count))
42711 atomic_dec(&rp_num_ports_open);
42712 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
42713 spin_unlock_irqrestore(&info->port.lock, flags);
42714 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
42715 index 1002054..dd644a8 100644
42716 --- a/drivers/tty/serial/kgdboc.c
42717 +++ b/drivers/tty/serial/kgdboc.c
42718 @@ -24,8 +24,9 @@
42719 #define MAX_CONFIG_LEN 40
42720
42721 static struct kgdb_io kgdboc_io_ops;
42722 +static struct kgdb_io kgdboc_io_ops_console;
42723
42724 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
42725 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
42726 static int configured = -1;
42727
42728 static char config[MAX_CONFIG_LEN];
42729 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
42730 kgdboc_unregister_kbd();
42731 if (configured == 1)
42732 kgdb_unregister_io_module(&kgdboc_io_ops);
42733 + else if (configured == 2)
42734 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
42735 }
42736
42737 static int configure_kgdboc(void)
42738 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
42739 int err;
42740 char *cptr = config;
42741 struct console *cons;
42742 + int is_console = 0;
42743
42744 err = kgdboc_option_setup(config);
42745 if (err || !strlen(config) || isspace(config[0]))
42746 goto noconfig;
42747
42748 err = -ENODEV;
42749 - kgdboc_io_ops.is_console = 0;
42750 kgdb_tty_driver = NULL;
42751
42752 kgdboc_use_kms = 0;
42753 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
42754 int idx;
42755 if (cons->device && cons->device(cons, &idx) == p &&
42756 idx == tty_line) {
42757 - kgdboc_io_ops.is_console = 1;
42758 + is_console = 1;
42759 break;
42760 }
42761 cons = cons->next;
42762 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
42763 kgdb_tty_line = tty_line;
42764
42765 do_register:
42766 - err = kgdb_register_io_module(&kgdboc_io_ops);
42767 + if (is_console) {
42768 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
42769 + configured = 2;
42770 + } else {
42771 + err = kgdb_register_io_module(&kgdboc_io_ops);
42772 + configured = 1;
42773 + }
42774 if (err)
42775 goto noconfig;
42776
42777 @@ -205,8 +214,6 @@ do_register:
42778 if (err)
42779 goto nmi_con_failed;
42780
42781 - configured = 1;
42782 -
42783 return 0;
42784
42785 nmi_con_failed:
42786 @@ -223,7 +230,7 @@ noconfig:
42787 static int __init init_kgdboc(void)
42788 {
42789 /* Already configured? */
42790 - if (configured == 1)
42791 + if (configured >= 1)
42792 return 0;
42793
42794 return configure_kgdboc();
42795 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
42796 if (config[len - 1] == '\n')
42797 config[len - 1] = '\0';
42798
42799 - if (configured == 1)
42800 + if (configured >= 1)
42801 cleanup_kgdboc();
42802
42803 /* Go and configure with the new params. */
42804 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
42805 .post_exception = kgdboc_post_exp_handler,
42806 };
42807
42808 +static struct kgdb_io kgdboc_io_ops_console = {
42809 + .name = "kgdboc",
42810 + .read_char = kgdboc_get_char,
42811 + .write_char = kgdboc_put_char,
42812 + .pre_exception = kgdboc_pre_exp_handler,
42813 + .post_exception = kgdboc_post_exp_handler,
42814 + .is_console = 1
42815 +};
42816 +
42817 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
42818 /* This is only available if kgdboc is a built in for early debugging */
42819 static int __init kgdboc_early_init(char *opt)
42820 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
42821 index 2769a38..f3dbe48 100644
42822 --- a/drivers/tty/serial/samsung.c
42823 +++ b/drivers/tty/serial/samsung.c
42824 @@ -451,11 +451,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
42825 }
42826 }
42827
42828 +static int s3c64xx_serial_startup(struct uart_port *port);
42829 static int s3c24xx_serial_startup(struct uart_port *port)
42830 {
42831 struct s3c24xx_uart_port *ourport = to_ourport(port);
42832 int ret;
42833
42834 + /* Startup sequence is different for s3c64xx and higher SoC's */
42835 + if (s3c24xx_serial_has_interrupt_mask(port))
42836 + return s3c64xx_serial_startup(port);
42837 +
42838 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
42839 port->mapbase, port->membase);
42840
42841 @@ -1120,10 +1125,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
42842 /* setup info for port */
42843 port->dev = &platdev->dev;
42844
42845 - /* Startup sequence is different for s3c64xx and higher SoC's */
42846 - if (s3c24xx_serial_has_interrupt_mask(port))
42847 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
42848 -
42849 port->uartclk = 1;
42850
42851 if (cfg->uart_flags & UPF_CONS_FLOW) {
42852 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
42853 index 8fbb6d2..822a9e6 100644
42854 --- a/drivers/tty/serial/serial_core.c
42855 +++ b/drivers/tty/serial/serial_core.c
42856 @@ -1454,7 +1454,7 @@ static void uart_hangup(struct tty_struct *tty)
42857 uart_flush_buffer(tty);
42858 uart_shutdown(tty, state);
42859 spin_lock_irqsave(&port->lock, flags);
42860 - port->count = 0;
42861 + atomic_set(&port->count, 0);
42862 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
42863 spin_unlock_irqrestore(&port->lock, flags);
42864 tty_port_tty_set(port, NULL);
42865 @@ -1550,7 +1550,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
42866 goto end;
42867 }
42868
42869 - port->count++;
42870 + atomic_inc(&port->count);
42871 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
42872 retval = -ENXIO;
42873 goto err_dec_count;
42874 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
42875 /*
42876 * Make sure the device is in D0 state.
42877 */
42878 - if (port->count == 1)
42879 + if (atomic_read(&port->count) == 1)
42880 uart_change_pm(state, UART_PM_STATE_ON);
42881
42882 /*
42883 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
42884 end:
42885 return retval;
42886 err_dec_count:
42887 - port->count--;
42888 + atomic_inc(&port->count);
42889 mutex_unlock(&port->mutex);
42890 goto end;
42891 }
42892 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
42893 index 8983276..72a4090 100644
42894 --- a/drivers/tty/synclink.c
42895 +++ b/drivers/tty/synclink.c
42896 @@ -3093,7 +3093,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
42897
42898 if (debug_level >= DEBUG_LEVEL_INFO)
42899 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
42900 - __FILE__,__LINE__, info->device_name, info->port.count);
42901 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
42902
42903 if (tty_port_close_start(&info->port, tty, filp) == 0)
42904 goto cleanup;
42905 @@ -3111,7 +3111,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
42906 cleanup:
42907 if (debug_level >= DEBUG_LEVEL_INFO)
42908 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
42909 - tty->driver->name, info->port.count);
42910 + tty->driver->name, atomic_read(&info->port.count));
42911
42912 } /* end of mgsl_close() */
42913
42914 @@ -3210,8 +3210,8 @@ static void mgsl_hangup(struct tty_struct *tty)
42915
42916 mgsl_flush_buffer(tty);
42917 shutdown(info);
42918 -
42919 - info->port.count = 0;
42920 +
42921 + atomic_set(&info->port.count, 0);
42922 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
42923 info->port.tty = NULL;
42924
42925 @@ -3300,12 +3300,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
42926
42927 if (debug_level >= DEBUG_LEVEL_INFO)
42928 printk("%s(%d):block_til_ready before block on %s count=%d\n",
42929 - __FILE__,__LINE__, tty->driver->name, port->count );
42930 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
42931
42932 spin_lock_irqsave(&info->irq_spinlock, flags);
42933 if (!tty_hung_up_p(filp)) {
42934 extra_count = true;
42935 - port->count--;
42936 + atomic_dec(&port->count);
42937 }
42938 spin_unlock_irqrestore(&info->irq_spinlock, flags);
42939 port->blocked_open++;
42940 @@ -3334,7 +3334,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
42941
42942 if (debug_level >= DEBUG_LEVEL_INFO)
42943 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
42944 - __FILE__,__LINE__, tty->driver->name, port->count );
42945 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
42946
42947 tty_unlock(tty);
42948 schedule();
42949 @@ -3346,12 +3346,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
42950
42951 /* FIXME: Racy on hangup during close wait */
42952 if (extra_count)
42953 - port->count++;
42954 + atomic_inc(&port->count);
42955 port->blocked_open--;
42956
42957 if (debug_level >= DEBUG_LEVEL_INFO)
42958 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
42959 - __FILE__,__LINE__, tty->driver->name, port->count );
42960 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
42961
42962 if (!retval)
42963 port->flags |= ASYNC_NORMAL_ACTIVE;
42964 @@ -3403,7 +3403,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
42965
42966 if (debug_level >= DEBUG_LEVEL_INFO)
42967 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
42968 - __FILE__,__LINE__,tty->driver->name, info->port.count);
42969 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
42970
42971 /* If port is closing, signal caller to try again */
42972 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
42973 @@ -3422,10 +3422,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
42974 spin_unlock_irqrestore(&info->netlock, flags);
42975 goto cleanup;
42976 }
42977 - info->port.count++;
42978 + atomic_inc(&info->port.count);
42979 spin_unlock_irqrestore(&info->netlock, flags);
42980
42981 - if (info->port.count == 1) {
42982 + if (atomic_read(&info->port.count) == 1) {
42983 /* 1st open on this device, init hardware */
42984 retval = startup(info);
42985 if (retval < 0)
42986 @@ -3449,8 +3449,8 @@ cleanup:
42987 if (retval) {
42988 if (tty->count == 1)
42989 info->port.tty = NULL; /* tty layer will release tty struct */
42990 - if(info->port.count)
42991 - info->port.count--;
42992 + if (atomic_read(&info->port.count))
42993 + atomic_dec(&info->port.count);
42994 }
42995
42996 return retval;
42997 @@ -7668,7 +7668,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
42998 unsigned short new_crctype;
42999
43000 /* return error if TTY interface open */
43001 - if (info->port.count)
43002 + if (atomic_read(&info->port.count))
43003 return -EBUSY;
43004
43005 switch (encoding)
43006 @@ -7763,7 +7763,7 @@ static int hdlcdev_open(struct net_device *dev)
43007
43008 /* arbitrate between network and tty opens */
43009 spin_lock_irqsave(&info->netlock, flags);
43010 - if (info->port.count != 0 || info->netcount != 0) {
43011 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43012 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43013 spin_unlock_irqrestore(&info->netlock, flags);
43014 return -EBUSY;
43015 @@ -7849,7 +7849,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43016 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43017
43018 /* return error if TTY interface open */
43019 - if (info->port.count)
43020 + if (atomic_read(&info->port.count))
43021 return -EBUSY;
43022
43023 if (cmd != SIOCWANDEV)
43024 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
43025 index aa9eece..d8baaec 100644
43026 --- a/drivers/tty/synclink_gt.c
43027 +++ b/drivers/tty/synclink_gt.c
43028 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43029 tty->driver_data = info;
43030 info->port.tty = tty;
43031
43032 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
43033 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
43034
43035 /* If port is closing, signal caller to try again */
43036 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43037 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43038 mutex_unlock(&info->port.mutex);
43039 goto cleanup;
43040 }
43041 - info->port.count++;
43042 + atomic_inc(&info->port.count);
43043 spin_unlock_irqrestore(&info->netlock, flags);
43044
43045 - if (info->port.count == 1) {
43046 + if (atomic_read(&info->port.count) == 1) {
43047 /* 1st open on this device, init hardware */
43048 retval = startup(info);
43049 if (retval < 0) {
43050 @@ -715,8 +715,8 @@ cleanup:
43051 if (retval) {
43052 if (tty->count == 1)
43053 info->port.tty = NULL; /* tty layer will release tty struct */
43054 - if(info->port.count)
43055 - info->port.count--;
43056 + if(atomic_read(&info->port.count))
43057 + atomic_dec(&info->port.count);
43058 }
43059
43060 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
43061 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43062
43063 if (sanity_check(info, tty->name, "close"))
43064 return;
43065 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
43066 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
43067
43068 if (tty_port_close_start(&info->port, tty, filp) == 0)
43069 goto cleanup;
43070 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43071 tty_port_close_end(&info->port, tty);
43072 info->port.tty = NULL;
43073 cleanup:
43074 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
43075 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
43076 }
43077
43078 static void hangup(struct tty_struct *tty)
43079 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
43080 shutdown(info);
43081
43082 spin_lock_irqsave(&info->port.lock, flags);
43083 - info->port.count = 0;
43084 + atomic_set(&info->port.count, 0);
43085 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43086 info->port.tty = NULL;
43087 spin_unlock_irqrestore(&info->port.lock, flags);
43088 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43089 unsigned short new_crctype;
43090
43091 /* return error if TTY interface open */
43092 - if (info->port.count)
43093 + if (atomic_read(&info->port.count))
43094 return -EBUSY;
43095
43096 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
43097 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
43098
43099 /* arbitrate between network and tty opens */
43100 spin_lock_irqsave(&info->netlock, flags);
43101 - if (info->port.count != 0 || info->netcount != 0) {
43102 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43103 DBGINFO(("%s hdlc_open busy\n", dev->name));
43104 spin_unlock_irqrestore(&info->netlock, flags);
43105 return -EBUSY;
43106 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43107 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
43108
43109 /* return error if TTY interface open */
43110 - if (info->port.count)
43111 + if (atomic_read(&info->port.count))
43112 return -EBUSY;
43113
43114 if (cmd != SIOCWANDEV)
43115 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
43116 if (port == NULL)
43117 continue;
43118 spin_lock(&port->lock);
43119 - if ((port->port.count || port->netcount) &&
43120 + if ((atomic_read(&port->port.count) || port->netcount) &&
43121 port->pending_bh && !port->bh_running &&
43122 !port->bh_requested) {
43123 DBGISR(("%s bh queued\n", port->device_name));
43124 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43125 spin_lock_irqsave(&info->lock, flags);
43126 if (!tty_hung_up_p(filp)) {
43127 extra_count = true;
43128 - port->count--;
43129 + atomic_dec(&port->count);
43130 }
43131 spin_unlock_irqrestore(&info->lock, flags);
43132 port->blocked_open++;
43133 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43134 remove_wait_queue(&port->open_wait, &wait);
43135
43136 if (extra_count)
43137 - port->count++;
43138 + atomic_inc(&port->count);
43139 port->blocked_open--;
43140
43141 if (!retval)
43142 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
43143 index 6d5780c..aa4d8cd 100644
43144 --- a/drivers/tty/synclinkmp.c
43145 +++ b/drivers/tty/synclinkmp.c
43146 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43147
43148 if (debug_level >= DEBUG_LEVEL_INFO)
43149 printk("%s(%d):%s open(), old ref count = %d\n",
43150 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43151 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43152
43153 /* If port is closing, signal caller to try again */
43154 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43155 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43156 spin_unlock_irqrestore(&info->netlock, flags);
43157 goto cleanup;
43158 }
43159 - info->port.count++;
43160 + atomic_inc(&info->port.count);
43161 spin_unlock_irqrestore(&info->netlock, flags);
43162
43163 - if (info->port.count == 1) {
43164 + if (atomic_read(&info->port.count) == 1) {
43165 /* 1st open on this device, init hardware */
43166 retval = startup(info);
43167 if (retval < 0)
43168 @@ -796,8 +796,8 @@ cleanup:
43169 if (retval) {
43170 if (tty->count == 1)
43171 info->port.tty = NULL; /* tty layer will release tty struct */
43172 - if(info->port.count)
43173 - info->port.count--;
43174 + if(atomic_read(&info->port.count))
43175 + atomic_dec(&info->port.count);
43176 }
43177
43178 return retval;
43179 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43180
43181 if (debug_level >= DEBUG_LEVEL_INFO)
43182 printk("%s(%d):%s close() entry, count=%d\n",
43183 - __FILE__,__LINE__, info->device_name, info->port.count);
43184 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43185
43186 if (tty_port_close_start(&info->port, tty, filp) == 0)
43187 goto cleanup;
43188 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43189 cleanup:
43190 if (debug_level >= DEBUG_LEVEL_INFO)
43191 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
43192 - tty->driver->name, info->port.count);
43193 + tty->driver->name, atomic_read(&info->port.count));
43194 }
43195
43196 /* Called by tty_hangup() when a hangup is signaled.
43197 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
43198 shutdown(info);
43199
43200 spin_lock_irqsave(&info->port.lock, flags);
43201 - info->port.count = 0;
43202 + atomic_set(&info->port.count, 0);
43203 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43204 info->port.tty = NULL;
43205 spin_unlock_irqrestore(&info->port.lock, flags);
43206 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43207 unsigned short new_crctype;
43208
43209 /* return error if TTY interface open */
43210 - if (info->port.count)
43211 + if (atomic_read(&info->port.count))
43212 return -EBUSY;
43213
43214 switch (encoding)
43215 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
43216
43217 /* arbitrate between network and tty opens */
43218 spin_lock_irqsave(&info->netlock, flags);
43219 - if (info->port.count != 0 || info->netcount != 0) {
43220 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43221 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43222 spin_unlock_irqrestore(&info->netlock, flags);
43223 return -EBUSY;
43224 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43225 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43226
43227 /* return error if TTY interface open */
43228 - if (info->port.count)
43229 + if (atomic_read(&info->port.count))
43230 return -EBUSY;
43231
43232 if (cmd != SIOCWANDEV)
43233 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
43234 * do not request bottom half processing if the
43235 * device is not open in a normal mode.
43236 */
43237 - if ( port && (port->port.count || port->netcount) &&
43238 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
43239 port->pending_bh && !port->bh_running &&
43240 !port->bh_requested ) {
43241 if ( debug_level >= DEBUG_LEVEL_ISR )
43242 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43243
43244 if (debug_level >= DEBUG_LEVEL_INFO)
43245 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
43246 - __FILE__,__LINE__, tty->driver->name, port->count );
43247 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43248
43249 spin_lock_irqsave(&info->lock, flags);
43250 if (!tty_hung_up_p(filp)) {
43251 extra_count = true;
43252 - port->count--;
43253 + atomic_dec(&port->count);
43254 }
43255 spin_unlock_irqrestore(&info->lock, flags);
43256 port->blocked_open++;
43257 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43258
43259 if (debug_level >= DEBUG_LEVEL_INFO)
43260 printk("%s(%d):%s block_til_ready() count=%d\n",
43261 - __FILE__,__LINE__, tty->driver->name, port->count );
43262 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43263
43264 tty_unlock(tty);
43265 schedule();
43266 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43267 remove_wait_queue(&port->open_wait, &wait);
43268
43269 if (extra_count)
43270 - port->count++;
43271 + atomic_inc(&port->count);
43272 port->blocked_open--;
43273
43274 if (debug_level >= DEBUG_LEVEL_INFO)
43275 printk("%s(%d):%s block_til_ready() after, count=%d\n",
43276 - __FILE__,__LINE__, tty->driver->name, port->count );
43277 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43278
43279 if (!retval)
43280 port->flags |= ASYNC_NORMAL_ACTIVE;
43281 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
43282 index 3687f0c..6b9b808 100644
43283 --- a/drivers/tty/sysrq.c
43284 +++ b/drivers/tty/sysrq.c
43285 @@ -995,7 +995,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
43286 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
43287 size_t count, loff_t *ppos)
43288 {
43289 - if (count) {
43290 + if (count && capable(CAP_SYS_ADMIN)) {
43291 char c;
43292
43293 if (get_user(c, buf))
43294 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
43295 index a9cd0b9..47b9336 100644
43296 --- a/drivers/tty/tty_io.c
43297 +++ b/drivers/tty/tty_io.c
43298 @@ -3398,7 +3398,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
43299
43300 void tty_default_fops(struct file_operations *fops)
43301 {
43302 - *fops = tty_fops;
43303 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
43304 }
43305
43306 /*
43307 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
43308 index d794087..e4f49e5 100644
43309 --- a/drivers/tty/tty_ldisc.c
43310 +++ b/drivers/tty/tty_ldisc.c
43311 @@ -56,7 +56,7 @@ static void put_ldisc(struct tty_ldisc *ld)
43312 if (atomic_dec_and_test(&ld->users)) {
43313 struct tty_ldisc_ops *ldo = ld->ops;
43314
43315 - ldo->refcount--;
43316 + atomic_dec(&ldo->refcount);
43317 module_put(ldo->owner);
43318 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43319
43320 @@ -93,7 +93,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
43321 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43322 tty_ldiscs[disc] = new_ldisc;
43323 new_ldisc->num = disc;
43324 - new_ldisc->refcount = 0;
43325 + atomic_set(&new_ldisc->refcount, 0);
43326 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43327
43328 return ret;
43329 @@ -121,7 +121,7 @@ int tty_unregister_ldisc(int disc)
43330 return -EINVAL;
43331
43332 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43333 - if (tty_ldiscs[disc]->refcount)
43334 + if (atomic_read(&tty_ldiscs[disc]->refcount))
43335 ret = -EBUSY;
43336 else
43337 tty_ldiscs[disc] = NULL;
43338 @@ -142,7 +142,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
43339 if (ldops) {
43340 ret = ERR_PTR(-EAGAIN);
43341 if (try_module_get(ldops->owner)) {
43342 - ldops->refcount++;
43343 + atomic_inc(&ldops->refcount);
43344 ret = ldops;
43345 }
43346 }
43347 @@ -155,7 +155,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
43348 unsigned long flags;
43349
43350 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43351 - ldops->refcount--;
43352 + atomic_dec(&ldops->refcount);
43353 module_put(ldops->owner);
43354 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43355 }
43356 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
43357 index b7ff59d..7c6105e 100644
43358 --- a/drivers/tty/tty_port.c
43359 +++ b/drivers/tty/tty_port.c
43360 @@ -218,7 +218,7 @@ void tty_port_hangup(struct tty_port *port)
43361 unsigned long flags;
43362
43363 spin_lock_irqsave(&port->lock, flags);
43364 - port->count = 0;
43365 + atomic_set(&port->count, 0);
43366 port->flags &= ~ASYNC_NORMAL_ACTIVE;
43367 if (port->tty) {
43368 set_bit(TTY_IO_ERROR, &port->tty->flags);
43369 @@ -344,7 +344,7 @@ int tty_port_block_til_ready(struct tty_port *port,
43370 /* The port lock protects the port counts */
43371 spin_lock_irqsave(&port->lock, flags);
43372 if (!tty_hung_up_p(filp))
43373 - port->count--;
43374 + atomic_dec(&port->count);
43375 port->blocked_open++;
43376 spin_unlock_irqrestore(&port->lock, flags);
43377
43378 @@ -386,7 +386,7 @@ int tty_port_block_til_ready(struct tty_port *port,
43379 we must not mess that up further */
43380 spin_lock_irqsave(&port->lock, flags);
43381 if (!tty_hung_up_p(filp))
43382 - port->count++;
43383 + atomic_inc(&port->count);
43384 port->blocked_open--;
43385 if (retval == 0)
43386 port->flags |= ASYNC_NORMAL_ACTIVE;
43387 @@ -406,19 +406,19 @@ int tty_port_close_start(struct tty_port *port,
43388 return 0;
43389 }
43390
43391 - if (tty->count == 1 && port->count != 1) {
43392 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
43393 printk(KERN_WARNING
43394 "tty_port_close_start: tty->count = 1 port count = %d.\n",
43395 - port->count);
43396 - port->count = 1;
43397 + atomic_read(&port->count));
43398 + atomic_set(&port->count, 1);
43399 }
43400 - if (--port->count < 0) {
43401 + if (atomic_dec_return(&port->count) < 0) {
43402 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
43403 - port->count);
43404 - port->count = 0;
43405 + atomic_read(&port->count));
43406 + atomic_set(&port->count, 0);
43407 }
43408
43409 - if (port->count) {
43410 + if (atomic_read(&port->count)) {
43411 spin_unlock_irqrestore(&port->lock, flags);
43412 if (port->ops->drop)
43413 port->ops->drop(port);
43414 @@ -516,7 +516,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
43415 {
43416 spin_lock_irq(&port->lock);
43417 if (!tty_hung_up_p(filp))
43418 - ++port->count;
43419 + atomic_inc(&port->count);
43420 spin_unlock_irq(&port->lock);
43421 tty_port_tty_set(port, tty);
43422
43423 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
43424 index a9af1b9a..1e08e7f 100644
43425 --- a/drivers/tty/vt/keyboard.c
43426 +++ b/drivers/tty/vt/keyboard.c
43427 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
43428 kbd->kbdmode == VC_OFF) &&
43429 value != KVAL(K_SAK))
43430 return; /* SAK is allowed even in raw mode */
43431 +
43432 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
43433 + {
43434 + void *func = fn_handler[value];
43435 + if (func == fn_show_state || func == fn_show_ptregs ||
43436 + func == fn_show_mem)
43437 + return;
43438 + }
43439 +#endif
43440 +
43441 fn_handler[value](vc);
43442 }
43443
43444 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
43445 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
43446 return -EFAULT;
43447
43448 - if (!capable(CAP_SYS_TTY_CONFIG))
43449 - perm = 0;
43450 -
43451 switch (cmd) {
43452 case KDGKBENT:
43453 /* Ensure another thread doesn't free it under us */
43454 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
43455 spin_unlock_irqrestore(&kbd_event_lock, flags);
43456 return put_user(val, &user_kbe->kb_value);
43457 case KDSKBENT:
43458 + if (!capable(CAP_SYS_TTY_CONFIG))
43459 + perm = 0;
43460 +
43461 if (!perm)
43462 return -EPERM;
43463 if (!i && v == K_NOSUCHMAP) {
43464 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
43465 int i, j, k;
43466 int ret;
43467
43468 - if (!capable(CAP_SYS_TTY_CONFIG))
43469 - perm = 0;
43470 -
43471 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
43472 if (!kbs) {
43473 ret = -ENOMEM;
43474 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
43475 kfree(kbs);
43476 return ((p && *p) ? -EOVERFLOW : 0);
43477 case KDSKBSENT:
43478 + if (!capable(CAP_SYS_TTY_CONFIG))
43479 + perm = 0;
43480 +
43481 if (!perm) {
43482 ret = -EPERM;
43483 goto reterr;
43484 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
43485 index c8b9262..7e824e6 100644
43486 --- a/drivers/uio/uio.c
43487 +++ b/drivers/uio/uio.c
43488 @@ -25,6 +25,7 @@
43489 #include <linux/kobject.h>
43490 #include <linux/cdev.h>
43491 #include <linux/uio_driver.h>
43492 +#include <asm/local.h>
43493
43494 #define UIO_MAX_DEVICES (1U << MINORBITS)
43495
43496 @@ -32,10 +33,10 @@ struct uio_device {
43497 struct module *owner;
43498 struct device *dev;
43499 int minor;
43500 - atomic_t event;
43501 + atomic_unchecked_t event;
43502 struct fasync_struct *async_queue;
43503 wait_queue_head_t wait;
43504 - int vma_count;
43505 + local_t vma_count;
43506 struct uio_info *info;
43507 struct kobject *map_dir;
43508 struct kobject *portio_dir;
43509 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
43510 struct device_attribute *attr, char *buf)
43511 {
43512 struct uio_device *idev = dev_get_drvdata(dev);
43513 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
43514 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
43515 }
43516
43517 static struct device_attribute uio_class_attributes[] = {
43518 @@ -397,7 +398,7 @@ void uio_event_notify(struct uio_info *info)
43519 {
43520 struct uio_device *idev = info->uio_dev;
43521
43522 - atomic_inc(&idev->event);
43523 + atomic_inc_unchecked(&idev->event);
43524 wake_up_interruptible(&idev->wait);
43525 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
43526 }
43527 @@ -450,7 +451,7 @@ static int uio_open(struct inode *inode, struct file *filep)
43528 }
43529
43530 listener->dev = idev;
43531 - listener->event_count = atomic_read(&idev->event);
43532 + listener->event_count = atomic_read_unchecked(&idev->event);
43533 filep->private_data = listener;
43534
43535 if (idev->info->open) {
43536 @@ -501,7 +502,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
43537 return -EIO;
43538
43539 poll_wait(filep, &idev->wait, wait);
43540 - if (listener->event_count != atomic_read(&idev->event))
43541 + if (listener->event_count != atomic_read_unchecked(&idev->event))
43542 return POLLIN | POLLRDNORM;
43543 return 0;
43544 }
43545 @@ -526,7 +527,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
43546 do {
43547 set_current_state(TASK_INTERRUPTIBLE);
43548
43549 - event_count = atomic_read(&idev->event);
43550 + event_count = atomic_read_unchecked(&idev->event);
43551 if (event_count != listener->event_count) {
43552 if (copy_to_user(buf, &event_count, count))
43553 retval = -EFAULT;
43554 @@ -595,13 +596,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
43555 static void uio_vma_open(struct vm_area_struct *vma)
43556 {
43557 struct uio_device *idev = vma->vm_private_data;
43558 - idev->vma_count++;
43559 + local_inc(&idev->vma_count);
43560 }
43561
43562 static void uio_vma_close(struct vm_area_struct *vma)
43563 {
43564 struct uio_device *idev = vma->vm_private_data;
43565 - idev->vma_count--;
43566 + local_dec(&idev->vma_count);
43567 }
43568
43569 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
43570 @@ -808,7 +809,7 @@ int __uio_register_device(struct module *owner,
43571 idev->owner = owner;
43572 idev->info = info;
43573 init_waitqueue_head(&idev->wait);
43574 - atomic_set(&idev->event, 0);
43575 + atomic_set_unchecked(&idev->event, 0);
43576
43577 ret = uio_get_minor(idev);
43578 if (ret)
43579 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
43580 index b7eb86a..36d28af 100644
43581 --- a/drivers/usb/atm/cxacru.c
43582 +++ b/drivers/usb/atm/cxacru.c
43583 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
43584 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
43585 if (ret < 2)
43586 return -EINVAL;
43587 - if (index < 0 || index > 0x7f)
43588 + if (index > 0x7f)
43589 return -EINVAL;
43590 pos += tmp;
43591
43592 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
43593 index 35f10bf..6a38a0b 100644
43594 --- a/drivers/usb/atm/usbatm.c
43595 +++ b/drivers/usb/atm/usbatm.c
43596 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43597 if (printk_ratelimit())
43598 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
43599 __func__, vpi, vci);
43600 - atomic_inc(&vcc->stats->rx_err);
43601 + atomic_inc_unchecked(&vcc->stats->rx_err);
43602 return;
43603 }
43604
43605 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43606 if (length > ATM_MAX_AAL5_PDU) {
43607 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
43608 __func__, length, vcc);
43609 - atomic_inc(&vcc->stats->rx_err);
43610 + atomic_inc_unchecked(&vcc->stats->rx_err);
43611 goto out;
43612 }
43613
43614 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43615 if (sarb->len < pdu_length) {
43616 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
43617 __func__, pdu_length, sarb->len, vcc);
43618 - atomic_inc(&vcc->stats->rx_err);
43619 + atomic_inc_unchecked(&vcc->stats->rx_err);
43620 goto out;
43621 }
43622
43623 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
43624 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
43625 __func__, vcc);
43626 - atomic_inc(&vcc->stats->rx_err);
43627 + atomic_inc_unchecked(&vcc->stats->rx_err);
43628 goto out;
43629 }
43630
43631 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43632 if (printk_ratelimit())
43633 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
43634 __func__, length);
43635 - atomic_inc(&vcc->stats->rx_drop);
43636 + atomic_inc_unchecked(&vcc->stats->rx_drop);
43637 goto out;
43638 }
43639
43640 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
43641
43642 vcc->push(vcc, skb);
43643
43644 - atomic_inc(&vcc->stats->rx);
43645 + atomic_inc_unchecked(&vcc->stats->rx);
43646 out:
43647 skb_trim(sarb, 0);
43648 }
43649 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
43650 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
43651
43652 usbatm_pop(vcc, skb);
43653 - atomic_inc(&vcc->stats->tx);
43654 + atomic_inc_unchecked(&vcc->stats->tx);
43655
43656 skb = skb_dequeue(&instance->sndqueue);
43657 }
43658 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
43659 if (!left--)
43660 return sprintf(page,
43661 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
43662 - atomic_read(&atm_dev->stats.aal5.tx),
43663 - atomic_read(&atm_dev->stats.aal5.tx_err),
43664 - atomic_read(&atm_dev->stats.aal5.rx),
43665 - atomic_read(&atm_dev->stats.aal5.rx_err),
43666 - atomic_read(&atm_dev->stats.aal5.rx_drop));
43667 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
43668 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
43669 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
43670 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
43671 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
43672
43673 if (!left--) {
43674 if (instance->disconnected)
43675 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
43676 index 2a3bbdf..91d72cf 100644
43677 --- a/drivers/usb/core/devices.c
43678 +++ b/drivers/usb/core/devices.c
43679 @@ -126,7 +126,7 @@ static const char format_endpt[] =
43680 * time it gets called.
43681 */
43682 static struct device_connect_event {
43683 - atomic_t count;
43684 + atomic_unchecked_t count;
43685 wait_queue_head_t wait;
43686 } device_event = {
43687 .count = ATOMIC_INIT(1),
43688 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
43689
43690 void usbfs_conn_disc_event(void)
43691 {
43692 - atomic_add(2, &device_event.count);
43693 + atomic_add_unchecked(2, &device_event.count);
43694 wake_up(&device_event.wait);
43695 }
43696
43697 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
43698
43699 poll_wait(file, &device_event.wait, wait);
43700
43701 - event_count = atomic_read(&device_event.count);
43702 + event_count = atomic_read_unchecked(&device_event.count);
43703 if (file->f_version != event_count) {
43704 file->f_version = event_count;
43705 return POLLIN | POLLRDNORM;
43706 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
43707 index f9ec44c..eb5779f 100644
43708 --- a/drivers/usb/core/hcd.c
43709 +++ b/drivers/usb/core/hcd.c
43710 @@ -1526,7 +1526,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
43711 */
43712 usb_get_urb(urb);
43713 atomic_inc(&urb->use_count);
43714 - atomic_inc(&urb->dev->urbnum);
43715 + atomic_inc_unchecked(&urb->dev->urbnum);
43716 usbmon_urb_submit(&hcd->self, urb);
43717
43718 /* NOTE requirements on root-hub callers (usbfs and the hub
43719 @@ -1553,7 +1553,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
43720 urb->hcpriv = NULL;
43721 INIT_LIST_HEAD(&urb->urb_list);
43722 atomic_dec(&urb->use_count);
43723 - atomic_dec(&urb->dev->urbnum);
43724 + atomic_dec_unchecked(&urb->dev->urbnum);
43725 if (atomic_read(&urb->reject))
43726 wake_up(&usb_kill_urb_queue);
43727 usb_put_urb(urb);
43728 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
43729 index 444d30e..f15c850 100644
43730 --- a/drivers/usb/core/message.c
43731 +++ b/drivers/usb/core/message.c
43732 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
43733 * method can wait for it to complete. Since you don't have a handle on the
43734 * URB used, you can't cancel the request.
43735 */
43736 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
43737 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
43738 __u8 requesttype, __u16 value, __u16 index, void *data,
43739 __u16 size, int timeout)
43740 {
43741 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
43742 index 3f81a3d..a3aa993 100644
43743 --- a/drivers/usb/core/sysfs.c
43744 +++ b/drivers/usb/core/sysfs.c
43745 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
43746 struct usb_device *udev;
43747
43748 udev = to_usb_device(dev);
43749 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
43750 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
43751 }
43752 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
43753
43754 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
43755 index f81b925..78d22ec 100644
43756 --- a/drivers/usb/core/usb.c
43757 +++ b/drivers/usb/core/usb.c
43758 @@ -388,7 +388,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
43759 set_dev_node(&dev->dev, dev_to_node(bus->controller));
43760 dev->state = USB_STATE_ATTACHED;
43761 dev->lpm_disable_count = 1;
43762 - atomic_set(&dev->urbnum, 0);
43763 + atomic_set_unchecked(&dev->urbnum, 0);
43764
43765 INIT_LIST_HEAD(&dev->ep0.urb_list);
43766 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
43767 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
43768 index 5e29dde..eca992f 100644
43769 --- a/drivers/usb/early/ehci-dbgp.c
43770 +++ b/drivers/usb/early/ehci-dbgp.c
43771 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
43772
43773 #ifdef CONFIG_KGDB
43774 static struct kgdb_io kgdbdbgp_io_ops;
43775 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
43776 +static struct kgdb_io kgdbdbgp_io_ops_console;
43777 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
43778 #else
43779 #define dbgp_kgdb_mode (0)
43780 #endif
43781 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
43782 .write_char = kgdbdbgp_write_char,
43783 };
43784
43785 +static struct kgdb_io kgdbdbgp_io_ops_console = {
43786 + .name = "kgdbdbgp",
43787 + .read_char = kgdbdbgp_read_char,
43788 + .write_char = kgdbdbgp_write_char,
43789 + .is_console = 1
43790 +};
43791 +
43792 static int kgdbdbgp_wait_time;
43793
43794 static int __init kgdbdbgp_parse_config(char *str)
43795 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
43796 ptr++;
43797 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
43798 }
43799 - kgdb_register_io_module(&kgdbdbgp_io_ops);
43800 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
43801 + if (early_dbgp_console.index != -1)
43802 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
43803 + else
43804 + kgdb_register_io_module(&kgdbdbgp_io_ops);
43805
43806 return 0;
43807 }
43808 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
43809 index b369292..9f3ba40 100644
43810 --- a/drivers/usb/gadget/u_serial.c
43811 +++ b/drivers/usb/gadget/u_serial.c
43812 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
43813 spin_lock_irq(&port->port_lock);
43814
43815 /* already open? Great. */
43816 - if (port->port.count) {
43817 + if (atomic_read(&port->port.count)) {
43818 status = 0;
43819 - port->port.count++;
43820 + atomic_inc(&port->port.count);
43821
43822 /* currently opening/closing? wait ... */
43823 } else if (port->openclose) {
43824 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
43825 tty->driver_data = port;
43826 port->port.tty = tty;
43827
43828 - port->port.count = 1;
43829 + atomic_set(&port->port.count, 1);
43830 port->openclose = false;
43831
43832 /* if connected, start the I/O stream */
43833 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
43834
43835 spin_lock_irq(&port->port_lock);
43836
43837 - if (port->port.count != 1) {
43838 - if (port->port.count == 0)
43839 + if (atomic_read(&port->port.count) != 1) {
43840 + if (atomic_read(&port->port.count) == 0)
43841 WARN_ON(1);
43842 else
43843 - --port->port.count;
43844 + atomic_dec(&port->port.count);
43845 goto exit;
43846 }
43847
43848 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
43849 * and sleep if necessary
43850 */
43851 port->openclose = true;
43852 - port->port.count = 0;
43853 + atomic_set(&port->port.count, 0);
43854
43855 gser = port->port_usb;
43856 if (gser && gser->disconnect)
43857 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
43858 int cond;
43859
43860 spin_lock_irq(&port->port_lock);
43861 - cond = (port->port.count == 0) && !port->openclose;
43862 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
43863 spin_unlock_irq(&port->port_lock);
43864 return cond;
43865 }
43866 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
43867 /* if it's already open, start I/O ... and notify the serial
43868 * protocol about open/close status (connect/disconnect).
43869 */
43870 - if (port->port.count) {
43871 + if (atomic_read(&port->port.count)) {
43872 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
43873 gs_start_io(port);
43874 if (gser->connect)
43875 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
43876
43877 port->port_usb = NULL;
43878 gser->ioport = NULL;
43879 - if (port->port.count > 0 || port->openclose) {
43880 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
43881 wake_up_interruptible(&port->drain_wait);
43882 if (port->port.tty)
43883 tty_hangup(port->port.tty);
43884 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
43885
43886 /* finally, free any unused/unusable I/O buffers */
43887 spin_lock_irqsave(&port->port_lock, flags);
43888 - if (port->port.count == 0 && !port->openclose)
43889 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
43890 gs_buf_free(&port->port_write_buf);
43891 gs_free_requests(gser->out, &port->read_pool, NULL);
43892 gs_free_requests(gser->out, &port->read_queue, NULL);
43893 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
43894 index 5f3bcd3..bfca43f 100644
43895 --- a/drivers/usb/serial/console.c
43896 +++ b/drivers/usb/serial/console.c
43897 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
43898
43899 info->port = port;
43900
43901 - ++port->port.count;
43902 + atomic_inc(&port->port.count);
43903 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
43904 if (serial->type->set_termios) {
43905 /*
43906 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
43907 }
43908 /* Now that any required fake tty operations are completed restore
43909 * the tty port count */
43910 - --port->port.count;
43911 + atomic_dec(&port->port.count);
43912 /* The console is special in terms of closing the device so
43913 * indicate this port is now acting as a system console. */
43914 port->port.console = 1;
43915 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
43916 free_tty:
43917 kfree(tty);
43918 reset_open_count:
43919 - port->port.count = 0;
43920 + atomic_set(&port->port.count, 0);
43921 usb_autopm_put_interface(serial->interface);
43922 error_get_interface:
43923 usb_serial_put(serial);
43924 diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
43925 index 6c3586a..a94e621 100644
43926 --- a/drivers/usb/storage/realtek_cr.c
43927 +++ b/drivers/usb/storage/realtek_cr.c
43928 @@ -429,7 +429,7 @@ static int rts51x_read_status(struct us_data *us,
43929
43930 buf = kmalloc(len, GFP_NOIO);
43931 if (buf == NULL)
43932 - return USB_STOR_TRANSPORT_ERROR;
43933 + return -ENOMEM;
43934
43935 US_DEBUGP("%s, lun = %d\n", __func__, lun);
43936
43937 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
43938 index 75f70f0..d467e1a 100644
43939 --- a/drivers/usb/storage/usb.h
43940 +++ b/drivers/usb/storage/usb.h
43941 @@ -63,7 +63,7 @@ struct us_unusual_dev {
43942 __u8 useProtocol;
43943 __u8 useTransport;
43944 int (*initFunction)(struct us_data *);
43945 -};
43946 +} __do_const;
43947
43948
43949 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
43950 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
43951 index d6bea3e..60b250e 100644
43952 --- a/drivers/usb/wusbcore/wa-hc.h
43953 +++ b/drivers/usb/wusbcore/wa-hc.h
43954 @@ -192,7 +192,7 @@ struct wahc {
43955 struct list_head xfer_delayed_list;
43956 spinlock_t xfer_list_lock;
43957 struct work_struct xfer_work;
43958 - atomic_t xfer_id_count;
43959 + atomic_unchecked_t xfer_id_count;
43960 };
43961
43962
43963 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
43964 INIT_LIST_HEAD(&wa->xfer_delayed_list);
43965 spin_lock_init(&wa->xfer_list_lock);
43966 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
43967 - atomic_set(&wa->xfer_id_count, 1);
43968 + atomic_set_unchecked(&wa->xfer_id_count, 1);
43969 }
43970
43971 /**
43972 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
43973 index 6ef94bc..1b41265 100644
43974 --- a/drivers/usb/wusbcore/wa-xfer.c
43975 +++ b/drivers/usb/wusbcore/wa-xfer.c
43976 @@ -296,7 +296,7 @@ out:
43977 */
43978 static void wa_xfer_id_init(struct wa_xfer *xfer)
43979 {
43980 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
43981 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
43982 }
43983
43984 /*
43985 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
43986 index 8c55011..eed4ae1a 100644
43987 --- a/drivers/video/aty/aty128fb.c
43988 +++ b/drivers/video/aty/aty128fb.c
43989 @@ -149,7 +149,7 @@ enum {
43990 };
43991
43992 /* Must match above enum */
43993 -static char * const r128_family[] = {
43994 +static const char * const r128_family[] = {
43995 "AGP",
43996 "PCI",
43997 "PRO AGP",
43998 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
43999 index 4f27fdc..d3537e6 100644
44000 --- a/drivers/video/aty/atyfb_base.c
44001 +++ b/drivers/video/aty/atyfb_base.c
44002 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
44003 par->accel_flags = var->accel_flags; /* hack */
44004
44005 if (var->accel_flags) {
44006 - info->fbops->fb_sync = atyfb_sync;
44007 + pax_open_kernel();
44008 + *(void **)&info->fbops->fb_sync = atyfb_sync;
44009 + pax_close_kernel();
44010 info->flags &= ~FBINFO_HWACCEL_DISABLED;
44011 } else {
44012 - info->fbops->fb_sync = NULL;
44013 + pax_open_kernel();
44014 + *(void **)&info->fbops->fb_sync = NULL;
44015 + pax_close_kernel();
44016 info->flags |= FBINFO_HWACCEL_DISABLED;
44017 }
44018
44019 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
44020 index 95ec042..e6affdd 100644
44021 --- a/drivers/video/aty/mach64_cursor.c
44022 +++ b/drivers/video/aty/mach64_cursor.c
44023 @@ -7,6 +7,7 @@
44024 #include <linux/string.h>
44025
44026 #include <asm/io.h>
44027 +#include <asm/pgtable.h>
44028
44029 #ifdef __sparc__
44030 #include <asm/fbio.h>
44031 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
44032 info->sprite.buf_align = 16; /* and 64 lines tall. */
44033 info->sprite.flags = FB_PIXMAP_IO;
44034
44035 - info->fbops->fb_cursor = atyfb_cursor;
44036 + pax_open_kernel();
44037 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
44038 + pax_close_kernel();
44039
44040 return 0;
44041 }
44042 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
44043 index 6c5ed6b..b727c88 100644
44044 --- a/drivers/video/backlight/kb3886_bl.c
44045 +++ b/drivers/video/backlight/kb3886_bl.c
44046 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
44047 static unsigned long kb3886bl_flags;
44048 #define KB3886BL_SUSPENDED 0x01
44049
44050 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
44051 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
44052 {
44053 .ident = "Sahara Touch-iT",
44054 .matches = {
44055 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
44056 index 900aa4e..6d49418 100644
44057 --- a/drivers/video/fb_defio.c
44058 +++ b/drivers/video/fb_defio.c
44059 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
44060
44061 BUG_ON(!fbdefio);
44062 mutex_init(&fbdefio->lock);
44063 - info->fbops->fb_mmap = fb_deferred_io_mmap;
44064 + pax_open_kernel();
44065 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
44066 + pax_close_kernel();
44067 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
44068 INIT_LIST_HEAD(&fbdefio->pagelist);
44069 if (fbdefio->delay == 0) /* set a default of 1 s */
44070 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
44071 page->mapping = NULL;
44072 }
44073
44074 - info->fbops->fb_mmap = NULL;
44075 + *(void **)&info->fbops->fb_mmap = NULL;
44076 mutex_destroy(&fbdefio->lock);
44077 }
44078 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
44079 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
44080 index 5c3960d..15cf8fc 100644
44081 --- a/drivers/video/fbcmap.c
44082 +++ b/drivers/video/fbcmap.c
44083 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
44084 rc = -ENODEV;
44085 goto out;
44086 }
44087 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
44088 - !info->fbops->fb_setcmap)) {
44089 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
44090 rc = -EINVAL;
44091 goto out1;
44092 }
44093 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
44094 index 86291dc..7cc5962 100644
44095 --- a/drivers/video/fbmem.c
44096 +++ b/drivers/video/fbmem.c
44097 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44098 image->dx += image->width + 8;
44099 }
44100 } else if (rotate == FB_ROTATE_UD) {
44101 - for (x = 0; x < num && image->dx >= 0; x++) {
44102 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
44103 info->fbops->fb_imageblit(info, image);
44104 image->dx -= image->width + 8;
44105 }
44106 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44107 image->dy += image->height + 8;
44108 }
44109 } else if (rotate == FB_ROTATE_CCW) {
44110 - for (x = 0; x < num && image->dy >= 0; x++) {
44111 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
44112 info->fbops->fb_imageblit(info, image);
44113 image->dy -= image->height + 8;
44114 }
44115 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
44116 return -EFAULT;
44117 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
44118 return -EINVAL;
44119 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
44120 + if (con2fb.framebuffer >= FB_MAX)
44121 return -EINVAL;
44122 if (!registered_fb[con2fb.framebuffer])
44123 request_module("fb%d", con2fb.framebuffer);
44124 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
44125 index 7672d2e..b56437f 100644
44126 --- a/drivers/video/i810/i810_accel.c
44127 +++ b/drivers/video/i810/i810_accel.c
44128 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
44129 }
44130 }
44131 printk("ringbuffer lockup!!!\n");
44132 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
44133 i810_report_error(mmio);
44134 par->dev_flags |= LOCKUP;
44135 info->pixmap.scan_align = 1;
44136 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
44137 index 3c14e43..eafa544 100644
44138 --- a/drivers/video/logo/logo_linux_clut224.ppm
44139 +++ b/drivers/video/logo/logo_linux_clut224.ppm
44140 @@ -1,1604 +1,1123 @@
44141 P3
44142 -# Standard 224-color Linux logo
44143 80 80
44144 255
44145 - 0 0 0 0 0 0 0 0 0 0 0 0
44146 - 0 0 0 0 0 0 0 0 0 0 0 0
44147 - 0 0 0 0 0 0 0 0 0 0 0 0
44148 - 0 0 0 0 0 0 0 0 0 0 0 0
44149 - 0 0 0 0 0 0 0 0 0 0 0 0
44150 - 0 0 0 0 0 0 0 0 0 0 0 0
44151 - 0 0 0 0 0 0 0 0 0 0 0 0
44152 - 0 0 0 0 0 0 0 0 0 0 0 0
44153 - 0 0 0 0 0 0 0 0 0 0 0 0
44154 - 6 6 6 6 6 6 10 10 10 10 10 10
44155 - 10 10 10 6 6 6 6 6 6 6 6 6
44156 - 0 0 0 0 0 0 0 0 0 0 0 0
44157 - 0 0 0 0 0 0 0 0 0 0 0 0
44158 - 0 0 0 0 0 0 0 0 0 0 0 0
44159 - 0 0 0 0 0 0 0 0 0 0 0 0
44160 - 0 0 0 0 0 0 0 0 0 0 0 0
44161 - 0 0 0 0 0 0 0 0 0 0 0 0
44162 - 0 0 0 0 0 0 0 0 0 0 0 0
44163 - 0 0 0 0 0 0 0 0 0 0 0 0
44164 - 0 0 0 0 0 0 0 0 0 0 0 0
44165 - 0 0 0 0 0 0 0 0 0 0 0 0
44166 - 0 0 0 0 0 0 0 0 0 0 0 0
44167 - 0 0 0 0 0 0 0 0 0 0 0 0
44168 - 0 0 0 0 0 0 0 0 0 0 0 0
44169 - 0 0 0 0 0 0 0 0 0 0 0 0
44170 - 0 0 0 0 0 0 0 0 0 0 0 0
44171 - 0 0 0 0 0 0 0 0 0 0 0 0
44172 - 0 0 0 0 0 0 0 0 0 0 0 0
44173 - 0 0 0 6 6 6 10 10 10 14 14 14
44174 - 22 22 22 26 26 26 30 30 30 34 34 34
44175 - 30 30 30 30 30 30 26 26 26 18 18 18
44176 - 14 14 14 10 10 10 6 6 6 0 0 0
44177 - 0 0 0 0 0 0 0 0 0 0 0 0
44178 - 0 0 0 0 0 0 0 0 0 0 0 0
44179 - 0 0 0 0 0 0 0 0 0 0 0 0
44180 - 0 0 0 0 0 0 0 0 0 0 0 0
44181 - 0 0 0 0 0 0 0 0 0 0 0 0
44182 - 0 0 0 0 0 0 0 0 0 0 0 0
44183 - 0 0 0 0 0 0 0 0 0 0 0 0
44184 - 0 0 0 0 0 0 0 0 0 0 0 0
44185 - 0 0 0 0 0 0 0 0 0 0 0 0
44186 - 0 0 0 0 0 1 0 0 1 0 0 0
44187 - 0 0 0 0 0 0 0 0 0 0 0 0
44188 - 0 0 0 0 0 0 0 0 0 0 0 0
44189 - 0 0 0 0 0 0 0 0 0 0 0 0
44190 - 0 0 0 0 0 0 0 0 0 0 0 0
44191 - 0 0 0 0 0 0 0 0 0 0 0 0
44192 - 0 0 0 0 0 0 0 0 0 0 0 0
44193 - 6 6 6 14 14 14 26 26 26 42 42 42
44194 - 54 54 54 66 66 66 78 78 78 78 78 78
44195 - 78 78 78 74 74 74 66 66 66 54 54 54
44196 - 42 42 42 26 26 26 18 18 18 10 10 10
44197 - 6 6 6 0 0 0 0 0 0 0 0 0
44198 - 0 0 0 0 0 0 0 0 0 0 0 0
44199 - 0 0 0 0 0 0 0 0 0 0 0 0
44200 - 0 0 0 0 0 0 0 0 0 0 0 0
44201 - 0 0 0 0 0 0 0 0 0 0 0 0
44202 - 0 0 0 0 0 0 0 0 0 0 0 0
44203 - 0 0 0 0 0 0 0 0 0 0 0 0
44204 - 0 0 0 0 0 0 0 0 0 0 0 0
44205 - 0 0 0 0 0 0 0 0 0 0 0 0
44206 - 0 0 1 0 0 0 0 0 0 0 0 0
44207 - 0 0 0 0 0 0 0 0 0 0 0 0
44208 - 0 0 0 0 0 0 0 0 0 0 0 0
44209 - 0 0 0 0 0 0 0 0 0 0 0 0
44210 - 0 0 0 0 0 0 0 0 0 0 0 0
44211 - 0 0 0 0 0 0 0 0 0 0 0 0
44212 - 0 0 0 0 0 0 0 0 0 10 10 10
44213 - 22 22 22 42 42 42 66 66 66 86 86 86
44214 - 66 66 66 38 38 38 38 38 38 22 22 22
44215 - 26 26 26 34 34 34 54 54 54 66 66 66
44216 - 86 86 86 70 70 70 46 46 46 26 26 26
44217 - 14 14 14 6 6 6 0 0 0 0 0 0
44218 - 0 0 0 0 0 0 0 0 0 0 0 0
44219 - 0 0 0 0 0 0 0 0 0 0 0 0
44220 - 0 0 0 0 0 0 0 0 0 0 0 0
44221 - 0 0 0 0 0 0 0 0 0 0 0 0
44222 - 0 0 0 0 0 0 0 0 0 0 0 0
44223 - 0 0 0 0 0 0 0 0 0 0 0 0
44224 - 0 0 0 0 0 0 0 0 0 0 0 0
44225 - 0 0 0 0 0 0 0 0 0 0 0 0
44226 - 0 0 1 0 0 1 0 0 1 0 0 0
44227 - 0 0 0 0 0 0 0 0 0 0 0 0
44228 - 0 0 0 0 0 0 0 0 0 0 0 0
44229 - 0 0 0 0 0 0 0 0 0 0 0 0
44230 - 0 0 0 0 0 0 0 0 0 0 0 0
44231 - 0 0 0 0 0 0 0 0 0 0 0 0
44232 - 0 0 0 0 0 0 10 10 10 26 26 26
44233 - 50 50 50 82 82 82 58 58 58 6 6 6
44234 - 2 2 6 2 2 6 2 2 6 2 2 6
44235 - 2 2 6 2 2 6 2 2 6 2 2 6
44236 - 6 6 6 54 54 54 86 86 86 66 66 66
44237 - 38 38 38 18 18 18 6 6 6 0 0 0
44238 - 0 0 0 0 0 0 0 0 0 0 0 0
44239 - 0 0 0 0 0 0 0 0 0 0 0 0
44240 - 0 0 0 0 0 0 0 0 0 0 0 0
44241 - 0 0 0 0 0 0 0 0 0 0 0 0
44242 - 0 0 0 0 0 0 0 0 0 0 0 0
44243 - 0 0 0 0 0 0 0 0 0 0 0 0
44244 - 0 0 0 0 0 0 0 0 0 0 0 0
44245 - 0 0 0 0 0 0 0 0 0 0 0 0
44246 - 0 0 0 0 0 0 0 0 0 0 0 0
44247 - 0 0 0 0 0 0 0 0 0 0 0 0
44248 - 0 0 0 0 0 0 0 0 0 0 0 0
44249 - 0 0 0 0 0 0 0 0 0 0 0 0
44250 - 0 0 0 0 0 0 0 0 0 0 0 0
44251 - 0 0 0 0 0 0 0 0 0 0 0 0
44252 - 0 0 0 6 6 6 22 22 22 50 50 50
44253 - 78 78 78 34 34 34 2 2 6 2 2 6
44254 - 2 2 6 2 2 6 2 2 6 2 2 6
44255 - 2 2 6 2 2 6 2 2 6 2 2 6
44256 - 2 2 6 2 2 6 6 6 6 70 70 70
44257 - 78 78 78 46 46 46 22 22 22 6 6 6
44258 - 0 0 0 0 0 0 0 0 0 0 0 0
44259 - 0 0 0 0 0 0 0 0 0 0 0 0
44260 - 0 0 0 0 0 0 0 0 0 0 0 0
44261 - 0 0 0 0 0 0 0 0 0 0 0 0
44262 - 0 0 0 0 0 0 0 0 0 0 0 0
44263 - 0 0 0 0 0 0 0 0 0 0 0 0
44264 - 0 0 0 0 0 0 0 0 0 0 0 0
44265 - 0 0 0 0 0 0 0 0 0 0 0 0
44266 - 0 0 1 0 0 1 0 0 1 0 0 0
44267 - 0 0 0 0 0 0 0 0 0 0 0 0
44268 - 0 0 0 0 0 0 0 0 0 0 0 0
44269 - 0 0 0 0 0 0 0 0 0 0 0 0
44270 - 0 0 0 0 0 0 0 0 0 0 0 0
44271 - 0 0 0 0 0 0 0 0 0 0 0 0
44272 - 6 6 6 18 18 18 42 42 42 82 82 82
44273 - 26 26 26 2 2 6 2 2 6 2 2 6
44274 - 2 2 6 2 2 6 2 2 6 2 2 6
44275 - 2 2 6 2 2 6 2 2 6 14 14 14
44276 - 46 46 46 34 34 34 6 6 6 2 2 6
44277 - 42 42 42 78 78 78 42 42 42 18 18 18
44278 - 6 6 6 0 0 0 0 0 0 0 0 0
44279 - 0 0 0 0 0 0 0 0 0 0 0 0
44280 - 0 0 0 0 0 0 0 0 0 0 0 0
44281 - 0 0 0 0 0 0 0 0 0 0 0 0
44282 - 0 0 0 0 0 0 0 0 0 0 0 0
44283 - 0 0 0 0 0 0 0 0 0 0 0 0
44284 - 0 0 0 0 0 0 0 0 0 0 0 0
44285 - 0 0 0 0 0 0 0 0 0 0 0 0
44286 - 0 0 1 0 0 0 0 0 1 0 0 0
44287 - 0 0 0 0 0 0 0 0 0 0 0 0
44288 - 0 0 0 0 0 0 0 0 0 0 0 0
44289 - 0 0 0 0 0 0 0 0 0 0 0 0
44290 - 0 0 0 0 0 0 0 0 0 0 0 0
44291 - 0 0 0 0 0 0 0 0 0 0 0 0
44292 - 10 10 10 30 30 30 66 66 66 58 58 58
44293 - 2 2 6 2 2 6 2 2 6 2 2 6
44294 - 2 2 6 2 2 6 2 2 6 2 2 6
44295 - 2 2 6 2 2 6 2 2 6 26 26 26
44296 - 86 86 86 101 101 101 46 46 46 10 10 10
44297 - 2 2 6 58 58 58 70 70 70 34 34 34
44298 - 10 10 10 0 0 0 0 0 0 0 0 0
44299 - 0 0 0 0 0 0 0 0 0 0 0 0
44300 - 0 0 0 0 0 0 0 0 0 0 0 0
44301 - 0 0 0 0 0 0 0 0 0 0 0 0
44302 - 0 0 0 0 0 0 0 0 0 0 0 0
44303 - 0 0 0 0 0 0 0 0 0 0 0 0
44304 - 0 0 0 0 0 0 0 0 0 0 0 0
44305 - 0 0 0 0 0 0 0 0 0 0 0 0
44306 - 0 0 1 0 0 1 0 0 1 0 0 0
44307 - 0 0 0 0 0 0 0 0 0 0 0 0
44308 - 0 0 0 0 0 0 0 0 0 0 0 0
44309 - 0 0 0 0 0 0 0 0 0 0 0 0
44310 - 0 0 0 0 0 0 0 0 0 0 0 0
44311 - 0 0 0 0 0 0 0 0 0 0 0 0
44312 - 14 14 14 42 42 42 86 86 86 10 10 10
44313 - 2 2 6 2 2 6 2 2 6 2 2 6
44314 - 2 2 6 2 2 6 2 2 6 2 2 6
44315 - 2 2 6 2 2 6 2 2 6 30 30 30
44316 - 94 94 94 94 94 94 58 58 58 26 26 26
44317 - 2 2 6 6 6 6 78 78 78 54 54 54
44318 - 22 22 22 6 6 6 0 0 0 0 0 0
44319 - 0 0 0 0 0 0 0 0 0 0 0 0
44320 - 0 0 0 0 0 0 0 0 0 0 0 0
44321 - 0 0 0 0 0 0 0 0 0 0 0 0
44322 - 0 0 0 0 0 0 0 0 0 0 0 0
44323 - 0 0 0 0 0 0 0 0 0 0 0 0
44324 - 0 0 0 0 0 0 0 0 0 0 0 0
44325 - 0 0 0 0 0 0 0 0 0 0 0 0
44326 - 0 0 0 0 0 0 0 0 0 0 0 0
44327 - 0 0 0 0 0 0 0 0 0 0 0 0
44328 - 0 0 0 0 0 0 0 0 0 0 0 0
44329 - 0 0 0 0 0 0 0 0 0 0 0 0
44330 - 0 0 0 0 0 0 0 0 0 0 0 0
44331 - 0 0 0 0 0 0 0 0 0 6 6 6
44332 - 22 22 22 62 62 62 62 62 62 2 2 6
44333 - 2 2 6 2 2 6 2 2 6 2 2 6
44334 - 2 2 6 2 2 6 2 2 6 2 2 6
44335 - 2 2 6 2 2 6 2 2 6 26 26 26
44336 - 54 54 54 38 38 38 18 18 18 10 10 10
44337 - 2 2 6 2 2 6 34 34 34 82 82 82
44338 - 38 38 38 14 14 14 0 0 0 0 0 0
44339 - 0 0 0 0 0 0 0 0 0 0 0 0
44340 - 0 0 0 0 0 0 0 0 0 0 0 0
44341 - 0 0 0 0 0 0 0 0 0 0 0 0
44342 - 0 0 0 0 0 0 0 0 0 0 0 0
44343 - 0 0 0 0 0 0 0 0 0 0 0 0
44344 - 0 0 0 0 0 0 0 0 0 0 0 0
44345 - 0 0 0 0 0 0 0 0 0 0 0 0
44346 - 0 0 0 0 0 1 0 0 1 0 0 0
44347 - 0 0 0 0 0 0 0 0 0 0 0 0
44348 - 0 0 0 0 0 0 0 0 0 0 0 0
44349 - 0 0 0 0 0 0 0 0 0 0 0 0
44350 - 0 0 0 0 0 0 0 0 0 0 0 0
44351 - 0 0 0 0 0 0 0 0 0 6 6 6
44352 - 30 30 30 78 78 78 30 30 30 2 2 6
44353 - 2 2 6 2 2 6 2 2 6 2 2 6
44354 - 2 2 6 2 2 6 2 2 6 2 2 6
44355 - 2 2 6 2 2 6 2 2 6 10 10 10
44356 - 10 10 10 2 2 6 2 2 6 2 2 6
44357 - 2 2 6 2 2 6 2 2 6 78 78 78
44358 - 50 50 50 18 18 18 6 6 6 0 0 0
44359 - 0 0 0 0 0 0 0 0 0 0 0 0
44360 - 0 0 0 0 0 0 0 0 0 0 0 0
44361 - 0 0 0 0 0 0 0 0 0 0 0 0
44362 - 0 0 0 0 0 0 0 0 0 0 0 0
44363 - 0 0 0 0 0 0 0 0 0 0 0 0
44364 - 0 0 0 0 0 0 0 0 0 0 0 0
44365 - 0 0 0 0 0 0 0 0 0 0 0 0
44366 - 0 0 1 0 0 0 0 0 0 0 0 0
44367 - 0 0 0 0 0 0 0 0 0 0 0 0
44368 - 0 0 0 0 0 0 0 0 0 0 0 0
44369 - 0 0 0 0 0 0 0 0 0 0 0 0
44370 - 0 0 0 0 0 0 0 0 0 0 0 0
44371 - 0 0 0 0 0 0 0 0 0 10 10 10
44372 - 38 38 38 86 86 86 14 14 14 2 2 6
44373 - 2 2 6 2 2 6 2 2 6 2 2 6
44374 - 2 2 6 2 2 6 2 2 6 2 2 6
44375 - 2 2 6 2 2 6 2 2 6 2 2 6
44376 - 2 2 6 2 2 6 2 2 6 2 2 6
44377 - 2 2 6 2 2 6 2 2 6 54 54 54
44378 - 66 66 66 26 26 26 6 6 6 0 0 0
44379 - 0 0 0 0 0 0 0 0 0 0 0 0
44380 - 0 0 0 0 0 0 0 0 0 0 0 0
44381 - 0 0 0 0 0 0 0 0 0 0 0 0
44382 - 0 0 0 0 0 0 0 0 0 0 0 0
44383 - 0 0 0 0 0 0 0 0 0 0 0 0
44384 - 0 0 0 0 0 0 0 0 0 0 0 0
44385 - 0 0 0 0 0 0 0 0 0 0 0 0
44386 - 0 0 0 0 0 1 0 0 1 0 0 0
44387 - 0 0 0 0 0 0 0 0 0 0 0 0
44388 - 0 0 0 0 0 0 0 0 0 0 0 0
44389 - 0 0 0 0 0 0 0 0 0 0 0 0
44390 - 0 0 0 0 0 0 0 0 0 0 0 0
44391 - 0 0 0 0 0 0 0 0 0 14 14 14
44392 - 42 42 42 82 82 82 2 2 6 2 2 6
44393 - 2 2 6 6 6 6 10 10 10 2 2 6
44394 - 2 2 6 2 2 6 2 2 6 2 2 6
44395 - 2 2 6 2 2 6 2 2 6 6 6 6
44396 - 14 14 14 10 10 10 2 2 6 2 2 6
44397 - 2 2 6 2 2 6 2 2 6 18 18 18
44398 - 82 82 82 34 34 34 10 10 10 0 0 0
44399 - 0 0 0 0 0 0 0 0 0 0 0 0
44400 - 0 0 0 0 0 0 0 0 0 0 0 0
44401 - 0 0 0 0 0 0 0 0 0 0 0 0
44402 - 0 0 0 0 0 0 0 0 0 0 0 0
44403 - 0 0 0 0 0 0 0 0 0 0 0 0
44404 - 0 0 0 0 0 0 0 0 0 0 0 0
44405 - 0 0 0 0 0 0 0 0 0 0 0 0
44406 - 0 0 1 0 0 0 0 0 0 0 0 0
44407 - 0 0 0 0 0 0 0 0 0 0 0 0
44408 - 0 0 0 0 0 0 0 0 0 0 0 0
44409 - 0 0 0 0 0 0 0 0 0 0 0 0
44410 - 0 0 0 0 0 0 0 0 0 0 0 0
44411 - 0 0 0 0 0 0 0 0 0 14 14 14
44412 - 46 46 46 86 86 86 2 2 6 2 2 6
44413 - 6 6 6 6 6 6 22 22 22 34 34 34
44414 - 6 6 6 2 2 6 2 2 6 2 2 6
44415 - 2 2 6 2 2 6 18 18 18 34 34 34
44416 - 10 10 10 50 50 50 22 22 22 2 2 6
44417 - 2 2 6 2 2 6 2 2 6 10 10 10
44418 - 86 86 86 42 42 42 14 14 14 0 0 0
44419 - 0 0 0 0 0 0 0 0 0 0 0 0
44420 - 0 0 0 0 0 0 0 0 0 0 0 0
44421 - 0 0 0 0 0 0 0 0 0 0 0 0
44422 - 0 0 0 0 0 0 0 0 0 0 0 0
44423 - 0 0 0 0 0 0 0 0 0 0 0 0
44424 - 0 0 0 0 0 0 0 0 0 0 0 0
44425 - 0 0 0 0 0 0 0 0 0 0 0 0
44426 - 0 0 1 0 0 1 0 0 1 0 0 0
44427 - 0 0 0 0 0 0 0 0 0 0 0 0
44428 - 0 0 0 0 0 0 0 0 0 0 0 0
44429 - 0 0 0 0 0 0 0 0 0 0 0 0
44430 - 0 0 0 0 0 0 0 0 0 0 0 0
44431 - 0 0 0 0 0 0 0 0 0 14 14 14
44432 - 46 46 46 86 86 86 2 2 6 2 2 6
44433 - 38 38 38 116 116 116 94 94 94 22 22 22
44434 - 22 22 22 2 2 6 2 2 6 2 2 6
44435 - 14 14 14 86 86 86 138 138 138 162 162 162
44436 -154 154 154 38 38 38 26 26 26 6 6 6
44437 - 2 2 6 2 2 6 2 2 6 2 2 6
44438 - 86 86 86 46 46 46 14 14 14 0 0 0
44439 - 0 0 0 0 0 0 0 0 0 0 0 0
44440 - 0 0 0 0 0 0 0 0 0 0 0 0
44441 - 0 0 0 0 0 0 0 0 0 0 0 0
44442 - 0 0 0 0 0 0 0 0 0 0 0 0
44443 - 0 0 0 0 0 0 0 0 0 0 0 0
44444 - 0 0 0 0 0 0 0 0 0 0 0 0
44445 - 0 0 0 0 0 0 0 0 0 0 0 0
44446 - 0 0 0 0 0 0 0 0 0 0 0 0
44447 - 0 0 0 0 0 0 0 0 0 0 0 0
44448 - 0 0 0 0 0 0 0 0 0 0 0 0
44449 - 0 0 0 0 0 0 0 0 0 0 0 0
44450 - 0 0 0 0 0 0 0 0 0 0 0 0
44451 - 0 0 0 0 0 0 0 0 0 14 14 14
44452 - 46 46 46 86 86 86 2 2 6 14 14 14
44453 -134 134 134 198 198 198 195 195 195 116 116 116
44454 - 10 10 10 2 2 6 2 2 6 6 6 6
44455 -101 98 89 187 187 187 210 210 210 218 218 218
44456 -214 214 214 134 134 134 14 14 14 6 6 6
44457 - 2 2 6 2 2 6 2 2 6 2 2 6
44458 - 86 86 86 50 50 50 18 18 18 6 6 6
44459 - 0 0 0 0 0 0 0 0 0 0 0 0
44460 - 0 0 0 0 0 0 0 0 0 0 0 0
44461 - 0 0 0 0 0 0 0 0 0 0 0 0
44462 - 0 0 0 0 0 0 0 0 0 0 0 0
44463 - 0 0 0 0 0 0 0 0 0 0 0 0
44464 - 0 0 0 0 0 0 0 0 0 0 0 0
44465 - 0 0 0 0 0 0 0 0 1 0 0 0
44466 - 0 0 1 0 0 1 0 0 1 0 0 0
44467 - 0 0 0 0 0 0 0 0 0 0 0 0
44468 - 0 0 0 0 0 0 0 0 0 0 0 0
44469 - 0 0 0 0 0 0 0 0 0 0 0 0
44470 - 0 0 0 0 0 0 0 0 0 0 0 0
44471 - 0 0 0 0 0 0 0 0 0 14 14 14
44472 - 46 46 46 86 86 86 2 2 6 54 54 54
44473 -218 218 218 195 195 195 226 226 226 246 246 246
44474 - 58 58 58 2 2 6 2 2 6 30 30 30
44475 -210 210 210 253 253 253 174 174 174 123 123 123
44476 -221 221 221 234 234 234 74 74 74 2 2 6
44477 - 2 2 6 2 2 6 2 2 6 2 2 6
44478 - 70 70 70 58 58 58 22 22 22 6 6 6
44479 - 0 0 0 0 0 0 0 0 0 0 0 0
44480 - 0 0 0 0 0 0 0 0 0 0 0 0
44481 - 0 0 0 0 0 0 0 0 0 0 0 0
44482 - 0 0 0 0 0 0 0 0 0 0 0 0
44483 - 0 0 0 0 0 0 0 0 0 0 0 0
44484 - 0 0 0 0 0 0 0 0 0 0 0 0
44485 - 0 0 0 0 0 0 0 0 0 0 0 0
44486 - 0 0 0 0 0 0 0 0 0 0 0 0
44487 - 0 0 0 0 0 0 0 0 0 0 0 0
44488 - 0 0 0 0 0 0 0 0 0 0 0 0
44489 - 0 0 0 0 0 0 0 0 0 0 0 0
44490 - 0 0 0 0 0 0 0 0 0 0 0 0
44491 - 0 0 0 0 0 0 0 0 0 14 14 14
44492 - 46 46 46 82 82 82 2 2 6 106 106 106
44493 -170 170 170 26 26 26 86 86 86 226 226 226
44494 -123 123 123 10 10 10 14 14 14 46 46 46
44495 -231 231 231 190 190 190 6 6 6 70 70 70
44496 - 90 90 90 238 238 238 158 158 158 2 2 6
44497 - 2 2 6 2 2 6 2 2 6 2 2 6
44498 - 70 70 70 58 58 58 22 22 22 6 6 6
44499 - 0 0 0 0 0 0 0 0 0 0 0 0
44500 - 0 0 0 0 0 0 0 0 0 0 0 0
44501 - 0 0 0 0 0 0 0 0 0 0 0 0
44502 - 0 0 0 0 0 0 0 0 0 0 0 0
44503 - 0 0 0 0 0 0 0 0 0 0 0 0
44504 - 0 0 0 0 0 0 0 0 0 0 0 0
44505 - 0 0 0 0 0 0 0 0 1 0 0 0
44506 - 0 0 1 0 0 1 0 0 1 0 0 0
44507 - 0 0 0 0 0 0 0 0 0 0 0 0
44508 - 0 0 0 0 0 0 0 0 0 0 0 0
44509 - 0 0 0 0 0 0 0 0 0 0 0 0
44510 - 0 0 0 0 0 0 0 0 0 0 0 0
44511 - 0 0 0 0 0 0 0 0 0 14 14 14
44512 - 42 42 42 86 86 86 6 6 6 116 116 116
44513 -106 106 106 6 6 6 70 70 70 149 149 149
44514 -128 128 128 18 18 18 38 38 38 54 54 54
44515 -221 221 221 106 106 106 2 2 6 14 14 14
44516 - 46 46 46 190 190 190 198 198 198 2 2 6
44517 - 2 2 6 2 2 6 2 2 6 2 2 6
44518 - 74 74 74 62 62 62 22 22 22 6 6 6
44519 - 0 0 0 0 0 0 0 0 0 0 0 0
44520 - 0 0 0 0 0 0 0 0 0 0 0 0
44521 - 0 0 0 0 0 0 0 0 0 0 0 0
44522 - 0 0 0 0 0 0 0 0 0 0 0 0
44523 - 0 0 0 0 0 0 0 0 0 0 0 0
44524 - 0 0 0 0 0 0 0 0 0 0 0 0
44525 - 0 0 0 0 0 0 0 0 1 0 0 0
44526 - 0 0 1 0 0 0 0 0 1 0 0 0
44527 - 0 0 0 0 0 0 0 0 0 0 0 0
44528 - 0 0 0 0 0 0 0 0 0 0 0 0
44529 - 0 0 0 0 0 0 0 0 0 0 0 0
44530 - 0 0 0 0 0 0 0 0 0 0 0 0
44531 - 0 0 0 0 0 0 0 0 0 14 14 14
44532 - 42 42 42 94 94 94 14 14 14 101 101 101
44533 -128 128 128 2 2 6 18 18 18 116 116 116
44534 -118 98 46 121 92 8 121 92 8 98 78 10
44535 -162 162 162 106 106 106 2 2 6 2 2 6
44536 - 2 2 6 195 195 195 195 195 195 6 6 6
44537 - 2 2 6 2 2 6 2 2 6 2 2 6
44538 - 74 74 74 62 62 62 22 22 22 6 6 6
44539 - 0 0 0 0 0 0 0 0 0 0 0 0
44540 - 0 0 0 0 0 0 0 0 0 0 0 0
44541 - 0 0 0 0 0 0 0 0 0 0 0 0
44542 - 0 0 0 0 0 0 0 0 0 0 0 0
44543 - 0 0 0 0 0 0 0 0 0 0 0 0
44544 - 0 0 0 0 0 0 0 0 0 0 0 0
44545 - 0 0 0 0 0 0 0 0 1 0 0 1
44546 - 0 0 1 0 0 0 0 0 1 0 0 0
44547 - 0 0 0 0 0 0 0 0 0 0 0 0
44548 - 0 0 0 0 0 0 0 0 0 0 0 0
44549 - 0 0 0 0 0 0 0 0 0 0 0 0
44550 - 0 0 0 0 0 0 0 0 0 0 0 0
44551 - 0 0 0 0 0 0 0 0 0 10 10 10
44552 - 38 38 38 90 90 90 14 14 14 58 58 58
44553 -210 210 210 26 26 26 54 38 6 154 114 10
44554 -226 170 11 236 186 11 225 175 15 184 144 12
44555 -215 174 15 175 146 61 37 26 9 2 2 6
44556 - 70 70 70 246 246 246 138 138 138 2 2 6
44557 - 2 2 6 2 2 6 2 2 6 2 2 6
44558 - 70 70 70 66 66 66 26 26 26 6 6 6
44559 - 0 0 0 0 0 0 0 0 0 0 0 0
44560 - 0 0 0 0 0 0 0 0 0 0 0 0
44561 - 0 0 0 0 0 0 0 0 0 0 0 0
44562 - 0 0 0 0 0 0 0 0 0 0 0 0
44563 - 0 0 0 0 0 0 0 0 0 0 0 0
44564 - 0 0 0 0 0 0 0 0 0 0 0 0
44565 - 0 0 0 0 0 0 0 0 0 0 0 0
44566 - 0 0 0 0 0 0 0 0 0 0 0 0
44567 - 0 0 0 0 0 0 0 0 0 0 0 0
44568 - 0 0 0 0 0 0 0 0 0 0 0 0
44569 - 0 0 0 0 0 0 0 0 0 0 0 0
44570 - 0 0 0 0 0 0 0 0 0 0 0 0
44571 - 0 0 0 0 0 0 0 0 0 10 10 10
44572 - 38 38 38 86 86 86 14 14 14 10 10 10
44573 -195 195 195 188 164 115 192 133 9 225 175 15
44574 -239 182 13 234 190 10 232 195 16 232 200 30
44575 -245 207 45 241 208 19 232 195 16 184 144 12
44576 -218 194 134 211 206 186 42 42 42 2 2 6
44577 - 2 2 6 2 2 6 2 2 6 2 2 6
44578 - 50 50 50 74 74 74 30 30 30 6 6 6
44579 - 0 0 0 0 0 0 0 0 0 0 0 0
44580 - 0 0 0 0 0 0 0 0 0 0 0 0
44581 - 0 0 0 0 0 0 0 0 0 0 0 0
44582 - 0 0 0 0 0 0 0 0 0 0 0 0
44583 - 0 0 0 0 0 0 0 0 0 0 0 0
44584 - 0 0 0 0 0 0 0 0 0 0 0 0
44585 - 0 0 0 0 0 0 0 0 0 0 0 0
44586 - 0 0 0 0 0 0 0 0 0 0 0 0
44587 - 0 0 0 0 0 0 0 0 0 0 0 0
44588 - 0 0 0 0 0 0 0 0 0 0 0 0
44589 - 0 0 0 0 0 0 0 0 0 0 0 0
44590 - 0 0 0 0 0 0 0 0 0 0 0 0
44591 - 0 0 0 0 0 0 0 0 0 10 10 10
44592 - 34 34 34 86 86 86 14 14 14 2 2 6
44593 -121 87 25 192 133 9 219 162 10 239 182 13
44594 -236 186 11 232 195 16 241 208 19 244 214 54
44595 -246 218 60 246 218 38 246 215 20 241 208 19
44596 -241 208 19 226 184 13 121 87 25 2 2 6
44597 - 2 2 6 2 2 6 2 2 6 2 2 6
44598 - 50 50 50 82 82 82 34 34 34 10 10 10
44599 - 0 0 0 0 0 0 0 0 0 0 0 0
44600 - 0 0 0 0 0 0 0 0 0 0 0 0
44601 - 0 0 0 0 0 0 0 0 0 0 0 0
44602 - 0 0 0 0 0 0 0 0 0 0 0 0
44603 - 0 0 0 0 0 0 0 0 0 0 0 0
44604 - 0 0 0 0 0 0 0 0 0 0 0 0
44605 - 0 0 0 0 0 0 0 0 0 0 0 0
44606 - 0 0 0 0 0 0 0 0 0 0 0 0
44607 - 0 0 0 0 0 0 0 0 0 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 10 10 10
44612 - 34 34 34 82 82 82 30 30 30 61 42 6
44613 -180 123 7 206 145 10 230 174 11 239 182 13
44614 -234 190 10 238 202 15 241 208 19 246 218 74
44615 -246 218 38 246 215 20 246 215 20 246 215 20
44616 -226 184 13 215 174 15 184 144 12 6 6 6
44617 - 2 2 6 2 2 6 2 2 6 2 2 6
44618 - 26 26 26 94 94 94 42 42 42 14 14 14
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 10 10 10
44632 - 30 30 30 78 78 78 50 50 50 104 69 6
44633 -192 133 9 216 158 10 236 178 12 236 186 11
44634 -232 195 16 241 208 19 244 214 54 245 215 43
44635 -246 215 20 246 215 20 241 208 19 198 155 10
44636 -200 144 11 216 158 10 156 118 10 2 2 6
44637 - 2 2 6 2 2 6 2 2 6 2 2 6
44638 - 6 6 6 90 90 90 54 54 54 18 18 18
44639 - 6 6 6 0 0 0 0 0 0 0 0 0
44640 - 0 0 0 0 0 0 0 0 0 0 0 0
44641 - 0 0 0 0 0 0 0 0 0 0 0 0
44642 - 0 0 0 0 0 0 0 0 0 0 0 0
44643 - 0 0 0 0 0 0 0 0 0 0 0 0
44644 - 0 0 0 0 0 0 0 0 0 0 0 0
44645 - 0 0 0 0 0 0 0 0 0 0 0 0
44646 - 0 0 0 0 0 0 0 0 0 0 0 0
44647 - 0 0 0 0 0 0 0 0 0 0 0 0
44648 - 0 0 0 0 0 0 0 0 0 0 0 0
44649 - 0 0 0 0 0 0 0 0 0 0 0 0
44650 - 0 0 0 0 0 0 0 0 0 0 0 0
44651 - 0 0 0 0 0 0 0 0 0 10 10 10
44652 - 30 30 30 78 78 78 46 46 46 22 22 22
44653 -137 92 6 210 162 10 239 182 13 238 190 10
44654 -238 202 15 241 208 19 246 215 20 246 215 20
44655 -241 208 19 203 166 17 185 133 11 210 150 10
44656 -216 158 10 210 150 10 102 78 10 2 2 6
44657 - 6 6 6 54 54 54 14 14 14 2 2 6
44658 - 2 2 6 62 62 62 74 74 74 30 30 30
44659 - 10 10 10 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 0 0 0 0 0 0 0 0 0 0
44666 - 0 0 0 0 0 0 0 0 0 0 0 0
44667 - 0 0 0 0 0 0 0 0 0 0 0 0
44668 - 0 0 0 0 0 0 0 0 0 0 0 0
44669 - 0 0 0 0 0 0 0 0 0 0 0 0
44670 - 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 - 34 34 34 78 78 78 50 50 50 6 6 6
44673 - 94 70 30 139 102 15 190 146 13 226 184 13
44674 -232 200 30 232 195 16 215 174 15 190 146 13
44675 -168 122 10 192 133 9 210 150 10 213 154 11
44676 -202 150 34 182 157 106 101 98 89 2 2 6
44677 - 2 2 6 78 78 78 116 116 116 58 58 58
44678 - 2 2 6 22 22 22 90 90 90 46 46 46
44679 - 18 18 18 6 6 6 0 0 0 0 0 0
44680 - 0 0 0 0 0 0 0 0 0 0 0 0
44681 - 0 0 0 0 0 0 0 0 0 0 0 0
44682 - 0 0 0 0 0 0 0 0 0 0 0 0
44683 - 0 0 0 0 0 0 0 0 0 0 0 0
44684 - 0 0 0 0 0 0 0 0 0 0 0 0
44685 - 0 0 0 0 0 0 0 0 0 0 0 0
44686 - 0 0 0 0 0 0 0 0 0 0 0 0
44687 - 0 0 0 0 0 0 0 0 0 0 0 0
44688 - 0 0 0 0 0 0 0 0 0 0 0 0
44689 - 0 0 0 0 0 0 0 0 0 0 0 0
44690 - 0 0 0 0 0 0 0 0 0 0 0 0
44691 - 0 0 0 0 0 0 0 0 0 10 10 10
44692 - 38 38 38 86 86 86 50 50 50 6 6 6
44693 -128 128 128 174 154 114 156 107 11 168 122 10
44694 -198 155 10 184 144 12 197 138 11 200 144 11
44695 -206 145 10 206 145 10 197 138 11 188 164 115
44696 -195 195 195 198 198 198 174 174 174 14 14 14
44697 - 2 2 6 22 22 22 116 116 116 116 116 116
44698 - 22 22 22 2 2 6 74 74 74 70 70 70
44699 - 30 30 30 10 10 10 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 0 0 0 6 6 6 18 18 18
44712 - 50 50 50 101 101 101 26 26 26 10 10 10
44713 -138 138 138 190 190 190 174 154 114 156 107 11
44714 -197 138 11 200 144 11 197 138 11 192 133 9
44715 -180 123 7 190 142 34 190 178 144 187 187 187
44716 -202 202 202 221 221 221 214 214 214 66 66 66
44717 - 2 2 6 2 2 6 50 50 50 62 62 62
44718 - 6 6 6 2 2 6 10 10 10 90 90 90
44719 - 50 50 50 18 18 18 6 6 6 0 0 0
44720 - 0 0 0 0 0 0 0 0 0 0 0 0
44721 - 0 0 0 0 0 0 0 0 0 0 0 0
44722 - 0 0 0 0 0 0 0 0 0 0 0 0
44723 - 0 0 0 0 0 0 0 0 0 0 0 0
44724 - 0 0 0 0 0 0 0 0 0 0 0 0
44725 - 0 0 0 0 0 0 0 0 0 0 0 0
44726 - 0 0 0 0 0 0 0 0 0 0 0 0
44727 - 0 0 0 0 0 0 0 0 0 0 0 0
44728 - 0 0 0 0 0 0 0 0 0 0 0 0
44729 - 0 0 0 0 0 0 0 0 0 0 0 0
44730 - 0 0 0 0 0 0 0 0 0 0 0 0
44731 - 0 0 0 0 0 0 10 10 10 34 34 34
44732 - 74 74 74 74 74 74 2 2 6 6 6 6
44733 -144 144 144 198 198 198 190 190 190 178 166 146
44734 -154 121 60 156 107 11 156 107 11 168 124 44
44735 -174 154 114 187 187 187 190 190 190 210 210 210
44736 -246 246 246 253 253 253 253 253 253 182 182 182
44737 - 6 6 6 2 2 6 2 2 6 2 2 6
44738 - 2 2 6 2 2 6 2 2 6 62 62 62
44739 - 74 74 74 34 34 34 14 14 14 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 0 0 0 0 0 0 0 0 0 0
44746 - 0 0 0 0 0 0 0 0 0 0 0 0
44747 - 0 0 0 0 0 0 0 0 0 0 0 0
44748 - 0 0 0 0 0 0 0 0 0 0 0 0
44749 - 0 0 0 0 0 0 0 0 0 0 0 0
44750 - 0 0 0 0 0 0 0 0 0 0 0 0
44751 - 0 0 0 10 10 10 22 22 22 54 54 54
44752 - 94 94 94 18 18 18 2 2 6 46 46 46
44753 -234 234 234 221 221 221 190 190 190 190 190 190
44754 -190 190 190 187 187 187 187 187 187 190 190 190
44755 -190 190 190 195 195 195 214 214 214 242 242 242
44756 -253 253 253 253 253 253 253 253 253 253 253 253
44757 - 82 82 82 2 2 6 2 2 6 2 2 6
44758 - 2 2 6 2 2 6 2 2 6 14 14 14
44759 - 86 86 86 54 54 54 22 22 22 6 6 6
44760 - 0 0 0 0 0 0 0 0 0 0 0 0
44761 - 0 0 0 0 0 0 0 0 0 0 0 0
44762 - 0 0 0 0 0 0 0 0 0 0 0 0
44763 - 0 0 0 0 0 0 0 0 0 0 0 0
44764 - 0 0 0 0 0 0 0 0 0 0 0 0
44765 - 0 0 0 0 0 0 0 0 0 0 0 0
44766 - 0 0 0 0 0 0 0 0 0 0 0 0
44767 - 0 0 0 0 0 0 0 0 0 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 - 6 6 6 18 18 18 46 46 46 90 90 90
44772 - 46 46 46 18 18 18 6 6 6 182 182 182
44773 -253 253 253 246 246 246 206 206 206 190 190 190
44774 -190 190 190 190 190 190 190 190 190 190 190 190
44775 -206 206 206 231 231 231 250 250 250 253 253 253
44776 -253 253 253 253 253 253 253 253 253 253 253 253
44777 -202 202 202 14 14 14 2 2 6 2 2 6
44778 - 2 2 6 2 2 6 2 2 6 2 2 6
44779 - 42 42 42 86 86 86 42 42 42 18 18 18
44780 - 6 6 6 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 - 14 14 14 38 38 38 74 74 74 66 66 66
44792 - 2 2 6 6 6 6 90 90 90 250 250 250
44793 -253 253 253 253 253 253 238 238 238 198 198 198
44794 -190 190 190 190 190 190 195 195 195 221 221 221
44795 -246 246 246 253 253 253 253 253 253 253 253 253
44796 -253 253 253 253 253 253 253 253 253 253 253 253
44797 -253 253 253 82 82 82 2 2 6 2 2 6
44798 - 2 2 6 2 2 6 2 2 6 2 2 6
44799 - 2 2 6 78 78 78 70 70 70 34 34 34
44800 - 14 14 14 6 6 6 0 0 0 0 0 0
44801 - 0 0 0 0 0 0 0 0 0 0 0 0
44802 - 0 0 0 0 0 0 0 0 0 0 0 0
44803 - 0 0 0 0 0 0 0 0 0 0 0 0
44804 - 0 0 0 0 0 0 0 0 0 0 0 0
44805 - 0 0 0 0 0 0 0 0 0 0 0 0
44806 - 0 0 0 0 0 0 0 0 0 0 0 0
44807 - 0 0 0 0 0 0 0 0 0 0 0 0
44808 - 0 0 0 0 0 0 0 0 0 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 14 14 14
44811 - 34 34 34 66 66 66 78 78 78 6 6 6
44812 - 2 2 6 18 18 18 218 218 218 253 253 253
44813 -253 253 253 253 253 253 253 253 253 246 246 246
44814 -226 226 226 231 231 231 246 246 246 253 253 253
44815 -253 253 253 253 253 253 253 253 253 253 253 253
44816 -253 253 253 253 253 253 253 253 253 253 253 253
44817 -253 253 253 178 178 178 2 2 6 2 2 6
44818 - 2 2 6 2 2 6 2 2 6 2 2 6
44819 - 2 2 6 18 18 18 90 90 90 62 62 62
44820 - 30 30 30 10 10 10 0 0 0 0 0 0
44821 - 0 0 0 0 0 0 0 0 0 0 0 0
44822 - 0 0 0 0 0 0 0 0 0 0 0 0
44823 - 0 0 0 0 0 0 0 0 0 0 0 0
44824 - 0 0 0 0 0 0 0 0 0 0 0 0
44825 - 0 0 0 0 0 0 0 0 0 0 0 0
44826 - 0 0 0 0 0 0 0 0 0 0 0 0
44827 - 0 0 0 0 0 0 0 0 0 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 10 10 10 26 26 26
44831 - 58 58 58 90 90 90 18 18 18 2 2 6
44832 - 2 2 6 110 110 110 253 253 253 253 253 253
44833 -253 253 253 253 253 253 253 253 253 253 253 253
44834 -250 250 250 253 253 253 253 253 253 253 253 253
44835 -253 253 253 253 253 253 253 253 253 253 253 253
44836 -253 253 253 253 253 253 253 253 253 253 253 253
44837 -253 253 253 231 231 231 18 18 18 2 2 6
44838 - 2 2 6 2 2 6 2 2 6 2 2 6
44839 - 2 2 6 2 2 6 18 18 18 94 94 94
44840 - 54 54 54 26 26 26 10 10 10 0 0 0
44841 - 0 0 0 0 0 0 0 0 0 0 0 0
44842 - 0 0 0 0 0 0 0 0 0 0 0 0
44843 - 0 0 0 0 0 0 0 0 0 0 0 0
44844 - 0 0 0 0 0 0 0 0 0 0 0 0
44845 - 0 0 0 0 0 0 0 0 0 0 0 0
44846 - 0 0 0 0 0 0 0 0 0 0 0 0
44847 - 0 0 0 0 0 0 0 0 0 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 6 6 6 22 22 22 50 50 50
44851 - 90 90 90 26 26 26 2 2 6 2 2 6
44852 - 14 14 14 195 195 195 250 250 250 253 253 253
44853 -253 253 253 253 253 253 253 253 253 253 253 253
44854 -253 253 253 253 253 253 253 253 253 253 253 253
44855 -253 253 253 253 253 253 253 253 253 253 253 253
44856 -253 253 253 253 253 253 253 253 253 253 253 253
44857 -250 250 250 242 242 242 54 54 54 2 2 6
44858 - 2 2 6 2 2 6 2 2 6 2 2 6
44859 - 2 2 6 2 2 6 2 2 6 38 38 38
44860 - 86 86 86 50 50 50 22 22 22 6 6 6
44861 - 0 0 0 0 0 0 0 0 0 0 0 0
44862 - 0 0 0 0 0 0 0 0 0 0 0 0
44863 - 0 0 0 0 0 0 0 0 0 0 0 0
44864 - 0 0 0 0 0 0 0 0 0 0 0 0
44865 - 0 0 0 0 0 0 0 0 0 0 0 0
44866 - 0 0 0 0 0 0 0 0 0 0 0 0
44867 - 0 0 0 0 0 0 0 0 0 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 - 6 6 6 14 14 14 38 38 38 82 82 82
44871 - 34 34 34 2 2 6 2 2 6 2 2 6
44872 - 42 42 42 195 195 195 246 246 246 253 253 253
44873 -253 253 253 253 253 253 253 253 253 250 250 250
44874 -242 242 242 242 242 242 250 250 250 253 253 253
44875 -253 253 253 253 253 253 253 253 253 253 253 253
44876 -253 253 253 250 250 250 246 246 246 238 238 238
44877 -226 226 226 231 231 231 101 101 101 6 6 6
44878 - 2 2 6 2 2 6 2 2 6 2 2 6
44879 - 2 2 6 2 2 6 2 2 6 2 2 6
44880 - 38 38 38 82 82 82 42 42 42 14 14 14
44881 - 6 6 6 0 0 0 0 0 0 0 0 0
44882 - 0 0 0 0 0 0 0 0 0 0 0 0
44883 - 0 0 0 0 0 0 0 0 0 0 0 0
44884 - 0 0 0 0 0 0 0 0 0 0 0 0
44885 - 0 0 0 0 0 0 0 0 0 0 0 0
44886 - 0 0 0 0 0 0 0 0 0 0 0 0
44887 - 0 0 0 0 0 0 0 0 0 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 - 10 10 10 26 26 26 62 62 62 66 66 66
44891 - 2 2 6 2 2 6 2 2 6 6 6 6
44892 - 70 70 70 170 170 170 206 206 206 234 234 234
44893 -246 246 246 250 250 250 250 250 250 238 238 238
44894 -226 226 226 231 231 231 238 238 238 250 250 250
44895 -250 250 250 250 250 250 246 246 246 231 231 231
44896 -214 214 214 206 206 206 202 202 202 202 202 202
44897 -198 198 198 202 202 202 182 182 182 18 18 18
44898 - 2 2 6 2 2 6 2 2 6 2 2 6
44899 - 2 2 6 2 2 6 2 2 6 2 2 6
44900 - 2 2 6 62 62 62 66 66 66 30 30 30
44901 - 10 10 10 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 - 14 14 14 42 42 42 82 82 82 18 18 18
44911 - 2 2 6 2 2 6 2 2 6 10 10 10
44912 - 94 94 94 182 182 182 218 218 218 242 242 242
44913 -250 250 250 253 253 253 253 253 253 250 250 250
44914 -234 234 234 253 253 253 253 253 253 253 253 253
44915 -253 253 253 253 253 253 253 253 253 246 246 246
44916 -238 238 238 226 226 226 210 210 210 202 202 202
44917 -195 195 195 195 195 195 210 210 210 158 158 158
44918 - 6 6 6 14 14 14 50 50 50 14 14 14
44919 - 2 2 6 2 2 6 2 2 6 2 2 6
44920 - 2 2 6 6 6 6 86 86 86 46 46 46
44921 - 18 18 18 6 6 6 0 0 0 0 0 0
44922 - 0 0 0 0 0 0 0 0 0 0 0 0
44923 - 0 0 0 0 0 0 0 0 0 0 0 0
44924 - 0 0 0 0 0 0 0 0 0 0 0 0
44925 - 0 0 0 0 0 0 0 0 0 0 0 0
44926 - 0 0 0 0 0 0 0 0 0 0 0 0
44927 - 0 0 0 0 0 0 0 0 0 0 0 0
44928 - 0 0 0 0 0 0 0 0 0 0 0 0
44929 - 0 0 0 0 0 0 0 0 0 6 6 6
44930 - 22 22 22 54 54 54 70 70 70 2 2 6
44931 - 2 2 6 10 10 10 2 2 6 22 22 22
44932 -166 166 166 231 231 231 250 250 250 253 253 253
44933 -253 253 253 253 253 253 253 253 253 250 250 250
44934 -242 242 242 253 253 253 253 253 253 253 253 253
44935 -253 253 253 253 253 253 253 253 253 253 253 253
44936 -253 253 253 253 253 253 253 253 253 246 246 246
44937 -231 231 231 206 206 206 198 198 198 226 226 226
44938 - 94 94 94 2 2 6 6 6 6 38 38 38
44939 - 30 30 30 2 2 6 2 2 6 2 2 6
44940 - 2 2 6 2 2 6 62 62 62 66 66 66
44941 - 26 26 26 10 10 10 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 10 10 10
44950 - 30 30 30 74 74 74 50 50 50 2 2 6
44951 - 26 26 26 26 26 26 2 2 6 106 106 106
44952 -238 238 238 253 253 253 253 253 253 253 253 253
44953 -253 253 253 253 253 253 253 253 253 253 253 253
44954 -253 253 253 253 253 253 253 253 253 253 253 253
44955 -253 253 253 253 253 253 253 253 253 253 253 253
44956 -253 253 253 253 253 253 253 253 253 253 253 253
44957 -253 253 253 246 246 246 218 218 218 202 202 202
44958 -210 210 210 14 14 14 2 2 6 2 2 6
44959 - 30 30 30 22 22 22 2 2 6 2 2 6
44960 - 2 2 6 2 2 6 18 18 18 86 86 86
44961 - 42 42 42 14 14 14 0 0 0 0 0 0
44962 - 0 0 0 0 0 0 0 0 0 0 0 0
44963 - 0 0 0 0 0 0 0 0 0 0 0 0
44964 - 0 0 0 0 0 0 0 0 0 0 0 0
44965 - 0 0 0 0 0 0 0 0 0 0 0 0
44966 - 0 0 0 0 0 0 0 0 0 0 0 0
44967 - 0 0 0 0 0 0 0 0 0 0 0 0
44968 - 0 0 0 0 0 0 0 0 0 0 0 0
44969 - 0 0 0 0 0 0 0 0 0 14 14 14
44970 - 42 42 42 90 90 90 22 22 22 2 2 6
44971 - 42 42 42 2 2 6 18 18 18 218 218 218
44972 -253 253 253 253 253 253 253 253 253 253 253 253
44973 -253 253 253 253 253 253 253 253 253 253 253 253
44974 -253 253 253 253 253 253 253 253 253 253 253 253
44975 -253 253 253 253 253 253 253 253 253 253 253 253
44976 -253 253 253 253 253 253 253 253 253 253 253 253
44977 -253 253 253 253 253 253 250 250 250 221 221 221
44978 -218 218 218 101 101 101 2 2 6 14 14 14
44979 - 18 18 18 38 38 38 10 10 10 2 2 6
44980 - 2 2 6 2 2 6 2 2 6 78 78 78
44981 - 58 58 58 22 22 22 6 6 6 0 0 0
44982 - 0 0 0 0 0 0 0 0 0 0 0 0
44983 - 0 0 0 0 0 0 0 0 0 0 0 0
44984 - 0 0 0 0 0 0 0 0 0 0 0 0
44985 - 0 0 0 0 0 0 0 0 0 0 0 0
44986 - 0 0 0 0 0 0 0 0 0 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 6 6 6 18 18 18
44990 - 54 54 54 82 82 82 2 2 6 26 26 26
44991 - 22 22 22 2 2 6 123 123 123 253 253 253
44992 -253 253 253 253 253 253 253 253 253 253 253 253
44993 -253 253 253 253 253 253 253 253 253 253 253 253
44994 -253 253 253 253 253 253 253 253 253 253 253 253
44995 -253 253 253 253 253 253 253 253 253 253 253 253
44996 -253 253 253 253 253 253 253 253 253 253 253 253
44997 -253 253 253 253 253 253 253 253 253 250 250 250
44998 -238 238 238 198 198 198 6 6 6 38 38 38
44999 - 58 58 58 26 26 26 38 38 38 2 2 6
45000 - 2 2 6 2 2 6 2 2 6 46 46 46
45001 - 78 78 78 30 30 30 10 10 10 0 0 0
45002 - 0 0 0 0 0 0 0 0 0 0 0 0
45003 - 0 0 0 0 0 0 0 0 0 0 0 0
45004 - 0 0 0 0 0 0 0 0 0 0 0 0
45005 - 0 0 0 0 0 0 0 0 0 0 0 0
45006 - 0 0 0 0 0 0 0 0 0 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 10 10 10 30 30 30
45010 - 74 74 74 58 58 58 2 2 6 42 42 42
45011 - 2 2 6 22 22 22 231 231 231 253 253 253
45012 -253 253 253 253 253 253 253 253 253 253 253 253
45013 -253 253 253 253 253 253 253 253 253 250 250 250
45014 -253 253 253 253 253 253 253 253 253 253 253 253
45015 -253 253 253 253 253 253 253 253 253 253 253 253
45016 -253 253 253 253 253 253 253 253 253 253 253 253
45017 -253 253 253 253 253 253 253 253 253 253 253 253
45018 -253 253 253 246 246 246 46 46 46 38 38 38
45019 - 42 42 42 14 14 14 38 38 38 14 14 14
45020 - 2 2 6 2 2 6 2 2 6 6 6 6
45021 - 86 86 86 46 46 46 14 14 14 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 6 6 6 14 14 14 42 42 42
45030 - 90 90 90 18 18 18 18 18 18 26 26 26
45031 - 2 2 6 116 116 116 253 253 253 253 253 253
45032 -253 253 253 253 253 253 253 253 253 253 253 253
45033 -253 253 253 253 253 253 250 250 250 238 238 238
45034 -253 253 253 253 253 253 253 253 253 253 253 253
45035 -253 253 253 253 253 253 253 253 253 253 253 253
45036 -253 253 253 253 253 253 253 253 253 253 253 253
45037 -253 253 253 253 253 253 253 253 253 253 253 253
45038 -253 253 253 253 253 253 94 94 94 6 6 6
45039 - 2 2 6 2 2 6 10 10 10 34 34 34
45040 - 2 2 6 2 2 6 2 2 6 2 2 6
45041 - 74 74 74 58 58 58 22 22 22 6 6 6
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 10 10 10 26 26 26 66 66 66
45050 - 82 82 82 2 2 6 38 38 38 6 6 6
45051 - 14 14 14 210 210 210 253 253 253 253 253 253
45052 -253 253 253 253 253 253 253 253 253 253 253 253
45053 -253 253 253 253 253 253 246 246 246 242 242 242
45054 -253 253 253 253 253 253 253 253 253 253 253 253
45055 -253 253 253 253 253 253 253 253 253 253 253 253
45056 -253 253 253 253 253 253 253 253 253 253 253 253
45057 -253 253 253 253 253 253 253 253 253 253 253 253
45058 -253 253 253 253 253 253 144 144 144 2 2 6
45059 - 2 2 6 2 2 6 2 2 6 46 46 46
45060 - 2 2 6 2 2 6 2 2 6 2 2 6
45061 - 42 42 42 74 74 74 30 30 30 10 10 10
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 - 6 6 6 14 14 14 42 42 42 90 90 90
45070 - 26 26 26 6 6 6 42 42 42 2 2 6
45071 - 74 74 74 250 250 250 253 253 253 253 253 253
45072 -253 253 253 253 253 253 253 253 253 253 253 253
45073 -253 253 253 253 253 253 242 242 242 242 242 242
45074 -253 253 253 253 253 253 253 253 253 253 253 253
45075 -253 253 253 253 253 253 253 253 253 253 253 253
45076 -253 253 253 253 253 253 253 253 253 253 253 253
45077 -253 253 253 253 253 253 253 253 253 253 253 253
45078 -253 253 253 253 253 253 182 182 182 2 2 6
45079 - 2 2 6 2 2 6 2 2 6 46 46 46
45080 - 2 2 6 2 2 6 2 2 6 2 2 6
45081 - 10 10 10 86 86 86 38 38 38 10 10 10
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 - 10 10 10 26 26 26 66 66 66 82 82 82
45090 - 2 2 6 22 22 22 18 18 18 2 2 6
45091 -149 149 149 253 253 253 253 253 253 253 253 253
45092 -253 253 253 253 253 253 253 253 253 253 253 253
45093 -253 253 253 253 253 253 234 234 234 242 242 242
45094 -253 253 253 253 253 253 253 253 253 253 253 253
45095 -253 253 253 253 253 253 253 253 253 253 253 253
45096 -253 253 253 253 253 253 253 253 253 253 253 253
45097 -253 253 253 253 253 253 253 253 253 253 253 253
45098 -253 253 253 253 253 253 206 206 206 2 2 6
45099 - 2 2 6 2 2 6 2 2 6 38 38 38
45100 - 2 2 6 2 2 6 2 2 6 2 2 6
45101 - 6 6 6 86 86 86 46 46 46 14 14 14
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 6 6 6
45109 - 18 18 18 46 46 46 86 86 86 18 18 18
45110 - 2 2 6 34 34 34 10 10 10 6 6 6
45111 -210 210 210 253 253 253 253 253 253 253 253 253
45112 -253 253 253 253 253 253 253 253 253 253 253 253
45113 -253 253 253 253 253 253 234 234 234 242 242 242
45114 -253 253 253 253 253 253 253 253 253 253 253 253
45115 -253 253 253 253 253 253 253 253 253 253 253 253
45116 -253 253 253 253 253 253 253 253 253 253 253 253
45117 -253 253 253 253 253 253 253 253 253 253 253 253
45118 -253 253 253 253 253 253 221 221 221 6 6 6
45119 - 2 2 6 2 2 6 6 6 6 30 30 30
45120 - 2 2 6 2 2 6 2 2 6 2 2 6
45121 - 2 2 6 82 82 82 54 54 54 18 18 18
45122 - 6 6 6 0 0 0 0 0 0 0 0 0
45123 - 0 0 0 0 0 0 0 0 0 0 0 0
45124 - 0 0 0 0 0 0 0 0 0 0 0 0
45125 - 0 0 0 0 0 0 0 0 0 0 0 0
45126 - 0 0 0 0 0 0 0 0 0 0 0 0
45127 - 0 0 0 0 0 0 0 0 0 0 0 0
45128 - 0 0 0 0 0 0 0 0 0 10 10 10
45129 - 26 26 26 66 66 66 62 62 62 2 2 6
45130 - 2 2 6 38 38 38 10 10 10 26 26 26
45131 -238 238 238 253 253 253 253 253 253 253 253 253
45132 -253 253 253 253 253 253 253 253 253 253 253 253
45133 -253 253 253 253 253 253 231 231 231 238 238 238
45134 -253 253 253 253 253 253 253 253 253 253 253 253
45135 -253 253 253 253 253 253 253 253 253 253 253 253
45136 -253 253 253 253 253 253 253 253 253 253 253 253
45137 -253 253 253 253 253 253 253 253 253 253 253 253
45138 -253 253 253 253 253 253 231 231 231 6 6 6
45139 - 2 2 6 2 2 6 10 10 10 30 30 30
45140 - 2 2 6 2 2 6 2 2 6 2 2 6
45141 - 2 2 6 66 66 66 58 58 58 22 22 22
45142 - 6 6 6 0 0 0 0 0 0 0 0 0
45143 - 0 0 0 0 0 0 0 0 0 0 0 0
45144 - 0 0 0 0 0 0 0 0 0 0 0 0
45145 - 0 0 0 0 0 0 0 0 0 0 0 0
45146 - 0 0 0 0 0 0 0 0 0 0 0 0
45147 - 0 0 0 0 0 0 0 0 0 0 0 0
45148 - 0 0 0 0 0 0 0 0 0 10 10 10
45149 - 38 38 38 78 78 78 6 6 6 2 2 6
45150 - 2 2 6 46 46 46 14 14 14 42 42 42
45151 -246 246 246 253 253 253 253 253 253 253 253 253
45152 -253 253 253 253 253 253 253 253 253 253 253 253
45153 -253 253 253 253 253 253 231 231 231 242 242 242
45154 -253 253 253 253 253 253 253 253 253 253 253 253
45155 -253 253 253 253 253 253 253 253 253 253 253 253
45156 -253 253 253 253 253 253 253 253 253 253 253 253
45157 -253 253 253 253 253 253 253 253 253 253 253 253
45158 -253 253 253 253 253 253 234 234 234 10 10 10
45159 - 2 2 6 2 2 6 22 22 22 14 14 14
45160 - 2 2 6 2 2 6 2 2 6 2 2 6
45161 - 2 2 6 66 66 66 62 62 62 22 22 22
45162 - 6 6 6 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 6 6 6 18 18 18
45169 - 50 50 50 74 74 74 2 2 6 2 2 6
45170 - 14 14 14 70 70 70 34 34 34 62 62 62
45171 -250 250 250 253 253 253 253 253 253 253 253 253
45172 -253 253 253 253 253 253 253 253 253 253 253 253
45173 -253 253 253 253 253 253 231 231 231 246 246 246
45174 -253 253 253 253 253 253 253 253 253 253 253 253
45175 -253 253 253 253 253 253 253 253 253 253 253 253
45176 -253 253 253 253 253 253 253 253 253 253 253 253
45177 -253 253 253 253 253 253 253 253 253 253 253 253
45178 -253 253 253 253 253 253 234 234 234 14 14 14
45179 - 2 2 6 2 2 6 30 30 30 2 2 6
45180 - 2 2 6 2 2 6 2 2 6 2 2 6
45181 - 2 2 6 66 66 66 62 62 62 22 22 22
45182 - 6 6 6 0 0 0 0 0 0 0 0 0
45183 - 0 0 0 0 0 0 0 0 0 0 0 0
45184 - 0 0 0 0 0 0 0 0 0 0 0 0
45185 - 0 0 0 0 0 0 0 0 0 0 0 0
45186 - 0 0 0 0 0 0 0 0 0 0 0 0
45187 - 0 0 0 0 0 0 0 0 0 0 0 0
45188 - 0 0 0 0 0 0 6 6 6 18 18 18
45189 - 54 54 54 62 62 62 2 2 6 2 2 6
45190 - 2 2 6 30 30 30 46 46 46 70 70 70
45191 -250 250 250 253 253 253 253 253 253 253 253 253
45192 -253 253 253 253 253 253 253 253 253 253 253 253
45193 -253 253 253 253 253 253 231 231 231 246 246 246
45194 -253 253 253 253 253 253 253 253 253 253 253 253
45195 -253 253 253 253 253 253 253 253 253 253 253 253
45196 -253 253 253 253 253 253 253 253 253 253 253 253
45197 -253 253 253 253 253 253 253 253 253 253 253 253
45198 -253 253 253 253 253 253 226 226 226 10 10 10
45199 - 2 2 6 6 6 6 30 30 30 2 2 6
45200 - 2 2 6 2 2 6 2 2 6 2 2 6
45201 - 2 2 6 66 66 66 58 58 58 22 22 22
45202 - 6 6 6 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 6 6 6 22 22 22
45209 - 58 58 58 62 62 62 2 2 6 2 2 6
45210 - 2 2 6 2 2 6 30 30 30 78 78 78
45211 -250 250 250 253 253 253 253 253 253 253 253 253
45212 -253 253 253 253 253 253 253 253 253 253 253 253
45213 -253 253 253 253 253 253 231 231 231 246 246 246
45214 -253 253 253 253 253 253 253 253 253 253 253 253
45215 -253 253 253 253 253 253 253 253 253 253 253 253
45216 -253 253 253 253 253 253 253 253 253 253 253 253
45217 -253 253 253 253 253 253 253 253 253 253 253 253
45218 -253 253 253 253 253 253 206 206 206 2 2 6
45219 - 22 22 22 34 34 34 18 14 6 22 22 22
45220 - 26 26 26 18 18 18 6 6 6 2 2 6
45221 - 2 2 6 82 82 82 54 54 54 18 18 18
45222 - 6 6 6 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 6 6 6 26 26 26
45229 - 62 62 62 106 106 106 74 54 14 185 133 11
45230 -210 162 10 121 92 8 6 6 6 62 62 62
45231 -238 238 238 253 253 253 253 253 253 253 253 253
45232 -253 253 253 253 253 253 253 253 253 253 253 253
45233 -253 253 253 253 253 253 231 231 231 246 246 246
45234 -253 253 253 253 253 253 253 253 253 253 253 253
45235 -253 253 253 253 253 253 253 253 253 253 253 253
45236 -253 253 253 253 253 253 253 253 253 253 253 253
45237 -253 253 253 253 253 253 253 253 253 253 253 253
45238 -253 253 253 253 253 253 158 158 158 18 18 18
45239 - 14 14 14 2 2 6 2 2 6 2 2 6
45240 - 6 6 6 18 18 18 66 66 66 38 38 38
45241 - 6 6 6 94 94 94 50 50 50 18 18 18
45242 - 6 6 6 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 6 6 6
45248 - 10 10 10 10 10 10 18 18 18 38 38 38
45249 - 78 78 78 142 134 106 216 158 10 242 186 14
45250 -246 190 14 246 190 14 156 118 10 10 10 10
45251 - 90 90 90 238 238 238 253 253 253 253 253 253
45252 -253 253 253 253 253 253 253 253 253 253 253 253
45253 -253 253 253 253 253 253 231 231 231 250 250 250
45254 -253 253 253 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 253 253 253 253 253 253 253 253 253
45257 -253 253 253 253 253 253 253 253 253 246 230 190
45258 -238 204 91 238 204 91 181 142 44 37 26 9
45259 - 2 2 6 2 2 6 2 2 6 2 2 6
45260 - 2 2 6 2 2 6 38 38 38 46 46 46
45261 - 26 26 26 106 106 106 54 54 54 18 18 18
45262 - 6 6 6 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 6 6 6 14 14 14 22 22 22
45268 - 30 30 30 38 38 38 50 50 50 70 70 70
45269 -106 106 106 190 142 34 226 170 11 242 186 14
45270 -246 190 14 246 190 14 246 190 14 154 114 10
45271 - 6 6 6 74 74 74 226 226 226 253 253 253
45272 -253 253 253 253 253 253 253 253 253 253 253 253
45273 -253 253 253 253 253 253 231 231 231 250 250 250
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 253 253 253 253 253 253 253 253 253
45277 -253 253 253 253 253 253 253 253 253 228 184 62
45278 -241 196 14 241 208 19 232 195 16 38 30 10
45279 - 2 2 6 2 2 6 2 2 6 2 2 6
45280 - 2 2 6 6 6 6 30 30 30 26 26 26
45281 -203 166 17 154 142 90 66 66 66 26 26 26
45282 - 6 6 6 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 - 6 6 6 18 18 18 38 38 38 58 58 58
45288 - 78 78 78 86 86 86 101 101 101 123 123 123
45289 -175 146 61 210 150 10 234 174 13 246 186 14
45290 -246 190 14 246 190 14 246 190 14 238 190 10
45291 -102 78 10 2 2 6 46 46 46 198 198 198
45292 -253 253 253 253 253 253 253 253 253 253 253 253
45293 -253 253 253 253 253 253 234 234 234 242 242 242
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 253 253 253 253 253 253 253 253 253
45297 -253 253 253 253 253 253 253 253 253 224 178 62
45298 -242 186 14 241 196 14 210 166 10 22 18 6
45299 - 2 2 6 2 2 6 2 2 6 2 2 6
45300 - 2 2 6 2 2 6 6 6 6 121 92 8
45301 -238 202 15 232 195 16 82 82 82 34 34 34
45302 - 10 10 10 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 - 14 14 14 38 38 38 70 70 70 154 122 46
45308 -190 142 34 200 144 11 197 138 11 197 138 11
45309 -213 154 11 226 170 11 242 186 14 246 190 14
45310 -246 190 14 246 190 14 246 190 14 246 190 14
45311 -225 175 15 46 32 6 2 2 6 22 22 22
45312 -158 158 158 250 250 250 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 -253 253 253 253 253 253 253 253 253 253 253 253
45317 -253 253 253 250 250 250 242 242 242 224 178 62
45318 -239 182 13 236 186 11 213 154 11 46 32 6
45319 - 2 2 6 2 2 6 2 2 6 2 2 6
45320 - 2 2 6 2 2 6 61 42 6 225 175 15
45321 -238 190 10 236 186 11 112 100 78 42 42 42
45322 - 14 14 14 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 6 6 6
45327 - 22 22 22 54 54 54 154 122 46 213 154 11
45328 -226 170 11 230 174 11 226 170 11 226 170 11
45329 -236 178 12 242 186 14 246 190 14 246 190 14
45330 -246 190 14 246 190 14 246 190 14 246 190 14
45331 -241 196 14 184 144 12 10 10 10 2 2 6
45332 - 6 6 6 116 116 116 242 242 242 253 253 253
45333 -253 253 253 253 253 253 253 253 253 253 253 253
45334 -253 253 253 253 253 253 253 253 253 253 253 253
45335 -253 253 253 253 253 253 253 253 253 253 253 253
45336 -253 253 253 253 253 253 253 253 253 253 253 253
45337 -253 253 253 231 231 231 198 198 198 214 170 54
45338 -236 178 12 236 178 12 210 150 10 137 92 6
45339 - 18 14 6 2 2 6 2 2 6 2 2 6
45340 - 6 6 6 70 47 6 200 144 11 236 178 12
45341 -239 182 13 239 182 13 124 112 88 58 58 58
45342 - 22 22 22 6 6 6 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 10 10 10
45347 - 30 30 30 70 70 70 180 133 36 226 170 11
45348 -239 182 13 242 186 14 242 186 14 246 186 14
45349 -246 190 14 246 190 14 246 190 14 246 190 14
45350 -246 190 14 246 190 14 246 190 14 246 190 14
45351 -246 190 14 232 195 16 98 70 6 2 2 6
45352 - 2 2 6 2 2 6 66 66 66 221 221 221
45353 -253 253 253 253 253 253 253 253 253 253 253 253
45354 -253 253 253 253 253 253 253 253 253 253 253 253
45355 -253 253 253 253 253 253 253 253 253 253 253 253
45356 -253 253 253 253 253 253 253 253 253 253 253 253
45357 -253 253 253 206 206 206 198 198 198 214 166 58
45358 -230 174 11 230 174 11 216 158 10 192 133 9
45359 -163 110 8 116 81 8 102 78 10 116 81 8
45360 -167 114 7 197 138 11 226 170 11 239 182 13
45361 -242 186 14 242 186 14 162 146 94 78 78 78
45362 - 34 34 34 14 14 14 6 6 6 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 6 6 6
45367 - 30 30 30 78 78 78 190 142 34 226 170 11
45368 -239 182 13 246 190 14 246 190 14 246 190 14
45369 -246 190 14 246 190 14 246 190 14 246 190 14
45370 -246 190 14 246 190 14 246 190 14 246 190 14
45371 -246 190 14 241 196 14 203 166 17 22 18 6
45372 - 2 2 6 2 2 6 2 2 6 38 38 38
45373 -218 218 218 253 253 253 253 253 253 253 253 253
45374 -253 253 253 253 253 253 253 253 253 253 253 253
45375 -253 253 253 253 253 253 253 253 253 253 253 253
45376 -253 253 253 253 253 253 253 253 253 253 253 253
45377 -250 250 250 206 206 206 198 198 198 202 162 69
45378 -226 170 11 236 178 12 224 166 10 210 150 10
45379 -200 144 11 197 138 11 192 133 9 197 138 11
45380 -210 150 10 226 170 11 242 186 14 246 190 14
45381 -246 190 14 246 186 14 225 175 15 124 112 88
45382 - 62 62 62 30 30 30 14 14 14 6 6 6
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 10 10 10
45387 - 30 30 30 78 78 78 174 135 50 224 166 10
45388 -239 182 13 246 190 14 246 190 14 246 190 14
45389 -246 190 14 246 190 14 246 190 14 246 190 14
45390 -246 190 14 246 190 14 246 190 14 246 190 14
45391 -246 190 14 246 190 14 241 196 14 139 102 15
45392 - 2 2 6 2 2 6 2 2 6 2 2 6
45393 - 78 78 78 250 250 250 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 253 253 253
45396 -253 253 253 253 253 253 253 253 253 253 253 253
45397 -250 250 250 214 214 214 198 198 198 190 150 46
45398 -219 162 10 236 178 12 234 174 13 224 166 10
45399 -216 158 10 213 154 11 213 154 11 216 158 10
45400 -226 170 11 239 182 13 246 190 14 246 190 14
45401 -246 190 14 246 190 14 242 186 14 206 162 42
45402 -101 101 101 58 58 58 30 30 30 14 14 14
45403 - 6 6 6 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 10 10 10
45407 - 30 30 30 74 74 74 174 135 50 216 158 10
45408 -236 178 12 246 190 14 246 190 14 246 190 14
45409 -246 190 14 246 190 14 246 190 14 246 190 14
45410 -246 190 14 246 190 14 246 190 14 246 190 14
45411 -246 190 14 246 190 14 241 196 14 226 184 13
45412 - 61 42 6 2 2 6 2 2 6 2 2 6
45413 - 22 22 22 238 238 238 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 253 253 253 253 253 253 253 253 253
45417 -253 253 253 226 226 226 187 187 187 180 133 36
45418 -216 158 10 236 178 12 239 182 13 236 178 12
45419 -230 174 11 226 170 11 226 170 11 230 174 11
45420 -236 178 12 242 186 14 246 190 14 246 190 14
45421 -246 190 14 246 190 14 246 186 14 239 182 13
45422 -206 162 42 106 106 106 66 66 66 34 34 34
45423 - 14 14 14 6 6 6 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 6 6 6
45427 - 26 26 26 70 70 70 163 133 67 213 154 11
45428 -236 178 12 246 190 14 246 190 14 246 190 14
45429 -246 190 14 246 190 14 246 190 14 246 190 14
45430 -246 190 14 246 190 14 246 190 14 246 190 14
45431 -246 190 14 246 190 14 246 190 14 241 196 14
45432 -190 146 13 18 14 6 2 2 6 2 2 6
45433 - 46 46 46 246 246 246 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 253 253 253 253 253 253
45437 -253 253 253 221 221 221 86 86 86 156 107 11
45438 -216 158 10 236 178 12 242 186 14 246 186 14
45439 -242 186 14 239 182 13 239 182 13 242 186 14
45440 -242 186 14 246 186 14 246 190 14 246 190 14
45441 -246 190 14 246 190 14 246 190 14 246 190 14
45442 -242 186 14 225 175 15 142 122 72 66 66 66
45443 - 30 30 30 10 10 10 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 6 6 6
45447 - 26 26 26 70 70 70 163 133 67 210 150 10
45448 -236 178 12 246 190 14 246 190 14 246 190 14
45449 -246 190 14 246 190 14 246 190 14 246 190 14
45450 -246 190 14 246 190 14 246 190 14 246 190 14
45451 -246 190 14 246 190 14 246 190 14 246 190 14
45452 -232 195 16 121 92 8 34 34 34 106 106 106
45453 -221 221 221 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 253 253 253
45457 -242 242 242 82 82 82 18 14 6 163 110 8
45458 -216 158 10 236 178 12 242 186 14 246 190 14
45459 -246 190 14 246 190 14 246 190 14 246 190 14
45460 -246 190 14 246 190 14 246 190 14 246 190 14
45461 -246 190 14 246 190 14 246 190 14 246 190 14
45462 -246 190 14 246 190 14 242 186 14 163 133 67
45463 - 46 46 46 18 18 18 6 6 6 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 10 10 10
45467 - 30 30 30 78 78 78 163 133 67 210 150 10
45468 -236 178 12 246 186 14 246 190 14 246 190 14
45469 -246 190 14 246 190 14 246 190 14 246 190 14
45470 -246 190 14 246 190 14 246 190 14 246 190 14
45471 -246 190 14 246 190 14 246 190 14 246 190 14
45472 -241 196 14 215 174 15 190 178 144 253 253 253
45473 -253 253 253 253 253 253 253 253 253 253 253 253
45474 -253 253 253 253 253 253 253 253 253 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 218 218 218
45477 - 58 58 58 2 2 6 22 18 6 167 114 7
45478 -216 158 10 236 178 12 246 186 14 246 190 14
45479 -246 190 14 246 190 14 246 190 14 246 190 14
45480 -246 190 14 246 190 14 246 190 14 246 190 14
45481 -246 190 14 246 190 14 246 190 14 246 190 14
45482 -246 190 14 246 186 14 242 186 14 190 150 46
45483 - 54 54 54 22 22 22 6 6 6 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 14 14 14
45487 - 38 38 38 86 86 86 180 133 36 213 154 11
45488 -236 178 12 246 186 14 246 190 14 246 190 14
45489 -246 190 14 246 190 14 246 190 14 246 190 14
45490 -246 190 14 246 190 14 246 190 14 246 190 14
45491 -246 190 14 246 190 14 246 190 14 246 190 14
45492 -246 190 14 232 195 16 190 146 13 214 214 214
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 250 250 250 170 170 170 26 26 26
45497 - 2 2 6 2 2 6 37 26 9 163 110 8
45498 -219 162 10 239 182 13 246 186 14 246 190 14
45499 -246 190 14 246 190 14 246 190 14 246 190 14
45500 -246 190 14 246 190 14 246 190 14 246 190 14
45501 -246 190 14 246 190 14 246 190 14 246 190 14
45502 -246 186 14 236 178 12 224 166 10 142 122 72
45503 - 46 46 46 18 18 18 6 6 6 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 6 6 6 18 18 18
45507 - 50 50 50 109 106 95 192 133 9 224 166 10
45508 -242 186 14 246 190 14 246 190 14 246 190 14
45509 -246 190 14 246 190 14 246 190 14 246 190 14
45510 -246 190 14 246 190 14 246 190 14 246 190 14
45511 -246 190 14 246 190 14 246 190 14 246 190 14
45512 -242 186 14 226 184 13 210 162 10 142 110 46
45513 -226 226 226 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 -198 198 198 66 66 66 2 2 6 2 2 6
45517 - 2 2 6 2 2 6 50 34 6 156 107 11
45518 -219 162 10 239 182 13 246 186 14 246 190 14
45519 -246 190 14 246 190 14 246 190 14 246 190 14
45520 -246 190 14 246 190 14 246 190 14 246 190 14
45521 -246 190 14 246 190 14 246 190 14 242 186 14
45522 -234 174 13 213 154 11 154 122 46 66 66 66
45523 - 30 30 30 10 10 10 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 6 6 6 22 22 22
45527 - 58 58 58 154 121 60 206 145 10 234 174 13
45528 -242 186 14 246 186 14 246 190 14 246 190 14
45529 -246 190 14 246 190 14 246 190 14 246 190 14
45530 -246 190 14 246 190 14 246 190 14 246 190 14
45531 -246 190 14 246 190 14 246 190 14 246 190 14
45532 -246 186 14 236 178 12 210 162 10 163 110 8
45533 - 61 42 6 138 138 138 218 218 218 250 250 250
45534 -253 253 253 253 253 253 253 253 253 250 250 250
45535 -242 242 242 210 210 210 144 144 144 66 66 66
45536 - 6 6 6 2 2 6 2 2 6 2 2 6
45537 - 2 2 6 2 2 6 61 42 6 163 110 8
45538 -216 158 10 236 178 12 246 190 14 246 190 14
45539 -246 190 14 246 190 14 246 190 14 246 190 14
45540 -246 190 14 246 190 14 246 190 14 246 190 14
45541 -246 190 14 239 182 13 230 174 11 216 158 10
45542 -190 142 34 124 112 88 70 70 70 38 38 38
45543 - 18 18 18 6 6 6 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 6 6 6 22 22 22
45547 - 62 62 62 168 124 44 206 145 10 224 166 10
45548 -236 178 12 239 182 13 242 186 14 242 186 14
45549 -246 186 14 246 190 14 246 190 14 246 190 14
45550 -246 190 14 246 190 14 246 190 14 246 190 14
45551 -246 190 14 246 190 14 246 190 14 246 190 14
45552 -246 190 14 236 178 12 216 158 10 175 118 6
45553 - 80 54 7 2 2 6 6 6 6 30 30 30
45554 - 54 54 54 62 62 62 50 50 50 38 38 38
45555 - 14 14 14 2 2 6 2 2 6 2 2 6
45556 - 2 2 6 2 2 6 2 2 6 2 2 6
45557 - 2 2 6 6 6 6 80 54 7 167 114 7
45558 -213 154 11 236 178 12 246 190 14 246 190 14
45559 -246 190 14 246 190 14 246 190 14 246 190 14
45560 -246 190 14 242 186 14 239 182 13 239 182 13
45561 -230 174 11 210 150 10 174 135 50 124 112 88
45562 - 82 82 82 54 54 54 34 34 34 18 18 18
45563 - 6 6 6 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 6 6 6 18 18 18
45567 - 50 50 50 158 118 36 192 133 9 200 144 11
45568 -216 158 10 219 162 10 224 166 10 226 170 11
45569 -230 174 11 236 178 12 239 182 13 239 182 13
45570 -242 186 14 246 186 14 246 190 14 246 190 14
45571 -246 190 14 246 190 14 246 190 14 246 190 14
45572 -246 186 14 230 174 11 210 150 10 163 110 8
45573 -104 69 6 10 10 10 2 2 6 2 2 6
45574 - 2 2 6 2 2 6 2 2 6 2 2 6
45575 - 2 2 6 2 2 6 2 2 6 2 2 6
45576 - 2 2 6 2 2 6 2 2 6 2 2 6
45577 - 2 2 6 6 6 6 91 60 6 167 114 7
45578 -206 145 10 230 174 11 242 186 14 246 190 14
45579 -246 190 14 246 190 14 246 186 14 242 186 14
45580 -239 182 13 230 174 11 224 166 10 213 154 11
45581 -180 133 36 124 112 88 86 86 86 58 58 58
45582 - 38 38 38 22 22 22 10 10 10 6 6 6
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 14 14 14
45587 - 34 34 34 70 70 70 138 110 50 158 118 36
45588 -167 114 7 180 123 7 192 133 9 197 138 11
45589 -200 144 11 206 145 10 213 154 11 219 162 10
45590 -224 166 10 230 174 11 239 182 13 242 186 14
45591 -246 186 14 246 186 14 246 186 14 246 186 14
45592 -239 182 13 216 158 10 185 133 11 152 99 6
45593 -104 69 6 18 14 6 2 2 6 2 2 6
45594 - 2 2 6 2 2 6 2 2 6 2 2 6
45595 - 2 2 6 2 2 6 2 2 6 2 2 6
45596 - 2 2 6 2 2 6 2 2 6 2 2 6
45597 - 2 2 6 6 6 6 80 54 7 152 99 6
45598 -192 133 9 219 162 10 236 178 12 239 182 13
45599 -246 186 14 242 186 14 239 182 13 236 178 12
45600 -224 166 10 206 145 10 192 133 9 154 121 60
45601 - 94 94 94 62 62 62 42 42 42 22 22 22
45602 - 14 14 14 6 6 6 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 6 6 6
45607 - 18 18 18 34 34 34 58 58 58 78 78 78
45608 -101 98 89 124 112 88 142 110 46 156 107 11
45609 -163 110 8 167 114 7 175 118 6 180 123 7
45610 -185 133 11 197 138 11 210 150 10 219 162 10
45611 -226 170 11 236 178 12 236 178 12 234 174 13
45612 -219 162 10 197 138 11 163 110 8 130 83 6
45613 - 91 60 6 10 10 10 2 2 6 2 2 6
45614 - 18 18 18 38 38 38 38 38 38 38 38 38
45615 - 38 38 38 38 38 38 38 38 38 38 38 38
45616 - 38 38 38 38 38 38 26 26 26 2 2 6
45617 - 2 2 6 6 6 6 70 47 6 137 92 6
45618 -175 118 6 200 144 11 219 162 10 230 174 11
45619 -234 174 13 230 174 11 219 162 10 210 150 10
45620 -192 133 9 163 110 8 124 112 88 82 82 82
45621 - 50 50 50 30 30 30 14 14 14 6 6 6
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 - 6 6 6 14 14 14 22 22 22 34 34 34
45628 - 42 42 42 58 58 58 74 74 74 86 86 86
45629 -101 98 89 122 102 70 130 98 46 121 87 25
45630 -137 92 6 152 99 6 163 110 8 180 123 7
45631 -185 133 11 197 138 11 206 145 10 200 144 11
45632 -180 123 7 156 107 11 130 83 6 104 69 6
45633 - 50 34 6 54 54 54 110 110 110 101 98 89
45634 - 86 86 86 82 82 82 78 78 78 78 78 78
45635 - 78 78 78 78 78 78 78 78 78 78 78 78
45636 - 78 78 78 82 82 82 86 86 86 94 94 94
45637 -106 106 106 101 101 101 86 66 34 124 80 6
45638 -156 107 11 180 123 7 192 133 9 200 144 11
45639 -206 145 10 200 144 11 192 133 9 175 118 6
45640 -139 102 15 109 106 95 70 70 70 42 42 42
45641 - 22 22 22 10 10 10 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 10 10 10
45648 - 14 14 14 22 22 22 30 30 30 38 38 38
45649 - 50 50 50 62 62 62 74 74 74 90 90 90
45650 -101 98 89 112 100 78 121 87 25 124 80 6
45651 -137 92 6 152 99 6 152 99 6 152 99 6
45652 -138 86 6 124 80 6 98 70 6 86 66 30
45653 -101 98 89 82 82 82 58 58 58 46 46 46
45654 - 38 38 38 34 34 34 34 34 34 34 34 34
45655 - 34 34 34 34 34 34 34 34 34 34 34 34
45656 - 34 34 34 34 34 34 38 38 38 42 42 42
45657 - 54 54 54 82 82 82 94 86 76 91 60 6
45658 -134 86 6 156 107 11 167 114 7 175 118 6
45659 -175 118 6 167 114 7 152 99 6 121 87 25
45660 -101 98 89 62 62 62 34 34 34 18 18 18
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 0 0 0 0 0 0
45668 - 0 0 0 6 6 6 6 6 6 10 10 10
45669 - 18 18 18 22 22 22 30 30 30 42 42 42
45670 - 50 50 50 66 66 66 86 86 86 101 98 89
45671 -106 86 58 98 70 6 104 69 6 104 69 6
45672 -104 69 6 91 60 6 82 62 34 90 90 90
45673 - 62 62 62 38 38 38 22 22 22 14 14 14
45674 - 10 10 10 10 10 10 10 10 10 10 10 10
45675 - 10 10 10 10 10 10 6 6 6 10 10 10
45676 - 10 10 10 10 10 10 10 10 10 14 14 14
45677 - 22 22 22 42 42 42 70 70 70 89 81 66
45678 - 80 54 7 104 69 6 124 80 6 137 92 6
45679 -134 86 6 116 81 8 100 82 52 86 86 86
45680 - 58 58 58 30 30 30 14 14 14 6 6 6
45681 - 0 0 0 0 0 0 0 0 0 0 0 0
45682 - 0 0 0 0 0 0 0 0 0 0 0 0
45683 - 0 0 0 0 0 0 0 0 0 0 0 0
45684 - 0 0 0 0 0 0 0 0 0 0 0 0
45685 - 0 0 0 0 0 0 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 0 0 0 0 0 0
45688 - 0 0 0 0 0 0 0 0 0 0 0 0
45689 - 0 0 0 6 6 6 10 10 10 14 14 14
45690 - 18 18 18 26 26 26 38 38 38 54 54 54
45691 - 70 70 70 86 86 86 94 86 76 89 81 66
45692 - 89 81 66 86 86 86 74 74 74 50 50 50
45693 - 30 30 30 14 14 14 6 6 6 0 0 0
45694 - 0 0 0 0 0 0 0 0 0 0 0 0
45695 - 0 0 0 0 0 0 0 0 0 0 0 0
45696 - 0 0 0 0 0 0 0 0 0 0 0 0
45697 - 6 6 6 18 18 18 34 34 34 58 58 58
45698 - 82 82 82 89 81 66 89 81 66 89 81 66
45699 - 94 86 66 94 86 76 74 74 74 50 50 50
45700 - 26 26 26 14 14 14 6 6 6 0 0 0
45701 - 0 0 0 0 0 0 0 0 0 0 0 0
45702 - 0 0 0 0 0 0 0 0 0 0 0 0
45703 - 0 0 0 0 0 0 0 0 0 0 0 0
45704 - 0 0 0 0 0 0 0 0 0 0 0 0
45705 - 0 0 0 0 0 0 0 0 0 0 0 0
45706 - 0 0 0 0 0 0 0 0 0 0 0 0
45707 - 0 0 0 0 0 0 0 0 0 0 0 0
45708 - 0 0 0 0 0 0 0 0 0 0 0 0
45709 - 0 0 0 0 0 0 0 0 0 0 0 0
45710 - 6 6 6 6 6 6 14 14 14 18 18 18
45711 - 30 30 30 38 38 38 46 46 46 54 54 54
45712 - 50 50 50 42 42 42 30 30 30 18 18 18
45713 - 10 10 10 0 0 0 0 0 0 0 0 0
45714 - 0 0 0 0 0 0 0 0 0 0 0 0
45715 - 0 0 0 0 0 0 0 0 0 0 0 0
45716 - 0 0 0 0 0 0 0 0 0 0 0 0
45717 - 0 0 0 6 6 6 14 14 14 26 26 26
45718 - 38 38 38 50 50 50 58 58 58 58 58 58
45719 - 54 54 54 42 42 42 30 30 30 18 18 18
45720 - 10 10 10 0 0 0 0 0 0 0 0 0
45721 - 0 0 0 0 0 0 0 0 0 0 0 0
45722 - 0 0 0 0 0 0 0 0 0 0 0 0
45723 - 0 0 0 0 0 0 0 0 0 0 0 0
45724 - 0 0 0 0 0 0 0 0 0 0 0 0
45725 - 0 0 0 0 0 0 0 0 0 0 0 0
45726 - 0 0 0 0 0 0 0 0 0 0 0 0
45727 - 0 0 0 0 0 0 0 0 0 0 0 0
45728 - 0 0 0 0 0 0 0 0 0 0 0 0
45729 - 0 0 0 0 0 0 0 0 0 0 0 0
45730 - 0 0 0 0 0 0 0 0 0 6 6 6
45731 - 6 6 6 10 10 10 14 14 14 18 18 18
45732 - 18 18 18 14 14 14 10 10 10 6 6 6
45733 - 0 0 0 0 0 0 0 0 0 0 0 0
45734 - 0 0 0 0 0 0 0 0 0 0 0 0
45735 - 0 0 0 0 0 0 0 0 0 0 0 0
45736 - 0 0 0 0 0 0 0 0 0 0 0 0
45737 - 0 0 0 0 0 0 0 0 0 6 6 6
45738 - 14 14 14 18 18 18 22 22 22 22 22 22
45739 - 18 18 18 14 14 14 10 10 10 6 6 6
45740 - 0 0 0 0 0 0 0 0 0 0 0 0
45741 - 0 0 0 0 0 0 0 0 0 0 0 0
45742 - 0 0 0 0 0 0 0 0 0 0 0 0
45743 - 0 0 0 0 0 0 0 0 0 0 0 0
45744 - 0 0 0 0 0 0 0 0 0 0 0 0
45745 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45746 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45747 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45748 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45749 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45750 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45751 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45752 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45754 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45755 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45756 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45757 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45758 +4 4 4 4 4 4
45759 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45760 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45761 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45762 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45763 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45764 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45766 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45768 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45770 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45771 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45772 +4 4 4 4 4 4
45773 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45774 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45775 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45776 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45777 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45778 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45779 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45780 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45781 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45782 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45783 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45784 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45785 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45786 +4 4 4 4 4 4
45787 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45788 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45789 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45790 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45791 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45792 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45793 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45794 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45795 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45796 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45797 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45798 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45799 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45800 +4 4 4 4 4 4
45801 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45802 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45803 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45804 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45805 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45806 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45807 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45808 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45809 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45810 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45811 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45812 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45813 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45814 +4 4 4 4 4 4
45815 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45816 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45817 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45818 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45819 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45820 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45821 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45822 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45823 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45824 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45825 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45826 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45827 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45828 +4 4 4 4 4 4
45829 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45830 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45831 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45832 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45833 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
45834 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
45835 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45836 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45838 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
45839 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
45840 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
45841 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45842 +4 4 4 4 4 4
45843 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45844 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45845 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45846 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45847 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
45848 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
45849 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45850 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45852 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
45853 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
45854 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
45855 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45856 +4 4 4 4 4 4
45857 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45858 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45859 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45860 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45861 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
45862 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
45863 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
45864 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45866 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
45867 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
45868 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
45869 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
45870 +4 4 4 4 4 4
45871 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45872 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45873 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45874 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
45875 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
45876 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
45877 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
45878 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45879 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
45880 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
45881 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
45882 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
45883 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
45884 +4 4 4 4 4 4
45885 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45886 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45887 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45888 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
45889 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
45890 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
45891 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
45892 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
45893 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
45894 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
45895 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
45896 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
45897 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
45898 +4 4 4 4 4 4
45899 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45900 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45901 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
45902 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
45903 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
45904 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
45905 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
45906 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
45907 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
45908 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
45909 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
45910 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
45911 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
45912 +4 4 4 4 4 4
45913 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45914 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45915 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
45916 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
45917 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
45918 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
45919 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
45920 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
45921 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
45922 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
45923 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
45924 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
45925 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
45926 +4 4 4 4 4 4
45927 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45928 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45929 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
45930 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
45931 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
45932 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
45933 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
45934 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
45935 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
45936 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
45937 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
45938 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
45939 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
45940 +4 4 4 4 4 4
45941 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45942 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45943 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
45944 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
45945 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
45946 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
45947 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
45948 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
45949 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
45950 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
45951 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
45952 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
45953 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
45954 +4 4 4 4 4 4
45955 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45956 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45957 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
45958 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
45959 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
45960 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
45961 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
45962 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
45963 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
45964 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
45965 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
45966 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
45967 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
45968 +4 4 4 4 4 4
45969 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45970 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
45971 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
45972 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
45973 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
45974 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
45975 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
45976 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
45977 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
45978 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
45979 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
45980 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
45981 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
45982 +4 4 4 4 4 4
45983 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
45984 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
45985 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
45986 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
45987 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
45988 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
45989 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
45990 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
45991 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
45992 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
45993 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
45994 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
45995 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
45996 +0 0 0 4 4 4
45997 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
45998 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
45999 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
46000 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
46001 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
46002 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
46003 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
46004 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
46005 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
46006 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
46007 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
46008 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
46009 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
46010 +2 0 0 0 0 0
46011 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
46012 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
46013 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
46014 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
46015 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
46016 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
46017 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
46018 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
46019 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
46020 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
46021 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
46022 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
46023 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
46024 +37 38 37 0 0 0
46025 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46026 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
46027 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
46028 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
46029 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
46030 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
46031 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
46032 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
46033 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
46034 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
46035 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
46036 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
46037 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
46038 +85 115 134 4 0 0
46039 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
46040 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
46041 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
46042 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
46043 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
46044 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
46045 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
46046 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
46047 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
46048 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
46049 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
46050 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
46051 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
46052 +60 73 81 4 0 0
46053 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
46054 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
46055 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
46056 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
46057 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
46058 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
46059 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
46060 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
46061 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
46062 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
46063 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
46064 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
46065 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
46066 +16 19 21 4 0 0
46067 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
46068 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
46069 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
46070 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
46071 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
46072 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
46073 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
46074 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
46075 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
46076 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
46077 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
46078 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
46079 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
46080 +4 0 0 4 3 3
46081 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
46082 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
46083 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
46084 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
46085 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
46086 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
46087 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
46088 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
46089 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
46090 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
46091 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
46092 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
46093 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
46094 +3 2 2 4 4 4
46095 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
46096 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
46097 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
46098 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46099 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
46100 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
46101 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
46102 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
46103 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
46104 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
46105 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
46106 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
46107 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
46108 +4 4 4 4 4 4
46109 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
46110 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
46111 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
46112 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
46113 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
46114 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
46115 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
46116 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
46117 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
46118 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
46119 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
46120 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
46121 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
46122 +4 4 4 4 4 4
46123 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
46124 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
46125 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
46126 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
46127 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
46128 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
46129 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
46130 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
46131 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
46132 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
46133 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
46134 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
46135 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
46136 +5 5 5 5 5 5
46137 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
46138 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
46139 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
46140 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
46141 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
46142 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46143 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
46144 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
46145 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
46146 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
46147 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
46148 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
46149 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
46150 +5 5 5 4 4 4
46151 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
46152 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
46153 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
46154 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
46155 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46156 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
46157 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
46158 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
46159 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
46160 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
46161 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
46162 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
46163 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46164 +4 4 4 4 4 4
46165 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
46166 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
46167 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
46168 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
46169 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
46170 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46171 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46172 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
46173 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
46174 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
46175 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
46176 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
46177 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46178 +4 4 4 4 4 4
46179 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
46180 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
46181 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
46182 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
46183 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46184 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
46185 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
46186 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
46187 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
46188 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
46189 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
46190 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46191 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46192 +4 4 4 4 4 4
46193 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
46194 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
46195 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
46196 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
46197 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46198 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46199 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46200 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
46201 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
46202 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
46203 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
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
46207 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
46208 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
46209 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
46210 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
46211 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46212 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
46213 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
46214 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
46215 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
46216 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
46217 +4 0 0 4 3 3 5 5 5 4 4 4 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
46221 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
46222 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
46223 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
46224 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
46225 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46226 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
46227 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
46228 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
46229 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
46230 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
46231 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
46232 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46233 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46234 +4 4 4 4 4 4
46235 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
46236 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
46237 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
46238 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
46239 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46240 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
46241 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
46242 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
46243 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
46244 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
46245 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
46246 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46247 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46248 +4 4 4 4 4 4
46249 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
46250 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
46251 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
46252 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
46253 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
46254 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
46255 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
46256 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
46257 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
46258 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
46259 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46260 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46261 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46262 +4 4 4 4 4 4
46263 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
46264 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
46265 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
46266 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
46267 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46268 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
46269 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
46270 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
46271 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
46272 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
46273 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46274 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46275 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46276 +4 4 4 4 4 4
46277 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
46278 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
46279 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
46280 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
46281 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46282 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
46283 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
46284 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
46285 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
46286 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
46287 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46288 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46289 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46290 +4 4 4 4 4 4
46291 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
46292 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
46293 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
46294 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
46295 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46296 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
46297 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
46298 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
46299 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
46300 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46301 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46302 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46303 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46304 +4 4 4 4 4 4
46305 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
46306 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
46307 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
46308 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
46309 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
46310 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
46311 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
46312 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
46313 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46314 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46315 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46316 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46317 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46318 +4 4 4 4 4 4
46319 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
46320 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
46321 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
46322 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
46323 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46324 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
46325 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
46326 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
46327 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46328 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46329 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46330 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46331 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46332 +4 4 4 4 4 4
46333 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
46334 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
46335 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
46336 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
46337 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
46338 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
46339 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
46340 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
46341 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46342 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46343 +0 0 0 3 3 3 5 5 5 4 4 4 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
46347 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
46348 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
46349 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46350 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
46351 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
46352 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
46353 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
46354 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
46355 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
46356 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46357 +0 0 0 3 3 3 5 5 5 4 4 4 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
46361 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
46362 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
46363 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
46364 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
46365 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
46366 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
46367 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
46368 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
46369 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46370 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46371 +0 0 0 3 3 3 5 5 5 4 4 4 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
46375 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
46376 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
46377 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46378 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
46379 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
46380 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
46381 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
46382 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
46383 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
46384 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46385 +0 0 0 3 3 3 5 5 5 4 4 4 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
46389 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
46390 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
46391 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
46392 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
46393 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
46394 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
46395 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
46396 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
46397 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46398 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46399 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46400 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46401 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46402 +4 4 4 4 4 4
46403 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46404 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
46405 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46406 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
46407 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
46408 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
46409 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
46410 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
46411 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46412 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46413 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46414 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46415 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46416 +4 4 4 4 4 4
46417 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
46418 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
46419 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
46420 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
46421 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
46422 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
46423 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46424 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
46425 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46426 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46427 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46428 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46429 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46430 +4 4 4 4 4 4
46431 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46432 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
46433 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
46434 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
46435 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
46436 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
46437 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46438 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
46439 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46440 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46441 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46442 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46443 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46444 +4 4 4 4 4 4
46445 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
46446 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
46447 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
46448 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
46449 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
46450 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
46451 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
46452 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
46453 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
46454 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46455 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46456 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46457 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46458 +4 4 4 4 4 4
46459 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46460 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
46461 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
46462 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
46463 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
46464 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
46465 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
46466 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
46467 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
46468 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46469 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46470 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46471 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46472 +4 4 4 4 4 4
46473 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
46474 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
46475 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
46476 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
46477 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
46478 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
46479 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
46480 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
46481 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
46482 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46483 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46484 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46485 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46486 +4 4 4 4 4 4
46487 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46488 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
46489 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
46490 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
46491 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
46492 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
46493 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
46494 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
46495 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
46496 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46497 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46498 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46499 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46500 +4 4 4 4 4 4
46501 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
46502 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
46503 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
46504 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
46505 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
46506 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
46507 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
46508 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
46509 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
46510 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
46511 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46512 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46513 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46514 +4 4 4 4 4 4
46515 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
46516 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
46517 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
46518 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
46519 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
46520 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
46521 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
46522 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
46523 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
46524 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
46525 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46526 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46527 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46528 +4 4 4 4 4 4
46529 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
46530 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
46531 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
46532 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
46533 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
46534 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
46535 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46536 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
46537 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
46538 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
46539 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46540 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46541 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46542 +4 4 4 4 4 4
46543 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
46544 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
46545 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
46546 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
46547 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
46548 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
46549 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
46550 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
46551 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
46552 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
46553 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46554 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46555 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46556 +4 4 4 4 4 4
46557 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
46558 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
46559 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
46560 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
46561 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
46562 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
46563 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
46564 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
46565 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
46566 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
46567 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46568 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46569 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46570 +4 4 4 4 4 4
46571 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
46572 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
46573 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
46574 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
46575 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
46576 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
46577 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
46578 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
46579 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
46580 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
46581 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46582 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46583 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46584 +4 4 4 4 4 4
46585 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
46586 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
46587 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
46588 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
46589 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
46590 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
46591 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
46592 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
46593 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
46594 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
46595 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46596 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46597 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46598 +4 4 4 4 4 4
46599 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
46600 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
46601 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
46602 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
46603 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
46604 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
46605 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
46606 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
46607 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
46608 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46609 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46610 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46611 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46612 +4 4 4 4 4 4
46613 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
46614 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
46615 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
46616 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
46617 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
46618 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
46619 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
46620 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
46621 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
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 4 4 4 4 4 4 4 4 4 4 4 4
46624 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46625 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46626 +4 4 4 4 4 4
46627 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
46628 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
46629 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
46630 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
46631 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
46632 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
46633 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
46634 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
46635 +4 0 0 4 0 0 4 0 0 6 6 6 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 4 4 4 4 4 4 4 4 4 4 4 4
46638 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46639 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46640 +4 4 4 4 4 4
46641 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
46642 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
46643 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
46644 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
46645 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
46646 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
46647 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
46648 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
46649 +4 0 0 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 4 4 4 4 4 4 4 4 4 4 4 4
46652 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46653 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46654 +4 4 4 4 4 4
46655 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
46656 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
46657 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
46658 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
46659 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
46660 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
46661 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
46662 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
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 4 4 4 4 4 4 4 4 4 4 4 4
46666 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46668 +4 4 4 4 4 4
46669 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
46670 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
46671 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
46672 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
46673 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
46674 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
46675 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
46676 +6 6 6 4 0 0 4 0 0 4 3 3 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 4 4 4 4 4 4 4 4 4 4 4 4
46680 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46681 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46682 +4 4 4 4 4 4
46683 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46684 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
46685 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
46686 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
46687 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
46688 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
46689 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
46690 +4 0 0 4 3 3 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 4 4 4 4 4 4 4 4 4 4 4 4
46694 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46695 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46696 +4 4 4 4 4 4
46697 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46698 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
46699 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
46700 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
46701 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
46702 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
46703 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
46704 +6 6 6 6 6 6 4 3 3 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
46708 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46709 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46710 +4 4 4 4 4 4
46711 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46712 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
46713 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
46714 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
46715 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
46716 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
46717 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
46718 +5 5 5 5 5 5 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
46722 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46723 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46724 +4 4 4 4 4 4
46725 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46726 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46727 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
46728 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
46729 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
46730 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
46731 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
46732 +4 3 3 5 5 5 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
46736 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46737 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46738 +4 4 4 4 4 4
46739 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46740 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46741 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46742 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
46743 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
46744 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
46745 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
46746 +4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
46750 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46751 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46752 +4 4 4 4 4 4
46753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46754 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46755 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46756 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
46757 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
46758 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
46759 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
46760 +4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
46764 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46766 +4 4 4 4 4 4
46767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46768 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46770 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
46771 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
46772 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
46773 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
46774 +4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
46778 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46779 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46780 +4 4 4 4 4 4
46781 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46782 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46783 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46784 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
46785 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
46786 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
46787 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
46788 +4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
46792 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46793 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46794 +4 4 4 4 4 4
46795 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46796 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46797 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46798 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46799 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
46800 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
46801 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46802 +4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
46806 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46807 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46808 +4 4 4 4 4 4
46809 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46810 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46811 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46812 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46813 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
46814 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
46815 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46816 +4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
46820 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46821 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46822 +4 4 4 4 4 4
46823 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46824 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46825 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46826 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46827 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
46828 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
46829 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46830 +4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
46834 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46835 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46836 +4 4 4 4 4 4
46837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46838 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46839 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46840 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46841 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
46842 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
46843 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46844 +4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
46848 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46849 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46850 +4 4 4 4 4 4
46851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46852 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46853 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46854 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46855 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
46856 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
46857 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46858 +4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
46862 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46863 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46864 +4 4 4 4 4 4
46865 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
46866 index fe92eed..106e085 100644
46867 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
46868 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
46869 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
46870 struct mb862xxfb_par *par = info->par;
46871
46872 if (info->var.bits_per_pixel == 32) {
46873 - info->fbops->fb_fillrect = cfb_fillrect;
46874 - info->fbops->fb_copyarea = cfb_copyarea;
46875 - info->fbops->fb_imageblit = cfb_imageblit;
46876 + pax_open_kernel();
46877 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
46878 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
46879 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
46880 + pax_close_kernel();
46881 } else {
46882 outreg(disp, GC_L0EM, 3);
46883 - info->fbops->fb_fillrect = mb86290fb_fillrect;
46884 - info->fbops->fb_copyarea = mb86290fb_copyarea;
46885 - info->fbops->fb_imageblit = mb86290fb_imageblit;
46886 + pax_open_kernel();
46887 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
46888 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
46889 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
46890 + pax_close_kernel();
46891 }
46892 outreg(draw, GDC_REG_DRAW_BASE, 0);
46893 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
46894 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
46895 index ff22871..b129bed 100644
46896 --- a/drivers/video/nvidia/nvidia.c
46897 +++ b/drivers/video/nvidia/nvidia.c
46898 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
46899 info->fix.line_length = (info->var.xres_virtual *
46900 info->var.bits_per_pixel) >> 3;
46901 if (info->var.accel_flags) {
46902 - info->fbops->fb_imageblit = nvidiafb_imageblit;
46903 - info->fbops->fb_fillrect = nvidiafb_fillrect;
46904 - info->fbops->fb_copyarea = nvidiafb_copyarea;
46905 - info->fbops->fb_sync = nvidiafb_sync;
46906 + pax_open_kernel();
46907 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
46908 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
46909 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
46910 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
46911 + pax_close_kernel();
46912 info->pixmap.scan_align = 4;
46913 info->flags &= ~FBINFO_HWACCEL_DISABLED;
46914 info->flags |= FBINFO_READS_FAST;
46915 NVResetGraphics(info);
46916 } else {
46917 - info->fbops->fb_imageblit = cfb_imageblit;
46918 - info->fbops->fb_fillrect = cfb_fillrect;
46919 - info->fbops->fb_copyarea = cfb_copyarea;
46920 - info->fbops->fb_sync = NULL;
46921 + pax_open_kernel();
46922 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
46923 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
46924 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
46925 + *(void **)&info->fbops->fb_sync = NULL;
46926 + pax_close_kernel();
46927 info->pixmap.scan_align = 1;
46928 info->flags |= FBINFO_HWACCEL_DISABLED;
46929 info->flags &= ~FBINFO_READS_FAST;
46930 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
46931 info->pixmap.size = 8 * 1024;
46932 info->pixmap.flags = FB_PIXMAP_SYSTEM;
46933
46934 - if (!hwcur)
46935 - info->fbops->fb_cursor = NULL;
46936 + if (!hwcur) {
46937 + pax_open_kernel();
46938 + *(void **)&info->fbops->fb_cursor = NULL;
46939 + pax_close_kernel();
46940 + }
46941
46942 info->var.accel_flags = (!noaccel);
46943
46944 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
46945 index 76d9053..dec2bfd 100644
46946 --- a/drivers/video/s1d13xxxfb.c
46947 +++ b/drivers/video/s1d13xxxfb.c
46948 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
46949
46950 switch(prod_id) {
46951 case S1D13506_PROD_ID: /* activate acceleration */
46952 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
46953 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
46954 + pax_open_kernel();
46955 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
46956 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
46957 + pax_close_kernel();
46958 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
46959 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
46960 break;
46961 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
46962 index 97bd662..39fab85 100644
46963 --- a/drivers/video/smscufx.c
46964 +++ b/drivers/video/smscufx.c
46965 @@ -1171,7 +1171,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
46966 fb_deferred_io_cleanup(info);
46967 kfree(info->fbdefio);
46968 info->fbdefio = NULL;
46969 - info->fbops->fb_mmap = ufx_ops_mmap;
46970 + pax_open_kernel();
46971 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
46972 + pax_close_kernel();
46973 }
46974
46975 pr_debug("released /dev/fb%d user=%d count=%d",
46976 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
46977 index 86d449e..8e04dc5 100644
46978 --- a/drivers/video/udlfb.c
46979 +++ b/drivers/video/udlfb.c
46980 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
46981 dlfb_urb_completion(urb);
46982
46983 error:
46984 - atomic_add(bytes_sent, &dev->bytes_sent);
46985 - atomic_add(bytes_identical, &dev->bytes_identical);
46986 - atomic_add(width*height*2, &dev->bytes_rendered);
46987 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
46988 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
46989 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
46990 end_cycles = get_cycles();
46991 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
46992 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
46993 >> 10)), /* Kcycles */
46994 &dev->cpu_kcycles_used);
46995
46996 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
46997 dlfb_urb_completion(urb);
46998
46999 error:
47000 - atomic_add(bytes_sent, &dev->bytes_sent);
47001 - atomic_add(bytes_identical, &dev->bytes_identical);
47002 - atomic_add(bytes_rendered, &dev->bytes_rendered);
47003 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47004 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47005 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
47006 end_cycles = get_cycles();
47007 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47008 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47009 >> 10)), /* Kcycles */
47010 &dev->cpu_kcycles_used);
47011 }
47012 @@ -989,7 +989,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
47013 fb_deferred_io_cleanup(info);
47014 kfree(info->fbdefio);
47015 info->fbdefio = NULL;
47016 - info->fbops->fb_mmap = dlfb_ops_mmap;
47017 + pax_open_kernel();
47018 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
47019 + pax_close_kernel();
47020 }
47021
47022 pr_warn("released /dev/fb%d user=%d count=%d\n",
47023 @@ -1372,7 +1374,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
47024 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47025 struct dlfb_data *dev = fb_info->par;
47026 return snprintf(buf, PAGE_SIZE, "%u\n",
47027 - atomic_read(&dev->bytes_rendered));
47028 + atomic_read_unchecked(&dev->bytes_rendered));
47029 }
47030
47031 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47032 @@ -1380,7 +1382,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47033 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47034 struct dlfb_data *dev = fb_info->par;
47035 return snprintf(buf, PAGE_SIZE, "%u\n",
47036 - atomic_read(&dev->bytes_identical));
47037 + atomic_read_unchecked(&dev->bytes_identical));
47038 }
47039
47040 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47041 @@ -1388,7 +1390,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47042 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47043 struct dlfb_data *dev = fb_info->par;
47044 return snprintf(buf, PAGE_SIZE, "%u\n",
47045 - atomic_read(&dev->bytes_sent));
47046 + atomic_read_unchecked(&dev->bytes_sent));
47047 }
47048
47049 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47050 @@ -1396,7 +1398,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47051 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47052 struct dlfb_data *dev = fb_info->par;
47053 return snprintf(buf, PAGE_SIZE, "%u\n",
47054 - atomic_read(&dev->cpu_kcycles_used));
47055 + atomic_read_unchecked(&dev->cpu_kcycles_used));
47056 }
47057
47058 static ssize_t edid_show(
47059 @@ -1456,10 +1458,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
47060 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47061 struct dlfb_data *dev = fb_info->par;
47062
47063 - atomic_set(&dev->bytes_rendered, 0);
47064 - atomic_set(&dev->bytes_identical, 0);
47065 - atomic_set(&dev->bytes_sent, 0);
47066 - atomic_set(&dev->cpu_kcycles_used, 0);
47067 + atomic_set_unchecked(&dev->bytes_rendered, 0);
47068 + atomic_set_unchecked(&dev->bytes_identical, 0);
47069 + atomic_set_unchecked(&dev->bytes_sent, 0);
47070 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
47071
47072 return count;
47073 }
47074 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
47075 index d428445..79a78df 100644
47076 --- a/drivers/video/uvesafb.c
47077 +++ b/drivers/video/uvesafb.c
47078 @@ -19,6 +19,7 @@
47079 #include <linux/io.h>
47080 #include <linux/mutex.h>
47081 #include <linux/slab.h>
47082 +#include <linux/moduleloader.h>
47083 #include <video/edid.h>
47084 #include <video/uvesafb.h>
47085 #ifdef CONFIG_X86
47086 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
47087 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
47088 par->pmi_setpal = par->ypan = 0;
47089 } else {
47090 +
47091 +#ifdef CONFIG_PAX_KERNEXEC
47092 +#ifdef CONFIG_MODULES
47093 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
47094 +#endif
47095 + if (!par->pmi_code) {
47096 + par->pmi_setpal = par->ypan = 0;
47097 + return 0;
47098 + }
47099 +#endif
47100 +
47101 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
47102 + task->t.regs.edi);
47103 +
47104 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47105 + pax_open_kernel();
47106 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
47107 + pax_close_kernel();
47108 +
47109 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
47110 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
47111 +#else
47112 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
47113 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
47114 +#endif
47115 +
47116 printk(KERN_INFO "uvesafb: protected mode interface info at "
47117 "%04x:%04x\n",
47118 (u16)task->t.regs.es, (u16)task->t.regs.edi);
47119 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
47120 par->ypan = ypan;
47121
47122 if (par->pmi_setpal || par->ypan) {
47123 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
47124 if (__supported_pte_mask & _PAGE_NX) {
47125 par->pmi_setpal = par->ypan = 0;
47126 printk(KERN_WARNING "uvesafb: NX protection is actively."
47127 "We have better not to use the PMI.\n");
47128 - } else {
47129 + } else
47130 +#endif
47131 uvesafb_vbe_getpmi(task, par);
47132 - }
47133 }
47134 #else
47135 /* The protected mode interface is not available on non-x86. */
47136 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
47137 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
47138
47139 /* Disable blanking if the user requested so. */
47140 - if (!blank)
47141 - info->fbops->fb_blank = NULL;
47142 + if (!blank) {
47143 + pax_open_kernel();
47144 + *(void **)&info->fbops->fb_blank = NULL;
47145 + pax_close_kernel();
47146 + }
47147
47148 /*
47149 * Find out how much IO memory is required for the mode with
47150 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
47151 info->flags = FBINFO_FLAG_DEFAULT |
47152 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
47153
47154 - if (!par->ypan)
47155 - info->fbops->fb_pan_display = NULL;
47156 + if (!par->ypan) {
47157 + pax_open_kernel();
47158 + *(void **)&info->fbops->fb_pan_display = NULL;
47159 + pax_close_kernel();
47160 + }
47161 }
47162
47163 static void uvesafb_init_mtrr(struct fb_info *info)
47164 @@ -1836,6 +1866,11 @@ out:
47165 if (par->vbe_modes)
47166 kfree(par->vbe_modes);
47167
47168 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47169 + if (par->pmi_code)
47170 + module_free_exec(NULL, par->pmi_code);
47171 +#endif
47172 +
47173 framebuffer_release(info);
47174 return err;
47175 }
47176 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
47177 kfree(par->vbe_state_orig);
47178 if (par->vbe_state_saved)
47179 kfree(par->vbe_state_saved);
47180 +
47181 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47182 + if (par->pmi_code)
47183 + module_free_exec(NULL, par->pmi_code);
47184 +#endif
47185 +
47186 }
47187
47188 framebuffer_release(info);
47189 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
47190 index 501b340..d80aa17 100644
47191 --- a/drivers/video/vesafb.c
47192 +++ b/drivers/video/vesafb.c
47193 @@ -9,6 +9,7 @@
47194 */
47195
47196 #include <linux/module.h>
47197 +#include <linux/moduleloader.h>
47198 #include <linux/kernel.h>
47199 #include <linux/errno.h>
47200 #include <linux/string.h>
47201 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
47202 static int vram_total __initdata; /* Set total amount of memory */
47203 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
47204 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
47205 -static void (*pmi_start)(void) __read_mostly;
47206 -static void (*pmi_pal) (void) __read_mostly;
47207 +static void (*pmi_start)(void) __read_only;
47208 +static void (*pmi_pal) (void) __read_only;
47209 static int depth __read_mostly;
47210 static int vga_compat __read_mostly;
47211 /* --------------------------------------------------------------------- */
47212 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
47213 unsigned int size_vmode;
47214 unsigned int size_remap;
47215 unsigned int size_total;
47216 + void *pmi_code = NULL;
47217
47218 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
47219 return -ENODEV;
47220 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
47221 size_remap = size_total;
47222 vesafb_fix.smem_len = size_remap;
47223
47224 -#ifndef __i386__
47225 - screen_info.vesapm_seg = 0;
47226 -#endif
47227 -
47228 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
47229 printk(KERN_WARNING
47230 "vesafb: cannot reserve video memory at 0x%lx\n",
47231 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
47232 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
47233 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
47234
47235 +#ifdef __i386__
47236 +
47237 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47238 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
47239 + if (!pmi_code)
47240 +#elif !defined(CONFIG_PAX_KERNEXEC)
47241 + if (0)
47242 +#endif
47243 +
47244 +#endif
47245 + screen_info.vesapm_seg = 0;
47246 +
47247 if (screen_info.vesapm_seg) {
47248 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
47249 - screen_info.vesapm_seg,screen_info.vesapm_off);
47250 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
47251 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
47252 }
47253
47254 if (screen_info.vesapm_seg < 0xc000)
47255 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
47256
47257 if (ypan || pmi_setpal) {
47258 unsigned short *pmi_base;
47259 +
47260 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
47261 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
47262 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
47263 +
47264 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47265 + pax_open_kernel();
47266 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
47267 +#else
47268 + pmi_code = pmi_base;
47269 +#endif
47270 +
47271 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
47272 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
47273 +
47274 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47275 + pmi_start = ktva_ktla(pmi_start);
47276 + pmi_pal = ktva_ktla(pmi_pal);
47277 + pax_close_kernel();
47278 +#endif
47279 +
47280 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
47281 if (pmi_base[3]) {
47282 printk(KERN_INFO "vesafb: pmi: ports = ");
47283 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
47284 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
47285 (ypan ? FBINFO_HWACCEL_YPAN : 0);
47286
47287 - if (!ypan)
47288 - info->fbops->fb_pan_display = NULL;
47289 + if (!ypan) {
47290 + pax_open_kernel();
47291 + *(void **)&info->fbops->fb_pan_display = NULL;
47292 + pax_close_kernel();
47293 + }
47294
47295 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
47296 err = -ENOMEM;
47297 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
47298 info->node, info->fix.id);
47299 return 0;
47300 err:
47301 +
47302 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47303 + module_free_exec(NULL, pmi_code);
47304 +#endif
47305 +
47306 if (info->screen_base)
47307 iounmap(info->screen_base);
47308 framebuffer_release(info);
47309 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
47310 index 88714ae..16c2e11 100644
47311 --- a/drivers/video/via/via_clock.h
47312 +++ b/drivers/video/via/via_clock.h
47313 @@ -56,7 +56,7 @@ struct via_clock {
47314
47315 void (*set_engine_pll_state)(u8 state);
47316 void (*set_engine_pll)(struct via_pll_config config);
47317 -};
47318 +} __no_const;
47319
47320
47321 static inline u32 get_pll_internal_frequency(u32 ref_freq,
47322 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
47323 index fef20db..d28b1ab 100644
47324 --- a/drivers/xen/xenfs/xenstored.c
47325 +++ b/drivers/xen/xenfs/xenstored.c
47326 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
47327 static int xsd_kva_open(struct inode *inode, struct file *file)
47328 {
47329 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
47330 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47331 + NULL);
47332 +#else
47333 xen_store_interface);
47334 +#endif
47335 +
47336 if (!file->private_data)
47337 return -ENOMEM;
47338 return 0;
47339 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
47340 index d86edc8..40ff2fb 100644
47341 --- a/fs/9p/vfs_inode.c
47342 +++ b/fs/9p/vfs_inode.c
47343 @@ -1314,7 +1314,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
47344 void
47345 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
47346 {
47347 - char *s = nd_get_link(nd);
47348 + const char *s = nd_get_link(nd);
47349
47350 p9_debug(P9_DEBUG_VFS, " %s %s\n",
47351 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
47352 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
47353 index 0efd152..b5802ad 100644
47354 --- a/fs/Kconfig.binfmt
47355 +++ b/fs/Kconfig.binfmt
47356 @@ -89,7 +89,7 @@ config HAVE_AOUT
47357
47358 config BINFMT_AOUT
47359 tristate "Kernel support for a.out and ECOFF binaries"
47360 - depends on HAVE_AOUT
47361 + depends on HAVE_AOUT && BROKEN
47362 ---help---
47363 A.out (Assembler.OUTput) is a set of formats for libraries and
47364 executables used in the earliest versions of UNIX. Linux used
47365 diff --git a/fs/aio.c b/fs/aio.c
47366 index 1dc8786..d3b29e8 100644
47367 --- a/fs/aio.c
47368 +++ b/fs/aio.c
47369 @@ -111,7 +111,7 @@ static int aio_setup_ring(struct kioctx *ctx)
47370 size += sizeof(struct io_event) * nr_events;
47371 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
47372
47373 - if (nr_pages < 0)
47374 + if (nr_pages <= 0)
47375 return -EINVAL;
47376
47377 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
47378 @@ -1375,18 +1375,19 @@ static ssize_t aio_fsync(struct kiocb *iocb)
47379 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
47380 {
47381 ssize_t ret;
47382 + struct iovec iovstack;
47383
47384 #ifdef CONFIG_COMPAT
47385 if (compat)
47386 ret = compat_rw_copy_check_uvector(type,
47387 (struct compat_iovec __user *)kiocb->ki_buf,
47388 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
47389 + kiocb->ki_nbytes, 1, &iovstack,
47390 &kiocb->ki_iovec);
47391 else
47392 #endif
47393 ret = rw_copy_check_uvector(type,
47394 (struct iovec __user *)kiocb->ki_buf,
47395 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
47396 + kiocb->ki_nbytes, 1, &iovstack,
47397 &kiocb->ki_iovec);
47398 if (ret < 0)
47399 goto out;
47400 @@ -1395,6 +1396,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
47401 if (ret < 0)
47402 goto out;
47403
47404 + if (kiocb->ki_iovec == &iovstack) {
47405 + kiocb->ki_inline_vec = iovstack;
47406 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
47407 + }
47408 kiocb->ki_nr_segs = kiocb->ki_nbytes;
47409 kiocb->ki_cur_seg = 0;
47410 /* ki_nbytes/left now reflect bytes instead of segs */
47411 diff --git a/fs/attr.c b/fs/attr.c
47412 index 1449adb..a2038c2 100644
47413 --- a/fs/attr.c
47414 +++ b/fs/attr.c
47415 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
47416 unsigned long limit;
47417
47418 limit = rlimit(RLIMIT_FSIZE);
47419 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
47420 if (limit != RLIM_INFINITY && offset > limit)
47421 goto out_sig;
47422 if (offset > inode->i_sb->s_maxbytes)
47423 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
47424 index 3db70da..7aeec5b 100644
47425 --- a/fs/autofs4/waitq.c
47426 +++ b/fs/autofs4/waitq.c
47427 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
47428 {
47429 unsigned long sigpipe, flags;
47430 mm_segment_t fs;
47431 - const char *data = (const char *)addr;
47432 + const char __user *data = (const char __force_user *)addr;
47433 ssize_t wr = 0;
47434
47435 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
47436 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
47437 return 1;
47438 }
47439
47440 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47441 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
47442 +#endif
47443 +
47444 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
47445 enum autofs_notify notify)
47446 {
47447 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
47448
47449 /* If this is a direct mount request create a dummy name */
47450 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
47451 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47452 + /* this name does get written to userland via autofs4_write() */
47453 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
47454 +#else
47455 qstr.len = sprintf(name, "%p", dentry);
47456 +#endif
47457 else {
47458 qstr.len = autofs4_getpath(sbi, dentry, &name);
47459 if (!qstr.len) {
47460 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
47461 index 2722387..c8dd2a7 100644
47462 --- a/fs/befs/endian.h
47463 +++ b/fs/befs/endian.h
47464 @@ -11,7 +11,7 @@
47465
47466 #include <asm/byteorder.h>
47467
47468 -static inline u64
47469 +static inline u64 __intentional_overflow(-1)
47470 fs64_to_cpu(const struct super_block *sb, fs64 n)
47471 {
47472 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
47473 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
47474 return (__force fs64)cpu_to_be64(n);
47475 }
47476
47477 -static inline u32
47478 +static inline u32 __intentional_overflow(-1)
47479 fs32_to_cpu(const struct super_block *sb, fs32 n)
47480 {
47481 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
47482 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
47483 index 8615ee8..388ed68 100644
47484 --- a/fs/befs/linuxvfs.c
47485 +++ b/fs/befs/linuxvfs.c
47486 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
47487 {
47488 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
47489 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
47490 - char *link = nd_get_link(nd);
47491 + const char *link = nd_get_link(nd);
47492 if (!IS_ERR(link))
47493 kfree(link);
47494 }
47495 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
47496 index bbc8f88..7c7ac97 100644
47497 --- a/fs/binfmt_aout.c
47498 +++ b/fs/binfmt_aout.c
47499 @@ -16,6 +16,7 @@
47500 #include <linux/string.h>
47501 #include <linux/fs.h>
47502 #include <linux/file.h>
47503 +#include <linux/security.h>
47504 #include <linux/stat.h>
47505 #include <linux/fcntl.h>
47506 #include <linux/ptrace.h>
47507 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
47508 #endif
47509 # define START_STACK(u) ((void __user *)u.start_stack)
47510
47511 + memset(&dump, 0, sizeof(dump));
47512 +
47513 fs = get_fs();
47514 set_fs(KERNEL_DS);
47515 has_dumped = 1;
47516 @@ -70,10 +73,12 @@ static int aout_core_dump(struct coredump_params *cprm)
47517
47518 /* If the size of the dump file exceeds the rlimit, then see what would happen
47519 if we wrote the stack, but not the data area. */
47520 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
47521 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
47522 dump.u_dsize = 0;
47523
47524 /* Make sure we have enough room to write the stack and data areas. */
47525 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
47526 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
47527 dump.u_ssize = 0;
47528
47529 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
47530 rlim = rlimit(RLIMIT_DATA);
47531 if (rlim >= RLIM_INFINITY)
47532 rlim = ~0;
47533 +
47534 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
47535 if (ex.a_data + ex.a_bss > rlim)
47536 return -ENOMEM;
47537
47538 @@ -268,6 +275,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
47539
47540 install_exec_creds(bprm);
47541
47542 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
47543 + current->mm->pax_flags = 0UL;
47544 +#endif
47545 +
47546 +#ifdef CONFIG_PAX_PAGEEXEC
47547 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
47548 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
47549 +
47550 +#ifdef CONFIG_PAX_EMUTRAMP
47551 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
47552 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
47553 +#endif
47554 +
47555 +#ifdef CONFIG_PAX_MPROTECT
47556 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
47557 + current->mm->pax_flags |= MF_PAX_MPROTECT;
47558 +#endif
47559 +
47560 + }
47561 +#endif
47562 +
47563 if (N_MAGIC(ex) == OMAGIC) {
47564 unsigned long text_addr, map_size;
47565 loff_t pos;
47566 @@ -333,7 +361,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
47567 }
47568
47569 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
47570 - PROT_READ | PROT_WRITE | PROT_EXEC,
47571 + PROT_READ | PROT_WRITE,
47572 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
47573 fd_offset + ex.a_text);
47574 if (error != N_DATADDR(ex)) {
47575 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
47576 index 86af964..8a1da7e 100644
47577 --- a/fs/binfmt_elf.c
47578 +++ b/fs/binfmt_elf.c
47579 @@ -34,6 +34,7 @@
47580 #include <linux/utsname.h>
47581 #include <linux/coredump.h>
47582 #include <linux/sched.h>
47583 +#include <linux/xattr.h>
47584 #include <asm/uaccess.h>
47585 #include <asm/param.h>
47586 #include <asm/page.h>
47587 @@ -60,6 +61,10 @@ static int elf_core_dump(struct coredump_params *cprm);
47588 #define elf_core_dump NULL
47589 #endif
47590
47591 +#ifdef CONFIG_PAX_MPROTECT
47592 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
47593 +#endif
47594 +
47595 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
47596 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
47597 #else
47598 @@ -79,6 +84,11 @@ static struct linux_binfmt elf_format = {
47599 .load_binary = load_elf_binary,
47600 .load_shlib = load_elf_library,
47601 .core_dump = elf_core_dump,
47602 +
47603 +#ifdef CONFIG_PAX_MPROTECT
47604 + .handle_mprotect= elf_handle_mprotect,
47605 +#endif
47606 +
47607 .min_coredump = ELF_EXEC_PAGESIZE,
47608 };
47609
47610 @@ -86,6 +96,8 @@ static struct linux_binfmt elf_format = {
47611
47612 static int set_brk(unsigned long start, unsigned long end)
47613 {
47614 + unsigned long e = end;
47615 +
47616 start = ELF_PAGEALIGN(start);
47617 end = ELF_PAGEALIGN(end);
47618 if (end > start) {
47619 @@ -94,7 +106,7 @@ static int set_brk(unsigned long start, unsigned long end)
47620 if (BAD_ADDR(addr))
47621 return addr;
47622 }
47623 - current->mm->start_brk = current->mm->brk = end;
47624 + current->mm->start_brk = current->mm->brk = e;
47625 return 0;
47626 }
47627
47628 @@ -155,12 +167,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
47629 elf_addr_t __user *u_rand_bytes;
47630 const char *k_platform = ELF_PLATFORM;
47631 const char *k_base_platform = ELF_BASE_PLATFORM;
47632 - unsigned char k_rand_bytes[16];
47633 + u32 k_rand_bytes[4];
47634 int items;
47635 elf_addr_t *elf_info;
47636 int ei_index = 0;
47637 const struct cred *cred = current_cred();
47638 struct vm_area_struct *vma;
47639 + unsigned long saved_auxv[AT_VECTOR_SIZE];
47640
47641 /*
47642 * In some cases (e.g. Hyper-Threading), we want to avoid L1
47643 @@ -202,8 +215,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
47644 * Generate 16 random bytes for userspace PRNG seeding.
47645 */
47646 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
47647 - u_rand_bytes = (elf_addr_t __user *)
47648 - STACK_ALLOC(p, sizeof(k_rand_bytes));
47649 + srandom32(k_rand_bytes[0] ^ random32());
47650 + srandom32(k_rand_bytes[1] ^ random32());
47651 + srandom32(k_rand_bytes[2] ^ random32());
47652 + srandom32(k_rand_bytes[3] ^ random32());
47653 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
47654 + u_rand_bytes = (elf_addr_t __user *) p;
47655 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
47656 return -EFAULT;
47657
47658 @@ -315,9 +332,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
47659 return -EFAULT;
47660 current->mm->env_end = p;
47661
47662 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
47663 +
47664 /* Put the elf_info on the stack in the right place. */
47665 sp = (elf_addr_t __user *)envp + 1;
47666 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
47667 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
47668 return -EFAULT;
47669 return 0;
47670 }
47671 @@ -385,15 +404,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
47672 an ELF header */
47673
47674 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
47675 - struct file *interpreter, unsigned long *interp_map_addr,
47676 - unsigned long no_base)
47677 + struct file *interpreter, unsigned long no_base)
47678 {
47679 struct elf_phdr *elf_phdata;
47680 struct elf_phdr *eppnt;
47681 - unsigned long load_addr = 0;
47682 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
47683 int load_addr_set = 0;
47684 unsigned long last_bss = 0, elf_bss = 0;
47685 - unsigned long error = ~0UL;
47686 + unsigned long error = -EINVAL;
47687 unsigned long total_size;
47688 int retval, i, size;
47689
47690 @@ -439,6 +457,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
47691 goto out_close;
47692 }
47693
47694 +#ifdef CONFIG_PAX_SEGMEXEC
47695 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
47696 + pax_task_size = SEGMEXEC_TASK_SIZE;
47697 +#endif
47698 +
47699 eppnt = elf_phdata;
47700 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
47701 if (eppnt->p_type == PT_LOAD) {
47702 @@ -462,8 +485,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
47703 map_addr = elf_map(interpreter, load_addr + vaddr,
47704 eppnt, elf_prot, elf_type, total_size);
47705 total_size = 0;
47706 - if (!*interp_map_addr)
47707 - *interp_map_addr = map_addr;
47708 error = map_addr;
47709 if (BAD_ADDR(map_addr))
47710 goto out_close;
47711 @@ -482,8 +503,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
47712 k = load_addr + eppnt->p_vaddr;
47713 if (BAD_ADDR(k) ||
47714 eppnt->p_filesz > eppnt->p_memsz ||
47715 - eppnt->p_memsz > TASK_SIZE ||
47716 - TASK_SIZE - eppnt->p_memsz < k) {
47717 + eppnt->p_memsz > pax_task_size ||
47718 + pax_task_size - eppnt->p_memsz < k) {
47719 error = -ENOMEM;
47720 goto out_close;
47721 }
47722 @@ -535,6 +556,315 @@ out:
47723 return error;
47724 }
47725
47726 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
47727 +#ifdef CONFIG_PAX_SOFTMODE
47728 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
47729 +{
47730 + unsigned long pax_flags = 0UL;
47731 +
47732 +#ifdef CONFIG_PAX_PAGEEXEC
47733 + if (elf_phdata->p_flags & PF_PAGEEXEC)
47734 + pax_flags |= MF_PAX_PAGEEXEC;
47735 +#endif
47736 +
47737 +#ifdef CONFIG_PAX_SEGMEXEC
47738 + if (elf_phdata->p_flags & PF_SEGMEXEC)
47739 + pax_flags |= MF_PAX_SEGMEXEC;
47740 +#endif
47741 +
47742 +#ifdef CONFIG_PAX_EMUTRAMP
47743 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
47744 + pax_flags |= MF_PAX_EMUTRAMP;
47745 +#endif
47746 +
47747 +#ifdef CONFIG_PAX_MPROTECT
47748 + if (elf_phdata->p_flags & PF_MPROTECT)
47749 + pax_flags |= MF_PAX_MPROTECT;
47750 +#endif
47751 +
47752 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
47753 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
47754 + pax_flags |= MF_PAX_RANDMMAP;
47755 +#endif
47756 +
47757 + return pax_flags;
47758 +}
47759 +#endif
47760 +
47761 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
47762 +{
47763 + unsigned long pax_flags = 0UL;
47764 +
47765 +#ifdef CONFIG_PAX_PAGEEXEC
47766 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
47767 + pax_flags |= MF_PAX_PAGEEXEC;
47768 +#endif
47769 +
47770 +#ifdef CONFIG_PAX_SEGMEXEC
47771 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
47772 + pax_flags |= MF_PAX_SEGMEXEC;
47773 +#endif
47774 +
47775 +#ifdef CONFIG_PAX_EMUTRAMP
47776 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
47777 + pax_flags |= MF_PAX_EMUTRAMP;
47778 +#endif
47779 +
47780 +#ifdef CONFIG_PAX_MPROTECT
47781 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
47782 + pax_flags |= MF_PAX_MPROTECT;
47783 +#endif
47784 +
47785 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
47786 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
47787 + pax_flags |= MF_PAX_RANDMMAP;
47788 +#endif
47789 +
47790 + return pax_flags;
47791 +}
47792 +#endif
47793 +
47794 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
47795 +#ifdef CONFIG_PAX_SOFTMODE
47796 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
47797 +{
47798 + unsigned long pax_flags = 0UL;
47799 +
47800 +#ifdef CONFIG_PAX_PAGEEXEC
47801 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
47802 + pax_flags |= MF_PAX_PAGEEXEC;
47803 +#endif
47804 +
47805 +#ifdef CONFIG_PAX_SEGMEXEC
47806 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
47807 + pax_flags |= MF_PAX_SEGMEXEC;
47808 +#endif
47809 +
47810 +#ifdef CONFIG_PAX_EMUTRAMP
47811 + if (pax_flags_softmode & MF_PAX_EMUTRAMP)
47812 + pax_flags |= MF_PAX_EMUTRAMP;
47813 +#endif
47814 +
47815 +#ifdef CONFIG_PAX_MPROTECT
47816 + if (pax_flags_softmode & MF_PAX_MPROTECT)
47817 + pax_flags |= MF_PAX_MPROTECT;
47818 +#endif
47819 +
47820 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
47821 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
47822 + pax_flags |= MF_PAX_RANDMMAP;
47823 +#endif
47824 +
47825 + return pax_flags;
47826 +}
47827 +#endif
47828 +
47829 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
47830 +{
47831 + unsigned long pax_flags = 0UL;
47832 +
47833 +#ifdef CONFIG_PAX_PAGEEXEC
47834 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
47835 + pax_flags |= MF_PAX_PAGEEXEC;
47836 +#endif
47837 +
47838 +#ifdef CONFIG_PAX_SEGMEXEC
47839 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
47840 + pax_flags |= MF_PAX_SEGMEXEC;
47841 +#endif
47842 +
47843 +#ifdef CONFIG_PAX_EMUTRAMP
47844 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
47845 + pax_flags |= MF_PAX_EMUTRAMP;
47846 +#endif
47847 +
47848 +#ifdef CONFIG_PAX_MPROTECT
47849 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
47850 + pax_flags |= MF_PAX_MPROTECT;
47851 +#endif
47852 +
47853 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
47854 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
47855 + pax_flags |= MF_PAX_RANDMMAP;
47856 +#endif
47857 +
47858 + return pax_flags;
47859 +}
47860 +#endif
47861 +
47862 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
47863 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
47864 +{
47865 + unsigned long pax_flags = 0UL;
47866 +
47867 +#ifdef CONFIG_PAX_EI_PAX
47868 +
47869 +#ifdef CONFIG_PAX_PAGEEXEC
47870 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
47871 + pax_flags |= MF_PAX_PAGEEXEC;
47872 +#endif
47873 +
47874 +#ifdef CONFIG_PAX_SEGMEXEC
47875 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
47876 + pax_flags |= MF_PAX_SEGMEXEC;
47877 +#endif
47878 +
47879 +#ifdef CONFIG_PAX_EMUTRAMP
47880 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
47881 + pax_flags |= MF_PAX_EMUTRAMP;
47882 +#endif
47883 +
47884 +#ifdef CONFIG_PAX_MPROTECT
47885 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
47886 + pax_flags |= MF_PAX_MPROTECT;
47887 +#endif
47888 +
47889 +#ifdef CONFIG_PAX_ASLR
47890 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
47891 + pax_flags |= MF_PAX_RANDMMAP;
47892 +#endif
47893 +
47894 +#else
47895 +
47896 +#ifdef CONFIG_PAX_PAGEEXEC
47897 + pax_flags |= MF_PAX_PAGEEXEC;
47898 +#endif
47899 +
47900 +#ifdef CONFIG_PAX_SEGMEXEC
47901 + pax_flags |= MF_PAX_SEGMEXEC;
47902 +#endif
47903 +
47904 +#ifdef CONFIG_PAX_MPROTECT
47905 + pax_flags |= MF_PAX_MPROTECT;
47906 +#endif
47907 +
47908 +#ifdef CONFIG_PAX_RANDMMAP
47909 + if (randomize_va_space)
47910 + pax_flags |= MF_PAX_RANDMMAP;
47911 +#endif
47912 +
47913 +#endif
47914 +
47915 + return pax_flags;
47916 +}
47917 +
47918 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
47919 +{
47920 +
47921 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
47922 + unsigned long i;
47923 +
47924 + for (i = 0UL; i < elf_ex->e_phnum; i++)
47925 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
47926 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
47927 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
47928 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
47929 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
47930 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
47931 + return ~0UL;
47932 +
47933 +#ifdef CONFIG_PAX_SOFTMODE
47934 + if (pax_softmode)
47935 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
47936 + else
47937 +#endif
47938 +
47939 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
47940 + break;
47941 + }
47942 +#endif
47943 +
47944 + return ~0UL;
47945 +}
47946 +
47947 +static unsigned long pax_parse_xattr_pax(struct file * const file)
47948 +{
47949 +
47950 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
47951 + ssize_t xattr_size, i;
47952 + unsigned char xattr_value[sizeof("pemrs") - 1];
47953 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
47954 +
47955 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
47956 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
47957 + return ~0UL;
47958 +
47959 + for (i = 0; i < xattr_size; i++)
47960 + switch (xattr_value[i]) {
47961 + default:
47962 + return ~0UL;
47963 +
47964 +#define parse_flag(option1, option2, flag) \
47965 + case option1: \
47966 + if (pax_flags_hardmode & MF_PAX_##flag) \
47967 + return ~0UL; \
47968 + pax_flags_hardmode |= MF_PAX_##flag; \
47969 + break; \
47970 + case option2: \
47971 + if (pax_flags_softmode & MF_PAX_##flag) \
47972 + return ~0UL; \
47973 + pax_flags_softmode |= MF_PAX_##flag; \
47974 + break;
47975 +
47976 + parse_flag('p', 'P', PAGEEXEC);
47977 + parse_flag('e', 'E', EMUTRAMP);
47978 + parse_flag('m', 'M', MPROTECT);
47979 + parse_flag('r', 'R', RANDMMAP);
47980 + parse_flag('s', 'S', SEGMEXEC);
47981 +
47982 +#undef parse_flag
47983 + }
47984 +
47985 + if (pax_flags_hardmode & pax_flags_softmode)
47986 + return ~0UL;
47987 +
47988 +#ifdef CONFIG_PAX_SOFTMODE
47989 + if (pax_softmode)
47990 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
47991 + else
47992 +#endif
47993 +
47994 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
47995 +#else
47996 + return ~0UL;
47997 +#endif
47998 +
47999 +}
48000 +
48001 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
48002 +{
48003 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
48004 +
48005 + pax_flags = pax_parse_ei_pax(elf_ex);
48006 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
48007 + xattr_pax_flags = pax_parse_xattr_pax(file);
48008 +
48009 + if (pt_pax_flags == ~0UL)
48010 + pt_pax_flags = xattr_pax_flags;
48011 + else if (xattr_pax_flags == ~0UL)
48012 + xattr_pax_flags = pt_pax_flags;
48013 + if (pt_pax_flags != xattr_pax_flags)
48014 + return -EINVAL;
48015 + if (pt_pax_flags != ~0UL)
48016 + pax_flags = pt_pax_flags;
48017 +
48018 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
48019 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48020 + if ((__supported_pte_mask & _PAGE_NX))
48021 + pax_flags &= ~MF_PAX_SEGMEXEC;
48022 + else
48023 + pax_flags &= ~MF_PAX_PAGEEXEC;
48024 + }
48025 +#endif
48026 +
48027 + if (0 > pax_check_flags(&pax_flags))
48028 + return -EINVAL;
48029 +
48030 + current->mm->pax_flags = pax_flags;
48031 + return 0;
48032 +}
48033 +#endif
48034 +
48035 /*
48036 * These are the functions used to load ELF style executables and shared
48037 * libraries. There is no binary dependent code anywhere else.
48038 @@ -551,6 +881,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
48039 {
48040 unsigned int random_variable = 0;
48041
48042 +#ifdef CONFIG_PAX_RANDUSTACK
48043 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
48044 + return stack_top - current->mm->delta_stack;
48045 +#endif
48046 +
48047 if ((current->flags & PF_RANDOMIZE) &&
48048 !(current->personality & ADDR_NO_RANDOMIZE)) {
48049 random_variable = get_random_int() & STACK_RND_MASK;
48050 @@ -569,7 +904,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
48051 unsigned long load_addr = 0, load_bias = 0;
48052 int load_addr_set = 0;
48053 char * elf_interpreter = NULL;
48054 - unsigned long error;
48055 + unsigned long error = 0;
48056 struct elf_phdr *elf_ppnt, *elf_phdata;
48057 unsigned long elf_bss, elf_brk;
48058 int retval, i;
48059 @@ -579,12 +914,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
48060 unsigned long start_code, end_code, start_data, end_data;
48061 unsigned long reloc_func_desc __maybe_unused = 0;
48062 int executable_stack = EXSTACK_DEFAULT;
48063 - unsigned long def_flags = 0;
48064 struct pt_regs *regs = current_pt_regs();
48065 struct {
48066 struct elfhdr elf_ex;
48067 struct elfhdr interp_elf_ex;
48068 } *loc;
48069 + unsigned long pax_task_size = TASK_SIZE;
48070
48071 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
48072 if (!loc) {
48073 @@ -720,11 +1055,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
48074 goto out_free_dentry;
48075
48076 /* OK, This is the point of no return */
48077 - current->mm->def_flags = def_flags;
48078 +
48079 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48080 + current->mm->pax_flags = 0UL;
48081 +#endif
48082 +
48083 +#ifdef CONFIG_PAX_DLRESOLVE
48084 + current->mm->call_dl_resolve = 0UL;
48085 +#endif
48086 +
48087 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
48088 + current->mm->call_syscall = 0UL;
48089 +#endif
48090 +
48091 +#ifdef CONFIG_PAX_ASLR
48092 + current->mm->delta_mmap = 0UL;
48093 + current->mm->delta_stack = 0UL;
48094 +#endif
48095 +
48096 + current->mm->def_flags = 0;
48097 +
48098 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48099 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
48100 + send_sig(SIGKILL, current, 0);
48101 + goto out_free_dentry;
48102 + }
48103 +#endif
48104 +
48105 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
48106 + pax_set_initial_flags(bprm);
48107 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
48108 + if (pax_set_initial_flags_func)
48109 + (pax_set_initial_flags_func)(bprm);
48110 +#endif
48111 +
48112 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
48113 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
48114 + current->mm->context.user_cs_limit = PAGE_SIZE;
48115 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
48116 + }
48117 +#endif
48118 +
48119 +#ifdef CONFIG_PAX_SEGMEXEC
48120 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
48121 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
48122 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
48123 + pax_task_size = SEGMEXEC_TASK_SIZE;
48124 + current->mm->def_flags |= VM_NOHUGEPAGE;
48125 + }
48126 +#endif
48127 +
48128 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
48129 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48130 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
48131 + put_cpu();
48132 + }
48133 +#endif
48134
48135 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
48136 may depend on the personality. */
48137 SET_PERSONALITY(loc->elf_ex);
48138 +
48139 +#ifdef CONFIG_PAX_ASLR
48140 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
48141 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
48142 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
48143 + }
48144 +#endif
48145 +
48146 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
48147 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48148 + executable_stack = EXSTACK_DISABLE_X;
48149 + current->personality &= ~READ_IMPLIES_EXEC;
48150 + } else
48151 +#endif
48152 +
48153 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
48154 current->personality |= READ_IMPLIES_EXEC;
48155
48156 @@ -815,6 +1220,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
48157 #else
48158 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
48159 #endif
48160 +
48161 +#ifdef CONFIG_PAX_RANDMMAP
48162 + /* PaX: randomize base address at the default exe base if requested */
48163 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
48164 +#ifdef CONFIG_SPARC64
48165 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
48166 +#else
48167 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
48168 +#endif
48169 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
48170 + elf_flags |= MAP_FIXED;
48171 + }
48172 +#endif
48173 +
48174 }
48175
48176 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
48177 @@ -847,9 +1266,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
48178 * allowed task size. Note that p_filesz must always be
48179 * <= p_memsz so it is only necessary to check p_memsz.
48180 */
48181 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
48182 - elf_ppnt->p_memsz > TASK_SIZE ||
48183 - TASK_SIZE - elf_ppnt->p_memsz < k) {
48184 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
48185 + elf_ppnt->p_memsz > pax_task_size ||
48186 + pax_task_size - elf_ppnt->p_memsz < k) {
48187 /* set_brk can never work. Avoid overflows. */
48188 send_sig(SIGKILL, current, 0);
48189 retval = -EINVAL;
48190 @@ -888,17 +1307,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
48191 goto out_free_dentry;
48192 }
48193 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
48194 - send_sig(SIGSEGV, current, 0);
48195 - retval = -EFAULT; /* Nobody gets to see this, but.. */
48196 - goto out_free_dentry;
48197 + /*
48198 + * This bss-zeroing can fail if the ELF
48199 + * file specifies odd protections. So
48200 + * we don't check the return value
48201 + */
48202 }
48203
48204 +#ifdef CONFIG_PAX_RANDMMAP
48205 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
48206 + unsigned long start, size, flags;
48207 + vm_flags_t vm_flags;
48208 +
48209 + start = ELF_PAGEALIGN(elf_brk);
48210 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
48211 + flags = MAP_FIXED | MAP_PRIVATE;
48212 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
48213 +
48214 + down_write(&current->mm->mmap_sem);
48215 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
48216 + retval = -ENOMEM;
48217 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
48218 +// if (current->personality & ADDR_NO_RANDOMIZE)
48219 +// vm_flags |= VM_READ | VM_MAYREAD;
48220 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
48221 + retval = IS_ERR_VALUE(start) ? start : 0;
48222 + }
48223 + up_write(&current->mm->mmap_sem);
48224 + if (retval == 0)
48225 + retval = set_brk(start + size, start + size + PAGE_SIZE);
48226 + if (retval < 0) {
48227 + send_sig(SIGKILL, current, 0);
48228 + goto out_free_dentry;
48229 + }
48230 + }
48231 +#endif
48232 +
48233 if (elf_interpreter) {
48234 - unsigned long interp_map_addr = 0;
48235 -
48236 elf_entry = load_elf_interp(&loc->interp_elf_ex,
48237 interpreter,
48238 - &interp_map_addr,
48239 load_bias);
48240 if (!IS_ERR((void *)elf_entry)) {
48241 /*
48242 @@ -1120,7 +1567,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
48243 * Decide what to dump of a segment, part, all or none.
48244 */
48245 static unsigned long vma_dump_size(struct vm_area_struct *vma,
48246 - unsigned long mm_flags)
48247 + unsigned long mm_flags, long signr)
48248 {
48249 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
48250
48251 @@ -1158,7 +1605,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
48252 if (vma->vm_file == NULL)
48253 return 0;
48254
48255 - if (FILTER(MAPPED_PRIVATE))
48256 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
48257 goto whole;
48258
48259 /*
48260 @@ -1383,9 +1830,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
48261 {
48262 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
48263 int i = 0;
48264 - do
48265 + do {
48266 i += 2;
48267 - while (auxv[i - 2] != AT_NULL);
48268 + } while (auxv[i - 2] != AT_NULL);
48269 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
48270 }
48271
48272 @@ -2015,14 +2462,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
48273 }
48274
48275 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
48276 - unsigned long mm_flags)
48277 + struct coredump_params *cprm)
48278 {
48279 struct vm_area_struct *vma;
48280 size_t size = 0;
48281
48282 for (vma = first_vma(current, gate_vma); vma != NULL;
48283 vma = next_vma(vma, gate_vma))
48284 - size += vma_dump_size(vma, mm_flags);
48285 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48286 return size;
48287 }
48288
48289 @@ -2116,7 +2563,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48290
48291 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
48292
48293 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
48294 + offset += elf_core_vma_data_size(gate_vma, cprm);
48295 offset += elf_core_extra_data_size();
48296 e_shoff = offset;
48297
48298 @@ -2130,10 +2577,12 @@ static int elf_core_dump(struct coredump_params *cprm)
48299 offset = dataoff;
48300
48301 size += sizeof(*elf);
48302 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48303 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
48304 goto end_coredump;
48305
48306 size += sizeof(*phdr4note);
48307 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48308 if (size > cprm->limit
48309 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
48310 goto end_coredump;
48311 @@ -2147,7 +2596,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48312 phdr.p_offset = offset;
48313 phdr.p_vaddr = vma->vm_start;
48314 phdr.p_paddr = 0;
48315 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
48316 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48317 phdr.p_memsz = vma->vm_end - vma->vm_start;
48318 offset += phdr.p_filesz;
48319 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
48320 @@ -2158,6 +2607,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48321 phdr.p_align = ELF_EXEC_PAGESIZE;
48322
48323 size += sizeof(phdr);
48324 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48325 if (size > cprm->limit
48326 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
48327 goto end_coredump;
48328 @@ -2182,7 +2632,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48329 unsigned long addr;
48330 unsigned long end;
48331
48332 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
48333 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48334
48335 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
48336 struct page *page;
48337 @@ -2191,6 +2641,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48338 page = get_dump_page(addr);
48339 if (page) {
48340 void *kaddr = kmap(page);
48341 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
48342 stop = ((size += PAGE_SIZE) > cprm->limit) ||
48343 !dump_write(cprm->file, kaddr,
48344 PAGE_SIZE);
48345 @@ -2208,6 +2659,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48346
48347 if (e_phnum == PN_XNUM) {
48348 size += sizeof(*shdr4extnum);
48349 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48350 if (size > cprm->limit
48351 || !dump_write(cprm->file, shdr4extnum,
48352 sizeof(*shdr4extnum)))
48353 @@ -2228,6 +2680,97 @@ out:
48354
48355 #endif /* CONFIG_ELF_CORE */
48356
48357 +#ifdef CONFIG_PAX_MPROTECT
48358 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
48359 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
48360 + * we'll remove VM_MAYWRITE for good on RELRO segments.
48361 + *
48362 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
48363 + * basis because we want to allow the common case and not the special ones.
48364 + */
48365 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
48366 +{
48367 + struct elfhdr elf_h;
48368 + struct elf_phdr elf_p;
48369 + unsigned long i;
48370 + unsigned long oldflags;
48371 + bool is_textrel_rw, is_textrel_rx, is_relro;
48372 +
48373 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
48374 + return;
48375 +
48376 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
48377 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
48378 +
48379 +#ifdef CONFIG_PAX_ELFRELOCS
48380 + /* possible TEXTREL */
48381 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
48382 + 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);
48383 +#else
48384 + is_textrel_rw = false;
48385 + is_textrel_rx = false;
48386 +#endif
48387 +
48388 + /* possible RELRO */
48389 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
48390 +
48391 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
48392 + return;
48393 +
48394 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
48395 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
48396 +
48397 +#ifdef CONFIG_PAX_ETEXECRELOCS
48398 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
48399 +#else
48400 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
48401 +#endif
48402 +
48403 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
48404 + !elf_check_arch(&elf_h) ||
48405 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
48406 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
48407 + return;
48408 +
48409 + for (i = 0UL; i < elf_h.e_phnum; i++) {
48410 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
48411 + return;
48412 + switch (elf_p.p_type) {
48413 + case PT_DYNAMIC:
48414 + if (!is_textrel_rw && !is_textrel_rx)
48415 + continue;
48416 + i = 0UL;
48417 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
48418 + elf_dyn dyn;
48419 +
48420 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
48421 + return;
48422 + if (dyn.d_tag == DT_NULL)
48423 + return;
48424 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
48425 + gr_log_textrel(vma);
48426 + if (is_textrel_rw)
48427 + vma->vm_flags |= VM_MAYWRITE;
48428 + else
48429 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
48430 + vma->vm_flags &= ~VM_MAYWRITE;
48431 + return;
48432 + }
48433 + i++;
48434 + }
48435 + return;
48436 +
48437 + case PT_GNU_RELRO:
48438 + if (!is_relro)
48439 + continue;
48440 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
48441 + vma->vm_flags &= ~VM_MAYWRITE;
48442 + return;
48443 + }
48444 + }
48445 +}
48446 +#endif
48447 +
48448 static int __init init_elf_binfmt(void)
48449 {
48450 register_binfmt(&elf_format);
48451 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
48452 index 2036d21..b0430d0 100644
48453 --- a/fs/binfmt_flat.c
48454 +++ b/fs/binfmt_flat.c
48455 @@ -562,7 +562,9 @@ static int load_flat_file(struct linux_binprm * bprm,
48456 realdatastart = (unsigned long) -ENOMEM;
48457 printk("Unable to allocate RAM for process data, errno %d\n",
48458 (int)-realdatastart);
48459 + down_write(&current->mm->mmap_sem);
48460 vm_munmap(textpos, text_len);
48461 + up_write(&current->mm->mmap_sem);
48462 ret = realdatastart;
48463 goto err;
48464 }
48465 @@ -586,8 +588,10 @@ static int load_flat_file(struct linux_binprm * bprm,
48466 }
48467 if (IS_ERR_VALUE(result)) {
48468 printk("Unable to read data+bss, errno %d\n", (int)-result);
48469 + down_write(&current->mm->mmap_sem);
48470 vm_munmap(textpos, text_len);
48471 vm_munmap(realdatastart, len);
48472 + up_write(&current->mm->mmap_sem);
48473 ret = result;
48474 goto err;
48475 }
48476 @@ -654,8 +658,10 @@ static int load_flat_file(struct linux_binprm * bprm,
48477 }
48478 if (IS_ERR_VALUE(result)) {
48479 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
48480 + down_write(&current->mm->mmap_sem);
48481 vm_munmap(textpos, text_len + data_len + extra +
48482 MAX_SHARED_LIBS * sizeof(unsigned long));
48483 + up_write(&current->mm->mmap_sem);
48484 ret = result;
48485 goto err;
48486 }
48487 diff --git a/fs/bio.c b/fs/bio.c
48488 index b96fc6c..431d628 100644
48489 --- a/fs/bio.c
48490 +++ b/fs/bio.c
48491 @@ -818,7 +818,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
48492 /*
48493 * Overflow, abort
48494 */
48495 - if (end < start)
48496 + if (end < start || end - start > INT_MAX - nr_pages)
48497 return ERR_PTR(-EINVAL);
48498
48499 nr_pages += end - start;
48500 @@ -952,7 +952,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
48501 /*
48502 * Overflow, abort
48503 */
48504 - if (end < start)
48505 + if (end < start || end - start > INT_MAX - nr_pages)
48506 return ERR_PTR(-EINVAL);
48507
48508 nr_pages += end - start;
48509 @@ -1214,7 +1214,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
48510 const int read = bio_data_dir(bio) == READ;
48511 struct bio_map_data *bmd = bio->bi_private;
48512 int i;
48513 - char *p = bmd->sgvecs[0].iov_base;
48514 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
48515
48516 __bio_for_each_segment(bvec, bio, i, 0) {
48517 char *addr = page_address(bvec->bv_page);
48518 diff --git a/fs/block_dev.c b/fs/block_dev.c
48519 index aae187a..fd790ba 100644
48520 --- a/fs/block_dev.c
48521 +++ b/fs/block_dev.c
48522 @@ -652,7 +652,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
48523 else if (bdev->bd_contains == bdev)
48524 return true; /* is a whole device which isn't held */
48525
48526 - else if (whole->bd_holder == bd_may_claim)
48527 + else if (whole->bd_holder == (void *)bd_may_claim)
48528 return true; /* is a partition of a device that is being partitioned */
48529 else if (whole->bd_holder != NULL)
48530 return false; /* is a partition of a held device */
48531 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
48532 index ca9d8f1..8c0142d 100644
48533 --- a/fs/btrfs/ctree.c
48534 +++ b/fs/btrfs/ctree.c
48535 @@ -1036,9 +1036,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
48536 free_extent_buffer(buf);
48537 add_root_to_dirty_list(root);
48538 } else {
48539 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
48540 - parent_start = parent->start;
48541 - else
48542 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
48543 + if (parent)
48544 + parent_start = parent->start;
48545 + else
48546 + parent_start = 0;
48547 + } else
48548 parent_start = 0;
48549
48550 WARN_ON(trans->transid != btrfs_header_generation(parent));
48551 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
48552 index 2c02310..a0c895e 100644
48553 --- a/fs/btrfs/ioctl.c
48554 +++ b/fs/btrfs/ioctl.c
48555 @@ -3077,9 +3077,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
48556 for (i = 0; i < num_types; i++) {
48557 struct btrfs_space_info *tmp;
48558
48559 + /* Don't copy in more than we allocated */
48560 if (!slot_count)
48561 break;
48562
48563 + slot_count--;
48564 +
48565 info = NULL;
48566 rcu_read_lock();
48567 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
48568 @@ -3101,10 +3104,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
48569 memcpy(dest, &space, sizeof(space));
48570 dest++;
48571 space_args.total_spaces++;
48572 - slot_count--;
48573 }
48574 - if (!slot_count)
48575 - break;
48576 }
48577 up_read(&info->groups_sem);
48578 }
48579 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
48580 index f6b8859..54fe8c5 100644
48581 --- a/fs/btrfs/super.c
48582 +++ b/fs/btrfs/super.c
48583 @@ -266,7 +266,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
48584 function, line, errstr);
48585 return;
48586 }
48587 - ACCESS_ONCE(trans->transaction->aborted) = errno;
48588 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
48589 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
48590 }
48591 /*
48592 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
48593 index 622f469..e8d2d55 100644
48594 --- a/fs/cachefiles/bind.c
48595 +++ b/fs/cachefiles/bind.c
48596 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
48597 args);
48598
48599 /* start by checking things over */
48600 - ASSERT(cache->fstop_percent >= 0 &&
48601 - cache->fstop_percent < cache->fcull_percent &&
48602 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
48603 cache->fcull_percent < cache->frun_percent &&
48604 cache->frun_percent < 100);
48605
48606 - ASSERT(cache->bstop_percent >= 0 &&
48607 - cache->bstop_percent < cache->bcull_percent &&
48608 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
48609 cache->bcull_percent < cache->brun_percent &&
48610 cache->brun_percent < 100);
48611
48612 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
48613 index 0a1467b..6a53245 100644
48614 --- a/fs/cachefiles/daemon.c
48615 +++ b/fs/cachefiles/daemon.c
48616 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
48617 if (n > buflen)
48618 return -EMSGSIZE;
48619
48620 - if (copy_to_user(_buffer, buffer, n) != 0)
48621 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
48622 return -EFAULT;
48623
48624 return n;
48625 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
48626 if (test_bit(CACHEFILES_DEAD, &cache->flags))
48627 return -EIO;
48628
48629 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
48630 + if (datalen > PAGE_SIZE - 1)
48631 return -EOPNOTSUPP;
48632
48633 /* drag the command string into the kernel so we can parse it */
48634 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
48635 if (args[0] != '%' || args[1] != '\0')
48636 return -EINVAL;
48637
48638 - if (fstop < 0 || fstop >= cache->fcull_percent)
48639 + if (fstop >= cache->fcull_percent)
48640 return cachefiles_daemon_range_error(cache, args);
48641
48642 cache->fstop_percent = fstop;
48643 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
48644 if (args[0] != '%' || args[1] != '\0')
48645 return -EINVAL;
48646
48647 - if (bstop < 0 || bstop >= cache->bcull_percent)
48648 + if (bstop >= cache->bcull_percent)
48649 return cachefiles_daemon_range_error(cache, args);
48650
48651 cache->bstop_percent = bstop;
48652 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
48653 index 4938251..7e01445 100644
48654 --- a/fs/cachefiles/internal.h
48655 +++ b/fs/cachefiles/internal.h
48656 @@ -59,7 +59,7 @@ struct cachefiles_cache {
48657 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
48658 struct rb_root active_nodes; /* active nodes (can't be culled) */
48659 rwlock_t active_lock; /* lock for active_nodes */
48660 - atomic_t gravecounter; /* graveyard uniquifier */
48661 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
48662 unsigned frun_percent; /* when to stop culling (% files) */
48663 unsigned fcull_percent; /* when to start culling (% files) */
48664 unsigned fstop_percent; /* when to stop allocating (% files) */
48665 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
48666 * proc.c
48667 */
48668 #ifdef CONFIG_CACHEFILES_HISTOGRAM
48669 -extern atomic_t cachefiles_lookup_histogram[HZ];
48670 -extern atomic_t cachefiles_mkdir_histogram[HZ];
48671 -extern atomic_t cachefiles_create_histogram[HZ];
48672 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
48673 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
48674 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
48675
48676 extern int __init cachefiles_proc_init(void);
48677 extern void cachefiles_proc_cleanup(void);
48678 static inline
48679 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
48680 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
48681 {
48682 unsigned long jif = jiffies - start_jif;
48683 if (jif >= HZ)
48684 jif = HZ - 1;
48685 - atomic_inc(&histogram[jif]);
48686 + atomic_inc_unchecked(&histogram[jif]);
48687 }
48688
48689 #else
48690 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
48691 index 8c01c5fc..15f982e 100644
48692 --- a/fs/cachefiles/namei.c
48693 +++ b/fs/cachefiles/namei.c
48694 @@ -317,7 +317,7 @@ try_again:
48695 /* first step is to make up a grave dentry in the graveyard */
48696 sprintf(nbuffer, "%08x%08x",
48697 (uint32_t) get_seconds(),
48698 - (uint32_t) atomic_inc_return(&cache->gravecounter));
48699 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
48700
48701 /* do the multiway lock magic */
48702 trap = lock_rename(cache->graveyard, dir);
48703 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
48704 index eccd339..4c1d995 100644
48705 --- a/fs/cachefiles/proc.c
48706 +++ b/fs/cachefiles/proc.c
48707 @@ -14,9 +14,9 @@
48708 #include <linux/seq_file.h>
48709 #include "internal.h"
48710
48711 -atomic_t cachefiles_lookup_histogram[HZ];
48712 -atomic_t cachefiles_mkdir_histogram[HZ];
48713 -atomic_t cachefiles_create_histogram[HZ];
48714 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
48715 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
48716 +atomic_unchecked_t cachefiles_create_histogram[HZ];
48717
48718 /*
48719 * display the latency histogram
48720 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
48721 return 0;
48722 default:
48723 index = (unsigned long) v - 3;
48724 - x = atomic_read(&cachefiles_lookup_histogram[index]);
48725 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
48726 - z = atomic_read(&cachefiles_create_histogram[index]);
48727 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
48728 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
48729 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
48730 if (x == 0 && y == 0 && z == 0)
48731 return 0;
48732
48733 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
48734 index 4809922..aab2c39 100644
48735 --- a/fs/cachefiles/rdwr.c
48736 +++ b/fs/cachefiles/rdwr.c
48737 @@ -965,7 +965,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
48738 old_fs = get_fs();
48739 set_fs(KERNEL_DS);
48740 ret = file->f_op->write(
48741 - file, (const void __user *) data, len, &pos);
48742 + file, (const void __force_user *) data, len, &pos);
48743 set_fs(old_fs);
48744 kunmap(page);
48745 if (ret != len)
48746 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
48747 index 6d797f4..0ace2e5 100644
48748 --- a/fs/ceph/dir.c
48749 +++ b/fs/ceph/dir.c
48750 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
48751 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
48752 struct ceph_mds_client *mdsc = fsc->mdsc;
48753 unsigned frag = fpos_frag(filp->f_pos);
48754 - int off = fpos_off(filp->f_pos);
48755 + unsigned int off = fpos_off(filp->f_pos);
48756 int err;
48757 u32 ftype;
48758 struct ceph_mds_reply_info_parsed *rinfo;
48759 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
48760 index d9ea6ed..1e6c8ac 100644
48761 --- a/fs/cifs/cifs_debug.c
48762 +++ b/fs/cifs/cifs_debug.c
48763 @@ -267,8 +267,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
48764
48765 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
48766 #ifdef CONFIG_CIFS_STATS2
48767 - atomic_set(&totBufAllocCount, 0);
48768 - atomic_set(&totSmBufAllocCount, 0);
48769 + atomic_set_unchecked(&totBufAllocCount, 0);
48770 + atomic_set_unchecked(&totSmBufAllocCount, 0);
48771 #endif /* CONFIG_CIFS_STATS2 */
48772 spin_lock(&cifs_tcp_ses_lock);
48773 list_for_each(tmp1, &cifs_tcp_ses_list) {
48774 @@ -281,7 +281,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
48775 tcon = list_entry(tmp3,
48776 struct cifs_tcon,
48777 tcon_list);
48778 - atomic_set(&tcon->num_smbs_sent, 0);
48779 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
48780 if (server->ops->clear_stats)
48781 server->ops->clear_stats(tcon);
48782 }
48783 @@ -313,8 +313,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
48784 smBufAllocCount.counter, cifs_min_small);
48785 #ifdef CONFIG_CIFS_STATS2
48786 seq_printf(m, "Total Large %d Small %d Allocations\n",
48787 - atomic_read(&totBufAllocCount),
48788 - atomic_read(&totSmBufAllocCount));
48789 + atomic_read_unchecked(&totBufAllocCount),
48790 + atomic_read_unchecked(&totSmBufAllocCount));
48791 #endif /* CONFIG_CIFS_STATS2 */
48792
48793 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
48794 @@ -343,7 +343,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
48795 if (tcon->need_reconnect)
48796 seq_puts(m, "\tDISCONNECTED ");
48797 seq_printf(m, "\nSMBs: %d",
48798 - atomic_read(&tcon->num_smbs_sent));
48799 + atomic_read_unchecked(&tcon->num_smbs_sent));
48800 if (server->ops->print_stats)
48801 server->ops->print_stats(m, tcon);
48802 }
48803 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
48804 index 345fc89..b2acae5 100644
48805 --- a/fs/cifs/cifsfs.c
48806 +++ b/fs/cifs/cifsfs.c
48807 @@ -1033,7 +1033,7 @@ cifs_init_request_bufs(void)
48808 /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
48809 cifs_req_cachep = kmem_cache_create("cifs_request",
48810 CIFSMaxBufSize + max_hdr_size, 0,
48811 - SLAB_HWCACHE_ALIGN, NULL);
48812 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
48813 if (cifs_req_cachep == NULL)
48814 return -ENOMEM;
48815
48816 @@ -1060,7 +1060,7 @@ cifs_init_request_bufs(void)
48817 efficient to alloc 1 per page off the slab compared to 17K (5page)
48818 alloc of large cifs buffers even when page debugging is on */
48819 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
48820 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
48821 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
48822 NULL);
48823 if (cifs_sm_req_cachep == NULL) {
48824 mempool_destroy(cifs_req_poolp);
48825 @@ -1145,8 +1145,8 @@ init_cifs(void)
48826 atomic_set(&bufAllocCount, 0);
48827 atomic_set(&smBufAllocCount, 0);
48828 #ifdef CONFIG_CIFS_STATS2
48829 - atomic_set(&totBufAllocCount, 0);
48830 - atomic_set(&totSmBufAllocCount, 0);
48831 + atomic_set_unchecked(&totBufAllocCount, 0);
48832 + atomic_set_unchecked(&totSmBufAllocCount, 0);
48833 #endif /* CONFIG_CIFS_STATS2 */
48834
48835 atomic_set(&midCount, 0);
48836 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
48837 index 4f07f6f..55de8ce 100644
48838 --- a/fs/cifs/cifsglob.h
48839 +++ b/fs/cifs/cifsglob.h
48840 @@ -751,35 +751,35 @@ struct cifs_tcon {
48841 __u16 Flags; /* optional support bits */
48842 enum statusEnum tidStatus;
48843 #ifdef CONFIG_CIFS_STATS
48844 - atomic_t num_smbs_sent;
48845 + atomic_unchecked_t num_smbs_sent;
48846 union {
48847 struct {
48848 - atomic_t num_writes;
48849 - atomic_t num_reads;
48850 - atomic_t num_flushes;
48851 - atomic_t num_oplock_brks;
48852 - atomic_t num_opens;
48853 - atomic_t num_closes;
48854 - atomic_t num_deletes;
48855 - atomic_t num_mkdirs;
48856 - atomic_t num_posixopens;
48857 - atomic_t num_posixmkdirs;
48858 - atomic_t num_rmdirs;
48859 - atomic_t num_renames;
48860 - atomic_t num_t2renames;
48861 - atomic_t num_ffirst;
48862 - atomic_t num_fnext;
48863 - atomic_t num_fclose;
48864 - atomic_t num_hardlinks;
48865 - atomic_t num_symlinks;
48866 - atomic_t num_locks;
48867 - atomic_t num_acl_get;
48868 - atomic_t num_acl_set;
48869 + atomic_unchecked_t num_writes;
48870 + atomic_unchecked_t num_reads;
48871 + atomic_unchecked_t num_flushes;
48872 + atomic_unchecked_t num_oplock_brks;
48873 + atomic_unchecked_t num_opens;
48874 + atomic_unchecked_t num_closes;
48875 + atomic_unchecked_t num_deletes;
48876 + atomic_unchecked_t num_mkdirs;
48877 + atomic_unchecked_t num_posixopens;
48878 + atomic_unchecked_t num_posixmkdirs;
48879 + atomic_unchecked_t num_rmdirs;
48880 + atomic_unchecked_t num_renames;
48881 + atomic_unchecked_t num_t2renames;
48882 + atomic_unchecked_t num_ffirst;
48883 + atomic_unchecked_t num_fnext;
48884 + atomic_unchecked_t num_fclose;
48885 + atomic_unchecked_t num_hardlinks;
48886 + atomic_unchecked_t num_symlinks;
48887 + atomic_unchecked_t num_locks;
48888 + atomic_unchecked_t num_acl_get;
48889 + atomic_unchecked_t num_acl_set;
48890 } cifs_stats;
48891 #ifdef CONFIG_CIFS_SMB2
48892 struct {
48893 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
48894 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
48895 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
48896 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
48897 } smb2_stats;
48898 #endif /* CONFIG_CIFS_SMB2 */
48899 } stats;
48900 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
48901 }
48902
48903 #ifdef CONFIG_CIFS_STATS
48904 -#define cifs_stats_inc atomic_inc
48905 +#define cifs_stats_inc atomic_inc_unchecked
48906
48907 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
48908 unsigned int bytes)
48909 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
48910 /* Various Debug counters */
48911 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
48912 #ifdef CONFIG_CIFS_STATS2
48913 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
48914 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
48915 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
48916 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
48917 #endif
48918 GLOBAL_EXTERN atomic_t smBufAllocCount;
48919 GLOBAL_EXTERN atomic_t midCount;
48920 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
48921 index 9f6c4c4..8de307a 100644
48922 --- a/fs/cifs/link.c
48923 +++ b/fs/cifs/link.c
48924 @@ -616,7 +616,7 @@ symlink_exit:
48925
48926 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
48927 {
48928 - char *p = nd_get_link(nd);
48929 + const char *p = nd_get_link(nd);
48930 if (!IS_ERR(p))
48931 kfree(p);
48932 }
48933 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
48934 index 1b15bf8..1ce489e 100644
48935 --- a/fs/cifs/misc.c
48936 +++ b/fs/cifs/misc.c
48937 @@ -169,7 +169,7 @@ cifs_buf_get(void)
48938 memset(ret_buf, 0, buf_size + 3);
48939 atomic_inc(&bufAllocCount);
48940 #ifdef CONFIG_CIFS_STATS2
48941 - atomic_inc(&totBufAllocCount);
48942 + atomic_inc_unchecked(&totBufAllocCount);
48943 #endif /* CONFIG_CIFS_STATS2 */
48944 }
48945
48946 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
48947 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
48948 atomic_inc(&smBufAllocCount);
48949 #ifdef CONFIG_CIFS_STATS2
48950 - atomic_inc(&totSmBufAllocCount);
48951 + atomic_inc_unchecked(&totSmBufAllocCount);
48952 #endif /* CONFIG_CIFS_STATS2 */
48953
48954 }
48955 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
48956 index 47bc5a8..10decbe 100644
48957 --- a/fs/cifs/smb1ops.c
48958 +++ b/fs/cifs/smb1ops.c
48959 @@ -586,27 +586,27 @@ static void
48960 cifs_clear_stats(struct cifs_tcon *tcon)
48961 {
48962 #ifdef CONFIG_CIFS_STATS
48963 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
48964 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
48965 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
48966 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
48967 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
48968 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
48969 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
48970 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
48971 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
48972 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
48973 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
48974 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
48975 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
48976 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
48977 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
48978 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
48979 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
48980 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
48981 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
48982 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
48983 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
48984 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
48985 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
48986 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
48987 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
48988 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
48989 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
48990 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
48991 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
48992 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
48993 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
48994 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
48995 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
48996 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
48997 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
48998 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
48999 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
49000 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
49001 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
49002 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
49003 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
49004 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
49005 #endif
49006 }
49007
49008 @@ -615,36 +615,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49009 {
49010 #ifdef CONFIG_CIFS_STATS
49011 seq_printf(m, " Oplocks breaks: %d",
49012 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
49013 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
49014 seq_printf(m, "\nReads: %d Bytes: %llu",
49015 - atomic_read(&tcon->stats.cifs_stats.num_reads),
49016 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
49017 (long long)(tcon->bytes_read));
49018 seq_printf(m, "\nWrites: %d Bytes: %llu",
49019 - atomic_read(&tcon->stats.cifs_stats.num_writes),
49020 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
49021 (long long)(tcon->bytes_written));
49022 seq_printf(m, "\nFlushes: %d",
49023 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
49024 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
49025 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
49026 - atomic_read(&tcon->stats.cifs_stats.num_locks),
49027 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
49028 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
49029 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
49030 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
49031 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
49032 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
49033 - atomic_read(&tcon->stats.cifs_stats.num_opens),
49034 - atomic_read(&tcon->stats.cifs_stats.num_closes),
49035 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
49036 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
49037 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
49038 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
49039 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
49040 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
49041 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
49042 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
49043 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
49044 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
49045 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
49046 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
49047 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
49048 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
49049 seq_printf(m, "\nRenames: %d T2 Renames %d",
49050 - atomic_read(&tcon->stats.cifs_stats.num_renames),
49051 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
49052 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
49053 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
49054 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
49055 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
49056 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
49057 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
49058 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
49059 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
49060 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
49061 #endif
49062 }
49063
49064 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
49065 index bceffe7..cd1ae59 100644
49066 --- a/fs/cifs/smb2ops.c
49067 +++ b/fs/cifs/smb2ops.c
49068 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
49069 #ifdef CONFIG_CIFS_STATS
49070 int i;
49071 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
49072 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49073 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49074 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49075 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49076 }
49077 #endif
49078 }
49079 @@ -284,66 +284,66 @@ static void
49080 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49081 {
49082 #ifdef CONFIG_CIFS_STATS
49083 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49084 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49085 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49086 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49087 seq_printf(m, "\nNegotiates: %d sent %d failed",
49088 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
49089 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
49090 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
49091 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
49092 seq_printf(m, "\nSessionSetups: %d sent %d failed",
49093 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
49094 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
49095 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
49096 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
49097 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
49098 seq_printf(m, "\nLogoffs: %d sent %d failed",
49099 - atomic_read(&sent[SMB2_LOGOFF_HE]),
49100 - atomic_read(&failed[SMB2_LOGOFF_HE]));
49101 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
49102 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
49103 seq_printf(m, "\nTreeConnects: %d sent %d failed",
49104 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
49105 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
49106 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
49107 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
49108 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
49109 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
49110 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
49111 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
49112 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
49113 seq_printf(m, "\nCreates: %d sent %d failed",
49114 - atomic_read(&sent[SMB2_CREATE_HE]),
49115 - atomic_read(&failed[SMB2_CREATE_HE]));
49116 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
49117 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
49118 seq_printf(m, "\nCloses: %d sent %d failed",
49119 - atomic_read(&sent[SMB2_CLOSE_HE]),
49120 - atomic_read(&failed[SMB2_CLOSE_HE]));
49121 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
49122 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
49123 seq_printf(m, "\nFlushes: %d sent %d failed",
49124 - atomic_read(&sent[SMB2_FLUSH_HE]),
49125 - atomic_read(&failed[SMB2_FLUSH_HE]));
49126 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
49127 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
49128 seq_printf(m, "\nReads: %d sent %d failed",
49129 - atomic_read(&sent[SMB2_READ_HE]),
49130 - atomic_read(&failed[SMB2_READ_HE]));
49131 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
49132 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
49133 seq_printf(m, "\nWrites: %d sent %d failed",
49134 - atomic_read(&sent[SMB2_WRITE_HE]),
49135 - atomic_read(&failed[SMB2_WRITE_HE]));
49136 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
49137 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
49138 seq_printf(m, "\nLocks: %d sent %d failed",
49139 - atomic_read(&sent[SMB2_LOCK_HE]),
49140 - atomic_read(&failed[SMB2_LOCK_HE]));
49141 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
49142 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
49143 seq_printf(m, "\nIOCTLs: %d sent %d failed",
49144 - atomic_read(&sent[SMB2_IOCTL_HE]),
49145 - atomic_read(&failed[SMB2_IOCTL_HE]));
49146 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
49147 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
49148 seq_printf(m, "\nCancels: %d sent %d failed",
49149 - atomic_read(&sent[SMB2_CANCEL_HE]),
49150 - atomic_read(&failed[SMB2_CANCEL_HE]));
49151 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
49152 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
49153 seq_printf(m, "\nEchos: %d sent %d failed",
49154 - atomic_read(&sent[SMB2_ECHO_HE]),
49155 - atomic_read(&failed[SMB2_ECHO_HE]));
49156 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
49157 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
49158 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
49159 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
49160 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
49161 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
49162 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
49163 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
49164 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
49165 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
49166 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
49167 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
49168 seq_printf(m, "\nQueryInfos: %d sent %d failed",
49169 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
49170 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
49171 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
49172 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
49173 seq_printf(m, "\nSetInfos: %d sent %d failed",
49174 - atomic_read(&sent[SMB2_SET_INFO_HE]),
49175 - atomic_read(&failed[SMB2_SET_INFO_HE]));
49176 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
49177 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
49178 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
49179 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
49180 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
49181 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
49182 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
49183 #endif
49184 }
49185
49186 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
49187 index 41d9d07..dbb4772 100644
49188 --- a/fs/cifs/smb2pdu.c
49189 +++ b/fs/cifs/smb2pdu.c
49190 @@ -1761,8 +1761,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
49191 default:
49192 cERROR(1, "info level %u isn't supported",
49193 srch_inf->info_level);
49194 - rc = -EINVAL;
49195 - goto qdir_exit;
49196 + return -EINVAL;
49197 }
49198
49199 req->FileIndex = cpu_to_le32(index);
49200 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
49201 index 1da168c..8bc7ff6 100644
49202 --- a/fs/coda/cache.c
49203 +++ b/fs/coda/cache.c
49204 @@ -24,7 +24,7 @@
49205 #include "coda_linux.h"
49206 #include "coda_cache.h"
49207
49208 -static atomic_t permission_epoch = ATOMIC_INIT(0);
49209 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
49210
49211 /* replace or extend an acl cache hit */
49212 void coda_cache_enter(struct inode *inode, int mask)
49213 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
49214 struct coda_inode_info *cii = ITOC(inode);
49215
49216 spin_lock(&cii->c_lock);
49217 - cii->c_cached_epoch = atomic_read(&permission_epoch);
49218 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
49219 if (!uid_eq(cii->c_uid, current_fsuid())) {
49220 cii->c_uid = current_fsuid();
49221 cii->c_cached_perm = mask;
49222 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
49223 {
49224 struct coda_inode_info *cii = ITOC(inode);
49225 spin_lock(&cii->c_lock);
49226 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
49227 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
49228 spin_unlock(&cii->c_lock);
49229 }
49230
49231 /* remove all acl caches */
49232 void coda_cache_clear_all(struct super_block *sb)
49233 {
49234 - atomic_inc(&permission_epoch);
49235 + atomic_inc_unchecked(&permission_epoch);
49236 }
49237
49238
49239 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
49240 spin_lock(&cii->c_lock);
49241 hit = (mask & cii->c_cached_perm) == mask &&
49242 uid_eq(cii->c_uid, current_fsuid()) &&
49243 - cii->c_cached_epoch == atomic_read(&permission_epoch);
49244 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
49245 spin_unlock(&cii->c_lock);
49246
49247 return hit;
49248 diff --git a/fs/compat.c b/fs/compat.c
49249 index d487985..c9e04b1 100644
49250 --- a/fs/compat.c
49251 +++ b/fs/compat.c
49252 @@ -54,7 +54,7 @@
49253 #include <asm/ioctls.h>
49254 #include "internal.h"
49255
49256 -int compat_log = 1;
49257 +int compat_log = 0;
49258
49259 int compat_printk(const char *fmt, ...)
49260 {
49261 @@ -490,7 +490,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
49262
49263 set_fs(KERNEL_DS);
49264 /* The __user pointer cast is valid because of the set_fs() */
49265 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
49266 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
49267 set_fs(oldfs);
49268 /* truncating is ok because it's a user address */
49269 if (!ret)
49270 @@ -548,7 +548,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
49271 goto out;
49272
49273 ret = -EINVAL;
49274 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
49275 + if (nr_segs > UIO_MAXIOV)
49276 goto out;
49277 if (nr_segs > fast_segs) {
49278 ret = -ENOMEM;
49279 @@ -835,6 +835,7 @@ struct compat_old_linux_dirent {
49280
49281 struct compat_readdir_callback {
49282 struct compat_old_linux_dirent __user *dirent;
49283 + struct file * file;
49284 int result;
49285 };
49286
49287 @@ -852,6 +853,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
49288 buf->result = -EOVERFLOW;
49289 return -EOVERFLOW;
49290 }
49291 +
49292 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49293 + return 0;
49294 +
49295 buf->result++;
49296 dirent = buf->dirent;
49297 if (!access_ok(VERIFY_WRITE, dirent,
49298 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
49299
49300 buf.result = 0;
49301 buf.dirent = dirent;
49302 + buf.file = f.file;
49303
49304 error = vfs_readdir(f.file, compat_fillonedir, &buf);
49305 if (buf.result)
49306 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
49307 struct compat_getdents_callback {
49308 struct compat_linux_dirent __user *current_dir;
49309 struct compat_linux_dirent __user *previous;
49310 + struct file * file;
49311 int count;
49312 int error;
49313 };
49314 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
49315 buf->error = -EOVERFLOW;
49316 return -EOVERFLOW;
49317 }
49318 +
49319 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49320 + return 0;
49321 +
49322 dirent = buf->previous;
49323 if (dirent) {
49324 if (__put_user(offset, &dirent->d_off))
49325 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
49326 buf.previous = NULL;
49327 buf.count = count;
49328 buf.error = 0;
49329 + buf.file = f.file;
49330
49331 error = vfs_readdir(f.file, compat_filldir, &buf);
49332 if (error >= 0)
49333 @@ -987,6 +999,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
49334 struct compat_getdents_callback64 {
49335 struct linux_dirent64 __user *current_dir;
49336 struct linux_dirent64 __user *previous;
49337 + struct file * file;
49338 int count;
49339 int error;
49340 };
49341 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
49342 buf->error = -EINVAL; /* only used if we fail.. */
49343 if (reclen > buf->count)
49344 return -EINVAL;
49345 +
49346 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49347 + return 0;
49348 +
49349 dirent = buf->previous;
49350
49351 if (dirent) {
49352 @@ -1052,13 +1069,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
49353 buf.previous = NULL;
49354 buf.count = count;
49355 buf.error = 0;
49356 + buf.file = f.file;
49357
49358 error = vfs_readdir(f.file, compat_filldir64, &buf);
49359 if (error >= 0)
49360 error = buf.error;
49361 lastdirent = buf.previous;
49362 if (lastdirent) {
49363 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
49364 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
49365 if (__put_user_unaligned(d_off, &lastdirent->d_off))
49366 error = -EFAULT;
49367 else
49368 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
49369 index a81147e..20bf2b5 100644
49370 --- a/fs/compat_binfmt_elf.c
49371 +++ b/fs/compat_binfmt_elf.c
49372 @@ -30,11 +30,13 @@
49373 #undef elf_phdr
49374 #undef elf_shdr
49375 #undef elf_note
49376 +#undef elf_dyn
49377 #undef elf_addr_t
49378 #define elfhdr elf32_hdr
49379 #define elf_phdr elf32_phdr
49380 #define elf_shdr elf32_shdr
49381 #define elf_note elf32_note
49382 +#define elf_dyn Elf32_Dyn
49383 #define elf_addr_t Elf32_Addr
49384
49385 /*
49386 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
49387 index 3ced75f..1eeca06 100644
49388 --- a/fs/compat_ioctl.c
49389 +++ b/fs/compat_ioctl.c
49390 @@ -623,7 +623,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
49391 return -EFAULT;
49392 if (__get_user(udata, &ss32->iomem_base))
49393 return -EFAULT;
49394 - ss.iomem_base = compat_ptr(udata);
49395 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
49396 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
49397 __get_user(ss.port_high, &ss32->port_high))
49398 return -EFAULT;
49399 @@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
49400 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
49401 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
49402 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
49403 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
49404 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
49405 return -EFAULT;
49406
49407 return ioctl_preallocate(file, p);
49408 @@ -1620,8 +1620,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
49409 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
49410 {
49411 unsigned int a, b;
49412 - a = *(unsigned int *)p;
49413 - b = *(unsigned int *)q;
49414 + a = *(const unsigned int *)p;
49415 + b = *(const unsigned int *)q;
49416 if (a > b)
49417 return 1;
49418 if (a < b)
49419 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
49420 index 7aabc6a..34c1197 100644
49421 --- a/fs/configfs/dir.c
49422 +++ b/fs/configfs/dir.c
49423 @@ -1565,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
49424 }
49425 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
49426 struct configfs_dirent *next;
49427 - const char * name;
49428 + const unsigned char * name;
49429 + char d_name[sizeof(next->s_dentry->d_iname)];
49430 int len;
49431 struct inode *inode = NULL;
49432
49433 @@ -1575,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
49434 continue;
49435
49436 name = configfs_get_name(next);
49437 - len = strlen(name);
49438 + if (next->s_dentry && name == next->s_dentry->d_iname) {
49439 + len = next->s_dentry->d_name.len;
49440 + memcpy(d_name, name, len);
49441 + name = d_name;
49442 + } else
49443 + len = strlen(name);
49444
49445 /*
49446 * We'll have a dentry and an inode for
49447 diff --git a/fs/coredump.c b/fs/coredump.c
49448 index c647965..a77bff3 100644
49449 --- a/fs/coredump.c
49450 +++ b/fs/coredump.c
49451 @@ -52,7 +52,7 @@ struct core_name {
49452 char *corename;
49453 int used, size;
49454 };
49455 -static atomic_t call_count = ATOMIC_INIT(1);
49456 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
49457
49458 /* The maximal length of core_pattern is also specified in sysctl.c */
49459
49460 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
49461 {
49462 char *old_corename = cn->corename;
49463
49464 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
49465 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
49466 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
49467
49468 if (!cn->corename) {
49469 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
49470 int pid_in_pattern = 0;
49471 int err = 0;
49472
49473 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
49474 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
49475 cn->corename = kmalloc(cn->size, GFP_KERNEL);
49476 cn->used = 0;
49477
49478 @@ -414,17 +414,17 @@ static void wait_for_dump_helpers(struct file *file)
49479 pipe = file_inode(file)->i_pipe;
49480
49481 pipe_lock(pipe);
49482 - pipe->readers++;
49483 - pipe->writers--;
49484 + atomic_inc(&pipe->readers);
49485 + atomic_dec(&pipe->writers);
49486
49487 - while ((pipe->readers > 1) && (!signal_pending(current))) {
49488 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
49489 wake_up_interruptible_sync(&pipe->wait);
49490 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
49491 pipe_wait(pipe);
49492 }
49493
49494 - pipe->readers--;
49495 - pipe->writers++;
49496 + atomic_dec(&pipe->readers);
49497 + atomic_inc(&pipe->writers);
49498 pipe_unlock(pipe);
49499
49500 }
49501 @@ -471,7 +471,8 @@ void do_coredump(siginfo_t *siginfo)
49502 int ispipe;
49503 struct files_struct *displaced;
49504 bool need_nonrelative = false;
49505 - static atomic_t core_dump_count = ATOMIC_INIT(0);
49506 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
49507 + long signr = siginfo->si_signo;
49508 struct coredump_params cprm = {
49509 .siginfo = siginfo,
49510 .regs = signal_pt_regs(),
49511 @@ -484,7 +485,10 @@ void do_coredump(siginfo_t *siginfo)
49512 .mm_flags = mm->flags,
49513 };
49514
49515 - audit_core_dumps(siginfo->si_signo);
49516 + audit_core_dumps(signr);
49517 +
49518 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
49519 + gr_handle_brute_attach(cprm.mm_flags);
49520
49521 binfmt = mm->binfmt;
49522 if (!binfmt || !binfmt->core_dump)
49523 @@ -508,7 +512,7 @@ void do_coredump(siginfo_t *siginfo)
49524 need_nonrelative = true;
49525 }
49526
49527 - retval = coredump_wait(siginfo->si_signo, &core_state);
49528 + retval = coredump_wait(signr, &core_state);
49529 if (retval < 0)
49530 goto fail_creds;
49531
49532 @@ -556,7 +560,7 @@ void do_coredump(siginfo_t *siginfo)
49533 }
49534 cprm.limit = RLIM_INFINITY;
49535
49536 - dump_count = atomic_inc_return(&core_dump_count);
49537 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
49538 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
49539 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
49540 task_tgid_vnr(current), current->comm);
49541 @@ -583,6 +587,8 @@ void do_coredump(siginfo_t *siginfo)
49542 } else {
49543 struct inode *inode;
49544
49545 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
49546 +
49547 if (cprm.limit < binfmt->min_coredump)
49548 goto fail_unlock;
49549
49550 @@ -640,7 +646,7 @@ close_fail:
49551 filp_close(cprm.file, NULL);
49552 fail_dropcount:
49553 if (ispipe)
49554 - atomic_dec(&core_dump_count);
49555 + atomic_dec_unchecked(&core_dump_count);
49556 fail_unlock:
49557 kfree(cn.corename);
49558 fail_corename:
49559 @@ -659,7 +665,7 @@ fail:
49560 */
49561 int dump_write(struct file *file, const void *addr, int nr)
49562 {
49563 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
49564 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
49565 }
49566 EXPORT_SYMBOL(dump_write);
49567
49568 diff --git a/fs/dcache.c b/fs/dcache.c
49569 index e689268..f36956e 100644
49570 --- a/fs/dcache.c
49571 +++ b/fs/dcache.c
49572 @@ -3100,7 +3100,7 @@ void __init vfs_caches_init(unsigned long mempages)
49573 mempages -= reserve;
49574
49575 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
49576 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
49577 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
49578
49579 dcache_init();
49580 inode_init();
49581 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
49582 index 4888cb3..e0f7cf8 100644
49583 --- a/fs/debugfs/inode.c
49584 +++ b/fs/debugfs/inode.c
49585 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
49586 */
49587 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
49588 {
49589 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
49590 + return __create_file(name, S_IFDIR | S_IRWXU,
49591 +#else
49592 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
49593 +#endif
49594 parent, NULL, NULL);
49595 }
49596 EXPORT_SYMBOL_GPL(debugfs_create_dir);
49597 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
49598 index 5eab400..810a3f5 100644
49599 --- a/fs/ecryptfs/inode.c
49600 +++ b/fs/ecryptfs/inode.c
49601 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
49602 old_fs = get_fs();
49603 set_fs(get_ds());
49604 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
49605 - (char __user *)lower_buf,
49606 + (char __force_user *)lower_buf,
49607 PATH_MAX);
49608 set_fs(old_fs);
49609 if (rc < 0)
49610 @@ -706,7 +706,7 @@ out:
49611 static void
49612 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
49613 {
49614 - char *buf = nd_get_link(nd);
49615 + const char *buf = nd_get_link(nd);
49616 if (!IS_ERR(buf)) {
49617 /* Free the char* */
49618 kfree(buf);
49619 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
49620 index e4141f2..d8263e8 100644
49621 --- a/fs/ecryptfs/miscdev.c
49622 +++ b/fs/ecryptfs/miscdev.c
49623 @@ -304,7 +304,7 @@ check_list:
49624 goto out_unlock_msg_ctx;
49625 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
49626 if (msg_ctx->msg) {
49627 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
49628 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
49629 goto out_unlock_msg_ctx;
49630 i += packet_length_size;
49631 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
49632 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
49633 index 6a16053..2155147 100644
49634 --- a/fs/ecryptfs/read_write.c
49635 +++ b/fs/ecryptfs/read_write.c
49636 @@ -240,7 +240,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
49637 return -EIO;
49638 fs_save = get_fs();
49639 set_fs(get_ds());
49640 - rc = vfs_read(lower_file, data, size, &offset);
49641 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
49642 set_fs(fs_save);
49643 return rc;
49644 }
49645 diff --git a/fs/exec.c b/fs/exec.c
49646 index 6d56ff2..b56586d 100644
49647 --- a/fs/exec.c
49648 +++ b/fs/exec.c
49649 @@ -55,8 +55,20 @@
49650 #include <linux/pipe_fs_i.h>
49651 #include <linux/oom.h>
49652 #include <linux/compat.h>
49653 +#include <linux/random.h>
49654 +#include <linux/seq_file.h>
49655 +#include <linux/coredump.h>
49656 +#include <linux/mman.h>
49657 +
49658 +#ifdef CONFIG_PAX_REFCOUNT
49659 +#include <linux/kallsyms.h>
49660 +#include <linux/kdebug.h>
49661 +#endif
49662 +
49663 +#include <trace/events/fs.h>
49664
49665 #include <asm/uaccess.h>
49666 +#include <asm/sections.h>
49667 #include <asm/mmu_context.h>
49668 #include <asm/tlb.h>
49669
49670 @@ -66,6 +78,18 @@
49671
49672 #include <trace/events/sched.h>
49673
49674 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
49675 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
49676 +{
49677 + 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");
49678 +}
49679 +#endif
49680 +
49681 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
49682 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
49683 +EXPORT_SYMBOL(pax_set_initial_flags_func);
49684 +#endif
49685 +
49686 int suid_dumpable = 0;
49687
49688 static LIST_HEAD(formats);
49689 @@ -75,8 +99,8 @@ void __register_binfmt(struct linux_binfmt * fmt, int insert)
49690 {
49691 BUG_ON(!fmt);
49692 write_lock(&binfmt_lock);
49693 - insert ? list_add(&fmt->lh, &formats) :
49694 - list_add_tail(&fmt->lh, &formats);
49695 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
49696 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
49697 write_unlock(&binfmt_lock);
49698 }
49699
49700 @@ -85,7 +109,7 @@ EXPORT_SYMBOL(__register_binfmt);
49701 void unregister_binfmt(struct linux_binfmt * fmt)
49702 {
49703 write_lock(&binfmt_lock);
49704 - list_del(&fmt->lh);
49705 + pax_list_del((struct list_head *)&fmt->lh);
49706 write_unlock(&binfmt_lock);
49707 }
49708
49709 @@ -180,18 +204,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
49710 int write)
49711 {
49712 struct page *page;
49713 - int ret;
49714
49715 -#ifdef CONFIG_STACK_GROWSUP
49716 - if (write) {
49717 - ret = expand_downwards(bprm->vma, pos);
49718 - if (ret < 0)
49719 - return NULL;
49720 - }
49721 -#endif
49722 - ret = get_user_pages(current, bprm->mm, pos,
49723 - 1, write, 1, &page, NULL);
49724 - if (ret <= 0)
49725 + if (0 > expand_downwards(bprm->vma, pos))
49726 + return NULL;
49727 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
49728 return NULL;
49729
49730 if (write) {
49731 @@ -207,6 +223,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
49732 if (size <= ARG_MAX)
49733 return page;
49734
49735 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
49736 + // only allow 512KB for argv+env on suid/sgid binaries
49737 + // to prevent easy ASLR exhaustion
49738 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
49739 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
49740 + (size > (512 * 1024))) {
49741 + put_page(page);
49742 + return NULL;
49743 + }
49744 +#endif
49745 +
49746 /*
49747 * Limit to 1/4-th the stack size for the argv+env strings.
49748 * This ensures that:
49749 @@ -266,6 +293,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
49750 vma->vm_end = STACK_TOP_MAX;
49751 vma->vm_start = vma->vm_end - PAGE_SIZE;
49752 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
49753 +
49754 +#ifdef CONFIG_PAX_SEGMEXEC
49755 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
49756 +#endif
49757 +
49758 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
49759 INIT_LIST_HEAD(&vma->anon_vma_chain);
49760
49761 @@ -276,6 +308,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
49762 mm->stack_vm = mm->total_vm = 1;
49763 up_write(&mm->mmap_sem);
49764 bprm->p = vma->vm_end - sizeof(void *);
49765 +
49766 +#ifdef CONFIG_PAX_RANDUSTACK
49767 + if (randomize_va_space)
49768 + bprm->p ^= random32() & ~PAGE_MASK;
49769 +#endif
49770 +
49771 return 0;
49772 err:
49773 up_write(&mm->mmap_sem);
49774 @@ -396,7 +434,7 @@ struct user_arg_ptr {
49775 } ptr;
49776 };
49777
49778 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
49779 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
49780 {
49781 const char __user *native;
49782
49783 @@ -405,14 +443,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
49784 compat_uptr_t compat;
49785
49786 if (get_user(compat, argv.ptr.compat + nr))
49787 - return ERR_PTR(-EFAULT);
49788 + return (const char __force_user *)ERR_PTR(-EFAULT);
49789
49790 return compat_ptr(compat);
49791 }
49792 #endif
49793
49794 if (get_user(native, argv.ptr.native + nr))
49795 - return ERR_PTR(-EFAULT);
49796 + return (const char __force_user *)ERR_PTR(-EFAULT);
49797
49798 return native;
49799 }
49800 @@ -431,7 +469,7 @@ static int count(struct user_arg_ptr argv, int max)
49801 if (!p)
49802 break;
49803
49804 - if (IS_ERR(p))
49805 + if (IS_ERR((const char __force_kernel *)p))
49806 return -EFAULT;
49807
49808 if (i >= max)
49809 @@ -466,7 +504,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
49810
49811 ret = -EFAULT;
49812 str = get_user_arg_ptr(argv, argc);
49813 - if (IS_ERR(str))
49814 + if (IS_ERR((const char __force_kernel *)str))
49815 goto out;
49816
49817 len = strnlen_user(str, MAX_ARG_STRLEN);
49818 @@ -548,7 +586,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
49819 int r;
49820 mm_segment_t oldfs = get_fs();
49821 struct user_arg_ptr argv = {
49822 - .ptr.native = (const char __user *const __user *)__argv,
49823 + .ptr.native = (const char __force_user *const __force_user *)__argv,
49824 };
49825
49826 set_fs(KERNEL_DS);
49827 @@ -583,7 +621,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
49828 unsigned long new_end = old_end - shift;
49829 struct mmu_gather tlb;
49830
49831 - BUG_ON(new_start > new_end);
49832 + if (new_start >= new_end || new_start < mmap_min_addr)
49833 + return -ENOMEM;
49834
49835 /*
49836 * ensure there are no vmas between where we want to go
49837 @@ -592,6 +631,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
49838 if (vma != find_vma(mm, new_start))
49839 return -EFAULT;
49840
49841 +#ifdef CONFIG_PAX_SEGMEXEC
49842 + BUG_ON(pax_find_mirror_vma(vma));
49843 +#endif
49844 +
49845 /*
49846 * cover the whole range: [new_start, old_end)
49847 */
49848 @@ -672,10 +715,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
49849 stack_top = arch_align_stack(stack_top);
49850 stack_top = PAGE_ALIGN(stack_top);
49851
49852 - if (unlikely(stack_top < mmap_min_addr) ||
49853 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
49854 - return -ENOMEM;
49855 -
49856 stack_shift = vma->vm_end - stack_top;
49857
49858 bprm->p -= stack_shift;
49859 @@ -687,8 +726,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
49860 bprm->exec -= stack_shift;
49861
49862 down_write(&mm->mmap_sem);
49863 +
49864 + /* Move stack pages down in memory. */
49865 + if (stack_shift) {
49866 + ret = shift_arg_pages(vma, stack_shift);
49867 + if (ret)
49868 + goto out_unlock;
49869 + }
49870 +
49871 vm_flags = VM_STACK_FLAGS;
49872
49873 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
49874 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49875 + vm_flags &= ~VM_EXEC;
49876 +
49877 +#ifdef CONFIG_PAX_MPROTECT
49878 + if (mm->pax_flags & MF_PAX_MPROTECT)
49879 + vm_flags &= ~VM_MAYEXEC;
49880 +#endif
49881 +
49882 + }
49883 +#endif
49884 +
49885 /*
49886 * Adjust stack execute permissions; explicitly enable for
49887 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
49888 @@ -707,13 +766,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
49889 goto out_unlock;
49890 BUG_ON(prev != vma);
49891
49892 - /* Move stack pages down in memory. */
49893 - if (stack_shift) {
49894 - ret = shift_arg_pages(vma, stack_shift);
49895 - if (ret)
49896 - goto out_unlock;
49897 - }
49898 -
49899 /* mprotect_fixup is overkill to remove the temporary stack flags */
49900 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
49901
49902 @@ -737,6 +789,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
49903 #endif
49904 current->mm->start_stack = bprm->p;
49905 ret = expand_stack(vma, stack_base);
49906 +
49907 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
49908 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
49909 + unsigned long size;
49910 + vm_flags_t vm_flags;
49911 +
49912 + size = STACK_TOP - vma->vm_end;
49913 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
49914 +
49915 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
49916 +
49917 +#ifdef CONFIG_X86
49918 + if (!ret) {
49919 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
49920 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
49921 + }
49922 +#endif
49923 +
49924 + }
49925 +#endif
49926 +
49927 if (ret)
49928 ret = -EFAULT;
49929
49930 @@ -772,6 +845,8 @@ struct file *open_exec(const char *name)
49931
49932 fsnotify_open(file);
49933
49934 + trace_open_exec(name);
49935 +
49936 err = deny_write_access(file);
49937 if (err)
49938 goto exit;
49939 @@ -795,7 +870,7 @@ int kernel_read(struct file *file, loff_t offset,
49940 old_fs = get_fs();
49941 set_fs(get_ds());
49942 /* The cast to a user pointer is valid due to the set_fs() */
49943 - result = vfs_read(file, (void __user *)addr, count, &pos);
49944 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
49945 set_fs(old_fs);
49946 return result;
49947 }
49948 @@ -1250,7 +1325,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
49949 }
49950 rcu_read_unlock();
49951
49952 - if (p->fs->users > n_fs) {
49953 + if (atomic_read(&p->fs->users) > n_fs) {
49954 bprm->unsafe |= LSM_UNSAFE_SHARE;
49955 } else {
49956 res = -EAGAIN;
49957 @@ -1450,6 +1525,31 @@ int search_binary_handler(struct linux_binprm *bprm)
49958
49959 EXPORT_SYMBOL(search_binary_handler);
49960
49961 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
49962 +static DEFINE_PER_CPU(u64, exec_counter);
49963 +static int __init init_exec_counters(void)
49964 +{
49965 + unsigned int cpu;
49966 +
49967 + for_each_possible_cpu(cpu) {
49968 + per_cpu(exec_counter, cpu) = (u64)cpu;
49969 + }
49970 +
49971 + return 0;
49972 +}
49973 +early_initcall(init_exec_counters);
49974 +static inline void increment_exec_counter(void)
49975 +{
49976 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
49977 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
49978 +}
49979 +#else
49980 +static inline void increment_exec_counter(void) {}
49981 +#endif
49982 +
49983 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
49984 + struct user_arg_ptr argv);
49985 +
49986 /*
49987 * sys_execve() executes a new program.
49988 */
49989 @@ -1457,6 +1557,11 @@ static int do_execve_common(const char *filename,
49990 struct user_arg_ptr argv,
49991 struct user_arg_ptr envp)
49992 {
49993 +#ifdef CONFIG_GRKERNSEC
49994 + struct file *old_exec_file;
49995 + struct acl_subject_label *old_acl;
49996 + struct rlimit old_rlim[RLIM_NLIMITS];
49997 +#endif
49998 struct linux_binprm *bprm;
49999 struct file *file;
50000 struct files_struct *displaced;
50001 @@ -1464,6 +1569,8 @@ static int do_execve_common(const char *filename,
50002 int retval;
50003 const struct cred *cred = current_cred();
50004
50005 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current->cred->user->processes), 1);
50006 +
50007 /*
50008 * We move the actual failure in case of RLIMIT_NPROC excess from
50009 * set*uid() to execve() because too many poorly written programs
50010 @@ -1504,12 +1611,27 @@ static int do_execve_common(const char *filename,
50011 if (IS_ERR(file))
50012 goto out_unmark;
50013
50014 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
50015 + retval = -EPERM;
50016 + goto out_file;
50017 + }
50018 +
50019 sched_exec();
50020
50021 bprm->file = file;
50022 bprm->filename = filename;
50023 bprm->interp = filename;
50024
50025 + if (gr_process_user_ban()) {
50026 + retval = -EPERM;
50027 + goto out_file;
50028 + }
50029 +
50030 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
50031 + retval = -EACCES;
50032 + goto out_file;
50033 + }
50034 +
50035 retval = bprm_mm_init(bprm);
50036 if (retval)
50037 goto out_file;
50038 @@ -1526,24 +1648,65 @@ static int do_execve_common(const char *filename,
50039 if (retval < 0)
50040 goto out;
50041
50042 +#ifdef CONFIG_GRKERNSEC
50043 + old_acl = current->acl;
50044 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
50045 + old_exec_file = current->exec_file;
50046 + get_file(file);
50047 + current->exec_file = file;
50048 +#endif
50049 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50050 + /* limit suid stack to 8MB
50051 + * we saved the old limits above and will restore them if this exec fails
50052 + */
50053 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
50054 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
50055 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
50056 +#endif
50057 +
50058 + if (!gr_tpe_allow(file)) {
50059 + retval = -EACCES;
50060 + goto out_fail;
50061 + }
50062 +
50063 + if (gr_check_crash_exec(file)) {
50064 + retval = -EACCES;
50065 + goto out_fail;
50066 + }
50067 +
50068 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
50069 + bprm->unsafe);
50070 + if (retval < 0)
50071 + goto out_fail;
50072 +
50073 retval = copy_strings_kernel(1, &bprm->filename, bprm);
50074 if (retval < 0)
50075 - goto out;
50076 + goto out_fail;
50077
50078 bprm->exec = bprm->p;
50079 retval = copy_strings(bprm->envc, envp, bprm);
50080 if (retval < 0)
50081 - goto out;
50082 + goto out_fail;
50083
50084 retval = copy_strings(bprm->argc, argv, bprm);
50085 if (retval < 0)
50086 - goto out;
50087 + goto out_fail;
50088 +
50089 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
50090 +
50091 + gr_handle_exec_args(bprm, argv);
50092
50093 retval = search_binary_handler(bprm);
50094 if (retval < 0)
50095 - goto out;
50096 + goto out_fail;
50097 +#ifdef CONFIG_GRKERNSEC
50098 + if (old_exec_file)
50099 + fput(old_exec_file);
50100 +#endif
50101
50102 /* execve succeeded */
50103 +
50104 + increment_exec_counter();
50105 current->fs->in_exec = 0;
50106 current->in_execve = 0;
50107 acct_update_integrals(current);
50108 @@ -1552,6 +1715,14 @@ static int do_execve_common(const char *filename,
50109 put_files_struct(displaced);
50110 return retval;
50111
50112 +out_fail:
50113 +#ifdef CONFIG_GRKERNSEC
50114 + current->acl = old_acl;
50115 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
50116 + fput(current->exec_file);
50117 + current->exec_file = old_exec_file;
50118 +#endif
50119 +
50120 out:
50121 if (bprm->mm) {
50122 acct_arg_size(bprm, 0);
50123 @@ -1700,3 +1871,283 @@ asmlinkage long compat_sys_execve(const char __user * filename,
50124 return error;
50125 }
50126 #endif
50127 +
50128 +int pax_check_flags(unsigned long *flags)
50129 +{
50130 + int retval = 0;
50131 +
50132 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
50133 + if (*flags & MF_PAX_SEGMEXEC)
50134 + {
50135 + *flags &= ~MF_PAX_SEGMEXEC;
50136 + retval = -EINVAL;
50137 + }
50138 +#endif
50139 +
50140 + if ((*flags & MF_PAX_PAGEEXEC)
50141 +
50142 +#ifdef CONFIG_PAX_PAGEEXEC
50143 + && (*flags & MF_PAX_SEGMEXEC)
50144 +#endif
50145 +
50146 + )
50147 + {
50148 + *flags &= ~MF_PAX_PAGEEXEC;
50149 + retval = -EINVAL;
50150 + }
50151 +
50152 + if ((*flags & MF_PAX_MPROTECT)
50153 +
50154 +#ifdef CONFIG_PAX_MPROTECT
50155 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
50156 +#endif
50157 +
50158 + )
50159 + {
50160 + *flags &= ~MF_PAX_MPROTECT;
50161 + retval = -EINVAL;
50162 + }
50163 +
50164 + if ((*flags & MF_PAX_EMUTRAMP)
50165 +
50166 +#ifdef CONFIG_PAX_EMUTRAMP
50167 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
50168 +#endif
50169 +
50170 + )
50171 + {
50172 + *flags &= ~MF_PAX_EMUTRAMP;
50173 + retval = -EINVAL;
50174 + }
50175 +
50176 + return retval;
50177 +}
50178 +
50179 +EXPORT_SYMBOL(pax_check_flags);
50180 +
50181 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50182 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
50183 +{
50184 + struct task_struct *tsk = current;
50185 + struct mm_struct *mm = current->mm;
50186 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
50187 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
50188 + char *path_exec = NULL;
50189 + char *path_fault = NULL;
50190 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
50191 + siginfo_t info = { };
50192 +
50193 + if (buffer_exec && buffer_fault) {
50194 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
50195 +
50196 + down_read(&mm->mmap_sem);
50197 + vma = mm->mmap;
50198 + while (vma && (!vma_exec || !vma_fault)) {
50199 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
50200 + vma_exec = vma;
50201 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
50202 + vma_fault = vma;
50203 + vma = vma->vm_next;
50204 + }
50205 + if (vma_exec) {
50206 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
50207 + if (IS_ERR(path_exec))
50208 + path_exec = "<path too long>";
50209 + else {
50210 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
50211 + if (path_exec) {
50212 + *path_exec = 0;
50213 + path_exec = buffer_exec;
50214 + } else
50215 + path_exec = "<path too long>";
50216 + }
50217 + }
50218 + if (vma_fault) {
50219 + start = vma_fault->vm_start;
50220 + end = vma_fault->vm_end;
50221 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
50222 + if (vma_fault->vm_file) {
50223 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
50224 + if (IS_ERR(path_fault))
50225 + path_fault = "<path too long>";
50226 + else {
50227 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
50228 + if (path_fault) {
50229 + *path_fault = 0;
50230 + path_fault = buffer_fault;
50231 + } else
50232 + path_fault = "<path too long>";
50233 + }
50234 + } else
50235 + path_fault = "<anonymous mapping>";
50236 + }
50237 + up_read(&mm->mmap_sem);
50238 + }
50239 + if (tsk->signal->curr_ip)
50240 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
50241 + else
50242 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
50243 + 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),
50244 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
50245 + free_page((unsigned long)buffer_exec);
50246 + free_page((unsigned long)buffer_fault);
50247 + pax_report_insns(regs, pc, sp);
50248 + info.si_signo = SIGKILL;
50249 + info.si_errno = 0;
50250 + info.si_code = SI_KERNEL;
50251 + info.si_pid = 0;
50252 + info.si_uid = 0;
50253 + do_coredump(&info);
50254 +}
50255 +#endif
50256 +
50257 +#ifdef CONFIG_PAX_REFCOUNT
50258 +void pax_report_refcount_overflow(struct pt_regs *regs)
50259 +{
50260 + if (current->signal->curr_ip)
50261 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
50262 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
50263 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
50264 + else
50265 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
50266 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
50267 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
50268 + show_regs(regs);
50269 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
50270 +}
50271 +#endif
50272 +
50273 +#ifdef CONFIG_PAX_USERCOPY
50274 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
50275 +static noinline int check_stack_object(const void *obj, unsigned long len)
50276 +{
50277 + const void * const stack = task_stack_page(current);
50278 + const void * const stackend = stack + THREAD_SIZE;
50279 +
50280 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
50281 + const void *frame = NULL;
50282 + const void *oldframe;
50283 +#endif
50284 +
50285 + if (obj + len < obj)
50286 + return -1;
50287 +
50288 + if (obj + len <= stack || stackend <= obj)
50289 + return 0;
50290 +
50291 + if (obj < stack || stackend < obj + len)
50292 + return -1;
50293 +
50294 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
50295 + oldframe = __builtin_frame_address(1);
50296 + if (oldframe)
50297 + frame = __builtin_frame_address(2);
50298 + /*
50299 + low ----------------------------------------------> high
50300 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
50301 + ^----------------^
50302 + allow copies only within here
50303 + */
50304 + while (stack <= frame && frame < stackend) {
50305 + /* if obj + len extends past the last frame, this
50306 + check won't pass and the next frame will be 0,
50307 + causing us to bail out and correctly report
50308 + the copy as invalid
50309 + */
50310 + if (obj + len <= frame)
50311 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
50312 + oldframe = frame;
50313 + frame = *(const void * const *)frame;
50314 + }
50315 + return -1;
50316 +#else
50317 + return 1;
50318 +#endif
50319 +}
50320 +
50321 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
50322 +{
50323 + if (current->signal->curr_ip)
50324 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
50325 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
50326 + else
50327 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
50328 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
50329 + dump_stack();
50330 + gr_handle_kernel_exploit();
50331 + do_group_exit(SIGKILL);
50332 +}
50333 +#endif
50334 +
50335 +#ifdef CONFIG_PAX_USERCOPY
50336 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
50337 +{
50338 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
50339 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
50340 +#ifdef CONFIG_MODULES
50341 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
50342 +#else
50343 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
50344 +#endif
50345 +
50346 +#else
50347 + unsigned long textlow = _stext;
50348 + unsigned long texthigh = _etext;
50349 +#endif
50350 +
50351 + if (high <= textlow || low > texthigh)
50352 + return false;
50353 + else
50354 + return true;
50355 +}
50356 +#endif
50357 +
50358 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
50359 +{
50360 +
50361 +#ifdef CONFIG_PAX_USERCOPY
50362 + const char *type;
50363 +
50364 + if (!n)
50365 + return;
50366 +
50367 + type = check_heap_object(ptr, n);
50368 + if (!type) {
50369 + int ret = check_stack_object(ptr, n);
50370 + if (ret == 1 || ret == 2)
50371 + return;
50372 + if (ret == 0) {
50373 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
50374 + type = "<kernel text>";
50375 + else
50376 + return;
50377 + } else
50378 + type = "<process stack>";
50379 + }
50380 +
50381 + pax_report_usercopy(ptr, n, to_user, type);
50382 +#endif
50383 +
50384 +}
50385 +EXPORT_SYMBOL(__check_object_size);
50386 +
50387 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
50388 +void pax_track_stack(void)
50389 +{
50390 + unsigned long sp = (unsigned long)&sp;
50391 + if (sp < current_thread_info()->lowest_stack &&
50392 + sp > (unsigned long)task_stack_page(current))
50393 + current_thread_info()->lowest_stack = sp;
50394 +}
50395 +EXPORT_SYMBOL(pax_track_stack);
50396 +#endif
50397 +
50398 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
50399 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
50400 +{
50401 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
50402 + dump_stack();
50403 + do_group_exit(SIGKILL);
50404 +}
50405 +EXPORT_SYMBOL(report_size_overflow);
50406 +#endif
50407 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
50408 index 9f9992b..8b59411 100644
50409 --- a/fs/ext2/balloc.c
50410 +++ b/fs/ext2/balloc.c
50411 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
50412
50413 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
50414 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
50415 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
50416 + if (free_blocks < root_blocks + 1 &&
50417 !uid_eq(sbi->s_resuid, current_fsuid()) &&
50418 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
50419 - !in_group_p (sbi->s_resgid))) {
50420 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
50421 return 0;
50422 }
50423 return 1;
50424 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
50425 index 22548f5..41521d8 100644
50426 --- a/fs/ext3/balloc.c
50427 +++ b/fs/ext3/balloc.c
50428 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
50429
50430 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
50431 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
50432 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
50433 + if (free_blocks < root_blocks + 1 &&
50434 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
50435 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
50436 - !in_group_p (sbi->s_resgid))) {
50437 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
50438 return 0;
50439 }
50440 return 1;
50441 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
50442 index 92e68b3..115d987 100644
50443 --- a/fs/ext4/balloc.c
50444 +++ b/fs/ext4/balloc.c
50445 @@ -505,8 +505,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
50446 /* Hm, nope. Are (enough) root reserved clusters available? */
50447 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
50448 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
50449 - capable(CAP_SYS_RESOURCE) ||
50450 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
50451 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
50452 + capable_nolog(CAP_SYS_RESOURCE)) {
50453
50454 if (free_clusters >= (nclusters + dirty_clusters))
50455 return 1;
50456 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
50457 index 3b83cd6..0f34dcd 100644
50458 --- a/fs/ext4/ext4.h
50459 +++ b/fs/ext4/ext4.h
50460 @@ -1254,19 +1254,19 @@ struct ext4_sb_info {
50461 unsigned long s_mb_last_start;
50462
50463 /* stats for buddy allocator */
50464 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
50465 - atomic_t s_bal_success; /* we found long enough chunks */
50466 - atomic_t s_bal_allocated; /* in blocks */
50467 - atomic_t s_bal_ex_scanned; /* total extents scanned */
50468 - atomic_t s_bal_goals; /* goal hits */
50469 - atomic_t s_bal_breaks; /* too long searches */
50470 - atomic_t s_bal_2orders; /* 2^order hits */
50471 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
50472 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
50473 + atomic_unchecked_t s_bal_allocated; /* in blocks */
50474 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
50475 + atomic_unchecked_t s_bal_goals; /* goal hits */
50476 + atomic_unchecked_t s_bal_breaks; /* too long searches */
50477 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
50478 spinlock_t s_bal_lock;
50479 unsigned long s_mb_buddies_generated;
50480 unsigned long long s_mb_generation_time;
50481 - atomic_t s_mb_lost_chunks;
50482 - atomic_t s_mb_preallocated;
50483 - atomic_t s_mb_discarded;
50484 + atomic_unchecked_t s_mb_lost_chunks;
50485 + atomic_unchecked_t s_mb_preallocated;
50486 + atomic_unchecked_t s_mb_discarded;
50487 atomic_t s_lock_busy;
50488
50489 /* locality groups */
50490 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
50491 index cf3025c..cac6011 100644
50492 --- a/fs/ext4/mballoc.c
50493 +++ b/fs/ext4/mballoc.c
50494 @@ -1754,7 +1754,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
50495 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
50496
50497 if (EXT4_SB(sb)->s_mb_stats)
50498 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
50499 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
50500
50501 break;
50502 }
50503 @@ -2055,7 +2055,7 @@ repeat:
50504 ac->ac_status = AC_STATUS_CONTINUE;
50505 ac->ac_flags |= EXT4_MB_HINT_FIRST;
50506 cr = 3;
50507 - atomic_inc(&sbi->s_mb_lost_chunks);
50508 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
50509 goto repeat;
50510 }
50511 }
50512 @@ -2563,25 +2563,25 @@ int ext4_mb_release(struct super_block *sb)
50513 if (sbi->s_mb_stats) {
50514 ext4_msg(sb, KERN_INFO,
50515 "mballoc: %u blocks %u reqs (%u success)",
50516 - atomic_read(&sbi->s_bal_allocated),
50517 - atomic_read(&sbi->s_bal_reqs),
50518 - atomic_read(&sbi->s_bal_success));
50519 + atomic_read_unchecked(&sbi->s_bal_allocated),
50520 + atomic_read_unchecked(&sbi->s_bal_reqs),
50521 + atomic_read_unchecked(&sbi->s_bal_success));
50522 ext4_msg(sb, KERN_INFO,
50523 "mballoc: %u extents scanned, %u goal hits, "
50524 "%u 2^N hits, %u breaks, %u lost",
50525 - atomic_read(&sbi->s_bal_ex_scanned),
50526 - atomic_read(&sbi->s_bal_goals),
50527 - atomic_read(&sbi->s_bal_2orders),
50528 - atomic_read(&sbi->s_bal_breaks),
50529 - atomic_read(&sbi->s_mb_lost_chunks));
50530 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
50531 + atomic_read_unchecked(&sbi->s_bal_goals),
50532 + atomic_read_unchecked(&sbi->s_bal_2orders),
50533 + atomic_read_unchecked(&sbi->s_bal_breaks),
50534 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
50535 ext4_msg(sb, KERN_INFO,
50536 "mballoc: %lu generated and it took %Lu",
50537 sbi->s_mb_buddies_generated,
50538 sbi->s_mb_generation_time);
50539 ext4_msg(sb, KERN_INFO,
50540 "mballoc: %u preallocated, %u discarded",
50541 - atomic_read(&sbi->s_mb_preallocated),
50542 - atomic_read(&sbi->s_mb_discarded));
50543 + atomic_read_unchecked(&sbi->s_mb_preallocated),
50544 + atomic_read_unchecked(&sbi->s_mb_discarded));
50545 }
50546
50547 free_percpu(sbi->s_locality_groups);
50548 @@ -3035,16 +3035,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
50549 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
50550
50551 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
50552 - atomic_inc(&sbi->s_bal_reqs);
50553 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
50554 + atomic_inc_unchecked(&sbi->s_bal_reqs);
50555 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
50556 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
50557 - atomic_inc(&sbi->s_bal_success);
50558 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
50559 + atomic_inc_unchecked(&sbi->s_bal_success);
50560 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
50561 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
50562 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
50563 - atomic_inc(&sbi->s_bal_goals);
50564 + atomic_inc_unchecked(&sbi->s_bal_goals);
50565 if (ac->ac_found > sbi->s_mb_max_to_scan)
50566 - atomic_inc(&sbi->s_bal_breaks);
50567 + atomic_inc_unchecked(&sbi->s_bal_breaks);
50568 }
50569
50570 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
50571 @@ -3444,7 +3444,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
50572 trace_ext4_mb_new_inode_pa(ac, pa);
50573
50574 ext4_mb_use_inode_pa(ac, pa);
50575 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
50576 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
50577
50578 ei = EXT4_I(ac->ac_inode);
50579 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
50580 @@ -3504,7 +3504,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
50581 trace_ext4_mb_new_group_pa(ac, pa);
50582
50583 ext4_mb_use_group_pa(ac, pa);
50584 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
50585 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
50586
50587 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
50588 lg = ac->ac_lg;
50589 @@ -3593,7 +3593,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
50590 * from the bitmap and continue.
50591 */
50592 }
50593 - atomic_add(free, &sbi->s_mb_discarded);
50594 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
50595
50596 return err;
50597 }
50598 @@ -3611,7 +3611,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
50599 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
50600 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
50601 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
50602 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
50603 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
50604 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
50605
50606 return 0;
50607 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
50608 index febbe0e..782c4fd 100644
50609 --- a/fs/ext4/super.c
50610 +++ b/fs/ext4/super.c
50611 @@ -2380,7 +2380,7 @@ struct ext4_attr {
50612 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
50613 const char *, size_t);
50614 int offset;
50615 -};
50616 +} __do_const;
50617
50618 static int parse_strtoul(const char *buf,
50619 unsigned long max, unsigned long *value)
50620 diff --git a/fs/fcntl.c b/fs/fcntl.c
50621 index 6599222..e7bf0de 100644
50622 --- a/fs/fcntl.c
50623 +++ b/fs/fcntl.c
50624 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
50625 if (err)
50626 return err;
50627
50628 + if (gr_handle_chroot_fowner(pid, type))
50629 + return -ENOENT;
50630 + if (gr_check_protected_task_fowner(pid, type))
50631 + return -EACCES;
50632 +
50633 f_modown(filp, pid, type, force);
50634 return 0;
50635 }
50636 diff --git a/fs/fhandle.c b/fs/fhandle.c
50637 index 999ff5c..41f4109 100644
50638 --- a/fs/fhandle.c
50639 +++ b/fs/fhandle.c
50640 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
50641 } else
50642 retval = 0;
50643 /* copy the mount id */
50644 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
50645 - sizeof(*mnt_id)) ||
50646 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
50647 copy_to_user(ufh, handle,
50648 sizeof(struct file_handle) + handle_bytes))
50649 retval = -EFAULT;
50650 diff --git a/fs/fifo.c b/fs/fifo.c
50651 index cf6f434..3d7942c 100644
50652 --- a/fs/fifo.c
50653 +++ b/fs/fifo.c
50654 @@ -59,10 +59,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
50655 */
50656 filp->f_op = &read_pipefifo_fops;
50657 pipe->r_counter++;
50658 - if (pipe->readers++ == 0)
50659 + if (atomic_inc_return(&pipe->readers) == 1)
50660 wake_up_partner(inode);
50661
50662 - if (!pipe->writers) {
50663 + if (!atomic_read(&pipe->writers)) {
50664 if ((filp->f_flags & O_NONBLOCK)) {
50665 /* suppress POLLHUP until we have
50666 * seen a writer */
50667 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
50668 * errno=ENXIO when there is no process reading the FIFO.
50669 */
50670 ret = -ENXIO;
50671 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
50672 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
50673 goto err;
50674
50675 filp->f_op = &write_pipefifo_fops;
50676 pipe->w_counter++;
50677 - if (!pipe->writers++)
50678 + if (atomic_inc_return(&pipe->writers) == 1)
50679 wake_up_partner(inode);
50680
50681 - if (!pipe->readers) {
50682 + if (!atomic_read(&pipe->readers)) {
50683 if (wait_for_partner(inode, &pipe->r_counter))
50684 goto err_wr;
50685 }
50686 @@ -104,11 +104,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
50687 */
50688 filp->f_op = &rdwr_pipefifo_fops;
50689
50690 - pipe->readers++;
50691 - pipe->writers++;
50692 + atomic_inc(&pipe->readers);
50693 + atomic_inc(&pipe->writers);
50694 pipe->r_counter++;
50695 pipe->w_counter++;
50696 - if (pipe->readers == 1 || pipe->writers == 1)
50697 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
50698 wake_up_partner(inode);
50699 break;
50700
50701 @@ -122,19 +122,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
50702 return 0;
50703
50704 err_rd:
50705 - if (!--pipe->readers)
50706 + if (atomic_dec_and_test(&pipe->readers))
50707 wake_up_interruptible(&pipe->wait);
50708 ret = -ERESTARTSYS;
50709 goto err;
50710
50711 err_wr:
50712 - if (!--pipe->writers)
50713 + if (atomic_dec_and_test(&pipe->writers))
50714 wake_up_interruptible(&pipe->wait);
50715 ret = -ERESTARTSYS;
50716 goto err;
50717
50718 err:
50719 - if (!pipe->readers && !pipe->writers)
50720 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
50721 free_pipe_info(inode);
50722
50723 err_nocleanup:
50724 diff --git a/fs/file.c b/fs/file.c
50725 index 3906d95..5fe379b 100644
50726 --- a/fs/file.c
50727 +++ b/fs/file.c
50728 @@ -16,6 +16,7 @@
50729 #include <linux/slab.h>
50730 #include <linux/vmalloc.h>
50731 #include <linux/file.h>
50732 +#include <linux/security.h>
50733 #include <linux/fdtable.h>
50734 #include <linux/bitops.h>
50735 #include <linux/interrupt.h>
50736 @@ -892,6 +893,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
50737 if (!file)
50738 return __close_fd(files, fd);
50739
50740 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
50741 if (fd >= rlimit(RLIMIT_NOFILE))
50742 return -EBADF;
50743
50744 @@ -918,6 +920,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
50745 if (unlikely(oldfd == newfd))
50746 return -EINVAL;
50747
50748 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
50749 if (newfd >= rlimit(RLIMIT_NOFILE))
50750 return -EBADF;
50751
50752 @@ -973,6 +976,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
50753 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
50754 {
50755 int err;
50756 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
50757 if (from >= rlimit(RLIMIT_NOFILE))
50758 return -EINVAL;
50759 err = alloc_fd(from, flags);
50760 diff --git a/fs/filesystems.c b/fs/filesystems.c
50761 index 92567d9..fcd8cbf 100644
50762 --- a/fs/filesystems.c
50763 +++ b/fs/filesystems.c
50764 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
50765 int len = dot ? dot - name : strlen(name);
50766
50767 fs = __get_fs_type(name, len);
50768 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
50769 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
50770 +#else
50771 if (!fs && (request_module("fs-%.*s", len, name) == 0))
50772 +#endif
50773 fs = __get_fs_type(name, len);
50774
50775 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
50776 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
50777 index d8ac61d..79a36f0 100644
50778 --- a/fs/fs_struct.c
50779 +++ b/fs/fs_struct.c
50780 @@ -4,6 +4,7 @@
50781 #include <linux/path.h>
50782 #include <linux/slab.h>
50783 #include <linux/fs_struct.h>
50784 +#include <linux/grsecurity.h>
50785 #include "internal.h"
50786
50787 /*
50788 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
50789 write_seqcount_begin(&fs->seq);
50790 old_root = fs->root;
50791 fs->root = *path;
50792 + gr_set_chroot_entries(current, path);
50793 write_seqcount_end(&fs->seq);
50794 spin_unlock(&fs->lock);
50795 if (old_root.dentry)
50796 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
50797 int hits = 0;
50798 spin_lock(&fs->lock);
50799 write_seqcount_begin(&fs->seq);
50800 + /* this root replacement is only done by pivot_root,
50801 + leave grsec's chroot tagging alone for this task
50802 + so that a pivoted root isn't treated as a chroot
50803 + */
50804 hits += replace_path(&fs->root, old_root, new_root);
50805 hits += replace_path(&fs->pwd, old_root, new_root);
50806 write_seqcount_end(&fs->seq);
50807 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
50808 task_lock(tsk);
50809 spin_lock(&fs->lock);
50810 tsk->fs = NULL;
50811 - kill = !--fs->users;
50812 + gr_clear_chroot_entries(tsk);
50813 + kill = !atomic_dec_return(&fs->users);
50814 spin_unlock(&fs->lock);
50815 task_unlock(tsk);
50816 if (kill)
50817 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
50818 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
50819 /* We don't need to lock fs - think why ;-) */
50820 if (fs) {
50821 - fs->users = 1;
50822 + atomic_set(&fs->users, 1);
50823 fs->in_exec = 0;
50824 spin_lock_init(&fs->lock);
50825 seqcount_init(&fs->seq);
50826 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
50827 spin_lock(&old->lock);
50828 fs->root = old->root;
50829 path_get(&fs->root);
50830 + /* instead of calling gr_set_chroot_entries here,
50831 + we call it from every caller of this function
50832 + */
50833 fs->pwd = old->pwd;
50834 path_get(&fs->pwd);
50835 spin_unlock(&old->lock);
50836 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
50837
50838 task_lock(current);
50839 spin_lock(&fs->lock);
50840 - kill = !--fs->users;
50841 + kill = !atomic_dec_return(&fs->users);
50842 current->fs = new_fs;
50843 + gr_set_chroot_entries(current, &new_fs->root);
50844 spin_unlock(&fs->lock);
50845 task_unlock(current);
50846
50847 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
50848
50849 int current_umask(void)
50850 {
50851 - return current->fs->umask;
50852 + return current->fs->umask | gr_acl_umask();
50853 }
50854 EXPORT_SYMBOL(current_umask);
50855
50856 /* to be mentioned only in INIT_TASK */
50857 struct fs_struct init_fs = {
50858 - .users = 1,
50859 + .users = ATOMIC_INIT(1),
50860 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
50861 .seq = SEQCNT_ZERO,
50862 .umask = 0022,
50863 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
50864 index e2cba1f..17a25bb 100644
50865 --- a/fs/fscache/cookie.c
50866 +++ b/fs/fscache/cookie.c
50867 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
50868 parent ? (char *) parent->def->name : "<no-parent>",
50869 def->name, netfs_data);
50870
50871 - fscache_stat(&fscache_n_acquires);
50872 + fscache_stat_unchecked(&fscache_n_acquires);
50873
50874 /* if there's no parent cookie, then we don't create one here either */
50875 if (!parent) {
50876 - fscache_stat(&fscache_n_acquires_null);
50877 + fscache_stat_unchecked(&fscache_n_acquires_null);
50878 _leave(" [no parent]");
50879 return NULL;
50880 }
50881 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
50882 /* allocate and initialise a cookie */
50883 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
50884 if (!cookie) {
50885 - fscache_stat(&fscache_n_acquires_oom);
50886 + fscache_stat_unchecked(&fscache_n_acquires_oom);
50887 _leave(" [ENOMEM]");
50888 return NULL;
50889 }
50890 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
50891
50892 switch (cookie->def->type) {
50893 case FSCACHE_COOKIE_TYPE_INDEX:
50894 - fscache_stat(&fscache_n_cookie_index);
50895 + fscache_stat_unchecked(&fscache_n_cookie_index);
50896 break;
50897 case FSCACHE_COOKIE_TYPE_DATAFILE:
50898 - fscache_stat(&fscache_n_cookie_data);
50899 + fscache_stat_unchecked(&fscache_n_cookie_data);
50900 break;
50901 default:
50902 - fscache_stat(&fscache_n_cookie_special);
50903 + fscache_stat_unchecked(&fscache_n_cookie_special);
50904 break;
50905 }
50906
50907 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
50908 if (fscache_acquire_non_index_cookie(cookie) < 0) {
50909 atomic_dec(&parent->n_children);
50910 __fscache_cookie_put(cookie);
50911 - fscache_stat(&fscache_n_acquires_nobufs);
50912 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
50913 _leave(" = NULL");
50914 return NULL;
50915 }
50916 }
50917
50918 - fscache_stat(&fscache_n_acquires_ok);
50919 + fscache_stat_unchecked(&fscache_n_acquires_ok);
50920 _leave(" = %p", cookie);
50921 return cookie;
50922 }
50923 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
50924 cache = fscache_select_cache_for_object(cookie->parent);
50925 if (!cache) {
50926 up_read(&fscache_addremove_sem);
50927 - fscache_stat(&fscache_n_acquires_no_cache);
50928 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
50929 _leave(" = -ENOMEDIUM [no cache]");
50930 return -ENOMEDIUM;
50931 }
50932 @@ -255,12 +255,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
50933 object = cache->ops->alloc_object(cache, cookie);
50934 fscache_stat_d(&fscache_n_cop_alloc_object);
50935 if (IS_ERR(object)) {
50936 - fscache_stat(&fscache_n_object_no_alloc);
50937 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
50938 ret = PTR_ERR(object);
50939 goto error;
50940 }
50941
50942 - fscache_stat(&fscache_n_object_alloc);
50943 + fscache_stat_unchecked(&fscache_n_object_alloc);
50944
50945 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
50946
50947 @@ -376,7 +376,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
50948
50949 _enter("{%s}", cookie->def->name);
50950
50951 - fscache_stat(&fscache_n_invalidates);
50952 + fscache_stat_unchecked(&fscache_n_invalidates);
50953
50954 /* Only permit invalidation of data files. Invalidating an index will
50955 * require the caller to release all its attachments to the tree rooted
50956 @@ -434,10 +434,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
50957 {
50958 struct fscache_object *object;
50959
50960 - fscache_stat(&fscache_n_updates);
50961 + fscache_stat_unchecked(&fscache_n_updates);
50962
50963 if (!cookie) {
50964 - fscache_stat(&fscache_n_updates_null);
50965 + fscache_stat_unchecked(&fscache_n_updates_null);
50966 _leave(" [no cookie]");
50967 return;
50968 }
50969 @@ -471,12 +471,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
50970 struct fscache_object *object;
50971 unsigned long event;
50972
50973 - fscache_stat(&fscache_n_relinquishes);
50974 + fscache_stat_unchecked(&fscache_n_relinquishes);
50975 if (retire)
50976 - fscache_stat(&fscache_n_relinquishes_retire);
50977 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
50978
50979 if (!cookie) {
50980 - fscache_stat(&fscache_n_relinquishes_null);
50981 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
50982 _leave(" [no cookie]");
50983 return;
50984 }
50985 @@ -492,7 +492,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
50986
50987 /* wait for the cookie to finish being instantiated (or to fail) */
50988 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
50989 - fscache_stat(&fscache_n_relinquishes_waitcrt);
50990 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
50991 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
50992 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
50993 }
50994 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
50995 index ee38fef..0a326d4 100644
50996 --- a/fs/fscache/internal.h
50997 +++ b/fs/fscache/internal.h
50998 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
50999 * stats.c
51000 */
51001 #ifdef CONFIG_FSCACHE_STATS
51002 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51003 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51004 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51005 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51006
51007 -extern atomic_t fscache_n_op_pend;
51008 -extern atomic_t fscache_n_op_run;
51009 -extern atomic_t fscache_n_op_enqueue;
51010 -extern atomic_t fscache_n_op_deferred_release;
51011 -extern atomic_t fscache_n_op_release;
51012 -extern atomic_t fscache_n_op_gc;
51013 -extern atomic_t fscache_n_op_cancelled;
51014 -extern atomic_t fscache_n_op_rejected;
51015 +extern atomic_unchecked_t fscache_n_op_pend;
51016 +extern atomic_unchecked_t fscache_n_op_run;
51017 +extern atomic_unchecked_t fscache_n_op_enqueue;
51018 +extern atomic_unchecked_t fscache_n_op_deferred_release;
51019 +extern atomic_unchecked_t fscache_n_op_release;
51020 +extern atomic_unchecked_t fscache_n_op_gc;
51021 +extern atomic_unchecked_t fscache_n_op_cancelled;
51022 +extern atomic_unchecked_t fscache_n_op_rejected;
51023
51024 -extern atomic_t fscache_n_attr_changed;
51025 -extern atomic_t fscache_n_attr_changed_ok;
51026 -extern atomic_t fscache_n_attr_changed_nobufs;
51027 -extern atomic_t fscache_n_attr_changed_nomem;
51028 -extern atomic_t fscache_n_attr_changed_calls;
51029 +extern atomic_unchecked_t fscache_n_attr_changed;
51030 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
51031 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
51032 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
51033 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
51034
51035 -extern atomic_t fscache_n_allocs;
51036 -extern atomic_t fscache_n_allocs_ok;
51037 -extern atomic_t fscache_n_allocs_wait;
51038 -extern atomic_t fscache_n_allocs_nobufs;
51039 -extern atomic_t fscache_n_allocs_intr;
51040 -extern atomic_t fscache_n_allocs_object_dead;
51041 -extern atomic_t fscache_n_alloc_ops;
51042 -extern atomic_t fscache_n_alloc_op_waits;
51043 +extern atomic_unchecked_t fscache_n_allocs;
51044 +extern atomic_unchecked_t fscache_n_allocs_ok;
51045 +extern atomic_unchecked_t fscache_n_allocs_wait;
51046 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
51047 +extern atomic_unchecked_t fscache_n_allocs_intr;
51048 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
51049 +extern atomic_unchecked_t fscache_n_alloc_ops;
51050 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
51051
51052 -extern atomic_t fscache_n_retrievals;
51053 -extern atomic_t fscache_n_retrievals_ok;
51054 -extern atomic_t fscache_n_retrievals_wait;
51055 -extern atomic_t fscache_n_retrievals_nodata;
51056 -extern atomic_t fscache_n_retrievals_nobufs;
51057 -extern atomic_t fscache_n_retrievals_intr;
51058 -extern atomic_t fscache_n_retrievals_nomem;
51059 -extern atomic_t fscache_n_retrievals_object_dead;
51060 -extern atomic_t fscache_n_retrieval_ops;
51061 -extern atomic_t fscache_n_retrieval_op_waits;
51062 +extern atomic_unchecked_t fscache_n_retrievals;
51063 +extern atomic_unchecked_t fscache_n_retrievals_ok;
51064 +extern atomic_unchecked_t fscache_n_retrievals_wait;
51065 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
51066 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
51067 +extern atomic_unchecked_t fscache_n_retrievals_intr;
51068 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
51069 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
51070 +extern atomic_unchecked_t fscache_n_retrieval_ops;
51071 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
51072
51073 -extern atomic_t fscache_n_stores;
51074 -extern atomic_t fscache_n_stores_ok;
51075 -extern atomic_t fscache_n_stores_again;
51076 -extern atomic_t fscache_n_stores_nobufs;
51077 -extern atomic_t fscache_n_stores_oom;
51078 -extern atomic_t fscache_n_store_ops;
51079 -extern atomic_t fscache_n_store_calls;
51080 -extern atomic_t fscache_n_store_pages;
51081 -extern atomic_t fscache_n_store_radix_deletes;
51082 -extern atomic_t fscache_n_store_pages_over_limit;
51083 +extern atomic_unchecked_t fscache_n_stores;
51084 +extern atomic_unchecked_t fscache_n_stores_ok;
51085 +extern atomic_unchecked_t fscache_n_stores_again;
51086 +extern atomic_unchecked_t fscache_n_stores_nobufs;
51087 +extern atomic_unchecked_t fscache_n_stores_oom;
51088 +extern atomic_unchecked_t fscache_n_store_ops;
51089 +extern atomic_unchecked_t fscache_n_store_calls;
51090 +extern atomic_unchecked_t fscache_n_store_pages;
51091 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
51092 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
51093
51094 -extern atomic_t fscache_n_store_vmscan_not_storing;
51095 -extern atomic_t fscache_n_store_vmscan_gone;
51096 -extern atomic_t fscache_n_store_vmscan_busy;
51097 -extern atomic_t fscache_n_store_vmscan_cancelled;
51098 -extern atomic_t fscache_n_store_vmscan_wait;
51099 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
51100 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
51101 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
51102 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
51103 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
51104
51105 -extern atomic_t fscache_n_marks;
51106 -extern atomic_t fscache_n_uncaches;
51107 +extern atomic_unchecked_t fscache_n_marks;
51108 +extern atomic_unchecked_t fscache_n_uncaches;
51109
51110 -extern atomic_t fscache_n_acquires;
51111 -extern atomic_t fscache_n_acquires_null;
51112 -extern atomic_t fscache_n_acquires_no_cache;
51113 -extern atomic_t fscache_n_acquires_ok;
51114 -extern atomic_t fscache_n_acquires_nobufs;
51115 -extern atomic_t fscache_n_acquires_oom;
51116 +extern atomic_unchecked_t fscache_n_acquires;
51117 +extern atomic_unchecked_t fscache_n_acquires_null;
51118 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
51119 +extern atomic_unchecked_t fscache_n_acquires_ok;
51120 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
51121 +extern atomic_unchecked_t fscache_n_acquires_oom;
51122
51123 -extern atomic_t fscache_n_invalidates;
51124 -extern atomic_t fscache_n_invalidates_run;
51125 +extern atomic_unchecked_t fscache_n_invalidates;
51126 +extern atomic_unchecked_t fscache_n_invalidates_run;
51127
51128 -extern atomic_t fscache_n_updates;
51129 -extern atomic_t fscache_n_updates_null;
51130 -extern atomic_t fscache_n_updates_run;
51131 +extern atomic_unchecked_t fscache_n_updates;
51132 +extern atomic_unchecked_t fscache_n_updates_null;
51133 +extern atomic_unchecked_t fscache_n_updates_run;
51134
51135 -extern atomic_t fscache_n_relinquishes;
51136 -extern atomic_t fscache_n_relinquishes_null;
51137 -extern atomic_t fscache_n_relinquishes_waitcrt;
51138 -extern atomic_t fscache_n_relinquishes_retire;
51139 +extern atomic_unchecked_t fscache_n_relinquishes;
51140 +extern atomic_unchecked_t fscache_n_relinquishes_null;
51141 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
51142 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
51143
51144 -extern atomic_t fscache_n_cookie_index;
51145 -extern atomic_t fscache_n_cookie_data;
51146 -extern atomic_t fscache_n_cookie_special;
51147 +extern atomic_unchecked_t fscache_n_cookie_index;
51148 +extern atomic_unchecked_t fscache_n_cookie_data;
51149 +extern atomic_unchecked_t fscache_n_cookie_special;
51150
51151 -extern atomic_t fscache_n_object_alloc;
51152 -extern atomic_t fscache_n_object_no_alloc;
51153 -extern atomic_t fscache_n_object_lookups;
51154 -extern atomic_t fscache_n_object_lookups_negative;
51155 -extern atomic_t fscache_n_object_lookups_positive;
51156 -extern atomic_t fscache_n_object_lookups_timed_out;
51157 -extern atomic_t fscache_n_object_created;
51158 -extern atomic_t fscache_n_object_avail;
51159 -extern atomic_t fscache_n_object_dead;
51160 +extern atomic_unchecked_t fscache_n_object_alloc;
51161 +extern atomic_unchecked_t fscache_n_object_no_alloc;
51162 +extern atomic_unchecked_t fscache_n_object_lookups;
51163 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
51164 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
51165 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
51166 +extern atomic_unchecked_t fscache_n_object_created;
51167 +extern atomic_unchecked_t fscache_n_object_avail;
51168 +extern atomic_unchecked_t fscache_n_object_dead;
51169
51170 -extern atomic_t fscache_n_checkaux_none;
51171 -extern atomic_t fscache_n_checkaux_okay;
51172 -extern atomic_t fscache_n_checkaux_update;
51173 -extern atomic_t fscache_n_checkaux_obsolete;
51174 +extern atomic_unchecked_t fscache_n_checkaux_none;
51175 +extern atomic_unchecked_t fscache_n_checkaux_okay;
51176 +extern atomic_unchecked_t fscache_n_checkaux_update;
51177 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
51178
51179 extern atomic_t fscache_n_cop_alloc_object;
51180 extern atomic_t fscache_n_cop_lookup_object;
51181 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
51182 atomic_inc(stat);
51183 }
51184
51185 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
51186 +{
51187 + atomic_inc_unchecked(stat);
51188 +}
51189 +
51190 static inline void fscache_stat_d(atomic_t *stat)
51191 {
51192 atomic_dec(stat);
51193 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
51194
51195 #define __fscache_stat(stat) (NULL)
51196 #define fscache_stat(stat) do {} while (0)
51197 +#define fscache_stat_unchecked(stat) do {} while (0)
51198 #define fscache_stat_d(stat) do {} while (0)
51199 #endif
51200
51201 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
51202 index 50d41c1..10ee117 100644
51203 --- a/fs/fscache/object.c
51204 +++ b/fs/fscache/object.c
51205 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51206 /* Invalidate an object on disk */
51207 case FSCACHE_OBJECT_INVALIDATING:
51208 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
51209 - fscache_stat(&fscache_n_invalidates_run);
51210 + fscache_stat_unchecked(&fscache_n_invalidates_run);
51211 fscache_stat(&fscache_n_cop_invalidate_object);
51212 fscache_invalidate_object(object);
51213 fscache_stat_d(&fscache_n_cop_invalidate_object);
51214 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51215 /* update the object metadata on disk */
51216 case FSCACHE_OBJECT_UPDATING:
51217 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
51218 - fscache_stat(&fscache_n_updates_run);
51219 + fscache_stat_unchecked(&fscache_n_updates_run);
51220 fscache_stat(&fscache_n_cop_update_object);
51221 object->cache->ops->update_object(object);
51222 fscache_stat_d(&fscache_n_cop_update_object);
51223 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51224 spin_lock(&object->lock);
51225 object->state = FSCACHE_OBJECT_DEAD;
51226 spin_unlock(&object->lock);
51227 - fscache_stat(&fscache_n_object_dead);
51228 + fscache_stat_unchecked(&fscache_n_object_dead);
51229 goto terminal_transit;
51230
51231 /* handle the parent cache of this object being withdrawn from
51232 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51233 spin_lock(&object->lock);
51234 object->state = FSCACHE_OBJECT_DEAD;
51235 spin_unlock(&object->lock);
51236 - fscache_stat(&fscache_n_object_dead);
51237 + fscache_stat_unchecked(&fscache_n_object_dead);
51238 goto terminal_transit;
51239
51240 /* complain about the object being woken up once it is
51241 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
51242 parent->cookie->def->name, cookie->def->name,
51243 object->cache->tag->name);
51244
51245 - fscache_stat(&fscache_n_object_lookups);
51246 + fscache_stat_unchecked(&fscache_n_object_lookups);
51247 fscache_stat(&fscache_n_cop_lookup_object);
51248 ret = object->cache->ops->lookup_object(object);
51249 fscache_stat_d(&fscache_n_cop_lookup_object);
51250 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
51251 if (ret == -ETIMEDOUT) {
51252 /* probably stuck behind another object, so move this one to
51253 * the back of the queue */
51254 - fscache_stat(&fscache_n_object_lookups_timed_out);
51255 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
51256 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
51257 }
51258
51259 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
51260
51261 spin_lock(&object->lock);
51262 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
51263 - fscache_stat(&fscache_n_object_lookups_negative);
51264 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
51265
51266 /* transit here to allow write requests to begin stacking up
51267 * and read requests to begin returning ENODATA */
51268 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
51269 * result, in which case there may be data available */
51270 spin_lock(&object->lock);
51271 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
51272 - fscache_stat(&fscache_n_object_lookups_positive);
51273 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
51274
51275 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
51276
51277 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
51278 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
51279 } else {
51280 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
51281 - fscache_stat(&fscache_n_object_created);
51282 + fscache_stat_unchecked(&fscache_n_object_created);
51283
51284 object->state = FSCACHE_OBJECT_AVAILABLE;
51285 spin_unlock(&object->lock);
51286 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
51287 fscache_enqueue_dependents(object);
51288
51289 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
51290 - fscache_stat(&fscache_n_object_avail);
51291 + fscache_stat_unchecked(&fscache_n_object_avail);
51292
51293 _leave("");
51294 }
51295 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
51296 enum fscache_checkaux result;
51297
51298 if (!object->cookie->def->check_aux) {
51299 - fscache_stat(&fscache_n_checkaux_none);
51300 + fscache_stat_unchecked(&fscache_n_checkaux_none);
51301 return FSCACHE_CHECKAUX_OKAY;
51302 }
51303
51304 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
51305 switch (result) {
51306 /* entry okay as is */
51307 case FSCACHE_CHECKAUX_OKAY:
51308 - fscache_stat(&fscache_n_checkaux_okay);
51309 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
51310 break;
51311
51312 /* entry requires update */
51313 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
51314 - fscache_stat(&fscache_n_checkaux_update);
51315 + fscache_stat_unchecked(&fscache_n_checkaux_update);
51316 break;
51317
51318 /* entry requires deletion */
51319 case FSCACHE_CHECKAUX_OBSOLETE:
51320 - fscache_stat(&fscache_n_checkaux_obsolete);
51321 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
51322 break;
51323
51324 default:
51325 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
51326 index 762a9ec..2023284 100644
51327 --- a/fs/fscache/operation.c
51328 +++ b/fs/fscache/operation.c
51329 @@ -17,7 +17,7 @@
51330 #include <linux/slab.h>
51331 #include "internal.h"
51332
51333 -atomic_t fscache_op_debug_id;
51334 +atomic_unchecked_t fscache_op_debug_id;
51335 EXPORT_SYMBOL(fscache_op_debug_id);
51336
51337 /**
51338 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
51339 ASSERTCMP(atomic_read(&op->usage), >, 0);
51340 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
51341
51342 - fscache_stat(&fscache_n_op_enqueue);
51343 + fscache_stat_unchecked(&fscache_n_op_enqueue);
51344 switch (op->flags & FSCACHE_OP_TYPE) {
51345 case FSCACHE_OP_ASYNC:
51346 _debug("queue async");
51347 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
51348 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
51349 if (op->processor)
51350 fscache_enqueue_operation(op);
51351 - fscache_stat(&fscache_n_op_run);
51352 + fscache_stat_unchecked(&fscache_n_op_run);
51353 }
51354
51355 /*
51356 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
51357 if (object->n_in_progress > 0) {
51358 atomic_inc(&op->usage);
51359 list_add_tail(&op->pend_link, &object->pending_ops);
51360 - fscache_stat(&fscache_n_op_pend);
51361 + fscache_stat_unchecked(&fscache_n_op_pend);
51362 } else if (!list_empty(&object->pending_ops)) {
51363 atomic_inc(&op->usage);
51364 list_add_tail(&op->pend_link, &object->pending_ops);
51365 - fscache_stat(&fscache_n_op_pend);
51366 + fscache_stat_unchecked(&fscache_n_op_pend);
51367 fscache_start_operations(object);
51368 } else {
51369 ASSERTCMP(object->n_in_progress, ==, 0);
51370 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
51371 object->n_exclusive++; /* reads and writes must wait */
51372 atomic_inc(&op->usage);
51373 list_add_tail(&op->pend_link, &object->pending_ops);
51374 - fscache_stat(&fscache_n_op_pend);
51375 + fscache_stat_unchecked(&fscache_n_op_pend);
51376 ret = 0;
51377 } else {
51378 /* If we're in any other state, there must have been an I/O
51379 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
51380 if (object->n_exclusive > 0) {
51381 atomic_inc(&op->usage);
51382 list_add_tail(&op->pend_link, &object->pending_ops);
51383 - fscache_stat(&fscache_n_op_pend);
51384 + fscache_stat_unchecked(&fscache_n_op_pend);
51385 } else if (!list_empty(&object->pending_ops)) {
51386 atomic_inc(&op->usage);
51387 list_add_tail(&op->pend_link, &object->pending_ops);
51388 - fscache_stat(&fscache_n_op_pend);
51389 + fscache_stat_unchecked(&fscache_n_op_pend);
51390 fscache_start_operations(object);
51391 } else {
51392 ASSERTCMP(object->n_exclusive, ==, 0);
51393 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
51394 object->n_ops++;
51395 atomic_inc(&op->usage);
51396 list_add_tail(&op->pend_link, &object->pending_ops);
51397 - fscache_stat(&fscache_n_op_pend);
51398 + fscache_stat_unchecked(&fscache_n_op_pend);
51399 ret = 0;
51400 } else if (object->state == FSCACHE_OBJECT_DYING ||
51401 object->state == FSCACHE_OBJECT_LC_DYING ||
51402 object->state == FSCACHE_OBJECT_WITHDRAWING) {
51403 - fscache_stat(&fscache_n_op_rejected);
51404 + fscache_stat_unchecked(&fscache_n_op_rejected);
51405 op->state = FSCACHE_OP_ST_CANCELLED;
51406 ret = -ENOBUFS;
51407 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
51408 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
51409 ret = -EBUSY;
51410 if (op->state == FSCACHE_OP_ST_PENDING) {
51411 ASSERT(!list_empty(&op->pend_link));
51412 - fscache_stat(&fscache_n_op_cancelled);
51413 + fscache_stat_unchecked(&fscache_n_op_cancelled);
51414 list_del_init(&op->pend_link);
51415 if (do_cancel)
51416 do_cancel(op);
51417 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
51418 while (!list_empty(&object->pending_ops)) {
51419 op = list_entry(object->pending_ops.next,
51420 struct fscache_operation, pend_link);
51421 - fscache_stat(&fscache_n_op_cancelled);
51422 + fscache_stat_unchecked(&fscache_n_op_cancelled);
51423 list_del_init(&op->pend_link);
51424
51425 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
51426 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
51427 op->state, ==, FSCACHE_OP_ST_CANCELLED);
51428 op->state = FSCACHE_OP_ST_DEAD;
51429
51430 - fscache_stat(&fscache_n_op_release);
51431 + fscache_stat_unchecked(&fscache_n_op_release);
51432
51433 if (op->release) {
51434 op->release(op);
51435 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
51436 * lock, and defer it otherwise */
51437 if (!spin_trylock(&object->lock)) {
51438 _debug("defer put");
51439 - fscache_stat(&fscache_n_op_deferred_release);
51440 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
51441
51442 cache = object->cache;
51443 spin_lock(&cache->op_gc_list_lock);
51444 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
51445
51446 _debug("GC DEFERRED REL OBJ%x OP%x",
51447 object->debug_id, op->debug_id);
51448 - fscache_stat(&fscache_n_op_gc);
51449 + fscache_stat_unchecked(&fscache_n_op_gc);
51450
51451 ASSERTCMP(atomic_read(&op->usage), ==, 0);
51452 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
51453 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
51454 index ff000e5..c44ec6d 100644
51455 --- a/fs/fscache/page.c
51456 +++ b/fs/fscache/page.c
51457 @@ -61,7 +61,7 @@ try_again:
51458 val = radix_tree_lookup(&cookie->stores, page->index);
51459 if (!val) {
51460 rcu_read_unlock();
51461 - fscache_stat(&fscache_n_store_vmscan_not_storing);
51462 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
51463 __fscache_uncache_page(cookie, page);
51464 return true;
51465 }
51466 @@ -91,11 +91,11 @@ try_again:
51467 spin_unlock(&cookie->stores_lock);
51468
51469 if (xpage) {
51470 - fscache_stat(&fscache_n_store_vmscan_cancelled);
51471 - fscache_stat(&fscache_n_store_radix_deletes);
51472 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
51473 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
51474 ASSERTCMP(xpage, ==, page);
51475 } else {
51476 - fscache_stat(&fscache_n_store_vmscan_gone);
51477 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
51478 }
51479
51480 wake_up_bit(&cookie->flags, 0);
51481 @@ -110,11 +110,11 @@ page_busy:
51482 * sleeping on memory allocation, so we may need to impose a timeout
51483 * too. */
51484 if (!(gfp & __GFP_WAIT)) {
51485 - fscache_stat(&fscache_n_store_vmscan_busy);
51486 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
51487 return false;
51488 }
51489
51490 - fscache_stat(&fscache_n_store_vmscan_wait);
51491 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
51492 __fscache_wait_on_page_write(cookie, page);
51493 gfp &= ~__GFP_WAIT;
51494 goto try_again;
51495 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
51496 FSCACHE_COOKIE_STORING_TAG);
51497 if (!radix_tree_tag_get(&cookie->stores, page->index,
51498 FSCACHE_COOKIE_PENDING_TAG)) {
51499 - fscache_stat(&fscache_n_store_radix_deletes);
51500 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
51501 xpage = radix_tree_delete(&cookie->stores, page->index);
51502 }
51503 spin_unlock(&cookie->stores_lock);
51504 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
51505
51506 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
51507
51508 - fscache_stat(&fscache_n_attr_changed_calls);
51509 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
51510
51511 if (fscache_object_is_active(object)) {
51512 fscache_stat(&fscache_n_cop_attr_changed);
51513 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
51514
51515 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
51516
51517 - fscache_stat(&fscache_n_attr_changed);
51518 + fscache_stat_unchecked(&fscache_n_attr_changed);
51519
51520 op = kzalloc(sizeof(*op), GFP_KERNEL);
51521 if (!op) {
51522 - fscache_stat(&fscache_n_attr_changed_nomem);
51523 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
51524 _leave(" = -ENOMEM");
51525 return -ENOMEM;
51526 }
51527 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
51528 if (fscache_submit_exclusive_op(object, op) < 0)
51529 goto nobufs;
51530 spin_unlock(&cookie->lock);
51531 - fscache_stat(&fscache_n_attr_changed_ok);
51532 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
51533 fscache_put_operation(op);
51534 _leave(" = 0");
51535 return 0;
51536 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
51537 nobufs:
51538 spin_unlock(&cookie->lock);
51539 kfree(op);
51540 - fscache_stat(&fscache_n_attr_changed_nobufs);
51541 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
51542 _leave(" = %d", -ENOBUFS);
51543 return -ENOBUFS;
51544 }
51545 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
51546 /* allocate a retrieval operation and attempt to submit it */
51547 op = kzalloc(sizeof(*op), GFP_NOIO);
51548 if (!op) {
51549 - fscache_stat(&fscache_n_retrievals_nomem);
51550 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
51551 return NULL;
51552 }
51553
51554 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
51555 return 0;
51556 }
51557
51558 - fscache_stat(&fscache_n_retrievals_wait);
51559 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
51560
51561 jif = jiffies;
51562 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
51563 fscache_wait_bit_interruptible,
51564 TASK_INTERRUPTIBLE) != 0) {
51565 - fscache_stat(&fscache_n_retrievals_intr);
51566 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
51567 _leave(" = -ERESTARTSYS");
51568 return -ERESTARTSYS;
51569 }
51570 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
51571 */
51572 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
51573 struct fscache_retrieval *op,
51574 - atomic_t *stat_op_waits,
51575 - atomic_t *stat_object_dead)
51576 + atomic_unchecked_t *stat_op_waits,
51577 + atomic_unchecked_t *stat_object_dead)
51578 {
51579 int ret;
51580
51581 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
51582 goto check_if_dead;
51583
51584 _debug(">>> WT");
51585 - fscache_stat(stat_op_waits);
51586 + fscache_stat_unchecked(stat_op_waits);
51587 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
51588 fscache_wait_bit_interruptible,
51589 TASK_INTERRUPTIBLE) != 0) {
51590 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
51591
51592 check_if_dead:
51593 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
51594 - fscache_stat(stat_object_dead);
51595 + fscache_stat_unchecked(stat_object_dead);
51596 _leave(" = -ENOBUFS [cancelled]");
51597 return -ENOBUFS;
51598 }
51599 if (unlikely(fscache_object_is_dead(object))) {
51600 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
51601 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
51602 - fscache_stat(stat_object_dead);
51603 + fscache_stat_unchecked(stat_object_dead);
51604 return -ENOBUFS;
51605 }
51606 return 0;
51607 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
51608
51609 _enter("%p,%p,,,", cookie, page);
51610
51611 - fscache_stat(&fscache_n_retrievals);
51612 + fscache_stat_unchecked(&fscache_n_retrievals);
51613
51614 if (hlist_empty(&cookie->backing_objects))
51615 goto nobufs;
51616 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
51617 goto nobufs_unlock_dec;
51618 spin_unlock(&cookie->lock);
51619
51620 - fscache_stat(&fscache_n_retrieval_ops);
51621 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
51622
51623 /* pin the netfs read context in case we need to do the actual netfs
51624 * read because we've encountered a cache read failure */
51625 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
51626
51627 error:
51628 if (ret == -ENOMEM)
51629 - fscache_stat(&fscache_n_retrievals_nomem);
51630 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
51631 else if (ret == -ERESTARTSYS)
51632 - fscache_stat(&fscache_n_retrievals_intr);
51633 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
51634 else if (ret == -ENODATA)
51635 - fscache_stat(&fscache_n_retrievals_nodata);
51636 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
51637 else if (ret < 0)
51638 - fscache_stat(&fscache_n_retrievals_nobufs);
51639 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
51640 else
51641 - fscache_stat(&fscache_n_retrievals_ok);
51642 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
51643
51644 fscache_put_retrieval(op);
51645 _leave(" = %d", ret);
51646 @@ -467,7 +467,7 @@ nobufs_unlock:
51647 spin_unlock(&cookie->lock);
51648 kfree(op);
51649 nobufs:
51650 - fscache_stat(&fscache_n_retrievals_nobufs);
51651 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
51652 _leave(" = -ENOBUFS");
51653 return -ENOBUFS;
51654 }
51655 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
51656
51657 _enter("%p,,%d,,,", cookie, *nr_pages);
51658
51659 - fscache_stat(&fscache_n_retrievals);
51660 + fscache_stat_unchecked(&fscache_n_retrievals);
51661
51662 if (hlist_empty(&cookie->backing_objects))
51663 goto nobufs;
51664 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
51665 goto nobufs_unlock_dec;
51666 spin_unlock(&cookie->lock);
51667
51668 - fscache_stat(&fscache_n_retrieval_ops);
51669 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
51670
51671 /* pin the netfs read context in case we need to do the actual netfs
51672 * read because we've encountered a cache read failure */
51673 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
51674
51675 error:
51676 if (ret == -ENOMEM)
51677 - fscache_stat(&fscache_n_retrievals_nomem);
51678 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
51679 else if (ret == -ERESTARTSYS)
51680 - fscache_stat(&fscache_n_retrievals_intr);
51681 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
51682 else if (ret == -ENODATA)
51683 - fscache_stat(&fscache_n_retrievals_nodata);
51684 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
51685 else if (ret < 0)
51686 - fscache_stat(&fscache_n_retrievals_nobufs);
51687 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
51688 else
51689 - fscache_stat(&fscache_n_retrievals_ok);
51690 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
51691
51692 fscache_put_retrieval(op);
51693 _leave(" = %d", ret);
51694 @@ -591,7 +591,7 @@ nobufs_unlock:
51695 spin_unlock(&cookie->lock);
51696 kfree(op);
51697 nobufs:
51698 - fscache_stat(&fscache_n_retrievals_nobufs);
51699 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
51700 _leave(" = -ENOBUFS");
51701 return -ENOBUFS;
51702 }
51703 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
51704
51705 _enter("%p,%p,,,", cookie, page);
51706
51707 - fscache_stat(&fscache_n_allocs);
51708 + fscache_stat_unchecked(&fscache_n_allocs);
51709
51710 if (hlist_empty(&cookie->backing_objects))
51711 goto nobufs;
51712 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
51713 goto nobufs_unlock;
51714 spin_unlock(&cookie->lock);
51715
51716 - fscache_stat(&fscache_n_alloc_ops);
51717 + fscache_stat_unchecked(&fscache_n_alloc_ops);
51718
51719 ret = fscache_wait_for_retrieval_activation(
51720 object, op,
51721 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
51722
51723 error:
51724 if (ret == -ERESTARTSYS)
51725 - fscache_stat(&fscache_n_allocs_intr);
51726 + fscache_stat_unchecked(&fscache_n_allocs_intr);
51727 else if (ret < 0)
51728 - fscache_stat(&fscache_n_allocs_nobufs);
51729 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
51730 else
51731 - fscache_stat(&fscache_n_allocs_ok);
51732 + fscache_stat_unchecked(&fscache_n_allocs_ok);
51733
51734 fscache_put_retrieval(op);
51735 _leave(" = %d", ret);
51736 @@ -677,7 +677,7 @@ nobufs_unlock:
51737 spin_unlock(&cookie->lock);
51738 kfree(op);
51739 nobufs:
51740 - fscache_stat(&fscache_n_allocs_nobufs);
51741 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
51742 _leave(" = -ENOBUFS");
51743 return -ENOBUFS;
51744 }
51745 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
51746
51747 spin_lock(&cookie->stores_lock);
51748
51749 - fscache_stat(&fscache_n_store_calls);
51750 + fscache_stat_unchecked(&fscache_n_store_calls);
51751
51752 /* find a page to store */
51753 page = NULL;
51754 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
51755 page = results[0];
51756 _debug("gang %d [%lx]", n, page->index);
51757 if (page->index > op->store_limit) {
51758 - fscache_stat(&fscache_n_store_pages_over_limit);
51759 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
51760 goto superseded;
51761 }
51762
51763 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
51764 spin_unlock(&cookie->stores_lock);
51765 spin_unlock(&object->lock);
51766
51767 - fscache_stat(&fscache_n_store_pages);
51768 + fscache_stat_unchecked(&fscache_n_store_pages);
51769 fscache_stat(&fscache_n_cop_write_page);
51770 ret = object->cache->ops->write_page(op, page);
51771 fscache_stat_d(&fscache_n_cop_write_page);
51772 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
51773 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
51774 ASSERT(PageFsCache(page));
51775
51776 - fscache_stat(&fscache_n_stores);
51777 + fscache_stat_unchecked(&fscache_n_stores);
51778
51779 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
51780 _leave(" = -ENOBUFS [invalidating]");
51781 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
51782 spin_unlock(&cookie->stores_lock);
51783 spin_unlock(&object->lock);
51784
51785 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
51786 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
51787 op->store_limit = object->store_limit;
51788
51789 if (fscache_submit_op(object, &op->op) < 0)
51790 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
51791
51792 spin_unlock(&cookie->lock);
51793 radix_tree_preload_end();
51794 - fscache_stat(&fscache_n_store_ops);
51795 - fscache_stat(&fscache_n_stores_ok);
51796 + fscache_stat_unchecked(&fscache_n_store_ops);
51797 + fscache_stat_unchecked(&fscache_n_stores_ok);
51798
51799 /* the work queue now carries its own ref on the object */
51800 fscache_put_operation(&op->op);
51801 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
51802 return 0;
51803
51804 already_queued:
51805 - fscache_stat(&fscache_n_stores_again);
51806 + fscache_stat_unchecked(&fscache_n_stores_again);
51807 already_pending:
51808 spin_unlock(&cookie->stores_lock);
51809 spin_unlock(&object->lock);
51810 spin_unlock(&cookie->lock);
51811 radix_tree_preload_end();
51812 kfree(op);
51813 - fscache_stat(&fscache_n_stores_ok);
51814 + fscache_stat_unchecked(&fscache_n_stores_ok);
51815 _leave(" = 0");
51816 return 0;
51817
51818 @@ -959,14 +959,14 @@ nobufs:
51819 spin_unlock(&cookie->lock);
51820 radix_tree_preload_end();
51821 kfree(op);
51822 - fscache_stat(&fscache_n_stores_nobufs);
51823 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
51824 _leave(" = -ENOBUFS");
51825 return -ENOBUFS;
51826
51827 nomem_free:
51828 kfree(op);
51829 nomem:
51830 - fscache_stat(&fscache_n_stores_oom);
51831 + fscache_stat_unchecked(&fscache_n_stores_oom);
51832 _leave(" = -ENOMEM");
51833 return -ENOMEM;
51834 }
51835 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
51836 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
51837 ASSERTCMP(page, !=, NULL);
51838
51839 - fscache_stat(&fscache_n_uncaches);
51840 + fscache_stat_unchecked(&fscache_n_uncaches);
51841
51842 /* cache withdrawal may beat us to it */
51843 if (!PageFsCache(page))
51844 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
51845 struct fscache_cookie *cookie = op->op.object->cookie;
51846
51847 #ifdef CONFIG_FSCACHE_STATS
51848 - atomic_inc(&fscache_n_marks);
51849 + atomic_inc_unchecked(&fscache_n_marks);
51850 #endif
51851
51852 _debug("- mark %p{%lx}", page, page->index);
51853 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
51854 index 40d13c7..ddf52b9 100644
51855 --- a/fs/fscache/stats.c
51856 +++ b/fs/fscache/stats.c
51857 @@ -18,99 +18,99 @@
51858 /*
51859 * operation counters
51860 */
51861 -atomic_t fscache_n_op_pend;
51862 -atomic_t fscache_n_op_run;
51863 -atomic_t fscache_n_op_enqueue;
51864 -atomic_t fscache_n_op_requeue;
51865 -atomic_t fscache_n_op_deferred_release;
51866 -atomic_t fscache_n_op_release;
51867 -atomic_t fscache_n_op_gc;
51868 -atomic_t fscache_n_op_cancelled;
51869 -atomic_t fscache_n_op_rejected;
51870 +atomic_unchecked_t fscache_n_op_pend;
51871 +atomic_unchecked_t fscache_n_op_run;
51872 +atomic_unchecked_t fscache_n_op_enqueue;
51873 +atomic_unchecked_t fscache_n_op_requeue;
51874 +atomic_unchecked_t fscache_n_op_deferred_release;
51875 +atomic_unchecked_t fscache_n_op_release;
51876 +atomic_unchecked_t fscache_n_op_gc;
51877 +atomic_unchecked_t fscache_n_op_cancelled;
51878 +atomic_unchecked_t fscache_n_op_rejected;
51879
51880 -atomic_t fscache_n_attr_changed;
51881 -atomic_t fscache_n_attr_changed_ok;
51882 -atomic_t fscache_n_attr_changed_nobufs;
51883 -atomic_t fscache_n_attr_changed_nomem;
51884 -atomic_t fscache_n_attr_changed_calls;
51885 +atomic_unchecked_t fscache_n_attr_changed;
51886 +atomic_unchecked_t fscache_n_attr_changed_ok;
51887 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
51888 +atomic_unchecked_t fscache_n_attr_changed_nomem;
51889 +atomic_unchecked_t fscache_n_attr_changed_calls;
51890
51891 -atomic_t fscache_n_allocs;
51892 -atomic_t fscache_n_allocs_ok;
51893 -atomic_t fscache_n_allocs_wait;
51894 -atomic_t fscache_n_allocs_nobufs;
51895 -atomic_t fscache_n_allocs_intr;
51896 -atomic_t fscache_n_allocs_object_dead;
51897 -atomic_t fscache_n_alloc_ops;
51898 -atomic_t fscache_n_alloc_op_waits;
51899 +atomic_unchecked_t fscache_n_allocs;
51900 +atomic_unchecked_t fscache_n_allocs_ok;
51901 +atomic_unchecked_t fscache_n_allocs_wait;
51902 +atomic_unchecked_t fscache_n_allocs_nobufs;
51903 +atomic_unchecked_t fscache_n_allocs_intr;
51904 +atomic_unchecked_t fscache_n_allocs_object_dead;
51905 +atomic_unchecked_t fscache_n_alloc_ops;
51906 +atomic_unchecked_t fscache_n_alloc_op_waits;
51907
51908 -atomic_t fscache_n_retrievals;
51909 -atomic_t fscache_n_retrievals_ok;
51910 -atomic_t fscache_n_retrievals_wait;
51911 -atomic_t fscache_n_retrievals_nodata;
51912 -atomic_t fscache_n_retrievals_nobufs;
51913 -atomic_t fscache_n_retrievals_intr;
51914 -atomic_t fscache_n_retrievals_nomem;
51915 -atomic_t fscache_n_retrievals_object_dead;
51916 -atomic_t fscache_n_retrieval_ops;
51917 -atomic_t fscache_n_retrieval_op_waits;
51918 +atomic_unchecked_t fscache_n_retrievals;
51919 +atomic_unchecked_t fscache_n_retrievals_ok;
51920 +atomic_unchecked_t fscache_n_retrievals_wait;
51921 +atomic_unchecked_t fscache_n_retrievals_nodata;
51922 +atomic_unchecked_t fscache_n_retrievals_nobufs;
51923 +atomic_unchecked_t fscache_n_retrievals_intr;
51924 +atomic_unchecked_t fscache_n_retrievals_nomem;
51925 +atomic_unchecked_t fscache_n_retrievals_object_dead;
51926 +atomic_unchecked_t fscache_n_retrieval_ops;
51927 +atomic_unchecked_t fscache_n_retrieval_op_waits;
51928
51929 -atomic_t fscache_n_stores;
51930 -atomic_t fscache_n_stores_ok;
51931 -atomic_t fscache_n_stores_again;
51932 -atomic_t fscache_n_stores_nobufs;
51933 -atomic_t fscache_n_stores_oom;
51934 -atomic_t fscache_n_store_ops;
51935 -atomic_t fscache_n_store_calls;
51936 -atomic_t fscache_n_store_pages;
51937 -atomic_t fscache_n_store_radix_deletes;
51938 -atomic_t fscache_n_store_pages_over_limit;
51939 +atomic_unchecked_t fscache_n_stores;
51940 +atomic_unchecked_t fscache_n_stores_ok;
51941 +atomic_unchecked_t fscache_n_stores_again;
51942 +atomic_unchecked_t fscache_n_stores_nobufs;
51943 +atomic_unchecked_t fscache_n_stores_oom;
51944 +atomic_unchecked_t fscache_n_store_ops;
51945 +atomic_unchecked_t fscache_n_store_calls;
51946 +atomic_unchecked_t fscache_n_store_pages;
51947 +atomic_unchecked_t fscache_n_store_radix_deletes;
51948 +atomic_unchecked_t fscache_n_store_pages_over_limit;
51949
51950 -atomic_t fscache_n_store_vmscan_not_storing;
51951 -atomic_t fscache_n_store_vmscan_gone;
51952 -atomic_t fscache_n_store_vmscan_busy;
51953 -atomic_t fscache_n_store_vmscan_cancelled;
51954 -atomic_t fscache_n_store_vmscan_wait;
51955 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
51956 +atomic_unchecked_t fscache_n_store_vmscan_gone;
51957 +atomic_unchecked_t fscache_n_store_vmscan_busy;
51958 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
51959 +atomic_unchecked_t fscache_n_store_vmscan_wait;
51960
51961 -atomic_t fscache_n_marks;
51962 -atomic_t fscache_n_uncaches;
51963 +atomic_unchecked_t fscache_n_marks;
51964 +atomic_unchecked_t fscache_n_uncaches;
51965
51966 -atomic_t fscache_n_acquires;
51967 -atomic_t fscache_n_acquires_null;
51968 -atomic_t fscache_n_acquires_no_cache;
51969 -atomic_t fscache_n_acquires_ok;
51970 -atomic_t fscache_n_acquires_nobufs;
51971 -atomic_t fscache_n_acquires_oom;
51972 +atomic_unchecked_t fscache_n_acquires;
51973 +atomic_unchecked_t fscache_n_acquires_null;
51974 +atomic_unchecked_t fscache_n_acquires_no_cache;
51975 +atomic_unchecked_t fscache_n_acquires_ok;
51976 +atomic_unchecked_t fscache_n_acquires_nobufs;
51977 +atomic_unchecked_t fscache_n_acquires_oom;
51978
51979 -atomic_t fscache_n_invalidates;
51980 -atomic_t fscache_n_invalidates_run;
51981 +atomic_unchecked_t fscache_n_invalidates;
51982 +atomic_unchecked_t fscache_n_invalidates_run;
51983
51984 -atomic_t fscache_n_updates;
51985 -atomic_t fscache_n_updates_null;
51986 -atomic_t fscache_n_updates_run;
51987 +atomic_unchecked_t fscache_n_updates;
51988 +atomic_unchecked_t fscache_n_updates_null;
51989 +atomic_unchecked_t fscache_n_updates_run;
51990
51991 -atomic_t fscache_n_relinquishes;
51992 -atomic_t fscache_n_relinquishes_null;
51993 -atomic_t fscache_n_relinquishes_waitcrt;
51994 -atomic_t fscache_n_relinquishes_retire;
51995 +atomic_unchecked_t fscache_n_relinquishes;
51996 +atomic_unchecked_t fscache_n_relinquishes_null;
51997 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
51998 +atomic_unchecked_t fscache_n_relinquishes_retire;
51999
52000 -atomic_t fscache_n_cookie_index;
52001 -atomic_t fscache_n_cookie_data;
52002 -atomic_t fscache_n_cookie_special;
52003 +atomic_unchecked_t fscache_n_cookie_index;
52004 +atomic_unchecked_t fscache_n_cookie_data;
52005 +atomic_unchecked_t fscache_n_cookie_special;
52006
52007 -atomic_t fscache_n_object_alloc;
52008 -atomic_t fscache_n_object_no_alloc;
52009 -atomic_t fscache_n_object_lookups;
52010 -atomic_t fscache_n_object_lookups_negative;
52011 -atomic_t fscache_n_object_lookups_positive;
52012 -atomic_t fscache_n_object_lookups_timed_out;
52013 -atomic_t fscache_n_object_created;
52014 -atomic_t fscache_n_object_avail;
52015 -atomic_t fscache_n_object_dead;
52016 +atomic_unchecked_t fscache_n_object_alloc;
52017 +atomic_unchecked_t fscache_n_object_no_alloc;
52018 +atomic_unchecked_t fscache_n_object_lookups;
52019 +atomic_unchecked_t fscache_n_object_lookups_negative;
52020 +atomic_unchecked_t fscache_n_object_lookups_positive;
52021 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
52022 +atomic_unchecked_t fscache_n_object_created;
52023 +atomic_unchecked_t fscache_n_object_avail;
52024 +atomic_unchecked_t fscache_n_object_dead;
52025
52026 -atomic_t fscache_n_checkaux_none;
52027 -atomic_t fscache_n_checkaux_okay;
52028 -atomic_t fscache_n_checkaux_update;
52029 -atomic_t fscache_n_checkaux_obsolete;
52030 +atomic_unchecked_t fscache_n_checkaux_none;
52031 +atomic_unchecked_t fscache_n_checkaux_okay;
52032 +atomic_unchecked_t fscache_n_checkaux_update;
52033 +atomic_unchecked_t fscache_n_checkaux_obsolete;
52034
52035 atomic_t fscache_n_cop_alloc_object;
52036 atomic_t fscache_n_cop_lookup_object;
52037 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
52038 seq_puts(m, "FS-Cache statistics\n");
52039
52040 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
52041 - atomic_read(&fscache_n_cookie_index),
52042 - atomic_read(&fscache_n_cookie_data),
52043 - atomic_read(&fscache_n_cookie_special));
52044 + atomic_read_unchecked(&fscache_n_cookie_index),
52045 + atomic_read_unchecked(&fscache_n_cookie_data),
52046 + atomic_read_unchecked(&fscache_n_cookie_special));
52047
52048 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
52049 - atomic_read(&fscache_n_object_alloc),
52050 - atomic_read(&fscache_n_object_no_alloc),
52051 - atomic_read(&fscache_n_object_avail),
52052 - atomic_read(&fscache_n_object_dead));
52053 + atomic_read_unchecked(&fscache_n_object_alloc),
52054 + atomic_read_unchecked(&fscache_n_object_no_alloc),
52055 + atomic_read_unchecked(&fscache_n_object_avail),
52056 + atomic_read_unchecked(&fscache_n_object_dead));
52057 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
52058 - atomic_read(&fscache_n_checkaux_none),
52059 - atomic_read(&fscache_n_checkaux_okay),
52060 - atomic_read(&fscache_n_checkaux_update),
52061 - atomic_read(&fscache_n_checkaux_obsolete));
52062 + atomic_read_unchecked(&fscache_n_checkaux_none),
52063 + atomic_read_unchecked(&fscache_n_checkaux_okay),
52064 + atomic_read_unchecked(&fscache_n_checkaux_update),
52065 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
52066
52067 seq_printf(m, "Pages : mrk=%u unc=%u\n",
52068 - atomic_read(&fscache_n_marks),
52069 - atomic_read(&fscache_n_uncaches));
52070 + atomic_read_unchecked(&fscache_n_marks),
52071 + atomic_read_unchecked(&fscache_n_uncaches));
52072
52073 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
52074 " oom=%u\n",
52075 - atomic_read(&fscache_n_acquires),
52076 - atomic_read(&fscache_n_acquires_null),
52077 - atomic_read(&fscache_n_acquires_no_cache),
52078 - atomic_read(&fscache_n_acquires_ok),
52079 - atomic_read(&fscache_n_acquires_nobufs),
52080 - atomic_read(&fscache_n_acquires_oom));
52081 + atomic_read_unchecked(&fscache_n_acquires),
52082 + atomic_read_unchecked(&fscache_n_acquires_null),
52083 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
52084 + atomic_read_unchecked(&fscache_n_acquires_ok),
52085 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
52086 + atomic_read_unchecked(&fscache_n_acquires_oom));
52087
52088 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
52089 - atomic_read(&fscache_n_object_lookups),
52090 - atomic_read(&fscache_n_object_lookups_negative),
52091 - atomic_read(&fscache_n_object_lookups_positive),
52092 - atomic_read(&fscache_n_object_created),
52093 - atomic_read(&fscache_n_object_lookups_timed_out));
52094 + atomic_read_unchecked(&fscache_n_object_lookups),
52095 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
52096 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
52097 + atomic_read_unchecked(&fscache_n_object_created),
52098 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
52099
52100 seq_printf(m, "Invals : n=%u run=%u\n",
52101 - atomic_read(&fscache_n_invalidates),
52102 - atomic_read(&fscache_n_invalidates_run));
52103 + atomic_read_unchecked(&fscache_n_invalidates),
52104 + atomic_read_unchecked(&fscache_n_invalidates_run));
52105
52106 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
52107 - atomic_read(&fscache_n_updates),
52108 - atomic_read(&fscache_n_updates_null),
52109 - atomic_read(&fscache_n_updates_run));
52110 + atomic_read_unchecked(&fscache_n_updates),
52111 + atomic_read_unchecked(&fscache_n_updates_null),
52112 + atomic_read_unchecked(&fscache_n_updates_run));
52113
52114 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
52115 - atomic_read(&fscache_n_relinquishes),
52116 - atomic_read(&fscache_n_relinquishes_null),
52117 - atomic_read(&fscache_n_relinquishes_waitcrt),
52118 - atomic_read(&fscache_n_relinquishes_retire));
52119 + atomic_read_unchecked(&fscache_n_relinquishes),
52120 + atomic_read_unchecked(&fscache_n_relinquishes_null),
52121 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
52122 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
52123
52124 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
52125 - atomic_read(&fscache_n_attr_changed),
52126 - atomic_read(&fscache_n_attr_changed_ok),
52127 - atomic_read(&fscache_n_attr_changed_nobufs),
52128 - atomic_read(&fscache_n_attr_changed_nomem),
52129 - atomic_read(&fscache_n_attr_changed_calls));
52130 + atomic_read_unchecked(&fscache_n_attr_changed),
52131 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
52132 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
52133 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
52134 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
52135
52136 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
52137 - atomic_read(&fscache_n_allocs),
52138 - atomic_read(&fscache_n_allocs_ok),
52139 - atomic_read(&fscache_n_allocs_wait),
52140 - atomic_read(&fscache_n_allocs_nobufs),
52141 - atomic_read(&fscache_n_allocs_intr));
52142 + atomic_read_unchecked(&fscache_n_allocs),
52143 + atomic_read_unchecked(&fscache_n_allocs_ok),
52144 + atomic_read_unchecked(&fscache_n_allocs_wait),
52145 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
52146 + atomic_read_unchecked(&fscache_n_allocs_intr));
52147 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
52148 - atomic_read(&fscache_n_alloc_ops),
52149 - atomic_read(&fscache_n_alloc_op_waits),
52150 - atomic_read(&fscache_n_allocs_object_dead));
52151 + atomic_read_unchecked(&fscache_n_alloc_ops),
52152 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
52153 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
52154
52155 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
52156 " int=%u oom=%u\n",
52157 - atomic_read(&fscache_n_retrievals),
52158 - atomic_read(&fscache_n_retrievals_ok),
52159 - atomic_read(&fscache_n_retrievals_wait),
52160 - atomic_read(&fscache_n_retrievals_nodata),
52161 - atomic_read(&fscache_n_retrievals_nobufs),
52162 - atomic_read(&fscache_n_retrievals_intr),
52163 - atomic_read(&fscache_n_retrievals_nomem));
52164 + atomic_read_unchecked(&fscache_n_retrievals),
52165 + atomic_read_unchecked(&fscache_n_retrievals_ok),
52166 + atomic_read_unchecked(&fscache_n_retrievals_wait),
52167 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
52168 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
52169 + atomic_read_unchecked(&fscache_n_retrievals_intr),
52170 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
52171 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
52172 - atomic_read(&fscache_n_retrieval_ops),
52173 - atomic_read(&fscache_n_retrieval_op_waits),
52174 - atomic_read(&fscache_n_retrievals_object_dead));
52175 + atomic_read_unchecked(&fscache_n_retrieval_ops),
52176 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
52177 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
52178
52179 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
52180 - atomic_read(&fscache_n_stores),
52181 - atomic_read(&fscache_n_stores_ok),
52182 - atomic_read(&fscache_n_stores_again),
52183 - atomic_read(&fscache_n_stores_nobufs),
52184 - atomic_read(&fscache_n_stores_oom));
52185 + atomic_read_unchecked(&fscache_n_stores),
52186 + atomic_read_unchecked(&fscache_n_stores_ok),
52187 + atomic_read_unchecked(&fscache_n_stores_again),
52188 + atomic_read_unchecked(&fscache_n_stores_nobufs),
52189 + atomic_read_unchecked(&fscache_n_stores_oom));
52190 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
52191 - atomic_read(&fscache_n_store_ops),
52192 - atomic_read(&fscache_n_store_calls),
52193 - atomic_read(&fscache_n_store_pages),
52194 - atomic_read(&fscache_n_store_radix_deletes),
52195 - atomic_read(&fscache_n_store_pages_over_limit));
52196 + atomic_read_unchecked(&fscache_n_store_ops),
52197 + atomic_read_unchecked(&fscache_n_store_calls),
52198 + atomic_read_unchecked(&fscache_n_store_pages),
52199 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
52200 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
52201
52202 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
52203 - atomic_read(&fscache_n_store_vmscan_not_storing),
52204 - atomic_read(&fscache_n_store_vmscan_gone),
52205 - atomic_read(&fscache_n_store_vmscan_busy),
52206 - atomic_read(&fscache_n_store_vmscan_cancelled),
52207 - atomic_read(&fscache_n_store_vmscan_wait));
52208 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
52209 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
52210 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
52211 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
52212 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
52213
52214 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
52215 - atomic_read(&fscache_n_op_pend),
52216 - atomic_read(&fscache_n_op_run),
52217 - atomic_read(&fscache_n_op_enqueue),
52218 - atomic_read(&fscache_n_op_cancelled),
52219 - atomic_read(&fscache_n_op_rejected));
52220 + atomic_read_unchecked(&fscache_n_op_pend),
52221 + atomic_read_unchecked(&fscache_n_op_run),
52222 + atomic_read_unchecked(&fscache_n_op_enqueue),
52223 + atomic_read_unchecked(&fscache_n_op_cancelled),
52224 + atomic_read_unchecked(&fscache_n_op_rejected));
52225 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
52226 - atomic_read(&fscache_n_op_deferred_release),
52227 - atomic_read(&fscache_n_op_release),
52228 - atomic_read(&fscache_n_op_gc));
52229 + atomic_read_unchecked(&fscache_n_op_deferred_release),
52230 + atomic_read_unchecked(&fscache_n_op_release),
52231 + atomic_read_unchecked(&fscache_n_op_gc));
52232
52233 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
52234 atomic_read(&fscache_n_cop_alloc_object),
52235 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
52236 index 6f96a8d..6019bb9 100644
52237 --- a/fs/fuse/cuse.c
52238 +++ b/fs/fuse/cuse.c
52239 @@ -597,10 +597,12 @@ static int __init cuse_init(void)
52240 INIT_LIST_HEAD(&cuse_conntbl[i]);
52241
52242 /* inherit and extend fuse_dev_operations */
52243 - cuse_channel_fops = fuse_dev_operations;
52244 - cuse_channel_fops.owner = THIS_MODULE;
52245 - cuse_channel_fops.open = cuse_channel_open;
52246 - cuse_channel_fops.release = cuse_channel_release;
52247 + pax_open_kernel();
52248 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
52249 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
52250 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
52251 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
52252 + pax_close_kernel();
52253
52254 cuse_class = class_create(THIS_MODULE, "cuse");
52255 if (IS_ERR(cuse_class))
52256 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
52257 index 11dfa0c..6f64416 100644
52258 --- a/fs/fuse/dev.c
52259 +++ b/fs/fuse/dev.c
52260 @@ -1294,7 +1294,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
52261 ret = 0;
52262 pipe_lock(pipe);
52263
52264 - if (!pipe->readers) {
52265 + if (!atomic_read(&pipe->readers)) {
52266 send_sig(SIGPIPE, current, 0);
52267 if (!ret)
52268 ret = -EPIPE;
52269 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
52270 index ff15522..092a0f6 100644
52271 --- a/fs/fuse/dir.c
52272 +++ b/fs/fuse/dir.c
52273 @@ -1409,7 +1409,7 @@ static char *read_link(struct dentry *dentry)
52274 return link;
52275 }
52276
52277 -static void free_link(char *link)
52278 +static void free_link(const char *link)
52279 {
52280 if (!IS_ERR(link))
52281 free_page((unsigned long) link);
52282 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
52283 index cc00bd1..3edb692 100644
52284 --- a/fs/gfs2/inode.c
52285 +++ b/fs/gfs2/inode.c
52286 @@ -1500,7 +1500,7 @@ out:
52287
52288 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52289 {
52290 - char *s = nd_get_link(nd);
52291 + const char *s = nd_get_link(nd);
52292 if (!IS_ERR(s))
52293 kfree(s);
52294 }
52295 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
52296 index a3f868a..bb308ae 100644
52297 --- a/fs/hugetlbfs/inode.c
52298 +++ b/fs/hugetlbfs/inode.c
52299 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
52300 struct mm_struct *mm = current->mm;
52301 struct vm_area_struct *vma;
52302 struct hstate *h = hstate_file(file);
52303 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
52304 struct vm_unmapped_area_info info;
52305
52306 if (len & ~huge_page_mask(h))
52307 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
52308 return addr;
52309 }
52310
52311 +#ifdef CONFIG_PAX_RANDMMAP
52312 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
52313 +#endif
52314 +
52315 if (addr) {
52316 addr = ALIGN(addr, huge_page_size(h));
52317 vma = find_vma(mm, addr);
52318 - if (TASK_SIZE - len >= addr &&
52319 - (!vma || addr + len <= vma->vm_start))
52320 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
52321 return addr;
52322 }
52323
52324 info.flags = 0;
52325 info.length = len;
52326 info.low_limit = TASK_UNMAPPED_BASE;
52327 +
52328 +#ifdef CONFIG_PAX_RANDMMAP
52329 + if (mm->pax_flags & MF_PAX_RANDMMAP)
52330 + info.low_limit += mm->delta_mmap;
52331 +#endif
52332 +
52333 info.high_limit = TASK_SIZE;
52334 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
52335 info.align_offset = 0;
52336 @@ -898,7 +908,7 @@ static struct file_system_type hugetlbfs_fs_type = {
52337 };
52338 MODULE_ALIAS_FS("hugetlbfs");
52339
52340 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
52341 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
52342
52343 static int can_do_hugetlb_shm(void)
52344 {
52345 diff --git a/fs/inode.c b/fs/inode.c
52346 index a898b3d..9b5a214 100644
52347 --- a/fs/inode.c
52348 +++ b/fs/inode.c
52349 @@ -878,8 +878,8 @@ unsigned int get_next_ino(void)
52350
52351 #ifdef CONFIG_SMP
52352 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
52353 - static atomic_t shared_last_ino;
52354 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
52355 + static atomic_unchecked_t shared_last_ino;
52356 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
52357
52358 res = next - LAST_INO_BATCH;
52359 }
52360 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
52361 index 4a6cf28..d3a29d3 100644
52362 --- a/fs/jffs2/erase.c
52363 +++ b/fs/jffs2/erase.c
52364 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
52365 struct jffs2_unknown_node marker = {
52366 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
52367 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
52368 - .totlen = cpu_to_je32(c->cleanmarker_size)
52369 + .totlen = cpu_to_je32(c->cleanmarker_size),
52370 + .hdr_crc = cpu_to_je32(0)
52371 };
52372
52373 jffs2_prealloc_raw_node_refs(c, jeb, 1);
52374 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
52375 index a6597d6..41b30ec 100644
52376 --- a/fs/jffs2/wbuf.c
52377 +++ b/fs/jffs2/wbuf.c
52378 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
52379 {
52380 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
52381 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
52382 - .totlen = constant_cpu_to_je32(8)
52383 + .totlen = constant_cpu_to_je32(8),
52384 + .hdr_crc = constant_cpu_to_je32(0)
52385 };
52386
52387 /*
52388 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
52389 index 2003e83..5e1975d 100644
52390 --- a/fs/jfs/super.c
52391 +++ b/fs/jfs/super.c
52392 @@ -225,7 +225,7 @@ static const match_table_t tokens = {
52393 static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
52394 int *flag)
52395 {
52396 - void *nls_map = (void *)-1; /* -1: no change; NULL: none */
52397 + const void *nls_map = (const void *)-1; /* -1: no change; NULL: none */
52398 char *p;
52399 struct jfs_sb_info *sbi = JFS_SBI(sb);
52400
52401 @@ -253,7 +253,7 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
52402 /* Don't do anything ;-) */
52403 break;
52404 case Opt_iocharset:
52405 - if (nls_map && nls_map != (void *) -1)
52406 + if (nls_map && nls_map != (const void *) -1)
52407 unload_nls(nls_map);
52408 if (!strcmp(args[0].from, "none"))
52409 nls_map = NULL;
52410 @@ -856,7 +856,7 @@ static int __init init_jfs_fs(void)
52411
52412 jfs_inode_cachep =
52413 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
52414 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
52415 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
52416 init_once);
52417 if (jfs_inode_cachep == NULL)
52418 return -ENOMEM;
52419 diff --git a/fs/libfs.c b/fs/libfs.c
52420 index 916da8c..1588998 100644
52421 --- a/fs/libfs.c
52422 +++ b/fs/libfs.c
52423 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
52424
52425 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
52426 struct dentry *next;
52427 + char d_name[sizeof(next->d_iname)];
52428 + const unsigned char *name;
52429 +
52430 next = list_entry(p, struct dentry, d_u.d_child);
52431 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
52432 if (!simple_positive(next)) {
52433 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
52434
52435 spin_unlock(&next->d_lock);
52436 spin_unlock(&dentry->d_lock);
52437 - if (filldir(dirent, next->d_name.name,
52438 + name = next->d_name.name;
52439 + if (name == next->d_iname) {
52440 + memcpy(d_name, name, next->d_name.len);
52441 + name = d_name;
52442 + }
52443 + if (filldir(dirent, name,
52444 next->d_name.len, filp->f_pos,
52445 next->d_inode->i_ino,
52446 dt_type(next->d_inode)) < 0)
52447 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
52448 index 9760ecb..9b838ef 100644
52449 --- a/fs/lockd/clntproc.c
52450 +++ b/fs/lockd/clntproc.c
52451 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
52452 /*
52453 * Cookie counter for NLM requests
52454 */
52455 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
52456 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
52457
52458 void nlmclnt_next_cookie(struct nlm_cookie *c)
52459 {
52460 - u32 cookie = atomic_inc_return(&nlm_cookie);
52461 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
52462
52463 memcpy(c->data, &cookie, 4);
52464 c->len=4;
52465 diff --git a/fs/locks.c b/fs/locks.c
52466 index cb424a4..850e4dd 100644
52467 --- a/fs/locks.c
52468 +++ b/fs/locks.c
52469 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
52470 return;
52471
52472 if (filp->f_op && filp->f_op->flock) {
52473 - struct file_lock fl = {
52474 + struct file_lock flock = {
52475 .fl_pid = current->tgid,
52476 .fl_file = filp,
52477 .fl_flags = FL_FLOCK,
52478 .fl_type = F_UNLCK,
52479 .fl_end = OFFSET_MAX,
52480 };
52481 - filp->f_op->flock(filp, F_SETLKW, &fl);
52482 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
52483 - fl.fl_ops->fl_release_private(&fl);
52484 + filp->f_op->flock(filp, F_SETLKW, &flock);
52485 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
52486 + flock.fl_ops->fl_release_private(&flock);
52487 }
52488
52489 lock_flocks();
52490 diff --git a/fs/namei.c b/fs/namei.c
52491 index 57ae9c8..b018eba 100644
52492 --- a/fs/namei.c
52493 +++ b/fs/namei.c
52494 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
52495 if (ret != -EACCES)
52496 return ret;
52497
52498 +#ifdef CONFIG_GRKERNSEC
52499 + /* we'll block if we have to log due to a denied capability use */
52500 + if (mask & MAY_NOT_BLOCK)
52501 + return -ECHILD;
52502 +#endif
52503 +
52504 if (S_ISDIR(inode->i_mode)) {
52505 /* DACs are overridable for directories */
52506 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
52507 - return 0;
52508 if (!(mask & MAY_WRITE))
52509 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
52510 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
52511 + inode_capable(inode, CAP_DAC_READ_SEARCH))
52512 return 0;
52513 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
52514 + return 0;
52515 return -EACCES;
52516 }
52517 /*
52518 + * Searching includes executable on directories, else just read.
52519 + */
52520 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
52521 + if (mask == MAY_READ)
52522 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
52523 + inode_capable(inode, CAP_DAC_READ_SEARCH))
52524 + return 0;
52525 +
52526 + /*
52527 * Read/write DACs are always overridable.
52528 * Executable DACs are overridable when there is
52529 * at least one exec bit set.
52530 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
52531 if (inode_capable(inode, CAP_DAC_OVERRIDE))
52532 return 0;
52533
52534 - /*
52535 - * Searching includes executable on directories, else just read.
52536 - */
52537 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
52538 - if (mask == MAY_READ)
52539 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
52540 - return 0;
52541 -
52542 return -EACCES;
52543 }
52544
52545 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
52546 {
52547 struct dentry *dentry = link->dentry;
52548 int error;
52549 - char *s;
52550 + const char *s;
52551
52552 BUG_ON(nd->flags & LOOKUP_RCU);
52553
52554 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
52555 if (error)
52556 goto out_put_nd_path;
52557
52558 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
52559 + dentry->d_inode, dentry, nd->path.mnt)) {
52560 + error = -EACCES;
52561 + goto out_put_nd_path;
52562 + }
52563 +
52564 nd->last_type = LAST_BIND;
52565 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
52566 error = PTR_ERR(*p);
52567 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
52568 if (res)
52569 break;
52570 res = walk_component(nd, path, LOOKUP_FOLLOW);
52571 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
52572 + res = -EACCES;
52573 put_link(nd, &link, cookie);
52574 } while (res > 0);
52575
52576 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
52577 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
52578 {
52579 unsigned long a, b, adata, bdata, mask, hash, len;
52580 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
52581 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
52582
52583 hash = a = 0;
52584 len = -sizeof(unsigned long);
52585 @@ -1968,6 +1984,8 @@ static int path_lookupat(int dfd, const char *name,
52586 if (err)
52587 break;
52588 err = lookup_last(nd, &path);
52589 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
52590 + err = -EACCES;
52591 put_link(nd, &link, cookie);
52592 }
52593 }
52594 @@ -1975,6 +1993,13 @@ static int path_lookupat(int dfd, const char *name,
52595 if (!err)
52596 err = complete_walk(nd);
52597
52598 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
52599 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
52600 + path_put(&nd->path);
52601 + err = -ENOENT;
52602 + }
52603 + }
52604 +
52605 if (!err && nd->flags & LOOKUP_DIRECTORY) {
52606 if (!nd->inode->i_op->lookup) {
52607 path_put(&nd->path);
52608 @@ -2002,8 +2027,15 @@ static int filename_lookup(int dfd, struct filename *name,
52609 retval = path_lookupat(dfd, name->name,
52610 flags | LOOKUP_REVAL, nd);
52611
52612 - if (likely(!retval))
52613 + if (likely(!retval)) {
52614 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
52615 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
52616 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
52617 + path_put(&nd->path);
52618 + return -ENOENT;
52619 + }
52620 + }
52621 + }
52622 return retval;
52623 }
52624
52625 @@ -2381,6 +2413,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
52626 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
52627 return -EPERM;
52628
52629 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
52630 + return -EPERM;
52631 + if (gr_handle_rawio(inode))
52632 + return -EPERM;
52633 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
52634 + return -EACCES;
52635 +
52636 return 0;
52637 }
52638
52639 @@ -2602,7 +2641,7 @@ looked_up:
52640 * cleared otherwise prior to returning.
52641 */
52642 static int lookup_open(struct nameidata *nd, struct path *path,
52643 - struct file *file,
52644 + struct path *link, struct file *file,
52645 const struct open_flags *op,
52646 bool got_write, int *opened)
52647 {
52648 @@ -2637,6 +2676,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
52649 /* Negative dentry, just create the file */
52650 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
52651 umode_t mode = op->mode;
52652 +
52653 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
52654 + error = -EACCES;
52655 + goto out_dput;
52656 + }
52657 +
52658 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
52659 + error = -EACCES;
52660 + goto out_dput;
52661 + }
52662 +
52663 if (!IS_POSIXACL(dir->d_inode))
52664 mode &= ~current_umask();
52665 /*
52666 @@ -2658,6 +2708,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
52667 nd->flags & LOOKUP_EXCL);
52668 if (error)
52669 goto out_dput;
52670 + else
52671 + gr_handle_create(dentry, nd->path.mnt);
52672 }
52673 out_no_open:
52674 path->dentry = dentry;
52675 @@ -2672,7 +2724,7 @@ out_dput:
52676 /*
52677 * Handle the last step of open()
52678 */
52679 -static int do_last(struct nameidata *nd, struct path *path,
52680 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
52681 struct file *file, const struct open_flags *op,
52682 int *opened, struct filename *name)
52683 {
52684 @@ -2701,16 +2753,32 @@ static int do_last(struct nameidata *nd, struct path *path,
52685 error = complete_walk(nd);
52686 if (error)
52687 return error;
52688 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
52689 + error = -ENOENT;
52690 + goto out;
52691 + }
52692 audit_inode(name, nd->path.dentry, 0);
52693 if (open_flag & O_CREAT) {
52694 error = -EISDIR;
52695 goto out;
52696 }
52697 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
52698 + error = -EACCES;
52699 + goto out;
52700 + }
52701 goto finish_open;
52702 case LAST_BIND:
52703 error = complete_walk(nd);
52704 if (error)
52705 return error;
52706 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
52707 + error = -ENOENT;
52708 + goto out;
52709 + }
52710 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
52711 + error = -EACCES;
52712 + goto out;
52713 + }
52714 audit_inode(name, dir, 0);
52715 goto finish_open;
52716 }
52717 @@ -2759,7 +2827,7 @@ retry_lookup:
52718 */
52719 }
52720 mutex_lock(&dir->d_inode->i_mutex);
52721 - error = lookup_open(nd, path, file, op, got_write, opened);
52722 + error = lookup_open(nd, path, link, file, op, got_write, opened);
52723 mutex_unlock(&dir->d_inode->i_mutex);
52724
52725 if (error <= 0) {
52726 @@ -2783,11 +2851,28 @@ retry_lookup:
52727 goto finish_open_created;
52728 }
52729
52730 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
52731 + error = -ENOENT;
52732 + goto exit_dput;
52733 + }
52734 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
52735 + error = -EACCES;
52736 + goto exit_dput;
52737 + }
52738 +
52739 /*
52740 * create/update audit record if it already exists.
52741 */
52742 - if (path->dentry->d_inode)
52743 + if (path->dentry->d_inode) {
52744 + /* only check if O_CREAT is specified, all other checks need to go
52745 + into may_open */
52746 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
52747 + error = -EACCES;
52748 + goto exit_dput;
52749 + }
52750 +
52751 audit_inode(name, path->dentry, 0);
52752 + }
52753
52754 /*
52755 * If atomic_open() acquired write access it is dropped now due to
52756 @@ -2828,6 +2913,11 @@ finish_lookup:
52757 }
52758 }
52759 BUG_ON(inode != path->dentry->d_inode);
52760 + /* if we're resolving a symlink to another symlink */
52761 + if (link && gr_handle_symlink_owner(link, inode)) {
52762 + error = -EACCES;
52763 + goto out;
52764 + }
52765 return 1;
52766 }
52767
52768 @@ -2837,7 +2927,6 @@ finish_lookup:
52769 save_parent.dentry = nd->path.dentry;
52770 save_parent.mnt = mntget(path->mnt);
52771 nd->path.dentry = path->dentry;
52772 -
52773 }
52774 nd->inode = inode;
52775 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
52776 @@ -2846,6 +2935,16 @@ finish_lookup:
52777 path_put(&save_parent);
52778 return error;
52779 }
52780 +
52781 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
52782 + error = -ENOENT;
52783 + goto out;
52784 + }
52785 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
52786 + error = -EACCES;
52787 + goto out;
52788 + }
52789 +
52790 error = -EISDIR;
52791 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
52792 goto out;
52793 @@ -2944,7 +3043,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
52794 if (unlikely(error))
52795 goto out;
52796
52797 - error = do_last(nd, &path, file, op, &opened, pathname);
52798 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
52799 while (unlikely(error > 0)) { /* trailing symlink */
52800 struct path link = path;
52801 void *cookie;
52802 @@ -2962,7 +3061,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
52803 error = follow_link(&link, nd, &cookie);
52804 if (unlikely(error))
52805 break;
52806 - error = do_last(nd, &path, file, op, &opened, pathname);
52807 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
52808 put_link(nd, &link, cookie);
52809 }
52810 out:
52811 @@ -3062,8 +3161,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
52812 goto unlock;
52813
52814 error = -EEXIST;
52815 - if (dentry->d_inode)
52816 + if (dentry->d_inode) {
52817 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
52818 + error = -ENOENT;
52819 + }
52820 goto fail;
52821 + }
52822 /*
52823 * Special case - lookup gave negative, but... we had foo/bar/
52824 * From the vfs_mknod() POV we just have a negative dentry -
52825 @@ -3115,6 +3218,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
52826 }
52827 EXPORT_SYMBOL(user_path_create);
52828
52829 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
52830 +{
52831 + struct filename *tmp = getname(pathname);
52832 + struct dentry *res;
52833 + if (IS_ERR(tmp))
52834 + return ERR_CAST(tmp);
52835 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
52836 + if (IS_ERR(res))
52837 + putname(tmp);
52838 + else
52839 + *to = tmp;
52840 + return res;
52841 +}
52842 +
52843 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
52844 {
52845 int error = may_create(dir, dentry);
52846 @@ -3177,6 +3294,17 @@ retry:
52847
52848 if (!IS_POSIXACL(path.dentry->d_inode))
52849 mode &= ~current_umask();
52850 +
52851 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
52852 + error = -EPERM;
52853 + goto out;
52854 + }
52855 +
52856 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
52857 + error = -EACCES;
52858 + goto out;
52859 + }
52860 +
52861 error = security_path_mknod(&path, dentry, mode, dev);
52862 if (error)
52863 goto out;
52864 @@ -3193,6 +3321,8 @@ retry:
52865 break;
52866 }
52867 out:
52868 + if (!error)
52869 + gr_handle_create(dentry, path.mnt);
52870 done_path_create(&path, dentry);
52871 if (retry_estale(error, lookup_flags)) {
52872 lookup_flags |= LOOKUP_REVAL;
52873 @@ -3245,9 +3375,16 @@ retry:
52874
52875 if (!IS_POSIXACL(path.dentry->d_inode))
52876 mode &= ~current_umask();
52877 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
52878 + error = -EACCES;
52879 + goto out;
52880 + }
52881 error = security_path_mkdir(&path, dentry, mode);
52882 if (!error)
52883 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
52884 + if (!error)
52885 + gr_handle_create(dentry, path.mnt);
52886 +out:
52887 done_path_create(&path, dentry);
52888 if (retry_estale(error, lookup_flags)) {
52889 lookup_flags |= LOOKUP_REVAL;
52890 @@ -3328,6 +3465,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
52891 struct filename *name;
52892 struct dentry *dentry;
52893 struct nameidata nd;
52894 + ino_t saved_ino = 0;
52895 + dev_t saved_dev = 0;
52896 unsigned int lookup_flags = 0;
52897 retry:
52898 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
52899 @@ -3360,10 +3499,21 @@ retry:
52900 error = -ENOENT;
52901 goto exit3;
52902 }
52903 +
52904 + saved_ino = dentry->d_inode->i_ino;
52905 + saved_dev = gr_get_dev_from_dentry(dentry);
52906 +
52907 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
52908 + error = -EACCES;
52909 + goto exit3;
52910 + }
52911 +
52912 error = security_path_rmdir(&nd.path, dentry);
52913 if (error)
52914 goto exit3;
52915 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
52916 + if (!error && (saved_dev || saved_ino))
52917 + gr_handle_delete(saved_ino, saved_dev);
52918 exit3:
52919 dput(dentry);
52920 exit2:
52921 @@ -3429,6 +3579,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
52922 struct dentry *dentry;
52923 struct nameidata nd;
52924 struct inode *inode = NULL;
52925 + ino_t saved_ino = 0;
52926 + dev_t saved_dev = 0;
52927 unsigned int lookup_flags = 0;
52928 retry:
52929 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
52930 @@ -3455,10 +3607,22 @@ retry:
52931 if (!inode)
52932 goto slashes;
52933 ihold(inode);
52934 +
52935 + if (inode->i_nlink <= 1) {
52936 + saved_ino = inode->i_ino;
52937 + saved_dev = gr_get_dev_from_dentry(dentry);
52938 + }
52939 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
52940 + error = -EACCES;
52941 + goto exit2;
52942 + }
52943 +
52944 error = security_path_unlink(&nd.path, dentry);
52945 if (error)
52946 goto exit2;
52947 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
52948 + if (!error && (saved_ino || saved_dev))
52949 + gr_handle_delete(saved_ino, saved_dev);
52950 exit2:
52951 dput(dentry);
52952 }
52953 @@ -3536,9 +3700,17 @@ retry:
52954 if (IS_ERR(dentry))
52955 goto out_putname;
52956
52957 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
52958 + error = -EACCES;
52959 + goto out;
52960 + }
52961 +
52962 error = security_path_symlink(&path, dentry, from->name);
52963 if (!error)
52964 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
52965 + if (!error)
52966 + gr_handle_create(dentry, path.mnt);
52967 +out:
52968 done_path_create(&path, dentry);
52969 if (retry_estale(error, lookup_flags)) {
52970 lookup_flags |= LOOKUP_REVAL;
52971 @@ -3612,6 +3784,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
52972 {
52973 struct dentry *new_dentry;
52974 struct path old_path, new_path;
52975 + struct filename *to = NULL;
52976 int how = 0;
52977 int error;
52978
52979 @@ -3635,7 +3808,7 @@ retry:
52980 if (error)
52981 return error;
52982
52983 - new_dentry = user_path_create(newdfd, newname, &new_path,
52984 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
52985 (how & LOOKUP_REVAL));
52986 error = PTR_ERR(new_dentry);
52987 if (IS_ERR(new_dentry))
52988 @@ -3647,11 +3820,28 @@ retry:
52989 error = may_linkat(&old_path);
52990 if (unlikely(error))
52991 goto out_dput;
52992 +
52993 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
52994 + old_path.dentry->d_inode,
52995 + old_path.dentry->d_inode->i_mode, to)) {
52996 + error = -EACCES;
52997 + goto out_dput;
52998 + }
52999 +
53000 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
53001 + old_path.dentry, old_path.mnt, to)) {
53002 + error = -EACCES;
53003 + goto out_dput;
53004 + }
53005 +
53006 error = security_path_link(old_path.dentry, &new_path, new_dentry);
53007 if (error)
53008 goto out_dput;
53009 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
53010 + if (!error)
53011 + gr_handle_create(new_dentry, new_path.mnt);
53012 out_dput:
53013 + putname(to);
53014 done_path_create(&new_path, new_dentry);
53015 if (retry_estale(error, how)) {
53016 how |= LOOKUP_REVAL;
53017 @@ -3897,12 +4087,21 @@ retry:
53018 if (new_dentry == trap)
53019 goto exit5;
53020
53021 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
53022 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
53023 + to);
53024 + if (error)
53025 + goto exit5;
53026 +
53027 error = security_path_rename(&oldnd.path, old_dentry,
53028 &newnd.path, new_dentry);
53029 if (error)
53030 goto exit5;
53031 error = vfs_rename(old_dir->d_inode, old_dentry,
53032 new_dir->d_inode, new_dentry);
53033 + if (!error)
53034 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
53035 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
53036 exit5:
53037 dput(new_dentry);
53038 exit4:
53039 @@ -3934,6 +4133,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
53040
53041 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
53042 {
53043 + char tmpbuf[64];
53044 + const char *newlink;
53045 int len;
53046
53047 len = PTR_ERR(link);
53048 @@ -3943,7 +4144,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
53049 len = strlen(link);
53050 if (len > (unsigned) buflen)
53051 len = buflen;
53052 - if (copy_to_user(buffer, link, len))
53053 +
53054 + if (len < sizeof(tmpbuf)) {
53055 + memcpy(tmpbuf, link, len);
53056 + newlink = tmpbuf;
53057 + } else
53058 + newlink = link;
53059 +
53060 + if (copy_to_user(buffer, newlink, len))
53061 len = -EFAULT;
53062 out:
53063 return len;
53064 diff --git a/fs/namespace.c b/fs/namespace.c
53065 index e945b81..1dd8104 100644
53066 --- a/fs/namespace.c
53067 +++ b/fs/namespace.c
53068 @@ -1219,6 +1219,9 @@ static int do_umount(struct mount *mnt, int flags)
53069 if (!(sb->s_flags & MS_RDONLY))
53070 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
53071 up_write(&sb->s_umount);
53072 +
53073 + gr_log_remount(mnt->mnt_devname, retval);
53074 +
53075 return retval;
53076 }
53077
53078 @@ -1238,6 +1241,9 @@ static int do_umount(struct mount *mnt, int flags)
53079 br_write_unlock(&vfsmount_lock);
53080 up_write(&namespace_sem);
53081 release_mounts(&umount_list);
53082 +
53083 + gr_log_unmount(mnt->mnt_devname, retval);
53084 +
53085 return retval;
53086 }
53087
53088 @@ -2267,6 +2273,16 @@ long do_mount(const char *dev_name, const char *dir_name,
53089 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
53090 MS_STRICTATIME);
53091
53092 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
53093 + retval = -EPERM;
53094 + goto dput_out;
53095 + }
53096 +
53097 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
53098 + retval = -EPERM;
53099 + goto dput_out;
53100 + }
53101 +
53102 if (flags & MS_REMOUNT)
53103 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
53104 data_page);
53105 @@ -2281,6 +2297,9 @@ long do_mount(const char *dev_name, const char *dir_name,
53106 dev_name, data_page);
53107 dput_out:
53108 path_put(&path);
53109 +
53110 + gr_log_mount(dev_name, dir_name, retval);
53111 +
53112 return retval;
53113 }
53114
53115 @@ -2567,6 +2586,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
53116 if (error)
53117 goto out2;
53118
53119 + if (gr_handle_chroot_pivot()) {
53120 + error = -EPERM;
53121 + goto out2;
53122 + }
53123 +
53124 get_fs_root(current->fs, &root);
53125 error = lock_mount(&old);
53126 if (error)
53127 @@ -2815,7 +2839,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
53128 !nsown_capable(CAP_SYS_ADMIN))
53129 return -EPERM;
53130
53131 - if (fs->users != 1)
53132 + if (atomic_read(&fs->users) != 1)
53133 return -EINVAL;
53134
53135 get_mnt_ns(mnt_ns);
53136 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
53137 index 59461c9..b17c57e 100644
53138 --- a/fs/nfs/callback_xdr.c
53139 +++ b/fs/nfs/callback_xdr.c
53140 @@ -51,7 +51,7 @@ struct callback_op {
53141 callback_decode_arg_t decode_args;
53142 callback_encode_res_t encode_res;
53143 long res_maxsize;
53144 -};
53145 +} __do_const;
53146
53147 static struct callback_op callback_ops[];
53148
53149 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
53150 index 1f94167..79c4ce4 100644
53151 --- a/fs/nfs/inode.c
53152 +++ b/fs/nfs/inode.c
53153 @@ -1041,16 +1041,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
53154 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
53155 }
53156
53157 -static atomic_long_t nfs_attr_generation_counter;
53158 +static atomic_long_unchecked_t nfs_attr_generation_counter;
53159
53160 static unsigned long nfs_read_attr_generation_counter(void)
53161 {
53162 - return atomic_long_read(&nfs_attr_generation_counter);
53163 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
53164 }
53165
53166 unsigned long nfs_inc_attr_generation_counter(void)
53167 {
53168 - return atomic_long_inc_return(&nfs_attr_generation_counter);
53169 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
53170 }
53171
53172 void nfs_fattr_init(struct nfs_fattr *fattr)
53173 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
53174 index 8288b08..4a140d4 100644
53175 --- a/fs/nfsd/nfs4proc.c
53176 +++ b/fs/nfsd/nfs4proc.c
53177 @@ -1098,7 +1098,7 @@ struct nfsd4_operation {
53178 nfsd4op_rsize op_rsize_bop;
53179 stateid_getter op_get_currentstateid;
53180 stateid_setter op_set_currentstateid;
53181 -};
53182 +} __do_const;
53183
53184 static struct nfsd4_operation nfsd4_ops[];
53185
53186 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
53187 index 6eb0dc5..29067a9 100644
53188 --- a/fs/nfsd/nfs4xdr.c
53189 +++ b/fs/nfsd/nfs4xdr.c
53190 @@ -1457,7 +1457,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
53191
53192 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
53193
53194 -static nfsd4_dec nfsd4_dec_ops[] = {
53195 +static const nfsd4_dec nfsd4_dec_ops[] = {
53196 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
53197 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
53198 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
53199 @@ -1497,7 +1497,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
53200 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
53201 };
53202
53203 -static nfsd4_dec nfsd41_dec_ops[] = {
53204 +static const nfsd4_dec nfsd41_dec_ops[] = {
53205 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
53206 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
53207 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
53208 @@ -1559,7 +1559,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
53209 };
53210
53211 struct nfsd4_minorversion_ops {
53212 - nfsd4_dec *decoders;
53213 + const nfsd4_dec *decoders;
53214 int nops;
53215 };
53216
53217 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
53218 index ca05f6d..411a576 100644
53219 --- a/fs/nfsd/nfscache.c
53220 +++ b/fs/nfsd/nfscache.c
53221 @@ -461,13 +461,15 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
53222 {
53223 struct svc_cacherep *rp = rqstp->rq_cacherep;
53224 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
53225 - int len;
53226 + long len;
53227
53228 if (!rp)
53229 return;
53230
53231 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
53232 - len >>= 2;
53233 + if (statp) {
53234 + len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
53235 + len >>= 2;
53236 + }
53237
53238 /* Don't cache excessive amounts of data and XDR failures */
53239 if (!statp || len > (256 >> 2)) {
53240 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
53241 index 2b2e239..c915b48 100644
53242 --- a/fs/nfsd/vfs.c
53243 +++ b/fs/nfsd/vfs.c
53244 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
53245 } else {
53246 oldfs = get_fs();
53247 set_fs(KERNEL_DS);
53248 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
53249 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
53250 set_fs(oldfs);
53251 }
53252
53253 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
53254
53255 /* Write the data. */
53256 oldfs = get_fs(); set_fs(KERNEL_DS);
53257 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
53258 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
53259 set_fs(oldfs);
53260 if (host_err < 0)
53261 goto out_nfserr;
53262 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
53263 */
53264
53265 oldfs = get_fs(); set_fs(KERNEL_DS);
53266 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
53267 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
53268 set_fs(oldfs);
53269
53270 if (host_err < 0)
53271 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
53272 index fea6bd5..8ee9d81 100644
53273 --- a/fs/nls/nls_base.c
53274 +++ b/fs/nls/nls_base.c
53275 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
53276
53277 int register_nls(struct nls_table * nls)
53278 {
53279 - struct nls_table ** tmp = &tables;
53280 + struct nls_table *tmp = tables;
53281
53282 if (nls->next)
53283 return -EBUSY;
53284
53285 spin_lock(&nls_lock);
53286 - while (*tmp) {
53287 - if (nls == *tmp) {
53288 + while (tmp) {
53289 + if (nls == tmp) {
53290 spin_unlock(&nls_lock);
53291 return -EBUSY;
53292 }
53293 - tmp = &(*tmp)->next;
53294 + tmp = tmp->next;
53295 }
53296 - nls->next = tables;
53297 + pax_open_kernel();
53298 + *(struct nls_table **)&nls->next = tables;
53299 + pax_close_kernel();
53300 tables = nls;
53301 spin_unlock(&nls_lock);
53302 return 0;
53303 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
53304
53305 int unregister_nls(struct nls_table * nls)
53306 {
53307 - struct nls_table ** tmp = &tables;
53308 + struct nls_table * const * tmp = &tables;
53309
53310 spin_lock(&nls_lock);
53311 while (*tmp) {
53312 if (nls == *tmp) {
53313 - *tmp = nls->next;
53314 + pax_open_kernel();
53315 + *(struct nls_table **)tmp = nls->next;
53316 + pax_close_kernel();
53317 spin_unlock(&nls_lock);
53318 return 0;
53319 }
53320 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
53321 index 7424929..35f6be5 100644
53322 --- a/fs/nls/nls_euc-jp.c
53323 +++ b/fs/nls/nls_euc-jp.c
53324 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
53325 p_nls = load_nls("cp932");
53326
53327 if (p_nls) {
53328 - table.charset2upper = p_nls->charset2upper;
53329 - table.charset2lower = p_nls->charset2lower;
53330 + pax_open_kernel();
53331 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
53332 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
53333 + pax_close_kernel();
53334 return register_nls(&table);
53335 }
53336
53337 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
53338 index e7bc1d7..06bd4bb 100644
53339 --- a/fs/nls/nls_koi8-ru.c
53340 +++ b/fs/nls/nls_koi8-ru.c
53341 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
53342 p_nls = load_nls("koi8-u");
53343
53344 if (p_nls) {
53345 - table.charset2upper = p_nls->charset2upper;
53346 - table.charset2lower = p_nls->charset2lower;
53347 + pax_open_kernel();
53348 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
53349 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
53350 + pax_close_kernel();
53351 return register_nls(&table);
53352 }
53353
53354 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
53355 index 5d84442..bf24453 100644
53356 --- a/fs/notify/fanotify/fanotify_user.c
53357 +++ b/fs/notify/fanotify/fanotify_user.c
53358 @@ -251,8 +251,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
53359
53360 fd = fanotify_event_metadata.fd;
53361 ret = -EFAULT;
53362 - if (copy_to_user(buf, &fanotify_event_metadata,
53363 - fanotify_event_metadata.event_len))
53364 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
53365 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
53366 goto out_close_fd;
53367
53368 ret = prepare_for_access_response(group, event, fd);
53369 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
53370 index 7b51b05..5ea5ef6 100644
53371 --- a/fs/notify/notification.c
53372 +++ b/fs/notify/notification.c
53373 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
53374 * get set to 0 so it will never get 'freed'
53375 */
53376 static struct fsnotify_event *q_overflow_event;
53377 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53378 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53379
53380 /**
53381 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
53382 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
53383 */
53384 u32 fsnotify_get_cookie(void)
53385 {
53386 - return atomic_inc_return(&fsnotify_sync_cookie);
53387 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
53388 }
53389 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
53390
53391 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
53392 index aa411c3..c260a84 100644
53393 --- a/fs/ntfs/dir.c
53394 +++ b/fs/ntfs/dir.c
53395 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
53396 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
53397 ~(s64)(ndir->itype.index.block_size - 1)));
53398 /* Bounds checks. */
53399 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
53400 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
53401 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
53402 "inode 0x%lx or driver bug.", vdir->i_ino);
53403 goto err_out;
53404 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
53405 index 5b2d4f0..c6de396 100644
53406 --- a/fs/ntfs/file.c
53407 +++ b/fs/ntfs/file.c
53408 @@ -2242,6 +2242,6 @@ const struct inode_operations ntfs_file_inode_ops = {
53409 #endif /* NTFS_RW */
53410 };
53411
53412 -const struct file_operations ntfs_empty_file_ops = {};
53413 +const struct file_operations ntfs_empty_file_ops __read_only;
53414
53415 -const struct inode_operations ntfs_empty_inode_ops = {};
53416 +const struct inode_operations ntfs_empty_inode_ops __read_only;
53417 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
53418 index aebeacd..0dcdd26 100644
53419 --- a/fs/ocfs2/localalloc.c
53420 +++ b/fs/ocfs2/localalloc.c
53421 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
53422 goto bail;
53423 }
53424
53425 - atomic_inc(&osb->alloc_stats.moves);
53426 + atomic_inc_unchecked(&osb->alloc_stats.moves);
53427
53428 bail:
53429 if (handle)
53430 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
53431 index d355e6e..578d905 100644
53432 --- a/fs/ocfs2/ocfs2.h
53433 +++ b/fs/ocfs2/ocfs2.h
53434 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
53435
53436 struct ocfs2_alloc_stats
53437 {
53438 - atomic_t moves;
53439 - atomic_t local_data;
53440 - atomic_t bitmap_data;
53441 - atomic_t bg_allocs;
53442 - atomic_t bg_extends;
53443 + atomic_unchecked_t moves;
53444 + atomic_unchecked_t local_data;
53445 + atomic_unchecked_t bitmap_data;
53446 + atomic_unchecked_t bg_allocs;
53447 + atomic_unchecked_t bg_extends;
53448 };
53449
53450 enum ocfs2_local_alloc_state
53451 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
53452 index b7e74b5..19c6536 100644
53453 --- a/fs/ocfs2/suballoc.c
53454 +++ b/fs/ocfs2/suballoc.c
53455 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
53456 mlog_errno(status);
53457 goto bail;
53458 }
53459 - atomic_inc(&osb->alloc_stats.bg_extends);
53460 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
53461
53462 /* You should never ask for this much metadata */
53463 BUG_ON(bits_wanted >
53464 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
53465 mlog_errno(status);
53466 goto bail;
53467 }
53468 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53469 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53470
53471 *suballoc_loc = res.sr_bg_blkno;
53472 *suballoc_bit_start = res.sr_bit_offset;
53473 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
53474 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
53475 res->sr_bits);
53476
53477 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53478 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53479
53480 BUG_ON(res->sr_bits != 1);
53481
53482 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
53483 mlog_errno(status);
53484 goto bail;
53485 }
53486 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53487 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
53488
53489 BUG_ON(res.sr_bits != 1);
53490
53491 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
53492 cluster_start,
53493 num_clusters);
53494 if (!status)
53495 - atomic_inc(&osb->alloc_stats.local_data);
53496 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
53497 } else {
53498 if (min_clusters > (osb->bitmap_cpg - 1)) {
53499 /* The only paths asking for contiguousness
53500 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
53501 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
53502 res.sr_bg_blkno,
53503 res.sr_bit_offset);
53504 - atomic_inc(&osb->alloc_stats.bitmap_data);
53505 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
53506 *num_clusters = res.sr_bits;
53507 }
53508 }
53509 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
53510 index 01b8516..579c4df 100644
53511 --- a/fs/ocfs2/super.c
53512 +++ b/fs/ocfs2/super.c
53513 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
53514 "%10s => GlobalAllocs: %d LocalAllocs: %d "
53515 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
53516 "Stats",
53517 - atomic_read(&osb->alloc_stats.bitmap_data),
53518 - atomic_read(&osb->alloc_stats.local_data),
53519 - atomic_read(&osb->alloc_stats.bg_allocs),
53520 - atomic_read(&osb->alloc_stats.moves),
53521 - atomic_read(&osb->alloc_stats.bg_extends));
53522 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
53523 + atomic_read_unchecked(&osb->alloc_stats.local_data),
53524 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
53525 + atomic_read_unchecked(&osb->alloc_stats.moves),
53526 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
53527
53528 out += snprintf(buf + out, len - out,
53529 "%10s => State: %u Descriptor: %llu Size: %u bits "
53530 @@ -2122,11 +2122,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
53531 spin_lock_init(&osb->osb_xattr_lock);
53532 ocfs2_init_steal_slots(osb);
53533
53534 - atomic_set(&osb->alloc_stats.moves, 0);
53535 - atomic_set(&osb->alloc_stats.local_data, 0);
53536 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
53537 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
53538 - atomic_set(&osb->alloc_stats.bg_extends, 0);
53539 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
53540 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
53541 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
53542 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
53543 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
53544
53545 /* Copy the blockcheck stats from the superblock probe */
53546 osb->osb_ecc_stats = *stats;
53547 diff --git a/fs/open.c b/fs/open.c
53548 index 6835446..eadf09f 100644
53549 --- a/fs/open.c
53550 +++ b/fs/open.c
53551 @@ -32,6 +32,8 @@
53552 #include <linux/dnotify.h>
53553 #include <linux/compat.h>
53554
53555 +#define CREATE_TRACE_POINTS
53556 +#include <trace/events/fs.h>
53557 #include "internal.h"
53558
53559 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
53560 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
53561 error = locks_verify_truncate(inode, NULL, length);
53562 if (!error)
53563 error = security_path_truncate(path);
53564 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
53565 + error = -EACCES;
53566 if (!error)
53567 error = do_truncate(path->dentry, length, 0, NULL);
53568
53569 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
53570 error = locks_verify_truncate(inode, f.file, length);
53571 if (!error)
53572 error = security_path_truncate(&f.file->f_path);
53573 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
53574 + error = -EACCES;
53575 if (!error)
53576 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
53577 sb_end_write(inode->i_sb);
53578 @@ -388,6 +394,9 @@ retry:
53579 if (__mnt_is_readonly(path.mnt))
53580 res = -EROFS;
53581
53582 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
53583 + res = -EACCES;
53584 +
53585 out_path_release:
53586 path_put(&path);
53587 if (retry_estale(res, lookup_flags)) {
53588 @@ -419,6 +428,8 @@ retry:
53589 if (error)
53590 goto dput_and_out;
53591
53592 + gr_log_chdir(path.dentry, path.mnt);
53593 +
53594 set_fs_pwd(current->fs, &path);
53595
53596 dput_and_out:
53597 @@ -448,6 +459,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
53598 goto out_putf;
53599
53600 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
53601 +
53602 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
53603 + error = -EPERM;
53604 +
53605 + if (!error)
53606 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
53607 +
53608 if (!error)
53609 set_fs_pwd(current->fs, &f.file->f_path);
53610 out_putf:
53611 @@ -477,7 +495,13 @@ retry:
53612 if (error)
53613 goto dput_and_out;
53614
53615 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
53616 + goto dput_and_out;
53617 +
53618 set_fs_root(current->fs, &path);
53619 +
53620 + gr_handle_chroot_chdir(&path);
53621 +
53622 error = 0;
53623 dput_and_out:
53624 path_put(&path);
53625 @@ -499,6 +523,16 @@ static int chmod_common(struct path *path, umode_t mode)
53626 if (error)
53627 return error;
53628 mutex_lock(&inode->i_mutex);
53629 +
53630 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
53631 + error = -EACCES;
53632 + goto out_unlock;
53633 + }
53634 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
53635 + error = -EACCES;
53636 + goto out_unlock;
53637 + }
53638 +
53639 error = security_path_chmod(path, mode);
53640 if (error)
53641 goto out_unlock;
53642 @@ -559,6 +593,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
53643 uid = make_kuid(current_user_ns(), user);
53644 gid = make_kgid(current_user_ns(), group);
53645
53646 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
53647 + return -EACCES;
53648 +
53649 newattrs.ia_valid = ATTR_CTIME;
53650 if (user != (uid_t) -1) {
53651 if (!uid_valid(uid))
53652 @@ -974,6 +1011,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
53653 } else {
53654 fsnotify_open(f);
53655 fd_install(fd, f);
53656 + trace_do_sys_open(tmp->name, flags, mode);
53657 }
53658 }
53659 putname(tmp);
53660 diff --git a/fs/pipe.c b/fs/pipe.c
53661 index 2234f3f..f9083a1 100644
53662 --- a/fs/pipe.c
53663 +++ b/fs/pipe.c
53664 @@ -438,9 +438,9 @@ redo:
53665 }
53666 if (bufs) /* More to do? */
53667 continue;
53668 - if (!pipe->writers)
53669 + if (!atomic_read(&pipe->writers))
53670 break;
53671 - if (!pipe->waiting_writers) {
53672 + if (!atomic_read(&pipe->waiting_writers)) {
53673 /* syscall merging: Usually we must not sleep
53674 * if O_NONBLOCK is set, or if we got some data.
53675 * But if a writer sleeps in kernel space, then
53676 @@ -504,7 +504,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
53677 mutex_lock(&inode->i_mutex);
53678 pipe = inode->i_pipe;
53679
53680 - if (!pipe->readers) {
53681 + if (!atomic_read(&pipe->readers)) {
53682 send_sig(SIGPIPE, current, 0);
53683 ret = -EPIPE;
53684 goto out;
53685 @@ -553,7 +553,7 @@ redo1:
53686 for (;;) {
53687 int bufs;
53688
53689 - if (!pipe->readers) {
53690 + if (!atomic_read(&pipe->readers)) {
53691 send_sig(SIGPIPE, current, 0);
53692 if (!ret)
53693 ret = -EPIPE;
53694 @@ -644,9 +644,9 @@ redo2:
53695 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
53696 do_wakeup = 0;
53697 }
53698 - pipe->waiting_writers++;
53699 + atomic_inc(&pipe->waiting_writers);
53700 pipe_wait(pipe);
53701 - pipe->waiting_writers--;
53702 + atomic_dec(&pipe->waiting_writers);
53703 }
53704 out:
53705 mutex_unlock(&inode->i_mutex);
53706 @@ -716,7 +716,7 @@ pipe_poll(struct file *filp, poll_table *wait)
53707 mask = 0;
53708 if (filp->f_mode & FMODE_READ) {
53709 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
53710 - if (!pipe->writers && filp->f_version != pipe->w_counter)
53711 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
53712 mask |= POLLHUP;
53713 }
53714
53715 @@ -726,7 +726,7 @@ pipe_poll(struct file *filp, poll_table *wait)
53716 * Most Unices do not set POLLERR for FIFOs but on Linux they
53717 * behave exactly like pipes for poll().
53718 */
53719 - if (!pipe->readers)
53720 + if (!atomic_read(&pipe->readers))
53721 mask |= POLLERR;
53722 }
53723
53724 @@ -740,10 +740,10 @@ pipe_release(struct inode *inode, int decr, int decw)
53725
53726 mutex_lock(&inode->i_mutex);
53727 pipe = inode->i_pipe;
53728 - pipe->readers -= decr;
53729 - pipe->writers -= decw;
53730 + atomic_sub(decr, &pipe->readers);
53731 + atomic_sub(decw, &pipe->writers);
53732
53733 - if (!pipe->readers && !pipe->writers) {
53734 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
53735 free_pipe_info(inode);
53736 } else {
53737 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
53738 @@ -833,7 +833,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
53739
53740 if (inode->i_pipe) {
53741 ret = 0;
53742 - inode->i_pipe->readers++;
53743 + atomic_inc(&inode->i_pipe->readers);
53744 }
53745
53746 mutex_unlock(&inode->i_mutex);
53747 @@ -850,7 +850,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
53748
53749 if (inode->i_pipe) {
53750 ret = 0;
53751 - inode->i_pipe->writers++;
53752 + atomic_inc(&inode->i_pipe->writers);
53753 }
53754
53755 mutex_unlock(&inode->i_mutex);
53756 @@ -871,9 +871,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
53757 if (inode->i_pipe) {
53758 ret = 0;
53759 if (filp->f_mode & FMODE_READ)
53760 - inode->i_pipe->readers++;
53761 + atomic_inc(&inode->i_pipe->readers);
53762 if (filp->f_mode & FMODE_WRITE)
53763 - inode->i_pipe->writers++;
53764 + atomic_inc(&inode->i_pipe->writers);
53765 }
53766
53767 mutex_unlock(&inode->i_mutex);
53768 @@ -965,7 +965,7 @@ void free_pipe_info(struct inode *inode)
53769 inode->i_pipe = NULL;
53770 }
53771
53772 -static struct vfsmount *pipe_mnt __read_mostly;
53773 +struct vfsmount *pipe_mnt __read_mostly;
53774
53775 /*
53776 * pipefs_dname() is called from d_path().
53777 @@ -995,7 +995,8 @@ static struct inode * get_pipe_inode(void)
53778 goto fail_iput;
53779 inode->i_pipe = pipe;
53780
53781 - pipe->readers = pipe->writers = 1;
53782 + atomic_set(&pipe->readers, 1);
53783 + atomic_set(&pipe->writers, 1);
53784 inode->i_fop = &rdwr_pipefifo_fops;
53785
53786 /*
53787 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
53788 index 15af622..0e9f4467 100644
53789 --- a/fs/proc/Kconfig
53790 +++ b/fs/proc/Kconfig
53791 @@ -30,12 +30,12 @@ config PROC_FS
53792
53793 config PROC_KCORE
53794 bool "/proc/kcore support" if !ARM
53795 - depends on PROC_FS && MMU
53796 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
53797
53798 config PROC_VMCORE
53799 bool "/proc/vmcore support"
53800 - depends on PROC_FS && CRASH_DUMP
53801 - default y
53802 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
53803 + default n
53804 help
53805 Exports the dump image of crashed kernel in ELF format.
53806
53807 @@ -59,8 +59,8 @@ config PROC_SYSCTL
53808 limited in memory.
53809
53810 config PROC_PAGE_MONITOR
53811 - default y
53812 - depends on PROC_FS && MMU
53813 + default n
53814 + depends on PROC_FS && MMU && !GRKERNSEC
53815 bool "Enable /proc page monitoring" if EXPERT
53816 help
53817 Various /proc files exist to monitor process memory utilization:
53818 diff --git a/fs/proc/array.c b/fs/proc/array.c
53819 index cbd0f1b..adec3f0 100644
53820 --- a/fs/proc/array.c
53821 +++ b/fs/proc/array.c
53822 @@ -60,6 +60,7 @@
53823 #include <linux/tty.h>
53824 #include <linux/string.h>
53825 #include <linux/mman.h>
53826 +#include <linux/grsecurity.h>
53827 #include <linux/proc_fs.h>
53828 #include <linux/ioport.h>
53829 #include <linux/uaccess.h>
53830 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
53831 seq_putc(m, '\n');
53832 }
53833
53834 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53835 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
53836 +{
53837 + if (p->mm)
53838 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
53839 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
53840 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
53841 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
53842 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
53843 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
53844 + else
53845 + seq_printf(m, "PaX:\t-----\n");
53846 +}
53847 +#endif
53848 +
53849 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
53850 struct pid *pid, struct task_struct *task)
53851 {
53852 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
53853 task_cpus_allowed(m, task);
53854 cpuset_task_status_allowed(m, task);
53855 task_context_switch_counts(m, task);
53856 +
53857 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53858 + task_pax(m, task);
53859 +#endif
53860 +
53861 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
53862 + task_grsec_rbac(m, task);
53863 +#endif
53864 +
53865 return 0;
53866 }
53867
53868 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
53869 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
53870 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
53871 + _mm->pax_flags & MF_PAX_SEGMEXEC))
53872 +#endif
53873 +
53874 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
53875 struct pid *pid, struct task_struct *task, int whole)
53876 {
53877 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
53878 char tcomm[sizeof(task->comm)];
53879 unsigned long flags;
53880
53881 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
53882 + if (current->exec_id != m->exec_id) {
53883 + gr_log_badprocpid("stat");
53884 + return 0;
53885 + }
53886 +#endif
53887 +
53888 state = *get_task_state(task);
53889 vsize = eip = esp = 0;
53890 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
53891 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
53892 gtime = task_gtime(task);
53893 }
53894
53895 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
53896 + if (PAX_RAND_FLAGS(mm)) {
53897 + eip = 0;
53898 + esp = 0;
53899 + wchan = 0;
53900 + }
53901 +#endif
53902 +#ifdef CONFIG_GRKERNSEC_HIDESYM
53903 + wchan = 0;
53904 + eip =0;
53905 + esp =0;
53906 +#endif
53907 +
53908 /* scale priority and nice values from timeslices to -20..20 */
53909 /* to make it look like a "normal" Unix priority/nice value */
53910 priority = task_prio(task);
53911 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
53912 seq_put_decimal_ull(m, ' ', vsize);
53913 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
53914 seq_put_decimal_ull(m, ' ', rsslim);
53915 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
53916 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
53917 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
53918 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
53919 +#else
53920 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
53921 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
53922 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
53923 +#endif
53924 seq_put_decimal_ull(m, ' ', esp);
53925 seq_put_decimal_ull(m, ' ', eip);
53926 /* The signal information here is obsolete.
53927 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
53928 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
53929 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
53930
53931 - if (mm && permitted) {
53932 + if (mm && permitted
53933 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
53934 + && !PAX_RAND_FLAGS(mm)
53935 +#endif
53936 + ) {
53937 seq_put_decimal_ull(m, ' ', mm->start_data);
53938 seq_put_decimal_ull(m, ' ', mm->end_data);
53939 seq_put_decimal_ull(m, ' ', mm->start_brk);
53940 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
53941 struct pid *pid, struct task_struct *task)
53942 {
53943 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
53944 - struct mm_struct *mm = get_task_mm(task);
53945 + struct mm_struct *mm;
53946
53947 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
53948 + if (current->exec_id != m->exec_id) {
53949 + gr_log_badprocpid("statm");
53950 + return 0;
53951 + }
53952 +#endif
53953 + mm = get_task_mm(task);
53954 if (mm) {
53955 size = task_statm(mm, &shared, &text, &data, &resident);
53956 mmput(mm);
53957 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
53958 return 0;
53959 }
53960
53961 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
53962 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
53963 +{
53964 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
53965 +}
53966 +#endif
53967 +
53968 #ifdef CONFIG_CHECKPOINT_RESTORE
53969 static struct pid *
53970 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
53971 diff --git a/fs/proc/base.c b/fs/proc/base.c
53972 index 69078c7..3e12a75 100644
53973 --- a/fs/proc/base.c
53974 +++ b/fs/proc/base.c
53975 @@ -112,6 +112,14 @@ struct pid_entry {
53976 union proc_op op;
53977 };
53978
53979 +struct getdents_callback {
53980 + struct linux_dirent __user * current_dir;
53981 + struct linux_dirent __user * previous;
53982 + struct file * file;
53983 + int count;
53984 + int error;
53985 +};
53986 +
53987 #define NOD(NAME, MODE, IOP, FOP, OP) { \
53988 .name = (NAME), \
53989 .len = sizeof(NAME) - 1, \
53990 @@ -209,6 +217,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
53991 if (!mm->arg_end)
53992 goto out_mm; /* Shh! No looking before we're done */
53993
53994 + if (gr_acl_handle_procpidmem(task))
53995 + goto out_mm;
53996 +
53997 len = mm->arg_end - mm->arg_start;
53998
53999 if (len > PAGE_SIZE)
54000 @@ -236,12 +247,28 @@ out:
54001 return res;
54002 }
54003
54004 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54005 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54006 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54007 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54008 +#endif
54009 +
54010 static int proc_pid_auxv(struct task_struct *task, char *buffer)
54011 {
54012 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
54013 int res = PTR_ERR(mm);
54014 if (mm && !IS_ERR(mm)) {
54015 unsigned int nwords = 0;
54016 +
54017 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54018 + /* allow if we're currently ptracing this task */
54019 + if (PAX_RAND_FLAGS(mm) &&
54020 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
54021 + mmput(mm);
54022 + return 0;
54023 + }
54024 +#endif
54025 +
54026 do {
54027 nwords += 2;
54028 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
54029 @@ -255,7 +282,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
54030 }
54031
54032
54033 -#ifdef CONFIG_KALLSYMS
54034 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54035 /*
54036 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
54037 * Returns the resolved symbol. If that fails, simply return the address.
54038 @@ -294,7 +321,7 @@ static void unlock_trace(struct task_struct *task)
54039 mutex_unlock(&task->signal->cred_guard_mutex);
54040 }
54041
54042 -#ifdef CONFIG_STACKTRACE
54043 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54044
54045 #define MAX_STACK_TRACE_DEPTH 64
54046
54047 @@ -486,7 +513,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
54048 return count;
54049 }
54050
54051 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54052 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54053 static int proc_pid_syscall(struct task_struct *task, char *buffer)
54054 {
54055 long nr;
54056 @@ -515,7 +542,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
54057 /************************************************************************/
54058
54059 /* permission checks */
54060 -static int proc_fd_access_allowed(struct inode *inode)
54061 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
54062 {
54063 struct task_struct *task;
54064 int allowed = 0;
54065 @@ -525,7 +552,10 @@ static int proc_fd_access_allowed(struct inode *inode)
54066 */
54067 task = get_proc_task(inode);
54068 if (task) {
54069 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
54070 + if (log)
54071 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
54072 + else
54073 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54074 put_task_struct(task);
54075 }
54076 return allowed;
54077 @@ -556,10 +586,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
54078 struct task_struct *task,
54079 int hide_pid_min)
54080 {
54081 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54082 + return false;
54083 +
54084 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54085 + rcu_read_lock();
54086 + {
54087 + const struct cred *tmpcred = current_cred();
54088 + const struct cred *cred = __task_cred(task);
54089 +
54090 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
54091 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54092 + || in_group_p(grsec_proc_gid)
54093 +#endif
54094 + ) {
54095 + rcu_read_unlock();
54096 + return true;
54097 + }
54098 + }
54099 + rcu_read_unlock();
54100 +
54101 + if (!pid->hide_pid)
54102 + return false;
54103 +#endif
54104 +
54105 if (pid->hide_pid < hide_pid_min)
54106 return true;
54107 if (in_group_p(pid->pid_gid))
54108 return true;
54109 +
54110 return ptrace_may_access(task, PTRACE_MODE_READ);
54111 }
54112
54113 @@ -577,7 +632,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
54114 put_task_struct(task);
54115
54116 if (!has_perms) {
54117 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54118 + {
54119 +#else
54120 if (pid->hide_pid == 2) {
54121 +#endif
54122 /*
54123 * Let's make getdents(), stat(), and open()
54124 * consistent with each other. If a process
54125 @@ -675,6 +734,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
54126 if (!task)
54127 return -ESRCH;
54128
54129 + if (gr_acl_handle_procpidmem(task)) {
54130 + put_task_struct(task);
54131 + return -EPERM;
54132 + }
54133 +
54134 mm = mm_access(task, mode);
54135 put_task_struct(task);
54136
54137 @@ -690,6 +754,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
54138
54139 file->private_data = mm;
54140
54141 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54142 + file->f_version = current->exec_id;
54143 +#endif
54144 +
54145 return 0;
54146 }
54147
54148 @@ -711,6 +779,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
54149 ssize_t copied;
54150 char *page;
54151
54152 +#ifdef CONFIG_GRKERNSEC
54153 + if (write)
54154 + return -EPERM;
54155 +#endif
54156 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54157 + if (file->f_version != current->exec_id) {
54158 + gr_log_badprocpid("mem");
54159 + return 0;
54160 + }
54161 +#endif
54162 +
54163 if (!mm)
54164 return 0;
54165
54166 @@ -723,7 +802,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
54167 goto free;
54168
54169 while (count > 0) {
54170 - int this_len = min_t(int, count, PAGE_SIZE);
54171 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
54172
54173 if (write && copy_from_user(page, buf, this_len)) {
54174 copied = -EFAULT;
54175 @@ -815,6 +894,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
54176 if (!mm)
54177 return 0;
54178
54179 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54180 + if (file->f_version != current->exec_id) {
54181 + gr_log_badprocpid("environ");
54182 + return 0;
54183 + }
54184 +#endif
54185 +
54186 page = (char *)__get_free_page(GFP_TEMPORARY);
54187 if (!page)
54188 return -ENOMEM;
54189 @@ -824,7 +910,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
54190 goto free;
54191 while (count > 0) {
54192 size_t this_len, max_len;
54193 - int retval;
54194 + ssize_t retval;
54195
54196 if (src >= (mm->env_end - mm->env_start))
54197 break;
54198 @@ -1430,7 +1516,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
54199 int error = -EACCES;
54200
54201 /* Are we allowed to snoop on the tasks file descriptors? */
54202 - if (!proc_fd_access_allowed(inode))
54203 + if (!proc_fd_access_allowed(inode, 0))
54204 goto out;
54205
54206 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
54207 @@ -1474,8 +1560,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
54208 struct path path;
54209
54210 /* Are we allowed to snoop on the tasks file descriptors? */
54211 - if (!proc_fd_access_allowed(inode))
54212 - goto out;
54213 + /* logging this is needed for learning on chromium to work properly,
54214 + but we don't want to flood the logs from 'ps' which does a readlink
54215 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
54216 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
54217 + */
54218 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
54219 + if (!proc_fd_access_allowed(inode,0))
54220 + goto out;
54221 + } else {
54222 + if (!proc_fd_access_allowed(inode,1))
54223 + goto out;
54224 + }
54225
54226 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
54227 if (error)
54228 @@ -1525,7 +1621,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
54229 rcu_read_lock();
54230 cred = __task_cred(task);
54231 inode->i_uid = cred->euid;
54232 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54233 + inode->i_gid = grsec_proc_gid;
54234 +#else
54235 inode->i_gid = cred->egid;
54236 +#endif
54237 rcu_read_unlock();
54238 }
54239 security_task_to_inode(task, inode);
54240 @@ -1561,10 +1661,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
54241 return -ENOENT;
54242 }
54243 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
54244 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54245 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
54246 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54247 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
54248 +#endif
54249 task_dumpable(task)) {
54250 cred = __task_cred(task);
54251 stat->uid = cred->euid;
54252 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54253 + stat->gid = grsec_proc_gid;
54254 +#else
54255 stat->gid = cred->egid;
54256 +#endif
54257 }
54258 }
54259 rcu_read_unlock();
54260 @@ -1602,11 +1711,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
54261
54262 if (task) {
54263 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
54264 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54265 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
54266 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54267 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
54268 +#endif
54269 task_dumpable(task)) {
54270 rcu_read_lock();
54271 cred = __task_cred(task);
54272 inode->i_uid = cred->euid;
54273 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54274 + inode->i_gid = grsec_proc_gid;
54275 +#else
54276 inode->i_gid = cred->egid;
54277 +#endif
54278 rcu_read_unlock();
54279 } else {
54280 inode->i_uid = GLOBAL_ROOT_UID;
54281 @@ -2059,6 +2177,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
54282 if (!task)
54283 goto out_no_task;
54284
54285 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54286 + goto out;
54287 +
54288 /*
54289 * Yes, it does not scale. And it should not. Don't add
54290 * new entries into /proc/<tgid>/ without very good reasons.
54291 @@ -2103,6 +2224,9 @@ static int proc_pident_readdir(struct file *filp,
54292 if (!task)
54293 goto out_no_task;
54294
54295 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54296 + goto out;
54297 +
54298 ret = 0;
54299 i = filp->f_pos;
54300 switch (i) {
54301 @@ -2516,7 +2640,7 @@ static const struct pid_entry tgid_base_stuff[] = {
54302 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
54303 #endif
54304 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
54305 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54306 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54307 INF("syscall", S_IRUGO, proc_pid_syscall),
54308 #endif
54309 INF("cmdline", S_IRUGO, proc_pid_cmdline),
54310 @@ -2541,10 +2665,10 @@ static const struct pid_entry tgid_base_stuff[] = {
54311 #ifdef CONFIG_SECURITY
54312 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
54313 #endif
54314 -#ifdef CONFIG_KALLSYMS
54315 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54316 INF("wchan", S_IRUGO, proc_pid_wchan),
54317 #endif
54318 -#ifdef CONFIG_STACKTRACE
54319 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54320 ONE("stack", S_IRUGO, proc_pid_stack),
54321 #endif
54322 #ifdef CONFIG_SCHEDSTATS
54323 @@ -2578,6 +2702,9 @@ static const struct pid_entry tgid_base_stuff[] = {
54324 #ifdef CONFIG_HARDWALL
54325 INF("hardwall", S_IRUGO, proc_pid_hardwall),
54326 #endif
54327 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54328 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
54329 +#endif
54330 #ifdef CONFIG_USER_NS
54331 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
54332 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
54333 @@ -2707,7 +2834,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
54334 if (!inode)
54335 goto out;
54336
54337 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54338 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
54339 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54340 + inode->i_gid = grsec_proc_gid;
54341 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
54342 +#else
54343 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
54344 +#endif
54345 inode->i_op = &proc_tgid_base_inode_operations;
54346 inode->i_fop = &proc_tgid_base_operations;
54347 inode->i_flags|=S_IMMUTABLE;
54348 @@ -2745,7 +2879,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
54349 if (!task)
54350 goto out;
54351
54352 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54353 + goto out_put_task;
54354 +
54355 result = proc_pid_instantiate(dir, dentry, task, NULL);
54356 +out_put_task:
54357 put_task_struct(task);
54358 out:
54359 return result;
54360 @@ -2808,6 +2946,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
54361 static int fake_filldir(void *buf, const char *name, int namelen,
54362 loff_t offset, u64 ino, unsigned d_type)
54363 {
54364 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
54365 + __buf->error = -EINVAL;
54366 return 0;
54367 }
54368
54369 @@ -2859,7 +2999,7 @@ static const struct pid_entry tid_base_stuff[] = {
54370 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
54371 #endif
54372 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
54373 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54374 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54375 INF("syscall", S_IRUGO, proc_pid_syscall),
54376 #endif
54377 INF("cmdline", S_IRUGO, proc_pid_cmdline),
54378 @@ -2886,10 +3026,10 @@ static const struct pid_entry tid_base_stuff[] = {
54379 #ifdef CONFIG_SECURITY
54380 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
54381 #endif
54382 -#ifdef CONFIG_KALLSYMS
54383 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54384 INF("wchan", S_IRUGO, proc_pid_wchan),
54385 #endif
54386 -#ifdef CONFIG_STACKTRACE
54387 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54388 ONE("stack", S_IRUGO, proc_pid_stack),
54389 #endif
54390 #ifdef CONFIG_SCHEDSTATS
54391 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
54392 index 82676e3..5f8518a 100644
54393 --- a/fs/proc/cmdline.c
54394 +++ b/fs/proc/cmdline.c
54395 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
54396
54397 static int __init proc_cmdline_init(void)
54398 {
54399 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
54400 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
54401 +#else
54402 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
54403 +#endif
54404 return 0;
54405 }
54406 module_init(proc_cmdline_init);
54407 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
54408 index b143471..bb105e5 100644
54409 --- a/fs/proc/devices.c
54410 +++ b/fs/proc/devices.c
54411 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
54412
54413 static int __init proc_devices_init(void)
54414 {
54415 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
54416 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
54417 +#else
54418 proc_create("devices", 0, NULL, &proc_devinfo_operations);
54419 +#endif
54420 return 0;
54421 }
54422 module_init(proc_devices_init);
54423 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
54424 index d7a4a28..0201742 100644
54425 --- a/fs/proc/fd.c
54426 +++ b/fs/proc/fd.c
54427 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
54428 if (!task)
54429 return -ENOENT;
54430
54431 - files = get_files_struct(task);
54432 + if (!gr_acl_handle_procpidmem(task))
54433 + files = get_files_struct(task);
54434 put_task_struct(task);
54435
54436 if (files) {
54437 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
54438 */
54439 int proc_fd_permission(struct inode *inode, int mask)
54440 {
54441 + struct task_struct *task;
54442 int rv = generic_permission(inode, mask);
54443 - if (rv == 0)
54444 - return 0;
54445 +
54446 if (task_pid(current) == proc_pid(inode))
54447 rv = 0;
54448 +
54449 + task = get_proc_task(inode);
54450 + if (task == NULL)
54451 + return rv;
54452 +
54453 + if (gr_acl_handle_procpidmem(task))
54454 + rv = -EACCES;
54455 +
54456 + put_task_struct(task);
54457 +
54458 return rv;
54459 }
54460
54461 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
54462 index 869116c..820cb27 100644
54463 --- a/fs/proc/inode.c
54464 +++ b/fs/proc/inode.c
54465 @@ -22,11 +22,17 @@
54466 #include <linux/seq_file.h>
54467 #include <linux/slab.h>
54468 #include <linux/mount.h>
54469 +#include <linux/grsecurity.h>
54470
54471 #include <asm/uaccess.h>
54472
54473 #include "internal.h"
54474
54475 +#ifdef CONFIG_PROC_SYSCTL
54476 +extern const struct inode_operations proc_sys_inode_operations;
54477 +extern const struct inode_operations proc_sys_dir_operations;
54478 +#endif
54479 +
54480 static void proc_evict_inode(struct inode *inode)
54481 {
54482 struct proc_dir_entry *de;
54483 @@ -54,6 +60,13 @@ static void proc_evict_inode(struct inode *inode)
54484 ns = PROC_I(inode)->ns;
54485 if (ns_ops && ns)
54486 ns_ops->put(ns);
54487 +
54488 +#ifdef CONFIG_PROC_SYSCTL
54489 + if (inode->i_op == &proc_sys_inode_operations ||
54490 + inode->i_op == &proc_sys_dir_operations)
54491 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
54492 +#endif
54493 +
54494 }
54495
54496 static struct kmem_cache * proc_inode_cachep;
54497 @@ -456,7 +469,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
54498 if (de->mode) {
54499 inode->i_mode = de->mode;
54500 inode->i_uid = de->uid;
54501 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54502 + inode->i_gid = grsec_proc_gid;
54503 +#else
54504 inode->i_gid = de->gid;
54505 +#endif
54506 }
54507 if (de->size)
54508 inode->i_size = de->size;
54509 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
54510 index 85ff3a4..a512bd8 100644
54511 --- a/fs/proc/internal.h
54512 +++ b/fs/proc/internal.h
54513 @@ -56,6 +56,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54514 struct pid *pid, struct task_struct *task);
54515 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54516 struct pid *pid, struct task_struct *task);
54517 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54518 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
54519 +#endif
54520 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
54521
54522 extern const struct file_operations proc_tid_children_operations;
54523 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
54524 index eda6f01..006ae24 100644
54525 --- a/fs/proc/kcore.c
54526 +++ b/fs/proc/kcore.c
54527 @@ -481,9 +481,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
54528 * the addresses in the elf_phdr on our list.
54529 */
54530 start = kc_offset_to_vaddr(*fpos - elf_buflen);
54531 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
54532 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
54533 + if (tsz > buflen)
54534 tsz = buflen;
54535 -
54536 +
54537 while (buflen) {
54538 struct kcore_list *m;
54539
54540 @@ -512,20 +513,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
54541 kfree(elf_buf);
54542 } else {
54543 if (kern_addr_valid(start)) {
54544 - unsigned long n;
54545 + char *elf_buf;
54546 + mm_segment_t oldfs;
54547
54548 - n = copy_to_user(buffer, (char *)start, tsz);
54549 - /*
54550 - * We cannot distinguish between fault on source
54551 - * and fault on destination. When this happens
54552 - * we clear too and hope it will trigger the
54553 - * EFAULT again.
54554 - */
54555 - if (n) {
54556 - if (clear_user(buffer + tsz - n,
54557 - n))
54558 + elf_buf = kmalloc(tsz, GFP_KERNEL);
54559 + if (!elf_buf)
54560 + return -ENOMEM;
54561 + oldfs = get_fs();
54562 + set_fs(KERNEL_DS);
54563 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
54564 + set_fs(oldfs);
54565 + if (copy_to_user(buffer, elf_buf, tsz)) {
54566 + kfree(elf_buf);
54567 return -EFAULT;
54568 + }
54569 }
54570 + set_fs(oldfs);
54571 + kfree(elf_buf);
54572 } else {
54573 if (clear_user(buffer, tsz))
54574 return -EFAULT;
54575 @@ -545,6 +549,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
54576
54577 static int open_kcore(struct inode *inode, struct file *filp)
54578 {
54579 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
54580 + return -EPERM;
54581 +#endif
54582 if (!capable(CAP_SYS_RAWIO))
54583 return -EPERM;
54584 if (kcore_need_update)
54585 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
54586 index 1efaaa1..834e49a 100644
54587 --- a/fs/proc/meminfo.c
54588 +++ b/fs/proc/meminfo.c
54589 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
54590 vmi.used >> 10,
54591 vmi.largest_chunk >> 10
54592 #ifdef CONFIG_MEMORY_FAILURE
54593 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
54594 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
54595 #endif
54596 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
54597 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
54598 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
54599 index ccfd99b..1b7e255 100644
54600 --- a/fs/proc/nommu.c
54601 +++ b/fs/proc/nommu.c
54602 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
54603 if (len < 1)
54604 len = 1;
54605 seq_printf(m, "%*c", len, ' ');
54606 - seq_path(m, &file->f_path, "");
54607 + seq_path(m, &file->f_path, "\n\\");
54608 }
54609
54610 seq_putc(m, '\n');
54611 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
54612 index b4ac657..0842bd2 100644
54613 --- a/fs/proc/proc_net.c
54614 +++ b/fs/proc/proc_net.c
54615 @@ -23,6 +23,7 @@
54616 #include <linux/nsproxy.h>
54617 #include <net/net_namespace.h>
54618 #include <linux/seq_file.h>
54619 +#include <linux/grsecurity.h>
54620
54621 #include "internal.h"
54622
54623 @@ -105,6 +106,17 @@ static struct net *get_proc_task_net(struct inode *dir)
54624 struct task_struct *task;
54625 struct nsproxy *ns;
54626 struct net *net = NULL;
54627 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54628 + const struct cred *cred = current_cred();
54629 +#endif
54630 +
54631 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54632 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
54633 + return net;
54634 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54635 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
54636 + return net;
54637 +#endif
54638
54639 rcu_read_lock();
54640 task = pid_task(proc_pid(dir), PIDTYPE_PID);
54641 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
54642 index ac05f33..1e6dc7e 100644
54643 --- a/fs/proc/proc_sysctl.c
54644 +++ b/fs/proc/proc_sysctl.c
54645 @@ -13,11 +13,15 @@
54646 #include <linux/module.h>
54647 #include "internal.h"
54648
54649 +extern int gr_handle_chroot_sysctl(const int op);
54650 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
54651 + const int op);
54652 +
54653 static const struct dentry_operations proc_sys_dentry_operations;
54654 static const struct file_operations proc_sys_file_operations;
54655 -static const struct inode_operations proc_sys_inode_operations;
54656 +const struct inode_operations proc_sys_inode_operations;
54657 static const struct file_operations proc_sys_dir_file_operations;
54658 -static const struct inode_operations proc_sys_dir_operations;
54659 +const struct inode_operations proc_sys_dir_operations;
54660
54661 void proc_sys_poll_notify(struct ctl_table_poll *poll)
54662 {
54663 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
54664
54665 err = NULL;
54666 d_set_d_op(dentry, &proc_sys_dentry_operations);
54667 +
54668 + gr_handle_proc_create(dentry, inode);
54669 +
54670 d_add(dentry, inode);
54671
54672 out:
54673 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
54674 struct inode *inode = file_inode(filp);
54675 struct ctl_table_header *head = grab_header(inode);
54676 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
54677 + int op = write ? MAY_WRITE : MAY_READ;
54678 ssize_t error;
54679 size_t res;
54680
54681 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
54682 * and won't be until we finish.
54683 */
54684 error = -EPERM;
54685 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
54686 + if (sysctl_perm(head, table, op))
54687 goto out;
54688
54689 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
54690 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
54691 if (!table->proc_handler)
54692 goto out;
54693
54694 +#ifdef CONFIG_GRKERNSEC
54695 + error = -EPERM;
54696 + if (gr_handle_chroot_sysctl(op))
54697 + goto out;
54698 + dget(filp->f_path.dentry);
54699 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
54700 + dput(filp->f_path.dentry);
54701 + goto out;
54702 + }
54703 + dput(filp->f_path.dentry);
54704 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
54705 + goto out;
54706 + if (write && !capable(CAP_SYS_ADMIN))
54707 + goto out;
54708 +#endif
54709 +
54710 /* careful: calling conventions are nasty here */
54711 res = count;
54712 error = table->proc_handler(table, write, buf, &res, ppos);
54713 @@ -598,6 +622,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
54714 return -ENOMEM;
54715 } else {
54716 d_set_d_op(child, &proc_sys_dentry_operations);
54717 +
54718 + gr_handle_proc_create(child, inode);
54719 +
54720 d_add(child, inode);
54721 }
54722 } else {
54723 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
54724 if ((*pos)++ < file->f_pos)
54725 return 0;
54726
54727 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
54728 + return 0;
54729 +
54730 if (unlikely(S_ISLNK(table->mode)))
54731 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
54732 else
54733 @@ -751,6 +781,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
54734 if (IS_ERR(head))
54735 return PTR_ERR(head);
54736
54737 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
54738 + return -ENOENT;
54739 +
54740 generic_fillattr(inode, stat);
54741 if (table)
54742 stat->mode = (stat->mode & S_IFMT) | table->mode;
54743 @@ -773,13 +806,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
54744 .llseek = generic_file_llseek,
54745 };
54746
54747 -static const struct inode_operations proc_sys_inode_operations = {
54748 +const struct inode_operations proc_sys_inode_operations = {
54749 .permission = proc_sys_permission,
54750 .setattr = proc_sys_setattr,
54751 .getattr = proc_sys_getattr,
54752 };
54753
54754 -static const struct inode_operations proc_sys_dir_operations = {
54755 +const struct inode_operations proc_sys_dir_operations = {
54756 .lookup = proc_sys_lookup,
54757 .permission = proc_sys_permission,
54758 .setattr = proc_sys_setattr,
54759 @@ -855,7 +888,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
54760 static struct ctl_dir *new_dir(struct ctl_table_set *set,
54761 const char *name, int namelen)
54762 {
54763 - struct ctl_table *table;
54764 + ctl_table_no_const *table;
54765 struct ctl_dir *new;
54766 struct ctl_node *node;
54767 char *new_name;
54768 @@ -867,7 +900,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
54769 return NULL;
54770
54771 node = (struct ctl_node *)(new + 1);
54772 - table = (struct ctl_table *)(node + 1);
54773 + table = (ctl_table_no_const *)(node + 1);
54774 new_name = (char *)(table + 2);
54775 memcpy(new_name, name, namelen);
54776 new_name[namelen] = '\0';
54777 @@ -1036,7 +1069,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
54778 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
54779 struct ctl_table_root *link_root)
54780 {
54781 - struct ctl_table *link_table, *entry, *link;
54782 + ctl_table_no_const *link_table, *link;
54783 + struct ctl_table *entry;
54784 struct ctl_table_header *links;
54785 struct ctl_node *node;
54786 char *link_name;
54787 @@ -1059,7 +1093,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
54788 return NULL;
54789
54790 node = (struct ctl_node *)(links + 1);
54791 - link_table = (struct ctl_table *)(node + nr_entries);
54792 + link_table = (ctl_table_no_const *)(node + nr_entries);
54793 link_name = (char *)&link_table[nr_entries + 1];
54794
54795 for (link = link_table, entry = table; entry->procname; link++, entry++) {
54796 @@ -1307,8 +1341,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
54797 struct ctl_table_header ***subheader, struct ctl_table_set *set,
54798 struct ctl_table *table)
54799 {
54800 - struct ctl_table *ctl_table_arg = NULL;
54801 - struct ctl_table *entry, *files;
54802 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
54803 + struct ctl_table *entry;
54804 int nr_files = 0;
54805 int nr_dirs = 0;
54806 int err = -ENOMEM;
54807 @@ -1320,10 +1354,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
54808 nr_files++;
54809 }
54810
54811 - files = table;
54812 /* If there are mixed files and directories we need a new table */
54813 if (nr_dirs && nr_files) {
54814 - struct ctl_table *new;
54815 + ctl_table_no_const *new;
54816 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
54817 GFP_KERNEL);
54818 if (!files)
54819 @@ -1341,7 +1374,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
54820 /* Register everything except a directory full of subdirectories */
54821 if (nr_files || !nr_dirs) {
54822 struct ctl_table_header *header;
54823 - header = __register_sysctl_table(set, path, files);
54824 + header = __register_sysctl_table(set, path, files ? files : table);
54825 if (!header) {
54826 kfree(ctl_table_arg);
54827 goto out;
54828 diff --git a/fs/proc/root.c b/fs/proc/root.c
54829 index 9c7fab1..ed1c8e0 100644
54830 --- a/fs/proc/root.c
54831 +++ b/fs/proc/root.c
54832 @@ -180,7 +180,15 @@ void __init proc_root_init(void)
54833 #ifdef CONFIG_PROC_DEVICETREE
54834 proc_device_tree_init();
54835 #endif
54836 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
54837 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54838 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
54839 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54840 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
54841 +#endif
54842 +#else
54843 proc_mkdir("bus", NULL);
54844 +#endif
54845 proc_sys_init();
54846 }
54847
54848 diff --git a/fs/proc/self.c b/fs/proc/self.c
54849 index aa5cc3b..c91a5d0 100644
54850 --- a/fs/proc/self.c
54851 +++ b/fs/proc/self.c
54852 @@ -37,7 +37,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
54853 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
54854 void *cookie)
54855 {
54856 - char *s = nd_get_link(nd);
54857 + const char *s = nd_get_link(nd);
54858 if (!IS_ERR(s))
54859 kfree(s);
54860 }
54861 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
54862 index 3e636d8..83e3b71 100644
54863 --- a/fs/proc/task_mmu.c
54864 +++ b/fs/proc/task_mmu.c
54865 @@ -11,12 +11,19 @@
54866 #include <linux/rmap.h>
54867 #include <linux/swap.h>
54868 #include <linux/swapops.h>
54869 +#include <linux/grsecurity.h>
54870
54871 #include <asm/elf.h>
54872 #include <asm/uaccess.h>
54873 #include <asm/tlbflush.h>
54874 #include "internal.h"
54875
54876 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54877 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54878 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54879 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54880 +#endif
54881 +
54882 void task_mem(struct seq_file *m, struct mm_struct *mm)
54883 {
54884 unsigned long data, text, lib, swap;
54885 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
54886 "VmExe:\t%8lu kB\n"
54887 "VmLib:\t%8lu kB\n"
54888 "VmPTE:\t%8lu kB\n"
54889 - "VmSwap:\t%8lu kB\n",
54890 - hiwater_vm << (PAGE_SHIFT-10),
54891 + "VmSwap:\t%8lu kB\n"
54892 +
54893 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
54894 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
54895 +#endif
54896 +
54897 + ,hiwater_vm << (PAGE_SHIFT-10),
54898 total_vm << (PAGE_SHIFT-10),
54899 mm->locked_vm << (PAGE_SHIFT-10),
54900 mm->pinned_vm << (PAGE_SHIFT-10),
54901 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
54902 data << (PAGE_SHIFT-10),
54903 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
54904 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
54905 - swap << (PAGE_SHIFT-10));
54906 + swap << (PAGE_SHIFT-10)
54907 +
54908 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
54909 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54910 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
54911 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
54912 +#else
54913 + , mm->context.user_cs_base
54914 + , mm->context.user_cs_limit
54915 +#endif
54916 +#endif
54917 +
54918 + );
54919 }
54920
54921 unsigned long task_vsize(struct mm_struct *mm)
54922 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
54923 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
54924 }
54925
54926 - /* We don't show the stack guard page in /proc/maps */
54927 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54928 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
54929 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
54930 +#else
54931 start = vma->vm_start;
54932 - if (stack_guard_page_start(vma, start))
54933 - start += PAGE_SIZE;
54934 end = vma->vm_end;
54935 - if (stack_guard_page_end(vma, end))
54936 - end -= PAGE_SIZE;
54937 +#endif
54938
54939 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
54940 start,
54941 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
54942 flags & VM_WRITE ? 'w' : '-',
54943 flags & VM_EXEC ? 'x' : '-',
54944 flags & VM_MAYSHARE ? 's' : 'p',
54945 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54946 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
54947 +#else
54948 pgoff,
54949 +#endif
54950 MAJOR(dev), MINOR(dev), ino, &len);
54951
54952 /*
54953 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
54954 */
54955 if (file) {
54956 pad_len_spaces(m, len);
54957 - seq_path(m, &file->f_path, "\n");
54958 + seq_path(m, &file->f_path, "\n\\");
54959 goto done;
54960 }
54961
54962 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
54963 * Thread stack in /proc/PID/task/TID/maps or
54964 * the main process stack.
54965 */
54966 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
54967 - vma->vm_end >= mm->start_stack)) {
54968 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
54969 + (vma->vm_start <= mm->start_stack &&
54970 + vma->vm_end >= mm->start_stack)) {
54971 name = "[stack]";
54972 } else {
54973 /* Thread stack in /proc/PID/maps */
54974 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
54975 struct proc_maps_private *priv = m->private;
54976 struct task_struct *task = priv->task;
54977
54978 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54979 + if (current->exec_id != m->exec_id) {
54980 + gr_log_badprocpid("maps");
54981 + return 0;
54982 + }
54983 +#endif
54984 +
54985 show_map_vma(m, vma, is_pid);
54986
54987 if (m->count < m->size) /* vma is copied successfully */
54988 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
54989 .private = &mss,
54990 };
54991
54992 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54993 + if (current->exec_id != m->exec_id) {
54994 + gr_log_badprocpid("smaps");
54995 + return 0;
54996 + }
54997 +#endif
54998 memset(&mss, 0, sizeof mss);
54999 - mss.vma = vma;
55000 - /* mmap_sem is held in m_start */
55001 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
55002 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
55003 -
55004 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55005 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
55006 +#endif
55007 + mss.vma = vma;
55008 + /* mmap_sem is held in m_start */
55009 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
55010 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
55011 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55012 + }
55013 +#endif
55014 show_map_vma(m, vma, is_pid);
55015
55016 seq_printf(m,
55017 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
55018 "KernelPageSize: %8lu kB\n"
55019 "MMUPageSize: %8lu kB\n"
55020 "Locked: %8lu kB\n",
55021 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55022 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
55023 +#else
55024 (vma->vm_end - vma->vm_start) >> 10,
55025 +#endif
55026 mss.resident >> 10,
55027 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
55028 mss.shared_clean >> 10,
55029 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
55030 int n;
55031 char buffer[50];
55032
55033 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55034 + if (current->exec_id != m->exec_id) {
55035 + gr_log_badprocpid("numa_maps");
55036 + return 0;
55037 + }
55038 +#endif
55039 +
55040 if (!mm)
55041 return 0;
55042
55043 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
55044 mpol_to_str(buffer, sizeof(buffer), pol);
55045 mpol_cond_put(pol);
55046
55047 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55048 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
55049 +#else
55050 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
55051 +#endif
55052
55053 if (file) {
55054 seq_printf(m, " file=");
55055 - seq_path(m, &file->f_path, "\n\t= ");
55056 + seq_path(m, &file->f_path, "\n\t\\= ");
55057 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
55058 seq_printf(m, " heap");
55059 } else {
55060 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
55061 index 56123a6..5a2f6ec 100644
55062 --- a/fs/proc/task_nommu.c
55063 +++ b/fs/proc/task_nommu.c
55064 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55065 else
55066 bytes += kobjsize(mm);
55067
55068 - if (current->fs && current->fs->users > 1)
55069 + if (current->fs && atomic_read(&current->fs->users) > 1)
55070 sbytes += kobjsize(current->fs);
55071 else
55072 bytes += kobjsize(current->fs);
55073 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
55074
55075 if (file) {
55076 pad_len_spaces(m, len);
55077 - seq_path(m, &file->f_path, "");
55078 + seq_path(m, &file->f_path, "\n\\");
55079 } else if (mm) {
55080 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
55081
55082 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
55083 index b00fcc9..e0c6381 100644
55084 --- a/fs/qnx6/qnx6.h
55085 +++ b/fs/qnx6/qnx6.h
55086 @@ -74,7 +74,7 @@ enum {
55087 BYTESEX_BE,
55088 };
55089
55090 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
55091 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
55092 {
55093 if (sbi->s_bytesex == BYTESEX_LE)
55094 return le64_to_cpu((__force __le64)n);
55095 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
55096 return (__force __fs64)cpu_to_be64(n);
55097 }
55098
55099 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
55100 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
55101 {
55102 if (sbi->s_bytesex == BYTESEX_LE)
55103 return le32_to_cpu((__force __le32)n);
55104 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
55105 index 16e8abb..2dcf914 100644
55106 --- a/fs/quota/netlink.c
55107 +++ b/fs/quota/netlink.c
55108 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
55109 void quota_send_warning(struct kqid qid, dev_t dev,
55110 const char warntype)
55111 {
55112 - static atomic_t seq;
55113 + static atomic_unchecked_t seq;
55114 struct sk_buff *skb;
55115 void *msg_head;
55116 int ret;
55117 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
55118 "VFS: Not enough memory to send quota warning.\n");
55119 return;
55120 }
55121 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
55122 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
55123 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
55124 if (!msg_head) {
55125 printk(KERN_ERR
55126 diff --git a/fs/readdir.c b/fs/readdir.c
55127 index fee38e0..12fdf47 100644
55128 --- a/fs/readdir.c
55129 +++ b/fs/readdir.c
55130 @@ -17,6 +17,7 @@
55131 #include <linux/security.h>
55132 #include <linux/syscalls.h>
55133 #include <linux/unistd.h>
55134 +#include <linux/namei.h>
55135
55136 #include <asm/uaccess.h>
55137
55138 @@ -67,6 +68,7 @@ struct old_linux_dirent {
55139
55140 struct readdir_callback {
55141 struct old_linux_dirent __user * dirent;
55142 + struct file * file;
55143 int result;
55144 };
55145
55146 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
55147 buf->result = -EOVERFLOW;
55148 return -EOVERFLOW;
55149 }
55150 +
55151 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55152 + return 0;
55153 +
55154 buf->result++;
55155 dirent = buf->dirent;
55156 if (!access_ok(VERIFY_WRITE, dirent,
55157 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
55158
55159 buf.result = 0;
55160 buf.dirent = dirent;
55161 + buf.file = f.file;
55162
55163 error = vfs_readdir(f.file, fillonedir, &buf);
55164 if (buf.result)
55165 @@ -139,6 +146,7 @@ struct linux_dirent {
55166 struct getdents_callback {
55167 struct linux_dirent __user * current_dir;
55168 struct linux_dirent __user * previous;
55169 + struct file * file;
55170 int count;
55171 int error;
55172 };
55173 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
55174 buf->error = -EOVERFLOW;
55175 return -EOVERFLOW;
55176 }
55177 +
55178 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55179 + return 0;
55180 +
55181 dirent = buf->previous;
55182 if (dirent) {
55183 if (__put_user(offset, &dirent->d_off))
55184 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
55185 buf.previous = NULL;
55186 buf.count = count;
55187 buf.error = 0;
55188 + buf.file = f.file;
55189
55190 error = vfs_readdir(f.file, filldir, &buf);
55191 if (error >= 0)
55192 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
55193 struct getdents_callback64 {
55194 struct linux_dirent64 __user * current_dir;
55195 struct linux_dirent64 __user * previous;
55196 + struct file *file;
55197 int count;
55198 int error;
55199 };
55200 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
55201 buf->error = -EINVAL; /* only used if we fail.. */
55202 if (reclen > buf->count)
55203 return -EINVAL;
55204 +
55205 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55206 + return 0;
55207 +
55208 dirent = buf->previous;
55209 if (dirent) {
55210 if (__put_user(offset, &dirent->d_off))
55211 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
55212
55213 buf.current_dir = dirent;
55214 buf.previous = NULL;
55215 + buf.file = f.file;
55216 buf.count = count;
55217 buf.error = 0;
55218
55219 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
55220 error = buf.error;
55221 lastdirent = buf.previous;
55222 if (lastdirent) {
55223 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
55224 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
55225 if (__put_user(d_off, &lastdirent->d_off))
55226 error = -EFAULT;
55227 else
55228 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
55229 index 2b7882b..1c5ef48 100644
55230 --- a/fs/reiserfs/do_balan.c
55231 +++ b/fs/reiserfs/do_balan.c
55232 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
55233 return;
55234 }
55235
55236 - atomic_inc(&(fs_generation(tb->tb_sb)));
55237 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
55238 do_balance_starts(tb);
55239
55240 /* balance leaf returns 0 except if combining L R and S into
55241 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
55242 index 9cc0740a..46bf953 100644
55243 --- a/fs/reiserfs/procfs.c
55244 +++ b/fs/reiserfs/procfs.c
55245 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
55246 "SMALL_TAILS " : "NO_TAILS ",
55247 replay_only(sb) ? "REPLAY_ONLY " : "",
55248 convert_reiserfs(sb) ? "CONV " : "",
55249 - atomic_read(&r->s_generation_counter),
55250 + atomic_read_unchecked(&r->s_generation_counter),
55251 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
55252 SF(s_do_balance), SF(s_unneeded_left_neighbor),
55253 SF(s_good_search_by_key_reada), SF(s_bmaps),
55254 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
55255 index 157e474..65a6114 100644
55256 --- a/fs/reiserfs/reiserfs.h
55257 +++ b/fs/reiserfs/reiserfs.h
55258 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
55259 /* Comment? -Hans */
55260 wait_queue_head_t s_wait;
55261 /* To be obsoleted soon by per buffer seals.. -Hans */
55262 - atomic_t s_generation_counter; // increased by one every time the
55263 + atomic_unchecked_t s_generation_counter; // increased by one every time the
55264 // tree gets re-balanced
55265 unsigned long s_properties; /* File system properties. Currently holds
55266 on-disk FS format */
55267 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
55268 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
55269
55270 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
55271 -#define get_generation(s) atomic_read (&fs_generation(s))
55272 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
55273 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
55274 #define __fs_changed(gen,s) (gen != get_generation (s))
55275 #define fs_changed(gen,s) \
55276 diff --git a/fs/select.c b/fs/select.c
55277 index 8c1c96c..a0f9b6d 100644
55278 --- a/fs/select.c
55279 +++ b/fs/select.c
55280 @@ -20,6 +20,7 @@
55281 #include <linux/export.h>
55282 #include <linux/slab.h>
55283 #include <linux/poll.h>
55284 +#include <linux/security.h>
55285 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
55286 #include <linux/file.h>
55287 #include <linux/fdtable.h>
55288 @@ -827,6 +828,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
55289 struct poll_list *walk = head;
55290 unsigned long todo = nfds;
55291
55292 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
55293 if (nfds > rlimit(RLIMIT_NOFILE))
55294 return -EINVAL;
55295
55296 diff --git a/fs/seq_file.c b/fs/seq_file.c
55297 index 38bb59f..a304f9d 100644
55298 --- a/fs/seq_file.c
55299 +++ b/fs/seq_file.c
55300 @@ -10,6 +10,7 @@
55301 #include <linux/seq_file.h>
55302 #include <linux/slab.h>
55303 #include <linux/cred.h>
55304 +#include <linux/sched.h>
55305
55306 #include <asm/uaccess.h>
55307 #include <asm/page.h>
55308 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
55309 #ifdef CONFIG_USER_NS
55310 p->user_ns = file->f_cred->user_ns;
55311 #endif
55312 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55313 + p->exec_id = current->exec_id;
55314 +#endif
55315
55316 /*
55317 * Wrappers around seq_open(e.g. swaps_open) need to be
55318 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
55319 return 0;
55320 }
55321 if (!m->buf) {
55322 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
55323 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
55324 if (!m->buf)
55325 return -ENOMEM;
55326 }
55327 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
55328 Eoverflow:
55329 m->op->stop(m, p);
55330 kfree(m->buf);
55331 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
55332 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
55333 return !m->buf ? -ENOMEM : -EAGAIN;
55334 }
55335
55336 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
55337
55338 /* grab buffer if we didn't have one */
55339 if (!m->buf) {
55340 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
55341 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
55342 if (!m->buf)
55343 goto Enomem;
55344 }
55345 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
55346 goto Fill;
55347 m->op->stop(m, p);
55348 kfree(m->buf);
55349 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
55350 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
55351 if (!m->buf)
55352 goto Enomem;
55353 m->count = 0;
55354 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
55355 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
55356 void *data)
55357 {
55358 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
55359 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
55360 int res = -ENOMEM;
55361
55362 if (op) {
55363 diff --git a/fs/splice.c b/fs/splice.c
55364 index 29e394e..b13c247 100644
55365 --- a/fs/splice.c
55366 +++ b/fs/splice.c
55367 @@ -195,7 +195,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
55368 pipe_lock(pipe);
55369
55370 for (;;) {
55371 - if (!pipe->readers) {
55372 + if (!atomic_read(&pipe->readers)) {
55373 send_sig(SIGPIPE, current, 0);
55374 if (!ret)
55375 ret = -EPIPE;
55376 @@ -249,9 +249,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
55377 do_wakeup = 0;
55378 }
55379
55380 - pipe->waiting_writers++;
55381 + atomic_inc(&pipe->waiting_writers);
55382 pipe_wait(pipe);
55383 - pipe->waiting_writers--;
55384 + atomic_dec(&pipe->waiting_writers);
55385 }
55386
55387 pipe_unlock(pipe);
55388 @@ -564,7 +564,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
55389 old_fs = get_fs();
55390 set_fs(get_ds());
55391 /* The cast to a user pointer is valid due to the set_fs() */
55392 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
55393 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
55394 set_fs(old_fs);
55395
55396 return res;
55397 @@ -579,7 +579,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
55398 old_fs = get_fs();
55399 set_fs(get_ds());
55400 /* The cast to a user pointer is valid due to the set_fs() */
55401 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
55402 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
55403 set_fs(old_fs);
55404
55405 return res;
55406 @@ -632,7 +632,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
55407 goto err;
55408
55409 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
55410 - vec[i].iov_base = (void __user *) page_address(page);
55411 + vec[i].iov_base = (void __force_user *) page_address(page);
55412 vec[i].iov_len = this_len;
55413 spd.pages[i] = page;
55414 spd.nr_pages++;
55415 @@ -853,10 +853,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
55416 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
55417 {
55418 while (!pipe->nrbufs) {
55419 - if (!pipe->writers)
55420 + if (!atomic_read(&pipe->writers))
55421 return 0;
55422
55423 - if (!pipe->waiting_writers && sd->num_spliced)
55424 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
55425 return 0;
55426
55427 if (sd->flags & SPLICE_F_NONBLOCK)
55428 @@ -1192,7 +1192,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
55429 * out of the pipe right after the splice_to_pipe(). So set
55430 * PIPE_READERS appropriately.
55431 */
55432 - pipe->readers = 1;
55433 + atomic_set(&pipe->readers, 1);
55434
55435 current->splice_pipe = pipe;
55436 }
55437 @@ -1741,9 +1741,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
55438 ret = -ERESTARTSYS;
55439 break;
55440 }
55441 - if (!pipe->writers)
55442 + if (!atomic_read(&pipe->writers))
55443 break;
55444 - if (!pipe->waiting_writers) {
55445 + if (!atomic_read(&pipe->waiting_writers)) {
55446 if (flags & SPLICE_F_NONBLOCK) {
55447 ret = -EAGAIN;
55448 break;
55449 @@ -1775,7 +1775,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
55450 pipe_lock(pipe);
55451
55452 while (pipe->nrbufs >= pipe->buffers) {
55453 - if (!pipe->readers) {
55454 + if (!atomic_read(&pipe->readers)) {
55455 send_sig(SIGPIPE, current, 0);
55456 ret = -EPIPE;
55457 break;
55458 @@ -1788,9 +1788,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
55459 ret = -ERESTARTSYS;
55460 break;
55461 }
55462 - pipe->waiting_writers++;
55463 + atomic_inc(&pipe->waiting_writers);
55464 pipe_wait(pipe);
55465 - pipe->waiting_writers--;
55466 + atomic_dec(&pipe->waiting_writers);
55467 }
55468
55469 pipe_unlock(pipe);
55470 @@ -1826,14 +1826,14 @@ retry:
55471 pipe_double_lock(ipipe, opipe);
55472
55473 do {
55474 - if (!opipe->readers) {
55475 + if (!atomic_read(&opipe->readers)) {
55476 send_sig(SIGPIPE, current, 0);
55477 if (!ret)
55478 ret = -EPIPE;
55479 break;
55480 }
55481
55482 - if (!ipipe->nrbufs && !ipipe->writers)
55483 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
55484 break;
55485
55486 /*
55487 @@ -1930,7 +1930,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
55488 pipe_double_lock(ipipe, opipe);
55489
55490 do {
55491 - if (!opipe->readers) {
55492 + if (!atomic_read(&opipe->readers)) {
55493 send_sig(SIGPIPE, current, 0);
55494 if (!ret)
55495 ret = -EPIPE;
55496 @@ -1975,7 +1975,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
55497 * return EAGAIN if we have the potential of some data in the
55498 * future, otherwise just return 0
55499 */
55500 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
55501 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
55502 ret = -EAGAIN;
55503
55504 pipe_unlock(ipipe);
55505 diff --git a/fs/stat.c b/fs/stat.c
55506 index 04ce1ac..a13dd1e 100644
55507 --- a/fs/stat.c
55508 +++ b/fs/stat.c
55509 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
55510 stat->gid = inode->i_gid;
55511 stat->rdev = inode->i_rdev;
55512 stat->size = i_size_read(inode);
55513 - stat->atime = inode->i_atime;
55514 - stat->mtime = inode->i_mtime;
55515 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
55516 + stat->atime = inode->i_ctime;
55517 + stat->mtime = inode->i_ctime;
55518 + } else {
55519 + stat->atime = inode->i_atime;
55520 + stat->mtime = inode->i_mtime;
55521 + }
55522 stat->ctime = inode->i_ctime;
55523 stat->blksize = (1 << inode->i_blkbits);
55524 stat->blocks = inode->i_blocks;
55525 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
55526 if (retval)
55527 return retval;
55528
55529 - if (inode->i_op->getattr)
55530 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
55531 + if (inode->i_op->getattr) {
55532 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
55533 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
55534 + stat->atime = stat->ctime;
55535 + stat->mtime = stat->ctime;
55536 + }
55537 + return retval;
55538 + }
55539
55540 generic_fillattr(inode, stat);
55541 return 0;
55542 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
55543 index 15c68f9..36a8b3e 100644
55544 --- a/fs/sysfs/bin.c
55545 +++ b/fs/sysfs/bin.c
55546 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
55547 return ret;
55548 }
55549
55550 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
55551 - void *buf, int len, int write)
55552 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
55553 + void *buf, size_t len, int write)
55554 {
55555 struct file *file = vma->vm_file;
55556 struct bin_buffer *bb = file->private_data;
55557 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
55558 - int ret;
55559 + ssize_t ret;
55560
55561 if (!bb->vm_ops)
55562 return -EINVAL;
55563 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
55564 index 6f31590..3c87c8a 100644
55565 --- a/fs/sysfs/dir.c
55566 +++ b/fs/sysfs/dir.c
55567 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
55568 *
55569 * Returns 31 bit hash of ns + name (so it fits in an off_t )
55570 */
55571 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
55572 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
55573 {
55574 unsigned long hash = init_name_hash();
55575 unsigned int len = strlen(name);
55576 @@ -685,6 +685,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
55577 struct sysfs_dirent *sd;
55578 int rc;
55579
55580 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
55581 + const char *parent_name = parent_sd->s_name;
55582 +
55583 + mode = S_IFDIR | S_IRWXU;
55584 +
55585 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
55586 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
55587 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
55588 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
55589 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
55590 +#endif
55591 +
55592 /* allocate */
55593 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
55594 if (!sd)
55595 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
55596 index 602f56d..6853db8 100644
55597 --- a/fs/sysfs/file.c
55598 +++ b/fs/sysfs/file.c
55599 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
55600
55601 struct sysfs_open_dirent {
55602 atomic_t refcnt;
55603 - atomic_t event;
55604 + atomic_unchecked_t event;
55605 wait_queue_head_t poll;
55606 struct list_head buffers; /* goes through sysfs_buffer.list */
55607 };
55608 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
55609 if (!sysfs_get_active(attr_sd))
55610 return -ENODEV;
55611
55612 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
55613 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
55614 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
55615
55616 sysfs_put_active(attr_sd);
55617 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
55618 return -ENOMEM;
55619
55620 atomic_set(&new_od->refcnt, 0);
55621 - atomic_set(&new_od->event, 1);
55622 + atomic_set_unchecked(&new_od->event, 1);
55623 init_waitqueue_head(&new_od->poll);
55624 INIT_LIST_HEAD(&new_od->buffers);
55625 goto retry;
55626 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
55627
55628 sysfs_put_active(attr_sd);
55629
55630 - if (buffer->event != atomic_read(&od->event))
55631 + if (buffer->event != atomic_read_unchecked(&od->event))
55632 goto trigger;
55633
55634 return DEFAULT_POLLMASK;
55635 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
55636
55637 od = sd->s_attr.open;
55638 if (od) {
55639 - atomic_inc(&od->event);
55640 + atomic_inc_unchecked(&od->event);
55641 wake_up_interruptible(&od->poll);
55642 }
55643
55644 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
55645 index 8c940df..25b733e 100644
55646 --- a/fs/sysfs/symlink.c
55647 +++ b/fs/sysfs/symlink.c
55648 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
55649
55650 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
55651 {
55652 - char *page = nd_get_link(nd);
55653 + const char *page = nd_get_link(nd);
55654 if (!IS_ERR(page))
55655 free_page((unsigned long)page);
55656 }
55657 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
55658 index 69d4889..a810bd4 100644
55659 --- a/fs/sysv/sysv.h
55660 +++ b/fs/sysv/sysv.h
55661 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
55662 #endif
55663 }
55664
55665 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
55666 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
55667 {
55668 if (sbi->s_bytesex == BYTESEX_PDP)
55669 return PDP_swab((__force __u32)n);
55670 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
55671 index e18b988..f1d4ad0f 100644
55672 --- a/fs/ubifs/io.c
55673 +++ b/fs/ubifs/io.c
55674 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
55675 return err;
55676 }
55677
55678 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
55679 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
55680 {
55681 int err;
55682
55683 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
55684 index c175b4d..8f36a16 100644
55685 --- a/fs/udf/misc.c
55686 +++ b/fs/udf/misc.c
55687 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
55688
55689 u8 udf_tag_checksum(const struct tag *t)
55690 {
55691 - u8 *data = (u8 *)t;
55692 + const u8 *data = (const u8 *)t;
55693 u8 checksum = 0;
55694 int i;
55695 for (i = 0; i < sizeof(struct tag); ++i)
55696 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
55697 index 8d974c4..b82f6ec 100644
55698 --- a/fs/ufs/swab.h
55699 +++ b/fs/ufs/swab.h
55700 @@ -22,7 +22,7 @@ enum {
55701 BYTESEX_BE
55702 };
55703
55704 -static inline u64
55705 +static inline u64 __intentional_overflow(-1)
55706 fs64_to_cpu(struct super_block *sbp, __fs64 n)
55707 {
55708 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
55709 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
55710 return (__force __fs64)cpu_to_be64(n);
55711 }
55712
55713 -static inline u32
55714 +static inline u32 __intentional_overflow(-1)
55715 fs32_to_cpu(struct super_block *sbp, __fs32 n)
55716 {
55717 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
55718 diff --git a/fs/utimes.c b/fs/utimes.c
55719 index f4fb7ec..3fe03c0 100644
55720 --- a/fs/utimes.c
55721 +++ b/fs/utimes.c
55722 @@ -1,6 +1,7 @@
55723 #include <linux/compiler.h>
55724 #include <linux/file.h>
55725 #include <linux/fs.h>
55726 +#include <linux/security.h>
55727 #include <linux/linkage.h>
55728 #include <linux/mount.h>
55729 #include <linux/namei.h>
55730 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
55731 goto mnt_drop_write_and_out;
55732 }
55733 }
55734 +
55735 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
55736 + error = -EACCES;
55737 + goto mnt_drop_write_and_out;
55738 + }
55739 +
55740 mutex_lock(&inode->i_mutex);
55741 error = notify_change(path->dentry, &newattrs);
55742 mutex_unlock(&inode->i_mutex);
55743 diff --git a/fs/xattr.c b/fs/xattr.c
55744 index 3377dff..4d074d9 100644
55745 --- a/fs/xattr.c
55746 +++ b/fs/xattr.c
55747 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
55748 return rc;
55749 }
55750
55751 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
55752 +ssize_t
55753 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
55754 +{
55755 + struct inode *inode = dentry->d_inode;
55756 + ssize_t error;
55757 +
55758 + error = inode_permission(inode, MAY_EXEC);
55759 + if (error)
55760 + return error;
55761 +
55762 + if (inode->i_op->getxattr)
55763 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
55764 + else
55765 + error = -EOPNOTSUPP;
55766 +
55767 + return error;
55768 +}
55769 +EXPORT_SYMBOL(pax_getxattr);
55770 +#endif
55771 +
55772 ssize_t
55773 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
55774 {
55775 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
55776 * Extended attribute SET operations
55777 */
55778 static long
55779 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
55780 +setxattr(struct path *path, const char __user *name, const void __user *value,
55781 size_t size, int flags)
55782 {
55783 int error;
55784 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
55785 posix_acl_fix_xattr_from_user(kvalue, size);
55786 }
55787
55788 - error = vfs_setxattr(d, kname, kvalue, size, flags);
55789 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
55790 + error = -EACCES;
55791 + goto out;
55792 + }
55793 +
55794 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
55795 out:
55796 if (vvalue)
55797 vfree(vvalue);
55798 @@ -377,7 +403,7 @@ retry:
55799 return error;
55800 error = mnt_want_write(path.mnt);
55801 if (!error) {
55802 - error = setxattr(path.dentry, name, value, size, flags);
55803 + error = setxattr(&path, name, value, size, flags);
55804 mnt_drop_write(path.mnt);
55805 }
55806 path_put(&path);
55807 @@ -401,7 +427,7 @@ retry:
55808 return error;
55809 error = mnt_want_write(path.mnt);
55810 if (!error) {
55811 - error = setxattr(path.dentry, name, value, size, flags);
55812 + error = setxattr(&path, name, value, size, flags);
55813 mnt_drop_write(path.mnt);
55814 }
55815 path_put(&path);
55816 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
55817 const void __user *,value, size_t, size, int, flags)
55818 {
55819 struct fd f = fdget(fd);
55820 - struct dentry *dentry;
55821 int error = -EBADF;
55822
55823 if (!f.file)
55824 return error;
55825 - dentry = f.file->f_path.dentry;
55826 - audit_inode(NULL, dentry, 0);
55827 + audit_inode(NULL, f.file->f_path.dentry, 0);
55828 error = mnt_want_write_file(f.file);
55829 if (!error) {
55830 - error = setxattr(dentry, name, value, size, flags);
55831 + error = setxattr(&f.file->f_path, name, value, size, flags);
55832 mnt_drop_write_file(f.file);
55833 }
55834 fdput(f);
55835 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
55836 index 9fbea87..6b19972 100644
55837 --- a/fs/xattr_acl.c
55838 +++ b/fs/xattr_acl.c
55839 @@ -76,8 +76,8 @@ struct posix_acl *
55840 posix_acl_from_xattr(struct user_namespace *user_ns,
55841 const void *value, size_t size)
55842 {
55843 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
55844 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
55845 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
55846 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
55847 int count;
55848 struct posix_acl *acl;
55849 struct posix_acl_entry *acl_e;
55850 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
55851 index b44af92..06073da 100644
55852 --- a/fs/xfs/xfs_bmap.c
55853 +++ b/fs/xfs/xfs_bmap.c
55854 @@ -192,7 +192,7 @@ xfs_bmap_validate_ret(
55855 int nmap,
55856 int ret_nmap);
55857 #else
55858 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
55859 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
55860 #endif /* DEBUG */
55861
55862 STATIC int
55863 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
55864 index 1b9fc3e..e1bdde0 100644
55865 --- a/fs/xfs/xfs_dir2_sf.c
55866 +++ b/fs/xfs/xfs_dir2_sf.c
55867 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
55868 }
55869
55870 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
55871 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
55872 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
55873 + char name[sfep->namelen];
55874 + memcpy(name, sfep->name, sfep->namelen);
55875 + if (filldir(dirent, name, sfep->namelen,
55876 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
55877 + *offset = off & 0x7fffffff;
55878 + return 0;
55879 + }
55880 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
55881 off & 0x7fffffff, ino, DT_UNKNOWN)) {
55882 *offset = off & 0x7fffffff;
55883 return 0;
55884 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
55885 index d681e34..2a3f5ab 100644
55886 --- a/fs/xfs/xfs_ioctl.c
55887 +++ b/fs/xfs/xfs_ioctl.c
55888 @@ -127,7 +127,7 @@ xfs_find_handle(
55889 }
55890
55891 error = -EFAULT;
55892 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
55893 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
55894 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
55895 goto out_put;
55896
55897 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
55898 index d82efaa..0904a8e 100644
55899 --- a/fs/xfs/xfs_iops.c
55900 +++ b/fs/xfs/xfs_iops.c
55901 @@ -395,7 +395,7 @@ xfs_vn_put_link(
55902 struct nameidata *nd,
55903 void *p)
55904 {
55905 - char *s = nd_get_link(nd);
55906 + const char *s = nd_get_link(nd);
55907
55908 if (!IS_ERR(s))
55909 kfree(s);
55910 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
55911 new file mode 100644
55912 index 0000000..7174794
55913 --- /dev/null
55914 +++ b/grsecurity/Kconfig
55915 @@ -0,0 +1,1031 @@
55916 +#
55917 +# grecurity configuration
55918 +#
55919 +menu "Memory Protections"
55920 +depends on GRKERNSEC
55921 +
55922 +config GRKERNSEC_KMEM
55923 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
55924 + default y if GRKERNSEC_CONFIG_AUTO
55925 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
55926 + help
55927 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
55928 + be written to or read from to modify or leak the contents of the running
55929 + kernel. /dev/port will also not be allowed to be opened and support
55930 + for /dev/cpu/*/msr will be removed. If you have module
55931 + support disabled, enabling this will close up five ways that are
55932 + currently used to insert malicious code into the running kernel.
55933 +
55934 + Even with all these features enabled, we still highly recommend that
55935 + you use the RBAC system, as it is still possible for an attacker to
55936 + modify the running kernel through privileged I/O granted by ioperm/iopl.
55937 +
55938 + If you are not using XFree86, you may be able to stop this additional
55939 + case by enabling the 'Disable privileged I/O' option. Though nothing
55940 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
55941 + but only to video memory, which is the only writing we allow in this
55942 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
55943 + not be allowed to mprotect it with PROT_WRITE later.
55944 + Enabling this feature will prevent the "cpupower" and "powertop" tools
55945 + from working.
55946 +
55947 + It is highly recommended that you say Y here if you meet all the
55948 + conditions above.
55949 +
55950 +config GRKERNSEC_VM86
55951 + bool "Restrict VM86 mode"
55952 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
55953 + depends on X86_32
55954 +
55955 + help
55956 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
55957 + make use of a special execution mode on 32bit x86 processors called
55958 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
55959 + video cards and will still work with this option enabled. The purpose
55960 + of the option is to prevent exploitation of emulation errors in
55961 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
55962 + Nearly all users should be able to enable this option.
55963 +
55964 +config GRKERNSEC_IO
55965 + bool "Disable privileged I/O"
55966 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
55967 + depends on X86
55968 + select RTC_CLASS
55969 + select RTC_INTF_DEV
55970 + select RTC_DRV_CMOS
55971 +
55972 + help
55973 + If you say Y here, all ioperm and iopl calls will return an error.
55974 + Ioperm and iopl can be used to modify the running kernel.
55975 + Unfortunately, some programs need this access to operate properly,
55976 + the most notable of which are XFree86 and hwclock. hwclock can be
55977 + remedied by having RTC support in the kernel, so real-time
55978 + clock support is enabled if this option is enabled, to ensure
55979 + that hwclock operates correctly. XFree86 still will not
55980 + operate correctly with this option enabled, so DO NOT CHOOSE Y
55981 + IF YOU USE XFree86. If you use XFree86 and you still want to
55982 + protect your kernel against modification, use the RBAC system.
55983 +
55984 +config GRKERNSEC_JIT_HARDEN
55985 + bool "Harden BPF JIT against spray attacks"
55986 + default y if GRKERNSEC_CONFIG_AUTO
55987 + depends on BPF_JIT
55988 + help
55989 + If you say Y here, the native code generated by the kernel's Berkeley
55990 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
55991 + attacks that attempt to fit attacker-beneficial instructions in
55992 + 32bit immediate fields of JIT-generated native instructions. The
55993 + attacker will generally aim to cause an unintended instruction sequence
55994 + of JIT-generated native code to execute by jumping into the middle of
55995 + a generated instruction. This feature effectively randomizes the 32bit
55996 + immediate constants present in the generated code to thwart such attacks.
55997 +
55998 + If you're using KERNEXEC, it's recommended that you enable this option
55999 + to supplement the hardening of the kernel.
56000 +
56001 +config GRKERNSEC_RAND_THREADSTACK
56002 + bool "Insert random gaps between thread stacks"
56003 + default y if GRKERNSEC_CONFIG_AUTO
56004 + depends on PAX_RANDMMAP && !PPC && BROKEN
56005 + help
56006 + If you say Y here, a random-sized gap will be enforced between allocated
56007 + thread stacks. Glibc's NPTL and other threading libraries that
56008 + pass MAP_STACK to the kernel for thread stack allocation are supported.
56009 + The implementation currently provides 8 bits of entropy for the gap.
56010 +
56011 + Many distributions do not compile threaded remote services with the
56012 + -fstack-check argument to GCC, causing the variable-sized stack-based
56013 + allocator, alloca(), to not probe the stack on allocation. This
56014 + permits an unbounded alloca() to skip over any guard page and potentially
56015 + modify another thread's stack reliably. An enforced random gap
56016 + reduces the reliability of such an attack and increases the chance
56017 + that such a read/write to another thread's stack instead lands in
56018 + an unmapped area, causing a crash and triggering grsecurity's
56019 + anti-bruteforcing logic.
56020 +
56021 +config GRKERNSEC_PROC_MEMMAP
56022 + bool "Harden ASLR against information leaks and entropy reduction"
56023 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
56024 + depends on PAX_NOEXEC || PAX_ASLR
56025 + help
56026 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
56027 + give no information about the addresses of its mappings if
56028 + PaX features that rely on random addresses are enabled on the task.
56029 + In addition to sanitizing this information and disabling other
56030 + dangerous sources of information, this option causes reads of sensitive
56031 + /proc/<pid> entries where the file descriptor was opened in a different
56032 + task than the one performing the read. Such attempts are logged.
56033 + This option also limits argv/env strings for suid/sgid binaries
56034 + to 512KB to prevent a complete exhaustion of the stack entropy provided
56035 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
56036 + binaries to prevent alternative mmap layouts from being abused.
56037 +
56038 + If you use PaX it is essential that you say Y here as it closes up
56039 + several holes that make full ASLR useless locally.
56040 +
56041 +config GRKERNSEC_BRUTE
56042 + bool "Deter exploit bruteforcing"
56043 + default y if GRKERNSEC_CONFIG_AUTO
56044 + help
56045 + If you say Y here, attempts to bruteforce exploits against forking
56046 + daemons such as apache or sshd, as well as against suid/sgid binaries
56047 + will be deterred. When a child of a forking daemon is killed by PaX
56048 + or crashes due to an illegal instruction or other suspicious signal,
56049 + the parent process will be delayed 30 seconds upon every subsequent
56050 + fork until the administrator is able to assess the situation and
56051 + restart the daemon.
56052 + In the suid/sgid case, the attempt is logged, the user has all their
56053 + processes terminated, and they are prevented from executing any further
56054 + processes for 15 minutes.
56055 + It is recommended that you also enable signal logging in the auditing
56056 + section so that logs are generated when a process triggers a suspicious
56057 + signal.
56058 + If the sysctl option is enabled, a sysctl option with name
56059 + "deter_bruteforce" is created.
56060 +
56061 +
56062 +config GRKERNSEC_MODHARDEN
56063 + bool "Harden module auto-loading"
56064 + default y if GRKERNSEC_CONFIG_AUTO
56065 + depends on MODULES
56066 + help
56067 + If you say Y here, module auto-loading in response to use of some
56068 + feature implemented by an unloaded module will be restricted to
56069 + root users. Enabling this option helps defend against attacks
56070 + by unprivileged users who abuse the auto-loading behavior to
56071 + cause a vulnerable module to load that is then exploited.
56072 +
56073 + If this option prevents a legitimate use of auto-loading for a
56074 + non-root user, the administrator can execute modprobe manually
56075 + with the exact name of the module mentioned in the alert log.
56076 + Alternatively, the administrator can add the module to the list
56077 + of modules loaded at boot by modifying init scripts.
56078 +
56079 + Modification of init scripts will most likely be needed on
56080 + Ubuntu servers with encrypted home directory support enabled,
56081 + as the first non-root user logging in will cause the ecb(aes),
56082 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
56083 +
56084 +config GRKERNSEC_HIDESYM
56085 + bool "Hide kernel symbols"
56086 + default y if GRKERNSEC_CONFIG_AUTO
56087 + select PAX_USERCOPY_SLABS
56088 + help
56089 + If you say Y here, getting information on loaded modules, and
56090 + displaying all kernel symbols through a syscall will be restricted
56091 + to users with CAP_SYS_MODULE. For software compatibility reasons,
56092 + /proc/kallsyms will be restricted to the root user. The RBAC
56093 + system can hide that entry even from root.
56094 +
56095 + This option also prevents leaking of kernel addresses through
56096 + several /proc entries.
56097 +
56098 + Note that this option is only effective provided the following
56099 + conditions are met:
56100 + 1) The kernel using grsecurity is not precompiled by some distribution
56101 + 2) You have also enabled GRKERNSEC_DMESG
56102 + 3) You are using the RBAC system and hiding other files such as your
56103 + kernel image and System.map. Alternatively, enabling this option
56104 + causes the permissions on /boot, /lib/modules, and the kernel
56105 + source directory to change at compile time to prevent
56106 + reading by non-root users.
56107 + If the above conditions are met, this option will aid in providing a
56108 + useful protection against local kernel exploitation of overflows
56109 + and arbitrary read/write vulnerabilities.
56110 +
56111 +config GRKERNSEC_KERN_LOCKOUT
56112 + bool "Active kernel exploit response"
56113 + default y if GRKERNSEC_CONFIG_AUTO
56114 + depends on X86 || ARM || PPC || SPARC
56115 + help
56116 + If you say Y here, when a PaX alert is triggered due to suspicious
56117 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
56118 + or an OOPS occurs due to bad memory accesses, instead of just
56119 + terminating the offending process (and potentially allowing
56120 + a subsequent exploit from the same user), we will take one of two
56121 + actions:
56122 + If the user was root, we will panic the system
56123 + If the user was non-root, we will log the attempt, terminate
56124 + all processes owned by the user, then prevent them from creating
56125 + any new processes until the system is restarted
56126 + This deters repeated kernel exploitation/bruteforcing attempts
56127 + and is useful for later forensics.
56128 +
56129 +endmenu
56130 +menu "Role Based Access Control Options"
56131 +depends on GRKERNSEC
56132 +
56133 +config GRKERNSEC_RBAC_DEBUG
56134 + bool
56135 +
56136 +config GRKERNSEC_NO_RBAC
56137 + bool "Disable RBAC system"
56138 + help
56139 + If you say Y here, the /dev/grsec device will be removed from the kernel,
56140 + preventing the RBAC system from being enabled. You should only say Y
56141 + here if you have no intention of using the RBAC system, so as to prevent
56142 + an attacker with root access from misusing the RBAC system to hide files
56143 + and processes when loadable module support and /dev/[k]mem have been
56144 + locked down.
56145 +
56146 +config GRKERNSEC_ACL_HIDEKERN
56147 + bool "Hide kernel processes"
56148 + help
56149 + If you say Y here, all kernel threads will be hidden to all
56150 + processes but those whose subject has the "view hidden processes"
56151 + flag.
56152 +
56153 +config GRKERNSEC_ACL_MAXTRIES
56154 + int "Maximum tries before password lockout"
56155 + default 3
56156 + help
56157 + This option enforces the maximum number of times a user can attempt
56158 + to authorize themselves with the grsecurity RBAC system before being
56159 + denied the ability to attempt authorization again for a specified time.
56160 + The lower the number, the harder it will be to brute-force a password.
56161 +
56162 +config GRKERNSEC_ACL_TIMEOUT
56163 + int "Time to wait after max password tries, in seconds"
56164 + default 30
56165 + help
56166 + This option specifies the time the user must wait after attempting to
56167 + authorize to the RBAC system with the maximum number of invalid
56168 + passwords. The higher the number, the harder it will be to brute-force
56169 + a password.
56170 +
56171 +endmenu
56172 +menu "Filesystem Protections"
56173 +depends on GRKERNSEC
56174 +
56175 +config GRKERNSEC_PROC
56176 + bool "Proc restrictions"
56177 + default y if GRKERNSEC_CONFIG_AUTO
56178 + help
56179 + If you say Y here, the permissions of the /proc filesystem
56180 + will be altered to enhance system security and privacy. You MUST
56181 + choose either a user only restriction or a user and group restriction.
56182 + Depending upon the option you choose, you can either restrict users to
56183 + see only the processes they themselves run, or choose a group that can
56184 + view all processes and files normally restricted to root if you choose
56185 + the "restrict to user only" option. NOTE: If you're running identd or
56186 + ntpd as a non-root user, you will have to run it as the group you
56187 + specify here.
56188 +
56189 +config GRKERNSEC_PROC_USER
56190 + bool "Restrict /proc to user only"
56191 + depends on GRKERNSEC_PROC
56192 + help
56193 + If you say Y here, non-root users will only be able to view their own
56194 + processes, and restricts them from viewing network-related information,
56195 + and viewing kernel symbol and module information.
56196 +
56197 +config GRKERNSEC_PROC_USERGROUP
56198 + bool "Allow special group"
56199 + default y if GRKERNSEC_CONFIG_AUTO
56200 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
56201 + help
56202 + If you say Y here, you will be able to select a group that will be
56203 + able to view all processes and network-related information. If you've
56204 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
56205 + remain hidden. This option is useful if you want to run identd as
56206 + a non-root user. The group you select may also be chosen at boot time
56207 + via "grsec_proc_gid=" on the kernel commandline.
56208 +
56209 +config GRKERNSEC_PROC_GID
56210 + int "GID for special group"
56211 + depends on GRKERNSEC_PROC_USERGROUP
56212 + default 1001
56213 +
56214 +config GRKERNSEC_PROC_ADD
56215 + bool "Additional restrictions"
56216 + default y if GRKERNSEC_CONFIG_AUTO
56217 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
56218 + help
56219 + If you say Y here, additional restrictions will be placed on
56220 + /proc that keep normal users from viewing device information and
56221 + slabinfo information that could be useful for exploits.
56222 +
56223 +config GRKERNSEC_LINK
56224 + bool "Linking restrictions"
56225 + default y if GRKERNSEC_CONFIG_AUTO
56226 + help
56227 + If you say Y here, /tmp race exploits will be prevented, since users
56228 + will no longer be able to follow symlinks owned by other users in
56229 + world-writable +t directories (e.g. /tmp), unless the owner of the
56230 + symlink is the owner of the directory. users will also not be
56231 + able to hardlink to files they do not own. If the sysctl option is
56232 + enabled, a sysctl option with name "linking_restrictions" is created.
56233 +
56234 +config GRKERNSEC_SYMLINKOWN
56235 + bool "Kernel-enforced SymlinksIfOwnerMatch"
56236 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
56237 + help
56238 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
56239 + that prevents it from being used as a security feature. As Apache
56240 + verifies the symlink by performing a stat() against the target of
56241 + the symlink before it is followed, an attacker can setup a symlink
56242 + to point to a same-owned file, then replace the symlink with one
56243 + that targets another user's file just after Apache "validates" the
56244 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
56245 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
56246 + will be in place for the group you specify. If the sysctl option
56247 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
56248 + created.
56249 +
56250 +config GRKERNSEC_SYMLINKOWN_GID
56251 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
56252 + depends on GRKERNSEC_SYMLINKOWN
56253 + default 1006
56254 + help
56255 + Setting this GID determines what group kernel-enforced
56256 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
56257 + is enabled, a sysctl option with name "symlinkown_gid" is created.
56258 +
56259 +config GRKERNSEC_FIFO
56260 + bool "FIFO restrictions"
56261 + default y if GRKERNSEC_CONFIG_AUTO
56262 + help
56263 + If you say Y here, users will not be able to write to FIFOs they don't
56264 + own in world-writable +t directories (e.g. /tmp), unless the owner of
56265 + the FIFO is the same owner of the directory it's held in. If the sysctl
56266 + option is enabled, a sysctl option with name "fifo_restrictions" is
56267 + created.
56268 +
56269 +config GRKERNSEC_SYSFS_RESTRICT
56270 + bool "Sysfs/debugfs restriction"
56271 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56272 + depends on SYSFS
56273 + help
56274 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
56275 + any filesystem normally mounted under it (e.g. debugfs) will be
56276 + mostly accessible only by root. These filesystems generally provide access
56277 + to hardware and debug information that isn't appropriate for unprivileged
56278 + users of the system. Sysfs and debugfs have also become a large source
56279 + of new vulnerabilities, ranging from infoleaks to local compromise.
56280 + There has been very little oversight with an eye toward security involved
56281 + in adding new exporters of information to these filesystems, so their
56282 + use is discouraged.
56283 + For reasons of compatibility, a few directories have been whitelisted
56284 + for access by non-root users:
56285 + /sys/fs/selinux
56286 + /sys/fs/fuse
56287 + /sys/devices/system/cpu
56288 +
56289 +config GRKERNSEC_ROFS
56290 + bool "Runtime read-only mount protection"
56291 + help
56292 + If you say Y here, a sysctl option with name "romount_protect" will
56293 + be created. By setting this option to 1 at runtime, filesystems
56294 + will be protected in the following ways:
56295 + * No new writable mounts will be allowed
56296 + * Existing read-only mounts won't be able to be remounted read/write
56297 + * Write operations will be denied on all block devices
56298 + This option acts independently of grsec_lock: once it is set to 1,
56299 + it cannot be turned off. Therefore, please be mindful of the resulting
56300 + behavior if this option is enabled in an init script on a read-only
56301 + filesystem. This feature is mainly intended for secure embedded systems.
56302 +
56303 +config GRKERNSEC_DEVICE_SIDECHANNEL
56304 + bool "Eliminate stat/notify-based device sidechannels"
56305 + default y if GRKERNSEC_CONFIG_AUTO
56306 + help
56307 + If you say Y here, timing analyses on block or character
56308 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
56309 + will be thwarted for unprivileged users. If a process without
56310 + CAP_MKNOD stats such a device, the last access and last modify times
56311 + will match the device's create time. No access or modify events
56312 + will be triggered through inotify/dnotify/fanotify for such devices.
56313 + This feature will prevent attacks that may at a minimum
56314 + allow an attacker to determine the administrator's password length.
56315 +
56316 +config GRKERNSEC_CHROOT
56317 + bool "Chroot jail restrictions"
56318 + default y if GRKERNSEC_CONFIG_AUTO
56319 + help
56320 + If you say Y here, you will be able to choose several options that will
56321 + make breaking out of a chrooted jail much more difficult. If you
56322 + encounter no software incompatibilities with the following options, it
56323 + is recommended that you enable each one.
56324 +
56325 +config GRKERNSEC_CHROOT_MOUNT
56326 + bool "Deny mounts"
56327 + default y if GRKERNSEC_CONFIG_AUTO
56328 + depends on GRKERNSEC_CHROOT
56329 + help
56330 + If you say Y here, processes inside a chroot will not be able to
56331 + mount or remount filesystems. If the sysctl option is enabled, a
56332 + sysctl option with name "chroot_deny_mount" is created.
56333 +
56334 +config GRKERNSEC_CHROOT_DOUBLE
56335 + bool "Deny double-chroots"
56336 + default y if GRKERNSEC_CONFIG_AUTO
56337 + depends on GRKERNSEC_CHROOT
56338 + help
56339 + If you say Y here, processes inside a chroot will not be able to chroot
56340 + again outside the chroot. This is a widely used method of breaking
56341 + out of a chroot jail and should not be allowed. If the sysctl
56342 + option is enabled, a sysctl option with name
56343 + "chroot_deny_chroot" is created.
56344 +
56345 +config GRKERNSEC_CHROOT_PIVOT
56346 + bool "Deny pivot_root in chroot"
56347 + default y if GRKERNSEC_CONFIG_AUTO
56348 + depends on GRKERNSEC_CHROOT
56349 + help
56350 + If you say Y here, processes inside a chroot will not be able to use
56351 + a function called pivot_root() that was introduced in Linux 2.3.41. It
56352 + works similar to chroot in that it changes the root filesystem. This
56353 + function could be misused in a chrooted process to attempt to break out
56354 + of the chroot, and therefore should not be allowed. If the sysctl
56355 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
56356 + created.
56357 +
56358 +config GRKERNSEC_CHROOT_CHDIR
56359 + bool "Enforce chdir(\"/\") on all chroots"
56360 + default y if GRKERNSEC_CONFIG_AUTO
56361 + depends on GRKERNSEC_CHROOT
56362 + help
56363 + If you say Y here, the current working directory of all newly-chrooted
56364 + applications will be set to the the root directory of the chroot.
56365 + The man page on chroot(2) states:
56366 + Note that this call does not change the current working
56367 + directory, so that `.' can be outside the tree rooted at
56368 + `/'. In particular, the super-user can escape from a
56369 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
56370 +
56371 + It is recommended that you say Y here, since it's not known to break
56372 + any software. If the sysctl option is enabled, a sysctl option with
56373 + name "chroot_enforce_chdir" is created.
56374 +
56375 +config GRKERNSEC_CHROOT_CHMOD
56376 + bool "Deny (f)chmod +s"
56377 + default y if GRKERNSEC_CONFIG_AUTO
56378 + depends on GRKERNSEC_CHROOT
56379 + help
56380 + If you say Y here, processes inside a chroot will not be able to chmod
56381 + or fchmod files to make them have suid or sgid bits. This protects
56382 + against another published method of breaking a chroot. If the sysctl
56383 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
56384 + created.
56385 +
56386 +config GRKERNSEC_CHROOT_FCHDIR
56387 + bool "Deny fchdir out of chroot"
56388 + default y if GRKERNSEC_CONFIG_AUTO
56389 + depends on GRKERNSEC_CHROOT
56390 + help
56391 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
56392 + to a file descriptor of the chrooting process that points to a directory
56393 + outside the filesystem will be stopped. If the sysctl option
56394 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
56395 +
56396 +config GRKERNSEC_CHROOT_MKNOD
56397 + bool "Deny mknod"
56398 + default y if GRKERNSEC_CONFIG_AUTO
56399 + depends on GRKERNSEC_CHROOT
56400 + help
56401 + If you say Y here, processes inside a chroot will not be allowed to
56402 + mknod. The problem with using mknod inside a chroot is that it
56403 + would allow an attacker to create a device entry that is the same
56404 + as one on the physical root of your system, which could range from
56405 + anything from the console device to a device for your harddrive (which
56406 + they could then use to wipe the drive or steal data). It is recommended
56407 + that you say Y here, unless you run into software incompatibilities.
56408 + If the sysctl option is enabled, a sysctl option with name
56409 + "chroot_deny_mknod" is created.
56410 +
56411 +config GRKERNSEC_CHROOT_SHMAT
56412 + bool "Deny shmat() out of chroot"
56413 + default y if GRKERNSEC_CONFIG_AUTO
56414 + depends on GRKERNSEC_CHROOT
56415 + help
56416 + If you say Y here, processes inside a chroot will not be able to attach
56417 + to shared memory segments that were created outside of the chroot jail.
56418 + It is recommended that you say Y here. If the sysctl option is enabled,
56419 + a sysctl option with name "chroot_deny_shmat" is created.
56420 +
56421 +config GRKERNSEC_CHROOT_UNIX
56422 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
56423 + default y if GRKERNSEC_CONFIG_AUTO
56424 + depends on GRKERNSEC_CHROOT
56425 + help
56426 + If you say Y here, processes inside a chroot will not be able to
56427 + connect to abstract (meaning not belonging to a filesystem) Unix
56428 + domain sockets that were bound outside of a chroot. It is recommended
56429 + that you say Y here. If the sysctl option is enabled, a sysctl option
56430 + with name "chroot_deny_unix" is created.
56431 +
56432 +config GRKERNSEC_CHROOT_FINDTASK
56433 + bool "Protect outside processes"
56434 + default y if GRKERNSEC_CONFIG_AUTO
56435 + depends on GRKERNSEC_CHROOT
56436 + help
56437 + If you say Y here, processes inside a chroot will not be able to
56438 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
56439 + getsid, or view any process outside of the chroot. If the sysctl
56440 + option is enabled, a sysctl option with name "chroot_findtask" is
56441 + created.
56442 +
56443 +config GRKERNSEC_CHROOT_NICE
56444 + bool "Restrict priority changes"
56445 + default y if GRKERNSEC_CONFIG_AUTO
56446 + depends on GRKERNSEC_CHROOT
56447 + help
56448 + If you say Y here, processes inside a chroot will not be able to raise
56449 + the priority of processes in the chroot, or alter the priority of
56450 + processes outside the chroot. This provides more security than simply
56451 + removing CAP_SYS_NICE from the process' capability set. If the
56452 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
56453 + is created.
56454 +
56455 +config GRKERNSEC_CHROOT_SYSCTL
56456 + bool "Deny sysctl writes"
56457 + default y if GRKERNSEC_CONFIG_AUTO
56458 + depends on GRKERNSEC_CHROOT
56459 + help
56460 + If you say Y here, an attacker in a chroot will not be able to
56461 + write to sysctl entries, either by sysctl(2) or through a /proc
56462 + interface. It is strongly recommended that you say Y here. If the
56463 + sysctl option is enabled, a sysctl option with name
56464 + "chroot_deny_sysctl" is created.
56465 +
56466 +config GRKERNSEC_CHROOT_CAPS
56467 + bool "Capability restrictions"
56468 + default y if GRKERNSEC_CONFIG_AUTO
56469 + depends on GRKERNSEC_CHROOT
56470 + help
56471 + If you say Y here, the capabilities on all processes within a
56472 + chroot jail will be lowered to stop module insertion, raw i/o,
56473 + system and net admin tasks, rebooting the system, modifying immutable
56474 + files, modifying IPC owned by another, and changing the system time.
56475 + This is left an option because it can break some apps. Disable this
56476 + if your chrooted apps are having problems performing those kinds of
56477 + tasks. If the sysctl option is enabled, a sysctl option with
56478 + name "chroot_caps" is created.
56479 +
56480 +config GRKERNSEC_CHROOT_INITRD
56481 + bool "Exempt initrd tasks from restrictions"
56482 + default y if GRKERNSEC_CONFIG_AUTO
56483 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
56484 + help
56485 + If you say Y here, tasks started prior to init will be exempted from
56486 + grsecurity's chroot restrictions. This option is mainly meant to
56487 + resolve Plymouth's performing privileged operations unnecessarily
56488 + in a chroot.
56489 +
56490 +endmenu
56491 +menu "Kernel Auditing"
56492 +depends on GRKERNSEC
56493 +
56494 +config GRKERNSEC_AUDIT_GROUP
56495 + bool "Single group for auditing"
56496 + help
56497 + If you say Y here, the exec and chdir logging features will only operate
56498 + on a group you specify. This option is recommended if you only want to
56499 + watch certain users instead of having a large amount of logs from the
56500 + entire system. If the sysctl option is enabled, a sysctl option with
56501 + name "audit_group" is created.
56502 +
56503 +config GRKERNSEC_AUDIT_GID
56504 + int "GID for auditing"
56505 + depends on GRKERNSEC_AUDIT_GROUP
56506 + default 1007
56507 +
56508 +config GRKERNSEC_EXECLOG
56509 + bool "Exec logging"
56510 + help
56511 + If you say Y here, all execve() calls will be logged (since the
56512 + other exec*() calls are frontends to execve(), all execution
56513 + will be logged). Useful for shell-servers that like to keep track
56514 + of their users. If the sysctl option is enabled, a sysctl option with
56515 + name "exec_logging" is created.
56516 + WARNING: This option when enabled will produce a LOT of logs, especially
56517 + on an active system.
56518 +
56519 +config GRKERNSEC_RESLOG
56520 + bool "Resource logging"
56521 + default y if GRKERNSEC_CONFIG_AUTO
56522 + help
56523 + If you say Y here, all attempts to overstep resource limits will
56524 + be logged with the resource name, the requested size, and the current
56525 + limit. It is highly recommended that you say Y here. If the sysctl
56526 + option is enabled, a sysctl option with name "resource_logging" is
56527 + created. If the RBAC system is enabled, the sysctl value is ignored.
56528 +
56529 +config GRKERNSEC_CHROOT_EXECLOG
56530 + bool "Log execs within chroot"
56531 + help
56532 + If you say Y here, all executions inside a chroot jail will be logged
56533 + to syslog. This can cause a large amount of logs if certain
56534 + applications (eg. djb's daemontools) are installed on the system, and
56535 + is therefore left as an option. If the sysctl option is enabled, a
56536 + sysctl option with name "chroot_execlog" is created.
56537 +
56538 +config GRKERNSEC_AUDIT_PTRACE
56539 + bool "Ptrace logging"
56540 + help
56541 + If you say Y here, all attempts to attach to a process via ptrace
56542 + will be logged. If the sysctl option is enabled, a sysctl option
56543 + with name "audit_ptrace" is created.
56544 +
56545 +config GRKERNSEC_AUDIT_CHDIR
56546 + bool "Chdir logging"
56547 + help
56548 + If you say Y here, all chdir() calls will be logged. If the sysctl
56549 + option is enabled, a sysctl option with name "audit_chdir" is created.
56550 +
56551 +config GRKERNSEC_AUDIT_MOUNT
56552 + bool "(Un)Mount logging"
56553 + help
56554 + If you say Y here, all mounts and unmounts will be logged. If the
56555 + sysctl option is enabled, a sysctl option with name "audit_mount" is
56556 + created.
56557 +
56558 +config GRKERNSEC_SIGNAL
56559 + bool "Signal logging"
56560 + default y if GRKERNSEC_CONFIG_AUTO
56561 + help
56562 + If you say Y here, certain important signals will be logged, such as
56563 + SIGSEGV, which will as a result inform you of when a error in a program
56564 + occurred, which in some cases could mean a possible exploit attempt.
56565 + If the sysctl option is enabled, a sysctl option with name
56566 + "signal_logging" is created.
56567 +
56568 +config GRKERNSEC_FORKFAIL
56569 + bool "Fork failure logging"
56570 + help
56571 + If you say Y here, all failed fork() attempts will be logged.
56572 + This could suggest a fork bomb, or someone attempting to overstep
56573 + their process limit. If the sysctl option is enabled, a sysctl option
56574 + with name "forkfail_logging" is created.
56575 +
56576 +config GRKERNSEC_TIME
56577 + bool "Time change logging"
56578 + default y if GRKERNSEC_CONFIG_AUTO
56579 + help
56580 + If you say Y here, any changes of the system clock will be logged.
56581 + If the sysctl option is enabled, a sysctl option with name
56582 + "timechange_logging" is created.
56583 +
56584 +config GRKERNSEC_PROC_IPADDR
56585 + bool "/proc/<pid>/ipaddr support"
56586 + default y if GRKERNSEC_CONFIG_AUTO
56587 + help
56588 + If you say Y here, a new entry will be added to each /proc/<pid>
56589 + directory that contains the IP address of the person using the task.
56590 + The IP is carried across local TCP and AF_UNIX stream sockets.
56591 + This information can be useful for IDS/IPSes to perform remote response
56592 + to a local attack. The entry is readable by only the owner of the
56593 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
56594 + the RBAC system), and thus does not create privacy concerns.
56595 +
56596 +config GRKERNSEC_RWXMAP_LOG
56597 + bool 'Denied RWX mmap/mprotect logging'
56598 + default y if GRKERNSEC_CONFIG_AUTO
56599 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
56600 + help
56601 + If you say Y here, calls to mmap() and mprotect() with explicit
56602 + usage of PROT_WRITE and PROT_EXEC together will be logged when
56603 + denied by the PAX_MPROTECT feature. If the sysctl option is
56604 + enabled, a sysctl option with name "rwxmap_logging" is created.
56605 +
56606 +config GRKERNSEC_AUDIT_TEXTREL
56607 + bool 'ELF text relocations logging (READ HELP)'
56608 + depends on PAX_MPROTECT
56609 + help
56610 + If you say Y here, text relocations will be logged with the filename
56611 + of the offending library or binary. The purpose of the feature is
56612 + to help Linux distribution developers get rid of libraries and
56613 + binaries that need text relocations which hinder the future progress
56614 + of PaX. Only Linux distribution developers should say Y here, and
56615 + never on a production machine, as this option creates an information
56616 + leak that could aid an attacker in defeating the randomization of
56617 + a single memory region. If the sysctl option is enabled, a sysctl
56618 + option with name "audit_textrel" is created.
56619 +
56620 +endmenu
56621 +
56622 +menu "Executable Protections"
56623 +depends on GRKERNSEC
56624 +
56625 +config GRKERNSEC_DMESG
56626 + bool "Dmesg(8) restriction"
56627 + default y if GRKERNSEC_CONFIG_AUTO
56628 + help
56629 + If you say Y here, non-root users will not be able to use dmesg(8)
56630 + to view the contents of the kernel's circular log buffer.
56631 + The kernel's log buffer often contains kernel addresses and other
56632 + identifying information useful to an attacker in fingerprinting a
56633 + system for a targeted exploit.
56634 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
56635 + created.
56636 +
56637 +config GRKERNSEC_HARDEN_PTRACE
56638 + bool "Deter ptrace-based process snooping"
56639 + default y if GRKERNSEC_CONFIG_AUTO
56640 + help
56641 + If you say Y here, TTY sniffers and other malicious monitoring
56642 + programs implemented through ptrace will be defeated. If you
56643 + have been using the RBAC system, this option has already been
56644 + enabled for several years for all users, with the ability to make
56645 + fine-grained exceptions.
56646 +
56647 + This option only affects the ability of non-root users to ptrace
56648 + processes that are not a descendent of the ptracing process.
56649 + This means that strace ./binary and gdb ./binary will still work,
56650 + but attaching to arbitrary processes will not. If the sysctl
56651 + option is enabled, a sysctl option with name "harden_ptrace" is
56652 + created.
56653 +
56654 +config GRKERNSEC_PTRACE_READEXEC
56655 + bool "Require read access to ptrace sensitive binaries"
56656 + default y if GRKERNSEC_CONFIG_AUTO
56657 + help
56658 + If you say Y here, unprivileged users will not be able to ptrace unreadable
56659 + binaries. This option is useful in environments that
56660 + remove the read bits (e.g. file mode 4711) from suid binaries to
56661 + prevent infoleaking of their contents. This option adds
56662 + consistency to the use of that file mode, as the binary could normally
56663 + be read out when run without privileges while ptracing.
56664 +
56665 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
56666 + is created.
56667 +
56668 +config GRKERNSEC_SETXID
56669 + bool "Enforce consistent multithreaded privileges"
56670 + default y if GRKERNSEC_CONFIG_AUTO
56671 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
56672 + help
56673 + If you say Y here, a change from a root uid to a non-root uid
56674 + in a multithreaded application will cause the resulting uids,
56675 + gids, supplementary groups, and capabilities in that thread
56676 + to be propagated to the other threads of the process. In most
56677 + cases this is unnecessary, as glibc will emulate this behavior
56678 + on behalf of the application. Other libcs do not act in the
56679 + same way, allowing the other threads of the process to continue
56680 + running with root privileges. If the sysctl option is enabled,
56681 + a sysctl option with name "consistent_setxid" is created.
56682 +
56683 +config GRKERNSEC_TPE
56684 + bool "Trusted Path Execution (TPE)"
56685 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
56686 + help
56687 + If you say Y here, you will be able to choose a gid to add to the
56688 + supplementary groups of users you want to mark as "untrusted."
56689 + These users will not be able to execute any files that are not in
56690 + root-owned directories writable only by root. If the sysctl option
56691 + is enabled, a sysctl option with name "tpe" is created.
56692 +
56693 +config GRKERNSEC_TPE_ALL
56694 + bool "Partially restrict all non-root users"
56695 + depends on GRKERNSEC_TPE
56696 + help
56697 + If you say Y here, all non-root users will be covered under
56698 + a weaker TPE restriction. This is separate from, and in addition to,
56699 + the main TPE options that you have selected elsewhere. Thus, if a
56700 + "trusted" GID is chosen, this restriction applies to even that GID.
56701 + Under this restriction, all non-root users will only be allowed to
56702 + execute files in directories they own that are not group or
56703 + world-writable, or in directories owned by root and writable only by
56704 + root. If the sysctl option is enabled, a sysctl option with name
56705 + "tpe_restrict_all" is created.
56706 +
56707 +config GRKERNSEC_TPE_INVERT
56708 + bool "Invert GID option"
56709 + depends on GRKERNSEC_TPE
56710 + help
56711 + If you say Y here, the group you specify in the TPE configuration will
56712 + decide what group TPE restrictions will be *disabled* for. This
56713 + option is useful if you want TPE restrictions to be applied to most
56714 + users on the system. If the sysctl option is enabled, a sysctl option
56715 + with name "tpe_invert" is created. Unlike other sysctl options, this
56716 + entry will default to on for backward-compatibility.
56717 +
56718 +config GRKERNSEC_TPE_GID
56719 + int
56720 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
56721 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
56722 +
56723 +config GRKERNSEC_TPE_UNTRUSTED_GID
56724 + int "GID for TPE-untrusted users"
56725 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
56726 + default 1005
56727 + help
56728 + Setting this GID determines what group TPE restrictions will be
56729 + *enabled* for. If the sysctl option is enabled, a sysctl option
56730 + with name "tpe_gid" is created.
56731 +
56732 +config GRKERNSEC_TPE_TRUSTED_GID
56733 + int "GID for TPE-trusted users"
56734 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
56735 + default 1005
56736 + help
56737 + Setting this GID determines what group TPE restrictions will be
56738 + *disabled* for. If the sysctl option is enabled, a sysctl option
56739 + with name "tpe_gid" is created.
56740 +
56741 +endmenu
56742 +menu "Network Protections"
56743 +depends on GRKERNSEC
56744 +
56745 +config GRKERNSEC_RANDNET
56746 + bool "Larger entropy pools"
56747 + default y if GRKERNSEC_CONFIG_AUTO
56748 + help
56749 + If you say Y here, the entropy pools used for many features of Linux
56750 + and grsecurity will be doubled in size. Since several grsecurity
56751 + features use additional randomness, it is recommended that you say Y
56752 + here. Saying Y here has a similar effect as modifying
56753 + /proc/sys/kernel/random/poolsize.
56754 +
56755 +config GRKERNSEC_BLACKHOLE
56756 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
56757 + default y if GRKERNSEC_CONFIG_AUTO
56758 + depends on NET
56759 + help
56760 + If you say Y here, neither TCP resets nor ICMP
56761 + destination-unreachable packets will be sent in response to packets
56762 + sent to ports for which no associated listening process exists.
56763 + This feature supports both IPV4 and IPV6 and exempts the
56764 + loopback interface from blackholing. Enabling this feature
56765 + makes a host more resilient to DoS attacks and reduces network
56766 + visibility against scanners.
56767 +
56768 + The blackhole feature as-implemented is equivalent to the FreeBSD
56769 + blackhole feature, as it prevents RST responses to all packets, not
56770 + just SYNs. Under most application behavior this causes no
56771 + problems, but applications (like haproxy) may not close certain
56772 + connections in a way that cleanly terminates them on the remote
56773 + end, leaving the remote host in LAST_ACK state. Because of this
56774 + side-effect and to prevent intentional LAST_ACK DoSes, this
56775 + feature also adds automatic mitigation against such attacks.
56776 + The mitigation drastically reduces the amount of time a socket
56777 + can spend in LAST_ACK state. If you're using haproxy and not
56778 + all servers it connects to have this option enabled, consider
56779 + disabling this feature on the haproxy host.
56780 +
56781 + If the sysctl option is enabled, two sysctl options with names
56782 + "ip_blackhole" and "lastack_retries" will be created.
56783 + While "ip_blackhole" takes the standard zero/non-zero on/off
56784 + toggle, "lastack_retries" uses the same kinds of values as
56785 + "tcp_retries1" and "tcp_retries2". The default value of 4
56786 + prevents a socket from lasting more than 45 seconds in LAST_ACK
56787 + state.
56788 +
56789 +config GRKERNSEC_NO_SIMULT_CONNECT
56790 + bool "Disable TCP Simultaneous Connect"
56791 + default y if GRKERNSEC_CONFIG_AUTO
56792 + depends on NET
56793 + help
56794 + If you say Y here, a feature by Willy Tarreau will be enabled that
56795 + removes a weakness in Linux's strict implementation of TCP that
56796 + allows two clients to connect to each other without either entering
56797 + a listening state. The weakness allows an attacker to easily prevent
56798 + a client from connecting to a known server provided the source port
56799 + for the connection is guessed correctly.
56800 +
56801 + As the weakness could be used to prevent an antivirus or IPS from
56802 + fetching updates, or prevent an SSL gateway from fetching a CRL,
56803 + it should be eliminated by enabling this option. Though Linux is
56804 + one of few operating systems supporting simultaneous connect, it
56805 + has no legitimate use in practice and is rarely supported by firewalls.
56806 +
56807 +config GRKERNSEC_SOCKET
56808 + bool "Socket restrictions"
56809 + depends on NET
56810 + help
56811 + If you say Y here, you will be able to choose from several options.
56812 + If you assign a GID on your system and add it to the supplementary
56813 + groups of users you want to restrict socket access to, this patch
56814 + will perform up to three things, based on the option(s) you choose.
56815 +
56816 +config GRKERNSEC_SOCKET_ALL
56817 + bool "Deny any sockets to group"
56818 + depends on GRKERNSEC_SOCKET
56819 + help
56820 + If you say Y here, you will be able to choose a GID of whose users will
56821 + be unable to connect to other hosts from your machine or run server
56822 + applications from your machine. If the sysctl option is enabled, a
56823 + sysctl option with name "socket_all" is created.
56824 +
56825 +config GRKERNSEC_SOCKET_ALL_GID
56826 + int "GID to deny all sockets for"
56827 + depends on GRKERNSEC_SOCKET_ALL
56828 + default 1004
56829 + help
56830 + Here you can choose the GID to disable socket access for. Remember to
56831 + add the users you want socket access disabled for to the GID
56832 + specified here. If the sysctl option is enabled, a sysctl option
56833 + with name "socket_all_gid" is created.
56834 +
56835 +config GRKERNSEC_SOCKET_CLIENT
56836 + bool "Deny client sockets to group"
56837 + depends on GRKERNSEC_SOCKET
56838 + help
56839 + If you say Y here, you will be able to choose a GID of whose users will
56840 + be unable to connect to other hosts from your machine, but will be
56841 + able to run servers. If this option is enabled, all users in the group
56842 + you specify will have to use passive mode when initiating ftp transfers
56843 + from the shell on your machine. If the sysctl option is enabled, a
56844 + sysctl option with name "socket_client" is created.
56845 +
56846 +config GRKERNSEC_SOCKET_CLIENT_GID
56847 + int "GID to deny client sockets for"
56848 + depends on GRKERNSEC_SOCKET_CLIENT
56849 + default 1003
56850 + help
56851 + Here you can choose the GID to disable client socket access for.
56852 + Remember to add the users you want client socket access disabled for to
56853 + the GID specified here. If the sysctl option is enabled, a sysctl
56854 + option with name "socket_client_gid" is created.
56855 +
56856 +config GRKERNSEC_SOCKET_SERVER
56857 + bool "Deny server sockets to group"
56858 + depends on GRKERNSEC_SOCKET
56859 + help
56860 + If you say Y here, you will be able to choose a GID of whose users will
56861 + be unable to run server applications from your machine. If the sysctl
56862 + option is enabled, a sysctl option with name "socket_server" is created.
56863 +
56864 +config GRKERNSEC_SOCKET_SERVER_GID
56865 + int "GID to deny server sockets for"
56866 + depends on GRKERNSEC_SOCKET_SERVER
56867 + default 1002
56868 + help
56869 + Here you can choose the GID to disable server socket access for.
56870 + Remember to add the users you want server socket access disabled for to
56871 + the GID specified here. If the sysctl option is enabled, a sysctl
56872 + option with name "socket_server_gid" is created.
56873 +
56874 +endmenu
56875 +menu "Sysctl Support"
56876 +depends on GRKERNSEC && SYSCTL
56877 +
56878 +config GRKERNSEC_SYSCTL
56879 + bool "Sysctl support"
56880 + default y if GRKERNSEC_CONFIG_AUTO
56881 + help
56882 + If you say Y here, you will be able to change the options that
56883 + grsecurity runs with at bootup, without having to recompile your
56884 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
56885 + to enable (1) or disable (0) various features. All the sysctl entries
56886 + are mutable until the "grsec_lock" entry is set to a non-zero value.
56887 + All features enabled in the kernel configuration are disabled at boot
56888 + if you do not say Y to the "Turn on features by default" option.
56889 + All options should be set at startup, and the grsec_lock entry should
56890 + be set to a non-zero value after all the options are set.
56891 + *THIS IS EXTREMELY IMPORTANT*
56892 +
56893 +config GRKERNSEC_SYSCTL_DISTRO
56894 + bool "Extra sysctl support for distro makers (READ HELP)"
56895 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
56896 + help
56897 + If you say Y here, additional sysctl options will be created
56898 + for features that affect processes running as root. Therefore,
56899 + it is critical when using this option that the grsec_lock entry be
56900 + enabled after boot. Only distros with prebuilt kernel packages
56901 + with this option enabled that can ensure grsec_lock is enabled
56902 + after boot should use this option.
56903 + *Failure to set grsec_lock after boot makes all grsec features
56904 + this option covers useless*
56905 +
56906 + Currently this option creates the following sysctl entries:
56907 + "Disable Privileged I/O": "disable_priv_io"
56908 +
56909 +config GRKERNSEC_SYSCTL_ON
56910 + bool "Turn on features by default"
56911 + default y if GRKERNSEC_CONFIG_AUTO
56912 + depends on GRKERNSEC_SYSCTL
56913 + help
56914 + If you say Y here, instead of having all features enabled in the
56915 + kernel configuration disabled at boot time, the features will be
56916 + enabled at boot time. It is recommended you say Y here unless
56917 + there is some reason you would want all sysctl-tunable features to
56918 + be disabled by default. As mentioned elsewhere, it is important
56919 + to enable the grsec_lock entry once you have finished modifying
56920 + the sysctl entries.
56921 +
56922 +endmenu
56923 +menu "Logging Options"
56924 +depends on GRKERNSEC
56925 +
56926 +config GRKERNSEC_FLOODTIME
56927 + int "Seconds in between log messages (minimum)"
56928 + default 10
56929 + help
56930 + This option allows you to enforce the number of seconds between
56931 + grsecurity log messages. The default should be suitable for most
56932 + people, however, if you choose to change it, choose a value small enough
56933 + to allow informative logs to be produced, but large enough to
56934 + prevent flooding.
56935 +
56936 +config GRKERNSEC_FLOODBURST
56937 + int "Number of messages in a burst (maximum)"
56938 + default 6
56939 + help
56940 + This option allows you to choose the maximum number of messages allowed
56941 + within the flood time interval you chose in a separate option. The
56942 + default should be suitable for most people, however if you find that
56943 + many of your logs are being interpreted as flooding, you may want to
56944 + raise this value.
56945 +
56946 +endmenu
56947 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
56948 new file mode 100644
56949 index 0000000..1b9afa9
56950 --- /dev/null
56951 +++ b/grsecurity/Makefile
56952 @@ -0,0 +1,38 @@
56953 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
56954 +# during 2001-2009 it has been completely redesigned by Brad Spengler
56955 +# into an RBAC system
56956 +#
56957 +# All code in this directory and various hooks inserted throughout the kernel
56958 +# are copyright Brad Spengler - Open Source Security, Inc., and released
56959 +# under the GPL v2 or higher
56960 +
56961 +KBUILD_CFLAGS += -Werror
56962 +
56963 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
56964 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
56965 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
56966 +
56967 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
56968 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
56969 + gracl_learn.o grsec_log.o
56970 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
56971 +
56972 +ifdef CONFIG_NET
56973 +obj-y += grsec_sock.o
56974 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
56975 +endif
56976 +
56977 +ifndef CONFIG_GRKERNSEC
56978 +obj-y += grsec_disabled.o
56979 +endif
56980 +
56981 +ifdef CONFIG_GRKERNSEC_HIDESYM
56982 +extra-y := grsec_hidesym.o
56983 +$(obj)/grsec_hidesym.o:
56984 + @-chmod -f 500 /boot
56985 + @-chmod -f 500 /lib/modules
56986 + @-chmod -f 500 /lib64/modules
56987 + @-chmod -f 500 /lib32/modules
56988 + @-chmod -f 700 .
56989 + @echo ' grsec: protected kernel image paths'
56990 +endif
56991 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
56992 new file mode 100644
56993 index 0000000..1248ee0
56994 --- /dev/null
56995 +++ b/grsecurity/gracl.c
56996 @@ -0,0 +1,4073 @@
56997 +#include <linux/kernel.h>
56998 +#include <linux/module.h>
56999 +#include <linux/sched.h>
57000 +#include <linux/mm.h>
57001 +#include <linux/file.h>
57002 +#include <linux/fs.h>
57003 +#include <linux/namei.h>
57004 +#include <linux/mount.h>
57005 +#include <linux/tty.h>
57006 +#include <linux/proc_fs.h>
57007 +#include <linux/lglock.h>
57008 +#include <linux/slab.h>
57009 +#include <linux/vmalloc.h>
57010 +#include <linux/types.h>
57011 +#include <linux/sysctl.h>
57012 +#include <linux/netdevice.h>
57013 +#include <linux/ptrace.h>
57014 +#include <linux/gracl.h>
57015 +#include <linux/gralloc.h>
57016 +#include <linux/security.h>
57017 +#include <linux/grinternal.h>
57018 +#include <linux/pid_namespace.h>
57019 +#include <linux/stop_machine.h>
57020 +#include <linux/fdtable.h>
57021 +#include <linux/percpu.h>
57022 +#include <linux/lglock.h>
57023 +#include <linux/hugetlb.h>
57024 +#include <linux/posix-timers.h>
57025 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
57026 +#include <linux/magic.h>
57027 +#include <linux/pagemap.h>
57028 +#include "../fs/btrfs/async-thread.h"
57029 +#include "../fs/btrfs/ctree.h"
57030 +#include "../fs/btrfs/btrfs_inode.h"
57031 +#endif
57032 +#include "../fs/mount.h"
57033 +
57034 +#include <asm/uaccess.h>
57035 +#include <asm/errno.h>
57036 +#include <asm/mman.h>
57037 +
57038 +extern struct lglock vfsmount_lock;
57039 +
57040 +static struct acl_role_db acl_role_set;
57041 +static struct name_db name_set;
57042 +static struct inodev_db inodev_set;
57043 +
57044 +/* for keeping track of userspace pointers used for subjects, so we
57045 + can share references in the kernel as well
57046 +*/
57047 +
57048 +static struct path real_root;
57049 +
57050 +static struct acl_subj_map_db subj_map_set;
57051 +
57052 +static struct acl_role_label *default_role;
57053 +
57054 +static struct acl_role_label *role_list;
57055 +
57056 +static u16 acl_sp_role_value;
57057 +
57058 +extern char *gr_shared_page[4];
57059 +static DEFINE_MUTEX(gr_dev_mutex);
57060 +DEFINE_RWLOCK(gr_inode_lock);
57061 +
57062 +struct gr_arg *gr_usermode;
57063 +
57064 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
57065 +
57066 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
57067 +extern void gr_clear_learn_entries(void);
57068 +
57069 +unsigned char *gr_system_salt;
57070 +unsigned char *gr_system_sum;
57071 +
57072 +static struct sprole_pw **acl_special_roles = NULL;
57073 +static __u16 num_sprole_pws = 0;
57074 +
57075 +static struct acl_role_label *kernel_role = NULL;
57076 +
57077 +static unsigned int gr_auth_attempts = 0;
57078 +static unsigned long gr_auth_expires = 0UL;
57079 +
57080 +#ifdef CONFIG_NET
57081 +extern struct vfsmount *sock_mnt;
57082 +#endif
57083 +
57084 +extern struct vfsmount *pipe_mnt;
57085 +extern struct vfsmount *shm_mnt;
57086 +
57087 +#ifdef CONFIG_HUGETLBFS
57088 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57089 +#endif
57090 +
57091 +static struct acl_object_label *fakefs_obj_rw;
57092 +static struct acl_object_label *fakefs_obj_rwx;
57093 +
57094 +extern int gr_init_uidset(void);
57095 +extern void gr_free_uidset(void);
57096 +extern void gr_remove_uid(uid_t uid);
57097 +extern int gr_find_uid(uid_t uid);
57098 +
57099 +__inline__ int
57100 +gr_acl_is_enabled(void)
57101 +{
57102 + return (gr_status & GR_READY);
57103 +}
57104 +
57105 +static inline dev_t __get_dev(const struct dentry *dentry)
57106 +{
57107 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
57108 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
57109 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
57110 + else
57111 +#endif
57112 + return dentry->d_sb->s_dev;
57113 +}
57114 +
57115 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
57116 +{
57117 + return __get_dev(dentry);
57118 +}
57119 +
57120 +static char gr_task_roletype_to_char(struct task_struct *task)
57121 +{
57122 + switch (task->role->roletype &
57123 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
57124 + GR_ROLE_SPECIAL)) {
57125 + case GR_ROLE_DEFAULT:
57126 + return 'D';
57127 + case GR_ROLE_USER:
57128 + return 'U';
57129 + case GR_ROLE_GROUP:
57130 + return 'G';
57131 + case GR_ROLE_SPECIAL:
57132 + return 'S';
57133 + }
57134 +
57135 + return 'X';
57136 +}
57137 +
57138 +char gr_roletype_to_char(void)
57139 +{
57140 + return gr_task_roletype_to_char(current);
57141 +}
57142 +
57143 +__inline__ int
57144 +gr_acl_tpe_check(void)
57145 +{
57146 + if (unlikely(!(gr_status & GR_READY)))
57147 + return 0;
57148 + if (current->role->roletype & GR_ROLE_TPE)
57149 + return 1;
57150 + else
57151 + return 0;
57152 +}
57153 +
57154 +int
57155 +gr_handle_rawio(const struct inode *inode)
57156 +{
57157 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
57158 + if (inode && S_ISBLK(inode->i_mode) &&
57159 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
57160 + !capable(CAP_SYS_RAWIO))
57161 + return 1;
57162 +#endif
57163 + return 0;
57164 +}
57165 +
57166 +static int
57167 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
57168 +{
57169 + if (likely(lena != lenb))
57170 + return 0;
57171 +
57172 + return !memcmp(a, b, lena);
57173 +}
57174 +
57175 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
57176 +{
57177 + *buflen -= namelen;
57178 + if (*buflen < 0)
57179 + return -ENAMETOOLONG;
57180 + *buffer -= namelen;
57181 + memcpy(*buffer, str, namelen);
57182 + return 0;
57183 +}
57184 +
57185 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
57186 +{
57187 + return prepend(buffer, buflen, name->name, name->len);
57188 +}
57189 +
57190 +static int prepend_path(const struct path *path, struct path *root,
57191 + char **buffer, int *buflen)
57192 +{
57193 + struct dentry *dentry = path->dentry;
57194 + struct vfsmount *vfsmnt = path->mnt;
57195 + struct mount *mnt = real_mount(vfsmnt);
57196 + bool slash = false;
57197 + int error = 0;
57198 +
57199 + while (dentry != root->dentry || vfsmnt != root->mnt) {
57200 + struct dentry * parent;
57201 +
57202 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
57203 + /* Global root? */
57204 + if (!mnt_has_parent(mnt)) {
57205 + goto out;
57206 + }
57207 + dentry = mnt->mnt_mountpoint;
57208 + mnt = mnt->mnt_parent;
57209 + vfsmnt = &mnt->mnt;
57210 + continue;
57211 + }
57212 + parent = dentry->d_parent;
57213 + prefetch(parent);
57214 + spin_lock(&dentry->d_lock);
57215 + error = prepend_name(buffer, buflen, &dentry->d_name);
57216 + spin_unlock(&dentry->d_lock);
57217 + if (!error)
57218 + error = prepend(buffer, buflen, "/", 1);
57219 + if (error)
57220 + break;
57221 +
57222 + slash = true;
57223 + dentry = parent;
57224 + }
57225 +
57226 +out:
57227 + if (!error && !slash)
57228 + error = prepend(buffer, buflen, "/", 1);
57229 +
57230 + return error;
57231 +}
57232 +
57233 +/* this must be called with vfsmount_lock and rename_lock held */
57234 +
57235 +static char *__our_d_path(const struct path *path, struct path *root,
57236 + char *buf, int buflen)
57237 +{
57238 + char *res = buf + buflen;
57239 + int error;
57240 +
57241 + prepend(&res, &buflen, "\0", 1);
57242 + error = prepend_path(path, root, &res, &buflen);
57243 + if (error)
57244 + return ERR_PTR(error);
57245 +
57246 + return res;
57247 +}
57248 +
57249 +static char *
57250 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
57251 +{
57252 + char *retval;
57253 +
57254 + retval = __our_d_path(path, root, buf, buflen);
57255 + if (unlikely(IS_ERR(retval)))
57256 + retval = strcpy(buf, "<path too long>");
57257 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
57258 + retval[1] = '\0';
57259 +
57260 + return retval;
57261 +}
57262 +
57263 +static char *
57264 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
57265 + char *buf, int buflen)
57266 +{
57267 + struct path path;
57268 + char *res;
57269 +
57270 + path.dentry = (struct dentry *)dentry;
57271 + path.mnt = (struct vfsmount *)vfsmnt;
57272 +
57273 + /* we can use real_root.dentry, real_root.mnt, because this is only called
57274 + by the RBAC system */
57275 + res = gen_full_path(&path, &real_root, buf, buflen);
57276 +
57277 + return res;
57278 +}
57279 +
57280 +static char *
57281 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
57282 + char *buf, int buflen)
57283 +{
57284 + char *res;
57285 + struct path path;
57286 + struct path root;
57287 + struct task_struct *reaper = init_pid_ns.child_reaper;
57288 +
57289 + path.dentry = (struct dentry *)dentry;
57290 + path.mnt = (struct vfsmount *)vfsmnt;
57291 +
57292 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
57293 + get_fs_root(reaper->fs, &root);
57294 +
57295 + br_read_lock(&vfsmount_lock);
57296 + write_seqlock(&rename_lock);
57297 + res = gen_full_path(&path, &root, buf, buflen);
57298 + write_sequnlock(&rename_lock);
57299 + br_read_unlock(&vfsmount_lock);
57300 +
57301 + path_put(&root);
57302 + return res;
57303 +}
57304 +
57305 +static char *
57306 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
57307 +{
57308 + char *ret;
57309 + br_read_lock(&vfsmount_lock);
57310 + write_seqlock(&rename_lock);
57311 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
57312 + PAGE_SIZE);
57313 + write_sequnlock(&rename_lock);
57314 + br_read_unlock(&vfsmount_lock);
57315 + return ret;
57316 +}
57317 +
57318 +static char *
57319 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
57320 +{
57321 + char *ret;
57322 + char *buf;
57323 + int buflen;
57324 +
57325 + br_read_lock(&vfsmount_lock);
57326 + write_seqlock(&rename_lock);
57327 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
57328 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
57329 + buflen = (int)(ret - buf);
57330 + if (buflen >= 5)
57331 + prepend(&ret, &buflen, "/proc", 5);
57332 + else
57333 + ret = strcpy(buf, "<path too long>");
57334 + write_sequnlock(&rename_lock);
57335 + br_read_unlock(&vfsmount_lock);
57336 + return ret;
57337 +}
57338 +
57339 +char *
57340 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
57341 +{
57342 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
57343 + PAGE_SIZE);
57344 +}
57345 +
57346 +char *
57347 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
57348 +{
57349 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
57350 + PAGE_SIZE);
57351 +}
57352 +
57353 +char *
57354 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
57355 +{
57356 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
57357 + PAGE_SIZE);
57358 +}
57359 +
57360 +char *
57361 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
57362 +{
57363 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
57364 + PAGE_SIZE);
57365 +}
57366 +
57367 +char *
57368 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
57369 +{
57370 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
57371 + PAGE_SIZE);
57372 +}
57373 +
57374 +__inline__ __u32
57375 +to_gr_audit(const __u32 reqmode)
57376 +{
57377 + /* masks off auditable permission flags, then shifts them to create
57378 + auditing flags, and adds the special case of append auditing if
57379 + we're requesting write */
57380 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
57381 +}
57382 +
57383 +struct acl_subject_label *
57384 +lookup_subject_map(const struct acl_subject_label *userp)
57385 +{
57386 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
57387 + struct subject_map *match;
57388 +
57389 + match = subj_map_set.s_hash[index];
57390 +
57391 + while (match && match->user != userp)
57392 + match = match->next;
57393 +
57394 + if (match != NULL)
57395 + return match->kernel;
57396 + else
57397 + return NULL;
57398 +}
57399 +
57400 +static void
57401 +insert_subj_map_entry(struct subject_map *subjmap)
57402 +{
57403 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
57404 + struct subject_map **curr;
57405 +
57406 + subjmap->prev = NULL;
57407 +
57408 + curr = &subj_map_set.s_hash[index];
57409 + if (*curr != NULL)
57410 + (*curr)->prev = subjmap;
57411 +
57412 + subjmap->next = *curr;
57413 + *curr = subjmap;
57414 +
57415 + return;
57416 +}
57417 +
57418 +static struct acl_role_label *
57419 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
57420 + const gid_t gid)
57421 +{
57422 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
57423 + struct acl_role_label *match;
57424 + struct role_allowed_ip *ipp;
57425 + unsigned int x;
57426 + u32 curr_ip = task->signal->curr_ip;
57427 +
57428 + task->signal->saved_ip = curr_ip;
57429 +
57430 + match = acl_role_set.r_hash[index];
57431 +
57432 + while (match) {
57433 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
57434 + for (x = 0; x < match->domain_child_num; x++) {
57435 + if (match->domain_children[x] == uid)
57436 + goto found;
57437 + }
57438 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
57439 + break;
57440 + match = match->next;
57441 + }
57442 +found:
57443 + if (match == NULL) {
57444 + try_group:
57445 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
57446 + match = acl_role_set.r_hash[index];
57447 +
57448 + while (match) {
57449 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
57450 + for (x = 0; x < match->domain_child_num; x++) {
57451 + if (match->domain_children[x] == gid)
57452 + goto found2;
57453 + }
57454 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
57455 + break;
57456 + match = match->next;
57457 + }
57458 +found2:
57459 + if (match == NULL)
57460 + match = default_role;
57461 + if (match->allowed_ips == NULL)
57462 + return match;
57463 + else {
57464 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
57465 + if (likely
57466 + ((ntohl(curr_ip) & ipp->netmask) ==
57467 + (ntohl(ipp->addr) & ipp->netmask)))
57468 + return match;
57469 + }
57470 + match = default_role;
57471 + }
57472 + } else if (match->allowed_ips == NULL) {
57473 + return match;
57474 + } else {
57475 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
57476 + if (likely
57477 + ((ntohl(curr_ip) & ipp->netmask) ==
57478 + (ntohl(ipp->addr) & ipp->netmask)))
57479 + return match;
57480 + }
57481 + goto try_group;
57482 + }
57483 +
57484 + return match;
57485 +}
57486 +
57487 +struct acl_subject_label *
57488 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
57489 + const struct acl_role_label *role)
57490 +{
57491 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
57492 + struct acl_subject_label *match;
57493 +
57494 + match = role->subj_hash[index];
57495 +
57496 + while (match && (match->inode != ino || match->device != dev ||
57497 + (match->mode & GR_DELETED))) {
57498 + match = match->next;
57499 + }
57500 +
57501 + if (match && !(match->mode & GR_DELETED))
57502 + return match;
57503 + else
57504 + return NULL;
57505 +}
57506 +
57507 +struct acl_subject_label *
57508 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
57509 + const struct acl_role_label *role)
57510 +{
57511 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
57512 + struct acl_subject_label *match;
57513 +
57514 + match = role->subj_hash[index];
57515 +
57516 + while (match && (match->inode != ino || match->device != dev ||
57517 + !(match->mode & GR_DELETED))) {
57518 + match = match->next;
57519 + }
57520 +
57521 + if (match && (match->mode & GR_DELETED))
57522 + return match;
57523 + else
57524 + return NULL;
57525 +}
57526 +
57527 +static struct acl_object_label *
57528 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
57529 + const struct acl_subject_label *subj)
57530 +{
57531 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
57532 + struct acl_object_label *match;
57533 +
57534 + match = subj->obj_hash[index];
57535 +
57536 + while (match && (match->inode != ino || match->device != dev ||
57537 + (match->mode & GR_DELETED))) {
57538 + match = match->next;
57539 + }
57540 +
57541 + if (match && !(match->mode & GR_DELETED))
57542 + return match;
57543 + else
57544 + return NULL;
57545 +}
57546 +
57547 +static struct acl_object_label *
57548 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
57549 + const struct acl_subject_label *subj)
57550 +{
57551 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
57552 + struct acl_object_label *match;
57553 +
57554 + match = subj->obj_hash[index];
57555 +
57556 + while (match && (match->inode != ino || match->device != dev ||
57557 + !(match->mode & GR_DELETED))) {
57558 + match = match->next;
57559 + }
57560 +
57561 + if (match && (match->mode & GR_DELETED))
57562 + return match;
57563 +
57564 + match = subj->obj_hash[index];
57565 +
57566 + while (match && (match->inode != ino || match->device != dev ||
57567 + (match->mode & GR_DELETED))) {
57568 + match = match->next;
57569 + }
57570 +
57571 + if (match && !(match->mode & GR_DELETED))
57572 + return match;
57573 + else
57574 + return NULL;
57575 +}
57576 +
57577 +static struct name_entry *
57578 +lookup_name_entry(const char *name)
57579 +{
57580 + unsigned int len = strlen(name);
57581 + unsigned int key = full_name_hash(name, len);
57582 + unsigned int index = key % name_set.n_size;
57583 + struct name_entry *match;
57584 +
57585 + match = name_set.n_hash[index];
57586 +
57587 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
57588 + match = match->next;
57589 +
57590 + return match;
57591 +}
57592 +
57593 +static struct name_entry *
57594 +lookup_name_entry_create(const char *name)
57595 +{
57596 + unsigned int len = strlen(name);
57597 + unsigned int key = full_name_hash(name, len);
57598 + unsigned int index = key % name_set.n_size;
57599 + struct name_entry *match;
57600 +
57601 + match = name_set.n_hash[index];
57602 +
57603 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
57604 + !match->deleted))
57605 + match = match->next;
57606 +
57607 + if (match && match->deleted)
57608 + return match;
57609 +
57610 + match = name_set.n_hash[index];
57611 +
57612 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
57613 + match->deleted))
57614 + match = match->next;
57615 +
57616 + if (match && !match->deleted)
57617 + return match;
57618 + else
57619 + return NULL;
57620 +}
57621 +
57622 +static struct inodev_entry *
57623 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
57624 +{
57625 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
57626 + struct inodev_entry *match;
57627 +
57628 + match = inodev_set.i_hash[index];
57629 +
57630 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
57631 + match = match->next;
57632 +
57633 + return match;
57634 +}
57635 +
57636 +static void
57637 +insert_inodev_entry(struct inodev_entry *entry)
57638 +{
57639 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
57640 + inodev_set.i_size);
57641 + struct inodev_entry **curr;
57642 +
57643 + entry->prev = NULL;
57644 +
57645 + curr = &inodev_set.i_hash[index];
57646 + if (*curr != NULL)
57647 + (*curr)->prev = entry;
57648 +
57649 + entry->next = *curr;
57650 + *curr = entry;
57651 +
57652 + return;
57653 +}
57654 +
57655 +static void
57656 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
57657 +{
57658 + unsigned int index =
57659 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
57660 + struct acl_role_label **curr;
57661 + struct acl_role_label *tmp, *tmp2;
57662 +
57663 + curr = &acl_role_set.r_hash[index];
57664 +
57665 + /* simple case, slot is empty, just set it to our role */
57666 + if (*curr == NULL) {
57667 + *curr = role;
57668 + } else {
57669 + /* example:
57670 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
57671 + 2 -> 3
57672 + */
57673 + /* first check to see if we can already be reached via this slot */
57674 + tmp = *curr;
57675 + while (tmp && tmp != role)
57676 + tmp = tmp->next;
57677 + if (tmp == role) {
57678 + /* we don't need to add ourselves to this slot's chain */
57679 + return;
57680 + }
57681 + /* we need to add ourselves to this chain, two cases */
57682 + if (role->next == NULL) {
57683 + /* simple case, append the current chain to our role */
57684 + role->next = *curr;
57685 + *curr = role;
57686 + } else {
57687 + /* 1 -> 2 -> 3 -> 4
57688 + 2 -> 3 -> 4
57689 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
57690 + */
57691 + /* trickier case: walk our role's chain until we find
57692 + the role for the start of the current slot's chain */
57693 + tmp = role;
57694 + tmp2 = *curr;
57695 + while (tmp->next && tmp->next != tmp2)
57696 + tmp = tmp->next;
57697 + if (tmp->next == tmp2) {
57698 + /* from example above, we found 3, so just
57699 + replace this slot's chain with ours */
57700 + *curr = role;
57701 + } else {
57702 + /* we didn't find a subset of our role's chain
57703 + in the current slot's chain, so append their
57704 + chain to ours, and set us as the first role in
57705 + the slot's chain
57706 +
57707 + we could fold this case with the case above,
57708 + but making it explicit for clarity
57709 + */
57710 + tmp->next = tmp2;
57711 + *curr = role;
57712 + }
57713 + }
57714 + }
57715 +
57716 + return;
57717 +}
57718 +
57719 +static void
57720 +insert_acl_role_label(struct acl_role_label *role)
57721 +{
57722 + int i;
57723 +
57724 + if (role_list == NULL) {
57725 + role_list = role;
57726 + role->prev = NULL;
57727 + } else {
57728 + role->prev = role_list;
57729 + role_list = role;
57730 + }
57731 +
57732 + /* used for hash chains */
57733 + role->next = NULL;
57734 +
57735 + if (role->roletype & GR_ROLE_DOMAIN) {
57736 + for (i = 0; i < role->domain_child_num; i++)
57737 + __insert_acl_role_label(role, role->domain_children[i]);
57738 + } else
57739 + __insert_acl_role_label(role, role->uidgid);
57740 +}
57741 +
57742 +static int
57743 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
57744 +{
57745 + struct name_entry **curr, *nentry;
57746 + struct inodev_entry *ientry;
57747 + unsigned int len = strlen(name);
57748 + unsigned int key = full_name_hash(name, len);
57749 + unsigned int index = key % name_set.n_size;
57750 +
57751 + curr = &name_set.n_hash[index];
57752 +
57753 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
57754 + curr = &((*curr)->next);
57755 +
57756 + if (*curr != NULL)
57757 + return 1;
57758 +
57759 + nentry = acl_alloc(sizeof (struct name_entry));
57760 + if (nentry == NULL)
57761 + return 0;
57762 + ientry = acl_alloc(sizeof (struct inodev_entry));
57763 + if (ientry == NULL)
57764 + return 0;
57765 + ientry->nentry = nentry;
57766 +
57767 + nentry->key = key;
57768 + nentry->name = name;
57769 + nentry->inode = inode;
57770 + nentry->device = device;
57771 + nentry->len = len;
57772 + nentry->deleted = deleted;
57773 +
57774 + nentry->prev = NULL;
57775 + curr = &name_set.n_hash[index];
57776 + if (*curr != NULL)
57777 + (*curr)->prev = nentry;
57778 + nentry->next = *curr;
57779 + *curr = nentry;
57780 +
57781 + /* insert us into the table searchable by inode/dev */
57782 + insert_inodev_entry(ientry);
57783 +
57784 + return 1;
57785 +}
57786 +
57787 +static void
57788 +insert_acl_obj_label(struct acl_object_label *obj,
57789 + struct acl_subject_label *subj)
57790 +{
57791 + unsigned int index =
57792 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
57793 + struct acl_object_label **curr;
57794 +
57795 +
57796 + obj->prev = NULL;
57797 +
57798 + curr = &subj->obj_hash[index];
57799 + if (*curr != NULL)
57800 + (*curr)->prev = obj;
57801 +
57802 + obj->next = *curr;
57803 + *curr = obj;
57804 +
57805 + return;
57806 +}
57807 +
57808 +static void
57809 +insert_acl_subj_label(struct acl_subject_label *obj,
57810 + struct acl_role_label *role)
57811 +{
57812 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
57813 + struct acl_subject_label **curr;
57814 +
57815 + obj->prev = NULL;
57816 +
57817 + curr = &role->subj_hash[index];
57818 + if (*curr != NULL)
57819 + (*curr)->prev = obj;
57820 +
57821 + obj->next = *curr;
57822 + *curr = obj;
57823 +
57824 + return;
57825 +}
57826 +
57827 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
57828 +
57829 +static void *
57830 +create_table(__u32 * len, int elementsize)
57831 +{
57832 + unsigned int table_sizes[] = {
57833 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
57834 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
57835 + 4194301, 8388593, 16777213, 33554393, 67108859
57836 + };
57837 + void *newtable = NULL;
57838 + unsigned int pwr = 0;
57839 +
57840 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
57841 + table_sizes[pwr] <= *len)
57842 + pwr++;
57843 +
57844 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
57845 + return newtable;
57846 +
57847 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
57848 + newtable =
57849 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
57850 + else
57851 + newtable = vmalloc(table_sizes[pwr] * elementsize);
57852 +
57853 + *len = table_sizes[pwr];
57854 +
57855 + return newtable;
57856 +}
57857 +
57858 +static int
57859 +init_variables(const struct gr_arg *arg)
57860 +{
57861 + struct task_struct *reaper = init_pid_ns.child_reaper;
57862 + unsigned int stacksize;
57863 +
57864 + subj_map_set.s_size = arg->role_db.num_subjects;
57865 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
57866 + name_set.n_size = arg->role_db.num_objects;
57867 + inodev_set.i_size = arg->role_db.num_objects;
57868 +
57869 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
57870 + !name_set.n_size || !inodev_set.i_size)
57871 + return 1;
57872 +
57873 + if (!gr_init_uidset())
57874 + return 1;
57875 +
57876 + /* set up the stack that holds allocation info */
57877 +
57878 + stacksize = arg->role_db.num_pointers + 5;
57879 +
57880 + if (!acl_alloc_stack_init(stacksize))
57881 + return 1;
57882 +
57883 + /* grab reference for the real root dentry and vfsmount */
57884 + get_fs_root(reaper->fs, &real_root);
57885 +
57886 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
57887 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
57888 +#endif
57889 +
57890 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
57891 + if (fakefs_obj_rw == NULL)
57892 + return 1;
57893 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
57894 +
57895 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
57896 + if (fakefs_obj_rwx == NULL)
57897 + return 1;
57898 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
57899 +
57900 + subj_map_set.s_hash =
57901 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
57902 + acl_role_set.r_hash =
57903 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
57904 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
57905 + inodev_set.i_hash =
57906 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
57907 +
57908 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
57909 + !name_set.n_hash || !inodev_set.i_hash)
57910 + return 1;
57911 +
57912 + memset(subj_map_set.s_hash, 0,
57913 + sizeof(struct subject_map *) * subj_map_set.s_size);
57914 + memset(acl_role_set.r_hash, 0,
57915 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
57916 + memset(name_set.n_hash, 0,
57917 + sizeof (struct name_entry *) * name_set.n_size);
57918 + memset(inodev_set.i_hash, 0,
57919 + sizeof (struct inodev_entry *) * inodev_set.i_size);
57920 +
57921 + return 0;
57922 +}
57923 +
57924 +/* free information not needed after startup
57925 + currently contains user->kernel pointer mappings for subjects
57926 +*/
57927 +
57928 +static void
57929 +free_init_variables(void)
57930 +{
57931 + __u32 i;
57932 +
57933 + if (subj_map_set.s_hash) {
57934 + for (i = 0; i < subj_map_set.s_size; i++) {
57935 + if (subj_map_set.s_hash[i]) {
57936 + kfree(subj_map_set.s_hash[i]);
57937 + subj_map_set.s_hash[i] = NULL;
57938 + }
57939 + }
57940 +
57941 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
57942 + PAGE_SIZE)
57943 + kfree(subj_map_set.s_hash);
57944 + else
57945 + vfree(subj_map_set.s_hash);
57946 + }
57947 +
57948 + return;
57949 +}
57950 +
57951 +static void
57952 +free_variables(void)
57953 +{
57954 + struct acl_subject_label *s;
57955 + struct acl_role_label *r;
57956 + struct task_struct *task, *task2;
57957 + unsigned int x;
57958 +
57959 + gr_clear_learn_entries();
57960 +
57961 + read_lock(&tasklist_lock);
57962 + do_each_thread(task2, task) {
57963 + task->acl_sp_role = 0;
57964 + task->acl_role_id = 0;
57965 + task->acl = NULL;
57966 + task->role = NULL;
57967 + } while_each_thread(task2, task);
57968 + read_unlock(&tasklist_lock);
57969 +
57970 + /* release the reference to the real root dentry and vfsmount */
57971 + path_put(&real_root);
57972 + memset(&real_root, 0, sizeof(real_root));
57973 +
57974 + /* free all object hash tables */
57975 +
57976 + FOR_EACH_ROLE_START(r)
57977 + if (r->subj_hash == NULL)
57978 + goto next_role;
57979 + FOR_EACH_SUBJECT_START(r, s, x)
57980 + if (s->obj_hash == NULL)
57981 + break;
57982 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
57983 + kfree(s->obj_hash);
57984 + else
57985 + vfree(s->obj_hash);
57986 + FOR_EACH_SUBJECT_END(s, x)
57987 + FOR_EACH_NESTED_SUBJECT_START(r, s)
57988 + if (s->obj_hash == NULL)
57989 + break;
57990 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
57991 + kfree(s->obj_hash);
57992 + else
57993 + vfree(s->obj_hash);
57994 + FOR_EACH_NESTED_SUBJECT_END(s)
57995 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
57996 + kfree(r->subj_hash);
57997 + else
57998 + vfree(r->subj_hash);
57999 + r->subj_hash = NULL;
58000 +next_role:
58001 + FOR_EACH_ROLE_END(r)
58002 +
58003 + acl_free_all();
58004 +
58005 + if (acl_role_set.r_hash) {
58006 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
58007 + PAGE_SIZE)
58008 + kfree(acl_role_set.r_hash);
58009 + else
58010 + vfree(acl_role_set.r_hash);
58011 + }
58012 + if (name_set.n_hash) {
58013 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
58014 + PAGE_SIZE)
58015 + kfree(name_set.n_hash);
58016 + else
58017 + vfree(name_set.n_hash);
58018 + }
58019 +
58020 + if (inodev_set.i_hash) {
58021 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
58022 + PAGE_SIZE)
58023 + kfree(inodev_set.i_hash);
58024 + else
58025 + vfree(inodev_set.i_hash);
58026 + }
58027 +
58028 + gr_free_uidset();
58029 +
58030 + memset(&name_set, 0, sizeof (struct name_db));
58031 + memset(&inodev_set, 0, sizeof (struct inodev_db));
58032 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
58033 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
58034 +
58035 + default_role = NULL;
58036 + kernel_role = NULL;
58037 + role_list = NULL;
58038 +
58039 + return;
58040 +}
58041 +
58042 +static __u32
58043 +count_user_objs(struct acl_object_label *userp)
58044 +{
58045 + struct acl_object_label o_tmp;
58046 + __u32 num = 0;
58047 +
58048 + while (userp) {
58049 + if (copy_from_user(&o_tmp, userp,
58050 + sizeof (struct acl_object_label)))
58051 + break;
58052 +
58053 + userp = o_tmp.prev;
58054 + num++;
58055 + }
58056 +
58057 + return num;
58058 +}
58059 +
58060 +static struct acl_subject_label *
58061 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
58062 +
58063 +static int
58064 +copy_user_glob(struct acl_object_label *obj)
58065 +{
58066 + struct acl_object_label *g_tmp, **guser;
58067 + unsigned int len;
58068 + char *tmp;
58069 +
58070 + if (obj->globbed == NULL)
58071 + return 0;
58072 +
58073 + guser = &obj->globbed;
58074 + while (*guser) {
58075 + g_tmp = (struct acl_object_label *)
58076 + acl_alloc(sizeof (struct acl_object_label));
58077 + if (g_tmp == NULL)
58078 + return -ENOMEM;
58079 +
58080 + if (copy_from_user(g_tmp, *guser,
58081 + sizeof (struct acl_object_label)))
58082 + return -EFAULT;
58083 +
58084 + len = strnlen_user(g_tmp->filename, PATH_MAX);
58085 +
58086 + if (!len || len >= PATH_MAX)
58087 + return -EINVAL;
58088 +
58089 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58090 + return -ENOMEM;
58091 +
58092 + if (copy_from_user(tmp, g_tmp->filename, len))
58093 + return -EFAULT;
58094 + tmp[len-1] = '\0';
58095 + g_tmp->filename = tmp;
58096 +
58097 + *guser = g_tmp;
58098 + guser = &(g_tmp->next);
58099 + }
58100 +
58101 + return 0;
58102 +}
58103 +
58104 +static int
58105 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
58106 + struct acl_role_label *role)
58107 +{
58108 + struct acl_object_label *o_tmp;
58109 + unsigned int len;
58110 + int ret;
58111 + char *tmp;
58112 +
58113 + while (userp) {
58114 + if ((o_tmp = (struct acl_object_label *)
58115 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
58116 + return -ENOMEM;
58117 +
58118 + if (copy_from_user(o_tmp, userp,
58119 + sizeof (struct acl_object_label)))
58120 + return -EFAULT;
58121 +
58122 + userp = o_tmp->prev;
58123 +
58124 + len = strnlen_user(o_tmp->filename, PATH_MAX);
58125 +
58126 + if (!len || len >= PATH_MAX)
58127 + return -EINVAL;
58128 +
58129 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58130 + return -ENOMEM;
58131 +
58132 + if (copy_from_user(tmp, o_tmp->filename, len))
58133 + return -EFAULT;
58134 + tmp[len-1] = '\0';
58135 + o_tmp->filename = tmp;
58136 +
58137 + insert_acl_obj_label(o_tmp, subj);
58138 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
58139 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
58140 + return -ENOMEM;
58141 +
58142 + ret = copy_user_glob(o_tmp);
58143 + if (ret)
58144 + return ret;
58145 +
58146 + if (o_tmp->nested) {
58147 + int already_copied;
58148 +
58149 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
58150 + if (IS_ERR(o_tmp->nested))
58151 + return PTR_ERR(o_tmp->nested);
58152 +
58153 + /* insert into nested subject list if we haven't copied this one yet
58154 + to prevent duplicate entries */
58155 + if (!already_copied) {
58156 + o_tmp->nested->next = role->hash->first;
58157 + role->hash->first = o_tmp->nested;
58158 + }
58159 + }
58160 + }
58161 +
58162 + return 0;
58163 +}
58164 +
58165 +static __u32
58166 +count_user_subjs(struct acl_subject_label *userp)
58167 +{
58168 + struct acl_subject_label s_tmp;
58169 + __u32 num = 0;
58170 +
58171 + while (userp) {
58172 + if (copy_from_user(&s_tmp, userp,
58173 + sizeof (struct acl_subject_label)))
58174 + break;
58175 +
58176 + userp = s_tmp.prev;
58177 + }
58178 +
58179 + return num;
58180 +}
58181 +
58182 +static int
58183 +copy_user_allowedips(struct acl_role_label *rolep)
58184 +{
58185 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
58186 +
58187 + ruserip = rolep->allowed_ips;
58188 +
58189 + while (ruserip) {
58190 + rlast = rtmp;
58191 +
58192 + if ((rtmp = (struct role_allowed_ip *)
58193 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
58194 + return -ENOMEM;
58195 +
58196 + if (copy_from_user(rtmp, ruserip,
58197 + sizeof (struct role_allowed_ip)))
58198 + return -EFAULT;
58199 +
58200 + ruserip = rtmp->prev;
58201 +
58202 + if (!rlast) {
58203 + rtmp->prev = NULL;
58204 + rolep->allowed_ips = rtmp;
58205 + } else {
58206 + rlast->next = rtmp;
58207 + rtmp->prev = rlast;
58208 + }
58209 +
58210 + if (!ruserip)
58211 + rtmp->next = NULL;
58212 + }
58213 +
58214 + return 0;
58215 +}
58216 +
58217 +static int
58218 +copy_user_transitions(struct acl_role_label *rolep)
58219 +{
58220 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
58221 +
58222 + unsigned int len;
58223 + char *tmp;
58224 +
58225 + rusertp = rolep->transitions;
58226 +
58227 + while (rusertp) {
58228 + rlast = rtmp;
58229 +
58230 + if ((rtmp = (struct role_transition *)
58231 + acl_alloc(sizeof (struct role_transition))) == NULL)
58232 + return -ENOMEM;
58233 +
58234 + if (copy_from_user(rtmp, rusertp,
58235 + sizeof (struct role_transition)))
58236 + return -EFAULT;
58237 +
58238 + rusertp = rtmp->prev;
58239 +
58240 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
58241 +
58242 + if (!len || len >= GR_SPROLE_LEN)
58243 + return -EINVAL;
58244 +
58245 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58246 + return -ENOMEM;
58247 +
58248 + if (copy_from_user(tmp, rtmp->rolename, len))
58249 + return -EFAULT;
58250 + tmp[len-1] = '\0';
58251 + rtmp->rolename = tmp;
58252 +
58253 + if (!rlast) {
58254 + rtmp->prev = NULL;
58255 + rolep->transitions = rtmp;
58256 + } else {
58257 + rlast->next = rtmp;
58258 + rtmp->prev = rlast;
58259 + }
58260 +
58261 + if (!rusertp)
58262 + rtmp->next = NULL;
58263 + }
58264 +
58265 + return 0;
58266 +}
58267 +
58268 +static struct acl_subject_label *
58269 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
58270 +{
58271 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
58272 + unsigned int len;
58273 + char *tmp;
58274 + __u32 num_objs;
58275 + struct acl_ip_label **i_tmp, *i_utmp2;
58276 + struct gr_hash_struct ghash;
58277 + struct subject_map *subjmap;
58278 + unsigned int i_num;
58279 + int err;
58280 +
58281 + if (already_copied != NULL)
58282 + *already_copied = 0;
58283 +
58284 + s_tmp = lookup_subject_map(userp);
58285 +
58286 + /* we've already copied this subject into the kernel, just return
58287 + the reference to it, and don't copy it over again
58288 + */
58289 + if (s_tmp) {
58290 + if (already_copied != NULL)
58291 + *already_copied = 1;
58292 + return(s_tmp);
58293 + }
58294 +
58295 + if ((s_tmp = (struct acl_subject_label *)
58296 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
58297 + return ERR_PTR(-ENOMEM);
58298 +
58299 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
58300 + if (subjmap == NULL)
58301 + return ERR_PTR(-ENOMEM);
58302 +
58303 + subjmap->user = userp;
58304 + subjmap->kernel = s_tmp;
58305 + insert_subj_map_entry(subjmap);
58306 +
58307 + if (copy_from_user(s_tmp, userp,
58308 + sizeof (struct acl_subject_label)))
58309 + return ERR_PTR(-EFAULT);
58310 +
58311 + len = strnlen_user(s_tmp->filename, PATH_MAX);
58312 +
58313 + if (!len || len >= PATH_MAX)
58314 + return ERR_PTR(-EINVAL);
58315 +
58316 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58317 + return ERR_PTR(-ENOMEM);
58318 +
58319 + if (copy_from_user(tmp, s_tmp->filename, len))
58320 + return ERR_PTR(-EFAULT);
58321 + tmp[len-1] = '\0';
58322 + s_tmp->filename = tmp;
58323 +
58324 + if (!strcmp(s_tmp->filename, "/"))
58325 + role->root_label = s_tmp;
58326 +
58327 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
58328 + return ERR_PTR(-EFAULT);
58329 +
58330 + /* copy user and group transition tables */
58331 +
58332 + if (s_tmp->user_trans_num) {
58333 + uid_t *uidlist;
58334 +
58335 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
58336 + if (uidlist == NULL)
58337 + return ERR_PTR(-ENOMEM);
58338 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
58339 + return ERR_PTR(-EFAULT);
58340 +
58341 + s_tmp->user_transitions = uidlist;
58342 + }
58343 +
58344 + if (s_tmp->group_trans_num) {
58345 + gid_t *gidlist;
58346 +
58347 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
58348 + if (gidlist == NULL)
58349 + return ERR_PTR(-ENOMEM);
58350 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
58351 + return ERR_PTR(-EFAULT);
58352 +
58353 + s_tmp->group_transitions = gidlist;
58354 + }
58355 +
58356 + /* set up object hash table */
58357 + num_objs = count_user_objs(ghash.first);
58358 +
58359 + s_tmp->obj_hash_size = num_objs;
58360 + s_tmp->obj_hash =
58361 + (struct acl_object_label **)
58362 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
58363 +
58364 + if (!s_tmp->obj_hash)
58365 + return ERR_PTR(-ENOMEM);
58366 +
58367 + memset(s_tmp->obj_hash, 0,
58368 + s_tmp->obj_hash_size *
58369 + sizeof (struct acl_object_label *));
58370 +
58371 + /* add in objects */
58372 + err = copy_user_objs(ghash.first, s_tmp, role);
58373 +
58374 + if (err)
58375 + return ERR_PTR(err);
58376 +
58377 + /* set pointer for parent subject */
58378 + if (s_tmp->parent_subject) {
58379 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
58380 +
58381 + if (IS_ERR(s_tmp2))
58382 + return s_tmp2;
58383 +
58384 + s_tmp->parent_subject = s_tmp2;
58385 + }
58386 +
58387 + /* add in ip acls */
58388 +
58389 + if (!s_tmp->ip_num) {
58390 + s_tmp->ips = NULL;
58391 + goto insert;
58392 + }
58393 +
58394 + i_tmp =
58395 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
58396 + sizeof (struct acl_ip_label *));
58397 +
58398 + if (!i_tmp)
58399 + return ERR_PTR(-ENOMEM);
58400 +
58401 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
58402 + *(i_tmp + i_num) =
58403 + (struct acl_ip_label *)
58404 + acl_alloc(sizeof (struct acl_ip_label));
58405 + if (!*(i_tmp + i_num))
58406 + return ERR_PTR(-ENOMEM);
58407 +
58408 + if (copy_from_user
58409 + (&i_utmp2, s_tmp->ips + i_num,
58410 + sizeof (struct acl_ip_label *)))
58411 + return ERR_PTR(-EFAULT);
58412 +
58413 + if (copy_from_user
58414 + (*(i_tmp + i_num), i_utmp2,
58415 + sizeof (struct acl_ip_label)))
58416 + return ERR_PTR(-EFAULT);
58417 +
58418 + if ((*(i_tmp + i_num))->iface == NULL)
58419 + continue;
58420 +
58421 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
58422 + if (!len || len >= IFNAMSIZ)
58423 + return ERR_PTR(-EINVAL);
58424 + tmp = acl_alloc(len);
58425 + if (tmp == NULL)
58426 + return ERR_PTR(-ENOMEM);
58427 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
58428 + return ERR_PTR(-EFAULT);
58429 + (*(i_tmp + i_num))->iface = tmp;
58430 + }
58431 +
58432 + s_tmp->ips = i_tmp;
58433 +
58434 +insert:
58435 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
58436 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
58437 + return ERR_PTR(-ENOMEM);
58438 +
58439 + return s_tmp;
58440 +}
58441 +
58442 +static int
58443 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
58444 +{
58445 + struct acl_subject_label s_pre;
58446 + struct acl_subject_label * ret;
58447 + int err;
58448 +
58449 + while (userp) {
58450 + if (copy_from_user(&s_pre, userp,
58451 + sizeof (struct acl_subject_label)))
58452 + return -EFAULT;
58453 +
58454 + ret = do_copy_user_subj(userp, role, NULL);
58455 +
58456 + err = PTR_ERR(ret);
58457 + if (IS_ERR(ret))
58458 + return err;
58459 +
58460 + insert_acl_subj_label(ret, role);
58461 +
58462 + userp = s_pre.prev;
58463 + }
58464 +
58465 + return 0;
58466 +}
58467 +
58468 +static int
58469 +copy_user_acl(struct gr_arg *arg)
58470 +{
58471 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
58472 + struct acl_subject_label *subj_list;
58473 + struct sprole_pw *sptmp;
58474 + struct gr_hash_struct *ghash;
58475 + uid_t *domainlist;
58476 + unsigned int r_num;
58477 + unsigned int len;
58478 + char *tmp;
58479 + int err = 0;
58480 + __u16 i;
58481 + __u32 num_subjs;
58482 +
58483 + /* we need a default and kernel role */
58484 + if (arg->role_db.num_roles < 2)
58485 + return -EINVAL;
58486 +
58487 + /* copy special role authentication info from userspace */
58488 +
58489 + num_sprole_pws = arg->num_sprole_pws;
58490 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
58491 +
58492 + if (!acl_special_roles && num_sprole_pws)
58493 + return -ENOMEM;
58494 +
58495 + for (i = 0; i < num_sprole_pws; i++) {
58496 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
58497 + if (!sptmp)
58498 + return -ENOMEM;
58499 + if (copy_from_user(sptmp, arg->sprole_pws + i,
58500 + sizeof (struct sprole_pw)))
58501 + return -EFAULT;
58502 +
58503 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
58504 +
58505 + if (!len || len >= GR_SPROLE_LEN)
58506 + return -EINVAL;
58507 +
58508 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58509 + return -ENOMEM;
58510 +
58511 + if (copy_from_user(tmp, sptmp->rolename, len))
58512 + return -EFAULT;
58513 +
58514 + tmp[len-1] = '\0';
58515 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
58516 + printk(KERN_ALERT "Copying special role %s\n", tmp);
58517 +#endif
58518 + sptmp->rolename = tmp;
58519 + acl_special_roles[i] = sptmp;
58520 + }
58521 +
58522 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
58523 +
58524 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
58525 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
58526 +
58527 + if (!r_tmp)
58528 + return -ENOMEM;
58529 +
58530 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
58531 + sizeof (struct acl_role_label *)))
58532 + return -EFAULT;
58533 +
58534 + if (copy_from_user(r_tmp, r_utmp2,
58535 + sizeof (struct acl_role_label)))
58536 + return -EFAULT;
58537 +
58538 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
58539 +
58540 + if (!len || len >= PATH_MAX)
58541 + return -EINVAL;
58542 +
58543 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58544 + return -ENOMEM;
58545 +
58546 + if (copy_from_user(tmp, r_tmp->rolename, len))
58547 + return -EFAULT;
58548 +
58549 + tmp[len-1] = '\0';
58550 + r_tmp->rolename = tmp;
58551 +
58552 + if (!strcmp(r_tmp->rolename, "default")
58553 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
58554 + default_role = r_tmp;
58555 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
58556 + kernel_role = r_tmp;
58557 + }
58558 +
58559 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
58560 + return -ENOMEM;
58561 +
58562 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
58563 + return -EFAULT;
58564 +
58565 + r_tmp->hash = ghash;
58566 +
58567 + num_subjs = count_user_subjs(r_tmp->hash->first);
58568 +
58569 + r_tmp->subj_hash_size = num_subjs;
58570 + r_tmp->subj_hash =
58571 + (struct acl_subject_label **)
58572 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
58573 +
58574 + if (!r_tmp->subj_hash)
58575 + return -ENOMEM;
58576 +
58577 + err = copy_user_allowedips(r_tmp);
58578 + if (err)
58579 + return err;
58580 +
58581 + /* copy domain info */
58582 + if (r_tmp->domain_children != NULL) {
58583 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
58584 + if (domainlist == NULL)
58585 + return -ENOMEM;
58586 +
58587 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
58588 + return -EFAULT;
58589 +
58590 + r_tmp->domain_children = domainlist;
58591 + }
58592 +
58593 + err = copy_user_transitions(r_tmp);
58594 + if (err)
58595 + return err;
58596 +
58597 + memset(r_tmp->subj_hash, 0,
58598 + r_tmp->subj_hash_size *
58599 + sizeof (struct acl_subject_label *));
58600 +
58601 + /* acquire the list of subjects, then NULL out
58602 + the list prior to parsing the subjects for this role,
58603 + as during this parsing the list is replaced with a list
58604 + of *nested* subjects for the role
58605 + */
58606 + subj_list = r_tmp->hash->first;
58607 +
58608 + /* set nested subject list to null */
58609 + r_tmp->hash->first = NULL;
58610 +
58611 + err = copy_user_subjs(subj_list, r_tmp);
58612 +
58613 + if (err)
58614 + return err;
58615 +
58616 + insert_acl_role_label(r_tmp);
58617 + }
58618 +
58619 + if (default_role == NULL || kernel_role == NULL)
58620 + return -EINVAL;
58621 +
58622 + return err;
58623 +}
58624 +
58625 +static int
58626 +gracl_init(struct gr_arg *args)
58627 +{
58628 + int error = 0;
58629 +
58630 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
58631 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
58632 +
58633 + if (init_variables(args)) {
58634 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
58635 + error = -ENOMEM;
58636 + free_variables();
58637 + goto out;
58638 + }
58639 +
58640 + error = copy_user_acl(args);
58641 + free_init_variables();
58642 + if (error) {
58643 + free_variables();
58644 + goto out;
58645 + }
58646 +
58647 + if ((error = gr_set_acls(0))) {
58648 + free_variables();
58649 + goto out;
58650 + }
58651 +
58652 + pax_open_kernel();
58653 + gr_status |= GR_READY;
58654 + pax_close_kernel();
58655 +
58656 + out:
58657 + return error;
58658 +}
58659 +
58660 +/* derived from glibc fnmatch() 0: match, 1: no match*/
58661 +
58662 +static int
58663 +glob_match(const char *p, const char *n)
58664 +{
58665 + char c;
58666 +
58667 + while ((c = *p++) != '\0') {
58668 + switch (c) {
58669 + case '?':
58670 + if (*n == '\0')
58671 + return 1;
58672 + else if (*n == '/')
58673 + return 1;
58674 + break;
58675 + case '\\':
58676 + if (*n != c)
58677 + return 1;
58678 + break;
58679 + case '*':
58680 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
58681 + if (*n == '/')
58682 + return 1;
58683 + else if (c == '?') {
58684 + if (*n == '\0')
58685 + return 1;
58686 + else
58687 + ++n;
58688 + }
58689 + }
58690 + if (c == '\0') {
58691 + return 0;
58692 + } else {
58693 + const char *endp;
58694 +
58695 + if ((endp = strchr(n, '/')) == NULL)
58696 + endp = n + strlen(n);
58697 +
58698 + if (c == '[') {
58699 + for (--p; n < endp; ++n)
58700 + if (!glob_match(p, n))
58701 + return 0;
58702 + } else if (c == '/') {
58703 + while (*n != '\0' && *n != '/')
58704 + ++n;
58705 + if (*n == '/' && !glob_match(p, n + 1))
58706 + return 0;
58707 + } else {
58708 + for (--p; n < endp; ++n)
58709 + if (*n == c && !glob_match(p, n))
58710 + return 0;
58711 + }
58712 +
58713 + return 1;
58714 + }
58715 + case '[':
58716 + {
58717 + int not;
58718 + char cold;
58719 +
58720 + if (*n == '\0' || *n == '/')
58721 + return 1;
58722 +
58723 + not = (*p == '!' || *p == '^');
58724 + if (not)
58725 + ++p;
58726 +
58727 + c = *p++;
58728 + for (;;) {
58729 + unsigned char fn = (unsigned char)*n;
58730 +
58731 + if (c == '\0')
58732 + return 1;
58733 + else {
58734 + if (c == fn)
58735 + goto matched;
58736 + cold = c;
58737 + c = *p++;
58738 +
58739 + if (c == '-' && *p != ']') {
58740 + unsigned char cend = *p++;
58741 +
58742 + if (cend == '\0')
58743 + return 1;
58744 +
58745 + if (cold <= fn && fn <= cend)
58746 + goto matched;
58747 +
58748 + c = *p++;
58749 + }
58750 + }
58751 +
58752 + if (c == ']')
58753 + break;
58754 + }
58755 + if (!not)
58756 + return 1;
58757 + break;
58758 + matched:
58759 + while (c != ']') {
58760 + if (c == '\0')
58761 + return 1;
58762 +
58763 + c = *p++;
58764 + }
58765 + if (not)
58766 + return 1;
58767 + }
58768 + break;
58769 + default:
58770 + if (c != *n)
58771 + return 1;
58772 + }
58773 +
58774 + ++n;
58775 + }
58776 +
58777 + if (*n == '\0')
58778 + return 0;
58779 +
58780 + if (*n == '/')
58781 + return 0;
58782 +
58783 + return 1;
58784 +}
58785 +
58786 +static struct acl_object_label *
58787 +chk_glob_label(struct acl_object_label *globbed,
58788 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
58789 +{
58790 + struct acl_object_label *tmp;
58791 +
58792 + if (*path == NULL)
58793 + *path = gr_to_filename_nolock(dentry, mnt);
58794 +
58795 + tmp = globbed;
58796 +
58797 + while (tmp) {
58798 + if (!glob_match(tmp->filename, *path))
58799 + return tmp;
58800 + tmp = tmp->next;
58801 + }
58802 +
58803 + return NULL;
58804 +}
58805 +
58806 +static struct acl_object_label *
58807 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
58808 + const ino_t curr_ino, const dev_t curr_dev,
58809 + const struct acl_subject_label *subj, char **path, const int checkglob)
58810 +{
58811 + struct acl_subject_label *tmpsubj;
58812 + struct acl_object_label *retval;
58813 + struct acl_object_label *retval2;
58814 +
58815 + tmpsubj = (struct acl_subject_label *) subj;
58816 + read_lock(&gr_inode_lock);
58817 + do {
58818 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
58819 + if (retval) {
58820 + if (checkglob && retval->globbed) {
58821 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
58822 + if (retval2)
58823 + retval = retval2;
58824 + }
58825 + break;
58826 + }
58827 + } while ((tmpsubj = tmpsubj->parent_subject));
58828 + read_unlock(&gr_inode_lock);
58829 +
58830 + return retval;
58831 +}
58832 +
58833 +static __inline__ struct acl_object_label *
58834 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
58835 + struct dentry *curr_dentry,
58836 + const struct acl_subject_label *subj, char **path, const int checkglob)
58837 +{
58838 + int newglob = checkglob;
58839 + ino_t inode;
58840 + dev_t device;
58841 +
58842 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
58843 + as we don't want a / * rule to match instead of the / object
58844 + don't do this for create lookups that call this function though, since they're looking up
58845 + on the parent and thus need globbing checks on all paths
58846 + */
58847 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
58848 + newglob = GR_NO_GLOB;
58849 +
58850 + spin_lock(&curr_dentry->d_lock);
58851 + inode = curr_dentry->d_inode->i_ino;
58852 + device = __get_dev(curr_dentry);
58853 + spin_unlock(&curr_dentry->d_lock);
58854 +
58855 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
58856 +}
58857 +
58858 +#ifdef CONFIG_HUGETLBFS
58859 +static inline bool
58860 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
58861 +{
58862 + int i;
58863 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
58864 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
58865 + return true;
58866 + }
58867 +
58868 + return false;
58869 +}
58870 +#endif
58871 +
58872 +static struct acl_object_label *
58873 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
58874 + const struct acl_subject_label *subj, char *path, const int checkglob)
58875 +{
58876 + struct dentry *dentry = (struct dentry *) l_dentry;
58877 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
58878 + struct mount *real_mnt = real_mount(mnt);
58879 + struct acl_object_label *retval;
58880 + struct dentry *parent;
58881 +
58882 + br_read_lock(&vfsmount_lock);
58883 + write_seqlock(&rename_lock);
58884 +
58885 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
58886 +#ifdef CONFIG_NET
58887 + mnt == sock_mnt ||
58888 +#endif
58889 +#ifdef CONFIG_HUGETLBFS
58890 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
58891 +#endif
58892 + /* ignore Eric Biederman */
58893 + IS_PRIVATE(l_dentry->d_inode))) {
58894 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
58895 + goto out;
58896 + }
58897 +
58898 + for (;;) {
58899 + if (dentry == real_root.dentry && mnt == real_root.mnt)
58900 + break;
58901 +
58902 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
58903 + if (!mnt_has_parent(real_mnt))
58904 + break;
58905 +
58906 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
58907 + if (retval != NULL)
58908 + goto out;
58909 +
58910 + dentry = real_mnt->mnt_mountpoint;
58911 + real_mnt = real_mnt->mnt_parent;
58912 + mnt = &real_mnt->mnt;
58913 + continue;
58914 + }
58915 +
58916 + parent = dentry->d_parent;
58917 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
58918 + if (retval != NULL)
58919 + goto out;
58920 +
58921 + dentry = parent;
58922 + }
58923 +
58924 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
58925 +
58926 + /* real_root is pinned so we don't have to hold a reference */
58927 + if (retval == NULL)
58928 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
58929 +out:
58930 + write_sequnlock(&rename_lock);
58931 + br_read_unlock(&vfsmount_lock);
58932 +
58933 + BUG_ON(retval == NULL);
58934 +
58935 + return retval;
58936 +}
58937 +
58938 +static __inline__ struct acl_object_label *
58939 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
58940 + const struct acl_subject_label *subj)
58941 +{
58942 + char *path = NULL;
58943 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
58944 +}
58945 +
58946 +static __inline__ struct acl_object_label *
58947 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
58948 + const struct acl_subject_label *subj)
58949 +{
58950 + char *path = NULL;
58951 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
58952 +}
58953 +
58954 +static __inline__ struct acl_object_label *
58955 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
58956 + const struct acl_subject_label *subj, char *path)
58957 +{
58958 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
58959 +}
58960 +
58961 +static struct acl_subject_label *
58962 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
58963 + const struct acl_role_label *role)
58964 +{
58965 + struct dentry *dentry = (struct dentry *) l_dentry;
58966 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
58967 + struct mount *real_mnt = real_mount(mnt);
58968 + struct acl_subject_label *retval;
58969 + struct dentry *parent;
58970 +
58971 + br_read_lock(&vfsmount_lock);
58972 + write_seqlock(&rename_lock);
58973 +
58974 + for (;;) {
58975 + if (dentry == real_root.dentry && mnt == real_root.mnt)
58976 + break;
58977 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
58978 + if (!mnt_has_parent(real_mnt))
58979 + break;
58980 +
58981 + spin_lock(&dentry->d_lock);
58982 + read_lock(&gr_inode_lock);
58983 + retval =
58984 + lookup_acl_subj_label(dentry->d_inode->i_ino,
58985 + __get_dev(dentry), role);
58986 + read_unlock(&gr_inode_lock);
58987 + spin_unlock(&dentry->d_lock);
58988 + if (retval != NULL)
58989 + goto out;
58990 +
58991 + dentry = real_mnt->mnt_mountpoint;
58992 + real_mnt = real_mnt->mnt_parent;
58993 + mnt = &real_mnt->mnt;
58994 + continue;
58995 + }
58996 +
58997 + spin_lock(&dentry->d_lock);
58998 + read_lock(&gr_inode_lock);
58999 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
59000 + __get_dev(dentry), role);
59001 + read_unlock(&gr_inode_lock);
59002 + parent = dentry->d_parent;
59003 + spin_unlock(&dentry->d_lock);
59004 +
59005 + if (retval != NULL)
59006 + goto out;
59007 +
59008 + dentry = parent;
59009 + }
59010 +
59011 + spin_lock(&dentry->d_lock);
59012 + read_lock(&gr_inode_lock);
59013 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
59014 + __get_dev(dentry), role);
59015 + read_unlock(&gr_inode_lock);
59016 + spin_unlock(&dentry->d_lock);
59017 +
59018 + if (unlikely(retval == NULL)) {
59019 + /* real_root is pinned, we don't need to hold a reference */
59020 + read_lock(&gr_inode_lock);
59021 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
59022 + __get_dev(real_root.dentry), role);
59023 + read_unlock(&gr_inode_lock);
59024 + }
59025 +out:
59026 + write_sequnlock(&rename_lock);
59027 + br_read_unlock(&vfsmount_lock);
59028 +
59029 + BUG_ON(retval == NULL);
59030 +
59031 + return retval;
59032 +}
59033 +
59034 +static void
59035 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
59036 +{
59037 + struct task_struct *task = current;
59038 + const struct cred *cred = current_cred();
59039 +
59040 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
59041 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59042 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59043 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
59044 +
59045 + return;
59046 +}
59047 +
59048 +static void
59049 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
59050 +{
59051 + struct task_struct *task = current;
59052 + const struct cred *cred = current_cred();
59053 +
59054 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
59055 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59056 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59057 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
59058 +
59059 + return;
59060 +}
59061 +
59062 +static void
59063 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
59064 +{
59065 + struct task_struct *task = current;
59066 + const struct cred *cred = current_cred();
59067 +
59068 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
59069 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59070 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59071 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
59072 +
59073 + return;
59074 +}
59075 +
59076 +__u32
59077 +gr_search_file(const struct dentry * dentry, const __u32 mode,
59078 + const struct vfsmount * mnt)
59079 +{
59080 + __u32 retval = mode;
59081 + struct acl_subject_label *curracl;
59082 + struct acl_object_label *currobj;
59083 +
59084 + if (unlikely(!(gr_status & GR_READY)))
59085 + return (mode & ~GR_AUDITS);
59086 +
59087 + curracl = current->acl;
59088 +
59089 + currobj = chk_obj_label(dentry, mnt, curracl);
59090 + retval = currobj->mode & mode;
59091 +
59092 + /* if we're opening a specified transfer file for writing
59093 + (e.g. /dev/initctl), then transfer our role to init
59094 + */
59095 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
59096 + current->role->roletype & GR_ROLE_PERSIST)) {
59097 + struct task_struct *task = init_pid_ns.child_reaper;
59098 +
59099 + if (task->role != current->role) {
59100 + task->acl_sp_role = 0;
59101 + task->acl_role_id = current->acl_role_id;
59102 + task->role = current->role;
59103 + rcu_read_lock();
59104 + read_lock(&grsec_exec_file_lock);
59105 + gr_apply_subject_to_task(task);
59106 + read_unlock(&grsec_exec_file_lock);
59107 + rcu_read_unlock();
59108 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
59109 + }
59110 + }
59111 +
59112 + if (unlikely
59113 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
59114 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
59115 + __u32 new_mode = mode;
59116 +
59117 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
59118 +
59119 + retval = new_mode;
59120 +
59121 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
59122 + new_mode |= GR_INHERIT;
59123 +
59124 + if (!(mode & GR_NOLEARN))
59125 + gr_log_learn(dentry, mnt, new_mode);
59126 + }
59127 +
59128 + return retval;
59129 +}
59130 +
59131 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
59132 + const struct dentry *parent,
59133 + const struct vfsmount *mnt)
59134 +{
59135 + struct name_entry *match;
59136 + struct acl_object_label *matchpo;
59137 + struct acl_subject_label *curracl;
59138 + char *path;
59139 +
59140 + if (unlikely(!(gr_status & GR_READY)))
59141 + return NULL;
59142 +
59143 + preempt_disable();
59144 + path = gr_to_filename_rbac(new_dentry, mnt);
59145 + match = lookup_name_entry_create(path);
59146 +
59147 + curracl = current->acl;
59148 +
59149 + if (match) {
59150 + read_lock(&gr_inode_lock);
59151 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
59152 + read_unlock(&gr_inode_lock);
59153 +
59154 + if (matchpo) {
59155 + preempt_enable();
59156 + return matchpo;
59157 + }
59158 + }
59159 +
59160 + // lookup parent
59161 +
59162 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
59163 +
59164 + preempt_enable();
59165 + return matchpo;
59166 +}
59167 +
59168 +__u32
59169 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
59170 + const struct vfsmount * mnt, const __u32 mode)
59171 +{
59172 + struct acl_object_label *matchpo;
59173 + __u32 retval;
59174 +
59175 + if (unlikely(!(gr_status & GR_READY)))
59176 + return (mode & ~GR_AUDITS);
59177 +
59178 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
59179 +
59180 + retval = matchpo->mode & mode;
59181 +
59182 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
59183 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
59184 + __u32 new_mode = mode;
59185 +
59186 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
59187 +
59188 + gr_log_learn(new_dentry, mnt, new_mode);
59189 + return new_mode;
59190 + }
59191 +
59192 + return retval;
59193 +}
59194 +
59195 +__u32
59196 +gr_check_link(const struct dentry * new_dentry,
59197 + const struct dentry * parent_dentry,
59198 + const struct vfsmount * parent_mnt,
59199 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
59200 +{
59201 + struct acl_object_label *obj;
59202 + __u32 oldmode, newmode;
59203 + __u32 needmode;
59204 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
59205 + GR_DELETE | GR_INHERIT;
59206 +
59207 + if (unlikely(!(gr_status & GR_READY)))
59208 + return (GR_CREATE | GR_LINK);
59209 +
59210 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
59211 + oldmode = obj->mode;
59212 +
59213 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
59214 + newmode = obj->mode;
59215 +
59216 + needmode = newmode & checkmodes;
59217 +
59218 + // old name for hardlink must have at least the permissions of the new name
59219 + if ((oldmode & needmode) != needmode)
59220 + goto bad;
59221 +
59222 + // if old name had restrictions/auditing, make sure the new name does as well
59223 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
59224 +
59225 + // don't allow hardlinking of suid/sgid/fcapped files without permission
59226 + if (is_privileged_binary(old_dentry))
59227 + needmode |= GR_SETID;
59228 +
59229 + if ((newmode & needmode) != needmode)
59230 + goto bad;
59231 +
59232 + // enforce minimum permissions
59233 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
59234 + return newmode;
59235 +bad:
59236 + needmode = oldmode;
59237 + if (is_privileged_binary(old_dentry))
59238 + needmode |= GR_SETID;
59239 +
59240 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
59241 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
59242 + return (GR_CREATE | GR_LINK);
59243 + } else if (newmode & GR_SUPPRESS)
59244 + return GR_SUPPRESS;
59245 + else
59246 + return 0;
59247 +}
59248 +
59249 +int
59250 +gr_check_hidden_task(const struct task_struct *task)
59251 +{
59252 + if (unlikely(!(gr_status & GR_READY)))
59253 + return 0;
59254 +
59255 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
59256 + return 1;
59257 +
59258 + return 0;
59259 +}
59260 +
59261 +int
59262 +gr_check_protected_task(const struct task_struct *task)
59263 +{
59264 + if (unlikely(!(gr_status & GR_READY) || !task))
59265 + return 0;
59266 +
59267 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
59268 + task->acl != current->acl)
59269 + return 1;
59270 +
59271 + return 0;
59272 +}
59273 +
59274 +int
59275 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
59276 +{
59277 + struct task_struct *p;
59278 + int ret = 0;
59279 +
59280 + if (unlikely(!(gr_status & GR_READY) || !pid))
59281 + return ret;
59282 +
59283 + read_lock(&tasklist_lock);
59284 + do_each_pid_task(pid, type, p) {
59285 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
59286 + p->acl != current->acl) {
59287 + ret = 1;
59288 + goto out;
59289 + }
59290 + } while_each_pid_task(pid, type, p);
59291 +out:
59292 + read_unlock(&tasklist_lock);
59293 +
59294 + return ret;
59295 +}
59296 +
59297 +void
59298 +gr_copy_label(struct task_struct *tsk)
59299 +{
59300 + tsk->signal->used_accept = 0;
59301 + tsk->acl_sp_role = 0;
59302 + tsk->acl_role_id = current->acl_role_id;
59303 + tsk->acl = current->acl;
59304 + tsk->role = current->role;
59305 + tsk->signal->curr_ip = current->signal->curr_ip;
59306 + tsk->signal->saved_ip = current->signal->saved_ip;
59307 + if (current->exec_file)
59308 + get_file(current->exec_file);
59309 + tsk->exec_file = current->exec_file;
59310 + tsk->is_writable = current->is_writable;
59311 + if (unlikely(current->signal->used_accept)) {
59312 + current->signal->curr_ip = 0;
59313 + current->signal->saved_ip = 0;
59314 + }
59315 +
59316 + return;
59317 +}
59318 +
59319 +static void
59320 +gr_set_proc_res(struct task_struct *task)
59321 +{
59322 + struct acl_subject_label *proc;
59323 + unsigned short i;
59324 +
59325 + proc = task->acl;
59326 +
59327 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
59328 + return;
59329 +
59330 + for (i = 0; i < RLIM_NLIMITS; i++) {
59331 + if (!(proc->resmask & (1U << i)))
59332 + continue;
59333 +
59334 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
59335 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
59336 +
59337 + if (i == RLIMIT_CPU)
59338 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
59339 + }
59340 +
59341 + return;
59342 +}
59343 +
59344 +extern int __gr_process_user_ban(struct user_struct *user);
59345 +
59346 +int
59347 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
59348 +{
59349 + unsigned int i;
59350 + __u16 num;
59351 + uid_t *uidlist;
59352 + uid_t curuid;
59353 + int realok = 0;
59354 + int effectiveok = 0;
59355 + int fsok = 0;
59356 + uid_t globalreal, globaleffective, globalfs;
59357 +
59358 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
59359 + struct user_struct *user;
59360 +
59361 + if (!uid_valid(real))
59362 + goto skipit;
59363 +
59364 + /* find user based on global namespace */
59365 +
59366 + globalreal = GR_GLOBAL_UID(real);
59367 +
59368 + user = find_user(make_kuid(&init_user_ns, globalreal));
59369 + if (user == NULL)
59370 + goto skipit;
59371 +
59372 + if (__gr_process_user_ban(user)) {
59373 + /* for find_user */
59374 + free_uid(user);
59375 + return 1;
59376 + }
59377 +
59378 + /* for find_user */
59379 + free_uid(user);
59380 +
59381 +skipit:
59382 +#endif
59383 +
59384 + if (unlikely(!(gr_status & GR_READY)))
59385 + return 0;
59386 +
59387 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
59388 + gr_log_learn_uid_change(real, effective, fs);
59389 +
59390 + num = current->acl->user_trans_num;
59391 + uidlist = current->acl->user_transitions;
59392 +
59393 + if (uidlist == NULL)
59394 + return 0;
59395 +
59396 + if (!uid_valid(real)) {
59397 + realok = 1;
59398 + globalreal = (uid_t)-1;
59399 + } else {
59400 + globalreal = GR_GLOBAL_UID(real);
59401 + }
59402 + if (!uid_valid(effective)) {
59403 + effectiveok = 1;
59404 + globaleffective = (uid_t)-1;
59405 + } else {
59406 + globaleffective = GR_GLOBAL_UID(effective);
59407 + }
59408 + if (!uid_valid(fs)) {
59409 + fsok = 1;
59410 + globalfs = (uid_t)-1;
59411 + } else {
59412 + globalfs = GR_GLOBAL_UID(fs);
59413 + }
59414 +
59415 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
59416 + for (i = 0; i < num; i++) {
59417 + curuid = uidlist[i];
59418 + if (globalreal == curuid)
59419 + realok = 1;
59420 + if (globaleffective == curuid)
59421 + effectiveok = 1;
59422 + if (globalfs == curuid)
59423 + fsok = 1;
59424 + }
59425 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
59426 + for (i = 0; i < num; i++) {
59427 + curuid = uidlist[i];
59428 + if (globalreal == curuid)
59429 + break;
59430 + if (globaleffective == curuid)
59431 + break;
59432 + if (globalfs == curuid)
59433 + break;
59434 + }
59435 + /* not in deny list */
59436 + if (i == num) {
59437 + realok = 1;
59438 + effectiveok = 1;
59439 + fsok = 1;
59440 + }
59441 + }
59442 +
59443 + if (realok && effectiveok && fsok)
59444 + return 0;
59445 + else {
59446 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
59447 + return 1;
59448 + }
59449 +}
59450 +
59451 +int
59452 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
59453 +{
59454 + unsigned int i;
59455 + __u16 num;
59456 + gid_t *gidlist;
59457 + gid_t curgid;
59458 + int realok = 0;
59459 + int effectiveok = 0;
59460 + int fsok = 0;
59461 + gid_t globalreal, globaleffective, globalfs;
59462 +
59463 + if (unlikely(!(gr_status & GR_READY)))
59464 + return 0;
59465 +
59466 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
59467 + gr_log_learn_gid_change(real, effective, fs);
59468 +
59469 + num = current->acl->group_trans_num;
59470 + gidlist = current->acl->group_transitions;
59471 +
59472 + if (gidlist == NULL)
59473 + return 0;
59474 +
59475 + if (!gid_valid(real)) {
59476 + realok = 1;
59477 + globalreal = (gid_t)-1;
59478 + } else {
59479 + globalreal = GR_GLOBAL_GID(real);
59480 + }
59481 + if (!gid_valid(effective)) {
59482 + effectiveok = 1;
59483 + globaleffective = (gid_t)-1;
59484 + } else {
59485 + globaleffective = GR_GLOBAL_GID(effective);
59486 + }
59487 + if (!gid_valid(fs)) {
59488 + fsok = 1;
59489 + globalfs = (gid_t)-1;
59490 + } else {
59491 + globalfs = GR_GLOBAL_GID(fs);
59492 + }
59493 +
59494 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
59495 + for (i = 0; i < num; i++) {
59496 + curgid = gidlist[i];
59497 + if (globalreal == curgid)
59498 + realok = 1;
59499 + if (globaleffective == curgid)
59500 + effectiveok = 1;
59501 + if (globalfs == curgid)
59502 + fsok = 1;
59503 + }
59504 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
59505 + for (i = 0; i < num; i++) {
59506 + curgid = gidlist[i];
59507 + if (globalreal == curgid)
59508 + break;
59509 + if (globaleffective == curgid)
59510 + break;
59511 + if (globalfs == curgid)
59512 + break;
59513 + }
59514 + /* not in deny list */
59515 + if (i == num) {
59516 + realok = 1;
59517 + effectiveok = 1;
59518 + fsok = 1;
59519 + }
59520 + }
59521 +
59522 + if (realok && effectiveok && fsok)
59523 + return 0;
59524 + else {
59525 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
59526 + return 1;
59527 + }
59528 +}
59529 +
59530 +extern int gr_acl_is_capable(const int cap);
59531 +
59532 +void
59533 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
59534 +{
59535 + struct acl_role_label *role = task->role;
59536 + struct acl_subject_label *subj = NULL;
59537 + struct acl_object_label *obj;
59538 + struct file *filp;
59539 + uid_t uid;
59540 + gid_t gid;
59541 +
59542 + if (unlikely(!(gr_status & GR_READY)))
59543 + return;
59544 +
59545 + uid = GR_GLOBAL_UID(kuid);
59546 + gid = GR_GLOBAL_GID(kgid);
59547 +
59548 + filp = task->exec_file;
59549 +
59550 + /* kernel process, we'll give them the kernel role */
59551 + if (unlikely(!filp)) {
59552 + task->role = kernel_role;
59553 + task->acl = kernel_role->root_label;
59554 + return;
59555 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
59556 + role = lookup_acl_role_label(task, uid, gid);
59557 +
59558 + /* don't change the role if we're not a privileged process */
59559 + if (role && task->role != role &&
59560 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
59561 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
59562 + return;
59563 +
59564 + /* perform subject lookup in possibly new role
59565 + we can use this result below in the case where role == task->role
59566 + */
59567 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
59568 +
59569 + /* if we changed uid/gid, but result in the same role
59570 + and are using inheritance, don't lose the inherited subject
59571 + if current subject is other than what normal lookup
59572 + would result in, we arrived via inheritance, don't
59573 + lose subject
59574 + */
59575 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
59576 + (subj == task->acl)))
59577 + task->acl = subj;
59578 +
59579 + task->role = role;
59580 +
59581 + task->is_writable = 0;
59582 +
59583 + /* ignore additional mmap checks for processes that are writable
59584 + by the default ACL */
59585 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
59586 + if (unlikely(obj->mode & GR_WRITE))
59587 + task->is_writable = 1;
59588 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
59589 + if (unlikely(obj->mode & GR_WRITE))
59590 + task->is_writable = 1;
59591 +
59592 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59593 + 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);
59594 +#endif
59595 +
59596 + gr_set_proc_res(task);
59597 +
59598 + return;
59599 +}
59600 +
59601 +int
59602 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
59603 + const int unsafe_flags)
59604 +{
59605 + struct task_struct *task = current;
59606 + struct acl_subject_label *newacl;
59607 + struct acl_object_label *obj;
59608 + __u32 retmode;
59609 +
59610 + if (unlikely(!(gr_status & GR_READY)))
59611 + return 0;
59612 +
59613 + newacl = chk_subj_label(dentry, mnt, task->role);
59614 +
59615 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
59616 + did an exec
59617 + */
59618 + rcu_read_lock();
59619 + read_lock(&tasklist_lock);
59620 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
59621 + (task->parent->acl->mode & GR_POVERRIDE))) {
59622 + read_unlock(&tasklist_lock);
59623 + rcu_read_unlock();
59624 + goto skip_check;
59625 + }
59626 + read_unlock(&tasklist_lock);
59627 + rcu_read_unlock();
59628 +
59629 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
59630 + !(task->role->roletype & GR_ROLE_GOD) &&
59631 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
59632 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
59633 + if (unsafe_flags & LSM_UNSAFE_SHARE)
59634 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
59635 + else
59636 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
59637 + return -EACCES;
59638 + }
59639 +
59640 +skip_check:
59641 +
59642 + obj = chk_obj_label(dentry, mnt, task->acl);
59643 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
59644 +
59645 + if (!(task->acl->mode & GR_INHERITLEARN) &&
59646 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
59647 + if (obj->nested)
59648 + task->acl = obj->nested;
59649 + else
59650 + task->acl = newacl;
59651 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
59652 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
59653 +
59654 + task->is_writable = 0;
59655 +
59656 + /* ignore additional mmap checks for processes that are writable
59657 + by the default ACL */
59658 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
59659 + if (unlikely(obj->mode & GR_WRITE))
59660 + task->is_writable = 1;
59661 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
59662 + if (unlikely(obj->mode & GR_WRITE))
59663 + task->is_writable = 1;
59664 +
59665 + gr_set_proc_res(task);
59666 +
59667 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59668 + 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);
59669 +#endif
59670 + return 0;
59671 +}
59672 +
59673 +/* always called with valid inodev ptr */
59674 +static void
59675 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
59676 +{
59677 + struct acl_object_label *matchpo;
59678 + struct acl_subject_label *matchps;
59679 + struct acl_subject_label *subj;
59680 + struct acl_role_label *role;
59681 + unsigned int x;
59682 +
59683 + FOR_EACH_ROLE_START(role)
59684 + FOR_EACH_SUBJECT_START(role, subj, x)
59685 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
59686 + matchpo->mode |= GR_DELETED;
59687 + FOR_EACH_SUBJECT_END(subj,x)
59688 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
59689 + /* nested subjects aren't in the role's subj_hash table */
59690 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
59691 + matchpo->mode |= GR_DELETED;
59692 + FOR_EACH_NESTED_SUBJECT_END(subj)
59693 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
59694 + matchps->mode |= GR_DELETED;
59695 + FOR_EACH_ROLE_END(role)
59696 +
59697 + inodev->nentry->deleted = 1;
59698 +
59699 + return;
59700 +}
59701 +
59702 +void
59703 +gr_handle_delete(const ino_t ino, const dev_t dev)
59704 +{
59705 + struct inodev_entry *inodev;
59706 +
59707 + if (unlikely(!(gr_status & GR_READY)))
59708 + return;
59709 +
59710 + write_lock(&gr_inode_lock);
59711 + inodev = lookup_inodev_entry(ino, dev);
59712 + if (inodev != NULL)
59713 + do_handle_delete(inodev, ino, dev);
59714 + write_unlock(&gr_inode_lock);
59715 +
59716 + return;
59717 +}
59718 +
59719 +static void
59720 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
59721 + const ino_t newinode, const dev_t newdevice,
59722 + struct acl_subject_label *subj)
59723 +{
59724 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
59725 + struct acl_object_label *match;
59726 +
59727 + match = subj->obj_hash[index];
59728 +
59729 + while (match && (match->inode != oldinode ||
59730 + match->device != olddevice ||
59731 + !(match->mode & GR_DELETED)))
59732 + match = match->next;
59733 +
59734 + if (match && (match->inode == oldinode)
59735 + && (match->device == olddevice)
59736 + && (match->mode & GR_DELETED)) {
59737 + if (match->prev == NULL) {
59738 + subj->obj_hash[index] = match->next;
59739 + if (match->next != NULL)
59740 + match->next->prev = NULL;
59741 + } else {
59742 + match->prev->next = match->next;
59743 + if (match->next != NULL)
59744 + match->next->prev = match->prev;
59745 + }
59746 + match->prev = NULL;
59747 + match->next = NULL;
59748 + match->inode = newinode;
59749 + match->device = newdevice;
59750 + match->mode &= ~GR_DELETED;
59751 +
59752 + insert_acl_obj_label(match, subj);
59753 + }
59754 +
59755 + return;
59756 +}
59757 +
59758 +static void
59759 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
59760 + const ino_t newinode, const dev_t newdevice,
59761 + struct acl_role_label *role)
59762 +{
59763 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
59764 + struct acl_subject_label *match;
59765 +
59766 + match = role->subj_hash[index];
59767 +
59768 + while (match && (match->inode != oldinode ||
59769 + match->device != olddevice ||
59770 + !(match->mode & GR_DELETED)))
59771 + match = match->next;
59772 +
59773 + if (match && (match->inode == oldinode)
59774 + && (match->device == olddevice)
59775 + && (match->mode & GR_DELETED)) {
59776 + if (match->prev == NULL) {
59777 + role->subj_hash[index] = match->next;
59778 + if (match->next != NULL)
59779 + match->next->prev = NULL;
59780 + } else {
59781 + match->prev->next = match->next;
59782 + if (match->next != NULL)
59783 + match->next->prev = match->prev;
59784 + }
59785 + match->prev = NULL;
59786 + match->next = NULL;
59787 + match->inode = newinode;
59788 + match->device = newdevice;
59789 + match->mode &= ~GR_DELETED;
59790 +
59791 + insert_acl_subj_label(match, role);
59792 + }
59793 +
59794 + return;
59795 +}
59796 +
59797 +static void
59798 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
59799 + const ino_t newinode, const dev_t newdevice)
59800 +{
59801 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
59802 + struct inodev_entry *match;
59803 +
59804 + match = inodev_set.i_hash[index];
59805 +
59806 + while (match && (match->nentry->inode != oldinode ||
59807 + match->nentry->device != olddevice || !match->nentry->deleted))
59808 + match = match->next;
59809 +
59810 + if (match && (match->nentry->inode == oldinode)
59811 + && (match->nentry->device == olddevice) &&
59812 + match->nentry->deleted) {
59813 + if (match->prev == NULL) {
59814 + inodev_set.i_hash[index] = match->next;
59815 + if (match->next != NULL)
59816 + match->next->prev = NULL;
59817 + } else {
59818 + match->prev->next = match->next;
59819 + if (match->next != NULL)
59820 + match->next->prev = match->prev;
59821 + }
59822 + match->prev = NULL;
59823 + match->next = NULL;
59824 + match->nentry->inode = newinode;
59825 + match->nentry->device = newdevice;
59826 + match->nentry->deleted = 0;
59827 +
59828 + insert_inodev_entry(match);
59829 + }
59830 +
59831 + return;
59832 +}
59833 +
59834 +static void
59835 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
59836 +{
59837 + struct acl_subject_label *subj;
59838 + struct acl_role_label *role;
59839 + unsigned int x;
59840 +
59841 + FOR_EACH_ROLE_START(role)
59842 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
59843 +
59844 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
59845 + if ((subj->inode == ino) && (subj->device == dev)) {
59846 + subj->inode = ino;
59847 + subj->device = dev;
59848 + }
59849 + /* nested subjects aren't in the role's subj_hash table */
59850 + update_acl_obj_label(matchn->inode, matchn->device,
59851 + ino, dev, subj);
59852 + FOR_EACH_NESTED_SUBJECT_END(subj)
59853 + FOR_EACH_SUBJECT_START(role, subj, x)
59854 + update_acl_obj_label(matchn->inode, matchn->device,
59855 + ino, dev, subj);
59856 + FOR_EACH_SUBJECT_END(subj,x)
59857 + FOR_EACH_ROLE_END(role)
59858 +
59859 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
59860 +
59861 + return;
59862 +}
59863 +
59864 +static void
59865 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
59866 + const struct vfsmount *mnt)
59867 +{
59868 + ino_t ino = dentry->d_inode->i_ino;
59869 + dev_t dev = __get_dev(dentry);
59870 +
59871 + __do_handle_create(matchn, ino, dev);
59872 +
59873 + return;
59874 +}
59875 +
59876 +void
59877 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
59878 +{
59879 + struct name_entry *matchn;
59880 +
59881 + if (unlikely(!(gr_status & GR_READY)))
59882 + return;
59883 +
59884 + preempt_disable();
59885 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
59886 +
59887 + if (unlikely((unsigned long)matchn)) {
59888 + write_lock(&gr_inode_lock);
59889 + do_handle_create(matchn, dentry, mnt);
59890 + write_unlock(&gr_inode_lock);
59891 + }
59892 + preempt_enable();
59893 +
59894 + return;
59895 +}
59896 +
59897 +void
59898 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
59899 +{
59900 + struct name_entry *matchn;
59901 +
59902 + if (unlikely(!(gr_status & GR_READY)))
59903 + return;
59904 +
59905 + preempt_disable();
59906 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
59907 +
59908 + if (unlikely((unsigned long)matchn)) {
59909 + write_lock(&gr_inode_lock);
59910 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
59911 + write_unlock(&gr_inode_lock);
59912 + }
59913 + preempt_enable();
59914 +
59915 + return;
59916 +}
59917 +
59918 +void
59919 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
59920 + struct dentry *old_dentry,
59921 + struct dentry *new_dentry,
59922 + struct vfsmount *mnt, const __u8 replace)
59923 +{
59924 + struct name_entry *matchn;
59925 + struct inodev_entry *inodev;
59926 + struct inode *inode = new_dentry->d_inode;
59927 + ino_t old_ino = old_dentry->d_inode->i_ino;
59928 + dev_t old_dev = __get_dev(old_dentry);
59929 +
59930 + /* vfs_rename swaps the name and parent link for old_dentry and
59931 + new_dentry
59932 + at this point, old_dentry has the new name, parent link, and inode
59933 + for the renamed file
59934 + if a file is being replaced by a rename, new_dentry has the inode
59935 + and name for the replaced file
59936 + */
59937 +
59938 + if (unlikely(!(gr_status & GR_READY)))
59939 + return;
59940 +
59941 + preempt_disable();
59942 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
59943 +
59944 + /* we wouldn't have to check d_inode if it weren't for
59945 + NFS silly-renaming
59946 + */
59947 +
59948 + write_lock(&gr_inode_lock);
59949 + if (unlikely(replace && inode)) {
59950 + ino_t new_ino = inode->i_ino;
59951 + dev_t new_dev = __get_dev(new_dentry);
59952 +
59953 + inodev = lookup_inodev_entry(new_ino, new_dev);
59954 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
59955 + do_handle_delete(inodev, new_ino, new_dev);
59956 + }
59957 +
59958 + inodev = lookup_inodev_entry(old_ino, old_dev);
59959 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
59960 + do_handle_delete(inodev, old_ino, old_dev);
59961 +
59962 + if (unlikely((unsigned long)matchn))
59963 + do_handle_create(matchn, old_dentry, mnt);
59964 +
59965 + write_unlock(&gr_inode_lock);
59966 + preempt_enable();
59967 +
59968 + return;
59969 +}
59970 +
59971 +static int
59972 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
59973 + unsigned char **sum)
59974 +{
59975 + struct acl_role_label *r;
59976 + struct role_allowed_ip *ipp;
59977 + struct role_transition *trans;
59978 + unsigned int i;
59979 + int found = 0;
59980 + u32 curr_ip = current->signal->curr_ip;
59981 +
59982 + current->signal->saved_ip = curr_ip;
59983 +
59984 + /* check transition table */
59985 +
59986 + for (trans = current->role->transitions; trans; trans = trans->next) {
59987 + if (!strcmp(rolename, trans->rolename)) {
59988 + found = 1;
59989 + break;
59990 + }
59991 + }
59992 +
59993 + if (!found)
59994 + return 0;
59995 +
59996 + /* handle special roles that do not require authentication
59997 + and check ip */
59998 +
59999 + FOR_EACH_ROLE_START(r)
60000 + if (!strcmp(rolename, r->rolename) &&
60001 + (r->roletype & GR_ROLE_SPECIAL)) {
60002 + found = 0;
60003 + if (r->allowed_ips != NULL) {
60004 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
60005 + if ((ntohl(curr_ip) & ipp->netmask) ==
60006 + (ntohl(ipp->addr) & ipp->netmask))
60007 + found = 1;
60008 + }
60009 + } else
60010 + found = 2;
60011 + if (!found)
60012 + return 0;
60013 +
60014 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
60015 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
60016 + *salt = NULL;
60017 + *sum = NULL;
60018 + return 1;
60019 + }
60020 + }
60021 + FOR_EACH_ROLE_END(r)
60022 +
60023 + for (i = 0; i < num_sprole_pws; i++) {
60024 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
60025 + *salt = acl_special_roles[i]->salt;
60026 + *sum = acl_special_roles[i]->sum;
60027 + return 1;
60028 + }
60029 + }
60030 +
60031 + return 0;
60032 +}
60033 +
60034 +static void
60035 +assign_special_role(char *rolename)
60036 +{
60037 + struct acl_object_label *obj;
60038 + struct acl_role_label *r;
60039 + struct acl_role_label *assigned = NULL;
60040 + struct task_struct *tsk;
60041 + struct file *filp;
60042 +
60043 + FOR_EACH_ROLE_START(r)
60044 + if (!strcmp(rolename, r->rolename) &&
60045 + (r->roletype & GR_ROLE_SPECIAL)) {
60046 + assigned = r;
60047 + break;
60048 + }
60049 + FOR_EACH_ROLE_END(r)
60050 +
60051 + if (!assigned)
60052 + return;
60053 +
60054 + read_lock(&tasklist_lock);
60055 + read_lock(&grsec_exec_file_lock);
60056 +
60057 + tsk = current->real_parent;
60058 + if (tsk == NULL)
60059 + goto out_unlock;
60060 +
60061 + filp = tsk->exec_file;
60062 + if (filp == NULL)
60063 + goto out_unlock;
60064 +
60065 + tsk->is_writable = 0;
60066 +
60067 + tsk->acl_sp_role = 1;
60068 + tsk->acl_role_id = ++acl_sp_role_value;
60069 + tsk->role = assigned;
60070 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
60071 +
60072 + /* ignore additional mmap checks for processes that are writable
60073 + by the default ACL */
60074 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60075 + if (unlikely(obj->mode & GR_WRITE))
60076 + tsk->is_writable = 1;
60077 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
60078 + if (unlikely(obj->mode & GR_WRITE))
60079 + tsk->is_writable = 1;
60080 +
60081 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60082 + 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));
60083 +#endif
60084 +
60085 +out_unlock:
60086 + read_unlock(&grsec_exec_file_lock);
60087 + read_unlock(&tasklist_lock);
60088 + return;
60089 +}
60090 +
60091 +int gr_check_secure_terminal(struct task_struct *task)
60092 +{
60093 + struct task_struct *p, *p2, *p3;
60094 + struct files_struct *files;
60095 + struct fdtable *fdt;
60096 + struct file *our_file = NULL, *file;
60097 + int i;
60098 +
60099 + if (task->signal->tty == NULL)
60100 + return 1;
60101 +
60102 + files = get_files_struct(task);
60103 + if (files != NULL) {
60104 + rcu_read_lock();
60105 + fdt = files_fdtable(files);
60106 + for (i=0; i < fdt->max_fds; i++) {
60107 + file = fcheck_files(files, i);
60108 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
60109 + get_file(file);
60110 + our_file = file;
60111 + }
60112 + }
60113 + rcu_read_unlock();
60114 + put_files_struct(files);
60115 + }
60116 +
60117 + if (our_file == NULL)
60118 + return 1;
60119 +
60120 + read_lock(&tasklist_lock);
60121 + do_each_thread(p2, p) {
60122 + files = get_files_struct(p);
60123 + if (files == NULL ||
60124 + (p->signal && p->signal->tty == task->signal->tty)) {
60125 + if (files != NULL)
60126 + put_files_struct(files);
60127 + continue;
60128 + }
60129 + rcu_read_lock();
60130 + fdt = files_fdtable(files);
60131 + for (i=0; i < fdt->max_fds; i++) {
60132 + file = fcheck_files(files, i);
60133 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
60134 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
60135 + p3 = task;
60136 + while (task_pid_nr(p3) > 0) {
60137 + if (p3 == p)
60138 + break;
60139 + p3 = p3->real_parent;
60140 + }
60141 + if (p3 == p)
60142 + break;
60143 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
60144 + gr_handle_alertkill(p);
60145 + rcu_read_unlock();
60146 + put_files_struct(files);
60147 + read_unlock(&tasklist_lock);
60148 + fput(our_file);
60149 + return 0;
60150 + }
60151 + }
60152 + rcu_read_unlock();
60153 + put_files_struct(files);
60154 + } while_each_thread(p2, p);
60155 + read_unlock(&tasklist_lock);
60156 +
60157 + fput(our_file);
60158 + return 1;
60159 +}
60160 +
60161 +static int gr_rbac_disable(void *unused)
60162 +{
60163 + pax_open_kernel();
60164 + gr_status &= ~GR_READY;
60165 + pax_close_kernel();
60166 +
60167 + return 0;
60168 +}
60169 +
60170 +ssize_t
60171 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
60172 +{
60173 + struct gr_arg_wrapper uwrap;
60174 + unsigned char *sprole_salt = NULL;
60175 + unsigned char *sprole_sum = NULL;
60176 + int error = sizeof (struct gr_arg_wrapper);
60177 + int error2 = 0;
60178 +
60179 + mutex_lock(&gr_dev_mutex);
60180 +
60181 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
60182 + error = -EPERM;
60183 + goto out;
60184 + }
60185 +
60186 + if (count != sizeof (struct gr_arg_wrapper)) {
60187 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
60188 + error = -EINVAL;
60189 + goto out;
60190 + }
60191 +
60192 +
60193 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
60194 + gr_auth_expires = 0;
60195 + gr_auth_attempts = 0;
60196 + }
60197 +
60198 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
60199 + error = -EFAULT;
60200 + goto out;
60201 + }
60202 +
60203 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
60204 + error = -EINVAL;
60205 + goto out;
60206 + }
60207 +
60208 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
60209 + error = -EFAULT;
60210 + goto out;
60211 + }
60212 +
60213 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
60214 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
60215 + time_after(gr_auth_expires, get_seconds())) {
60216 + error = -EBUSY;
60217 + goto out;
60218 + }
60219 +
60220 + /* if non-root trying to do anything other than use a special role,
60221 + do not attempt authentication, do not count towards authentication
60222 + locking
60223 + */
60224 +
60225 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
60226 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
60227 + gr_is_global_nonroot(current_uid())) {
60228 + error = -EPERM;
60229 + goto out;
60230 + }
60231 +
60232 + /* ensure pw and special role name are null terminated */
60233 +
60234 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
60235 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
60236 +
60237 + /* Okay.
60238 + * We have our enough of the argument structure..(we have yet
60239 + * to copy_from_user the tables themselves) . Copy the tables
60240 + * only if we need them, i.e. for loading operations. */
60241 +
60242 + switch (gr_usermode->mode) {
60243 + case GR_STATUS:
60244 + if (gr_status & GR_READY) {
60245 + error = 1;
60246 + if (!gr_check_secure_terminal(current))
60247 + error = 3;
60248 + } else
60249 + error = 2;
60250 + goto out;
60251 + case GR_SHUTDOWN:
60252 + if ((gr_status & GR_READY)
60253 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60254 + stop_machine(gr_rbac_disable, NULL, NULL);
60255 + free_variables();
60256 + memset(gr_usermode, 0, sizeof (struct gr_arg));
60257 + memset(gr_system_salt, 0, GR_SALT_LEN);
60258 + memset(gr_system_sum, 0, GR_SHA_LEN);
60259 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
60260 + } else if (gr_status & GR_READY) {
60261 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
60262 + error = -EPERM;
60263 + } else {
60264 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
60265 + error = -EAGAIN;
60266 + }
60267 + break;
60268 + case GR_ENABLE:
60269 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
60270 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
60271 + else {
60272 + if (gr_status & GR_READY)
60273 + error = -EAGAIN;
60274 + else
60275 + error = error2;
60276 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
60277 + }
60278 + break;
60279 + case GR_RELOAD:
60280 + if (!(gr_status & GR_READY)) {
60281 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
60282 + error = -EAGAIN;
60283 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60284 + stop_machine(gr_rbac_disable, NULL, NULL);
60285 + free_variables();
60286 + error2 = gracl_init(gr_usermode);
60287 + if (!error2)
60288 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
60289 + else {
60290 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
60291 + error = error2;
60292 + }
60293 + } else {
60294 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
60295 + error = -EPERM;
60296 + }
60297 + break;
60298 + case GR_SEGVMOD:
60299 + if (unlikely(!(gr_status & GR_READY))) {
60300 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
60301 + error = -EAGAIN;
60302 + break;
60303 + }
60304 +
60305 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
60306 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
60307 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
60308 + struct acl_subject_label *segvacl;
60309 + segvacl =
60310 + lookup_acl_subj_label(gr_usermode->segv_inode,
60311 + gr_usermode->segv_device,
60312 + current->role);
60313 + if (segvacl) {
60314 + segvacl->crashes = 0;
60315 + segvacl->expires = 0;
60316 + }
60317 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
60318 + gr_remove_uid(gr_usermode->segv_uid);
60319 + }
60320 + } else {
60321 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
60322 + error = -EPERM;
60323 + }
60324 + break;
60325 + case GR_SPROLE:
60326 + case GR_SPROLEPAM:
60327 + if (unlikely(!(gr_status & GR_READY))) {
60328 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
60329 + error = -EAGAIN;
60330 + break;
60331 + }
60332 +
60333 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
60334 + current->role->expires = 0;
60335 + current->role->auth_attempts = 0;
60336 + }
60337 +
60338 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
60339 + time_after(current->role->expires, get_seconds())) {
60340 + error = -EBUSY;
60341 + goto out;
60342 + }
60343 +
60344 + if (lookup_special_role_auth
60345 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
60346 + && ((!sprole_salt && !sprole_sum)
60347 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
60348 + char *p = "";
60349 + assign_special_role(gr_usermode->sp_role);
60350 + read_lock(&tasklist_lock);
60351 + if (current->real_parent)
60352 + p = current->real_parent->role->rolename;
60353 + read_unlock(&tasklist_lock);
60354 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
60355 + p, acl_sp_role_value);
60356 + } else {
60357 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
60358 + error = -EPERM;
60359 + if(!(current->role->auth_attempts++))
60360 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
60361 +
60362 + goto out;
60363 + }
60364 + break;
60365 + case GR_UNSPROLE:
60366 + if (unlikely(!(gr_status & GR_READY))) {
60367 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
60368 + error = -EAGAIN;
60369 + break;
60370 + }
60371 +
60372 + if (current->role->roletype & GR_ROLE_SPECIAL) {
60373 + char *p = "";
60374 + int i = 0;
60375 +
60376 + read_lock(&tasklist_lock);
60377 + if (current->real_parent) {
60378 + p = current->real_parent->role->rolename;
60379 + i = current->real_parent->acl_role_id;
60380 + }
60381 + read_unlock(&tasklist_lock);
60382 +
60383 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
60384 + gr_set_acls(1);
60385 + } else {
60386 + error = -EPERM;
60387 + goto out;
60388 + }
60389 + break;
60390 + default:
60391 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
60392 + error = -EINVAL;
60393 + break;
60394 + }
60395 +
60396 + if (error != -EPERM)
60397 + goto out;
60398 +
60399 + if(!(gr_auth_attempts++))
60400 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
60401 +
60402 + out:
60403 + mutex_unlock(&gr_dev_mutex);
60404 + return error;
60405 +}
60406 +
60407 +/* must be called with
60408 + rcu_read_lock();
60409 + read_lock(&tasklist_lock);
60410 + read_lock(&grsec_exec_file_lock);
60411 +*/
60412 +int gr_apply_subject_to_task(struct task_struct *task)
60413 +{
60414 + struct acl_object_label *obj;
60415 + char *tmpname;
60416 + struct acl_subject_label *tmpsubj;
60417 + struct file *filp;
60418 + struct name_entry *nmatch;
60419 +
60420 + filp = task->exec_file;
60421 + if (filp == NULL)
60422 + return 0;
60423 +
60424 + /* the following is to apply the correct subject
60425 + on binaries running when the RBAC system
60426 + is enabled, when the binaries have been
60427 + replaced or deleted since their execution
60428 + -----
60429 + when the RBAC system starts, the inode/dev
60430 + from exec_file will be one the RBAC system
60431 + is unaware of. It only knows the inode/dev
60432 + of the present file on disk, or the absence
60433 + of it.
60434 + */
60435 + preempt_disable();
60436 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
60437 +
60438 + nmatch = lookup_name_entry(tmpname);
60439 + preempt_enable();
60440 + tmpsubj = NULL;
60441 + if (nmatch) {
60442 + if (nmatch->deleted)
60443 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
60444 + else
60445 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
60446 + if (tmpsubj != NULL)
60447 + task->acl = tmpsubj;
60448 + }
60449 + if (tmpsubj == NULL)
60450 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
60451 + task->role);
60452 + if (task->acl) {
60453 + task->is_writable = 0;
60454 + /* ignore additional mmap checks for processes that are writable
60455 + by the default ACL */
60456 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60457 + if (unlikely(obj->mode & GR_WRITE))
60458 + task->is_writable = 1;
60459 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60460 + if (unlikely(obj->mode & GR_WRITE))
60461 + task->is_writable = 1;
60462 +
60463 + gr_set_proc_res(task);
60464 +
60465 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60466 + 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);
60467 +#endif
60468 + } else {
60469 + return 1;
60470 + }
60471 +
60472 + return 0;
60473 +}
60474 +
60475 +int
60476 +gr_set_acls(const int type)
60477 +{
60478 + struct task_struct *task, *task2;
60479 + struct acl_role_label *role = current->role;
60480 + __u16 acl_role_id = current->acl_role_id;
60481 + const struct cred *cred;
60482 + int ret;
60483 +
60484 + rcu_read_lock();
60485 + read_lock(&tasklist_lock);
60486 + read_lock(&grsec_exec_file_lock);
60487 + do_each_thread(task2, task) {
60488 + /* check to see if we're called from the exit handler,
60489 + if so, only replace ACLs that have inherited the admin
60490 + ACL */
60491 +
60492 + if (type && (task->role != role ||
60493 + task->acl_role_id != acl_role_id))
60494 + continue;
60495 +
60496 + task->acl_role_id = 0;
60497 + task->acl_sp_role = 0;
60498 +
60499 + if (task->exec_file) {
60500 + cred = __task_cred(task);
60501 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
60502 + ret = gr_apply_subject_to_task(task);
60503 + if (ret) {
60504 + read_unlock(&grsec_exec_file_lock);
60505 + read_unlock(&tasklist_lock);
60506 + rcu_read_unlock();
60507 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
60508 + return ret;
60509 + }
60510 + } else {
60511 + // it's a kernel process
60512 + task->role = kernel_role;
60513 + task->acl = kernel_role->root_label;
60514 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
60515 + task->acl->mode &= ~GR_PROCFIND;
60516 +#endif
60517 + }
60518 + } while_each_thread(task2, task);
60519 + read_unlock(&grsec_exec_file_lock);
60520 + read_unlock(&tasklist_lock);
60521 + rcu_read_unlock();
60522 +
60523 + return 0;
60524 +}
60525 +
60526 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
60527 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
60528 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
60529 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
60530 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
60531 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
60532 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
60533 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
60534 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
60535 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
60536 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
60537 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
60538 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
60539 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
60540 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
60541 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
60542 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
60543 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
60544 +};
60545 +
60546 +void
60547 +gr_learn_resource(const struct task_struct *task,
60548 + const int res, const unsigned long wanted, const int gt)
60549 +{
60550 + struct acl_subject_label *acl;
60551 + const struct cred *cred;
60552 +
60553 + if (unlikely((gr_status & GR_READY) &&
60554 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
60555 + goto skip_reslog;
60556 +
60557 + gr_log_resource(task, res, wanted, gt);
60558 +skip_reslog:
60559 +
60560 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
60561 + return;
60562 +
60563 + acl = task->acl;
60564 +
60565 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
60566 + !(acl->resmask & (1U << (unsigned short) res))))
60567 + return;
60568 +
60569 + if (wanted >= acl->res[res].rlim_cur) {
60570 + unsigned long res_add;
60571 +
60572 + res_add = wanted + res_learn_bumps[res];
60573 +
60574 + acl->res[res].rlim_cur = res_add;
60575 +
60576 + if (wanted > acl->res[res].rlim_max)
60577 + acl->res[res].rlim_max = res_add;
60578 +
60579 + /* only log the subject filename, since resource logging is supported for
60580 + single-subject learning only */
60581 + rcu_read_lock();
60582 + cred = __task_cred(task);
60583 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
60584 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
60585 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
60586 + "", (unsigned long) res, &task->signal->saved_ip);
60587 + rcu_read_unlock();
60588 + }
60589 +
60590 + return;
60591 +}
60592 +EXPORT_SYMBOL(gr_learn_resource);
60593 +#endif
60594 +
60595 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
60596 +void
60597 +pax_set_initial_flags(struct linux_binprm *bprm)
60598 +{
60599 + struct task_struct *task = current;
60600 + struct acl_subject_label *proc;
60601 + unsigned long flags;
60602 +
60603 + if (unlikely(!(gr_status & GR_READY)))
60604 + return;
60605 +
60606 + flags = pax_get_flags(task);
60607 +
60608 + proc = task->acl;
60609 +
60610 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
60611 + flags &= ~MF_PAX_PAGEEXEC;
60612 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
60613 + flags &= ~MF_PAX_SEGMEXEC;
60614 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
60615 + flags &= ~MF_PAX_RANDMMAP;
60616 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
60617 + flags &= ~MF_PAX_EMUTRAMP;
60618 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
60619 + flags &= ~MF_PAX_MPROTECT;
60620 +
60621 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
60622 + flags |= MF_PAX_PAGEEXEC;
60623 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
60624 + flags |= MF_PAX_SEGMEXEC;
60625 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
60626 + flags |= MF_PAX_RANDMMAP;
60627 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
60628 + flags |= MF_PAX_EMUTRAMP;
60629 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
60630 + flags |= MF_PAX_MPROTECT;
60631 +
60632 + pax_set_flags(task, flags);
60633 +
60634 + return;
60635 +}
60636 +#endif
60637 +
60638 +int
60639 +gr_handle_proc_ptrace(struct task_struct *task)
60640 +{
60641 + struct file *filp;
60642 + struct task_struct *tmp = task;
60643 + struct task_struct *curtemp = current;
60644 + __u32 retmode;
60645 +
60646 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
60647 + if (unlikely(!(gr_status & GR_READY)))
60648 + return 0;
60649 +#endif
60650 +
60651 + read_lock(&tasklist_lock);
60652 + read_lock(&grsec_exec_file_lock);
60653 + filp = task->exec_file;
60654 +
60655 + while (task_pid_nr(tmp) > 0) {
60656 + if (tmp == curtemp)
60657 + break;
60658 + tmp = tmp->real_parent;
60659 + }
60660 +
60661 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
60662 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
60663 + read_unlock(&grsec_exec_file_lock);
60664 + read_unlock(&tasklist_lock);
60665 + return 1;
60666 + }
60667 +
60668 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
60669 + if (!(gr_status & GR_READY)) {
60670 + read_unlock(&grsec_exec_file_lock);
60671 + read_unlock(&tasklist_lock);
60672 + return 0;
60673 + }
60674 +#endif
60675 +
60676 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
60677 + read_unlock(&grsec_exec_file_lock);
60678 + read_unlock(&tasklist_lock);
60679 +
60680 + if (retmode & GR_NOPTRACE)
60681 + return 1;
60682 +
60683 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
60684 + && (current->acl != task->acl || (current->acl != current->role->root_label
60685 + && task_pid_nr(current) != task_pid_nr(task))))
60686 + return 1;
60687 +
60688 + return 0;
60689 +}
60690 +
60691 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
60692 +{
60693 + if (unlikely(!(gr_status & GR_READY)))
60694 + return;
60695 +
60696 + if (!(current->role->roletype & GR_ROLE_GOD))
60697 + return;
60698 +
60699 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
60700 + p->role->rolename, gr_task_roletype_to_char(p),
60701 + p->acl->filename);
60702 +}
60703 +
60704 +int
60705 +gr_handle_ptrace(struct task_struct *task, const long request)
60706 +{
60707 + struct task_struct *tmp = task;
60708 + struct task_struct *curtemp = current;
60709 + __u32 retmode;
60710 +
60711 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
60712 + if (unlikely(!(gr_status & GR_READY)))
60713 + return 0;
60714 +#endif
60715 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
60716 + read_lock(&tasklist_lock);
60717 + while (task_pid_nr(tmp) > 0) {
60718 + if (tmp == curtemp)
60719 + break;
60720 + tmp = tmp->real_parent;
60721 + }
60722 +
60723 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
60724 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
60725 + read_unlock(&tasklist_lock);
60726 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
60727 + return 1;
60728 + }
60729 + read_unlock(&tasklist_lock);
60730 + }
60731 +
60732 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
60733 + if (!(gr_status & GR_READY))
60734 + return 0;
60735 +#endif
60736 +
60737 + read_lock(&grsec_exec_file_lock);
60738 + if (unlikely(!task->exec_file)) {
60739 + read_unlock(&grsec_exec_file_lock);
60740 + return 0;
60741 + }
60742 +
60743 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
60744 + read_unlock(&grsec_exec_file_lock);
60745 +
60746 + if (retmode & GR_NOPTRACE) {
60747 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
60748 + return 1;
60749 + }
60750 +
60751 + if (retmode & GR_PTRACERD) {
60752 + switch (request) {
60753 + case PTRACE_SEIZE:
60754 + case PTRACE_POKETEXT:
60755 + case PTRACE_POKEDATA:
60756 + case PTRACE_POKEUSR:
60757 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
60758 + case PTRACE_SETREGS:
60759 + case PTRACE_SETFPREGS:
60760 +#endif
60761 +#ifdef CONFIG_X86
60762 + case PTRACE_SETFPXREGS:
60763 +#endif
60764 +#ifdef CONFIG_ALTIVEC
60765 + case PTRACE_SETVRREGS:
60766 +#endif
60767 + return 1;
60768 + default:
60769 + return 0;
60770 + }
60771 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
60772 + !(current->role->roletype & GR_ROLE_GOD) &&
60773 + (current->acl != task->acl)) {
60774 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
60775 + return 1;
60776 + }
60777 +
60778 + return 0;
60779 +}
60780 +
60781 +static int is_writable_mmap(const struct file *filp)
60782 +{
60783 + struct task_struct *task = current;
60784 + struct acl_object_label *obj, *obj2;
60785 +
60786 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
60787 + !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))) {
60788 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60789 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
60790 + task->role->root_label);
60791 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
60792 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
60793 + return 1;
60794 + }
60795 + }
60796 + return 0;
60797 +}
60798 +
60799 +int
60800 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
60801 +{
60802 + __u32 mode;
60803 +
60804 + if (unlikely(!file || !(prot & PROT_EXEC)))
60805 + return 1;
60806 +
60807 + if (is_writable_mmap(file))
60808 + return 0;
60809 +
60810 + mode =
60811 + gr_search_file(file->f_path.dentry,
60812 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
60813 + file->f_path.mnt);
60814 +
60815 + if (!gr_tpe_allow(file))
60816 + return 0;
60817 +
60818 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
60819 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
60820 + return 0;
60821 + } else if (unlikely(!(mode & GR_EXEC))) {
60822 + return 0;
60823 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
60824 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
60825 + return 1;
60826 + }
60827 +
60828 + return 1;
60829 +}
60830 +
60831 +int
60832 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
60833 +{
60834 + __u32 mode;
60835 +
60836 + if (unlikely(!file || !(prot & PROT_EXEC)))
60837 + return 1;
60838 +
60839 + if (is_writable_mmap(file))
60840 + return 0;
60841 +
60842 + mode =
60843 + gr_search_file(file->f_path.dentry,
60844 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
60845 + file->f_path.mnt);
60846 +
60847 + if (!gr_tpe_allow(file))
60848 + return 0;
60849 +
60850 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
60851 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
60852 + return 0;
60853 + } else if (unlikely(!(mode & GR_EXEC))) {
60854 + return 0;
60855 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
60856 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
60857 + return 1;
60858 + }
60859 +
60860 + return 1;
60861 +}
60862 +
60863 +void
60864 +gr_acl_handle_psacct(struct task_struct *task, const long code)
60865 +{
60866 + unsigned long runtime;
60867 + unsigned long cputime;
60868 + unsigned int wday, cday;
60869 + __u8 whr, chr;
60870 + __u8 wmin, cmin;
60871 + __u8 wsec, csec;
60872 + struct timespec timeval;
60873 +
60874 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
60875 + !(task->acl->mode & GR_PROCACCT)))
60876 + return;
60877 +
60878 + do_posix_clock_monotonic_gettime(&timeval);
60879 + runtime = timeval.tv_sec - task->start_time.tv_sec;
60880 + wday = runtime / (3600 * 24);
60881 + runtime -= wday * (3600 * 24);
60882 + whr = runtime / 3600;
60883 + runtime -= whr * 3600;
60884 + wmin = runtime / 60;
60885 + runtime -= wmin * 60;
60886 + wsec = runtime;
60887 +
60888 + cputime = (task->utime + task->stime) / HZ;
60889 + cday = cputime / (3600 * 24);
60890 + cputime -= cday * (3600 * 24);
60891 + chr = cputime / 3600;
60892 + cputime -= chr * 3600;
60893 + cmin = cputime / 60;
60894 + cputime -= cmin * 60;
60895 + csec = cputime;
60896 +
60897 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
60898 +
60899 + return;
60900 +}
60901 +
60902 +void gr_set_kernel_label(struct task_struct *task)
60903 +{
60904 + if (gr_status & GR_READY) {
60905 + task->role = kernel_role;
60906 + task->acl = kernel_role->root_label;
60907 + }
60908 + return;
60909 +}
60910 +
60911 +#ifdef CONFIG_TASKSTATS
60912 +int gr_is_taskstats_denied(int pid)
60913 +{
60914 + struct task_struct *task;
60915 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60916 + const struct cred *cred;
60917 +#endif
60918 + int ret = 0;
60919 +
60920 + /* restrict taskstats viewing to un-chrooted root users
60921 + who have the 'view' subject flag if the RBAC system is enabled
60922 + */
60923 +
60924 + rcu_read_lock();
60925 + read_lock(&tasklist_lock);
60926 + task = find_task_by_vpid(pid);
60927 + if (task) {
60928 +#ifdef CONFIG_GRKERNSEC_CHROOT
60929 + if (proc_is_chrooted(task))
60930 + ret = -EACCES;
60931 +#endif
60932 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60933 + cred = __task_cred(task);
60934 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60935 + if (gr_is_global_nonroot(cred->uid))
60936 + ret = -EACCES;
60937 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60938 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
60939 + ret = -EACCES;
60940 +#endif
60941 +#endif
60942 + if (gr_status & GR_READY) {
60943 + if (!(task->acl->mode & GR_VIEW))
60944 + ret = -EACCES;
60945 + }
60946 + } else
60947 + ret = -ENOENT;
60948 +
60949 + read_unlock(&tasklist_lock);
60950 + rcu_read_unlock();
60951 +
60952 + return ret;
60953 +}
60954 +#endif
60955 +
60956 +/* AUXV entries are filled via a descendant of search_binary_handler
60957 + after we've already applied the subject for the target
60958 +*/
60959 +int gr_acl_enable_at_secure(void)
60960 +{
60961 + if (unlikely(!(gr_status & GR_READY)))
60962 + return 0;
60963 +
60964 + if (current->acl->mode & GR_ATSECURE)
60965 + return 1;
60966 +
60967 + return 0;
60968 +}
60969 +
60970 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
60971 +{
60972 + struct task_struct *task = current;
60973 + struct dentry *dentry = file->f_path.dentry;
60974 + struct vfsmount *mnt = file->f_path.mnt;
60975 + struct acl_object_label *obj, *tmp;
60976 + struct acl_subject_label *subj;
60977 + unsigned int bufsize;
60978 + int is_not_root;
60979 + char *path;
60980 + dev_t dev = __get_dev(dentry);
60981 +
60982 + if (unlikely(!(gr_status & GR_READY)))
60983 + return 1;
60984 +
60985 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60986 + return 1;
60987 +
60988 + /* ignore Eric Biederman */
60989 + if (IS_PRIVATE(dentry->d_inode))
60990 + return 1;
60991 +
60992 + subj = task->acl;
60993 + read_lock(&gr_inode_lock);
60994 + do {
60995 + obj = lookup_acl_obj_label(ino, dev, subj);
60996 + if (obj != NULL) {
60997 + read_unlock(&gr_inode_lock);
60998 + return (obj->mode & GR_FIND) ? 1 : 0;
60999 + }
61000 + } while ((subj = subj->parent_subject));
61001 + read_unlock(&gr_inode_lock);
61002 +
61003 + /* this is purely an optimization since we're looking for an object
61004 + for the directory we're doing a readdir on
61005 + if it's possible for any globbed object to match the entry we're
61006 + filling into the directory, then the object we find here will be
61007 + an anchor point with attached globbed objects
61008 + */
61009 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
61010 + if (obj->globbed == NULL)
61011 + return (obj->mode & GR_FIND) ? 1 : 0;
61012 +
61013 + is_not_root = ((obj->filename[0] == '/') &&
61014 + (obj->filename[1] == '\0')) ? 0 : 1;
61015 + bufsize = PAGE_SIZE - namelen - is_not_root;
61016 +
61017 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
61018 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
61019 + return 1;
61020 +
61021 + preempt_disable();
61022 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
61023 + bufsize);
61024 +
61025 + bufsize = strlen(path);
61026 +
61027 + /* if base is "/", don't append an additional slash */
61028 + if (is_not_root)
61029 + *(path + bufsize) = '/';
61030 + memcpy(path + bufsize + is_not_root, name, namelen);
61031 + *(path + bufsize + namelen + is_not_root) = '\0';
61032 +
61033 + tmp = obj->globbed;
61034 + while (tmp) {
61035 + if (!glob_match(tmp->filename, path)) {
61036 + preempt_enable();
61037 + return (tmp->mode & GR_FIND) ? 1 : 0;
61038 + }
61039 + tmp = tmp->next;
61040 + }
61041 + preempt_enable();
61042 + return (obj->mode & GR_FIND) ? 1 : 0;
61043 +}
61044 +
61045 +void gr_put_exec_file(struct task_struct *task)
61046 +{
61047 + struct file *filp;
61048 +
61049 + write_lock(&grsec_exec_file_lock);
61050 + filp = task->exec_file;
61051 + task->exec_file = NULL;
61052 + write_unlock(&grsec_exec_file_lock);
61053 +
61054 + if (filp)
61055 + fput(filp);
61056 +
61057 + return;
61058 +}
61059 +
61060 +
61061 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
61062 +EXPORT_SYMBOL(gr_acl_is_enabled);
61063 +#endif
61064 +EXPORT_SYMBOL(gr_set_kernel_label);
61065 +#ifdef CONFIG_SECURITY
61066 +EXPORT_SYMBOL(gr_check_user_change);
61067 +EXPORT_SYMBOL(gr_check_group_change);
61068 +#endif
61069 +
61070 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
61071 new file mode 100644
61072 index 0000000..34fefda
61073 --- /dev/null
61074 +++ b/grsecurity/gracl_alloc.c
61075 @@ -0,0 +1,105 @@
61076 +#include <linux/kernel.h>
61077 +#include <linux/mm.h>
61078 +#include <linux/slab.h>
61079 +#include <linux/vmalloc.h>
61080 +#include <linux/gracl.h>
61081 +#include <linux/grsecurity.h>
61082 +
61083 +static unsigned long alloc_stack_next = 1;
61084 +static unsigned long alloc_stack_size = 1;
61085 +static void **alloc_stack;
61086 +
61087 +static __inline__ int
61088 +alloc_pop(void)
61089 +{
61090 + if (alloc_stack_next == 1)
61091 + return 0;
61092 +
61093 + kfree(alloc_stack[alloc_stack_next - 2]);
61094 +
61095 + alloc_stack_next--;
61096 +
61097 + return 1;
61098 +}
61099 +
61100 +static __inline__ int
61101 +alloc_push(void *buf)
61102 +{
61103 + if (alloc_stack_next >= alloc_stack_size)
61104 + return 1;
61105 +
61106 + alloc_stack[alloc_stack_next - 1] = buf;
61107 +
61108 + alloc_stack_next++;
61109 +
61110 + return 0;
61111 +}
61112 +
61113 +void *
61114 +acl_alloc(unsigned long len)
61115 +{
61116 + void *ret = NULL;
61117 +
61118 + if (!len || len > PAGE_SIZE)
61119 + goto out;
61120 +
61121 + ret = kmalloc(len, GFP_KERNEL);
61122 +
61123 + if (ret) {
61124 + if (alloc_push(ret)) {
61125 + kfree(ret);
61126 + ret = NULL;
61127 + }
61128 + }
61129 +
61130 +out:
61131 + return ret;
61132 +}
61133 +
61134 +void *
61135 +acl_alloc_num(unsigned long num, unsigned long len)
61136 +{
61137 + if (!len || (num > (PAGE_SIZE / len)))
61138 + return NULL;
61139 +
61140 + return acl_alloc(num * len);
61141 +}
61142 +
61143 +void
61144 +acl_free_all(void)
61145 +{
61146 + if (gr_acl_is_enabled() || !alloc_stack)
61147 + return;
61148 +
61149 + while (alloc_pop()) ;
61150 +
61151 + if (alloc_stack) {
61152 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
61153 + kfree(alloc_stack);
61154 + else
61155 + vfree(alloc_stack);
61156 + }
61157 +
61158 + alloc_stack = NULL;
61159 + alloc_stack_size = 1;
61160 + alloc_stack_next = 1;
61161 +
61162 + return;
61163 +}
61164 +
61165 +int
61166 +acl_alloc_stack_init(unsigned long size)
61167 +{
61168 + if ((size * sizeof (void *)) <= PAGE_SIZE)
61169 + alloc_stack =
61170 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
61171 + else
61172 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
61173 +
61174 + alloc_stack_size = size;
61175 +
61176 + if (!alloc_stack)
61177 + return 0;
61178 + else
61179 + return 1;
61180 +}
61181 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
61182 new file mode 100644
61183 index 0000000..bdd51ea
61184 --- /dev/null
61185 +++ b/grsecurity/gracl_cap.c
61186 @@ -0,0 +1,110 @@
61187 +#include <linux/kernel.h>
61188 +#include <linux/module.h>
61189 +#include <linux/sched.h>
61190 +#include <linux/gracl.h>
61191 +#include <linux/grsecurity.h>
61192 +#include <linux/grinternal.h>
61193 +
61194 +extern const char *captab_log[];
61195 +extern int captab_log_entries;
61196 +
61197 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
61198 +{
61199 + struct acl_subject_label *curracl;
61200 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
61201 + kernel_cap_t cap_audit = __cap_empty_set;
61202 +
61203 + if (!gr_acl_is_enabled())
61204 + return 1;
61205 +
61206 + curracl = task->acl;
61207 +
61208 + cap_drop = curracl->cap_lower;
61209 + cap_mask = curracl->cap_mask;
61210 + cap_audit = curracl->cap_invert_audit;
61211 +
61212 + while ((curracl = curracl->parent_subject)) {
61213 + /* if the cap isn't specified in the current computed mask but is specified in the
61214 + current level subject, and is lowered in the current level subject, then add
61215 + it to the set of dropped capabilities
61216 + otherwise, add the current level subject's mask to the current computed mask
61217 + */
61218 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
61219 + cap_raise(cap_mask, cap);
61220 + if (cap_raised(curracl->cap_lower, cap))
61221 + cap_raise(cap_drop, cap);
61222 + if (cap_raised(curracl->cap_invert_audit, cap))
61223 + cap_raise(cap_audit, cap);
61224 + }
61225 + }
61226 +
61227 + if (!cap_raised(cap_drop, cap)) {
61228 + if (cap_raised(cap_audit, cap))
61229 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
61230 + return 1;
61231 + }
61232 +
61233 + curracl = task->acl;
61234 +
61235 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
61236 + && cap_raised(cred->cap_effective, cap)) {
61237 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61238 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
61239 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
61240 + gr_to_filename(task->exec_file->f_path.dentry,
61241 + task->exec_file->f_path.mnt) : curracl->filename,
61242 + curracl->filename, 0UL,
61243 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
61244 + return 1;
61245 + }
61246 +
61247 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
61248 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
61249 +
61250 + return 0;
61251 +}
61252 +
61253 +int
61254 +gr_acl_is_capable(const int cap)
61255 +{
61256 + return gr_task_acl_is_capable(current, current_cred(), cap);
61257 +}
61258 +
61259 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
61260 +{
61261 + struct acl_subject_label *curracl;
61262 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
61263 +
61264 + if (!gr_acl_is_enabled())
61265 + return 1;
61266 +
61267 + curracl = task->acl;
61268 +
61269 + cap_drop = curracl->cap_lower;
61270 + cap_mask = curracl->cap_mask;
61271 +
61272 + while ((curracl = curracl->parent_subject)) {
61273 + /* if the cap isn't specified in the current computed mask but is specified in the
61274 + current level subject, and is lowered in the current level subject, then add
61275 + it to the set of dropped capabilities
61276 + otherwise, add the current level subject's mask to the current computed mask
61277 + */
61278 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
61279 + cap_raise(cap_mask, cap);
61280 + if (cap_raised(curracl->cap_lower, cap))
61281 + cap_raise(cap_drop, cap);
61282 + }
61283 + }
61284 +
61285 + if (!cap_raised(cap_drop, cap))
61286 + return 1;
61287 +
61288 + return 0;
61289 +}
61290 +
61291 +int
61292 +gr_acl_is_capable_nolog(const int cap)
61293 +{
61294 + return gr_task_acl_is_capable_nolog(current, cap);
61295 +}
61296 +
61297 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
61298 new file mode 100644
61299 index 0000000..a340c17
61300 --- /dev/null
61301 +++ b/grsecurity/gracl_fs.c
61302 @@ -0,0 +1,431 @@
61303 +#include <linux/kernel.h>
61304 +#include <linux/sched.h>
61305 +#include <linux/types.h>
61306 +#include <linux/fs.h>
61307 +#include <linux/file.h>
61308 +#include <linux/stat.h>
61309 +#include <linux/grsecurity.h>
61310 +#include <linux/grinternal.h>
61311 +#include <linux/gracl.h>
61312 +
61313 +umode_t
61314 +gr_acl_umask(void)
61315 +{
61316 + if (unlikely(!gr_acl_is_enabled()))
61317 + return 0;
61318 +
61319 + return current->role->umask;
61320 +}
61321 +
61322 +__u32
61323 +gr_acl_handle_hidden_file(const struct dentry * dentry,
61324 + const struct vfsmount * mnt)
61325 +{
61326 + __u32 mode;
61327 +
61328 + if (unlikely(!dentry->d_inode))
61329 + return GR_FIND;
61330 +
61331 + mode =
61332 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
61333 +
61334 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
61335 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
61336 + return mode;
61337 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
61338 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
61339 + return 0;
61340 + } else if (unlikely(!(mode & GR_FIND)))
61341 + return 0;
61342 +
61343 + return GR_FIND;
61344 +}
61345 +
61346 +__u32
61347 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
61348 + int acc_mode)
61349 +{
61350 + __u32 reqmode = GR_FIND;
61351 + __u32 mode;
61352 +
61353 + if (unlikely(!dentry->d_inode))
61354 + return reqmode;
61355 +
61356 + if (acc_mode & MAY_APPEND)
61357 + reqmode |= GR_APPEND;
61358 + else if (acc_mode & MAY_WRITE)
61359 + reqmode |= GR_WRITE;
61360 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
61361 + reqmode |= GR_READ;
61362 +
61363 + mode =
61364 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
61365 + mnt);
61366 +
61367 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
61368 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
61369 + reqmode & GR_READ ? " reading" : "",
61370 + reqmode & GR_WRITE ? " writing" : reqmode &
61371 + GR_APPEND ? " appending" : "");
61372 + return reqmode;
61373 + } else
61374 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
61375 + {
61376 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
61377 + reqmode & GR_READ ? " reading" : "",
61378 + reqmode & GR_WRITE ? " writing" : reqmode &
61379 + GR_APPEND ? " appending" : "");
61380 + return 0;
61381 + } else if (unlikely((mode & reqmode) != reqmode))
61382 + return 0;
61383 +
61384 + return reqmode;
61385 +}
61386 +
61387 +__u32
61388 +gr_acl_handle_creat(const struct dentry * dentry,
61389 + const struct dentry * p_dentry,
61390 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
61391 + const int imode)
61392 +{
61393 + __u32 reqmode = GR_WRITE | GR_CREATE;
61394 + __u32 mode;
61395 +
61396 + if (acc_mode & MAY_APPEND)
61397 + reqmode |= GR_APPEND;
61398 + // if a directory was required or the directory already exists, then
61399 + // don't count this open as a read
61400 + if ((acc_mode & MAY_READ) &&
61401 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
61402 + reqmode |= GR_READ;
61403 + if ((open_flags & O_CREAT) &&
61404 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
61405 + reqmode |= GR_SETID;
61406 +
61407 + mode =
61408 + gr_check_create(dentry, p_dentry, p_mnt,
61409 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
61410 +
61411 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
61412 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
61413 + reqmode & GR_READ ? " reading" : "",
61414 + reqmode & GR_WRITE ? " writing" : reqmode &
61415 + GR_APPEND ? " appending" : "");
61416 + return reqmode;
61417 + } else
61418 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
61419 + {
61420 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
61421 + reqmode & GR_READ ? " reading" : "",
61422 + reqmode & GR_WRITE ? " writing" : reqmode &
61423 + GR_APPEND ? " appending" : "");
61424 + return 0;
61425 + } else if (unlikely((mode & reqmode) != reqmode))
61426 + return 0;
61427 +
61428 + return reqmode;
61429 +}
61430 +
61431 +__u32
61432 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
61433 + const int fmode)
61434 +{
61435 + __u32 mode, reqmode = GR_FIND;
61436 +
61437 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
61438 + reqmode |= GR_EXEC;
61439 + if (fmode & S_IWOTH)
61440 + reqmode |= GR_WRITE;
61441 + if (fmode & S_IROTH)
61442 + reqmode |= GR_READ;
61443 +
61444 + mode =
61445 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
61446 + mnt);
61447 +
61448 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
61449 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
61450 + reqmode & GR_READ ? " reading" : "",
61451 + reqmode & GR_WRITE ? " writing" : "",
61452 + reqmode & GR_EXEC ? " executing" : "");
61453 + return reqmode;
61454 + } else
61455 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
61456 + {
61457 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
61458 + reqmode & GR_READ ? " reading" : "",
61459 + reqmode & GR_WRITE ? " writing" : "",
61460 + reqmode & GR_EXEC ? " executing" : "");
61461 + return 0;
61462 + } else if (unlikely((mode & reqmode) != reqmode))
61463 + return 0;
61464 +
61465 + return reqmode;
61466 +}
61467 +
61468 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
61469 +{
61470 + __u32 mode;
61471 +
61472 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
61473 +
61474 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
61475 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
61476 + return mode;
61477 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
61478 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
61479 + return 0;
61480 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
61481 + return 0;
61482 +
61483 + return (reqmode);
61484 +}
61485 +
61486 +__u32
61487 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
61488 +{
61489 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
61490 +}
61491 +
61492 +__u32
61493 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
61494 +{
61495 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
61496 +}
61497 +
61498 +__u32
61499 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
61500 +{
61501 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
61502 +}
61503 +
61504 +__u32
61505 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
61506 +{
61507 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
61508 +}
61509 +
61510 +__u32
61511 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
61512 + umode_t *modeptr)
61513 +{
61514 + umode_t mode;
61515 +
61516 + *modeptr &= ~gr_acl_umask();
61517 + mode = *modeptr;
61518 +
61519 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
61520 + return 1;
61521 +
61522 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
61523 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
61524 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
61525 + GR_CHMOD_ACL_MSG);
61526 + } else {
61527 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
61528 + }
61529 +}
61530 +
61531 +__u32
61532 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
61533 +{
61534 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
61535 +}
61536 +
61537 +__u32
61538 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
61539 +{
61540 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
61541 +}
61542 +
61543 +__u32
61544 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
61545 +{
61546 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
61547 +}
61548 +
61549 +__u32
61550 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
61551 +{
61552 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
61553 + GR_UNIXCONNECT_ACL_MSG);
61554 +}
61555 +
61556 +/* hardlinks require at minimum create and link permission,
61557 + any additional privilege required is based on the
61558 + privilege of the file being linked to
61559 +*/
61560 +__u32
61561 +gr_acl_handle_link(const struct dentry * new_dentry,
61562 + const struct dentry * parent_dentry,
61563 + const struct vfsmount * parent_mnt,
61564 + const struct dentry * old_dentry,
61565 + const struct vfsmount * old_mnt, const struct filename *to)
61566 +{
61567 + __u32 mode;
61568 + __u32 needmode = GR_CREATE | GR_LINK;
61569 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
61570 +
61571 + mode =
61572 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
61573 + old_mnt);
61574 +
61575 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
61576 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
61577 + return mode;
61578 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
61579 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
61580 + return 0;
61581 + } else if (unlikely((mode & needmode) != needmode))
61582 + return 0;
61583 +
61584 + return 1;
61585 +}
61586 +
61587 +__u32
61588 +gr_acl_handle_symlink(const struct dentry * new_dentry,
61589 + const struct dentry * parent_dentry,
61590 + const struct vfsmount * parent_mnt, const struct filename *from)
61591 +{
61592 + __u32 needmode = GR_WRITE | GR_CREATE;
61593 + __u32 mode;
61594 +
61595 + mode =
61596 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
61597 + GR_CREATE | GR_AUDIT_CREATE |
61598 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
61599 +
61600 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
61601 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
61602 + return mode;
61603 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
61604 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
61605 + return 0;
61606 + } else if (unlikely((mode & needmode) != needmode))
61607 + return 0;
61608 +
61609 + return (GR_WRITE | GR_CREATE);
61610 +}
61611 +
61612 +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)
61613 +{
61614 + __u32 mode;
61615 +
61616 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
61617 +
61618 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
61619 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
61620 + return mode;
61621 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
61622 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
61623 + return 0;
61624 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
61625 + return 0;
61626 +
61627 + return (reqmode);
61628 +}
61629 +
61630 +__u32
61631 +gr_acl_handle_mknod(const struct dentry * new_dentry,
61632 + const struct dentry * parent_dentry,
61633 + const struct vfsmount * parent_mnt,
61634 + const int mode)
61635 +{
61636 + __u32 reqmode = GR_WRITE | GR_CREATE;
61637 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
61638 + reqmode |= GR_SETID;
61639 +
61640 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
61641 + reqmode, GR_MKNOD_ACL_MSG);
61642 +}
61643 +
61644 +__u32
61645 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
61646 + const struct dentry *parent_dentry,
61647 + const struct vfsmount *parent_mnt)
61648 +{
61649 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
61650 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
61651 +}
61652 +
61653 +#define RENAME_CHECK_SUCCESS(old, new) \
61654 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
61655 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
61656 +
61657 +int
61658 +gr_acl_handle_rename(struct dentry *new_dentry,
61659 + struct dentry *parent_dentry,
61660 + const struct vfsmount *parent_mnt,
61661 + struct dentry *old_dentry,
61662 + struct inode *old_parent_inode,
61663 + struct vfsmount *old_mnt, const struct filename *newname)
61664 +{
61665 + __u32 comp1, comp2;
61666 + int error = 0;
61667 +
61668 + if (unlikely(!gr_acl_is_enabled()))
61669 + return 0;
61670 +
61671 + if (!new_dentry->d_inode) {
61672 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
61673 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
61674 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
61675 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
61676 + GR_DELETE | GR_AUDIT_DELETE |
61677 + GR_AUDIT_READ | GR_AUDIT_WRITE |
61678 + GR_SUPPRESS, old_mnt);
61679 + } else {
61680 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
61681 + GR_CREATE | GR_DELETE |
61682 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
61683 + GR_AUDIT_READ | GR_AUDIT_WRITE |
61684 + GR_SUPPRESS, parent_mnt);
61685 + comp2 =
61686 + gr_search_file(old_dentry,
61687 + GR_READ | GR_WRITE | GR_AUDIT_READ |
61688 + GR_DELETE | GR_AUDIT_DELETE |
61689 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
61690 + }
61691 +
61692 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
61693 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
61694 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
61695 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
61696 + && !(comp2 & GR_SUPPRESS)) {
61697 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
61698 + error = -EACCES;
61699 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
61700 + error = -EACCES;
61701 +
61702 + return error;
61703 +}
61704 +
61705 +void
61706 +gr_acl_handle_exit(void)
61707 +{
61708 + u16 id;
61709 + char *rolename;
61710 +
61711 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
61712 + !(current->role->roletype & GR_ROLE_PERSIST))) {
61713 + id = current->acl_role_id;
61714 + rolename = current->role->rolename;
61715 + gr_set_acls(1);
61716 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
61717 + }
61718 +
61719 + gr_put_exec_file(current);
61720 + return;
61721 +}
61722 +
61723 +int
61724 +gr_acl_handle_procpidmem(const struct task_struct *task)
61725 +{
61726 + if (unlikely(!gr_acl_is_enabled()))
61727 + return 0;
61728 +
61729 + if (task != current && task->acl->mode & GR_PROTPROCFD)
61730 + return -EACCES;
61731 +
61732 + return 0;
61733 +}
61734 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
61735 new file mode 100644
61736 index 0000000..8132048
61737 --- /dev/null
61738 +++ b/grsecurity/gracl_ip.c
61739 @@ -0,0 +1,387 @@
61740 +#include <linux/kernel.h>
61741 +#include <asm/uaccess.h>
61742 +#include <asm/errno.h>
61743 +#include <net/sock.h>
61744 +#include <linux/file.h>
61745 +#include <linux/fs.h>
61746 +#include <linux/net.h>
61747 +#include <linux/in.h>
61748 +#include <linux/skbuff.h>
61749 +#include <linux/ip.h>
61750 +#include <linux/udp.h>
61751 +#include <linux/types.h>
61752 +#include <linux/sched.h>
61753 +#include <linux/netdevice.h>
61754 +#include <linux/inetdevice.h>
61755 +#include <linux/gracl.h>
61756 +#include <linux/grsecurity.h>
61757 +#include <linux/grinternal.h>
61758 +
61759 +#define GR_BIND 0x01
61760 +#define GR_CONNECT 0x02
61761 +#define GR_INVERT 0x04
61762 +#define GR_BINDOVERRIDE 0x08
61763 +#define GR_CONNECTOVERRIDE 0x10
61764 +#define GR_SOCK_FAMILY 0x20
61765 +
61766 +static const char * gr_protocols[IPPROTO_MAX] = {
61767 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
61768 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
61769 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
61770 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
61771 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
61772 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
61773 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
61774 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
61775 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
61776 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
61777 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
61778 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
61779 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
61780 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
61781 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
61782 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
61783 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
61784 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
61785 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
61786 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
61787 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
61788 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
61789 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
61790 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
61791 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
61792 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
61793 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
61794 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
61795 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
61796 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
61797 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
61798 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
61799 + };
61800 +
61801 +static const char * gr_socktypes[SOCK_MAX] = {
61802 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
61803 + "unknown:7", "unknown:8", "unknown:9", "packet"
61804 + };
61805 +
61806 +static const char * gr_sockfamilies[AF_MAX+1] = {
61807 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
61808 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
61809 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
61810 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
61811 + };
61812 +
61813 +const char *
61814 +gr_proto_to_name(unsigned char proto)
61815 +{
61816 + return gr_protocols[proto];
61817 +}
61818 +
61819 +const char *
61820 +gr_socktype_to_name(unsigned char type)
61821 +{
61822 + return gr_socktypes[type];
61823 +}
61824 +
61825 +const char *
61826 +gr_sockfamily_to_name(unsigned char family)
61827 +{
61828 + return gr_sockfamilies[family];
61829 +}
61830 +
61831 +int
61832 +gr_search_socket(const int domain, const int type, const int protocol)
61833 +{
61834 + struct acl_subject_label *curr;
61835 + const struct cred *cred = current_cred();
61836 +
61837 + if (unlikely(!gr_acl_is_enabled()))
61838 + goto exit;
61839 +
61840 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
61841 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
61842 + goto exit; // let the kernel handle it
61843 +
61844 + curr = current->acl;
61845 +
61846 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
61847 + /* the family is allowed, if this is PF_INET allow it only if
61848 + the extra sock type/protocol checks pass */
61849 + if (domain == PF_INET)
61850 + goto inet_check;
61851 + goto exit;
61852 + } else {
61853 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
61854 + __u32 fakeip = 0;
61855 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
61856 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
61857 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
61858 + gr_to_filename(current->exec_file->f_path.dentry,
61859 + current->exec_file->f_path.mnt) :
61860 + curr->filename, curr->filename,
61861 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
61862 + &current->signal->saved_ip);
61863 + goto exit;
61864 + }
61865 + goto exit_fail;
61866 + }
61867 +
61868 +inet_check:
61869 + /* the rest of this checking is for IPv4 only */
61870 + if (!curr->ips)
61871 + goto exit;
61872 +
61873 + if ((curr->ip_type & (1U << type)) &&
61874 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
61875 + goto exit;
61876 +
61877 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
61878 + /* we don't place acls on raw sockets , and sometimes
61879 + dgram/ip sockets are opened for ioctl and not
61880 + bind/connect, so we'll fake a bind learn log */
61881 + if (type == SOCK_RAW || type == SOCK_PACKET) {
61882 + __u32 fakeip = 0;
61883 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
61884 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
61885 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
61886 + gr_to_filename(current->exec_file->f_path.dentry,
61887 + current->exec_file->f_path.mnt) :
61888 + curr->filename, curr->filename,
61889 + &fakeip, 0, type,
61890 + protocol, GR_CONNECT, &current->signal->saved_ip);
61891 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
61892 + __u32 fakeip = 0;
61893 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
61894 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
61895 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
61896 + gr_to_filename(current->exec_file->f_path.dentry,
61897 + current->exec_file->f_path.mnt) :
61898 + curr->filename, curr->filename,
61899 + &fakeip, 0, type,
61900 + protocol, GR_BIND, &current->signal->saved_ip);
61901 + }
61902 + /* we'll log when they use connect or bind */
61903 + goto exit;
61904 + }
61905 +
61906 +exit_fail:
61907 + if (domain == PF_INET)
61908 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
61909 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
61910 + else
61911 +#ifndef CONFIG_IPV6
61912 + if (domain != PF_INET6)
61913 +#endif
61914 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
61915 + gr_socktype_to_name(type), protocol);
61916 +
61917 + return 0;
61918 +exit:
61919 + return 1;
61920 +}
61921 +
61922 +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)
61923 +{
61924 + if ((ip->mode & mode) &&
61925 + (ip_port >= ip->low) &&
61926 + (ip_port <= ip->high) &&
61927 + ((ntohl(ip_addr) & our_netmask) ==
61928 + (ntohl(our_addr) & our_netmask))
61929 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
61930 + && (ip->type & (1U << type))) {
61931 + if (ip->mode & GR_INVERT)
61932 + return 2; // specifically denied
61933 + else
61934 + return 1; // allowed
61935 + }
61936 +
61937 + return 0; // not specifically allowed, may continue parsing
61938 +}
61939 +
61940 +static int
61941 +gr_search_connectbind(const int full_mode, struct sock *sk,
61942 + struct sockaddr_in *addr, const int type)
61943 +{
61944 + char iface[IFNAMSIZ] = {0};
61945 + struct acl_subject_label *curr;
61946 + struct acl_ip_label *ip;
61947 + struct inet_sock *isk;
61948 + struct net_device *dev;
61949 + struct in_device *idev;
61950 + unsigned long i;
61951 + int ret;
61952 + int mode = full_mode & (GR_BIND | GR_CONNECT);
61953 + __u32 ip_addr = 0;
61954 + __u32 our_addr;
61955 + __u32 our_netmask;
61956 + char *p;
61957 + __u16 ip_port = 0;
61958 + const struct cred *cred = current_cred();
61959 +
61960 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
61961 + return 0;
61962 +
61963 + curr = current->acl;
61964 + isk = inet_sk(sk);
61965 +
61966 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
61967 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
61968 + addr->sin_addr.s_addr = curr->inaddr_any_override;
61969 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
61970 + struct sockaddr_in saddr;
61971 + int err;
61972 +
61973 + saddr.sin_family = AF_INET;
61974 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
61975 + saddr.sin_port = isk->inet_sport;
61976 +
61977 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
61978 + if (err)
61979 + return err;
61980 +
61981 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
61982 + if (err)
61983 + return err;
61984 + }
61985 +
61986 + if (!curr->ips)
61987 + return 0;
61988 +
61989 + ip_addr = addr->sin_addr.s_addr;
61990 + ip_port = ntohs(addr->sin_port);
61991 +
61992 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
61993 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
61994 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
61995 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
61996 + gr_to_filename(current->exec_file->f_path.dentry,
61997 + current->exec_file->f_path.mnt) :
61998 + curr->filename, curr->filename,
61999 + &ip_addr, ip_port, type,
62000 + sk->sk_protocol, mode, &current->signal->saved_ip);
62001 + return 0;
62002 + }
62003 +
62004 + for (i = 0; i < curr->ip_num; i++) {
62005 + ip = *(curr->ips + i);
62006 + if (ip->iface != NULL) {
62007 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
62008 + p = strchr(iface, ':');
62009 + if (p != NULL)
62010 + *p = '\0';
62011 + dev = dev_get_by_name(sock_net(sk), iface);
62012 + if (dev == NULL)
62013 + continue;
62014 + idev = in_dev_get(dev);
62015 + if (idev == NULL) {
62016 + dev_put(dev);
62017 + continue;
62018 + }
62019 + rcu_read_lock();
62020 + for_ifa(idev) {
62021 + if (!strcmp(ip->iface, ifa->ifa_label)) {
62022 + our_addr = ifa->ifa_address;
62023 + our_netmask = 0xffffffff;
62024 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
62025 + if (ret == 1) {
62026 + rcu_read_unlock();
62027 + in_dev_put(idev);
62028 + dev_put(dev);
62029 + return 0;
62030 + } else if (ret == 2) {
62031 + rcu_read_unlock();
62032 + in_dev_put(idev);
62033 + dev_put(dev);
62034 + goto denied;
62035 + }
62036 + }
62037 + } endfor_ifa(idev);
62038 + rcu_read_unlock();
62039 + in_dev_put(idev);
62040 + dev_put(dev);
62041 + } else {
62042 + our_addr = ip->addr;
62043 + our_netmask = ip->netmask;
62044 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
62045 + if (ret == 1)
62046 + return 0;
62047 + else if (ret == 2)
62048 + goto denied;
62049 + }
62050 + }
62051 +
62052 +denied:
62053 + if (mode == GR_BIND)
62054 + 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));
62055 + else if (mode == GR_CONNECT)
62056 + 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));
62057 +
62058 + return -EACCES;
62059 +}
62060 +
62061 +int
62062 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
62063 +{
62064 + /* always allow disconnection of dgram sockets with connect */
62065 + if (addr->sin_family == AF_UNSPEC)
62066 + return 0;
62067 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
62068 +}
62069 +
62070 +int
62071 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
62072 +{
62073 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
62074 +}
62075 +
62076 +int gr_search_listen(struct socket *sock)
62077 +{
62078 + struct sock *sk = sock->sk;
62079 + struct sockaddr_in addr;
62080 +
62081 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
62082 + addr.sin_port = inet_sk(sk)->inet_sport;
62083 +
62084 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
62085 +}
62086 +
62087 +int gr_search_accept(struct socket *sock)
62088 +{
62089 + struct sock *sk = sock->sk;
62090 + struct sockaddr_in addr;
62091 +
62092 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
62093 + addr.sin_port = inet_sk(sk)->inet_sport;
62094 +
62095 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
62096 +}
62097 +
62098 +int
62099 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
62100 +{
62101 + if (addr)
62102 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
62103 + else {
62104 + struct sockaddr_in sin;
62105 + const struct inet_sock *inet = inet_sk(sk);
62106 +
62107 + sin.sin_addr.s_addr = inet->inet_daddr;
62108 + sin.sin_port = inet->inet_dport;
62109 +
62110 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
62111 + }
62112 +}
62113 +
62114 +int
62115 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
62116 +{
62117 + struct sockaddr_in sin;
62118 +
62119 + if (unlikely(skb->len < sizeof (struct udphdr)))
62120 + return 0; // skip this packet
62121 +
62122 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
62123 + sin.sin_port = udp_hdr(skb)->source;
62124 +
62125 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
62126 +}
62127 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
62128 new file mode 100644
62129 index 0000000..25f54ef
62130 --- /dev/null
62131 +++ b/grsecurity/gracl_learn.c
62132 @@ -0,0 +1,207 @@
62133 +#include <linux/kernel.h>
62134 +#include <linux/mm.h>
62135 +#include <linux/sched.h>
62136 +#include <linux/poll.h>
62137 +#include <linux/string.h>
62138 +#include <linux/file.h>
62139 +#include <linux/types.h>
62140 +#include <linux/vmalloc.h>
62141 +#include <linux/grinternal.h>
62142 +
62143 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
62144 + size_t count, loff_t *ppos);
62145 +extern int gr_acl_is_enabled(void);
62146 +
62147 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
62148 +static int gr_learn_attached;
62149 +
62150 +/* use a 512k buffer */
62151 +#define LEARN_BUFFER_SIZE (512 * 1024)
62152 +
62153 +static DEFINE_SPINLOCK(gr_learn_lock);
62154 +static DEFINE_MUTEX(gr_learn_user_mutex);
62155 +
62156 +/* we need to maintain two buffers, so that the kernel context of grlearn
62157 + uses a semaphore around the userspace copying, and the other kernel contexts
62158 + use a spinlock when copying into the buffer, since they cannot sleep
62159 +*/
62160 +static char *learn_buffer;
62161 +static char *learn_buffer_user;
62162 +static int learn_buffer_len;
62163 +static int learn_buffer_user_len;
62164 +
62165 +static ssize_t
62166 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
62167 +{
62168 + DECLARE_WAITQUEUE(wait, current);
62169 + ssize_t retval = 0;
62170 +
62171 + add_wait_queue(&learn_wait, &wait);
62172 + set_current_state(TASK_INTERRUPTIBLE);
62173 + do {
62174 + mutex_lock(&gr_learn_user_mutex);
62175 + spin_lock(&gr_learn_lock);
62176 + if (learn_buffer_len)
62177 + break;
62178 + spin_unlock(&gr_learn_lock);
62179 + mutex_unlock(&gr_learn_user_mutex);
62180 + if (file->f_flags & O_NONBLOCK) {
62181 + retval = -EAGAIN;
62182 + goto out;
62183 + }
62184 + if (signal_pending(current)) {
62185 + retval = -ERESTARTSYS;
62186 + goto out;
62187 + }
62188 +
62189 + schedule();
62190 + } while (1);
62191 +
62192 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
62193 + learn_buffer_user_len = learn_buffer_len;
62194 + retval = learn_buffer_len;
62195 + learn_buffer_len = 0;
62196 +
62197 + spin_unlock(&gr_learn_lock);
62198 +
62199 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
62200 + retval = -EFAULT;
62201 +
62202 + mutex_unlock(&gr_learn_user_mutex);
62203 +out:
62204 + set_current_state(TASK_RUNNING);
62205 + remove_wait_queue(&learn_wait, &wait);
62206 + return retval;
62207 +}
62208 +
62209 +static unsigned int
62210 +poll_learn(struct file * file, poll_table * wait)
62211 +{
62212 + poll_wait(file, &learn_wait, wait);
62213 +
62214 + if (learn_buffer_len)
62215 + return (POLLIN | POLLRDNORM);
62216 +
62217 + return 0;
62218 +}
62219 +
62220 +void
62221 +gr_clear_learn_entries(void)
62222 +{
62223 + char *tmp;
62224 +
62225 + mutex_lock(&gr_learn_user_mutex);
62226 + spin_lock(&gr_learn_lock);
62227 + tmp = learn_buffer;
62228 + learn_buffer = NULL;
62229 + spin_unlock(&gr_learn_lock);
62230 + if (tmp)
62231 + vfree(tmp);
62232 + if (learn_buffer_user != NULL) {
62233 + vfree(learn_buffer_user);
62234 + learn_buffer_user = NULL;
62235 + }
62236 + learn_buffer_len = 0;
62237 + mutex_unlock(&gr_learn_user_mutex);
62238 +
62239 + return;
62240 +}
62241 +
62242 +void
62243 +gr_add_learn_entry(const char *fmt, ...)
62244 +{
62245 + va_list args;
62246 + unsigned int len;
62247 +
62248 + if (!gr_learn_attached)
62249 + return;
62250 +
62251 + spin_lock(&gr_learn_lock);
62252 +
62253 + /* leave a gap at the end so we know when it's "full" but don't have to
62254 + compute the exact length of the string we're trying to append
62255 + */
62256 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
62257 + spin_unlock(&gr_learn_lock);
62258 + wake_up_interruptible(&learn_wait);
62259 + return;
62260 + }
62261 + if (learn_buffer == NULL) {
62262 + spin_unlock(&gr_learn_lock);
62263 + return;
62264 + }
62265 +
62266 + va_start(args, fmt);
62267 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
62268 + va_end(args);
62269 +
62270 + learn_buffer_len += len + 1;
62271 +
62272 + spin_unlock(&gr_learn_lock);
62273 + wake_up_interruptible(&learn_wait);
62274 +
62275 + return;
62276 +}
62277 +
62278 +static int
62279 +open_learn(struct inode *inode, struct file *file)
62280 +{
62281 + if (file->f_mode & FMODE_READ && gr_learn_attached)
62282 + return -EBUSY;
62283 + if (file->f_mode & FMODE_READ) {
62284 + int retval = 0;
62285 + mutex_lock(&gr_learn_user_mutex);
62286 + if (learn_buffer == NULL)
62287 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
62288 + if (learn_buffer_user == NULL)
62289 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
62290 + if (learn_buffer == NULL) {
62291 + retval = -ENOMEM;
62292 + goto out_error;
62293 + }
62294 + if (learn_buffer_user == NULL) {
62295 + retval = -ENOMEM;
62296 + goto out_error;
62297 + }
62298 + learn_buffer_len = 0;
62299 + learn_buffer_user_len = 0;
62300 + gr_learn_attached = 1;
62301 +out_error:
62302 + mutex_unlock(&gr_learn_user_mutex);
62303 + return retval;
62304 + }
62305 + return 0;
62306 +}
62307 +
62308 +static int
62309 +close_learn(struct inode *inode, struct file *file)
62310 +{
62311 + if (file->f_mode & FMODE_READ) {
62312 + char *tmp = NULL;
62313 + mutex_lock(&gr_learn_user_mutex);
62314 + spin_lock(&gr_learn_lock);
62315 + tmp = learn_buffer;
62316 + learn_buffer = NULL;
62317 + spin_unlock(&gr_learn_lock);
62318 + if (tmp)
62319 + vfree(tmp);
62320 + if (learn_buffer_user != NULL) {
62321 + vfree(learn_buffer_user);
62322 + learn_buffer_user = NULL;
62323 + }
62324 + learn_buffer_len = 0;
62325 + learn_buffer_user_len = 0;
62326 + gr_learn_attached = 0;
62327 + mutex_unlock(&gr_learn_user_mutex);
62328 + }
62329 +
62330 + return 0;
62331 +}
62332 +
62333 +const struct file_operations grsec_fops = {
62334 + .read = read_learn,
62335 + .write = write_grsec_handler,
62336 + .open = open_learn,
62337 + .release = close_learn,
62338 + .poll = poll_learn,
62339 +};
62340 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
62341 new file mode 100644
62342 index 0000000..39645c9
62343 --- /dev/null
62344 +++ b/grsecurity/gracl_res.c
62345 @@ -0,0 +1,68 @@
62346 +#include <linux/kernel.h>
62347 +#include <linux/sched.h>
62348 +#include <linux/gracl.h>
62349 +#include <linux/grinternal.h>
62350 +
62351 +static const char *restab_log[] = {
62352 + [RLIMIT_CPU] = "RLIMIT_CPU",
62353 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
62354 + [RLIMIT_DATA] = "RLIMIT_DATA",
62355 + [RLIMIT_STACK] = "RLIMIT_STACK",
62356 + [RLIMIT_CORE] = "RLIMIT_CORE",
62357 + [RLIMIT_RSS] = "RLIMIT_RSS",
62358 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
62359 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
62360 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
62361 + [RLIMIT_AS] = "RLIMIT_AS",
62362 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
62363 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
62364 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
62365 + [RLIMIT_NICE] = "RLIMIT_NICE",
62366 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
62367 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
62368 + [GR_CRASH_RES] = "RLIMIT_CRASH"
62369 +};
62370 +
62371 +void
62372 +gr_log_resource(const struct task_struct *task,
62373 + const int res, const unsigned long wanted, const int gt)
62374 +{
62375 + const struct cred *cred;
62376 + unsigned long rlim;
62377 +
62378 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
62379 + return;
62380 +
62381 + // not yet supported resource
62382 + if (unlikely(!restab_log[res]))
62383 + return;
62384 +
62385 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
62386 + rlim = task_rlimit_max(task, res);
62387 + else
62388 + rlim = task_rlimit(task, res);
62389 +
62390 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
62391 + return;
62392 +
62393 + rcu_read_lock();
62394 + cred = __task_cred(task);
62395 +
62396 + if (res == RLIMIT_NPROC &&
62397 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
62398 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
62399 + goto out_rcu_unlock;
62400 + else if (res == RLIMIT_MEMLOCK &&
62401 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
62402 + goto out_rcu_unlock;
62403 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
62404 + goto out_rcu_unlock;
62405 + rcu_read_unlock();
62406 +
62407 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
62408 +
62409 + return;
62410 +out_rcu_unlock:
62411 + rcu_read_unlock();
62412 + return;
62413 +}
62414 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
62415 new file mode 100644
62416 index 0000000..4dcc92a
62417 --- /dev/null
62418 +++ b/grsecurity/gracl_segv.c
62419 @@ -0,0 +1,305 @@
62420 +#include <linux/kernel.h>
62421 +#include <linux/mm.h>
62422 +#include <asm/uaccess.h>
62423 +#include <asm/errno.h>
62424 +#include <asm/mman.h>
62425 +#include <net/sock.h>
62426 +#include <linux/file.h>
62427 +#include <linux/fs.h>
62428 +#include <linux/net.h>
62429 +#include <linux/in.h>
62430 +#include <linux/slab.h>
62431 +#include <linux/types.h>
62432 +#include <linux/sched.h>
62433 +#include <linux/timer.h>
62434 +#include <linux/gracl.h>
62435 +#include <linux/grsecurity.h>
62436 +#include <linux/grinternal.h>
62437 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62438 +#include <linux/magic.h>
62439 +#include <linux/pagemap.h>
62440 +#include "../fs/btrfs/async-thread.h"
62441 +#include "../fs/btrfs/ctree.h"
62442 +#include "../fs/btrfs/btrfs_inode.h"
62443 +#endif
62444 +
62445 +static struct crash_uid *uid_set;
62446 +static unsigned short uid_used;
62447 +static DEFINE_SPINLOCK(gr_uid_lock);
62448 +extern rwlock_t gr_inode_lock;
62449 +extern struct acl_subject_label *
62450 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
62451 + struct acl_role_label *role);
62452 +
62453 +static inline dev_t __get_dev(const struct dentry *dentry)
62454 +{
62455 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62456 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
62457 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
62458 + else
62459 +#endif
62460 + return dentry->d_sb->s_dev;
62461 +}
62462 +
62463 +int
62464 +gr_init_uidset(void)
62465 +{
62466 + uid_set =
62467 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
62468 + uid_used = 0;
62469 +
62470 + return uid_set ? 1 : 0;
62471 +}
62472 +
62473 +void
62474 +gr_free_uidset(void)
62475 +{
62476 + if (uid_set)
62477 + kfree(uid_set);
62478 +
62479 + return;
62480 +}
62481 +
62482 +int
62483 +gr_find_uid(const uid_t uid)
62484 +{
62485 + struct crash_uid *tmp = uid_set;
62486 + uid_t buid;
62487 + int low = 0, high = uid_used - 1, mid;
62488 +
62489 + while (high >= low) {
62490 + mid = (low + high) >> 1;
62491 + buid = tmp[mid].uid;
62492 + if (buid == uid)
62493 + return mid;
62494 + if (buid > uid)
62495 + high = mid - 1;
62496 + if (buid < uid)
62497 + low = mid + 1;
62498 + }
62499 +
62500 + return -1;
62501 +}
62502 +
62503 +static __inline__ void
62504 +gr_insertsort(void)
62505 +{
62506 + unsigned short i, j;
62507 + struct crash_uid index;
62508 +
62509 + for (i = 1; i < uid_used; i++) {
62510 + index = uid_set[i];
62511 + j = i;
62512 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
62513 + uid_set[j] = uid_set[j - 1];
62514 + j--;
62515 + }
62516 + uid_set[j] = index;
62517 + }
62518 +
62519 + return;
62520 +}
62521 +
62522 +static __inline__ void
62523 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
62524 +{
62525 + int loc;
62526 + uid_t uid = GR_GLOBAL_UID(kuid);
62527 +
62528 + if (uid_used == GR_UIDTABLE_MAX)
62529 + return;
62530 +
62531 + loc = gr_find_uid(uid);
62532 +
62533 + if (loc >= 0) {
62534 + uid_set[loc].expires = expires;
62535 + return;
62536 + }
62537 +
62538 + uid_set[uid_used].uid = uid;
62539 + uid_set[uid_used].expires = expires;
62540 + uid_used++;
62541 +
62542 + gr_insertsort();
62543 +
62544 + return;
62545 +}
62546 +
62547 +void
62548 +gr_remove_uid(const unsigned short loc)
62549 +{
62550 + unsigned short i;
62551 +
62552 + for (i = loc + 1; i < uid_used; i++)
62553 + uid_set[i - 1] = uid_set[i];
62554 +
62555 + uid_used--;
62556 +
62557 + return;
62558 +}
62559 +
62560 +int
62561 +gr_check_crash_uid(const kuid_t kuid)
62562 +{
62563 + int loc;
62564 + int ret = 0;
62565 + uid_t uid;
62566 +
62567 + if (unlikely(!gr_acl_is_enabled()))
62568 + return 0;
62569 +
62570 + uid = GR_GLOBAL_UID(kuid);
62571 +
62572 + spin_lock(&gr_uid_lock);
62573 + loc = gr_find_uid(uid);
62574 +
62575 + if (loc < 0)
62576 + goto out_unlock;
62577 +
62578 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
62579 + gr_remove_uid(loc);
62580 + else
62581 + ret = 1;
62582 +
62583 +out_unlock:
62584 + spin_unlock(&gr_uid_lock);
62585 + return ret;
62586 +}
62587 +
62588 +static __inline__ int
62589 +proc_is_setxid(const struct cred *cred)
62590 +{
62591 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
62592 + !uid_eq(cred->uid, cred->fsuid))
62593 + return 1;
62594 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
62595 + !gid_eq(cred->gid, cred->fsgid))
62596 + return 1;
62597 +
62598 + return 0;
62599 +}
62600 +
62601 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
62602 +
62603 +void
62604 +gr_handle_crash(struct task_struct *task, const int sig)
62605 +{
62606 + struct acl_subject_label *curr;
62607 + struct task_struct *tsk, *tsk2;
62608 + const struct cred *cred;
62609 + const struct cred *cred2;
62610 +
62611 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
62612 + return;
62613 +
62614 + if (unlikely(!gr_acl_is_enabled()))
62615 + return;
62616 +
62617 + curr = task->acl;
62618 +
62619 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
62620 + return;
62621 +
62622 + if (time_before_eq(curr->expires, get_seconds())) {
62623 + curr->expires = 0;
62624 + curr->crashes = 0;
62625 + }
62626 +
62627 + curr->crashes++;
62628 +
62629 + if (!curr->expires)
62630 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
62631 +
62632 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
62633 + time_after(curr->expires, get_seconds())) {
62634 + rcu_read_lock();
62635 + cred = __task_cred(task);
62636 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
62637 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
62638 + spin_lock(&gr_uid_lock);
62639 + gr_insert_uid(cred->uid, curr->expires);
62640 + spin_unlock(&gr_uid_lock);
62641 + curr->expires = 0;
62642 + curr->crashes = 0;
62643 + read_lock(&tasklist_lock);
62644 + do_each_thread(tsk2, tsk) {
62645 + cred2 = __task_cred(tsk);
62646 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
62647 + gr_fake_force_sig(SIGKILL, tsk);
62648 + } while_each_thread(tsk2, tsk);
62649 + read_unlock(&tasklist_lock);
62650 + } else {
62651 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
62652 + read_lock(&tasklist_lock);
62653 + read_lock(&grsec_exec_file_lock);
62654 + do_each_thread(tsk2, tsk) {
62655 + if (likely(tsk != task)) {
62656 + // if this thread has the same subject as the one that triggered
62657 + // RES_CRASH and it's the same binary, kill it
62658 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
62659 + gr_fake_force_sig(SIGKILL, tsk);
62660 + }
62661 + } while_each_thread(tsk2, tsk);
62662 + read_unlock(&grsec_exec_file_lock);
62663 + read_unlock(&tasklist_lock);
62664 + }
62665 + rcu_read_unlock();
62666 + }
62667 +
62668 + return;
62669 +}
62670 +
62671 +int
62672 +gr_check_crash_exec(const struct file *filp)
62673 +{
62674 + struct acl_subject_label *curr;
62675 +
62676 + if (unlikely(!gr_acl_is_enabled()))
62677 + return 0;
62678 +
62679 + read_lock(&gr_inode_lock);
62680 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
62681 + __get_dev(filp->f_path.dentry),
62682 + current->role);
62683 + read_unlock(&gr_inode_lock);
62684 +
62685 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
62686 + (!curr->crashes && !curr->expires))
62687 + return 0;
62688 +
62689 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
62690 + time_after(curr->expires, get_seconds()))
62691 + return 1;
62692 + else if (time_before_eq(curr->expires, get_seconds())) {
62693 + curr->crashes = 0;
62694 + curr->expires = 0;
62695 + }
62696 +
62697 + return 0;
62698 +}
62699 +
62700 +void
62701 +gr_handle_alertkill(struct task_struct *task)
62702 +{
62703 + struct acl_subject_label *curracl;
62704 + __u32 curr_ip;
62705 + struct task_struct *p, *p2;
62706 +
62707 + if (unlikely(!gr_acl_is_enabled()))
62708 + return;
62709 +
62710 + curracl = task->acl;
62711 + curr_ip = task->signal->curr_ip;
62712 +
62713 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
62714 + read_lock(&tasklist_lock);
62715 + do_each_thread(p2, p) {
62716 + if (p->signal->curr_ip == curr_ip)
62717 + gr_fake_force_sig(SIGKILL, p);
62718 + } while_each_thread(p2, p);
62719 + read_unlock(&tasklist_lock);
62720 + } else if (curracl->mode & GR_KILLPROC)
62721 + gr_fake_force_sig(SIGKILL, task);
62722 +
62723 + return;
62724 +}
62725 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
62726 new file mode 100644
62727 index 0000000..98011b0
62728 --- /dev/null
62729 +++ b/grsecurity/gracl_shm.c
62730 @@ -0,0 +1,40 @@
62731 +#include <linux/kernel.h>
62732 +#include <linux/mm.h>
62733 +#include <linux/sched.h>
62734 +#include <linux/file.h>
62735 +#include <linux/ipc.h>
62736 +#include <linux/gracl.h>
62737 +#include <linux/grsecurity.h>
62738 +#include <linux/grinternal.h>
62739 +
62740 +int
62741 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
62742 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
62743 +{
62744 + struct task_struct *task;
62745 +
62746 + if (!gr_acl_is_enabled())
62747 + return 1;
62748 +
62749 + rcu_read_lock();
62750 + read_lock(&tasklist_lock);
62751 +
62752 + task = find_task_by_vpid(shm_cprid);
62753 +
62754 + if (unlikely(!task))
62755 + task = find_task_by_vpid(shm_lapid);
62756 +
62757 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
62758 + (task_pid_nr(task) == shm_lapid)) &&
62759 + (task->acl->mode & GR_PROTSHM) &&
62760 + (task->acl != current->acl))) {
62761 + read_unlock(&tasklist_lock);
62762 + rcu_read_unlock();
62763 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
62764 + return 0;
62765 + }
62766 + read_unlock(&tasklist_lock);
62767 + rcu_read_unlock();
62768 +
62769 + return 1;
62770 +}
62771 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
62772 new file mode 100644
62773 index 0000000..bc0be01
62774 --- /dev/null
62775 +++ b/grsecurity/grsec_chdir.c
62776 @@ -0,0 +1,19 @@
62777 +#include <linux/kernel.h>
62778 +#include <linux/sched.h>
62779 +#include <linux/fs.h>
62780 +#include <linux/file.h>
62781 +#include <linux/grsecurity.h>
62782 +#include <linux/grinternal.h>
62783 +
62784 +void
62785 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
62786 +{
62787 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
62788 + if ((grsec_enable_chdir && grsec_enable_group &&
62789 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
62790 + !grsec_enable_group)) {
62791 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
62792 + }
62793 +#endif
62794 + return;
62795 +}
62796 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
62797 new file mode 100644
62798 index 0000000..bd6e105
62799 --- /dev/null
62800 +++ b/grsecurity/grsec_chroot.c
62801 @@ -0,0 +1,370 @@
62802 +#include <linux/kernel.h>
62803 +#include <linux/module.h>
62804 +#include <linux/sched.h>
62805 +#include <linux/file.h>
62806 +#include <linux/fs.h>
62807 +#include <linux/mount.h>
62808 +#include <linux/types.h>
62809 +#include "../fs/mount.h"
62810 +#include <linux/grsecurity.h>
62811 +#include <linux/grinternal.h>
62812 +
62813 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
62814 +static int gr_init_ran;
62815 +#endif
62816 +
62817 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
62818 +{
62819 +#ifdef CONFIG_GRKERNSEC
62820 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
62821 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
62822 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
62823 + && gr_init_ran
62824 +#endif
62825 + )
62826 + task->gr_is_chrooted = 1;
62827 + else {
62828 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
62829 + if (task_pid_nr(task) == 1 && !gr_init_ran)
62830 + gr_init_ran = 1;
62831 +#endif
62832 + task->gr_is_chrooted = 0;
62833 + }
62834 +
62835 + task->gr_chroot_dentry = path->dentry;
62836 +#endif
62837 + return;
62838 +}
62839 +
62840 +void gr_clear_chroot_entries(struct task_struct *task)
62841 +{
62842 +#ifdef CONFIG_GRKERNSEC
62843 + task->gr_is_chrooted = 0;
62844 + task->gr_chroot_dentry = NULL;
62845 +#endif
62846 + return;
62847 +}
62848 +
62849 +int
62850 +gr_handle_chroot_unix(const pid_t pid)
62851 +{
62852 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
62853 + struct task_struct *p;
62854 +
62855 + if (unlikely(!grsec_enable_chroot_unix))
62856 + return 1;
62857 +
62858 + if (likely(!proc_is_chrooted(current)))
62859 + return 1;
62860 +
62861 + rcu_read_lock();
62862 + read_lock(&tasklist_lock);
62863 + p = find_task_by_vpid_unrestricted(pid);
62864 + if (unlikely(p && !have_same_root(current, p))) {
62865 + read_unlock(&tasklist_lock);
62866 + rcu_read_unlock();
62867 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
62868 + return 0;
62869 + }
62870 + read_unlock(&tasklist_lock);
62871 + rcu_read_unlock();
62872 +#endif
62873 + return 1;
62874 +}
62875 +
62876 +int
62877 +gr_handle_chroot_nice(void)
62878 +{
62879 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
62880 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
62881 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
62882 + return -EPERM;
62883 + }
62884 +#endif
62885 + return 0;
62886 +}
62887 +
62888 +int
62889 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
62890 +{
62891 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
62892 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
62893 + && proc_is_chrooted(current)) {
62894 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
62895 + return -EACCES;
62896 + }
62897 +#endif
62898 + return 0;
62899 +}
62900 +
62901 +int
62902 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
62903 +{
62904 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
62905 + struct task_struct *p;
62906 + int ret = 0;
62907 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
62908 + return ret;
62909 +
62910 + read_lock(&tasklist_lock);
62911 + do_each_pid_task(pid, type, p) {
62912 + if (!have_same_root(current, p)) {
62913 + ret = 1;
62914 + goto out;
62915 + }
62916 + } while_each_pid_task(pid, type, p);
62917 +out:
62918 + read_unlock(&tasklist_lock);
62919 + return ret;
62920 +#endif
62921 + return 0;
62922 +}
62923 +
62924 +int
62925 +gr_pid_is_chrooted(struct task_struct *p)
62926 +{
62927 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
62928 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
62929 + return 0;
62930 +
62931 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
62932 + !have_same_root(current, p)) {
62933 + return 1;
62934 + }
62935 +#endif
62936 + return 0;
62937 +}
62938 +
62939 +EXPORT_SYMBOL(gr_pid_is_chrooted);
62940 +
62941 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
62942 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
62943 +{
62944 + struct path path, currentroot;
62945 + int ret = 0;
62946 +
62947 + path.dentry = (struct dentry *)u_dentry;
62948 + path.mnt = (struct vfsmount *)u_mnt;
62949 + get_fs_root(current->fs, &currentroot);
62950 + if (path_is_under(&path, &currentroot))
62951 + ret = 1;
62952 + path_put(&currentroot);
62953 +
62954 + return ret;
62955 +}
62956 +#endif
62957 +
62958 +int
62959 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
62960 +{
62961 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
62962 + if (!grsec_enable_chroot_fchdir)
62963 + return 1;
62964 +
62965 + if (!proc_is_chrooted(current))
62966 + return 1;
62967 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
62968 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
62969 + return 0;
62970 + }
62971 +#endif
62972 + return 1;
62973 +}
62974 +
62975 +int
62976 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
62977 + const time_t shm_createtime)
62978 +{
62979 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
62980 + struct task_struct *p;
62981 + time_t starttime;
62982 +
62983 + if (unlikely(!grsec_enable_chroot_shmat))
62984 + return 1;
62985 +
62986 + if (likely(!proc_is_chrooted(current)))
62987 + return 1;
62988 +
62989 + rcu_read_lock();
62990 + read_lock(&tasklist_lock);
62991 +
62992 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
62993 + starttime = p->start_time.tv_sec;
62994 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
62995 + if (have_same_root(current, p)) {
62996 + goto allow;
62997 + } else {
62998 + read_unlock(&tasklist_lock);
62999 + rcu_read_unlock();
63000 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
63001 + return 0;
63002 + }
63003 + }
63004 + /* creator exited, pid reuse, fall through to next check */
63005 + }
63006 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
63007 + if (unlikely(!have_same_root(current, p))) {
63008 + read_unlock(&tasklist_lock);
63009 + rcu_read_unlock();
63010 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
63011 + return 0;
63012 + }
63013 + }
63014 +
63015 +allow:
63016 + read_unlock(&tasklist_lock);
63017 + rcu_read_unlock();
63018 +#endif
63019 + return 1;
63020 +}
63021 +
63022 +void
63023 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
63024 +{
63025 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
63026 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
63027 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
63028 +#endif
63029 + return;
63030 +}
63031 +
63032 +int
63033 +gr_handle_chroot_mknod(const struct dentry *dentry,
63034 + const struct vfsmount *mnt, const int mode)
63035 +{
63036 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
63037 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
63038 + proc_is_chrooted(current)) {
63039 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
63040 + return -EPERM;
63041 + }
63042 +#endif
63043 + return 0;
63044 +}
63045 +
63046 +int
63047 +gr_handle_chroot_mount(const struct dentry *dentry,
63048 + const struct vfsmount *mnt, const char *dev_name)
63049 +{
63050 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
63051 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
63052 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
63053 + return -EPERM;
63054 + }
63055 +#endif
63056 + return 0;
63057 +}
63058 +
63059 +int
63060 +gr_handle_chroot_pivot(void)
63061 +{
63062 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
63063 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
63064 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
63065 + return -EPERM;
63066 + }
63067 +#endif
63068 + return 0;
63069 +}
63070 +
63071 +int
63072 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
63073 +{
63074 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
63075 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
63076 + !gr_is_outside_chroot(dentry, mnt)) {
63077 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
63078 + return -EPERM;
63079 + }
63080 +#endif
63081 + return 0;
63082 +}
63083 +
63084 +extern const char *captab_log[];
63085 +extern int captab_log_entries;
63086 +
63087 +int
63088 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
63089 +{
63090 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63091 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
63092 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
63093 + if (cap_raised(chroot_caps, cap)) {
63094 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
63095 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
63096 + }
63097 + return 0;
63098 + }
63099 + }
63100 +#endif
63101 + return 1;
63102 +}
63103 +
63104 +int
63105 +gr_chroot_is_capable(const int cap)
63106 +{
63107 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63108 + return gr_task_chroot_is_capable(current, current_cred(), cap);
63109 +#endif
63110 + return 1;
63111 +}
63112 +
63113 +int
63114 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
63115 +{
63116 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63117 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
63118 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
63119 + if (cap_raised(chroot_caps, cap)) {
63120 + return 0;
63121 + }
63122 + }
63123 +#endif
63124 + return 1;
63125 +}
63126 +
63127 +int
63128 +gr_chroot_is_capable_nolog(const int cap)
63129 +{
63130 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63131 + return gr_task_chroot_is_capable_nolog(current, cap);
63132 +#endif
63133 + return 1;
63134 +}
63135 +
63136 +int
63137 +gr_handle_chroot_sysctl(const int op)
63138 +{
63139 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
63140 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
63141 + proc_is_chrooted(current))
63142 + return -EACCES;
63143 +#endif
63144 + return 0;
63145 +}
63146 +
63147 +void
63148 +gr_handle_chroot_chdir(const struct path *path)
63149 +{
63150 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
63151 + if (grsec_enable_chroot_chdir)
63152 + set_fs_pwd(current->fs, path);
63153 +#endif
63154 + return;
63155 +}
63156 +
63157 +int
63158 +gr_handle_chroot_chmod(const struct dentry *dentry,
63159 + const struct vfsmount *mnt, const int mode)
63160 +{
63161 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
63162 + /* allow chmod +s on directories, but not files */
63163 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
63164 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
63165 + proc_is_chrooted(current)) {
63166 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
63167 + return -EPERM;
63168 + }
63169 +#endif
63170 + return 0;
63171 +}
63172 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
63173 new file mode 100644
63174 index 0000000..ce65ceb
63175 --- /dev/null
63176 +++ b/grsecurity/grsec_disabled.c
63177 @@ -0,0 +1,434 @@
63178 +#include <linux/kernel.h>
63179 +#include <linux/module.h>
63180 +#include <linux/sched.h>
63181 +#include <linux/file.h>
63182 +#include <linux/fs.h>
63183 +#include <linux/kdev_t.h>
63184 +#include <linux/net.h>
63185 +#include <linux/in.h>
63186 +#include <linux/ip.h>
63187 +#include <linux/skbuff.h>
63188 +#include <linux/sysctl.h>
63189 +
63190 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
63191 +void
63192 +pax_set_initial_flags(struct linux_binprm *bprm)
63193 +{
63194 + return;
63195 +}
63196 +#endif
63197 +
63198 +#ifdef CONFIG_SYSCTL
63199 +__u32
63200 +gr_handle_sysctl(const struct ctl_table * table, const int op)
63201 +{
63202 + return 0;
63203 +}
63204 +#endif
63205 +
63206 +#ifdef CONFIG_TASKSTATS
63207 +int gr_is_taskstats_denied(int pid)
63208 +{
63209 + return 0;
63210 +}
63211 +#endif
63212 +
63213 +int
63214 +gr_acl_is_enabled(void)
63215 +{
63216 + return 0;
63217 +}
63218 +
63219 +void
63220 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
63221 +{
63222 + return;
63223 +}
63224 +
63225 +int
63226 +gr_handle_rawio(const struct inode *inode)
63227 +{
63228 + return 0;
63229 +}
63230 +
63231 +void
63232 +gr_acl_handle_psacct(struct task_struct *task, const long code)
63233 +{
63234 + return;
63235 +}
63236 +
63237 +int
63238 +gr_handle_ptrace(struct task_struct *task, const long request)
63239 +{
63240 + return 0;
63241 +}
63242 +
63243 +int
63244 +gr_handle_proc_ptrace(struct task_struct *task)
63245 +{
63246 + return 0;
63247 +}
63248 +
63249 +int
63250 +gr_set_acls(const int type)
63251 +{
63252 + return 0;
63253 +}
63254 +
63255 +int
63256 +gr_check_hidden_task(const struct task_struct *tsk)
63257 +{
63258 + return 0;
63259 +}
63260 +
63261 +int
63262 +gr_check_protected_task(const struct task_struct *task)
63263 +{
63264 + return 0;
63265 +}
63266 +
63267 +int
63268 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
63269 +{
63270 + return 0;
63271 +}
63272 +
63273 +void
63274 +gr_copy_label(struct task_struct *tsk)
63275 +{
63276 + return;
63277 +}
63278 +
63279 +void
63280 +gr_set_pax_flags(struct task_struct *task)
63281 +{
63282 + return;
63283 +}
63284 +
63285 +int
63286 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
63287 + const int unsafe_share)
63288 +{
63289 + return 0;
63290 +}
63291 +
63292 +void
63293 +gr_handle_delete(const ino_t ino, const dev_t dev)
63294 +{
63295 + return;
63296 +}
63297 +
63298 +void
63299 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
63300 +{
63301 + return;
63302 +}
63303 +
63304 +void
63305 +gr_handle_crash(struct task_struct *task, const int sig)
63306 +{
63307 + return;
63308 +}
63309 +
63310 +int
63311 +gr_check_crash_exec(const struct file *filp)
63312 +{
63313 + return 0;
63314 +}
63315 +
63316 +int
63317 +gr_check_crash_uid(const kuid_t uid)
63318 +{
63319 + return 0;
63320 +}
63321 +
63322 +void
63323 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
63324 + struct dentry *old_dentry,
63325 + struct dentry *new_dentry,
63326 + struct vfsmount *mnt, const __u8 replace)
63327 +{
63328 + return;
63329 +}
63330 +
63331 +int
63332 +gr_search_socket(const int family, const int type, const int protocol)
63333 +{
63334 + return 1;
63335 +}
63336 +
63337 +int
63338 +gr_search_connectbind(const int mode, const struct socket *sock,
63339 + const struct sockaddr_in *addr)
63340 +{
63341 + return 0;
63342 +}
63343 +
63344 +void
63345 +gr_handle_alertkill(struct task_struct *task)
63346 +{
63347 + return;
63348 +}
63349 +
63350 +__u32
63351 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
63352 +{
63353 + return 1;
63354 +}
63355 +
63356 +__u32
63357 +gr_acl_handle_hidden_file(const struct dentry * dentry,
63358 + const struct vfsmount * mnt)
63359 +{
63360 + return 1;
63361 +}
63362 +
63363 +__u32
63364 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
63365 + int acc_mode)
63366 +{
63367 + return 1;
63368 +}
63369 +
63370 +__u32
63371 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
63372 +{
63373 + return 1;
63374 +}
63375 +
63376 +__u32
63377 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
63378 +{
63379 + return 1;
63380 +}
63381 +
63382 +int
63383 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
63384 + unsigned int *vm_flags)
63385 +{
63386 + return 1;
63387 +}
63388 +
63389 +__u32
63390 +gr_acl_handle_truncate(const struct dentry * dentry,
63391 + const struct vfsmount * mnt)
63392 +{
63393 + return 1;
63394 +}
63395 +
63396 +__u32
63397 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
63398 +{
63399 + return 1;
63400 +}
63401 +
63402 +__u32
63403 +gr_acl_handle_access(const struct dentry * dentry,
63404 + const struct vfsmount * mnt, const int fmode)
63405 +{
63406 + return 1;
63407 +}
63408 +
63409 +__u32
63410 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
63411 + umode_t *mode)
63412 +{
63413 + return 1;
63414 +}
63415 +
63416 +__u32
63417 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
63418 +{
63419 + return 1;
63420 +}
63421 +
63422 +__u32
63423 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
63424 +{
63425 + return 1;
63426 +}
63427 +
63428 +void
63429 +grsecurity_init(void)
63430 +{
63431 + return;
63432 +}
63433 +
63434 +umode_t gr_acl_umask(void)
63435 +{
63436 + return 0;
63437 +}
63438 +
63439 +__u32
63440 +gr_acl_handle_mknod(const struct dentry * new_dentry,
63441 + const struct dentry * parent_dentry,
63442 + const struct vfsmount * parent_mnt,
63443 + const int mode)
63444 +{
63445 + return 1;
63446 +}
63447 +
63448 +__u32
63449 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
63450 + const struct dentry * parent_dentry,
63451 + const struct vfsmount * parent_mnt)
63452 +{
63453 + return 1;
63454 +}
63455 +
63456 +__u32
63457 +gr_acl_handle_symlink(const struct dentry * new_dentry,
63458 + const struct dentry * parent_dentry,
63459 + const struct vfsmount * parent_mnt, const struct filename *from)
63460 +{
63461 + return 1;
63462 +}
63463 +
63464 +__u32
63465 +gr_acl_handle_link(const struct dentry * new_dentry,
63466 + const struct dentry * parent_dentry,
63467 + const struct vfsmount * parent_mnt,
63468 + const struct dentry * old_dentry,
63469 + const struct vfsmount * old_mnt, const struct filename *to)
63470 +{
63471 + return 1;
63472 +}
63473 +
63474 +int
63475 +gr_acl_handle_rename(const struct dentry *new_dentry,
63476 + const struct dentry *parent_dentry,
63477 + const struct vfsmount *parent_mnt,
63478 + const struct dentry *old_dentry,
63479 + const struct inode *old_parent_inode,
63480 + const struct vfsmount *old_mnt, const struct filename *newname)
63481 +{
63482 + return 0;
63483 +}
63484 +
63485 +int
63486 +gr_acl_handle_filldir(const struct file *file, const char *name,
63487 + const int namelen, const ino_t ino)
63488 +{
63489 + return 1;
63490 +}
63491 +
63492 +int
63493 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63494 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
63495 +{
63496 + return 1;
63497 +}
63498 +
63499 +int
63500 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
63501 +{
63502 + return 0;
63503 +}
63504 +
63505 +int
63506 +gr_search_accept(const struct socket *sock)
63507 +{
63508 + return 0;
63509 +}
63510 +
63511 +int
63512 +gr_search_listen(const struct socket *sock)
63513 +{
63514 + return 0;
63515 +}
63516 +
63517 +int
63518 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
63519 +{
63520 + return 0;
63521 +}
63522 +
63523 +__u32
63524 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
63525 +{
63526 + return 1;
63527 +}
63528 +
63529 +__u32
63530 +gr_acl_handle_creat(const struct dentry * dentry,
63531 + const struct dentry * p_dentry,
63532 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
63533 + const int imode)
63534 +{
63535 + return 1;
63536 +}
63537 +
63538 +void
63539 +gr_acl_handle_exit(void)
63540 +{
63541 + return;
63542 +}
63543 +
63544 +int
63545 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
63546 +{
63547 + return 1;
63548 +}
63549 +
63550 +void
63551 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
63552 +{
63553 + return;
63554 +}
63555 +
63556 +int
63557 +gr_acl_handle_procpidmem(const struct task_struct *task)
63558 +{
63559 + return 0;
63560 +}
63561 +
63562 +int
63563 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
63564 +{
63565 + return 0;
63566 +}
63567 +
63568 +int
63569 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
63570 +{
63571 + return 0;
63572 +}
63573 +
63574 +void
63575 +gr_set_kernel_label(struct task_struct *task)
63576 +{
63577 + return;
63578 +}
63579 +
63580 +int
63581 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
63582 +{
63583 + return 0;
63584 +}
63585 +
63586 +int
63587 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
63588 +{
63589 + return 0;
63590 +}
63591 +
63592 +int gr_acl_enable_at_secure(void)
63593 +{
63594 + return 0;
63595 +}
63596 +
63597 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
63598 +{
63599 + return dentry->d_sb->s_dev;
63600 +}
63601 +
63602 +void gr_put_exec_file(struct task_struct *task)
63603 +{
63604 + return;
63605 +}
63606 +
63607 +EXPORT_SYMBOL(gr_set_kernel_label);
63608 +#ifdef CONFIG_SECURITY
63609 +EXPORT_SYMBOL(gr_check_user_change);
63610 +EXPORT_SYMBOL(gr_check_group_change);
63611 +#endif
63612 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
63613 new file mode 100644
63614 index 0000000..387032b
63615 --- /dev/null
63616 +++ b/grsecurity/grsec_exec.c
63617 @@ -0,0 +1,187 @@
63618 +#include <linux/kernel.h>
63619 +#include <linux/sched.h>
63620 +#include <linux/file.h>
63621 +#include <linux/binfmts.h>
63622 +#include <linux/fs.h>
63623 +#include <linux/types.h>
63624 +#include <linux/grdefs.h>
63625 +#include <linux/grsecurity.h>
63626 +#include <linux/grinternal.h>
63627 +#include <linux/capability.h>
63628 +#include <linux/module.h>
63629 +#include <linux/compat.h>
63630 +
63631 +#include <asm/uaccess.h>
63632 +
63633 +#ifdef CONFIG_GRKERNSEC_EXECLOG
63634 +static char gr_exec_arg_buf[132];
63635 +static DEFINE_MUTEX(gr_exec_arg_mutex);
63636 +#endif
63637 +
63638 +struct user_arg_ptr {
63639 +#ifdef CONFIG_COMPAT
63640 + bool is_compat;
63641 +#endif
63642 + union {
63643 + const char __user *const __user *native;
63644 +#ifdef CONFIG_COMPAT
63645 + const compat_uptr_t __user *compat;
63646 +#endif
63647 + } ptr;
63648 +};
63649 +
63650 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
63651 +
63652 +void
63653 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
63654 +{
63655 +#ifdef CONFIG_GRKERNSEC_EXECLOG
63656 + char *grarg = gr_exec_arg_buf;
63657 + unsigned int i, x, execlen = 0;
63658 + char c;
63659 +
63660 + if (!((grsec_enable_execlog && grsec_enable_group &&
63661 + in_group_p(grsec_audit_gid))
63662 + || (grsec_enable_execlog && !grsec_enable_group)))
63663 + return;
63664 +
63665 + mutex_lock(&gr_exec_arg_mutex);
63666 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
63667 +
63668 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
63669 + const char __user *p;
63670 + unsigned int len;
63671 +
63672 + p = get_user_arg_ptr(argv, i);
63673 + if (IS_ERR(p))
63674 + goto log;
63675 +
63676 + len = strnlen_user(p, 128 - execlen);
63677 + if (len > 128 - execlen)
63678 + len = 128 - execlen;
63679 + else if (len > 0)
63680 + len--;
63681 + if (copy_from_user(grarg + execlen, p, len))
63682 + goto log;
63683 +
63684 + /* rewrite unprintable characters */
63685 + for (x = 0; x < len; x++) {
63686 + c = *(grarg + execlen + x);
63687 + if (c < 32 || c > 126)
63688 + *(grarg + execlen + x) = ' ';
63689 + }
63690 +
63691 + execlen += len;
63692 + *(grarg + execlen) = ' ';
63693 + *(grarg + execlen + 1) = '\0';
63694 + execlen++;
63695 + }
63696 +
63697 + log:
63698 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
63699 + bprm->file->f_path.mnt, grarg);
63700 + mutex_unlock(&gr_exec_arg_mutex);
63701 +#endif
63702 + return;
63703 +}
63704 +
63705 +#ifdef CONFIG_GRKERNSEC
63706 +extern int gr_acl_is_capable(const int cap);
63707 +extern int gr_acl_is_capable_nolog(const int cap);
63708 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
63709 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
63710 +extern int gr_chroot_is_capable(const int cap);
63711 +extern int gr_chroot_is_capable_nolog(const int cap);
63712 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
63713 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
63714 +#endif
63715 +
63716 +const char *captab_log[] = {
63717 + "CAP_CHOWN",
63718 + "CAP_DAC_OVERRIDE",
63719 + "CAP_DAC_READ_SEARCH",
63720 + "CAP_FOWNER",
63721 + "CAP_FSETID",
63722 + "CAP_KILL",
63723 + "CAP_SETGID",
63724 + "CAP_SETUID",
63725 + "CAP_SETPCAP",
63726 + "CAP_LINUX_IMMUTABLE",
63727 + "CAP_NET_BIND_SERVICE",
63728 + "CAP_NET_BROADCAST",
63729 + "CAP_NET_ADMIN",
63730 + "CAP_NET_RAW",
63731 + "CAP_IPC_LOCK",
63732 + "CAP_IPC_OWNER",
63733 + "CAP_SYS_MODULE",
63734 + "CAP_SYS_RAWIO",
63735 + "CAP_SYS_CHROOT",
63736 + "CAP_SYS_PTRACE",
63737 + "CAP_SYS_PACCT",
63738 + "CAP_SYS_ADMIN",
63739 + "CAP_SYS_BOOT",
63740 + "CAP_SYS_NICE",
63741 + "CAP_SYS_RESOURCE",
63742 + "CAP_SYS_TIME",
63743 + "CAP_SYS_TTY_CONFIG",
63744 + "CAP_MKNOD",
63745 + "CAP_LEASE",
63746 + "CAP_AUDIT_WRITE",
63747 + "CAP_AUDIT_CONTROL",
63748 + "CAP_SETFCAP",
63749 + "CAP_MAC_OVERRIDE",
63750 + "CAP_MAC_ADMIN",
63751 + "CAP_SYSLOG",
63752 + "CAP_WAKE_ALARM"
63753 +};
63754 +
63755 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
63756 +
63757 +int gr_is_capable(const int cap)
63758 +{
63759 +#ifdef CONFIG_GRKERNSEC
63760 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
63761 + return 1;
63762 + return 0;
63763 +#else
63764 + return 1;
63765 +#endif
63766 +}
63767 +
63768 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
63769 +{
63770 +#ifdef CONFIG_GRKERNSEC
63771 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
63772 + return 1;
63773 + return 0;
63774 +#else
63775 + return 1;
63776 +#endif
63777 +}
63778 +
63779 +int gr_is_capable_nolog(const int cap)
63780 +{
63781 +#ifdef CONFIG_GRKERNSEC
63782 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
63783 + return 1;
63784 + return 0;
63785 +#else
63786 + return 1;
63787 +#endif
63788 +}
63789 +
63790 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
63791 +{
63792 +#ifdef CONFIG_GRKERNSEC
63793 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
63794 + return 1;
63795 + return 0;
63796 +#else
63797 + return 1;
63798 +#endif
63799 +}
63800 +
63801 +EXPORT_SYMBOL(gr_is_capable);
63802 +EXPORT_SYMBOL(gr_is_capable_nolog);
63803 +EXPORT_SYMBOL(gr_task_is_capable);
63804 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
63805 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
63806 new file mode 100644
63807 index 0000000..06cc6ea
63808 --- /dev/null
63809 +++ b/grsecurity/grsec_fifo.c
63810 @@ -0,0 +1,24 @@
63811 +#include <linux/kernel.h>
63812 +#include <linux/sched.h>
63813 +#include <linux/fs.h>
63814 +#include <linux/file.h>
63815 +#include <linux/grinternal.h>
63816 +
63817 +int
63818 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
63819 + const struct dentry *dir, const int flag, const int acc_mode)
63820 +{
63821 +#ifdef CONFIG_GRKERNSEC_FIFO
63822 + const struct cred *cred = current_cred();
63823 +
63824 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
63825 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
63826 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
63827 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
63828 + if (!inode_permission(dentry->d_inode, acc_mode))
63829 + 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));
63830 + return -EACCES;
63831 + }
63832 +#endif
63833 + return 0;
63834 +}
63835 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
63836 new file mode 100644
63837 index 0000000..8ca18bf
63838 --- /dev/null
63839 +++ b/grsecurity/grsec_fork.c
63840 @@ -0,0 +1,23 @@
63841 +#include <linux/kernel.h>
63842 +#include <linux/sched.h>
63843 +#include <linux/grsecurity.h>
63844 +#include <linux/grinternal.h>
63845 +#include <linux/errno.h>
63846 +
63847 +void
63848 +gr_log_forkfail(const int retval)
63849 +{
63850 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
63851 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
63852 + switch (retval) {
63853 + case -EAGAIN:
63854 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
63855 + break;
63856 + case -ENOMEM:
63857 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
63858 + break;
63859 + }
63860 + }
63861 +#endif
63862 + return;
63863 +}
63864 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
63865 new file mode 100644
63866 index 0000000..a862e9f
63867 --- /dev/null
63868 +++ b/grsecurity/grsec_init.c
63869 @@ -0,0 +1,283 @@
63870 +#include <linux/kernel.h>
63871 +#include <linux/sched.h>
63872 +#include <linux/mm.h>
63873 +#include <linux/gracl.h>
63874 +#include <linux/slab.h>
63875 +#include <linux/vmalloc.h>
63876 +#include <linux/percpu.h>
63877 +#include <linux/module.h>
63878 +
63879 +int grsec_enable_ptrace_readexec;
63880 +int grsec_enable_setxid;
63881 +int grsec_enable_symlinkown;
63882 +kgid_t grsec_symlinkown_gid;
63883 +int grsec_enable_brute;
63884 +int grsec_enable_link;
63885 +int grsec_enable_dmesg;
63886 +int grsec_enable_harden_ptrace;
63887 +int grsec_enable_fifo;
63888 +int grsec_enable_execlog;
63889 +int grsec_enable_signal;
63890 +int grsec_enable_forkfail;
63891 +int grsec_enable_audit_ptrace;
63892 +int grsec_enable_time;
63893 +int grsec_enable_audit_textrel;
63894 +int grsec_enable_group;
63895 +kgid_t grsec_audit_gid;
63896 +int grsec_enable_chdir;
63897 +int grsec_enable_mount;
63898 +int grsec_enable_rofs;
63899 +int grsec_enable_chroot_findtask;
63900 +int grsec_enable_chroot_mount;
63901 +int grsec_enable_chroot_shmat;
63902 +int grsec_enable_chroot_fchdir;
63903 +int grsec_enable_chroot_double;
63904 +int grsec_enable_chroot_pivot;
63905 +int grsec_enable_chroot_chdir;
63906 +int grsec_enable_chroot_chmod;
63907 +int grsec_enable_chroot_mknod;
63908 +int grsec_enable_chroot_nice;
63909 +int grsec_enable_chroot_execlog;
63910 +int grsec_enable_chroot_caps;
63911 +int grsec_enable_chroot_sysctl;
63912 +int grsec_enable_chroot_unix;
63913 +int grsec_enable_tpe;
63914 +kgid_t grsec_tpe_gid;
63915 +int grsec_enable_blackhole;
63916 +#ifdef CONFIG_IPV6_MODULE
63917 +EXPORT_SYMBOL(grsec_enable_blackhole);
63918 +#endif
63919 +int grsec_lastack_retries;
63920 +int grsec_enable_tpe_all;
63921 +int grsec_enable_tpe_invert;
63922 +int grsec_enable_socket_all;
63923 +kgid_t grsec_socket_all_gid;
63924 +int grsec_enable_socket_client;
63925 +kgid_t grsec_socket_client_gid;
63926 +int grsec_enable_socket_server;
63927 +kgid_t grsec_socket_server_gid;
63928 +int grsec_resource_logging;
63929 +int grsec_disable_privio;
63930 +int grsec_enable_log_rwxmaps;
63931 +int grsec_lock;
63932 +
63933 +DEFINE_SPINLOCK(grsec_alert_lock);
63934 +unsigned long grsec_alert_wtime = 0;
63935 +unsigned long grsec_alert_fyet = 0;
63936 +
63937 +DEFINE_SPINLOCK(grsec_audit_lock);
63938 +
63939 +DEFINE_RWLOCK(grsec_exec_file_lock);
63940 +
63941 +char *gr_shared_page[4];
63942 +
63943 +char *gr_alert_log_fmt;
63944 +char *gr_audit_log_fmt;
63945 +char *gr_alert_log_buf;
63946 +char *gr_audit_log_buf;
63947 +
63948 +extern struct gr_arg *gr_usermode;
63949 +extern unsigned char *gr_system_salt;
63950 +extern unsigned char *gr_system_sum;
63951 +
63952 +void __init
63953 +grsecurity_init(void)
63954 +{
63955 + int j;
63956 + /* create the per-cpu shared pages */
63957 +
63958 +#ifdef CONFIG_X86
63959 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
63960 +#endif
63961 +
63962 + for (j = 0; j < 4; j++) {
63963 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
63964 + if (gr_shared_page[j] == NULL) {
63965 + panic("Unable to allocate grsecurity shared page");
63966 + return;
63967 + }
63968 + }
63969 +
63970 + /* allocate log buffers */
63971 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
63972 + if (!gr_alert_log_fmt) {
63973 + panic("Unable to allocate grsecurity alert log format buffer");
63974 + return;
63975 + }
63976 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
63977 + if (!gr_audit_log_fmt) {
63978 + panic("Unable to allocate grsecurity audit log format buffer");
63979 + return;
63980 + }
63981 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
63982 + if (!gr_alert_log_buf) {
63983 + panic("Unable to allocate grsecurity alert log buffer");
63984 + return;
63985 + }
63986 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
63987 + if (!gr_audit_log_buf) {
63988 + panic("Unable to allocate grsecurity audit log buffer");
63989 + return;
63990 + }
63991 +
63992 + /* allocate memory for authentication structure */
63993 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
63994 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
63995 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
63996 +
63997 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
63998 + panic("Unable to allocate grsecurity authentication structure");
63999 + return;
64000 + }
64001 +
64002 +
64003 +#ifdef CONFIG_GRKERNSEC_IO
64004 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
64005 + grsec_disable_privio = 1;
64006 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
64007 + grsec_disable_privio = 1;
64008 +#else
64009 + grsec_disable_privio = 0;
64010 +#endif
64011 +#endif
64012 +
64013 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
64014 + /* for backward compatibility, tpe_invert always defaults to on if
64015 + enabled in the kernel
64016 + */
64017 + grsec_enable_tpe_invert = 1;
64018 +#endif
64019 +
64020 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
64021 +#ifndef CONFIG_GRKERNSEC_SYSCTL
64022 + grsec_lock = 1;
64023 +#endif
64024 +
64025 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
64026 + grsec_enable_audit_textrel = 1;
64027 +#endif
64028 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
64029 + grsec_enable_log_rwxmaps = 1;
64030 +#endif
64031 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
64032 + grsec_enable_group = 1;
64033 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
64034 +#endif
64035 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
64036 + grsec_enable_ptrace_readexec = 1;
64037 +#endif
64038 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
64039 + grsec_enable_chdir = 1;
64040 +#endif
64041 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
64042 + grsec_enable_harden_ptrace = 1;
64043 +#endif
64044 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64045 + grsec_enable_mount = 1;
64046 +#endif
64047 +#ifdef CONFIG_GRKERNSEC_LINK
64048 + grsec_enable_link = 1;
64049 +#endif
64050 +#ifdef CONFIG_GRKERNSEC_BRUTE
64051 + grsec_enable_brute = 1;
64052 +#endif
64053 +#ifdef CONFIG_GRKERNSEC_DMESG
64054 + grsec_enable_dmesg = 1;
64055 +#endif
64056 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
64057 + grsec_enable_blackhole = 1;
64058 + grsec_lastack_retries = 4;
64059 +#endif
64060 +#ifdef CONFIG_GRKERNSEC_FIFO
64061 + grsec_enable_fifo = 1;
64062 +#endif
64063 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64064 + grsec_enable_execlog = 1;
64065 +#endif
64066 +#ifdef CONFIG_GRKERNSEC_SETXID
64067 + grsec_enable_setxid = 1;
64068 +#endif
64069 +#ifdef CONFIG_GRKERNSEC_SIGNAL
64070 + grsec_enable_signal = 1;
64071 +#endif
64072 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64073 + grsec_enable_forkfail = 1;
64074 +#endif
64075 +#ifdef CONFIG_GRKERNSEC_TIME
64076 + grsec_enable_time = 1;
64077 +#endif
64078 +#ifdef CONFIG_GRKERNSEC_RESLOG
64079 + grsec_resource_logging = 1;
64080 +#endif
64081 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64082 + grsec_enable_chroot_findtask = 1;
64083 +#endif
64084 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
64085 + grsec_enable_chroot_unix = 1;
64086 +#endif
64087 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64088 + grsec_enable_chroot_mount = 1;
64089 +#endif
64090 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64091 + grsec_enable_chroot_fchdir = 1;
64092 +#endif
64093 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64094 + grsec_enable_chroot_shmat = 1;
64095 +#endif
64096 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
64097 + grsec_enable_audit_ptrace = 1;
64098 +#endif
64099 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64100 + grsec_enable_chroot_double = 1;
64101 +#endif
64102 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64103 + grsec_enable_chroot_pivot = 1;
64104 +#endif
64105 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64106 + grsec_enable_chroot_chdir = 1;
64107 +#endif
64108 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64109 + grsec_enable_chroot_chmod = 1;
64110 +#endif
64111 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64112 + grsec_enable_chroot_mknod = 1;
64113 +#endif
64114 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64115 + grsec_enable_chroot_nice = 1;
64116 +#endif
64117 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64118 + grsec_enable_chroot_execlog = 1;
64119 +#endif
64120 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64121 + grsec_enable_chroot_caps = 1;
64122 +#endif
64123 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64124 + grsec_enable_chroot_sysctl = 1;
64125 +#endif
64126 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
64127 + grsec_enable_symlinkown = 1;
64128 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
64129 +#endif
64130 +#ifdef CONFIG_GRKERNSEC_TPE
64131 + grsec_enable_tpe = 1;
64132 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
64133 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
64134 + grsec_enable_tpe_all = 1;
64135 +#endif
64136 +#endif
64137 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
64138 + grsec_enable_socket_all = 1;
64139 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
64140 +#endif
64141 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
64142 + grsec_enable_socket_client = 1;
64143 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
64144 +#endif
64145 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
64146 + grsec_enable_socket_server = 1;
64147 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
64148 +#endif
64149 +#endif
64150 +
64151 + return;
64152 +}
64153 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
64154 new file mode 100644
64155 index 0000000..5e05e20
64156 --- /dev/null
64157 +++ b/grsecurity/grsec_link.c
64158 @@ -0,0 +1,58 @@
64159 +#include <linux/kernel.h>
64160 +#include <linux/sched.h>
64161 +#include <linux/fs.h>
64162 +#include <linux/file.h>
64163 +#include <linux/grinternal.h>
64164 +
64165 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
64166 +{
64167 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
64168 + const struct inode *link_inode = link->dentry->d_inode;
64169 +
64170 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
64171 + /* ignore root-owned links, e.g. /proc/self */
64172 + gr_is_global_nonroot(link_inode->i_uid) && target &&
64173 + !uid_eq(link_inode->i_uid, target->i_uid)) {
64174 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
64175 + return 1;
64176 + }
64177 +#endif
64178 + return 0;
64179 +}
64180 +
64181 +int
64182 +gr_handle_follow_link(const struct inode *parent,
64183 + const struct inode *inode,
64184 + const struct dentry *dentry, const struct vfsmount *mnt)
64185 +{
64186 +#ifdef CONFIG_GRKERNSEC_LINK
64187 + const struct cred *cred = current_cred();
64188 +
64189 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
64190 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
64191 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
64192 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
64193 + return -EACCES;
64194 + }
64195 +#endif
64196 + return 0;
64197 +}
64198 +
64199 +int
64200 +gr_handle_hardlink(const struct dentry *dentry,
64201 + const struct vfsmount *mnt,
64202 + struct inode *inode, const int mode, const struct filename *to)
64203 +{
64204 +#ifdef CONFIG_GRKERNSEC_LINK
64205 + const struct cred *cred = current_cred();
64206 +
64207 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
64208 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
64209 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
64210 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
64211 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
64212 + return -EPERM;
64213 + }
64214 +#endif
64215 + return 0;
64216 +}
64217 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
64218 new file mode 100644
64219 index 0000000..7c06085
64220 --- /dev/null
64221 +++ b/grsecurity/grsec_log.c
64222 @@ -0,0 +1,326 @@
64223 +#include <linux/kernel.h>
64224 +#include <linux/sched.h>
64225 +#include <linux/file.h>
64226 +#include <linux/tty.h>
64227 +#include <linux/fs.h>
64228 +#include <linux/grinternal.h>
64229 +
64230 +#ifdef CONFIG_TREE_PREEMPT_RCU
64231 +#define DISABLE_PREEMPT() preempt_disable()
64232 +#define ENABLE_PREEMPT() preempt_enable()
64233 +#else
64234 +#define DISABLE_PREEMPT()
64235 +#define ENABLE_PREEMPT()
64236 +#endif
64237 +
64238 +#define BEGIN_LOCKS(x) \
64239 + DISABLE_PREEMPT(); \
64240 + rcu_read_lock(); \
64241 + read_lock(&tasklist_lock); \
64242 + read_lock(&grsec_exec_file_lock); \
64243 + if (x != GR_DO_AUDIT) \
64244 + spin_lock(&grsec_alert_lock); \
64245 + else \
64246 + spin_lock(&grsec_audit_lock)
64247 +
64248 +#define END_LOCKS(x) \
64249 + if (x != GR_DO_AUDIT) \
64250 + spin_unlock(&grsec_alert_lock); \
64251 + else \
64252 + spin_unlock(&grsec_audit_lock); \
64253 + read_unlock(&grsec_exec_file_lock); \
64254 + read_unlock(&tasklist_lock); \
64255 + rcu_read_unlock(); \
64256 + ENABLE_PREEMPT(); \
64257 + if (x == GR_DONT_AUDIT) \
64258 + gr_handle_alertkill(current)
64259 +
64260 +enum {
64261 + FLOODING,
64262 + NO_FLOODING
64263 +};
64264 +
64265 +extern char *gr_alert_log_fmt;
64266 +extern char *gr_audit_log_fmt;
64267 +extern char *gr_alert_log_buf;
64268 +extern char *gr_audit_log_buf;
64269 +
64270 +static int gr_log_start(int audit)
64271 +{
64272 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
64273 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
64274 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64275 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
64276 + unsigned long curr_secs = get_seconds();
64277 +
64278 + if (audit == GR_DO_AUDIT)
64279 + goto set_fmt;
64280 +
64281 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
64282 + grsec_alert_wtime = curr_secs;
64283 + grsec_alert_fyet = 0;
64284 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
64285 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
64286 + grsec_alert_fyet++;
64287 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
64288 + grsec_alert_wtime = curr_secs;
64289 + grsec_alert_fyet++;
64290 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
64291 + return FLOODING;
64292 + }
64293 + else return FLOODING;
64294 +
64295 +set_fmt:
64296 +#endif
64297 + memset(buf, 0, PAGE_SIZE);
64298 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
64299 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
64300 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
64301 + } else if (current->signal->curr_ip) {
64302 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
64303 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
64304 + } else if (gr_acl_is_enabled()) {
64305 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
64306 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
64307 + } else {
64308 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
64309 + strcpy(buf, fmt);
64310 + }
64311 +
64312 + return NO_FLOODING;
64313 +}
64314 +
64315 +static void gr_log_middle(int audit, const char *msg, va_list ap)
64316 + __attribute__ ((format (printf, 2, 0)));
64317 +
64318 +static void gr_log_middle(int audit, const char *msg, va_list ap)
64319 +{
64320 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64321 + unsigned int len = strlen(buf);
64322 +
64323 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
64324 +
64325 + return;
64326 +}
64327 +
64328 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
64329 + __attribute__ ((format (printf, 2, 3)));
64330 +
64331 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
64332 +{
64333 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64334 + unsigned int len = strlen(buf);
64335 + va_list ap;
64336 +
64337 + va_start(ap, msg);
64338 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
64339 + va_end(ap);
64340 +
64341 + return;
64342 +}
64343 +
64344 +static void gr_log_end(int audit, int append_default)
64345 +{
64346 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
64347 + if (append_default) {
64348 + struct task_struct *task = current;
64349 + struct task_struct *parent = task->real_parent;
64350 + const struct cred *cred = __task_cred(task);
64351 + const struct cred *pcred = __task_cred(parent);
64352 + unsigned int len = strlen(buf);
64353 +
64354 + 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));
64355 + }
64356 +
64357 + printk("%s\n", buf);
64358 +
64359 + return;
64360 +}
64361 +
64362 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
64363 +{
64364 + int logtype;
64365 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
64366 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
64367 + void *voidptr = NULL;
64368 + int num1 = 0, num2 = 0;
64369 + unsigned long ulong1 = 0, ulong2 = 0;
64370 + struct dentry *dentry = NULL;
64371 + struct vfsmount *mnt = NULL;
64372 + struct file *file = NULL;
64373 + struct task_struct *task = NULL;
64374 + const struct cred *cred, *pcred;
64375 + va_list ap;
64376 +
64377 + BEGIN_LOCKS(audit);
64378 + logtype = gr_log_start(audit);
64379 + if (logtype == FLOODING) {
64380 + END_LOCKS(audit);
64381 + return;
64382 + }
64383 + va_start(ap, argtypes);
64384 + switch (argtypes) {
64385 + case GR_TTYSNIFF:
64386 + task = va_arg(ap, struct task_struct *);
64387 + 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));
64388 + break;
64389 + case GR_SYSCTL_HIDDEN:
64390 + str1 = va_arg(ap, char *);
64391 + gr_log_middle_varargs(audit, msg, result, str1);
64392 + break;
64393 + case GR_RBAC:
64394 + dentry = va_arg(ap, struct dentry *);
64395 + mnt = va_arg(ap, struct vfsmount *);
64396 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
64397 + break;
64398 + case GR_RBAC_STR:
64399 + dentry = va_arg(ap, struct dentry *);
64400 + mnt = va_arg(ap, struct vfsmount *);
64401 + str1 = va_arg(ap, char *);
64402 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
64403 + break;
64404 + case GR_STR_RBAC:
64405 + str1 = va_arg(ap, char *);
64406 + dentry = va_arg(ap, struct dentry *);
64407 + mnt = va_arg(ap, struct vfsmount *);
64408 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
64409 + break;
64410 + case GR_RBAC_MODE2:
64411 + dentry = va_arg(ap, struct dentry *);
64412 + mnt = va_arg(ap, struct vfsmount *);
64413 + str1 = va_arg(ap, char *);
64414 + str2 = va_arg(ap, char *);
64415 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
64416 + break;
64417 + case GR_RBAC_MODE3:
64418 + dentry = va_arg(ap, struct dentry *);
64419 + mnt = va_arg(ap, struct vfsmount *);
64420 + str1 = va_arg(ap, char *);
64421 + str2 = va_arg(ap, char *);
64422 + str3 = va_arg(ap, char *);
64423 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
64424 + break;
64425 + case GR_FILENAME:
64426 + dentry = va_arg(ap, struct dentry *);
64427 + mnt = va_arg(ap, struct vfsmount *);
64428 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
64429 + break;
64430 + case GR_STR_FILENAME:
64431 + str1 = va_arg(ap, char *);
64432 + dentry = va_arg(ap, struct dentry *);
64433 + mnt = va_arg(ap, struct vfsmount *);
64434 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
64435 + break;
64436 + case GR_FILENAME_STR:
64437 + dentry = va_arg(ap, struct dentry *);
64438 + mnt = va_arg(ap, struct vfsmount *);
64439 + str1 = va_arg(ap, char *);
64440 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
64441 + break;
64442 + case GR_FILENAME_TWO_INT:
64443 + dentry = va_arg(ap, struct dentry *);
64444 + mnt = va_arg(ap, struct vfsmount *);
64445 + num1 = va_arg(ap, int);
64446 + num2 = va_arg(ap, int);
64447 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
64448 + break;
64449 + case GR_FILENAME_TWO_INT_STR:
64450 + dentry = va_arg(ap, struct dentry *);
64451 + mnt = va_arg(ap, struct vfsmount *);
64452 + num1 = va_arg(ap, int);
64453 + num2 = va_arg(ap, int);
64454 + str1 = va_arg(ap, char *);
64455 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
64456 + break;
64457 + case GR_TEXTREL:
64458 + file = va_arg(ap, struct file *);
64459 + ulong1 = va_arg(ap, unsigned long);
64460 + ulong2 = va_arg(ap, unsigned long);
64461 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
64462 + break;
64463 + case GR_PTRACE:
64464 + task = va_arg(ap, struct task_struct *);
64465 + 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));
64466 + break;
64467 + case GR_RESOURCE:
64468 + task = va_arg(ap, struct task_struct *);
64469 + cred = __task_cred(task);
64470 + pcred = __task_cred(task->real_parent);
64471 + ulong1 = va_arg(ap, unsigned long);
64472 + str1 = va_arg(ap, char *);
64473 + ulong2 = va_arg(ap, unsigned long);
64474 + 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));
64475 + break;
64476 + case GR_CAP:
64477 + task = va_arg(ap, struct task_struct *);
64478 + cred = __task_cred(task);
64479 + pcred = __task_cred(task->real_parent);
64480 + str1 = va_arg(ap, char *);
64481 + 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));
64482 + break;
64483 + case GR_SIG:
64484 + str1 = va_arg(ap, char *);
64485 + voidptr = va_arg(ap, void *);
64486 + gr_log_middle_varargs(audit, msg, str1, voidptr);
64487 + break;
64488 + case GR_SIG2:
64489 + task = va_arg(ap, struct task_struct *);
64490 + cred = __task_cred(task);
64491 + pcred = __task_cred(task->real_parent);
64492 + num1 = va_arg(ap, int);
64493 + 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));
64494 + break;
64495 + case GR_CRASH1:
64496 + task = va_arg(ap, struct task_struct *);
64497 + cred = __task_cred(task);
64498 + pcred = __task_cred(task->real_parent);
64499 + ulong1 = va_arg(ap, unsigned long);
64500 + 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);
64501 + break;
64502 + case GR_CRASH2:
64503 + task = va_arg(ap, struct task_struct *);
64504 + cred = __task_cred(task);
64505 + pcred = __task_cred(task->real_parent);
64506 + ulong1 = va_arg(ap, unsigned long);
64507 + 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);
64508 + break;
64509 + case GR_RWXMAP:
64510 + file = va_arg(ap, struct file *);
64511 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
64512 + break;
64513 + case GR_PSACCT:
64514 + {
64515 + unsigned int wday, cday;
64516 + __u8 whr, chr;
64517 + __u8 wmin, cmin;
64518 + __u8 wsec, csec;
64519 + char cur_tty[64] = { 0 };
64520 + char parent_tty[64] = { 0 };
64521 +
64522 + task = va_arg(ap, struct task_struct *);
64523 + wday = va_arg(ap, unsigned int);
64524 + cday = va_arg(ap, unsigned int);
64525 + whr = va_arg(ap, int);
64526 + chr = va_arg(ap, int);
64527 + wmin = va_arg(ap, int);
64528 + cmin = va_arg(ap, int);
64529 + wsec = va_arg(ap, int);
64530 + csec = va_arg(ap, int);
64531 + ulong1 = va_arg(ap, unsigned long);
64532 + cred = __task_cred(task);
64533 + pcred = __task_cred(task->real_parent);
64534 +
64535 + 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));
64536 + }
64537 + break;
64538 + default:
64539 + gr_log_middle(audit, msg, ap);
64540 + }
64541 + va_end(ap);
64542 + // these don't need DEFAULTSECARGS printed on the end
64543 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
64544 + gr_log_end(audit, 0);
64545 + else
64546 + gr_log_end(audit, 1);
64547 + END_LOCKS(audit);
64548 +}
64549 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
64550 new file mode 100644
64551 index 0000000..f536303
64552 --- /dev/null
64553 +++ b/grsecurity/grsec_mem.c
64554 @@ -0,0 +1,40 @@
64555 +#include <linux/kernel.h>
64556 +#include <linux/sched.h>
64557 +#include <linux/mm.h>
64558 +#include <linux/mman.h>
64559 +#include <linux/grinternal.h>
64560 +
64561 +void
64562 +gr_handle_ioperm(void)
64563 +{
64564 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
64565 + return;
64566 +}
64567 +
64568 +void
64569 +gr_handle_iopl(void)
64570 +{
64571 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
64572 + return;
64573 +}
64574 +
64575 +void
64576 +gr_handle_mem_readwrite(u64 from, u64 to)
64577 +{
64578 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
64579 + return;
64580 +}
64581 +
64582 +void
64583 +gr_handle_vm86(void)
64584 +{
64585 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
64586 + return;
64587 +}
64588 +
64589 +void
64590 +gr_log_badprocpid(const char *entry)
64591 +{
64592 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
64593 + return;
64594 +}
64595 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
64596 new file mode 100644
64597 index 0000000..2131422
64598 --- /dev/null
64599 +++ b/grsecurity/grsec_mount.c
64600 @@ -0,0 +1,62 @@
64601 +#include <linux/kernel.h>
64602 +#include <linux/sched.h>
64603 +#include <linux/mount.h>
64604 +#include <linux/grsecurity.h>
64605 +#include <linux/grinternal.h>
64606 +
64607 +void
64608 +gr_log_remount(const char *devname, const int retval)
64609 +{
64610 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64611 + if (grsec_enable_mount && (retval >= 0))
64612 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
64613 +#endif
64614 + return;
64615 +}
64616 +
64617 +void
64618 +gr_log_unmount(const char *devname, const int retval)
64619 +{
64620 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64621 + if (grsec_enable_mount && (retval >= 0))
64622 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
64623 +#endif
64624 + return;
64625 +}
64626 +
64627 +void
64628 +gr_log_mount(const char *from, const char *to, const int retval)
64629 +{
64630 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64631 + if (grsec_enable_mount && (retval >= 0))
64632 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
64633 +#endif
64634 + return;
64635 +}
64636 +
64637 +int
64638 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
64639 +{
64640 +#ifdef CONFIG_GRKERNSEC_ROFS
64641 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
64642 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
64643 + return -EPERM;
64644 + } else
64645 + return 0;
64646 +#endif
64647 + return 0;
64648 +}
64649 +
64650 +int
64651 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
64652 +{
64653 +#ifdef CONFIG_GRKERNSEC_ROFS
64654 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
64655 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
64656 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
64657 + return -EPERM;
64658 + } else
64659 + return 0;
64660 +#endif
64661 + return 0;
64662 +}
64663 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
64664 new file mode 100644
64665 index 0000000..a3b12a0
64666 --- /dev/null
64667 +++ b/grsecurity/grsec_pax.c
64668 @@ -0,0 +1,36 @@
64669 +#include <linux/kernel.h>
64670 +#include <linux/sched.h>
64671 +#include <linux/mm.h>
64672 +#include <linux/file.h>
64673 +#include <linux/grinternal.h>
64674 +#include <linux/grsecurity.h>
64675 +
64676 +void
64677 +gr_log_textrel(struct vm_area_struct * vma)
64678 +{
64679 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
64680 + if (grsec_enable_audit_textrel)
64681 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
64682 +#endif
64683 + return;
64684 +}
64685 +
64686 +void
64687 +gr_log_rwxmmap(struct file *file)
64688 +{
64689 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
64690 + if (grsec_enable_log_rwxmaps)
64691 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
64692 +#endif
64693 + return;
64694 +}
64695 +
64696 +void
64697 +gr_log_rwxmprotect(struct file *file)
64698 +{
64699 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
64700 + if (grsec_enable_log_rwxmaps)
64701 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
64702 +#endif
64703 + return;
64704 +}
64705 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
64706 new file mode 100644
64707 index 0000000..f7f29aa
64708 --- /dev/null
64709 +++ b/grsecurity/grsec_ptrace.c
64710 @@ -0,0 +1,30 @@
64711 +#include <linux/kernel.h>
64712 +#include <linux/sched.h>
64713 +#include <linux/grinternal.h>
64714 +#include <linux/security.h>
64715 +
64716 +void
64717 +gr_audit_ptrace(struct task_struct *task)
64718 +{
64719 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
64720 + if (grsec_enable_audit_ptrace)
64721 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
64722 +#endif
64723 + return;
64724 +}
64725 +
64726 +int
64727 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
64728 +{
64729 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
64730 + const struct dentry *dentry = file->f_path.dentry;
64731 + const struct vfsmount *mnt = file->f_path.mnt;
64732 +
64733 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
64734 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
64735 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
64736 + return -EACCES;
64737 + }
64738 +#endif
64739 + return 0;
64740 +}
64741 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
64742 new file mode 100644
64743 index 0000000..e09715a
64744 --- /dev/null
64745 +++ b/grsecurity/grsec_sig.c
64746 @@ -0,0 +1,222 @@
64747 +#include <linux/kernel.h>
64748 +#include <linux/sched.h>
64749 +#include <linux/delay.h>
64750 +#include <linux/grsecurity.h>
64751 +#include <linux/grinternal.h>
64752 +#include <linux/hardirq.h>
64753 +
64754 +char *signames[] = {
64755 + [SIGSEGV] = "Segmentation fault",
64756 + [SIGILL] = "Illegal instruction",
64757 + [SIGABRT] = "Abort",
64758 + [SIGBUS] = "Invalid alignment/Bus error"
64759 +};
64760 +
64761 +void
64762 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
64763 +{
64764 +#ifdef CONFIG_GRKERNSEC_SIGNAL
64765 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
64766 + (sig == SIGABRT) || (sig == SIGBUS))) {
64767 + if (task_pid_nr(t) == task_pid_nr(current)) {
64768 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
64769 + } else {
64770 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
64771 + }
64772 + }
64773 +#endif
64774 + return;
64775 +}
64776 +
64777 +int
64778 +gr_handle_signal(const struct task_struct *p, const int sig)
64779 +{
64780 +#ifdef CONFIG_GRKERNSEC
64781 + /* ignore the 0 signal for protected task checks */
64782 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
64783 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
64784 + return -EPERM;
64785 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
64786 + return -EPERM;
64787 + }
64788 +#endif
64789 + return 0;
64790 +}
64791 +
64792 +#ifdef CONFIG_GRKERNSEC
64793 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
64794 +
64795 +int gr_fake_force_sig(int sig, struct task_struct *t)
64796 +{
64797 + unsigned long int flags;
64798 + int ret, blocked, ignored;
64799 + struct k_sigaction *action;
64800 +
64801 + spin_lock_irqsave(&t->sighand->siglock, flags);
64802 + action = &t->sighand->action[sig-1];
64803 + ignored = action->sa.sa_handler == SIG_IGN;
64804 + blocked = sigismember(&t->blocked, sig);
64805 + if (blocked || ignored) {
64806 + action->sa.sa_handler = SIG_DFL;
64807 + if (blocked) {
64808 + sigdelset(&t->blocked, sig);
64809 + recalc_sigpending_and_wake(t);
64810 + }
64811 + }
64812 + if (action->sa.sa_handler == SIG_DFL)
64813 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
64814 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
64815 +
64816 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
64817 +
64818 + return ret;
64819 +}
64820 +#endif
64821 +
64822 +#ifdef CONFIG_GRKERNSEC_BRUTE
64823 +#define GR_USER_BAN_TIME (15 * 60)
64824 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
64825 +
64826 +static int __get_dumpable(unsigned long mm_flags)
64827 +{
64828 + int ret;
64829 +
64830 + ret = mm_flags & MMF_DUMPABLE_MASK;
64831 + return (ret >= 2) ? 2 : ret;
64832 +}
64833 +#endif
64834 +
64835 +void gr_handle_brute_attach(unsigned long mm_flags)
64836 +{
64837 +#ifdef CONFIG_GRKERNSEC_BRUTE
64838 + struct task_struct *p = current;
64839 + kuid_t uid = GLOBAL_ROOT_UID;
64840 + int daemon = 0;
64841 +
64842 + if (!grsec_enable_brute)
64843 + return;
64844 +
64845 + rcu_read_lock();
64846 + read_lock(&tasklist_lock);
64847 + read_lock(&grsec_exec_file_lock);
64848 + if (p->real_parent && p->real_parent->exec_file == p->exec_file) {
64849 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
64850 + p->real_parent->brute = 1;
64851 + daemon = 1;
64852 + } else {
64853 + const struct cred *cred = __task_cred(p), *cred2;
64854 + struct task_struct *tsk, *tsk2;
64855 +
64856 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
64857 + struct user_struct *user;
64858 +
64859 + uid = cred->uid;
64860 +
64861 + /* this is put upon execution past expiration */
64862 + user = find_user(uid);
64863 + if (user == NULL)
64864 + goto unlock;
64865 + user->banned = 1;
64866 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
64867 + if (user->ban_expires == ~0UL)
64868 + user->ban_expires--;
64869 +
64870 + do_each_thread(tsk2, tsk) {
64871 + cred2 = __task_cred(tsk);
64872 + if (tsk != p && uid_eq(cred2->uid, uid))
64873 + gr_fake_force_sig(SIGKILL, tsk);
64874 + } while_each_thread(tsk2, tsk);
64875 + }
64876 + }
64877 +unlock:
64878 + read_unlock(&grsec_exec_file_lock);
64879 + read_unlock(&tasklist_lock);
64880 + rcu_read_unlock();
64881 +
64882 + if (gr_is_global_nonroot(uid))
64883 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n",
64884 + GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
64885 + else if (daemon)
64886 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
64887 +
64888 +#endif
64889 + return;
64890 +}
64891 +
64892 +void gr_handle_brute_check(void)
64893 +{
64894 +#ifdef CONFIG_GRKERNSEC_BRUTE
64895 + struct task_struct *p = current;
64896 +
64897 + if (unlikely(p->brute)) {
64898 + if (!grsec_enable_brute)
64899 + p->brute = 0;
64900 + else if (time_before(get_seconds(), p->brute_expires))
64901 + msleep(30 * 1000);
64902 + }
64903 +#endif
64904 + return;
64905 +}
64906 +
64907 +void gr_handle_kernel_exploit(void)
64908 +{
64909 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
64910 + const struct cred *cred;
64911 + struct task_struct *tsk, *tsk2;
64912 + struct user_struct *user;
64913 + kuid_t uid;
64914 +
64915 + if (in_irq() || in_serving_softirq() || in_nmi())
64916 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
64917 +
64918 + uid = current_uid();
64919 +
64920 + if (gr_is_global_root(uid))
64921 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
64922 + else {
64923 + /* kill all the processes of this user, hold a reference
64924 + to their creds struct, and prevent them from creating
64925 + another process until system reset
64926 + */
64927 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
64928 + GR_GLOBAL_UID(uid));
64929 + /* we intentionally leak this ref */
64930 + user = get_uid(current->cred->user);
64931 + if (user) {
64932 + user->banned = 1;
64933 + user->ban_expires = ~0UL;
64934 + }
64935 +
64936 + read_lock(&tasklist_lock);
64937 + do_each_thread(tsk2, tsk) {
64938 + cred = __task_cred(tsk);
64939 + if (uid_eq(cred->uid, uid))
64940 + gr_fake_force_sig(SIGKILL, tsk);
64941 + } while_each_thread(tsk2, tsk);
64942 + read_unlock(&tasklist_lock);
64943 + }
64944 +#endif
64945 +}
64946 +
64947 +int __gr_process_user_ban(struct user_struct *user)
64948 +{
64949 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
64950 + if (unlikely(user->banned)) {
64951 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
64952 + user->banned = 0;
64953 + user->ban_expires = 0;
64954 + free_uid(user);
64955 + } else
64956 + return -EPERM;
64957 + }
64958 +#endif
64959 + return 0;
64960 +}
64961 +
64962 +int gr_process_user_ban(void)
64963 +{
64964 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
64965 + return __gr_process_user_ban(current->cred->user);
64966 +#endif
64967 + return 0;
64968 +}
64969 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
64970 new file mode 100644
64971 index 0000000..4030d57
64972 --- /dev/null
64973 +++ b/grsecurity/grsec_sock.c
64974 @@ -0,0 +1,244 @@
64975 +#include <linux/kernel.h>
64976 +#include <linux/module.h>
64977 +#include <linux/sched.h>
64978 +#include <linux/file.h>
64979 +#include <linux/net.h>
64980 +#include <linux/in.h>
64981 +#include <linux/ip.h>
64982 +#include <net/sock.h>
64983 +#include <net/inet_sock.h>
64984 +#include <linux/grsecurity.h>
64985 +#include <linux/grinternal.h>
64986 +#include <linux/gracl.h>
64987 +
64988 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
64989 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
64990 +
64991 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
64992 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
64993 +
64994 +#ifdef CONFIG_UNIX_MODULE
64995 +EXPORT_SYMBOL(gr_acl_handle_unix);
64996 +EXPORT_SYMBOL(gr_acl_handle_mknod);
64997 +EXPORT_SYMBOL(gr_handle_chroot_unix);
64998 +EXPORT_SYMBOL(gr_handle_create);
64999 +#endif
65000 +
65001 +#ifdef CONFIG_GRKERNSEC
65002 +#define gr_conn_table_size 32749
65003 +struct conn_table_entry {
65004 + struct conn_table_entry *next;
65005 + struct signal_struct *sig;
65006 +};
65007 +
65008 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
65009 +DEFINE_SPINLOCK(gr_conn_table_lock);
65010 +
65011 +extern const char * gr_socktype_to_name(unsigned char type);
65012 +extern const char * gr_proto_to_name(unsigned char proto);
65013 +extern const char * gr_sockfamily_to_name(unsigned char family);
65014 +
65015 +static __inline__ int
65016 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
65017 +{
65018 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
65019 +}
65020 +
65021 +static __inline__ int
65022 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
65023 + __u16 sport, __u16 dport)
65024 +{
65025 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
65026 + sig->gr_sport == sport && sig->gr_dport == dport))
65027 + return 1;
65028 + else
65029 + return 0;
65030 +}
65031 +
65032 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
65033 +{
65034 + struct conn_table_entry **match;
65035 + unsigned int index;
65036 +
65037 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
65038 + sig->gr_sport, sig->gr_dport,
65039 + gr_conn_table_size);
65040 +
65041 + newent->sig = sig;
65042 +
65043 + match = &gr_conn_table[index];
65044 + newent->next = *match;
65045 + *match = newent;
65046 +
65047 + return;
65048 +}
65049 +
65050 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
65051 +{
65052 + struct conn_table_entry *match, *last = NULL;
65053 + unsigned int index;
65054 +
65055 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
65056 + sig->gr_sport, sig->gr_dport,
65057 + gr_conn_table_size);
65058 +
65059 + match = gr_conn_table[index];
65060 + while (match && !conn_match(match->sig,
65061 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
65062 + sig->gr_dport)) {
65063 + last = match;
65064 + match = match->next;
65065 + }
65066 +
65067 + if (match) {
65068 + if (last)
65069 + last->next = match->next;
65070 + else
65071 + gr_conn_table[index] = NULL;
65072 + kfree(match);
65073 + }
65074 +
65075 + return;
65076 +}
65077 +
65078 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
65079 + __u16 sport, __u16 dport)
65080 +{
65081 + struct conn_table_entry *match;
65082 + unsigned int index;
65083 +
65084 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
65085 +
65086 + match = gr_conn_table[index];
65087 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
65088 + match = match->next;
65089 +
65090 + if (match)
65091 + return match->sig;
65092 + else
65093 + return NULL;
65094 +}
65095 +
65096 +#endif
65097 +
65098 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
65099 +{
65100 +#ifdef CONFIG_GRKERNSEC
65101 + struct signal_struct *sig = task->signal;
65102 + struct conn_table_entry *newent;
65103 +
65104 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
65105 + if (newent == NULL)
65106 + return;
65107 + /* no bh lock needed since we are called with bh disabled */
65108 + spin_lock(&gr_conn_table_lock);
65109 + gr_del_task_from_ip_table_nolock(sig);
65110 + sig->gr_saddr = inet->inet_rcv_saddr;
65111 + sig->gr_daddr = inet->inet_daddr;
65112 + sig->gr_sport = inet->inet_sport;
65113 + sig->gr_dport = inet->inet_dport;
65114 + gr_add_to_task_ip_table_nolock(sig, newent);
65115 + spin_unlock(&gr_conn_table_lock);
65116 +#endif
65117 + return;
65118 +}
65119 +
65120 +void gr_del_task_from_ip_table(struct task_struct *task)
65121 +{
65122 +#ifdef CONFIG_GRKERNSEC
65123 + spin_lock_bh(&gr_conn_table_lock);
65124 + gr_del_task_from_ip_table_nolock(task->signal);
65125 + spin_unlock_bh(&gr_conn_table_lock);
65126 +#endif
65127 + return;
65128 +}
65129 +
65130 +void
65131 +gr_attach_curr_ip(const struct sock *sk)
65132 +{
65133 +#ifdef CONFIG_GRKERNSEC
65134 + struct signal_struct *p, *set;
65135 + const struct inet_sock *inet = inet_sk(sk);
65136 +
65137 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
65138 + return;
65139 +
65140 + set = current->signal;
65141 +
65142 + spin_lock_bh(&gr_conn_table_lock);
65143 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
65144 + inet->inet_dport, inet->inet_sport);
65145 + if (unlikely(p != NULL)) {
65146 + set->curr_ip = p->curr_ip;
65147 + set->used_accept = 1;
65148 + gr_del_task_from_ip_table_nolock(p);
65149 + spin_unlock_bh(&gr_conn_table_lock);
65150 + return;
65151 + }
65152 + spin_unlock_bh(&gr_conn_table_lock);
65153 +
65154 + set->curr_ip = inet->inet_daddr;
65155 + set->used_accept = 1;
65156 +#endif
65157 + return;
65158 +}
65159 +
65160 +int
65161 +gr_handle_sock_all(const int family, const int type, const int protocol)
65162 +{
65163 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65164 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
65165 + (family != AF_UNIX)) {
65166 + if (family == AF_INET)
65167 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
65168 + else
65169 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
65170 + return -EACCES;
65171 + }
65172 +#endif
65173 + return 0;
65174 +}
65175 +
65176 +int
65177 +gr_handle_sock_server(const struct sockaddr *sck)
65178 +{
65179 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65180 + if (grsec_enable_socket_server &&
65181 + in_group_p(grsec_socket_server_gid) &&
65182 + sck && (sck->sa_family != AF_UNIX) &&
65183 + (sck->sa_family != AF_LOCAL)) {
65184 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
65185 + return -EACCES;
65186 + }
65187 +#endif
65188 + return 0;
65189 +}
65190 +
65191 +int
65192 +gr_handle_sock_server_other(const struct sock *sck)
65193 +{
65194 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65195 + if (grsec_enable_socket_server &&
65196 + in_group_p(grsec_socket_server_gid) &&
65197 + sck && (sck->sk_family != AF_UNIX) &&
65198 + (sck->sk_family != AF_LOCAL)) {
65199 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
65200 + return -EACCES;
65201 + }
65202 +#endif
65203 + return 0;
65204 +}
65205 +
65206 +int
65207 +gr_handle_sock_client(const struct sockaddr *sck)
65208 +{
65209 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65210 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
65211 + sck && (sck->sa_family != AF_UNIX) &&
65212 + (sck->sa_family != AF_LOCAL)) {
65213 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
65214 + return -EACCES;
65215 + }
65216 +#endif
65217 + return 0;
65218 +}
65219 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
65220 new file mode 100644
65221 index 0000000..f55ef0f
65222 --- /dev/null
65223 +++ b/grsecurity/grsec_sysctl.c
65224 @@ -0,0 +1,469 @@
65225 +#include <linux/kernel.h>
65226 +#include <linux/sched.h>
65227 +#include <linux/sysctl.h>
65228 +#include <linux/grsecurity.h>
65229 +#include <linux/grinternal.h>
65230 +
65231 +int
65232 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
65233 +{
65234 +#ifdef CONFIG_GRKERNSEC_SYSCTL
65235 + if (dirname == NULL || name == NULL)
65236 + return 0;
65237 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
65238 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
65239 + return -EACCES;
65240 + }
65241 +#endif
65242 + return 0;
65243 +}
65244 +
65245 +#ifdef CONFIG_GRKERNSEC_ROFS
65246 +static int __maybe_unused one = 1;
65247 +#endif
65248 +
65249 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
65250 +struct ctl_table grsecurity_table[] = {
65251 +#ifdef CONFIG_GRKERNSEC_SYSCTL
65252 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
65253 +#ifdef CONFIG_GRKERNSEC_IO
65254 + {
65255 + .procname = "disable_priv_io",
65256 + .data = &grsec_disable_privio,
65257 + .maxlen = sizeof(int),
65258 + .mode = 0600,
65259 + .proc_handler = &proc_dointvec,
65260 + },
65261 +#endif
65262 +#endif
65263 +#ifdef CONFIG_GRKERNSEC_LINK
65264 + {
65265 + .procname = "linking_restrictions",
65266 + .data = &grsec_enable_link,
65267 + .maxlen = sizeof(int),
65268 + .mode = 0600,
65269 + .proc_handler = &proc_dointvec,
65270 + },
65271 +#endif
65272 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65273 + {
65274 + .procname = "enforce_symlinksifowner",
65275 + .data = &grsec_enable_symlinkown,
65276 + .maxlen = sizeof(int),
65277 + .mode = 0600,
65278 + .proc_handler = &proc_dointvec,
65279 + },
65280 + {
65281 + .procname = "symlinkown_gid",
65282 + .data = &grsec_symlinkown_gid,
65283 + .maxlen = sizeof(int),
65284 + .mode = 0600,
65285 + .proc_handler = &proc_dointvec,
65286 + },
65287 +#endif
65288 +#ifdef CONFIG_GRKERNSEC_BRUTE
65289 + {
65290 + .procname = "deter_bruteforce",
65291 + .data = &grsec_enable_brute,
65292 + .maxlen = sizeof(int),
65293 + .mode = 0600,
65294 + .proc_handler = &proc_dointvec,
65295 + },
65296 +#endif
65297 +#ifdef CONFIG_GRKERNSEC_FIFO
65298 + {
65299 + .procname = "fifo_restrictions",
65300 + .data = &grsec_enable_fifo,
65301 + .maxlen = sizeof(int),
65302 + .mode = 0600,
65303 + .proc_handler = &proc_dointvec,
65304 + },
65305 +#endif
65306 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65307 + {
65308 + .procname = "ptrace_readexec",
65309 + .data = &grsec_enable_ptrace_readexec,
65310 + .maxlen = sizeof(int),
65311 + .mode = 0600,
65312 + .proc_handler = &proc_dointvec,
65313 + },
65314 +#endif
65315 +#ifdef CONFIG_GRKERNSEC_SETXID
65316 + {
65317 + .procname = "consistent_setxid",
65318 + .data = &grsec_enable_setxid,
65319 + .maxlen = sizeof(int),
65320 + .mode = 0600,
65321 + .proc_handler = &proc_dointvec,
65322 + },
65323 +#endif
65324 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65325 + {
65326 + .procname = "ip_blackhole",
65327 + .data = &grsec_enable_blackhole,
65328 + .maxlen = sizeof(int),
65329 + .mode = 0600,
65330 + .proc_handler = &proc_dointvec,
65331 + },
65332 + {
65333 + .procname = "lastack_retries",
65334 + .data = &grsec_lastack_retries,
65335 + .maxlen = sizeof(int),
65336 + .mode = 0600,
65337 + .proc_handler = &proc_dointvec,
65338 + },
65339 +#endif
65340 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65341 + {
65342 + .procname = "exec_logging",
65343 + .data = &grsec_enable_execlog,
65344 + .maxlen = sizeof(int),
65345 + .mode = 0600,
65346 + .proc_handler = &proc_dointvec,
65347 + },
65348 +#endif
65349 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65350 + {
65351 + .procname = "rwxmap_logging",
65352 + .data = &grsec_enable_log_rwxmaps,
65353 + .maxlen = sizeof(int),
65354 + .mode = 0600,
65355 + .proc_handler = &proc_dointvec,
65356 + },
65357 +#endif
65358 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65359 + {
65360 + .procname = "signal_logging",
65361 + .data = &grsec_enable_signal,
65362 + .maxlen = sizeof(int),
65363 + .mode = 0600,
65364 + .proc_handler = &proc_dointvec,
65365 + },
65366 +#endif
65367 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65368 + {
65369 + .procname = "forkfail_logging",
65370 + .data = &grsec_enable_forkfail,
65371 + .maxlen = sizeof(int),
65372 + .mode = 0600,
65373 + .proc_handler = &proc_dointvec,
65374 + },
65375 +#endif
65376 +#ifdef CONFIG_GRKERNSEC_TIME
65377 + {
65378 + .procname = "timechange_logging",
65379 + .data = &grsec_enable_time,
65380 + .maxlen = sizeof(int),
65381 + .mode = 0600,
65382 + .proc_handler = &proc_dointvec,
65383 + },
65384 +#endif
65385 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65386 + {
65387 + .procname = "chroot_deny_shmat",
65388 + .data = &grsec_enable_chroot_shmat,
65389 + .maxlen = sizeof(int),
65390 + .mode = 0600,
65391 + .proc_handler = &proc_dointvec,
65392 + },
65393 +#endif
65394 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65395 + {
65396 + .procname = "chroot_deny_unix",
65397 + .data = &grsec_enable_chroot_unix,
65398 + .maxlen = sizeof(int),
65399 + .mode = 0600,
65400 + .proc_handler = &proc_dointvec,
65401 + },
65402 +#endif
65403 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65404 + {
65405 + .procname = "chroot_deny_mount",
65406 + .data = &grsec_enable_chroot_mount,
65407 + .maxlen = sizeof(int),
65408 + .mode = 0600,
65409 + .proc_handler = &proc_dointvec,
65410 + },
65411 +#endif
65412 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
65413 + {
65414 + .procname = "chroot_deny_fchdir",
65415 + .data = &grsec_enable_chroot_fchdir,
65416 + .maxlen = sizeof(int),
65417 + .mode = 0600,
65418 + .proc_handler = &proc_dointvec,
65419 + },
65420 +#endif
65421 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
65422 + {
65423 + .procname = "chroot_deny_chroot",
65424 + .data = &grsec_enable_chroot_double,
65425 + .maxlen = sizeof(int),
65426 + .mode = 0600,
65427 + .proc_handler = &proc_dointvec,
65428 + },
65429 +#endif
65430 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
65431 + {
65432 + .procname = "chroot_deny_pivot",
65433 + .data = &grsec_enable_chroot_pivot,
65434 + .maxlen = sizeof(int),
65435 + .mode = 0600,
65436 + .proc_handler = &proc_dointvec,
65437 + },
65438 +#endif
65439 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65440 + {
65441 + .procname = "chroot_enforce_chdir",
65442 + .data = &grsec_enable_chroot_chdir,
65443 + .maxlen = sizeof(int),
65444 + .mode = 0600,
65445 + .proc_handler = &proc_dointvec,
65446 + },
65447 +#endif
65448 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65449 + {
65450 + .procname = "chroot_deny_chmod",
65451 + .data = &grsec_enable_chroot_chmod,
65452 + .maxlen = sizeof(int),
65453 + .mode = 0600,
65454 + .proc_handler = &proc_dointvec,
65455 + },
65456 +#endif
65457 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
65458 + {
65459 + .procname = "chroot_deny_mknod",
65460 + .data = &grsec_enable_chroot_mknod,
65461 + .maxlen = sizeof(int),
65462 + .mode = 0600,
65463 + .proc_handler = &proc_dointvec,
65464 + },
65465 +#endif
65466 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
65467 + {
65468 + .procname = "chroot_restrict_nice",
65469 + .data = &grsec_enable_chroot_nice,
65470 + .maxlen = sizeof(int),
65471 + .mode = 0600,
65472 + .proc_handler = &proc_dointvec,
65473 + },
65474 +#endif
65475 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
65476 + {
65477 + .procname = "chroot_execlog",
65478 + .data = &grsec_enable_chroot_execlog,
65479 + .maxlen = sizeof(int),
65480 + .mode = 0600,
65481 + .proc_handler = &proc_dointvec,
65482 + },
65483 +#endif
65484 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65485 + {
65486 + .procname = "chroot_caps",
65487 + .data = &grsec_enable_chroot_caps,
65488 + .maxlen = sizeof(int),
65489 + .mode = 0600,
65490 + .proc_handler = &proc_dointvec,
65491 + },
65492 +#endif
65493 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
65494 + {
65495 + .procname = "chroot_deny_sysctl",
65496 + .data = &grsec_enable_chroot_sysctl,
65497 + .maxlen = sizeof(int),
65498 + .mode = 0600,
65499 + .proc_handler = &proc_dointvec,
65500 + },
65501 +#endif
65502 +#ifdef CONFIG_GRKERNSEC_TPE
65503 + {
65504 + .procname = "tpe",
65505 + .data = &grsec_enable_tpe,
65506 + .maxlen = sizeof(int),
65507 + .mode = 0600,
65508 + .proc_handler = &proc_dointvec,
65509 + },
65510 + {
65511 + .procname = "tpe_gid",
65512 + .data = &grsec_tpe_gid,
65513 + .maxlen = sizeof(int),
65514 + .mode = 0600,
65515 + .proc_handler = &proc_dointvec,
65516 + },
65517 +#endif
65518 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65519 + {
65520 + .procname = "tpe_invert",
65521 + .data = &grsec_enable_tpe_invert,
65522 + .maxlen = sizeof(int),
65523 + .mode = 0600,
65524 + .proc_handler = &proc_dointvec,
65525 + },
65526 +#endif
65527 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65528 + {
65529 + .procname = "tpe_restrict_all",
65530 + .data = &grsec_enable_tpe_all,
65531 + .maxlen = sizeof(int),
65532 + .mode = 0600,
65533 + .proc_handler = &proc_dointvec,
65534 + },
65535 +#endif
65536 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65537 + {
65538 + .procname = "socket_all",
65539 + .data = &grsec_enable_socket_all,
65540 + .maxlen = sizeof(int),
65541 + .mode = 0600,
65542 + .proc_handler = &proc_dointvec,
65543 + },
65544 + {
65545 + .procname = "socket_all_gid",
65546 + .data = &grsec_socket_all_gid,
65547 + .maxlen = sizeof(int),
65548 + .mode = 0600,
65549 + .proc_handler = &proc_dointvec,
65550 + },
65551 +#endif
65552 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65553 + {
65554 + .procname = "socket_client",
65555 + .data = &grsec_enable_socket_client,
65556 + .maxlen = sizeof(int),
65557 + .mode = 0600,
65558 + .proc_handler = &proc_dointvec,
65559 + },
65560 + {
65561 + .procname = "socket_client_gid",
65562 + .data = &grsec_socket_client_gid,
65563 + .maxlen = sizeof(int),
65564 + .mode = 0600,
65565 + .proc_handler = &proc_dointvec,
65566 + },
65567 +#endif
65568 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65569 + {
65570 + .procname = "socket_server",
65571 + .data = &grsec_enable_socket_server,
65572 + .maxlen = sizeof(int),
65573 + .mode = 0600,
65574 + .proc_handler = &proc_dointvec,
65575 + },
65576 + {
65577 + .procname = "socket_server_gid",
65578 + .data = &grsec_socket_server_gid,
65579 + .maxlen = sizeof(int),
65580 + .mode = 0600,
65581 + .proc_handler = &proc_dointvec,
65582 + },
65583 +#endif
65584 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
65585 + {
65586 + .procname = "audit_group",
65587 + .data = &grsec_enable_group,
65588 + .maxlen = sizeof(int),
65589 + .mode = 0600,
65590 + .proc_handler = &proc_dointvec,
65591 + },
65592 + {
65593 + .procname = "audit_gid",
65594 + .data = &grsec_audit_gid,
65595 + .maxlen = sizeof(int),
65596 + .mode = 0600,
65597 + .proc_handler = &proc_dointvec,
65598 + },
65599 +#endif
65600 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
65601 + {
65602 + .procname = "audit_chdir",
65603 + .data = &grsec_enable_chdir,
65604 + .maxlen = sizeof(int),
65605 + .mode = 0600,
65606 + .proc_handler = &proc_dointvec,
65607 + },
65608 +#endif
65609 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65610 + {
65611 + .procname = "audit_mount",
65612 + .data = &grsec_enable_mount,
65613 + .maxlen = sizeof(int),
65614 + .mode = 0600,
65615 + .proc_handler = &proc_dointvec,
65616 + },
65617 +#endif
65618 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65619 + {
65620 + .procname = "audit_textrel",
65621 + .data = &grsec_enable_audit_textrel,
65622 + .maxlen = sizeof(int),
65623 + .mode = 0600,
65624 + .proc_handler = &proc_dointvec,
65625 + },
65626 +#endif
65627 +#ifdef CONFIG_GRKERNSEC_DMESG
65628 + {
65629 + .procname = "dmesg",
65630 + .data = &grsec_enable_dmesg,
65631 + .maxlen = sizeof(int),
65632 + .mode = 0600,
65633 + .proc_handler = &proc_dointvec,
65634 + },
65635 +#endif
65636 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
65637 + {
65638 + .procname = "chroot_findtask",
65639 + .data = &grsec_enable_chroot_findtask,
65640 + .maxlen = sizeof(int),
65641 + .mode = 0600,
65642 + .proc_handler = &proc_dointvec,
65643 + },
65644 +#endif
65645 +#ifdef CONFIG_GRKERNSEC_RESLOG
65646 + {
65647 + .procname = "resource_logging",
65648 + .data = &grsec_resource_logging,
65649 + .maxlen = sizeof(int),
65650 + .mode = 0600,
65651 + .proc_handler = &proc_dointvec,
65652 + },
65653 +#endif
65654 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65655 + {
65656 + .procname = "audit_ptrace",
65657 + .data = &grsec_enable_audit_ptrace,
65658 + .maxlen = sizeof(int),
65659 + .mode = 0600,
65660 + .proc_handler = &proc_dointvec,
65661 + },
65662 +#endif
65663 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65664 + {
65665 + .procname = "harden_ptrace",
65666 + .data = &grsec_enable_harden_ptrace,
65667 + .maxlen = sizeof(int),
65668 + .mode = 0600,
65669 + .proc_handler = &proc_dointvec,
65670 + },
65671 +#endif
65672 + {
65673 + .procname = "grsec_lock",
65674 + .data = &grsec_lock,
65675 + .maxlen = sizeof(int),
65676 + .mode = 0600,
65677 + .proc_handler = &proc_dointvec,
65678 + },
65679 +#endif
65680 +#ifdef CONFIG_GRKERNSEC_ROFS
65681 + {
65682 + .procname = "romount_protect",
65683 + .data = &grsec_enable_rofs,
65684 + .maxlen = sizeof(int),
65685 + .mode = 0600,
65686 + .proc_handler = &proc_dointvec_minmax,
65687 + .extra1 = &one,
65688 + .extra2 = &one,
65689 + },
65690 +#endif
65691 + { }
65692 +};
65693 +#endif
65694 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
65695 new file mode 100644
65696 index 0000000..0dc13c3
65697 --- /dev/null
65698 +++ b/grsecurity/grsec_time.c
65699 @@ -0,0 +1,16 @@
65700 +#include <linux/kernel.h>
65701 +#include <linux/sched.h>
65702 +#include <linux/grinternal.h>
65703 +#include <linux/module.h>
65704 +
65705 +void
65706 +gr_log_timechange(void)
65707 +{
65708 +#ifdef CONFIG_GRKERNSEC_TIME
65709 + if (grsec_enable_time)
65710 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
65711 +#endif
65712 + return;
65713 +}
65714 +
65715 +EXPORT_SYMBOL(gr_log_timechange);
65716 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
65717 new file mode 100644
65718 index 0000000..ee57dcf
65719 --- /dev/null
65720 +++ b/grsecurity/grsec_tpe.c
65721 @@ -0,0 +1,73 @@
65722 +#include <linux/kernel.h>
65723 +#include <linux/sched.h>
65724 +#include <linux/file.h>
65725 +#include <linux/fs.h>
65726 +#include <linux/grinternal.h>
65727 +
65728 +extern int gr_acl_tpe_check(void);
65729 +
65730 +int
65731 +gr_tpe_allow(const struct file *file)
65732 +{
65733 +#ifdef CONFIG_GRKERNSEC
65734 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
65735 + const struct cred *cred = current_cred();
65736 + char *msg = NULL;
65737 + char *msg2 = NULL;
65738 +
65739 + // never restrict root
65740 + if (gr_is_global_root(cred->uid))
65741 + return 1;
65742 +
65743 + if (grsec_enable_tpe) {
65744 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65745 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
65746 + msg = "not being in trusted group";
65747 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
65748 + msg = "being in untrusted group";
65749 +#else
65750 + if (in_group_p(grsec_tpe_gid))
65751 + msg = "being in untrusted group";
65752 +#endif
65753 + }
65754 + if (!msg && gr_acl_tpe_check())
65755 + msg = "being in untrusted role";
65756 +
65757 + // not in any affected group/role
65758 + if (!msg)
65759 + goto next_check;
65760 +
65761 + if (gr_is_global_nonroot(inode->i_uid))
65762 + msg2 = "file in non-root-owned directory";
65763 + else if (inode->i_mode & S_IWOTH)
65764 + msg2 = "file in world-writable directory";
65765 + else if (inode->i_mode & S_IWGRP)
65766 + msg2 = "file in group-writable directory";
65767 +
65768 + if (msg && msg2) {
65769 + char fullmsg[70] = {0};
65770 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
65771 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
65772 + return 0;
65773 + }
65774 + msg = NULL;
65775 +next_check:
65776 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65777 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
65778 + return 1;
65779 +
65780 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
65781 + msg = "directory not owned by user";
65782 + else if (inode->i_mode & S_IWOTH)
65783 + msg = "file in world-writable directory";
65784 + else if (inode->i_mode & S_IWGRP)
65785 + msg = "file in group-writable directory";
65786 +
65787 + if (msg) {
65788 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
65789 + return 0;
65790 + }
65791 +#endif
65792 +#endif
65793 + return 1;
65794 +}
65795 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
65796 new file mode 100644
65797 index 0000000..9f7b1ac
65798 --- /dev/null
65799 +++ b/grsecurity/grsum.c
65800 @@ -0,0 +1,61 @@
65801 +#include <linux/err.h>
65802 +#include <linux/kernel.h>
65803 +#include <linux/sched.h>
65804 +#include <linux/mm.h>
65805 +#include <linux/scatterlist.h>
65806 +#include <linux/crypto.h>
65807 +#include <linux/gracl.h>
65808 +
65809 +
65810 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
65811 +#error "crypto and sha256 must be built into the kernel"
65812 +#endif
65813 +
65814 +int
65815 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
65816 +{
65817 + char *p;
65818 + struct crypto_hash *tfm;
65819 + struct hash_desc desc;
65820 + struct scatterlist sg;
65821 + unsigned char temp_sum[GR_SHA_LEN];
65822 + volatile int retval = 0;
65823 + volatile int dummy = 0;
65824 + unsigned int i;
65825 +
65826 + sg_init_table(&sg, 1);
65827 +
65828 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
65829 + if (IS_ERR(tfm)) {
65830 + /* should never happen, since sha256 should be built in */
65831 + return 1;
65832 + }
65833 +
65834 + desc.tfm = tfm;
65835 + desc.flags = 0;
65836 +
65837 + crypto_hash_init(&desc);
65838 +
65839 + p = salt;
65840 + sg_set_buf(&sg, p, GR_SALT_LEN);
65841 + crypto_hash_update(&desc, &sg, sg.length);
65842 +
65843 + p = entry->pw;
65844 + sg_set_buf(&sg, p, strlen(p));
65845 +
65846 + crypto_hash_update(&desc, &sg, sg.length);
65847 +
65848 + crypto_hash_final(&desc, temp_sum);
65849 +
65850 + memset(entry->pw, 0, GR_PW_LEN);
65851 +
65852 + for (i = 0; i < GR_SHA_LEN; i++)
65853 + if (sum[i] != temp_sum[i])
65854 + retval = 1;
65855 + else
65856 + dummy = 1; // waste a cycle
65857 +
65858 + crypto_free_hash(tfm);
65859 +
65860 + return retval;
65861 +}
65862 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
65863 index 77ff547..181834f 100644
65864 --- a/include/asm-generic/4level-fixup.h
65865 +++ b/include/asm-generic/4level-fixup.h
65866 @@ -13,8 +13,10 @@
65867 #define pmd_alloc(mm, pud, address) \
65868 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
65869 NULL: pmd_offset(pud, address))
65870 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
65871
65872 #define pud_alloc(mm, pgd, address) (pgd)
65873 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
65874 #define pud_offset(pgd, start) (pgd)
65875 #define pud_none(pud) 0
65876 #define pud_bad(pud) 0
65877 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
65878 index b7babf0..04ad282 100644
65879 --- a/include/asm-generic/atomic-long.h
65880 +++ b/include/asm-generic/atomic-long.h
65881 @@ -22,6 +22,12 @@
65882
65883 typedef atomic64_t atomic_long_t;
65884
65885 +#ifdef CONFIG_PAX_REFCOUNT
65886 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
65887 +#else
65888 +typedef atomic64_t atomic_long_unchecked_t;
65889 +#endif
65890 +
65891 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
65892
65893 static inline long atomic_long_read(atomic_long_t *l)
65894 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
65895 return (long)atomic64_read(v);
65896 }
65897
65898 +#ifdef CONFIG_PAX_REFCOUNT
65899 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
65900 +{
65901 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
65902 +
65903 + return (long)atomic64_read_unchecked(v);
65904 +}
65905 +#endif
65906 +
65907 static inline void atomic_long_set(atomic_long_t *l, long i)
65908 {
65909 atomic64_t *v = (atomic64_t *)l;
65910 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
65911 atomic64_set(v, i);
65912 }
65913
65914 +#ifdef CONFIG_PAX_REFCOUNT
65915 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
65916 +{
65917 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
65918 +
65919 + atomic64_set_unchecked(v, i);
65920 +}
65921 +#endif
65922 +
65923 static inline void atomic_long_inc(atomic_long_t *l)
65924 {
65925 atomic64_t *v = (atomic64_t *)l;
65926 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
65927 atomic64_inc(v);
65928 }
65929
65930 +#ifdef CONFIG_PAX_REFCOUNT
65931 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
65932 +{
65933 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
65934 +
65935 + atomic64_inc_unchecked(v);
65936 +}
65937 +#endif
65938 +
65939 static inline void atomic_long_dec(atomic_long_t *l)
65940 {
65941 atomic64_t *v = (atomic64_t *)l;
65942 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
65943 atomic64_dec(v);
65944 }
65945
65946 +#ifdef CONFIG_PAX_REFCOUNT
65947 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
65948 +{
65949 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
65950 +
65951 + atomic64_dec_unchecked(v);
65952 +}
65953 +#endif
65954 +
65955 static inline void atomic_long_add(long i, atomic_long_t *l)
65956 {
65957 atomic64_t *v = (atomic64_t *)l;
65958 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
65959 atomic64_add(i, v);
65960 }
65961
65962 +#ifdef CONFIG_PAX_REFCOUNT
65963 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
65964 +{
65965 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
65966 +
65967 + atomic64_add_unchecked(i, v);
65968 +}
65969 +#endif
65970 +
65971 static inline void atomic_long_sub(long i, atomic_long_t *l)
65972 {
65973 atomic64_t *v = (atomic64_t *)l;
65974 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
65975 atomic64_sub(i, v);
65976 }
65977
65978 +#ifdef CONFIG_PAX_REFCOUNT
65979 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
65980 +{
65981 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
65982 +
65983 + atomic64_sub_unchecked(i, v);
65984 +}
65985 +#endif
65986 +
65987 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
65988 {
65989 atomic64_t *v = (atomic64_t *)l;
65990 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
65991 return (long)atomic64_add_return(i, v);
65992 }
65993
65994 +#ifdef CONFIG_PAX_REFCOUNT
65995 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
65996 +{
65997 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
65998 +
65999 + return (long)atomic64_add_return_unchecked(i, v);
66000 +}
66001 +#endif
66002 +
66003 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
66004 {
66005 atomic64_t *v = (atomic64_t *)l;
66006 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
66007 return (long)atomic64_inc_return(v);
66008 }
66009
66010 +#ifdef CONFIG_PAX_REFCOUNT
66011 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
66012 +{
66013 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66014 +
66015 + return (long)atomic64_inc_return_unchecked(v);
66016 +}
66017 +#endif
66018 +
66019 static inline long atomic_long_dec_return(atomic_long_t *l)
66020 {
66021 atomic64_t *v = (atomic64_t *)l;
66022 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
66023
66024 typedef atomic_t atomic_long_t;
66025
66026 +#ifdef CONFIG_PAX_REFCOUNT
66027 +typedef atomic_unchecked_t atomic_long_unchecked_t;
66028 +#else
66029 +typedef atomic_t atomic_long_unchecked_t;
66030 +#endif
66031 +
66032 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
66033 static inline long atomic_long_read(atomic_long_t *l)
66034 {
66035 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66036 return (long)atomic_read(v);
66037 }
66038
66039 +#ifdef CONFIG_PAX_REFCOUNT
66040 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66041 +{
66042 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66043 +
66044 + return (long)atomic_read_unchecked(v);
66045 +}
66046 +#endif
66047 +
66048 static inline void atomic_long_set(atomic_long_t *l, long i)
66049 {
66050 atomic_t *v = (atomic_t *)l;
66051 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66052 atomic_set(v, i);
66053 }
66054
66055 +#ifdef CONFIG_PAX_REFCOUNT
66056 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66057 +{
66058 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66059 +
66060 + atomic_set_unchecked(v, i);
66061 +}
66062 +#endif
66063 +
66064 static inline void atomic_long_inc(atomic_long_t *l)
66065 {
66066 atomic_t *v = (atomic_t *)l;
66067 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
66068 atomic_inc(v);
66069 }
66070
66071 +#ifdef CONFIG_PAX_REFCOUNT
66072 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
66073 +{
66074 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66075 +
66076 + atomic_inc_unchecked(v);
66077 +}
66078 +#endif
66079 +
66080 static inline void atomic_long_dec(atomic_long_t *l)
66081 {
66082 atomic_t *v = (atomic_t *)l;
66083 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
66084 atomic_dec(v);
66085 }
66086
66087 +#ifdef CONFIG_PAX_REFCOUNT
66088 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
66089 +{
66090 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66091 +
66092 + atomic_dec_unchecked(v);
66093 +}
66094 +#endif
66095 +
66096 static inline void atomic_long_add(long i, atomic_long_t *l)
66097 {
66098 atomic_t *v = (atomic_t *)l;
66099 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
66100 atomic_add(i, v);
66101 }
66102
66103 +#ifdef CONFIG_PAX_REFCOUNT
66104 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
66105 +{
66106 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66107 +
66108 + atomic_add_unchecked(i, v);
66109 +}
66110 +#endif
66111 +
66112 static inline void atomic_long_sub(long i, atomic_long_t *l)
66113 {
66114 atomic_t *v = (atomic_t *)l;
66115 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66116 atomic_sub(i, v);
66117 }
66118
66119 +#ifdef CONFIG_PAX_REFCOUNT
66120 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
66121 +{
66122 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66123 +
66124 + atomic_sub_unchecked(i, v);
66125 +}
66126 +#endif
66127 +
66128 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
66129 {
66130 atomic_t *v = (atomic_t *)l;
66131 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
66132 return (long)atomic_add_return(i, v);
66133 }
66134
66135 +#ifdef CONFIG_PAX_REFCOUNT
66136 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
66137 +{
66138 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66139 +
66140 + return (long)atomic_add_return_unchecked(i, v);
66141 +}
66142 +
66143 +#endif
66144 +
66145 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
66146 {
66147 atomic_t *v = (atomic_t *)l;
66148 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
66149 return (long)atomic_inc_return(v);
66150 }
66151
66152 +#ifdef CONFIG_PAX_REFCOUNT
66153 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
66154 +{
66155 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66156 +
66157 + return (long)atomic_inc_return_unchecked(v);
66158 +}
66159 +#endif
66160 +
66161 static inline long atomic_long_dec_return(atomic_long_t *l)
66162 {
66163 atomic_t *v = (atomic_t *)l;
66164 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
66165
66166 #endif /* BITS_PER_LONG == 64 */
66167
66168 +#ifdef CONFIG_PAX_REFCOUNT
66169 +static inline void pax_refcount_needs_these_functions(void)
66170 +{
66171 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
66172 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
66173 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
66174 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
66175 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
66176 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
66177 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
66178 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
66179 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
66180 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
66181 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
66182 +#ifdef CONFIG_X86
66183 + atomic_clear_mask_unchecked(0, NULL);
66184 + atomic_set_mask_unchecked(0, NULL);
66185 +#endif
66186 +
66187 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
66188 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
66189 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
66190 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
66191 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
66192 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
66193 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
66194 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
66195 +}
66196 +#else
66197 +#define atomic_read_unchecked(v) atomic_read(v)
66198 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
66199 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
66200 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
66201 +#define atomic_inc_unchecked(v) atomic_inc(v)
66202 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
66203 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
66204 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
66205 +#define atomic_dec_unchecked(v) atomic_dec(v)
66206 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
66207 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
66208 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
66209 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
66210 +
66211 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
66212 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
66213 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
66214 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
66215 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
66216 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
66217 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
66218 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
66219 +#endif
66220 +
66221 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
66222 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
66223 index 33bd2de..f31bff97 100644
66224 --- a/include/asm-generic/atomic.h
66225 +++ b/include/asm-generic/atomic.h
66226 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
66227 * Atomically clears the bits set in @mask from @v
66228 */
66229 #ifndef atomic_clear_mask
66230 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
66231 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
66232 {
66233 unsigned long flags;
66234
66235 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
66236 index b18ce4f..2ee2843 100644
66237 --- a/include/asm-generic/atomic64.h
66238 +++ b/include/asm-generic/atomic64.h
66239 @@ -16,6 +16,8 @@ typedef struct {
66240 long long counter;
66241 } atomic64_t;
66242
66243 +typedef atomic64_t atomic64_unchecked_t;
66244 +
66245 #define ATOMIC64_INIT(i) { (i) }
66246
66247 extern long long atomic64_read(const atomic64_t *v);
66248 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
66249 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
66250 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
66251
66252 +#define atomic64_read_unchecked(v) atomic64_read(v)
66253 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
66254 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
66255 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
66256 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
66257 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
66258 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
66259 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
66260 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
66261 +
66262 #endif /* _ASM_GENERIC_ATOMIC64_H */
66263 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
66264 index 1bfcfe5..e04c5c9 100644
66265 --- a/include/asm-generic/cache.h
66266 +++ b/include/asm-generic/cache.h
66267 @@ -6,7 +6,7 @@
66268 * cache lines need to provide their own cache.h.
66269 */
66270
66271 -#define L1_CACHE_SHIFT 5
66272 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
66273 +#define L1_CACHE_SHIFT 5UL
66274 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
66275
66276 #endif /* __ASM_GENERIC_CACHE_H */
66277 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
66278 index 0d68a1e..b74a761 100644
66279 --- a/include/asm-generic/emergency-restart.h
66280 +++ b/include/asm-generic/emergency-restart.h
66281 @@ -1,7 +1,7 @@
66282 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
66283 #define _ASM_GENERIC_EMERGENCY_RESTART_H
66284
66285 -static inline void machine_emergency_restart(void)
66286 +static inline __noreturn void machine_emergency_restart(void)
66287 {
66288 machine_restart(NULL);
66289 }
66290 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
66291 index 90f99c7..00ce236 100644
66292 --- a/include/asm-generic/kmap_types.h
66293 +++ b/include/asm-generic/kmap_types.h
66294 @@ -2,9 +2,9 @@
66295 #define _ASM_GENERIC_KMAP_TYPES_H
66296
66297 #ifdef __WITH_KM_FENCE
66298 -# define KM_TYPE_NR 41
66299 +# define KM_TYPE_NR 42
66300 #else
66301 -# define KM_TYPE_NR 20
66302 +# define KM_TYPE_NR 21
66303 #endif
66304
66305 #endif
66306 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
66307 index 9ceb03b..62b0b8f 100644
66308 --- a/include/asm-generic/local.h
66309 +++ b/include/asm-generic/local.h
66310 @@ -23,24 +23,37 @@ typedef struct
66311 atomic_long_t a;
66312 } local_t;
66313
66314 +typedef struct {
66315 + atomic_long_unchecked_t a;
66316 +} local_unchecked_t;
66317 +
66318 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
66319
66320 #define local_read(l) atomic_long_read(&(l)->a)
66321 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
66322 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
66323 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
66324 #define local_inc(l) atomic_long_inc(&(l)->a)
66325 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
66326 #define local_dec(l) atomic_long_dec(&(l)->a)
66327 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
66328 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
66329 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
66330 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
66331 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
66332
66333 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
66334 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
66335 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
66336 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
66337 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
66338 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
66339 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
66340 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
66341 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
66342
66343 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
66344 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
66345 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
66346 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
66347 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
66348 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
66349 index 725612b..9cc513a 100644
66350 --- a/include/asm-generic/pgtable-nopmd.h
66351 +++ b/include/asm-generic/pgtable-nopmd.h
66352 @@ -1,14 +1,19 @@
66353 #ifndef _PGTABLE_NOPMD_H
66354 #define _PGTABLE_NOPMD_H
66355
66356 -#ifndef __ASSEMBLY__
66357 -
66358 #include <asm-generic/pgtable-nopud.h>
66359
66360 -struct mm_struct;
66361 -
66362 #define __PAGETABLE_PMD_FOLDED
66363
66364 +#define PMD_SHIFT PUD_SHIFT
66365 +#define PTRS_PER_PMD 1
66366 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
66367 +#define PMD_MASK (~(PMD_SIZE-1))
66368 +
66369 +#ifndef __ASSEMBLY__
66370 +
66371 +struct mm_struct;
66372 +
66373 /*
66374 * Having the pmd type consist of a pud gets the size right, and allows
66375 * us to conceptually access the pud entry that this pmd is folded into
66376 @@ -16,11 +21,6 @@ struct mm_struct;
66377 */
66378 typedef struct { pud_t pud; } pmd_t;
66379
66380 -#define PMD_SHIFT PUD_SHIFT
66381 -#define PTRS_PER_PMD 1
66382 -#define PMD_SIZE (1UL << PMD_SHIFT)
66383 -#define PMD_MASK (~(PMD_SIZE-1))
66384 -
66385 /*
66386 * The "pud_xxx()" functions here are trivial for a folded two-level
66387 * setup: the pmd is never bad, and a pmd always exists (as it's folded
66388 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
66389 index 810431d..0ec4804f 100644
66390 --- a/include/asm-generic/pgtable-nopud.h
66391 +++ b/include/asm-generic/pgtable-nopud.h
66392 @@ -1,10 +1,15 @@
66393 #ifndef _PGTABLE_NOPUD_H
66394 #define _PGTABLE_NOPUD_H
66395
66396 -#ifndef __ASSEMBLY__
66397 -
66398 #define __PAGETABLE_PUD_FOLDED
66399
66400 +#define PUD_SHIFT PGDIR_SHIFT
66401 +#define PTRS_PER_PUD 1
66402 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
66403 +#define PUD_MASK (~(PUD_SIZE-1))
66404 +
66405 +#ifndef __ASSEMBLY__
66406 +
66407 /*
66408 * Having the pud type consist of a pgd gets the size right, and allows
66409 * us to conceptually access the pgd entry that this pud is folded into
66410 @@ -12,11 +17,6 @@
66411 */
66412 typedef struct { pgd_t pgd; } pud_t;
66413
66414 -#define PUD_SHIFT PGDIR_SHIFT
66415 -#define PTRS_PER_PUD 1
66416 -#define PUD_SIZE (1UL << PUD_SHIFT)
66417 -#define PUD_MASK (~(PUD_SIZE-1))
66418 -
66419 /*
66420 * The "pgd_xxx()" functions here are trivial for a folded two-level
66421 * setup: the pud is never bad, and a pud always exists (as it's folded
66422 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
66423 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
66424
66425 #define pgd_populate(mm, pgd, pud) do { } while (0)
66426 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
66427 /*
66428 * (puds are folded into pgds so this doesn't get actually called,
66429 * but the define is needed for a generic inline function.)
66430 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
66431 index a59ff51..2594a70 100644
66432 --- a/include/asm-generic/pgtable.h
66433 +++ b/include/asm-generic/pgtable.h
66434 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
66435 }
66436 #endif /* CONFIG_NUMA_BALANCING */
66437
66438 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
66439 +static inline unsigned long pax_open_kernel(void) { return 0; }
66440 +#endif
66441 +
66442 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
66443 +static inline unsigned long pax_close_kernel(void) { return 0; }
66444 +#endif
66445 +
66446 #endif /* CONFIG_MMU */
66447
66448 #endif /* !__ASSEMBLY__ */
66449 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
66450 index afa12c7..99d4da0 100644
66451 --- a/include/asm-generic/vmlinux.lds.h
66452 +++ b/include/asm-generic/vmlinux.lds.h
66453 @@ -245,6 +245,7 @@
66454 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
66455 VMLINUX_SYMBOL(__start_rodata) = .; \
66456 *(.rodata) *(.rodata.*) \
66457 + *(.data..read_only) \
66458 *(__vermagic) /* Kernel version magic */ \
66459 . = ALIGN(8); \
66460 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
66461 @@ -755,17 +756,18 @@
66462 * section in the linker script will go there too. @phdr should have
66463 * a leading colon.
66464 *
66465 - * Note that this macros defines __per_cpu_load as an absolute symbol.
66466 + * Note that this macros defines per_cpu_load as an absolute symbol.
66467 * If there is no need to put the percpu section at a predetermined
66468 * address, use PERCPU_SECTION.
66469 */
66470 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
66471 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
66472 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
66473 + per_cpu_load = .; \
66474 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
66475 - LOAD_OFFSET) { \
66476 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
66477 PERCPU_INPUT(cacheline) \
66478 } phdr \
66479 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
66480 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
66481
66482 /**
66483 * PERCPU_SECTION - define output section for percpu area, simple version
66484 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
66485 index 418d270..bfd2794 100644
66486 --- a/include/crypto/algapi.h
66487 +++ b/include/crypto/algapi.h
66488 @@ -34,7 +34,7 @@ struct crypto_type {
66489 unsigned int maskclear;
66490 unsigned int maskset;
66491 unsigned int tfmsize;
66492 -};
66493 +} __do_const;
66494
66495 struct crypto_instance {
66496 struct crypto_alg alg;
66497 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
66498 index f1ce786..086a7a5 100644
66499 --- a/include/drm/drmP.h
66500 +++ b/include/drm/drmP.h
66501 @@ -72,6 +72,7 @@
66502 #include <linux/workqueue.h>
66503 #include <linux/poll.h>
66504 #include <asm/pgalloc.h>
66505 +#include <asm/local.h>
66506 #include <drm/drm.h>
66507 #include <drm/drm_sarea.h>
66508
66509 @@ -296,10 +297,12 @@ do { \
66510 * \param cmd command.
66511 * \param arg argument.
66512 */
66513 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
66514 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
66515 + struct drm_file *file_priv);
66516 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
66517 struct drm_file *file_priv);
66518
66519 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
66520 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
66521 unsigned long arg);
66522
66523 #define DRM_IOCTL_NR(n) _IOC_NR(n)
66524 @@ -314,9 +317,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
66525 struct drm_ioctl_desc {
66526 unsigned int cmd;
66527 int flags;
66528 - drm_ioctl_t *func;
66529 + drm_ioctl_t func;
66530 unsigned int cmd_drv;
66531 -};
66532 +} __do_const;
66533
66534 /**
66535 * Creates a driver or general drm_ioctl_desc array entry for the given
66536 @@ -1014,7 +1017,7 @@ struct drm_info_list {
66537 int (*show)(struct seq_file*, void*); /** show callback */
66538 u32 driver_features; /**< Required driver features for this entry */
66539 void *data;
66540 -};
66541 +} __do_const;
66542
66543 /**
66544 * debugfs node structure. This structure represents a debugfs file.
66545 @@ -1087,7 +1090,7 @@ struct drm_device {
66546
66547 /** \name Usage Counters */
66548 /*@{ */
66549 - int open_count; /**< Outstanding files open */
66550 + local_t open_count; /**< Outstanding files open */
66551 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
66552 atomic_t vma_count; /**< Outstanding vma areas open */
66553 int buf_use; /**< Buffers in use -- cannot alloc */
66554 @@ -1098,7 +1101,7 @@ struct drm_device {
66555 /*@{ */
66556 unsigned long counters;
66557 enum drm_stat_type types[15];
66558 - atomic_t counts[15];
66559 + atomic_unchecked_t counts[15];
66560 /*@} */
66561
66562 struct list_head filelist;
66563 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
66564 index f43d556..94d9343 100644
66565 --- a/include/drm/drm_crtc_helper.h
66566 +++ b/include/drm/drm_crtc_helper.h
66567 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
66568 struct drm_connector *connector);
66569 /* disable encoder when not in use - more explicit than dpms off */
66570 void (*disable)(struct drm_encoder *encoder);
66571 -};
66572 +} __no_const;
66573
66574 /**
66575 * drm_connector_helper_funcs - helper operations for connectors
66576 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
66577 index 72dcbe8..8db58d7 100644
66578 --- a/include/drm/ttm/ttm_memory.h
66579 +++ b/include/drm/ttm/ttm_memory.h
66580 @@ -48,7 +48,7 @@
66581
66582 struct ttm_mem_shrink {
66583 int (*do_shrink) (struct ttm_mem_shrink *);
66584 -};
66585 +} __no_const;
66586
66587 /**
66588 * struct ttm_mem_global - Global memory accounting structure.
66589 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
66590 index 4b840e8..155d235 100644
66591 --- a/include/keys/asymmetric-subtype.h
66592 +++ b/include/keys/asymmetric-subtype.h
66593 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
66594 /* Verify the signature on a key of this subtype (optional) */
66595 int (*verify_signature)(const struct key *key,
66596 const struct public_key_signature *sig);
66597 -};
66598 +} __do_const;
66599
66600 /**
66601 * asymmetric_key_subtype - Get the subtype from an asymmetric key
66602 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
66603 index c1da539..1dcec55 100644
66604 --- a/include/linux/atmdev.h
66605 +++ b/include/linux/atmdev.h
66606 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
66607 #endif
66608
66609 struct k_atm_aal_stats {
66610 -#define __HANDLE_ITEM(i) atomic_t i
66611 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
66612 __AAL_STAT_ITEMS
66613 #undef __HANDLE_ITEM
66614 };
66615 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
66616 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
66617 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
66618 struct module *owner;
66619 -};
66620 +} __do_const ;
66621
66622 struct atmphy_ops {
66623 int (*start)(struct atm_dev *dev);
66624 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
66625 index c3a0914..ec5d48a 100644
66626 --- a/include/linux/binfmts.h
66627 +++ b/include/linux/binfmts.h
66628 @@ -73,8 +73,9 @@ struct linux_binfmt {
66629 int (*load_binary)(struct linux_binprm *);
66630 int (*load_shlib)(struct file *);
66631 int (*core_dump)(struct coredump_params *cprm);
66632 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
66633 unsigned long min_coredump; /* minimal dump size */
66634 -};
66635 +} __do_const;
66636
66637 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
66638
66639 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
66640 index 33f358f..7f2c27f 100644
66641 --- a/include/linux/blkdev.h
66642 +++ b/include/linux/blkdev.h
66643 @@ -1499,7 +1499,7 @@ struct block_device_operations {
66644 /* this callback is with swap_lock and sometimes page table lock held */
66645 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
66646 struct module *owner;
66647 -};
66648 +} __do_const;
66649
66650 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
66651 unsigned long);
66652 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
66653 index 7c2e030..b72475d 100644
66654 --- a/include/linux/blktrace_api.h
66655 +++ b/include/linux/blktrace_api.h
66656 @@ -23,7 +23,7 @@ struct blk_trace {
66657 struct dentry *dir;
66658 struct dentry *dropped_file;
66659 struct dentry *msg_file;
66660 - atomic_t dropped;
66661 + atomic_unchecked_t dropped;
66662 };
66663
66664 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
66665 diff --git a/include/linux/cache.h b/include/linux/cache.h
66666 index 4c57065..4307975 100644
66667 --- a/include/linux/cache.h
66668 +++ b/include/linux/cache.h
66669 @@ -16,6 +16,10 @@
66670 #define __read_mostly
66671 #endif
66672
66673 +#ifndef __read_only
66674 +#define __read_only __read_mostly
66675 +#endif
66676 +
66677 #ifndef ____cacheline_aligned
66678 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
66679 #endif
66680 diff --git a/include/linux/capability.h b/include/linux/capability.h
66681 index d9a4f7f4..19f77d6 100644
66682 --- a/include/linux/capability.h
66683 +++ b/include/linux/capability.h
66684 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
66685 extern bool nsown_capable(int cap);
66686 extern bool inode_capable(const struct inode *inode, int cap);
66687 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
66688 +extern bool capable_nolog(int cap);
66689 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
66690 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
66691
66692 /* audit system wants to get cap info from files as well */
66693 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
66694
66695 +extern int is_privileged_binary(const struct dentry *dentry);
66696 +
66697 #endif /* !_LINUX_CAPABILITY_H */
66698 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
66699 index 8609d57..86e4d79 100644
66700 --- a/include/linux/cdrom.h
66701 +++ b/include/linux/cdrom.h
66702 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
66703
66704 /* driver specifications */
66705 const int capability; /* capability flags */
66706 - int n_minors; /* number of active minor devices */
66707 /* handle uniform packets for scsi type devices (scsi,atapi) */
66708 int (*generic_packet) (struct cdrom_device_info *,
66709 struct packet_command *);
66710 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
66711 index 42e55de..1cd0e66 100644
66712 --- a/include/linux/cleancache.h
66713 +++ b/include/linux/cleancache.h
66714 @@ -31,7 +31,7 @@ struct cleancache_ops {
66715 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
66716 void (*invalidate_inode)(int, struct cleancache_filekey);
66717 void (*invalidate_fs)(int);
66718 -};
66719 +} __no_const;
66720
66721 extern struct cleancache_ops
66722 cleancache_register_ops(struct cleancache_ops *ops);
66723 diff --git a/include/linux/compat.h b/include/linux/compat.h
66724 index 377cd8c..2479845 100644
66725 --- a/include/linux/compat.h
66726 +++ b/include/linux/compat.h
66727 @@ -332,14 +332,14 @@ long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
66728 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
66729 int version, void __user *uptr);
66730 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
66731 - void __user *uptr);
66732 + void __user *uptr) __intentional_overflow(0);
66733 #else
66734 long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
66735 long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
66736 compat_ssize_t msgsz, int msgflg);
66737 long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
66738 compat_ssize_t msgsz, long msgtyp, int msgflg);
66739 -long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
66740 +long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
66741 #endif
66742 long compat_sys_msgctl(int first, int second, void __user *uptr);
66743 long compat_sys_shmctl(int first, int second, void __user *uptr);
66744 @@ -442,7 +442,7 @@ extern int compat_ptrace_request(struct task_struct *child,
66745 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
66746 compat_ulong_t addr, compat_ulong_t data);
66747 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
66748 - compat_long_t addr, compat_long_t data);
66749 + compat_ulong_t addr, compat_ulong_t data);
66750
66751 /*
66752 * epoll (fs/eventpoll.c) compat bits follow ...
66753 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
66754 index 68b162d..660f5f0 100644
66755 --- a/include/linux/compiler-gcc4.h
66756 +++ b/include/linux/compiler-gcc4.h
66757 @@ -39,9 +39,29 @@
66758 # define __compiletime_warning(message) __attribute__((warning(message)))
66759 # define __compiletime_error(message) __attribute__((error(message)))
66760 #endif /* __CHECKER__ */
66761 +
66762 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
66763 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
66764 +#define __bos0(ptr) __bos((ptr), 0)
66765 +#define __bos1(ptr) __bos((ptr), 1)
66766 #endif /* GCC_VERSION >= 40300 */
66767
66768 #if GCC_VERSION >= 40500
66769 +
66770 +#ifdef CONSTIFY_PLUGIN
66771 +#define __no_const __attribute__((no_const))
66772 +#define __do_const __attribute__((do_const))
66773 +#endif
66774 +
66775 +#ifdef SIZE_OVERFLOW_PLUGIN
66776 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
66777 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
66778 +#endif
66779 +
66780 +#ifdef LATENT_ENTROPY_PLUGIN
66781 +#define __latent_entropy __attribute__((latent_entropy))
66782 +#endif
66783 +
66784 /*
66785 * Mark a position in code as unreachable. This can be used to
66786 * suppress control flow warnings after asm blocks that transfer
66787 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
66788 index 10b8f23..5e0b083 100644
66789 --- a/include/linux/compiler.h
66790 +++ b/include/linux/compiler.h
66791 @@ -5,11 +5,14 @@
66792
66793 #ifdef __CHECKER__
66794 # define __user __attribute__((noderef, address_space(1)))
66795 +# define __force_user __force __user
66796 # define __kernel __attribute__((address_space(0)))
66797 +# define __force_kernel __force __kernel
66798 # define __safe __attribute__((safe))
66799 # define __force __attribute__((force))
66800 # define __nocast __attribute__((nocast))
66801 # define __iomem __attribute__((noderef, address_space(2)))
66802 +# define __force_iomem __force __iomem
66803 # define __must_hold(x) __attribute__((context(x,1,1)))
66804 # define __acquires(x) __attribute__((context(x,0,1)))
66805 # define __releases(x) __attribute__((context(x,1,0)))
66806 @@ -17,20 +20,37 @@
66807 # define __release(x) __context__(x,-1)
66808 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
66809 # define __percpu __attribute__((noderef, address_space(3)))
66810 +# define __force_percpu __force __percpu
66811 #ifdef CONFIG_SPARSE_RCU_POINTER
66812 # define __rcu __attribute__((noderef, address_space(4)))
66813 +# define __force_rcu __force __rcu
66814 #else
66815 # define __rcu
66816 +# define __force_rcu
66817 #endif
66818 extern void __chk_user_ptr(const volatile void __user *);
66819 extern void __chk_io_ptr(const volatile void __iomem *);
66820 #else
66821 -# define __user
66822 -# define __kernel
66823 +# ifdef CHECKER_PLUGIN
66824 +//# define __user
66825 +//# define __force_user
66826 +//# define __kernel
66827 +//# define __force_kernel
66828 +# else
66829 +# ifdef STRUCTLEAK_PLUGIN
66830 +# define __user __attribute__((user))
66831 +# else
66832 +# define __user
66833 +# endif
66834 +# define __force_user
66835 +# define __kernel
66836 +# define __force_kernel
66837 +# endif
66838 # define __safe
66839 # define __force
66840 # define __nocast
66841 # define __iomem
66842 +# define __force_iomem
66843 # define __chk_user_ptr(x) (void)0
66844 # define __chk_io_ptr(x) (void)0
66845 # define __builtin_warning(x, y...) (1)
66846 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
66847 # define __release(x) (void)0
66848 # define __cond_lock(x,c) (c)
66849 # define __percpu
66850 +# define __force_percpu
66851 # define __rcu
66852 +# define __force_rcu
66853 #endif
66854
66855 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
66856 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
66857 # define __attribute_const__ /* unimplemented */
66858 #endif
66859
66860 +#ifndef __no_const
66861 +# define __no_const
66862 +#endif
66863 +
66864 +#ifndef __do_const
66865 +# define __do_const
66866 +#endif
66867 +
66868 +#ifndef __size_overflow
66869 +# define __size_overflow(...)
66870 +#endif
66871 +
66872 +#ifndef __intentional_overflow
66873 +# define __intentional_overflow(...)
66874 +#endif
66875 +
66876 +#ifndef __latent_entropy
66877 +# define __latent_entropy
66878 +#endif
66879 +
66880 /*
66881 * Tell gcc if a function is cold. The compiler will assume any path
66882 * directly leading to the call is unlikely.
66883 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
66884 #define __cold
66885 #endif
66886
66887 +#ifndef __alloc_size
66888 +#define __alloc_size(...)
66889 +#endif
66890 +
66891 +#ifndef __bos
66892 +#define __bos(ptr, arg)
66893 +#endif
66894 +
66895 +#ifndef __bos0
66896 +#define __bos0(ptr)
66897 +#endif
66898 +
66899 +#ifndef __bos1
66900 +#define __bos1(ptr)
66901 +#endif
66902 +
66903 /* Simple shorthand for a section definition */
66904 #ifndef __section
66905 # define __section(S) __attribute__ ((__section__(#S)))
66906 @@ -349,6 +407,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
66907 * use is to mediate communication between process-level code and irq/NMI
66908 * handlers, all running on the same CPU.
66909 */
66910 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
66911 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
66912 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
66913
66914 #endif /* __LINUX_COMPILER_H */
66915 diff --git a/include/linux/completion.h b/include/linux/completion.h
66916 index 33f0280..35c6568 100644
66917 --- a/include/linux/completion.h
66918 +++ b/include/linux/completion.h
66919 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
66920 extern void wait_for_completion(struct completion *);
66921 extern void wait_for_completion_io(struct completion *);
66922 extern int wait_for_completion_interruptible(struct completion *x);
66923 -extern int wait_for_completion_killable(struct completion *x);
66924 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
66925 extern unsigned long wait_for_completion_timeout(struct completion *x,
66926 unsigned long timeout);
66927 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
66928 unsigned long timeout);
66929 extern long wait_for_completion_interruptible_timeout(
66930 - struct completion *x, unsigned long timeout);
66931 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
66932 extern long wait_for_completion_killable_timeout(
66933 - struct completion *x, unsigned long timeout);
66934 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
66935 extern bool try_wait_for_completion(struct completion *x);
66936 extern bool completion_done(struct completion *x);
66937
66938 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
66939 index 34025df..d94bbbc 100644
66940 --- a/include/linux/configfs.h
66941 +++ b/include/linux/configfs.h
66942 @@ -125,7 +125,7 @@ struct configfs_attribute {
66943 const char *ca_name;
66944 struct module *ca_owner;
66945 umode_t ca_mode;
66946 -};
66947 +} __do_const;
66948
66949 /*
66950 * Users often need to create attribute structures for their configurable
66951 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
66952 index ce7a074..01ab8ac 100644
66953 --- a/include/linux/cpu.h
66954 +++ b/include/linux/cpu.h
66955 @@ -115,7 +115,7 @@ enum {
66956 /* Need to know about CPUs going up/down? */
66957 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
66958 #define cpu_notifier(fn, pri) { \
66959 - static struct notifier_block fn##_nb __cpuinitdata = \
66960 + static struct notifier_block fn##_nb = \
66961 { .notifier_call = fn, .priority = pri }; \
66962 register_cpu_notifier(&fn##_nb); \
66963 }
66964 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
66965 index a22944c..4e695fe 100644
66966 --- a/include/linux/cpufreq.h
66967 +++ b/include/linux/cpufreq.h
66968 @@ -252,7 +252,7 @@ struct cpufreq_driver {
66969 int (*suspend) (struct cpufreq_policy *policy);
66970 int (*resume) (struct cpufreq_policy *policy);
66971 struct freq_attr **attr;
66972 -};
66973 +} __do_const;
66974
66975 /* flags */
66976
66977 @@ -311,6 +311,7 @@ struct global_attr {
66978 ssize_t (*store)(struct kobject *a, struct attribute *b,
66979 const char *c, size_t count);
66980 };
66981 +typedef struct global_attr __no_const global_attr_no_const;
66982
66983 #define define_one_global_ro(_name) \
66984 static struct global_attr _name = \
66985 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
66986 index 480c14d..552896f 100644
66987 --- a/include/linux/cpuidle.h
66988 +++ b/include/linux/cpuidle.h
66989 @@ -52,7 +52,8 @@ struct cpuidle_state {
66990 int index);
66991
66992 int (*enter_dead) (struct cpuidle_device *dev, int index);
66993 -};
66994 +} __do_const;
66995 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
66996
66997 /* Idle State Flags */
66998 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
66999 @@ -194,7 +195,7 @@ struct cpuidle_governor {
67000 void (*reflect) (struct cpuidle_device *dev, int index);
67001
67002 struct module *owner;
67003 -};
67004 +} __do_const;
67005
67006 #ifdef CONFIG_CPU_IDLE
67007
67008 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
67009 index 0325602..5e9feff 100644
67010 --- a/include/linux/cpumask.h
67011 +++ b/include/linux/cpumask.h
67012 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
67013 }
67014
67015 /* Valid inputs for n are -1 and 0. */
67016 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67017 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
67018 {
67019 return n+1;
67020 }
67021
67022 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67023 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
67024 {
67025 return n+1;
67026 }
67027
67028 -static inline unsigned int cpumask_next_and(int n,
67029 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
67030 const struct cpumask *srcp,
67031 const struct cpumask *andp)
67032 {
67033 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
67034 *
67035 * Returns >= nr_cpu_ids if no further cpus set.
67036 */
67037 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67038 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
67039 {
67040 /* -1 is a legal arg here. */
67041 if (n != -1)
67042 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67043 *
67044 * Returns >= nr_cpu_ids if no further cpus unset.
67045 */
67046 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67047 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
67048 {
67049 /* -1 is a legal arg here. */
67050 if (n != -1)
67051 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67052 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
67053 }
67054
67055 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
67056 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
67057 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
67058
67059 /**
67060 diff --git a/include/linux/cred.h b/include/linux/cred.h
67061 index 04421e8..6bce4ef 100644
67062 --- a/include/linux/cred.h
67063 +++ b/include/linux/cred.h
67064 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
67065 static inline void validate_process_creds(void)
67066 {
67067 }
67068 +static inline void validate_task_creds(struct task_struct *task)
67069 +{
67070 +}
67071 #endif
67072
67073 /**
67074 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
67075 index b92eadf..b4ecdc1 100644
67076 --- a/include/linux/crypto.h
67077 +++ b/include/linux/crypto.h
67078 @@ -373,7 +373,7 @@ struct cipher_tfm {
67079 const u8 *key, unsigned int keylen);
67080 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
67081 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
67082 -};
67083 +} __no_const;
67084
67085 struct hash_tfm {
67086 int (*init)(struct hash_desc *desc);
67087 @@ -394,13 +394,13 @@ struct compress_tfm {
67088 int (*cot_decompress)(struct crypto_tfm *tfm,
67089 const u8 *src, unsigned int slen,
67090 u8 *dst, unsigned int *dlen);
67091 -};
67092 +} __no_const;
67093
67094 struct rng_tfm {
67095 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
67096 unsigned int dlen);
67097 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
67098 -};
67099 +} __no_const;
67100
67101 #define crt_ablkcipher crt_u.ablkcipher
67102 #define crt_aead crt_u.aead
67103 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
67104 index 8acfe31..6ffccd63 100644
67105 --- a/include/linux/ctype.h
67106 +++ b/include/linux/ctype.h
67107 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
67108 * Fast implementation of tolower() for internal usage. Do not use in your
67109 * code.
67110 */
67111 -static inline char _tolower(const char c)
67112 +static inline unsigned char _tolower(const unsigned char c)
67113 {
67114 return c | 0x20;
67115 }
67116 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
67117 index 7925bf0..d5143d2 100644
67118 --- a/include/linux/decompress/mm.h
67119 +++ b/include/linux/decompress/mm.h
67120 @@ -77,7 +77,7 @@ static void free(void *where)
67121 * warnings when not needed (indeed large_malloc / large_free are not
67122 * needed by inflate */
67123
67124 -#define malloc(a) kmalloc(a, GFP_KERNEL)
67125 +#define malloc(a) kmalloc((a), GFP_KERNEL)
67126 #define free(a) kfree(a)
67127
67128 #define large_malloc(a) vmalloc(a)
67129 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
67130 index fe8c447..bdc1f33 100644
67131 --- a/include/linux/devfreq.h
67132 +++ b/include/linux/devfreq.h
67133 @@ -114,7 +114,7 @@ struct devfreq_governor {
67134 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
67135 int (*event_handler)(struct devfreq *devfreq,
67136 unsigned int event, void *data);
67137 -};
67138 +} __do_const;
67139
67140 /**
67141 * struct devfreq - Device devfreq structure
67142 diff --git a/include/linux/device.h b/include/linux/device.h
67143 index 9d6464e..8a5cc92 100644
67144 --- a/include/linux/device.h
67145 +++ b/include/linux/device.h
67146 @@ -295,7 +295,7 @@ struct subsys_interface {
67147 struct list_head node;
67148 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
67149 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
67150 -};
67151 +} __do_const;
67152
67153 int subsys_interface_register(struct subsys_interface *sif);
67154 void subsys_interface_unregister(struct subsys_interface *sif);
67155 @@ -475,7 +475,7 @@ struct device_type {
67156 void (*release)(struct device *dev);
67157
67158 const struct dev_pm_ops *pm;
67159 -};
67160 +} __do_const;
67161
67162 /* interface for exporting device attributes */
67163 struct device_attribute {
67164 @@ -485,11 +485,12 @@ struct device_attribute {
67165 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
67166 const char *buf, size_t count);
67167 };
67168 +typedef struct device_attribute __no_const device_attribute_no_const;
67169
67170 struct dev_ext_attribute {
67171 struct device_attribute attr;
67172 void *var;
67173 -};
67174 +} __do_const;
67175
67176 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
67177 char *buf);
67178 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
67179 index 94af418..b1ca7a2 100644
67180 --- a/include/linux/dma-mapping.h
67181 +++ b/include/linux/dma-mapping.h
67182 @@ -54,7 +54,7 @@ struct dma_map_ops {
67183 u64 (*get_required_mask)(struct device *dev);
67184 #endif
67185 int is_phys;
67186 -};
67187 +} __do_const;
67188
67189 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
67190
67191 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
67192 index 91ac8da..a841318 100644
67193 --- a/include/linux/dmaengine.h
67194 +++ b/include/linux/dmaengine.h
67195 @@ -1034,9 +1034,9 @@ struct dma_pinned_list {
67196 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
67197 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
67198
67199 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
67200 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
67201 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
67202 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
67203 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
67204 struct dma_pinned_list *pinned_list, struct page *page,
67205 unsigned int offset, size_t len);
67206
67207 diff --git a/include/linux/efi.h b/include/linux/efi.h
67208 index 3d7df3d..301f024 100644
67209 --- a/include/linux/efi.h
67210 +++ b/include/linux/efi.h
67211 @@ -740,6 +740,7 @@ struct efivar_operations {
67212 efi_set_variable_t *set_variable;
67213 efi_query_variable_store_t *query_variable_store;
67214 };
67215 +typedef struct efivar_operations __no_const efivar_operations_no_const;
67216
67217 struct efivars {
67218 /*
67219 diff --git a/include/linux/elf.h b/include/linux/elf.h
67220 index 40a3c0e..4c45a38 100644
67221 --- a/include/linux/elf.h
67222 +++ b/include/linux/elf.h
67223 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
67224 #define elf_note elf32_note
67225 #define elf_addr_t Elf32_Off
67226 #define Elf_Half Elf32_Half
67227 +#define elf_dyn Elf32_Dyn
67228
67229 #else
67230
67231 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
67232 #define elf_note elf64_note
67233 #define elf_addr_t Elf64_Off
67234 #define Elf_Half Elf64_Half
67235 +#define elf_dyn Elf64_Dyn
67236
67237 #endif
67238
67239 diff --git a/include/linux/err.h b/include/linux/err.h
67240 index f2edce2..cc2082c 100644
67241 --- a/include/linux/err.h
67242 +++ b/include/linux/err.h
67243 @@ -19,12 +19,12 @@
67244
67245 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
67246
67247 -static inline void * __must_check ERR_PTR(long error)
67248 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
67249 {
67250 return (void *) error;
67251 }
67252
67253 -static inline long __must_check PTR_ERR(const void *ptr)
67254 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
67255 {
67256 return (long) ptr;
67257 }
67258 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
67259 index fcb51c8..bdafcf6 100644
67260 --- a/include/linux/extcon.h
67261 +++ b/include/linux/extcon.h
67262 @@ -134,7 +134,7 @@ struct extcon_dev {
67263 /* /sys/class/extcon/.../mutually_exclusive/... */
67264 struct attribute_group attr_g_muex;
67265 struct attribute **attrs_muex;
67266 - struct device_attribute *d_attrs_muex;
67267 + device_attribute_no_const *d_attrs_muex;
67268 };
67269
67270 /**
67271 diff --git a/include/linux/fb.h b/include/linux/fb.h
67272 index 58b9860..58e5516 100644
67273 --- a/include/linux/fb.h
67274 +++ b/include/linux/fb.h
67275 @@ -304,7 +304,7 @@ struct fb_ops {
67276 /* called at KDB enter and leave time to prepare the console */
67277 int (*fb_debug_enter)(struct fb_info *info);
67278 int (*fb_debug_leave)(struct fb_info *info);
67279 -};
67280 +} __do_const;
67281
67282 #ifdef CONFIG_FB_TILEBLITTING
67283 #define FB_TILE_CURSOR_NONE 0
67284 diff --git a/include/linux/filter.h b/include/linux/filter.h
67285 index c45eabc..baa0be5 100644
67286 --- a/include/linux/filter.h
67287 +++ b/include/linux/filter.h
67288 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
67289
67290 struct sk_buff;
67291 struct sock;
67292 +struct bpf_jit_work;
67293
67294 struct sk_filter
67295 {
67296 @@ -27,6 +28,9 @@ struct sk_filter
67297 unsigned int len; /* Number of filter blocks */
67298 unsigned int (*bpf_func)(const struct sk_buff *skb,
67299 const struct sock_filter *filter);
67300 +#ifdef CONFIG_BPF_JIT
67301 + struct bpf_jit_work *work;
67302 +#endif
67303 struct rcu_head rcu;
67304 struct sock_filter insns[0];
67305 };
67306 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
67307 index 3044254..9767f41 100644
67308 --- a/include/linux/frontswap.h
67309 +++ b/include/linux/frontswap.h
67310 @@ -11,7 +11,7 @@ struct frontswap_ops {
67311 int (*load)(unsigned, pgoff_t, struct page *);
67312 void (*invalidate_page)(unsigned, pgoff_t);
67313 void (*invalidate_area)(unsigned);
67314 -};
67315 +} __no_const;
67316
67317 extern bool frontswap_enabled;
67318 extern struct frontswap_ops
67319 diff --git a/include/linux/fs.h b/include/linux/fs.h
67320 index 2c28271..8d3d74c 100644
67321 --- a/include/linux/fs.h
67322 +++ b/include/linux/fs.h
67323 @@ -1541,7 +1541,8 @@ struct file_operations {
67324 long (*fallocate)(struct file *file, int mode, loff_t offset,
67325 loff_t len);
67326 int (*show_fdinfo)(struct seq_file *m, struct file *f);
67327 -};
67328 +} __do_const;
67329 +typedef struct file_operations __no_const file_operations_no_const;
67330
67331 struct inode_operations {
67332 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
67333 @@ -2672,4 +2673,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
67334 inode->i_flags |= S_NOSEC;
67335 }
67336
67337 +static inline bool is_sidechannel_device(const struct inode *inode)
67338 +{
67339 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
67340 + umode_t mode = inode->i_mode;
67341 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
67342 +#else
67343 + return false;
67344 +#endif
67345 +}
67346 +
67347 #endif /* _LINUX_FS_H */
67348 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
67349 index 2b93a9a..855d94a 100644
67350 --- a/include/linux/fs_struct.h
67351 +++ b/include/linux/fs_struct.h
67352 @@ -6,7 +6,7 @@
67353 #include <linux/seqlock.h>
67354
67355 struct fs_struct {
67356 - int users;
67357 + atomic_t users;
67358 spinlock_t lock;
67359 seqcount_t seq;
67360 int umask;
67361 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
67362 index 5dfa0aa..6acf322 100644
67363 --- a/include/linux/fscache-cache.h
67364 +++ b/include/linux/fscache-cache.h
67365 @@ -112,7 +112,7 @@ struct fscache_operation {
67366 fscache_operation_release_t release;
67367 };
67368
67369 -extern atomic_t fscache_op_debug_id;
67370 +extern atomic_unchecked_t fscache_op_debug_id;
67371 extern void fscache_op_work_func(struct work_struct *work);
67372
67373 extern void fscache_enqueue_operation(struct fscache_operation *);
67374 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
67375 INIT_WORK(&op->work, fscache_op_work_func);
67376 atomic_set(&op->usage, 1);
67377 op->state = FSCACHE_OP_ST_INITIALISED;
67378 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
67379 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
67380 op->processor = processor;
67381 op->release = release;
67382 INIT_LIST_HEAD(&op->pend_link);
67383 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
67384 index 7a08623..4c07b0f 100644
67385 --- a/include/linux/fscache.h
67386 +++ b/include/linux/fscache.h
67387 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
67388 * - this is mandatory for any object that may have data
67389 */
67390 void (*now_uncached)(void *cookie_netfs_data);
67391 -};
67392 +} __do_const;
67393
67394 /*
67395 * fscache cached network filesystem type
67396 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
67397 index a78680a..87bd73e 100644
67398 --- a/include/linux/fsnotify.h
67399 +++ b/include/linux/fsnotify.h
67400 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
67401 struct inode *inode = path->dentry->d_inode;
67402 __u32 mask = FS_ACCESS;
67403
67404 + if (is_sidechannel_device(inode))
67405 + return;
67406 +
67407 if (S_ISDIR(inode->i_mode))
67408 mask |= FS_ISDIR;
67409
67410 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
67411 struct inode *inode = path->dentry->d_inode;
67412 __u32 mask = FS_MODIFY;
67413
67414 + if (is_sidechannel_device(inode))
67415 + return;
67416 +
67417 if (S_ISDIR(inode->i_mode))
67418 mask |= FS_ISDIR;
67419
67420 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
67421 */
67422 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
67423 {
67424 - return kstrdup(name, GFP_KERNEL);
67425 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
67426 }
67427
67428 /*
67429 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
67430 index 13a54d0..c6ce2a7 100644
67431 --- a/include/linux/ftrace_event.h
67432 +++ b/include/linux/ftrace_event.h
67433 @@ -274,7 +274,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
67434 extern int trace_add_event_call(struct ftrace_event_call *call);
67435 extern void trace_remove_event_call(struct ftrace_event_call *call);
67436
67437 -#define is_signed_type(type) (((type)(-1)) < (type)0)
67438 +#define is_signed_type(type) (((type)(-1)) < (type)1)
67439
67440 int trace_set_clr_event(const char *system, const char *event, int set);
67441
67442 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
67443 index 9f3c275..911b591 100644
67444 --- a/include/linux/genhd.h
67445 +++ b/include/linux/genhd.h
67446 @@ -194,7 +194,7 @@ struct gendisk {
67447 struct kobject *slave_dir;
67448
67449 struct timer_rand_state *random;
67450 - atomic_t sync_io; /* RAID */
67451 + atomic_unchecked_t sync_io; /* RAID */
67452 struct disk_events *ev;
67453 #ifdef CONFIG_BLK_DEV_INTEGRITY
67454 struct blk_integrity *integrity;
67455 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
67456 index 023bc34..b02b46a 100644
67457 --- a/include/linux/genl_magic_func.h
67458 +++ b/include/linux/genl_magic_func.h
67459 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
67460 },
67461
67462 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
67463 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
67464 +static struct genl_ops ZZZ_genl_ops[] = {
67465 #include GENL_MAGIC_INCLUDE_FILE
67466 };
67467
67468 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
67469 index 0f615eb..5c3832f 100644
67470 --- a/include/linux/gfp.h
67471 +++ b/include/linux/gfp.h
67472 @@ -35,6 +35,13 @@ struct vm_area_struct;
67473 #define ___GFP_NO_KSWAPD 0x400000u
67474 #define ___GFP_OTHER_NODE 0x800000u
67475 #define ___GFP_WRITE 0x1000000u
67476 +
67477 +#ifdef CONFIG_PAX_USERCOPY_SLABS
67478 +#define ___GFP_USERCOPY 0x2000000u
67479 +#else
67480 +#define ___GFP_USERCOPY 0
67481 +#endif
67482 +
67483 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
67484
67485 /*
67486 @@ -92,6 +99,7 @@ struct vm_area_struct;
67487 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
67488 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
67489 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
67490 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
67491
67492 /*
67493 * This may seem redundant, but it's a way of annotating false positives vs.
67494 @@ -99,7 +107,7 @@ struct vm_area_struct;
67495 */
67496 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
67497
67498 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
67499 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
67500 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
67501
67502 /* This equals 0, but use constants in case they ever change */
67503 @@ -153,6 +161,8 @@ struct vm_area_struct;
67504 /* 4GB DMA on some platforms */
67505 #define GFP_DMA32 __GFP_DMA32
67506
67507 +#define GFP_USERCOPY __GFP_USERCOPY
67508 +
67509 /* Convert GFP flags to their corresponding migrate type */
67510 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
67511 {
67512 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
67513 new file mode 100644
67514 index 0000000..ebe6d72
67515 --- /dev/null
67516 +++ b/include/linux/gracl.h
67517 @@ -0,0 +1,319 @@
67518 +#ifndef GR_ACL_H
67519 +#define GR_ACL_H
67520 +
67521 +#include <linux/grdefs.h>
67522 +#include <linux/resource.h>
67523 +#include <linux/capability.h>
67524 +#include <linux/dcache.h>
67525 +#include <asm/resource.h>
67526 +
67527 +/* Major status information */
67528 +
67529 +#define GR_VERSION "grsecurity 2.9.1"
67530 +#define GRSECURITY_VERSION 0x2901
67531 +
67532 +enum {
67533 + GR_SHUTDOWN = 0,
67534 + GR_ENABLE = 1,
67535 + GR_SPROLE = 2,
67536 + GR_RELOAD = 3,
67537 + GR_SEGVMOD = 4,
67538 + GR_STATUS = 5,
67539 + GR_UNSPROLE = 6,
67540 + GR_PASSSET = 7,
67541 + GR_SPROLEPAM = 8,
67542 +};
67543 +
67544 +/* Password setup definitions
67545 + * kernel/grhash.c */
67546 +enum {
67547 + GR_PW_LEN = 128,
67548 + GR_SALT_LEN = 16,
67549 + GR_SHA_LEN = 32,
67550 +};
67551 +
67552 +enum {
67553 + GR_SPROLE_LEN = 64,
67554 +};
67555 +
67556 +enum {
67557 + GR_NO_GLOB = 0,
67558 + GR_REG_GLOB,
67559 + GR_CREATE_GLOB
67560 +};
67561 +
67562 +#define GR_NLIMITS 32
67563 +
67564 +/* Begin Data Structures */
67565 +
67566 +struct sprole_pw {
67567 + unsigned char *rolename;
67568 + unsigned char salt[GR_SALT_LEN];
67569 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
67570 +};
67571 +
67572 +struct name_entry {
67573 + __u32 key;
67574 + ino_t inode;
67575 + dev_t device;
67576 + char *name;
67577 + __u16 len;
67578 + __u8 deleted;
67579 + struct name_entry *prev;
67580 + struct name_entry *next;
67581 +};
67582 +
67583 +struct inodev_entry {
67584 + struct name_entry *nentry;
67585 + struct inodev_entry *prev;
67586 + struct inodev_entry *next;
67587 +};
67588 +
67589 +struct acl_role_db {
67590 + struct acl_role_label **r_hash;
67591 + __u32 r_size;
67592 +};
67593 +
67594 +struct inodev_db {
67595 + struct inodev_entry **i_hash;
67596 + __u32 i_size;
67597 +};
67598 +
67599 +struct name_db {
67600 + struct name_entry **n_hash;
67601 + __u32 n_size;
67602 +};
67603 +
67604 +struct crash_uid {
67605 + uid_t uid;
67606 + unsigned long expires;
67607 +};
67608 +
67609 +struct gr_hash_struct {
67610 + void **table;
67611 + void **nametable;
67612 + void *first;
67613 + __u32 table_size;
67614 + __u32 used_size;
67615 + int type;
67616 +};
67617 +
67618 +/* Userspace Grsecurity ACL data structures */
67619 +
67620 +struct acl_subject_label {
67621 + char *filename;
67622 + ino_t inode;
67623 + dev_t device;
67624 + __u32 mode;
67625 + kernel_cap_t cap_mask;
67626 + kernel_cap_t cap_lower;
67627 + kernel_cap_t cap_invert_audit;
67628 +
67629 + struct rlimit res[GR_NLIMITS];
67630 + __u32 resmask;
67631 +
67632 + __u8 user_trans_type;
67633 + __u8 group_trans_type;
67634 + uid_t *user_transitions;
67635 + gid_t *group_transitions;
67636 + __u16 user_trans_num;
67637 + __u16 group_trans_num;
67638 +
67639 + __u32 sock_families[2];
67640 + __u32 ip_proto[8];
67641 + __u32 ip_type;
67642 + struct acl_ip_label **ips;
67643 + __u32 ip_num;
67644 + __u32 inaddr_any_override;
67645 +
67646 + __u32 crashes;
67647 + unsigned long expires;
67648 +
67649 + struct acl_subject_label *parent_subject;
67650 + struct gr_hash_struct *hash;
67651 + struct acl_subject_label *prev;
67652 + struct acl_subject_label *next;
67653 +
67654 + struct acl_object_label **obj_hash;
67655 + __u32 obj_hash_size;
67656 + __u16 pax_flags;
67657 +};
67658 +
67659 +struct role_allowed_ip {
67660 + __u32 addr;
67661 + __u32 netmask;
67662 +
67663 + struct role_allowed_ip *prev;
67664 + struct role_allowed_ip *next;
67665 +};
67666 +
67667 +struct role_transition {
67668 + char *rolename;
67669 +
67670 + struct role_transition *prev;
67671 + struct role_transition *next;
67672 +};
67673 +
67674 +struct acl_role_label {
67675 + char *rolename;
67676 + uid_t uidgid;
67677 + __u16 roletype;
67678 +
67679 + __u16 auth_attempts;
67680 + unsigned long expires;
67681 +
67682 + struct acl_subject_label *root_label;
67683 + struct gr_hash_struct *hash;
67684 +
67685 + struct acl_role_label *prev;
67686 + struct acl_role_label *next;
67687 +
67688 + struct role_transition *transitions;
67689 + struct role_allowed_ip *allowed_ips;
67690 + uid_t *domain_children;
67691 + __u16 domain_child_num;
67692 +
67693 + umode_t umask;
67694 +
67695 + struct acl_subject_label **subj_hash;
67696 + __u32 subj_hash_size;
67697 +};
67698 +
67699 +struct user_acl_role_db {
67700 + struct acl_role_label **r_table;
67701 + __u32 num_pointers; /* Number of allocations to track */
67702 + __u32 num_roles; /* Number of roles */
67703 + __u32 num_domain_children; /* Number of domain children */
67704 + __u32 num_subjects; /* Number of subjects */
67705 + __u32 num_objects; /* Number of objects */
67706 +};
67707 +
67708 +struct acl_object_label {
67709 + char *filename;
67710 + ino_t inode;
67711 + dev_t device;
67712 + __u32 mode;
67713 +
67714 + struct acl_subject_label *nested;
67715 + struct acl_object_label *globbed;
67716 +
67717 + /* next two structures not used */
67718 +
67719 + struct acl_object_label *prev;
67720 + struct acl_object_label *next;
67721 +};
67722 +
67723 +struct acl_ip_label {
67724 + char *iface;
67725 + __u32 addr;
67726 + __u32 netmask;
67727 + __u16 low, high;
67728 + __u8 mode;
67729 + __u32 type;
67730 + __u32 proto[8];
67731 +
67732 + /* next two structures not used */
67733 +
67734 + struct acl_ip_label *prev;
67735 + struct acl_ip_label *next;
67736 +};
67737 +
67738 +struct gr_arg {
67739 + struct user_acl_role_db role_db;
67740 + unsigned char pw[GR_PW_LEN];
67741 + unsigned char salt[GR_SALT_LEN];
67742 + unsigned char sum[GR_SHA_LEN];
67743 + unsigned char sp_role[GR_SPROLE_LEN];
67744 + struct sprole_pw *sprole_pws;
67745 + dev_t segv_device;
67746 + ino_t segv_inode;
67747 + uid_t segv_uid;
67748 + __u16 num_sprole_pws;
67749 + __u16 mode;
67750 +};
67751 +
67752 +struct gr_arg_wrapper {
67753 + struct gr_arg *arg;
67754 + __u32 version;
67755 + __u32 size;
67756 +};
67757 +
67758 +struct subject_map {
67759 + struct acl_subject_label *user;
67760 + struct acl_subject_label *kernel;
67761 + struct subject_map *prev;
67762 + struct subject_map *next;
67763 +};
67764 +
67765 +struct acl_subj_map_db {
67766 + struct subject_map **s_hash;
67767 + __u32 s_size;
67768 +};
67769 +
67770 +/* End Data Structures Section */
67771 +
67772 +/* Hash functions generated by empirical testing by Brad Spengler
67773 + Makes good use of the low bits of the inode. Generally 0-1 times
67774 + in loop for successful match. 0-3 for unsuccessful match.
67775 + Shift/add algorithm with modulus of table size and an XOR*/
67776 +
67777 +static __inline__ unsigned int
67778 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
67779 +{
67780 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
67781 +}
67782 +
67783 + static __inline__ unsigned int
67784 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
67785 +{
67786 + return ((const unsigned long)userp % sz);
67787 +}
67788 +
67789 +static __inline__ unsigned int
67790 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
67791 +{
67792 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
67793 +}
67794 +
67795 +static __inline__ unsigned int
67796 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
67797 +{
67798 + return full_name_hash((const unsigned char *)name, len) % sz;
67799 +}
67800 +
67801 +#define FOR_EACH_ROLE_START(role) \
67802 + role = role_list; \
67803 + while (role) {
67804 +
67805 +#define FOR_EACH_ROLE_END(role) \
67806 + role = role->prev; \
67807 + }
67808 +
67809 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
67810 + subj = NULL; \
67811 + iter = 0; \
67812 + while (iter < role->subj_hash_size) { \
67813 + if (subj == NULL) \
67814 + subj = role->subj_hash[iter]; \
67815 + if (subj == NULL) { \
67816 + iter++; \
67817 + continue; \
67818 + }
67819 +
67820 +#define FOR_EACH_SUBJECT_END(subj,iter) \
67821 + subj = subj->next; \
67822 + if (subj == NULL) \
67823 + iter++; \
67824 + }
67825 +
67826 +
67827 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
67828 + subj = role->hash->first; \
67829 + while (subj != NULL) {
67830 +
67831 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
67832 + subj = subj->next; \
67833 + }
67834 +
67835 +#endif
67836 +
67837 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
67838 new file mode 100644
67839 index 0000000..323ecf2
67840 --- /dev/null
67841 +++ b/include/linux/gralloc.h
67842 @@ -0,0 +1,9 @@
67843 +#ifndef __GRALLOC_H
67844 +#define __GRALLOC_H
67845 +
67846 +void acl_free_all(void);
67847 +int acl_alloc_stack_init(unsigned long size);
67848 +void *acl_alloc(unsigned long len);
67849 +void *acl_alloc_num(unsigned long num, unsigned long len);
67850 +
67851 +#endif
67852 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
67853 new file mode 100644
67854 index 0000000..be66033
67855 --- /dev/null
67856 +++ b/include/linux/grdefs.h
67857 @@ -0,0 +1,140 @@
67858 +#ifndef GRDEFS_H
67859 +#define GRDEFS_H
67860 +
67861 +/* Begin grsecurity status declarations */
67862 +
67863 +enum {
67864 + GR_READY = 0x01,
67865 + GR_STATUS_INIT = 0x00 // disabled state
67866 +};
67867 +
67868 +/* Begin ACL declarations */
67869 +
67870 +/* Role flags */
67871 +
67872 +enum {
67873 + GR_ROLE_USER = 0x0001,
67874 + GR_ROLE_GROUP = 0x0002,
67875 + GR_ROLE_DEFAULT = 0x0004,
67876 + GR_ROLE_SPECIAL = 0x0008,
67877 + GR_ROLE_AUTH = 0x0010,
67878 + GR_ROLE_NOPW = 0x0020,
67879 + GR_ROLE_GOD = 0x0040,
67880 + GR_ROLE_LEARN = 0x0080,
67881 + GR_ROLE_TPE = 0x0100,
67882 + GR_ROLE_DOMAIN = 0x0200,
67883 + GR_ROLE_PAM = 0x0400,
67884 + GR_ROLE_PERSIST = 0x0800
67885 +};
67886 +
67887 +/* ACL Subject and Object mode flags */
67888 +enum {
67889 + GR_DELETED = 0x80000000
67890 +};
67891 +
67892 +/* ACL Object-only mode flags */
67893 +enum {
67894 + GR_READ = 0x00000001,
67895 + GR_APPEND = 0x00000002,
67896 + GR_WRITE = 0x00000004,
67897 + GR_EXEC = 0x00000008,
67898 + GR_FIND = 0x00000010,
67899 + GR_INHERIT = 0x00000020,
67900 + GR_SETID = 0x00000040,
67901 + GR_CREATE = 0x00000080,
67902 + GR_DELETE = 0x00000100,
67903 + GR_LINK = 0x00000200,
67904 + GR_AUDIT_READ = 0x00000400,
67905 + GR_AUDIT_APPEND = 0x00000800,
67906 + GR_AUDIT_WRITE = 0x00001000,
67907 + GR_AUDIT_EXEC = 0x00002000,
67908 + GR_AUDIT_FIND = 0x00004000,
67909 + GR_AUDIT_INHERIT= 0x00008000,
67910 + GR_AUDIT_SETID = 0x00010000,
67911 + GR_AUDIT_CREATE = 0x00020000,
67912 + GR_AUDIT_DELETE = 0x00040000,
67913 + GR_AUDIT_LINK = 0x00080000,
67914 + GR_PTRACERD = 0x00100000,
67915 + GR_NOPTRACE = 0x00200000,
67916 + GR_SUPPRESS = 0x00400000,
67917 + GR_NOLEARN = 0x00800000,
67918 + GR_INIT_TRANSFER= 0x01000000
67919 +};
67920 +
67921 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
67922 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
67923 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
67924 +
67925 +/* ACL subject-only mode flags */
67926 +enum {
67927 + GR_KILL = 0x00000001,
67928 + GR_VIEW = 0x00000002,
67929 + GR_PROTECTED = 0x00000004,
67930 + GR_LEARN = 0x00000008,
67931 + GR_OVERRIDE = 0x00000010,
67932 + /* just a placeholder, this mode is only used in userspace */
67933 + GR_DUMMY = 0x00000020,
67934 + GR_PROTSHM = 0x00000040,
67935 + GR_KILLPROC = 0x00000080,
67936 + GR_KILLIPPROC = 0x00000100,
67937 + /* just a placeholder, this mode is only used in userspace */
67938 + GR_NOTROJAN = 0x00000200,
67939 + GR_PROTPROCFD = 0x00000400,
67940 + GR_PROCACCT = 0x00000800,
67941 + GR_RELAXPTRACE = 0x00001000,
67942 + //GR_NESTED = 0x00002000,
67943 + GR_INHERITLEARN = 0x00004000,
67944 + GR_PROCFIND = 0x00008000,
67945 + GR_POVERRIDE = 0x00010000,
67946 + GR_KERNELAUTH = 0x00020000,
67947 + GR_ATSECURE = 0x00040000,
67948 + GR_SHMEXEC = 0x00080000
67949 +};
67950 +
67951 +enum {
67952 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
67953 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
67954 + GR_PAX_ENABLE_MPROTECT = 0x0004,
67955 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
67956 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
67957 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
67958 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
67959 + GR_PAX_DISABLE_MPROTECT = 0x0400,
67960 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
67961 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
67962 +};
67963 +
67964 +enum {
67965 + GR_ID_USER = 0x01,
67966 + GR_ID_GROUP = 0x02,
67967 +};
67968 +
67969 +enum {
67970 + GR_ID_ALLOW = 0x01,
67971 + GR_ID_DENY = 0x02,
67972 +};
67973 +
67974 +#define GR_CRASH_RES 31
67975 +#define GR_UIDTABLE_MAX 500
67976 +
67977 +/* begin resource learning section */
67978 +enum {
67979 + GR_RLIM_CPU_BUMP = 60,
67980 + GR_RLIM_FSIZE_BUMP = 50000,
67981 + GR_RLIM_DATA_BUMP = 10000,
67982 + GR_RLIM_STACK_BUMP = 1000,
67983 + GR_RLIM_CORE_BUMP = 10000,
67984 + GR_RLIM_RSS_BUMP = 500000,
67985 + GR_RLIM_NPROC_BUMP = 1,
67986 + GR_RLIM_NOFILE_BUMP = 5,
67987 + GR_RLIM_MEMLOCK_BUMP = 50000,
67988 + GR_RLIM_AS_BUMP = 500000,
67989 + GR_RLIM_LOCKS_BUMP = 2,
67990 + GR_RLIM_SIGPENDING_BUMP = 5,
67991 + GR_RLIM_MSGQUEUE_BUMP = 10000,
67992 + GR_RLIM_NICE_BUMP = 1,
67993 + GR_RLIM_RTPRIO_BUMP = 1,
67994 + GR_RLIM_RTTIME_BUMP = 1000000
67995 +};
67996 +
67997 +#endif
67998 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
67999 new file mode 100644
68000 index 0000000..5402bce
68001 --- /dev/null
68002 +++ b/include/linux/grinternal.h
68003 @@ -0,0 +1,215 @@
68004 +#ifndef __GRINTERNAL_H
68005 +#define __GRINTERNAL_H
68006 +
68007 +#ifdef CONFIG_GRKERNSEC
68008 +
68009 +#include <linux/fs.h>
68010 +#include <linux/mnt_namespace.h>
68011 +#include <linux/nsproxy.h>
68012 +#include <linux/gracl.h>
68013 +#include <linux/grdefs.h>
68014 +#include <linux/grmsg.h>
68015 +
68016 +void gr_add_learn_entry(const char *fmt, ...)
68017 + __attribute__ ((format (printf, 1, 2)));
68018 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
68019 + const struct vfsmount *mnt);
68020 +__u32 gr_check_create(const struct dentry *new_dentry,
68021 + const struct dentry *parent,
68022 + const struct vfsmount *mnt, const __u32 mode);
68023 +int gr_check_protected_task(const struct task_struct *task);
68024 +__u32 to_gr_audit(const __u32 reqmode);
68025 +int gr_set_acls(const int type);
68026 +int gr_apply_subject_to_task(struct task_struct *task);
68027 +int gr_acl_is_enabled(void);
68028 +char gr_roletype_to_char(void);
68029 +
68030 +void gr_handle_alertkill(struct task_struct *task);
68031 +char *gr_to_filename(const struct dentry *dentry,
68032 + const struct vfsmount *mnt);
68033 +char *gr_to_filename1(const struct dentry *dentry,
68034 + const struct vfsmount *mnt);
68035 +char *gr_to_filename2(const struct dentry *dentry,
68036 + const struct vfsmount *mnt);
68037 +char *gr_to_filename3(const struct dentry *dentry,
68038 + const struct vfsmount *mnt);
68039 +
68040 +extern int grsec_enable_ptrace_readexec;
68041 +extern int grsec_enable_harden_ptrace;
68042 +extern int grsec_enable_link;
68043 +extern int grsec_enable_fifo;
68044 +extern int grsec_enable_execve;
68045 +extern int grsec_enable_shm;
68046 +extern int grsec_enable_execlog;
68047 +extern int grsec_enable_signal;
68048 +extern int grsec_enable_audit_ptrace;
68049 +extern int grsec_enable_forkfail;
68050 +extern int grsec_enable_time;
68051 +extern int grsec_enable_rofs;
68052 +extern int grsec_enable_chroot_shmat;
68053 +extern int grsec_enable_chroot_mount;
68054 +extern int grsec_enable_chroot_double;
68055 +extern int grsec_enable_chroot_pivot;
68056 +extern int grsec_enable_chroot_chdir;
68057 +extern int grsec_enable_chroot_chmod;
68058 +extern int grsec_enable_chroot_mknod;
68059 +extern int grsec_enable_chroot_fchdir;
68060 +extern int grsec_enable_chroot_nice;
68061 +extern int grsec_enable_chroot_execlog;
68062 +extern int grsec_enable_chroot_caps;
68063 +extern int grsec_enable_chroot_sysctl;
68064 +extern int grsec_enable_chroot_unix;
68065 +extern int grsec_enable_symlinkown;
68066 +extern kgid_t grsec_symlinkown_gid;
68067 +extern int grsec_enable_tpe;
68068 +extern kgid_t grsec_tpe_gid;
68069 +extern int grsec_enable_tpe_all;
68070 +extern int grsec_enable_tpe_invert;
68071 +extern int grsec_enable_socket_all;
68072 +extern kgid_t grsec_socket_all_gid;
68073 +extern int grsec_enable_socket_client;
68074 +extern kgid_t grsec_socket_client_gid;
68075 +extern int grsec_enable_socket_server;
68076 +extern kgid_t grsec_socket_server_gid;
68077 +extern kgid_t grsec_audit_gid;
68078 +extern int grsec_enable_group;
68079 +extern int grsec_enable_audit_textrel;
68080 +extern int grsec_enable_log_rwxmaps;
68081 +extern int grsec_enable_mount;
68082 +extern int grsec_enable_chdir;
68083 +extern int grsec_resource_logging;
68084 +extern int grsec_enable_blackhole;
68085 +extern int grsec_lastack_retries;
68086 +extern int grsec_enable_brute;
68087 +extern int grsec_lock;
68088 +
68089 +extern spinlock_t grsec_alert_lock;
68090 +extern unsigned long grsec_alert_wtime;
68091 +extern unsigned long grsec_alert_fyet;
68092 +
68093 +extern spinlock_t grsec_audit_lock;
68094 +
68095 +extern rwlock_t grsec_exec_file_lock;
68096 +
68097 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
68098 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
68099 + (tsk)->exec_file->f_path.mnt) : "/")
68100 +
68101 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
68102 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
68103 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
68104 +
68105 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
68106 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
68107 + (tsk)->exec_file->f_path.mnt) : "/")
68108 +
68109 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
68110 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
68111 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
68112 +
68113 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
68114 +
68115 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
68116 +
68117 +#define GR_CHROOT_CAPS {{ \
68118 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
68119 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
68120 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
68121 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
68122 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
68123 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
68124 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
68125 +
68126 +#define security_learn(normal_msg,args...) \
68127 +({ \
68128 + read_lock(&grsec_exec_file_lock); \
68129 + gr_add_learn_entry(normal_msg "\n", ## args); \
68130 + read_unlock(&grsec_exec_file_lock); \
68131 +})
68132 +
68133 +enum {
68134 + GR_DO_AUDIT,
68135 + GR_DONT_AUDIT,
68136 + /* used for non-audit messages that we shouldn't kill the task on */
68137 + GR_DONT_AUDIT_GOOD
68138 +};
68139 +
68140 +enum {
68141 + GR_TTYSNIFF,
68142 + GR_RBAC,
68143 + GR_RBAC_STR,
68144 + GR_STR_RBAC,
68145 + GR_RBAC_MODE2,
68146 + GR_RBAC_MODE3,
68147 + GR_FILENAME,
68148 + GR_SYSCTL_HIDDEN,
68149 + GR_NOARGS,
68150 + GR_ONE_INT,
68151 + GR_ONE_INT_TWO_STR,
68152 + GR_ONE_STR,
68153 + GR_STR_INT,
68154 + GR_TWO_STR_INT,
68155 + GR_TWO_INT,
68156 + GR_TWO_U64,
68157 + GR_THREE_INT,
68158 + GR_FIVE_INT_TWO_STR,
68159 + GR_TWO_STR,
68160 + GR_THREE_STR,
68161 + GR_FOUR_STR,
68162 + GR_STR_FILENAME,
68163 + GR_FILENAME_STR,
68164 + GR_FILENAME_TWO_INT,
68165 + GR_FILENAME_TWO_INT_STR,
68166 + GR_TEXTREL,
68167 + GR_PTRACE,
68168 + GR_RESOURCE,
68169 + GR_CAP,
68170 + GR_SIG,
68171 + GR_SIG2,
68172 + GR_CRASH1,
68173 + GR_CRASH2,
68174 + GR_PSACCT,
68175 + GR_RWXMAP
68176 +};
68177 +
68178 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
68179 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
68180 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
68181 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
68182 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
68183 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
68184 +#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)
68185 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
68186 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
68187 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
68188 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
68189 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
68190 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
68191 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
68192 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
68193 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
68194 +#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)
68195 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
68196 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
68197 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
68198 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
68199 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
68200 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
68201 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
68202 +#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)
68203 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
68204 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
68205 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
68206 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
68207 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
68208 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
68209 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
68210 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
68211 +#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)
68212 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
68213 +
68214 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
68215 +
68216 +#endif
68217 +
68218 +#endif
68219 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
68220 new file mode 100644
68221 index 0000000..2bd4c8d
68222 --- /dev/null
68223 +++ b/include/linux/grmsg.h
68224 @@ -0,0 +1,111 @@
68225 +#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"
68226 +#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"
68227 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
68228 +#define GR_STOPMOD_MSG "denied modification of module state by "
68229 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
68230 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
68231 +#define GR_IOPERM_MSG "denied use of ioperm() by "
68232 +#define GR_IOPL_MSG "denied use of iopl() by "
68233 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
68234 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
68235 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
68236 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
68237 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
68238 +#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"
68239 +#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"
68240 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
68241 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
68242 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
68243 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
68244 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
68245 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
68246 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
68247 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
68248 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
68249 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
68250 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
68251 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
68252 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
68253 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
68254 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
68255 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
68256 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
68257 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
68258 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
68259 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
68260 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
68261 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
68262 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
68263 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
68264 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
68265 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
68266 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
68267 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
68268 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
68269 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
68270 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
68271 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
68272 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
68273 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
68274 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
68275 +#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"
68276 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
68277 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
68278 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
68279 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
68280 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
68281 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
68282 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
68283 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
68284 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
68285 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
68286 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
68287 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
68288 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
68289 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
68290 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
68291 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
68292 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
68293 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
68294 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
68295 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
68296 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
68297 +#define GR_NICE_CHROOT_MSG "denied priority change by "
68298 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
68299 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
68300 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
68301 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
68302 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
68303 +#define GR_TIME_MSG "time set by "
68304 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
68305 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
68306 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
68307 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
68308 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
68309 +#define GR_BIND_MSG "denied bind() by "
68310 +#define GR_CONNECT_MSG "denied connect() by "
68311 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
68312 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
68313 +#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"
68314 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
68315 +#define GR_CAP_ACL_MSG "use of %s denied for "
68316 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
68317 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
68318 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
68319 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
68320 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
68321 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
68322 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
68323 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
68324 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
68325 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
68326 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
68327 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
68328 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
68329 +#define GR_VM86_MSG "denied use of vm86 by "
68330 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
68331 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
68332 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
68333 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
68334 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
68335 +#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 "
68336 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
68337 new file mode 100644
68338 index 0000000..d7ef0ac
68339 --- /dev/null
68340 +++ b/include/linux/grsecurity.h
68341 @@ -0,0 +1,242 @@
68342 +#ifndef GR_SECURITY_H
68343 +#define GR_SECURITY_H
68344 +#include <linux/fs.h>
68345 +#include <linux/fs_struct.h>
68346 +#include <linux/binfmts.h>
68347 +#include <linux/gracl.h>
68348 +
68349 +/* notify of brain-dead configs */
68350 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
68351 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
68352 +#endif
68353 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
68354 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
68355 +#endif
68356 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
68357 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
68358 +#endif
68359 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
68360 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
68361 +#endif
68362 +
68363 +void gr_handle_brute_attach(unsigned long mm_flags);
68364 +void gr_handle_brute_check(void);
68365 +void gr_handle_kernel_exploit(void);
68366 +int gr_process_user_ban(void);
68367 +
68368 +char gr_roletype_to_char(void);
68369 +
68370 +int gr_acl_enable_at_secure(void);
68371 +
68372 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
68373 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
68374 +
68375 +void gr_del_task_from_ip_table(struct task_struct *p);
68376 +
68377 +int gr_pid_is_chrooted(struct task_struct *p);
68378 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
68379 +int gr_handle_chroot_nice(void);
68380 +int gr_handle_chroot_sysctl(const int op);
68381 +int gr_handle_chroot_setpriority(struct task_struct *p,
68382 + const int niceval);
68383 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
68384 +int gr_handle_chroot_chroot(const struct dentry *dentry,
68385 + const struct vfsmount *mnt);
68386 +void gr_handle_chroot_chdir(const struct path *path);
68387 +int gr_handle_chroot_chmod(const struct dentry *dentry,
68388 + const struct vfsmount *mnt, const int mode);
68389 +int gr_handle_chroot_mknod(const struct dentry *dentry,
68390 + const struct vfsmount *mnt, const int mode);
68391 +int gr_handle_chroot_mount(const struct dentry *dentry,
68392 + const struct vfsmount *mnt,
68393 + const char *dev_name);
68394 +int gr_handle_chroot_pivot(void);
68395 +int gr_handle_chroot_unix(const pid_t pid);
68396 +
68397 +int gr_handle_rawio(const struct inode *inode);
68398 +
68399 +void gr_handle_ioperm(void);
68400 +void gr_handle_iopl(void);
68401 +
68402 +umode_t gr_acl_umask(void);
68403 +
68404 +int gr_tpe_allow(const struct file *file);
68405 +
68406 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
68407 +void gr_clear_chroot_entries(struct task_struct *task);
68408 +
68409 +void gr_log_forkfail(const int retval);
68410 +void gr_log_timechange(void);
68411 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
68412 +void gr_log_chdir(const struct dentry *dentry,
68413 + const struct vfsmount *mnt);
68414 +void gr_log_chroot_exec(const struct dentry *dentry,
68415 + const struct vfsmount *mnt);
68416 +void gr_log_remount(const char *devname, const int retval);
68417 +void gr_log_unmount(const char *devname, const int retval);
68418 +void gr_log_mount(const char *from, const char *to, const int retval);
68419 +void gr_log_textrel(struct vm_area_struct *vma);
68420 +void gr_log_rwxmmap(struct file *file);
68421 +void gr_log_rwxmprotect(struct file *file);
68422 +
68423 +int gr_handle_follow_link(const struct inode *parent,
68424 + const struct inode *inode,
68425 + const struct dentry *dentry,
68426 + const struct vfsmount *mnt);
68427 +int gr_handle_fifo(const struct dentry *dentry,
68428 + const struct vfsmount *mnt,
68429 + const struct dentry *dir, const int flag,
68430 + const int acc_mode);
68431 +int gr_handle_hardlink(const struct dentry *dentry,
68432 + const struct vfsmount *mnt,
68433 + struct inode *inode,
68434 + const int mode, const struct filename *to);
68435 +
68436 +int gr_is_capable(const int cap);
68437 +int gr_is_capable_nolog(const int cap);
68438 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
68439 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
68440 +
68441 +void gr_copy_label(struct task_struct *tsk);
68442 +void gr_handle_crash(struct task_struct *task, const int sig);
68443 +int gr_handle_signal(const struct task_struct *p, const int sig);
68444 +int gr_check_crash_uid(const kuid_t uid);
68445 +int gr_check_protected_task(const struct task_struct *task);
68446 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
68447 +int gr_acl_handle_mmap(const struct file *file,
68448 + const unsigned long prot);
68449 +int gr_acl_handle_mprotect(const struct file *file,
68450 + const unsigned long prot);
68451 +int gr_check_hidden_task(const struct task_struct *tsk);
68452 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
68453 + const struct vfsmount *mnt);
68454 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
68455 + const struct vfsmount *mnt);
68456 +__u32 gr_acl_handle_access(const struct dentry *dentry,
68457 + const struct vfsmount *mnt, const int fmode);
68458 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
68459 + const struct vfsmount *mnt, umode_t *mode);
68460 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
68461 + const struct vfsmount *mnt);
68462 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
68463 + const struct vfsmount *mnt);
68464 +int gr_handle_ptrace(struct task_struct *task, const long request);
68465 +int gr_handle_proc_ptrace(struct task_struct *task);
68466 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
68467 + const struct vfsmount *mnt);
68468 +int gr_check_crash_exec(const struct file *filp);
68469 +int gr_acl_is_enabled(void);
68470 +void gr_set_kernel_label(struct task_struct *task);
68471 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
68472 + const kgid_t gid);
68473 +int gr_set_proc_label(const struct dentry *dentry,
68474 + const struct vfsmount *mnt,
68475 + const int unsafe_flags);
68476 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
68477 + const struct vfsmount *mnt);
68478 +__u32 gr_acl_handle_open(const struct dentry *dentry,
68479 + const struct vfsmount *mnt, int acc_mode);
68480 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
68481 + const struct dentry *p_dentry,
68482 + const struct vfsmount *p_mnt,
68483 + int open_flags, int acc_mode, const int imode);
68484 +void gr_handle_create(const struct dentry *dentry,
68485 + const struct vfsmount *mnt);
68486 +void gr_handle_proc_create(const struct dentry *dentry,
68487 + const struct inode *inode);
68488 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
68489 + const struct dentry *parent_dentry,
68490 + const struct vfsmount *parent_mnt,
68491 + const int mode);
68492 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
68493 + const struct dentry *parent_dentry,
68494 + const struct vfsmount *parent_mnt);
68495 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
68496 + const struct vfsmount *mnt);
68497 +void gr_handle_delete(const ino_t ino, const dev_t dev);
68498 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
68499 + const struct vfsmount *mnt);
68500 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
68501 + const struct dentry *parent_dentry,
68502 + const struct vfsmount *parent_mnt,
68503 + const struct filename *from);
68504 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
68505 + const struct dentry *parent_dentry,
68506 + const struct vfsmount *parent_mnt,
68507 + const struct dentry *old_dentry,
68508 + const struct vfsmount *old_mnt, const struct filename *to);
68509 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
68510 +int gr_acl_handle_rename(struct dentry *new_dentry,
68511 + struct dentry *parent_dentry,
68512 + const struct vfsmount *parent_mnt,
68513 + struct dentry *old_dentry,
68514 + struct inode *old_parent_inode,
68515 + struct vfsmount *old_mnt, const struct filename *newname);
68516 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
68517 + struct dentry *old_dentry,
68518 + struct dentry *new_dentry,
68519 + struct vfsmount *mnt, const __u8 replace);
68520 +__u32 gr_check_link(const struct dentry *new_dentry,
68521 + const struct dentry *parent_dentry,
68522 + const struct vfsmount *parent_mnt,
68523 + const struct dentry *old_dentry,
68524 + const struct vfsmount *old_mnt);
68525 +int gr_acl_handle_filldir(const struct file *file, const char *name,
68526 + const unsigned int namelen, const ino_t ino);
68527 +
68528 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
68529 + const struct vfsmount *mnt);
68530 +void gr_acl_handle_exit(void);
68531 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
68532 +int gr_acl_handle_procpidmem(const struct task_struct *task);
68533 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
68534 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
68535 +void gr_audit_ptrace(struct task_struct *task);
68536 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
68537 +void gr_put_exec_file(struct task_struct *task);
68538 +
68539 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
68540 +
68541 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
68542 +extern void gr_learn_resource(const struct task_struct *task, const int res,
68543 + const unsigned long wanted, const int gt);
68544 +#else
68545 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
68546 + const unsigned long wanted, const int gt)
68547 +{
68548 +}
68549 +#endif
68550 +
68551 +#ifdef CONFIG_GRKERNSEC_RESLOG
68552 +extern void gr_log_resource(const struct task_struct *task, const int res,
68553 + const unsigned long wanted, const int gt);
68554 +#else
68555 +static inline void gr_log_resource(const struct task_struct *task, const int res,
68556 + const unsigned long wanted, const int gt)
68557 +{
68558 +}
68559 +#endif
68560 +
68561 +#ifdef CONFIG_GRKERNSEC
68562 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
68563 +void gr_handle_vm86(void);
68564 +void gr_handle_mem_readwrite(u64 from, u64 to);
68565 +
68566 +void gr_log_badprocpid(const char *entry);
68567 +
68568 +extern int grsec_enable_dmesg;
68569 +extern int grsec_disable_privio;
68570 +
68571 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
68572 +extern kgid_t grsec_proc_gid;
68573 +#endif
68574 +
68575 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68576 +extern int grsec_enable_chroot_findtask;
68577 +#endif
68578 +#ifdef CONFIG_GRKERNSEC_SETXID
68579 +extern int grsec_enable_setxid;
68580 +#endif
68581 +#endif
68582 +
68583 +#endif
68584 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
68585 new file mode 100644
68586 index 0000000..e7ffaaf
68587 --- /dev/null
68588 +++ b/include/linux/grsock.h
68589 @@ -0,0 +1,19 @@
68590 +#ifndef __GRSOCK_H
68591 +#define __GRSOCK_H
68592 +
68593 +extern void gr_attach_curr_ip(const struct sock *sk);
68594 +extern int gr_handle_sock_all(const int family, const int type,
68595 + const int protocol);
68596 +extern int gr_handle_sock_server(const struct sockaddr *sck);
68597 +extern int gr_handle_sock_server_other(const struct sock *sck);
68598 +extern int gr_handle_sock_client(const struct sockaddr *sck);
68599 +extern int gr_search_connect(struct socket * sock,
68600 + struct sockaddr_in * addr);
68601 +extern int gr_search_bind(struct socket * sock,
68602 + struct sockaddr_in * addr);
68603 +extern int gr_search_listen(struct socket * sock);
68604 +extern int gr_search_accept(struct socket * sock);
68605 +extern int gr_search_socket(const int domain, const int type,
68606 + const int protocol);
68607 +
68608 +#endif
68609 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
68610 index 7fb31da..08b5114 100644
68611 --- a/include/linux/highmem.h
68612 +++ b/include/linux/highmem.h
68613 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
68614 kunmap_atomic(kaddr);
68615 }
68616
68617 +static inline void sanitize_highpage(struct page *page)
68618 +{
68619 + void *kaddr;
68620 + unsigned long flags;
68621 +
68622 + local_irq_save(flags);
68623 + kaddr = kmap_atomic(page);
68624 + clear_page(kaddr);
68625 + kunmap_atomic(kaddr);
68626 + local_irq_restore(flags);
68627 +}
68628 +
68629 static inline void zero_user_segments(struct page *page,
68630 unsigned start1, unsigned end1,
68631 unsigned start2, unsigned end2)
68632 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
68633 index 1c7b89a..7f52502 100644
68634 --- a/include/linux/hwmon-sysfs.h
68635 +++ b/include/linux/hwmon-sysfs.h
68636 @@ -25,7 +25,8 @@
68637 struct sensor_device_attribute{
68638 struct device_attribute dev_attr;
68639 int index;
68640 -};
68641 +} __do_const;
68642 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
68643 #define to_sensor_dev_attr(_dev_attr) \
68644 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
68645
68646 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
68647 struct device_attribute dev_attr;
68648 u8 index;
68649 u8 nr;
68650 -};
68651 +} __do_const;
68652 #define to_sensor_dev_attr_2(_dev_attr) \
68653 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
68654
68655 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
68656 index d0c4db7..61b3577 100644
68657 --- a/include/linux/i2c.h
68658 +++ b/include/linux/i2c.h
68659 @@ -369,6 +369,7 @@ struct i2c_algorithm {
68660 /* To determine what the adapter supports */
68661 u32 (*functionality) (struct i2c_adapter *);
68662 };
68663 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
68664
68665 /*
68666 * i2c_adapter is the structure used to identify a physical i2c bus along
68667 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
68668 index d23c3c2..eb63c81 100644
68669 --- a/include/linux/i2o.h
68670 +++ b/include/linux/i2o.h
68671 @@ -565,7 +565,7 @@ struct i2o_controller {
68672 struct i2o_device *exec; /* Executive */
68673 #if BITS_PER_LONG == 64
68674 spinlock_t context_list_lock; /* lock for context_list */
68675 - atomic_t context_list_counter; /* needed for unique contexts */
68676 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
68677 struct list_head context_list; /* list of context id's
68678 and pointers */
68679 #endif
68680 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
68681 index aff7ad8..3942bbd 100644
68682 --- a/include/linux/if_pppox.h
68683 +++ b/include/linux/if_pppox.h
68684 @@ -76,7 +76,7 @@ struct pppox_proto {
68685 int (*ioctl)(struct socket *sock, unsigned int cmd,
68686 unsigned long arg);
68687 struct module *owner;
68688 -};
68689 +} __do_const;
68690
68691 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
68692 extern void unregister_pppox_proto(int proto_num);
68693 diff --git a/include/linux/init.h b/include/linux/init.h
68694 index 8618147..0821126 100644
68695 --- a/include/linux/init.h
68696 +++ b/include/linux/init.h
68697 @@ -39,9 +39,36 @@
68698 * Also note, that this data cannot be "const".
68699 */
68700
68701 +#ifdef MODULE
68702 +#define add_init_latent_entropy
68703 +#define add_devinit_latent_entropy
68704 +#define add_cpuinit_latent_entropy
68705 +#define add_meminit_latent_entropy
68706 +#else
68707 +#define add_init_latent_entropy __latent_entropy
68708 +
68709 +#ifdef CONFIG_HOTPLUG
68710 +#define add_devinit_latent_entropy
68711 +#else
68712 +#define add_devinit_latent_entropy __latent_entropy
68713 +#endif
68714 +
68715 +#ifdef CONFIG_HOTPLUG_CPU
68716 +#define add_cpuinit_latent_entropy
68717 +#else
68718 +#define add_cpuinit_latent_entropy __latent_entropy
68719 +#endif
68720 +
68721 +#ifdef CONFIG_MEMORY_HOTPLUG
68722 +#define add_meminit_latent_entropy
68723 +#else
68724 +#define add_meminit_latent_entropy __latent_entropy
68725 +#endif
68726 +#endif
68727 +
68728 /* These are for everybody (although not all archs will actually
68729 discard it in modules) */
68730 -#define __init __section(.init.text) __cold notrace
68731 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
68732 #define __initdata __section(.init.data)
68733 #define __initconst __constsection(.init.rodata)
68734 #define __exitdata __section(.exit.data)
68735 @@ -94,7 +121,7 @@
68736 #define __exit __section(.exit.text) __exitused __cold notrace
68737
68738 /* Used for HOTPLUG_CPU */
68739 -#define __cpuinit __section(.cpuinit.text) __cold notrace
68740 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
68741 #define __cpuinitdata __section(.cpuinit.data)
68742 #define __cpuinitconst __constsection(.cpuinit.rodata)
68743 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
68744 @@ -102,7 +129,7 @@
68745 #define __cpuexitconst __constsection(.cpuexit.rodata)
68746
68747 /* Used for MEMORY_HOTPLUG */
68748 -#define __meminit __section(.meminit.text) __cold notrace
68749 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
68750 #define __meminitdata __section(.meminit.data)
68751 #define __meminitconst __constsection(.meminit.rodata)
68752 #define __memexit __section(.memexit.text) __exitused __cold notrace
68753 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
68754 index 5cd0f09..c9f67cc 100644
68755 --- a/include/linux/init_task.h
68756 +++ b/include/linux/init_task.h
68757 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
68758
68759 #define INIT_TASK_COMM "swapper"
68760
68761 +#ifdef CONFIG_X86
68762 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
68763 +#else
68764 +#define INIT_TASK_THREAD_INFO
68765 +#endif
68766 +
68767 /*
68768 * INIT_TASK is used to set up the first task table, touch at
68769 * your own risk!. Base=0, limit=0x1fffff (=2MB)
68770 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
68771 RCU_POINTER_INITIALIZER(cred, &init_cred), \
68772 .comm = INIT_TASK_COMM, \
68773 .thread = INIT_THREAD, \
68774 + INIT_TASK_THREAD_INFO \
68775 .fs = &init_fs, \
68776 .files = &init_files, \
68777 .signal = &init_signals, \
68778 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
68779 index 5fa5afe..ac55b25 100644
68780 --- a/include/linux/interrupt.h
68781 +++ b/include/linux/interrupt.h
68782 @@ -430,7 +430,7 @@ enum
68783 /* map softirq index to softirq name. update 'softirq_to_name' in
68784 * kernel/softirq.c when adding a new softirq.
68785 */
68786 -extern char *softirq_to_name[NR_SOFTIRQS];
68787 +extern const char * const softirq_to_name[NR_SOFTIRQS];
68788
68789 /* softirq mask and active fields moved to irq_cpustat_t in
68790 * asm/hardirq.h to get better cache usage. KAO
68791 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
68792
68793 struct softirq_action
68794 {
68795 - void (*action)(struct softirq_action *);
68796 -};
68797 + void (*action)(void);
68798 +} __no_const;
68799
68800 asmlinkage void do_softirq(void);
68801 asmlinkage void __do_softirq(void);
68802 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
68803 +extern void open_softirq(int nr, void (*action)(void));
68804 extern void softirq_init(void);
68805 extern void __raise_softirq_irqoff(unsigned int nr);
68806
68807 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
68808 index ba3b8a9..7e14ed8 100644
68809 --- a/include/linux/iommu.h
68810 +++ b/include/linux/iommu.h
68811 @@ -113,7 +113,7 @@ struct iommu_ops {
68812 u32 (*domain_get_windows)(struct iommu_domain *domain);
68813
68814 unsigned long pgsize_bitmap;
68815 -};
68816 +} __do_const;
68817
68818 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
68819 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
68820 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
68821 index 85ac9b9b..e5759ab 100644
68822 --- a/include/linux/ioport.h
68823 +++ b/include/linux/ioport.h
68824 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
68825 int adjust_resource(struct resource *res, resource_size_t start,
68826 resource_size_t size);
68827 resource_size_t resource_alignment(struct resource *res);
68828 -static inline resource_size_t resource_size(const struct resource *res)
68829 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
68830 {
68831 return res->end - res->start + 1;
68832 }
68833 diff --git a/include/linux/irq.h b/include/linux/irq.h
68834 index bc4e066..50468a9 100644
68835 --- a/include/linux/irq.h
68836 +++ b/include/linux/irq.h
68837 @@ -328,7 +328,8 @@ struct irq_chip {
68838 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
68839
68840 unsigned long flags;
68841 -};
68842 +} __do_const;
68843 +typedef struct irq_chip __no_const irq_chip_no_const;
68844
68845 /*
68846 * irq_chip specific flags
68847 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
68848 index 3fd8e42..d5403e1 100644
68849 --- a/include/linux/irqchip/arm-gic.h
68850 +++ b/include/linux/irqchip/arm-gic.h
68851 @@ -61,7 +61,7 @@
68852
68853 struct device_node;
68854
68855 -extern struct irq_chip gic_arch_extn;
68856 +extern irq_chip_no_const gic_arch_extn;
68857
68858 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
68859 u32 offset, struct device_node *);
68860 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
68861 index 6883e19..06992b1 100644
68862 --- a/include/linux/kallsyms.h
68863 +++ b/include/linux/kallsyms.h
68864 @@ -15,7 +15,8 @@
68865
68866 struct module;
68867
68868 -#ifdef CONFIG_KALLSYMS
68869 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
68870 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
68871 /* Lookup the address for a symbol. Returns 0 if not found. */
68872 unsigned long kallsyms_lookup_name(const char *name);
68873
68874 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
68875 /* Stupid that this does nothing, but I didn't create this mess. */
68876 #define __print_symbol(fmt, addr)
68877 #endif /*CONFIG_KALLSYMS*/
68878 +#else /* when included by kallsyms.c, vsnprintf.c, or
68879 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
68880 +extern void __print_symbol(const char *fmt, unsigned long address);
68881 +extern int sprint_backtrace(char *buffer, unsigned long address);
68882 +extern int sprint_symbol(char *buffer, unsigned long address);
68883 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
68884 +const char *kallsyms_lookup(unsigned long addr,
68885 + unsigned long *symbolsize,
68886 + unsigned long *offset,
68887 + char **modname, char *namebuf);
68888 +#endif
68889
68890 /* This macro allows us to keep printk typechecking */
68891 static __printf(1, 2)
68892 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
68893 index 518a53a..5e28358 100644
68894 --- a/include/linux/key-type.h
68895 +++ b/include/linux/key-type.h
68896 @@ -125,7 +125,7 @@ struct key_type {
68897 /* internal fields */
68898 struct list_head link; /* link in types list */
68899 struct lock_class_key lock_class; /* key->sem lock class */
68900 -};
68901 +} __do_const;
68902
68903 extern struct key_type key_type_keyring;
68904
68905 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
68906 index c6e091b..a940adf 100644
68907 --- a/include/linux/kgdb.h
68908 +++ b/include/linux/kgdb.h
68909 @@ -52,7 +52,7 @@ extern int kgdb_connected;
68910 extern int kgdb_io_module_registered;
68911
68912 extern atomic_t kgdb_setting_breakpoint;
68913 -extern atomic_t kgdb_cpu_doing_single_step;
68914 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
68915
68916 extern struct task_struct *kgdb_usethread;
68917 extern struct task_struct *kgdb_contthread;
68918 @@ -254,7 +254,7 @@ struct kgdb_arch {
68919 void (*correct_hw_break)(void);
68920
68921 void (*enable_nmi)(bool on);
68922 -};
68923 +} __do_const;
68924
68925 /**
68926 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
68927 @@ -279,7 +279,7 @@ struct kgdb_io {
68928 void (*pre_exception) (void);
68929 void (*post_exception) (void);
68930 int is_console;
68931 -};
68932 +} __do_const;
68933
68934 extern struct kgdb_arch arch_kgdb_ops;
68935
68936 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
68937 index 5398d58..5883a34 100644
68938 --- a/include/linux/kmod.h
68939 +++ b/include/linux/kmod.h
68940 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
68941 * usually useless though. */
68942 extern __printf(2, 3)
68943 int __request_module(bool wait, const char *name, ...);
68944 +extern __printf(3, 4)
68945 +int ___request_module(bool wait, char *param_name, const char *name, ...);
68946 #define request_module(mod...) __request_module(true, mod)
68947 #define request_module_nowait(mod...) __request_module(false, mod)
68948 #define try_then_request_module(x, mod...) \
68949 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
68950 index 939b112..ed6ed51 100644
68951 --- a/include/linux/kobject.h
68952 +++ b/include/linux/kobject.h
68953 @@ -111,7 +111,7 @@ struct kobj_type {
68954 struct attribute **default_attrs;
68955 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
68956 const void *(*namespace)(struct kobject *kobj);
68957 -};
68958 +} __do_const;
68959
68960 struct kobj_uevent_env {
68961 char *envp[UEVENT_NUM_ENVP];
68962 @@ -134,6 +134,7 @@ struct kobj_attribute {
68963 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
68964 const char *buf, size_t count);
68965 };
68966 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
68967
68968 extern const struct sysfs_ops kobj_sysfs_ops;
68969
68970 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
68971 index f66b065..c2c29b4 100644
68972 --- a/include/linux/kobject_ns.h
68973 +++ b/include/linux/kobject_ns.h
68974 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
68975 const void *(*netlink_ns)(struct sock *sk);
68976 const void *(*initial_ns)(void);
68977 void (*drop_ns)(void *);
68978 -};
68979 +} __do_const;
68980
68981 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
68982 int kobj_ns_type_registered(enum kobj_ns_type type);
68983 diff --git a/include/linux/kref.h b/include/linux/kref.h
68984 index 4972e6e..de4d19b 100644
68985 --- a/include/linux/kref.h
68986 +++ b/include/linux/kref.h
68987 @@ -64,7 +64,7 @@ static inline void kref_get(struct kref *kref)
68988 static inline int kref_sub(struct kref *kref, unsigned int count,
68989 void (*release)(struct kref *kref))
68990 {
68991 - WARN_ON(release == NULL);
68992 + BUG_ON(release == NULL);
68993
68994 if (atomic_sub_and_test((int) count, &kref->refcount)) {
68995 release(kref);
68996 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
68997 index c139582..0b5b102 100644
68998 --- a/include/linux/kvm_host.h
68999 +++ b/include/linux/kvm_host.h
69000 @@ -424,7 +424,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
69001 int __must_check vcpu_load(struct kvm_vcpu *vcpu);
69002 void vcpu_put(struct kvm_vcpu *vcpu);
69003
69004 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69005 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69006 struct module *module);
69007 void kvm_exit(void);
69008
69009 @@ -582,7 +582,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
69010 struct kvm_guest_debug *dbg);
69011 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
69012
69013 -int kvm_arch_init(void *opaque);
69014 +int kvm_arch_init(const void *opaque);
69015 void kvm_arch_exit(void);
69016
69017 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
69018 diff --git a/include/linux/libata.h b/include/linux/libata.h
69019 index eae7a05..2cdd875 100644
69020 --- a/include/linux/libata.h
69021 +++ b/include/linux/libata.h
69022 @@ -919,7 +919,7 @@ struct ata_port_operations {
69023 * fields must be pointers.
69024 */
69025 const struct ata_port_operations *inherits;
69026 -};
69027 +} __do_const;
69028
69029 struct ata_port_info {
69030 unsigned long flags;
69031 diff --git a/include/linux/list.h b/include/linux/list.h
69032 index 6a1f8df..eaec1ff 100644
69033 --- a/include/linux/list.h
69034 +++ b/include/linux/list.h
69035 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
69036 extern void list_del(struct list_head *entry);
69037 #endif
69038
69039 +extern void __pax_list_add(struct list_head *new,
69040 + struct list_head *prev,
69041 + struct list_head *next);
69042 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
69043 +{
69044 + __pax_list_add(new, head, head->next);
69045 +}
69046 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
69047 +{
69048 + __pax_list_add(new, head->prev, head);
69049 +}
69050 +extern void pax_list_del(struct list_head *entry);
69051 +
69052 /**
69053 * list_replace - replace old entry by new one
69054 * @old : the element to be replaced
69055 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
69056 INIT_LIST_HEAD(entry);
69057 }
69058
69059 +extern void pax_list_del_init(struct list_head *entry);
69060 +
69061 /**
69062 * list_move - delete from one list and add as another's head
69063 * @list: the entry to move
69064 diff --git a/include/linux/math64.h b/include/linux/math64.h
69065 index b8ba855..0148090 100644
69066 --- a/include/linux/math64.h
69067 +++ b/include/linux/math64.h
69068 @@ -14,7 +14,7 @@
69069 * This is commonly provided by 32bit archs to provide an optimized 64bit
69070 * divide.
69071 */
69072 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69073 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69074 {
69075 *remainder = dividend % divisor;
69076 return dividend / divisor;
69077 @@ -50,7 +50,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
69078 #define div64_long(x,y) div_s64((x),(y))
69079
69080 #ifndef div_u64_rem
69081 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69082 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69083 {
69084 *remainder = do_div(dividend, divisor);
69085 return dividend;
69086 @@ -79,7 +79,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
69087 * divide.
69088 */
69089 #ifndef div_u64
69090 -static inline u64 div_u64(u64 dividend, u32 divisor)
69091 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
69092 {
69093 u32 remainder;
69094 return div_u64_rem(dividend, divisor, &remainder);
69095 diff --git a/include/linux/mm.h b/include/linux/mm.h
69096 index e2091b8..821db54 100644
69097 --- a/include/linux/mm.h
69098 +++ b/include/linux/mm.h
69099 @@ -101,6 +101,11 @@ extern unsigned int kobjsize(const void *objp);
69100 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
69101 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
69102 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
69103 +
69104 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
69105 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
69106 +#endif
69107 +
69108 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
69109
69110 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
69111 @@ -202,8 +207,8 @@ struct vm_operations_struct {
69112 /* called by access_process_vm when get_user_pages() fails, typically
69113 * for use by special VMAs that can switch between memory and hardware
69114 */
69115 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
69116 - void *buf, int len, int write);
69117 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
69118 + void *buf, size_t len, int write);
69119 #ifdef CONFIG_NUMA
69120 /*
69121 * set_policy() op must add a reference to any non-NULL @new mempolicy
69122 @@ -233,6 +238,7 @@ struct vm_operations_struct {
69123 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
69124 unsigned long size, pgoff_t pgoff);
69125 };
69126 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
69127
69128 struct mmu_gather;
69129 struct inode;
69130 @@ -970,8 +976,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
69131 unsigned long *pfn);
69132 int follow_phys(struct vm_area_struct *vma, unsigned long address,
69133 unsigned int flags, unsigned long *prot, resource_size_t *phys);
69134 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
69135 - void *buf, int len, int write);
69136 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
69137 + void *buf, size_t len, int write);
69138
69139 static inline void unmap_shared_mapping_range(struct address_space *mapping,
69140 loff_t const holebegin, loff_t const holelen)
69141 @@ -1010,9 +1016,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
69142 }
69143 #endif
69144
69145 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
69146 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
69147 - void *buf, int len, int write);
69148 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
69149 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
69150 + void *buf, size_t len, int write);
69151
69152 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
69153 unsigned long start, unsigned long nr_pages,
69154 @@ -1043,34 +1049,6 @@ int set_page_dirty(struct page *page);
69155 int set_page_dirty_lock(struct page *page);
69156 int clear_page_dirty_for_io(struct page *page);
69157
69158 -/* Is the vma a continuation of the stack vma above it? */
69159 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
69160 -{
69161 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
69162 -}
69163 -
69164 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
69165 - unsigned long addr)
69166 -{
69167 - return (vma->vm_flags & VM_GROWSDOWN) &&
69168 - (vma->vm_start == addr) &&
69169 - !vma_growsdown(vma->vm_prev, addr);
69170 -}
69171 -
69172 -/* Is the vma a continuation of the stack vma below it? */
69173 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
69174 -{
69175 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
69176 -}
69177 -
69178 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
69179 - unsigned long addr)
69180 -{
69181 - return (vma->vm_flags & VM_GROWSUP) &&
69182 - (vma->vm_end == addr) &&
69183 - !vma_growsup(vma->vm_next, addr);
69184 -}
69185 -
69186 extern pid_t
69187 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
69188
69189 @@ -1173,6 +1151,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
69190 }
69191 #endif
69192
69193 +#ifdef CONFIG_MMU
69194 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
69195 +#else
69196 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
69197 +{
69198 + return __pgprot(0);
69199 +}
69200 +#endif
69201 +
69202 int vma_wants_writenotify(struct vm_area_struct *vma);
69203
69204 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
69205 @@ -1191,8 +1178,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
69206 {
69207 return 0;
69208 }
69209 +
69210 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
69211 + unsigned long address)
69212 +{
69213 + return 0;
69214 +}
69215 #else
69216 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
69217 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
69218 #endif
69219
69220 #ifdef __PAGETABLE_PMD_FOLDED
69221 @@ -1201,8 +1195,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
69222 {
69223 return 0;
69224 }
69225 +
69226 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
69227 + unsigned long address)
69228 +{
69229 + return 0;
69230 +}
69231 #else
69232 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
69233 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
69234 #endif
69235
69236 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
69237 @@ -1220,11 +1221,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
69238 NULL: pud_offset(pgd, address);
69239 }
69240
69241 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
69242 +{
69243 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
69244 + NULL: pud_offset(pgd, address);
69245 +}
69246 +
69247 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
69248 {
69249 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
69250 NULL: pmd_offset(pud, address);
69251 }
69252 +
69253 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
69254 +{
69255 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
69256 + NULL: pmd_offset(pud, address);
69257 +}
69258 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
69259
69260 #if USE_SPLIT_PTLOCKS
69261 @@ -1455,6 +1468,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
69262 unsigned long len, unsigned long prot, unsigned long flags,
69263 unsigned long pgoff, unsigned long *populate);
69264 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
69265 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
69266
69267 #ifdef CONFIG_MMU
69268 extern int __mm_populate(unsigned long addr, unsigned long len,
69269 @@ -1483,6 +1497,7 @@ struct vm_unmapped_area_info {
69270 unsigned long high_limit;
69271 unsigned long align_mask;
69272 unsigned long align_offset;
69273 + unsigned long threadstack_offset;
69274 };
69275
69276 extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
69277 @@ -1561,6 +1576,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
69278 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
69279 struct vm_area_struct **pprev);
69280
69281 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
69282 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
69283 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
69284 +
69285 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
69286 NULL if none. Assume start_addr < end_addr. */
69287 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
69288 @@ -1589,15 +1608,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
69289 return vma;
69290 }
69291
69292 -#ifdef CONFIG_MMU
69293 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
69294 -#else
69295 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
69296 -{
69297 - return __pgprot(0);
69298 -}
69299 -#endif
69300 -
69301 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
69302 unsigned long change_prot_numa(struct vm_area_struct *vma,
69303 unsigned long start, unsigned long end);
69304 @@ -1649,6 +1659,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
69305 static inline void vm_stat_account(struct mm_struct *mm,
69306 unsigned long flags, struct file *file, long pages)
69307 {
69308 +
69309 +#ifdef CONFIG_PAX_RANDMMAP
69310 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
69311 +#endif
69312 +
69313 mm->total_vm += pages;
69314 }
69315 #endif /* CONFIG_PROC_FS */
69316 @@ -1725,7 +1740,7 @@ extern int unpoison_memory(unsigned long pfn);
69317 extern int sysctl_memory_failure_early_kill;
69318 extern int sysctl_memory_failure_recovery;
69319 extern void shake_page(struct page *p, int access);
69320 -extern atomic_long_t num_poisoned_pages;
69321 +extern atomic_long_unchecked_t num_poisoned_pages;
69322 extern int soft_offline_page(struct page *page, int flags);
69323
69324 extern void dump_page(struct page *page);
69325 @@ -1756,5 +1771,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
69326 static inline bool page_is_guard(struct page *page) { return false; }
69327 #endif /* CONFIG_DEBUG_PAGEALLOC */
69328
69329 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
69330 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
69331 +#else
69332 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
69333 +#endif
69334 +
69335 #endif /* __KERNEL__ */
69336 #endif /* _LINUX_MM_H */
69337 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
69338 index ace9a5f..81bdb59 100644
69339 --- a/include/linux/mm_types.h
69340 +++ b/include/linux/mm_types.h
69341 @@ -289,6 +289,8 @@ struct vm_area_struct {
69342 #ifdef CONFIG_NUMA
69343 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
69344 #endif
69345 +
69346 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
69347 };
69348
69349 struct core_thread {
69350 @@ -437,6 +439,24 @@ struct mm_struct {
69351 int first_nid;
69352 #endif
69353 struct uprobes_state uprobes_state;
69354 +
69355 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
69356 + unsigned long pax_flags;
69357 +#endif
69358 +
69359 +#ifdef CONFIG_PAX_DLRESOLVE
69360 + unsigned long call_dl_resolve;
69361 +#endif
69362 +
69363 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
69364 + unsigned long call_syscall;
69365 +#endif
69366 +
69367 +#ifdef CONFIG_PAX_ASLR
69368 + unsigned long delta_mmap; /* randomized offset */
69369 + unsigned long delta_stack; /* randomized offset */
69370 +#endif
69371 +
69372 };
69373
69374 /* first nid will either be a valid NID or one of these values */
69375 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
69376 index c5d5278..f0b68c8 100644
69377 --- a/include/linux/mmiotrace.h
69378 +++ b/include/linux/mmiotrace.h
69379 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
69380 /* Called from ioremap.c */
69381 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
69382 void __iomem *addr);
69383 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
69384 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
69385
69386 /* For anyone to insert markers. Remember trailing newline. */
69387 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
69388 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
69389 {
69390 }
69391
69392 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
69393 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
69394 {
69395 }
69396
69397 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
69398 index c74092e..b663967 100644
69399 --- a/include/linux/mmzone.h
69400 +++ b/include/linux/mmzone.h
69401 @@ -396,7 +396,7 @@ struct zone {
69402 unsigned long flags; /* zone flags, see below */
69403
69404 /* Zone statistics */
69405 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
69406 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
69407
69408 /*
69409 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
69410 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
69411 index 779cf7c..e6768240 100644
69412 --- a/include/linux/mod_devicetable.h
69413 +++ b/include/linux/mod_devicetable.h
69414 @@ -12,7 +12,7 @@
69415 typedef unsigned long kernel_ulong_t;
69416 #endif
69417
69418 -#define PCI_ANY_ID (~0)
69419 +#define PCI_ANY_ID ((__u16)~0)
69420
69421 struct pci_device_id {
69422 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
69423 @@ -138,7 +138,7 @@ struct usb_device_id {
69424 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
69425 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
69426
69427 -#define HID_ANY_ID (~0)
69428 +#define HID_ANY_ID (~0U)
69429 #define HID_BUS_ANY 0xffff
69430 #define HID_GROUP_ANY 0x0000
69431
69432 @@ -464,7 +464,7 @@ struct dmi_system_id {
69433 const char *ident;
69434 struct dmi_strmatch matches[4];
69435 void *driver_data;
69436 -};
69437 +} __do_const;
69438 /*
69439 * struct dmi_device_id appears during expansion of
69440 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
69441 diff --git a/include/linux/module.h b/include/linux/module.h
69442 index ead1b57..81a3b6c 100644
69443 --- a/include/linux/module.h
69444 +++ b/include/linux/module.h
69445 @@ -17,9 +17,11 @@
69446 #include <linux/moduleparam.h>
69447 #include <linux/tracepoint.h>
69448 #include <linux/export.h>
69449 +#include <linux/fs.h>
69450
69451 #include <linux/percpu.h>
69452 #include <asm/module.h>
69453 +#include <asm/pgtable.h>
69454
69455 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
69456 #define MODULE_SIG_STRING "~Module signature appended~\n"
69457 @@ -54,12 +56,13 @@ struct module_attribute {
69458 int (*test)(struct module *);
69459 void (*free)(struct module *);
69460 };
69461 +typedef struct module_attribute __no_const module_attribute_no_const;
69462
69463 struct module_version_attribute {
69464 struct module_attribute mattr;
69465 const char *module_name;
69466 const char *version;
69467 -} __attribute__ ((__aligned__(sizeof(void *))));
69468 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
69469
69470 extern ssize_t __modver_version_show(struct module_attribute *,
69471 struct module_kobject *, char *);
69472 @@ -232,7 +235,7 @@ struct module
69473
69474 /* Sysfs stuff. */
69475 struct module_kobject mkobj;
69476 - struct module_attribute *modinfo_attrs;
69477 + module_attribute_no_const *modinfo_attrs;
69478 const char *version;
69479 const char *srcversion;
69480 struct kobject *holders_dir;
69481 @@ -281,19 +284,16 @@ struct module
69482 int (*init)(void);
69483
69484 /* If this is non-NULL, vfree after init() returns */
69485 - void *module_init;
69486 + void *module_init_rx, *module_init_rw;
69487
69488 /* Here is the actual code + data, vfree'd on unload. */
69489 - void *module_core;
69490 + void *module_core_rx, *module_core_rw;
69491
69492 /* Here are the sizes of the init and core sections */
69493 - unsigned int init_size, core_size;
69494 + unsigned int init_size_rw, core_size_rw;
69495
69496 /* The size of the executable code in each section. */
69497 - unsigned int init_text_size, core_text_size;
69498 -
69499 - /* Size of RO sections of the module (text+rodata) */
69500 - unsigned int init_ro_size, core_ro_size;
69501 + unsigned int init_size_rx, core_size_rx;
69502
69503 /* Arch-specific module values */
69504 struct mod_arch_specific arch;
69505 @@ -349,6 +349,10 @@ struct module
69506 #ifdef CONFIG_EVENT_TRACING
69507 struct ftrace_event_call **trace_events;
69508 unsigned int num_trace_events;
69509 + struct file_operations trace_id;
69510 + struct file_operations trace_enable;
69511 + struct file_operations trace_format;
69512 + struct file_operations trace_filter;
69513 #endif
69514 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
69515 unsigned int num_ftrace_callsites;
69516 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
69517 bool is_module_percpu_address(unsigned long addr);
69518 bool is_module_text_address(unsigned long addr);
69519
69520 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
69521 +{
69522 +
69523 +#ifdef CONFIG_PAX_KERNEXEC
69524 + if (ktla_ktva(addr) >= (unsigned long)start &&
69525 + ktla_ktva(addr) < (unsigned long)start + size)
69526 + return 1;
69527 +#endif
69528 +
69529 + return ((void *)addr >= start && (void *)addr < start + size);
69530 +}
69531 +
69532 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
69533 +{
69534 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
69535 +}
69536 +
69537 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
69538 +{
69539 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
69540 +}
69541 +
69542 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
69543 +{
69544 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
69545 +}
69546 +
69547 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
69548 +{
69549 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
69550 +}
69551 +
69552 static inline int within_module_core(unsigned long addr, const struct module *mod)
69553 {
69554 - return (unsigned long)mod->module_core <= addr &&
69555 - addr < (unsigned long)mod->module_core + mod->core_size;
69556 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
69557 }
69558
69559 static inline int within_module_init(unsigned long addr, const struct module *mod)
69560 {
69561 - return (unsigned long)mod->module_init <= addr &&
69562 - addr < (unsigned long)mod->module_init + mod->init_size;
69563 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
69564 }
69565
69566 /* Search for module by name: must hold module_mutex. */
69567 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
69568 index 560ca53..ef621ef 100644
69569 --- a/include/linux/moduleloader.h
69570 +++ b/include/linux/moduleloader.h
69571 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
69572 sections. Returns NULL on failure. */
69573 void *module_alloc(unsigned long size);
69574
69575 +#ifdef CONFIG_PAX_KERNEXEC
69576 +void *module_alloc_exec(unsigned long size);
69577 +#else
69578 +#define module_alloc_exec(x) module_alloc(x)
69579 +#endif
69580 +
69581 /* Free memory returned from module_alloc. */
69582 void module_free(struct module *mod, void *module_region);
69583
69584 +#ifdef CONFIG_PAX_KERNEXEC
69585 +void module_free_exec(struct module *mod, void *module_region);
69586 +#else
69587 +#define module_free_exec(x, y) module_free((x), (y))
69588 +#endif
69589 +
69590 /*
69591 * Apply the given relocation to the (simplified) ELF. Return -error
69592 * or 0.
69593 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
69594 unsigned int relsec,
69595 struct module *me)
69596 {
69597 +#ifdef CONFIG_MODULES
69598 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
69599 +#endif
69600 return -ENOEXEC;
69601 }
69602 #endif
69603 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
69604 unsigned int relsec,
69605 struct module *me)
69606 {
69607 +#ifdef CONFIG_MODULES
69608 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
69609 +#endif
69610 return -ENOEXEC;
69611 }
69612 #endif
69613 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
69614 index 137b419..fe663ec 100644
69615 --- a/include/linux/moduleparam.h
69616 +++ b/include/linux/moduleparam.h
69617 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
69618 * @len is usually just sizeof(string).
69619 */
69620 #define module_param_string(name, string, len, perm) \
69621 - static const struct kparam_string __param_string_##name \
69622 + static const struct kparam_string __param_string_##name __used \
69623 = { len, string }; \
69624 __module_param_call(MODULE_PARAM_PREFIX, name, \
69625 &param_ops_string, \
69626 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
69627 */
69628 #define module_param_array_named(name, array, type, nump, perm) \
69629 param_check_##type(name, &(array)[0]); \
69630 - static const struct kparam_array __param_arr_##name \
69631 + static const struct kparam_array __param_arr_##name __used \
69632 = { .max = ARRAY_SIZE(array), .num = nump, \
69633 .ops = &param_ops_##type, \
69634 .elemsize = sizeof(array[0]), .elem = array }; \
69635 diff --git a/include/linux/namei.h b/include/linux/namei.h
69636 index 5a5ff57..5ae5070 100644
69637 --- a/include/linux/namei.h
69638 +++ b/include/linux/namei.h
69639 @@ -19,7 +19,7 @@ struct nameidata {
69640 unsigned seq;
69641 int last_type;
69642 unsigned depth;
69643 - char *saved_names[MAX_NESTED_LINKS + 1];
69644 + const char *saved_names[MAX_NESTED_LINKS + 1];
69645 };
69646
69647 /*
69648 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
69649
69650 extern void nd_jump_link(struct nameidata *nd, struct path *path);
69651
69652 -static inline void nd_set_link(struct nameidata *nd, char *path)
69653 +static inline void nd_set_link(struct nameidata *nd, const char *path)
69654 {
69655 nd->saved_names[nd->depth] = path;
69656 }
69657
69658 -static inline char *nd_get_link(struct nameidata *nd)
69659 +static inline const char *nd_get_link(const struct nameidata *nd)
69660 {
69661 return nd->saved_names[nd->depth];
69662 }
69663 diff --git a/include/linux/net.h b/include/linux/net.h
69664 index aa16731..514b875 100644
69665 --- a/include/linux/net.h
69666 +++ b/include/linux/net.h
69667 @@ -183,7 +183,7 @@ struct net_proto_family {
69668 int (*create)(struct net *net, struct socket *sock,
69669 int protocol, int kern);
69670 struct module *owner;
69671 -};
69672 +} __do_const;
69673
69674 struct iovec;
69675 struct kvec;
69676 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
69677 index 6151e90..2e0afb0 100644
69678 --- a/include/linux/netdevice.h
69679 +++ b/include/linux/netdevice.h
69680 @@ -1028,6 +1028,7 @@ struct net_device_ops {
69681 int (*ndo_change_carrier)(struct net_device *dev,
69682 bool new_carrier);
69683 };
69684 +typedef struct net_device_ops __no_const net_device_ops_no_const;
69685
69686 /*
69687 * The DEVICE structure.
69688 @@ -1094,7 +1095,7 @@ struct net_device {
69689 int iflink;
69690
69691 struct net_device_stats stats;
69692 - atomic_long_t rx_dropped; /* dropped packets by core network
69693 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
69694 * Do not use this in drivers.
69695 */
69696
69697 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
69698 index ee14284..bc65d63 100644
69699 --- a/include/linux/netfilter.h
69700 +++ b/include/linux/netfilter.h
69701 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
69702 #endif
69703 /* Use the module struct to lock set/get code in place */
69704 struct module *owner;
69705 -};
69706 +} __do_const;
69707
69708 /* Function to register/unregister hook points. */
69709 int nf_register_hook(struct nf_hook_ops *reg);
69710 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
69711 index 7958e84..ed74d7a 100644
69712 --- a/include/linux/netfilter/ipset/ip_set.h
69713 +++ b/include/linux/netfilter/ipset/ip_set.h
69714 @@ -98,7 +98,7 @@ struct ip_set_type_variant {
69715 /* Return true if "b" set is the same as "a"
69716 * according to the create set parameters */
69717 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
69718 -};
69719 +} __do_const;
69720
69721 /* The core set type structure */
69722 struct ip_set_type {
69723 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
69724 index ecbb8e4..8a1c4e1 100644
69725 --- a/include/linux/netfilter/nfnetlink.h
69726 +++ b/include/linux/netfilter/nfnetlink.h
69727 @@ -16,7 +16,7 @@ struct nfnl_callback {
69728 const struct nlattr * const cda[]);
69729 const struct nla_policy *policy; /* netlink attribute policy */
69730 const u_int16_t attr_count; /* number of nlattr's */
69731 -};
69732 +} __do_const;
69733
69734 struct nfnetlink_subsystem {
69735 const char *name;
69736 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
69737 new file mode 100644
69738 index 0000000..33f4af8
69739 --- /dev/null
69740 +++ b/include/linux/netfilter/xt_gradm.h
69741 @@ -0,0 +1,9 @@
69742 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
69743 +#define _LINUX_NETFILTER_XT_GRADM_H 1
69744 +
69745 +struct xt_gradm_mtinfo {
69746 + __u16 flags;
69747 + __u16 invflags;
69748 +};
69749 +
69750 +#endif
69751 diff --git a/include/linux/nls.h b/include/linux/nls.h
69752 index 5dc635f..35f5e11 100644
69753 --- a/include/linux/nls.h
69754 +++ b/include/linux/nls.h
69755 @@ -31,7 +31,7 @@ struct nls_table {
69756 const unsigned char *charset2upper;
69757 struct module *owner;
69758 struct nls_table *next;
69759 -};
69760 +} __do_const;
69761
69762 /* this value hold the maximum octet of charset */
69763 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
69764 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
69765 index d65746e..62e72c2 100644
69766 --- a/include/linux/notifier.h
69767 +++ b/include/linux/notifier.h
69768 @@ -51,7 +51,8 @@ struct notifier_block {
69769 int (*notifier_call)(struct notifier_block *, unsigned long, void *);
69770 struct notifier_block __rcu *next;
69771 int priority;
69772 -};
69773 +} __do_const;
69774 +typedef struct notifier_block __no_const notifier_block_no_const;
69775
69776 struct atomic_notifier_head {
69777 spinlock_t lock;
69778 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
69779 index a4c5624..79d6d88 100644
69780 --- a/include/linux/oprofile.h
69781 +++ b/include/linux/oprofile.h
69782 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
69783 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
69784 char const * name, ulong * val);
69785
69786 -/** Create a file for read-only access to an atomic_t. */
69787 +/** Create a file for read-only access to an atomic_unchecked_t. */
69788 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
69789 - char const * name, atomic_t * val);
69790 + char const * name, atomic_unchecked_t * val);
69791
69792 /** create a directory */
69793 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
69794 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
69795 index 45fc162..01a4068 100644
69796 --- a/include/linux/pci_hotplug.h
69797 +++ b/include/linux/pci_hotplug.h
69798 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
69799 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
69800 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
69801 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
69802 -};
69803 +} __do_const;
69804 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
69805
69806 /**
69807 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
69808 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
69809 index 1d795df..5df1246 100644
69810 --- a/include/linux/perf_event.h
69811 +++ b/include/linux/perf_event.h
69812 @@ -333,8 +333,8 @@ struct perf_event {
69813
69814 enum perf_event_active_state state;
69815 unsigned int attach_state;
69816 - local64_t count;
69817 - atomic64_t child_count;
69818 + local64_t count; /* PaX: fix it one day */
69819 + atomic64_unchecked_t child_count;
69820
69821 /*
69822 * These are the total time in nanoseconds that the event
69823 @@ -385,8 +385,8 @@ struct perf_event {
69824 * These accumulate total time (in nanoseconds) that children
69825 * events have been enabled and running, respectively.
69826 */
69827 - atomic64_t child_total_time_enabled;
69828 - atomic64_t child_total_time_running;
69829 + atomic64_unchecked_t child_total_time_enabled;
69830 + atomic64_unchecked_t child_total_time_running;
69831
69832 /*
69833 * Protect attach/detach and child_list:
69834 @@ -812,7 +812,7 @@ static inline void perf_restore_debug_store(void) { }
69835 */
69836 #define perf_cpu_notifier(fn) \
69837 do { \
69838 - static struct notifier_block fn##_nb __cpuinitdata = \
69839 + static struct notifier_block fn##_nb = \
69840 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
69841 unsigned long cpu = smp_processor_id(); \
69842 unsigned long flags; \
69843 @@ -831,7 +831,7 @@ do { \
69844 struct perf_pmu_events_attr {
69845 struct device_attribute attr;
69846 u64 id;
69847 -};
69848 +} __do_const;
69849
69850 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
69851 static struct perf_pmu_events_attr _var = { \
69852 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
69853 index ad1a427..6419649 100644
69854 --- a/include/linux/pipe_fs_i.h
69855 +++ b/include/linux/pipe_fs_i.h
69856 @@ -45,9 +45,9 @@ struct pipe_buffer {
69857 struct pipe_inode_info {
69858 wait_queue_head_t wait;
69859 unsigned int nrbufs, curbuf, buffers;
69860 - unsigned int readers;
69861 - unsigned int writers;
69862 - unsigned int waiting_writers;
69863 + atomic_t readers;
69864 + atomic_t writers;
69865 + atomic_t waiting_writers;
69866 unsigned int r_counter;
69867 unsigned int w_counter;
69868 struct page *tmp_page;
69869 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
69870 index 5f28cae..3d23723 100644
69871 --- a/include/linux/platform_data/usb-ehci-s5p.h
69872 +++ b/include/linux/platform_data/usb-ehci-s5p.h
69873 @@ -14,7 +14,7 @@
69874 struct s5p_ehci_platdata {
69875 int (*phy_init)(struct platform_device *pdev, int type);
69876 int (*phy_exit)(struct platform_device *pdev, int type);
69877 -};
69878 +} __no_const;
69879
69880 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
69881
69882 diff --git a/include/linux/platform_data/usb-exynos.h b/include/linux/platform_data/usb-exynos.h
69883 index c256c59..8ea94c7 100644
69884 --- a/include/linux/platform_data/usb-exynos.h
69885 +++ b/include/linux/platform_data/usb-exynos.h
69886 @@ -14,7 +14,7 @@
69887 struct exynos4_ohci_platdata {
69888 int (*phy_init)(struct platform_device *pdev, int type);
69889 int (*phy_exit)(struct platform_device *pdev, int type);
69890 -};
69891 +} __no_const;
69892
69893 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
69894
69895 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
69896 index 7c1d252..c5c773e 100644
69897 --- a/include/linux/pm_domain.h
69898 +++ b/include/linux/pm_domain.h
69899 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
69900
69901 struct gpd_cpu_data {
69902 unsigned int saved_exit_latency;
69903 - struct cpuidle_state *idle_state;
69904 + cpuidle_state_no_const *idle_state;
69905 };
69906
69907 struct generic_pm_domain {
69908 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
69909 index 7d7e09e..8671ef8 100644
69910 --- a/include/linux/pm_runtime.h
69911 +++ b/include/linux/pm_runtime.h
69912 @@ -104,7 +104,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
69913
69914 static inline void pm_runtime_mark_last_busy(struct device *dev)
69915 {
69916 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
69917 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
69918 }
69919
69920 #else /* !CONFIG_PM_RUNTIME */
69921 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
69922 index 195aafc..49a7bc2 100644
69923 --- a/include/linux/pnp.h
69924 +++ b/include/linux/pnp.h
69925 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
69926 struct pnp_fixup {
69927 char id[7];
69928 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
69929 -};
69930 +} __do_const;
69931
69932 /* config parameters */
69933 #define PNP_CONFIG_NORMAL 0x0001
69934 diff --git a/include/linux/poison.h b/include/linux/poison.h
69935 index 2110a81..13a11bb 100644
69936 --- a/include/linux/poison.h
69937 +++ b/include/linux/poison.h
69938 @@ -19,8 +19,8 @@
69939 * under normal circumstances, used to verify that nobody uses
69940 * non-initialized list entries.
69941 */
69942 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
69943 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
69944 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
69945 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
69946
69947 /********** include/linux/timer.h **********/
69948 /*
69949 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
69950 index c0f44c2..1572583 100644
69951 --- a/include/linux/power/smartreflex.h
69952 +++ b/include/linux/power/smartreflex.h
69953 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
69954 int (*notify)(struct omap_sr *sr, u32 status);
69955 u8 notify_flags;
69956 u8 class_type;
69957 -};
69958 +} __do_const;
69959
69960 /**
69961 * struct omap_sr_nvalue_table - Smartreflex n-target value info
69962 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
69963 index 4ea1d37..80f4b33 100644
69964 --- a/include/linux/ppp-comp.h
69965 +++ b/include/linux/ppp-comp.h
69966 @@ -84,7 +84,7 @@ struct compressor {
69967 struct module *owner;
69968 /* Extra skb space needed by the compressor algorithm */
69969 unsigned int comp_extra;
69970 -};
69971 +} __do_const;
69972
69973 /*
69974 * The return value from decompress routine is the length of the
69975 diff --git a/include/linux/printk.h b/include/linux/printk.h
69976 index 822171f..12b30e8 100644
69977 --- a/include/linux/printk.h
69978 +++ b/include/linux/printk.h
69979 @@ -98,6 +98,8 @@ int no_printk(const char *fmt, ...)
69980 extern asmlinkage __printf(1, 2)
69981 void early_printk(const char *fmt, ...);
69982
69983 +extern int kptr_restrict;
69984 +
69985 #ifdef CONFIG_PRINTK
69986 asmlinkage __printf(5, 0)
69987 int vprintk_emit(int facility, int level,
69988 @@ -132,7 +134,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
69989
69990 extern int printk_delay_msec;
69991 extern int dmesg_restrict;
69992 -extern int kptr_restrict;
69993
69994 extern void wake_up_klogd(void);
69995
69996 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
69997 index 94dfb2a..88b9d3b 100644
69998 --- a/include/linux/proc_fs.h
69999 +++ b/include/linux/proc_fs.h
70000 @@ -165,6 +165,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
70001 return proc_create_data(name, mode, parent, proc_fops, NULL);
70002 }
70003
70004 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
70005 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
70006 +{
70007 +#ifdef CONFIG_GRKERNSEC_PROC_USER
70008 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
70009 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
70010 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
70011 +#else
70012 + return proc_create_data(name, mode, parent, proc_fops, NULL);
70013 +#endif
70014 +}
70015 +
70016 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
70017 umode_t mode, struct proc_dir_entry *base,
70018 read_proc_t *read_proc, void * data)
70019 @@ -266,7 +278,7 @@ struct proc_ns_operations {
70020 void (*put)(void *ns);
70021 int (*install)(struct nsproxy *nsproxy, void *ns);
70022 unsigned int (*inum)(void *ns);
70023 -};
70024 +} __do_const;
70025 extern const struct proc_ns_operations netns_operations;
70026 extern const struct proc_ns_operations utsns_operations;
70027 extern const struct proc_ns_operations ipcns_operations;
70028 diff --git a/include/linux/random.h b/include/linux/random.h
70029 index 347ce55..880f97c 100644
70030 --- a/include/linux/random.h
70031 +++ b/include/linux/random.h
70032 @@ -39,6 +39,11 @@ void prandom_seed(u32 seed);
70033 u32 prandom_u32_state(struct rnd_state *);
70034 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
70035
70036 +static inline unsigned long pax_get_random_long(void)
70037 +{
70038 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
70039 +}
70040 +
70041 /*
70042 * Handle minimum values for seeds
70043 */
70044 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
70045 index 8089e35..3a0d59a 100644
70046 --- a/include/linux/rculist.h
70047 +++ b/include/linux/rculist.h
70048 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
70049 struct list_head *prev, struct list_head *next);
70050 #endif
70051
70052 +extern void __pax_list_add_rcu(struct list_head *new,
70053 + struct list_head *prev, struct list_head *next);
70054 +
70055 /**
70056 * list_add_rcu - add a new entry to rcu-protected list
70057 * @new: new entry to be added
70058 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
70059 __list_add_rcu(new, head, head->next);
70060 }
70061
70062 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
70063 +{
70064 + __pax_list_add_rcu(new, head, head->next);
70065 +}
70066 +
70067 /**
70068 * list_add_tail_rcu - add a new entry to rcu-protected list
70069 * @new: new entry to be added
70070 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
70071 __list_add_rcu(new, head->prev, head);
70072 }
70073
70074 +static inline void pax_list_add_tail_rcu(struct list_head *new,
70075 + struct list_head *head)
70076 +{
70077 + __pax_list_add_rcu(new, head->prev, head);
70078 +}
70079 +
70080 /**
70081 * list_del_rcu - deletes entry from list without re-initialization
70082 * @entry: the element to delete from the list.
70083 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
70084 entry->prev = LIST_POISON2;
70085 }
70086
70087 +extern void pax_list_del_rcu(struct list_head *entry);
70088 +
70089 /**
70090 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
70091 * @n: the element to delete from the hash list.
70092 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
70093 index 23b3630..e1bc12b 100644
70094 --- a/include/linux/reboot.h
70095 +++ b/include/linux/reboot.h
70096 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
70097 * Architecture-specific implementations of sys_reboot commands.
70098 */
70099
70100 -extern void machine_restart(char *cmd);
70101 -extern void machine_halt(void);
70102 -extern void machine_power_off(void);
70103 +extern void machine_restart(char *cmd) __noreturn;
70104 +extern void machine_halt(void) __noreturn;
70105 +extern void machine_power_off(void) __noreturn;
70106
70107 extern void machine_shutdown(void);
70108 struct pt_regs;
70109 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
70110 */
70111
70112 extern void kernel_restart_prepare(char *cmd);
70113 -extern void kernel_restart(char *cmd);
70114 -extern void kernel_halt(void);
70115 -extern void kernel_power_off(void);
70116 +extern void kernel_restart(char *cmd) __noreturn;
70117 +extern void kernel_halt(void) __noreturn;
70118 +extern void kernel_power_off(void) __noreturn;
70119
70120 extern int C_A_D; /* for sysctl */
70121 void ctrl_alt_del(void);
70122 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
70123 * Emergency restart, callable from an interrupt handler.
70124 */
70125
70126 -extern void emergency_restart(void);
70127 +extern void emergency_restart(void) __noreturn;
70128 #include <asm/emergency-restart.h>
70129
70130 #endif /* _LINUX_REBOOT_H */
70131 diff --git a/include/linux/regset.h b/include/linux/regset.h
70132 index 8e0c9fe..ac4d221 100644
70133 --- a/include/linux/regset.h
70134 +++ b/include/linux/regset.h
70135 @@ -161,7 +161,8 @@ struct user_regset {
70136 unsigned int align;
70137 unsigned int bias;
70138 unsigned int core_note_type;
70139 -};
70140 +} __do_const;
70141 +typedef struct user_regset __no_const user_regset_no_const;
70142
70143 /**
70144 * struct user_regset_view - available regsets
70145 diff --git a/include/linux/relay.h b/include/linux/relay.h
70146 index 91cacc3..b55ff74 100644
70147 --- a/include/linux/relay.h
70148 +++ b/include/linux/relay.h
70149 @@ -160,7 +160,7 @@ struct rchan_callbacks
70150 * The callback should return 0 if successful, negative if not.
70151 */
70152 int (*remove_buf_file)(struct dentry *dentry);
70153 -};
70154 +} __no_const;
70155
70156 /*
70157 * CONFIG_RELAY kernel API, kernel/relay.c
70158 diff --git a/include/linux/rio.h b/include/linux/rio.h
70159 index a3e7842..d973ca6 100644
70160 --- a/include/linux/rio.h
70161 +++ b/include/linux/rio.h
70162 @@ -339,7 +339,7 @@ struct rio_ops {
70163 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
70164 u64 rstart, u32 size, u32 flags);
70165 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
70166 -};
70167 +} __no_const;
70168
70169 #define RIO_RESOURCE_MEM 0x00000100
70170 #define RIO_RESOURCE_DOORBELL 0x00000200
70171 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
70172 index 6dacb93..6174423 100644
70173 --- a/include/linux/rmap.h
70174 +++ b/include/linux/rmap.h
70175 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
70176 void anon_vma_init(void); /* create anon_vma_cachep */
70177 int anon_vma_prepare(struct vm_area_struct *);
70178 void unlink_anon_vmas(struct vm_area_struct *);
70179 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
70180 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
70181 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
70182 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
70183
70184 static inline void anon_vma_merge(struct vm_area_struct *vma,
70185 struct vm_area_struct *next)
70186 diff --git a/include/linux/sched.h b/include/linux/sched.h
70187 index be4e742..7f9d593 100644
70188 --- a/include/linux/sched.h
70189 +++ b/include/linux/sched.h
70190 @@ -62,6 +62,7 @@ struct bio_list;
70191 struct fs_struct;
70192 struct perf_event_context;
70193 struct blk_plug;
70194 +struct linux_binprm;
70195
70196 /*
70197 * List of flags we want to share for kernel threads,
70198 @@ -315,7 +316,7 @@ extern char __sched_text_start[], __sched_text_end[];
70199 extern int in_sched_functions(unsigned long addr);
70200
70201 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
70202 -extern signed long schedule_timeout(signed long timeout);
70203 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
70204 extern signed long schedule_timeout_interruptible(signed long timeout);
70205 extern signed long schedule_timeout_killable(signed long timeout);
70206 extern signed long schedule_timeout_uninterruptible(signed long timeout);
70207 @@ -329,6 +330,18 @@ struct user_namespace;
70208 #include <linux/aio.h>
70209
70210 #ifdef CONFIG_MMU
70211 +
70212 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
70213 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
70214 +#else
70215 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
70216 +{
70217 + return 0;
70218 +}
70219 +#endif
70220 +
70221 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
70222 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
70223 extern void arch_pick_mmap_layout(struct mm_struct *mm);
70224 extern unsigned long
70225 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
70226 @@ -605,6 +618,17 @@ struct signal_struct {
70227 #ifdef CONFIG_TASKSTATS
70228 struct taskstats *stats;
70229 #endif
70230 +
70231 +#ifdef CONFIG_GRKERNSEC
70232 + u32 curr_ip;
70233 + u32 saved_ip;
70234 + u32 gr_saddr;
70235 + u32 gr_daddr;
70236 + u16 gr_sport;
70237 + u16 gr_dport;
70238 + u8 used_accept:1;
70239 +#endif
70240 +
70241 #ifdef CONFIG_AUDIT
70242 unsigned audit_tty;
70243 struct tty_audit_buf *tty_audit_buf;
70244 @@ -683,6 +707,11 @@ struct user_struct {
70245 struct key *session_keyring; /* UID's default session keyring */
70246 #endif
70247
70248 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
70249 + unsigned int banned;
70250 + unsigned long ban_expires;
70251 +#endif
70252 +
70253 /* Hash table maintenance information */
70254 struct hlist_node uidhash_node;
70255 kuid_t uid;
70256 @@ -1082,7 +1111,7 @@ struct sched_class {
70257 #ifdef CONFIG_FAIR_GROUP_SCHED
70258 void (*task_move_group) (struct task_struct *p, int on_rq);
70259 #endif
70260 -};
70261 +} __do_const;
70262
70263 struct load_weight {
70264 unsigned long weight, inv_weight;
70265 @@ -1323,8 +1352,8 @@ struct task_struct {
70266 struct list_head thread_group;
70267
70268 struct completion *vfork_done; /* for vfork() */
70269 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
70270 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
70271 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
70272 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
70273
70274 cputime_t utime, stime, utimescaled, stimescaled;
70275 cputime_t gtime;
70276 @@ -1349,11 +1378,6 @@ struct task_struct {
70277 struct task_cputime cputime_expires;
70278 struct list_head cpu_timers[3];
70279
70280 -/* process credentials */
70281 - const struct cred __rcu *real_cred; /* objective and real subjective task
70282 - * credentials (COW) */
70283 - const struct cred __rcu *cred; /* effective (overridable) subjective task
70284 - * credentials (COW) */
70285 char comm[TASK_COMM_LEN]; /* executable name excluding path
70286 - access with [gs]et_task_comm (which lock
70287 it with task_lock())
70288 @@ -1370,6 +1394,10 @@ struct task_struct {
70289 #endif
70290 /* CPU-specific state of this task */
70291 struct thread_struct thread;
70292 +/* thread_info moved to task_struct */
70293 +#ifdef CONFIG_X86
70294 + struct thread_info tinfo;
70295 +#endif
70296 /* filesystem information */
70297 struct fs_struct *fs;
70298 /* open file information */
70299 @@ -1443,6 +1471,10 @@ struct task_struct {
70300 gfp_t lockdep_reclaim_gfp;
70301 #endif
70302
70303 +/* process credentials */
70304 + const struct cred __rcu *real_cred; /* objective and real subjective task
70305 + * credentials (COW) */
70306 +
70307 /* journalling filesystem info */
70308 void *journal_info;
70309
70310 @@ -1481,6 +1513,10 @@ struct task_struct {
70311 /* cg_list protected by css_set_lock and tsk->alloc_lock */
70312 struct list_head cg_list;
70313 #endif
70314 +
70315 + const struct cred __rcu *cred; /* effective (overridable) subjective task
70316 + * credentials (COW) */
70317 +
70318 #ifdef CONFIG_FUTEX
70319 struct robust_list_head __user *robust_list;
70320 #ifdef CONFIG_COMPAT
70321 @@ -1577,8 +1613,74 @@ struct task_struct {
70322 #ifdef CONFIG_UPROBES
70323 struct uprobe_task *utask;
70324 #endif
70325 +
70326 +#ifdef CONFIG_GRKERNSEC
70327 + /* grsecurity */
70328 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
70329 + u64 exec_id;
70330 +#endif
70331 +#ifdef CONFIG_GRKERNSEC_SETXID
70332 + const struct cred *delayed_cred;
70333 +#endif
70334 + struct dentry *gr_chroot_dentry;
70335 + struct acl_subject_label *acl;
70336 + struct acl_role_label *role;
70337 + struct file *exec_file;
70338 + unsigned long brute_expires;
70339 + u16 acl_role_id;
70340 + /* is this the task that authenticated to the special role */
70341 + u8 acl_sp_role;
70342 + u8 is_writable;
70343 + u8 brute;
70344 + u8 gr_is_chrooted;
70345 +#endif
70346 +
70347 };
70348
70349 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
70350 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
70351 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
70352 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
70353 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
70354 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
70355 +
70356 +#ifdef CONFIG_PAX_SOFTMODE
70357 +extern int pax_softmode;
70358 +#endif
70359 +
70360 +extern int pax_check_flags(unsigned long *);
70361 +
70362 +/* if tsk != current then task_lock must be held on it */
70363 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
70364 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
70365 +{
70366 + if (likely(tsk->mm))
70367 + return tsk->mm->pax_flags;
70368 + else
70369 + return 0UL;
70370 +}
70371 +
70372 +/* if tsk != current then task_lock must be held on it */
70373 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
70374 +{
70375 + if (likely(tsk->mm)) {
70376 + tsk->mm->pax_flags = flags;
70377 + return 0;
70378 + }
70379 + return -EINVAL;
70380 +}
70381 +#endif
70382 +
70383 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
70384 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
70385 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
70386 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
70387 +#endif
70388 +
70389 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
70390 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
70391 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
70392 +
70393 /* Future-safe accessor for struct task_struct's cpus_allowed. */
70394 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
70395
70396 @@ -1637,7 +1739,7 @@ struct pid_namespace;
70397 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
70398 struct pid_namespace *ns);
70399
70400 -static inline pid_t task_pid_nr(struct task_struct *tsk)
70401 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
70402 {
70403 return tsk->pid;
70404 }
70405 @@ -2073,7 +2175,9 @@ void yield(void);
70406 extern struct exec_domain default_exec_domain;
70407
70408 union thread_union {
70409 +#ifndef CONFIG_X86
70410 struct thread_info thread_info;
70411 +#endif
70412 unsigned long stack[THREAD_SIZE/sizeof(long)];
70413 };
70414
70415 @@ -2106,6 +2210,7 @@ extern struct pid_namespace init_pid_ns;
70416 */
70417
70418 extern struct task_struct *find_task_by_vpid(pid_t nr);
70419 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
70420 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
70421 struct pid_namespace *ns);
70422
70423 @@ -2272,7 +2377,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
70424 extern void exit_itimers(struct signal_struct *);
70425 extern void flush_itimer_signals(void);
70426
70427 -extern void do_group_exit(int);
70428 +extern __noreturn void do_group_exit(int);
70429
70430 extern int allow_signal(int);
70431 extern int disallow_signal(int);
70432 @@ -2463,9 +2568,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
70433
70434 #endif
70435
70436 -static inline int object_is_on_stack(void *obj)
70437 +static inline int object_starts_on_stack(void *obj)
70438 {
70439 - void *stack = task_stack_page(current);
70440 + const void *stack = task_stack_page(current);
70441
70442 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
70443 }
70444 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
70445 index bf8086b..962b035 100644
70446 --- a/include/linux/sched/sysctl.h
70447 +++ b/include/linux/sched/sysctl.h
70448 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
70449 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
70450
70451 extern int sysctl_max_map_count;
70452 +extern unsigned long sysctl_heap_stack_gap;
70453
70454 extern unsigned int sysctl_sched_latency;
70455 extern unsigned int sysctl_sched_min_granularity;
70456 diff --git a/include/linux/security.h b/include/linux/security.h
70457 index 032c366..2c1c2dc2 100644
70458 --- a/include/linux/security.h
70459 +++ b/include/linux/security.h
70460 @@ -26,6 +26,7 @@
70461 #include <linux/capability.h>
70462 #include <linux/slab.h>
70463 #include <linux/err.h>
70464 +#include <linux/grsecurity.h>
70465
70466 struct linux_binprm;
70467 struct cred;
70468 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
70469 index 68a04a3..866e6a1 100644
70470 --- a/include/linux/seq_file.h
70471 +++ b/include/linux/seq_file.h
70472 @@ -26,6 +26,9 @@ struct seq_file {
70473 struct mutex lock;
70474 const struct seq_operations *op;
70475 int poll_event;
70476 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
70477 + u64 exec_id;
70478 +#endif
70479 #ifdef CONFIG_USER_NS
70480 struct user_namespace *user_ns;
70481 #endif
70482 @@ -38,6 +41,7 @@ struct seq_operations {
70483 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
70484 int (*show) (struct seq_file *m, void *v);
70485 };
70486 +typedef struct seq_operations __no_const seq_operations_no_const;
70487
70488 #define SEQ_SKIP 1
70489
70490 diff --git a/include/linux/shm.h b/include/linux/shm.h
70491 index 429c199..4d42e38 100644
70492 --- a/include/linux/shm.h
70493 +++ b/include/linux/shm.h
70494 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
70495
70496 /* The task created the shm object. NULL if the task is dead. */
70497 struct task_struct *shm_creator;
70498 +#ifdef CONFIG_GRKERNSEC
70499 + time_t shm_createtime;
70500 + pid_t shm_lapid;
70501 +#endif
70502 };
70503
70504 /* shm_mode upper byte flags */
70505 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
70506 index b8292d8..96db310 100644
70507 --- a/include/linux/skbuff.h
70508 +++ b/include/linux/skbuff.h
70509 @@ -599,7 +599,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
70510 extern struct sk_buff *__alloc_skb(unsigned int size,
70511 gfp_t priority, int flags, int node);
70512 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
70513 -static inline struct sk_buff *alloc_skb(unsigned int size,
70514 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
70515 gfp_t priority)
70516 {
70517 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
70518 @@ -709,7 +709,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
70519 */
70520 static inline int skb_queue_empty(const struct sk_buff_head *list)
70521 {
70522 - return list->next == (struct sk_buff *)list;
70523 + return list->next == (const struct sk_buff *)list;
70524 }
70525
70526 /**
70527 @@ -722,7 +722,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
70528 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
70529 const struct sk_buff *skb)
70530 {
70531 - return skb->next == (struct sk_buff *)list;
70532 + return skb->next == (const struct sk_buff *)list;
70533 }
70534
70535 /**
70536 @@ -735,7 +735,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
70537 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
70538 const struct sk_buff *skb)
70539 {
70540 - return skb->prev == (struct sk_buff *)list;
70541 + return skb->prev == (const struct sk_buff *)list;
70542 }
70543
70544 /**
70545 @@ -1756,7 +1756,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
70546 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
70547 */
70548 #ifndef NET_SKB_PAD
70549 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
70550 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
70551 #endif
70552
70553 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
70554 @@ -2351,7 +2351,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
70555 int noblock, int *err);
70556 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
70557 struct poll_table_struct *wait);
70558 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
70559 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
70560 int offset, struct iovec *to,
70561 int size);
70562 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
70563 @@ -2641,6 +2641,9 @@ static inline void nf_reset(struct sk_buff *skb)
70564 nf_bridge_put(skb->nf_bridge);
70565 skb->nf_bridge = NULL;
70566 #endif
70567 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
70568 + skb->nf_trace = 0;
70569 +#endif
70570 }
70571
70572 static inline void nf_reset_trace(struct sk_buff *skb)
70573 diff --git a/include/linux/slab.h b/include/linux/slab.h
70574 index 5d168d7..720bff3 100644
70575 --- a/include/linux/slab.h
70576 +++ b/include/linux/slab.h
70577 @@ -12,13 +12,20 @@
70578 #include <linux/gfp.h>
70579 #include <linux/types.h>
70580 #include <linux/workqueue.h>
70581 -
70582 +#include <linux/err.h>
70583
70584 /*
70585 * Flags to pass to kmem_cache_create().
70586 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
70587 */
70588 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
70589 +
70590 +#ifdef CONFIG_PAX_USERCOPY_SLABS
70591 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
70592 +#else
70593 +#define SLAB_USERCOPY 0x00000000UL
70594 +#endif
70595 +
70596 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
70597 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
70598 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
70599 @@ -89,10 +96,13 @@
70600 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
70601 * Both make kfree a no-op.
70602 */
70603 -#define ZERO_SIZE_PTR ((void *)16)
70604 +#define ZERO_SIZE_PTR \
70605 +({ \
70606 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
70607 + (void *)(-MAX_ERRNO-1L); \
70608 +})
70609
70610 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
70611 - (unsigned long)ZERO_SIZE_PTR)
70612 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
70613
70614 /*
70615 * Common fields provided in kmem_cache by all slab allocators
70616 @@ -112,7 +122,7 @@ struct kmem_cache {
70617 unsigned int align; /* Alignment as calculated */
70618 unsigned long flags; /* Active flags on the slab */
70619 const char *name; /* Slab name for sysfs */
70620 - int refcount; /* Use counter */
70621 + atomic_t refcount; /* Use counter */
70622 void (*ctor)(void *); /* Called on object slot creation */
70623 struct list_head list; /* List of all slab caches on the system */
70624 };
70625 @@ -232,6 +242,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
70626 void kfree(const void *);
70627 void kzfree(const void *);
70628 size_t ksize(const void *);
70629 +const char *check_heap_object(const void *ptr, unsigned long n);
70630 +bool is_usercopy_object(const void *ptr);
70631
70632 /*
70633 * Allocator specific definitions. These are mainly used to establish optimized
70634 @@ -311,6 +323,7 @@ size_t ksize(const void *);
70635 * for general use, and so are not documented here. For a full list of
70636 * potential flags, always refer to linux/gfp.h.
70637 */
70638 +
70639 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
70640 {
70641 if (size != 0 && n > SIZE_MAX / size)
70642 @@ -370,7 +383,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
70643 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
70644 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
70645 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
70646 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
70647 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
70648 #define kmalloc_track_caller(size, flags) \
70649 __kmalloc_track_caller(size, flags, _RET_IP_)
70650 #else
70651 @@ -390,7 +403,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
70652 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
70653 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
70654 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
70655 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
70656 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
70657 #define kmalloc_node_track_caller(size, flags, node) \
70658 __kmalloc_node_track_caller(size, flags, node, \
70659 _RET_IP_)
70660 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
70661 index 8bb6e0e..8eb0dbe 100644
70662 --- a/include/linux/slab_def.h
70663 +++ b/include/linux/slab_def.h
70664 @@ -52,7 +52,7 @@ struct kmem_cache {
70665 /* 4) cache creation/removal */
70666 const char *name;
70667 struct list_head list;
70668 - int refcount;
70669 + atomic_t refcount;
70670 int object_size;
70671 int align;
70672
70673 @@ -68,10 +68,10 @@ struct kmem_cache {
70674 unsigned long node_allocs;
70675 unsigned long node_frees;
70676 unsigned long node_overflow;
70677 - atomic_t allochit;
70678 - atomic_t allocmiss;
70679 - atomic_t freehit;
70680 - atomic_t freemiss;
70681 + atomic_unchecked_t allochit;
70682 + atomic_unchecked_t allocmiss;
70683 + atomic_unchecked_t freehit;
70684 + atomic_unchecked_t freemiss;
70685
70686 /*
70687 * If debugging is enabled, then the allocator can add additional
70688 @@ -111,11 +111,16 @@ struct cache_sizes {
70689 #ifdef CONFIG_ZONE_DMA
70690 struct kmem_cache *cs_dmacachep;
70691 #endif
70692 +
70693 +#ifdef CONFIG_PAX_USERCOPY_SLABS
70694 + struct kmem_cache *cs_usercopycachep;
70695 +#endif
70696 +
70697 };
70698 extern struct cache_sizes malloc_sizes[];
70699
70700 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
70701 -void *__kmalloc(size_t size, gfp_t flags);
70702 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
70703
70704 #ifdef CONFIG_TRACING
70705 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
70706 @@ -152,6 +157,13 @@ found:
70707 cachep = malloc_sizes[i].cs_dmacachep;
70708 else
70709 #endif
70710 +
70711 +#ifdef CONFIG_PAX_USERCOPY_SLABS
70712 + if (flags & GFP_USERCOPY)
70713 + cachep = malloc_sizes[i].cs_usercopycachep;
70714 + else
70715 +#endif
70716 +
70717 cachep = malloc_sizes[i].cs_cachep;
70718
70719 ret = kmem_cache_alloc_trace(cachep, flags, size);
70720 @@ -162,7 +174,7 @@ found:
70721 }
70722
70723 #ifdef CONFIG_NUMA
70724 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
70725 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
70726 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
70727
70728 #ifdef CONFIG_TRACING
70729 @@ -205,6 +217,13 @@ found:
70730 cachep = malloc_sizes[i].cs_dmacachep;
70731 else
70732 #endif
70733 +
70734 +#ifdef CONFIG_PAX_USERCOPY_SLABS
70735 + if (flags & GFP_USERCOPY)
70736 + cachep = malloc_sizes[i].cs_usercopycachep;
70737 + else
70738 +#endif
70739 +
70740 cachep = malloc_sizes[i].cs_cachep;
70741
70742 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
70743 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
70744 index f28e14a..7831211 100644
70745 --- a/include/linux/slob_def.h
70746 +++ b/include/linux/slob_def.h
70747 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
70748 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
70749 }
70750
70751 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
70752 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
70753
70754 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
70755 {
70756 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
70757 return __kmalloc_node(size, flags, NUMA_NO_NODE);
70758 }
70759
70760 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
70761 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
70762 {
70763 return kmalloc(size, flags);
70764 }
70765 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
70766 index 9db4825..ed42fb5 100644
70767 --- a/include/linux/slub_def.h
70768 +++ b/include/linux/slub_def.h
70769 @@ -91,7 +91,7 @@ struct kmem_cache {
70770 struct kmem_cache_order_objects max;
70771 struct kmem_cache_order_objects min;
70772 gfp_t allocflags; /* gfp flags to use on each alloc */
70773 - int refcount; /* Refcount for slab cache destroy */
70774 + atomic_t refcount; /* Refcount for slab cache destroy */
70775 void (*ctor)(void *);
70776 int inuse; /* Offset to metadata */
70777 int align; /* Alignment */
70778 @@ -156,7 +156,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
70779 * Sorry that the following has to be that ugly but some versions of GCC
70780 * have trouble with constant propagation and loops.
70781 */
70782 -static __always_inline int kmalloc_index(size_t size)
70783 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
70784 {
70785 if (!size)
70786 return 0;
70787 @@ -221,7 +221,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
70788 }
70789
70790 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
70791 -void *__kmalloc(size_t size, gfp_t flags);
70792 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
70793
70794 static __always_inline void *
70795 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
70796 @@ -265,7 +265,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
70797 }
70798 #endif
70799
70800 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
70801 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
70802 {
70803 unsigned int order = get_order(size);
70804 return kmalloc_order_trace(size, flags, order);
70805 @@ -290,7 +290,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
70806 }
70807
70808 #ifdef CONFIG_NUMA
70809 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
70810 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
70811 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
70812
70813 #ifdef CONFIG_TRACING
70814 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
70815 index e8d702e..0a56eb4 100644
70816 --- a/include/linux/sock_diag.h
70817 +++ b/include/linux/sock_diag.h
70818 @@ -10,7 +10,7 @@ struct sock;
70819 struct sock_diag_handler {
70820 __u8 family;
70821 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
70822 -};
70823 +} __do_const;
70824
70825 int sock_diag_register(const struct sock_diag_handler *h);
70826 void sock_diag_unregister(const struct sock_diag_handler *h);
70827 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
70828 index 680f9a3..f13aeb0 100644
70829 --- a/include/linux/sonet.h
70830 +++ b/include/linux/sonet.h
70831 @@ -7,7 +7,7 @@
70832 #include <uapi/linux/sonet.h>
70833
70834 struct k_sonet_stats {
70835 -#define __HANDLE_ITEM(i) atomic_t i
70836 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
70837 __SONET_ITEMS
70838 #undef __HANDLE_ITEM
70839 };
70840 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
70841 index 07d8e53..dc934c9 100644
70842 --- a/include/linux/sunrpc/addr.h
70843 +++ b/include/linux/sunrpc/addr.h
70844 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
70845 {
70846 switch (sap->sa_family) {
70847 case AF_INET:
70848 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
70849 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
70850 case AF_INET6:
70851 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
70852 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
70853 }
70854 return 0;
70855 }
70856 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
70857 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
70858 const struct sockaddr *src)
70859 {
70860 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
70861 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
70862 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
70863
70864 dsin->sin_family = ssin->sin_family;
70865 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
70866 if (sa->sa_family != AF_INET6)
70867 return 0;
70868
70869 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
70870 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
70871 }
70872
70873 #endif /* _LINUX_SUNRPC_ADDR_H */
70874 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
70875 index 2cf4ffa..470d140 100644
70876 --- a/include/linux/sunrpc/clnt.h
70877 +++ b/include/linux/sunrpc/clnt.h
70878 @@ -96,7 +96,7 @@ struct rpc_procinfo {
70879 unsigned int p_timer; /* Which RTT timer to use */
70880 u32 p_statidx; /* Which procedure to account */
70881 const char * p_name; /* name of procedure */
70882 -};
70883 +} __do_const;
70884
70885 #ifdef __KERNEL__
70886
70887 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
70888 index 1f0216b..6a4fa50 100644
70889 --- a/include/linux/sunrpc/svc.h
70890 +++ b/include/linux/sunrpc/svc.h
70891 @@ -411,7 +411,7 @@ struct svc_procedure {
70892 unsigned int pc_count; /* call count */
70893 unsigned int pc_cachetype; /* cache info (NFS) */
70894 unsigned int pc_xdrressize; /* maximum size of XDR reply */
70895 -};
70896 +} __do_const;
70897
70898 /*
70899 * Function prototypes.
70900 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
70901 index 0b8e3e6..33e0a01 100644
70902 --- a/include/linux/sunrpc/svc_rdma.h
70903 +++ b/include/linux/sunrpc/svc_rdma.h
70904 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
70905 extern unsigned int svcrdma_max_requests;
70906 extern unsigned int svcrdma_max_req_size;
70907
70908 -extern atomic_t rdma_stat_recv;
70909 -extern atomic_t rdma_stat_read;
70910 -extern atomic_t rdma_stat_write;
70911 -extern atomic_t rdma_stat_sq_starve;
70912 -extern atomic_t rdma_stat_rq_starve;
70913 -extern atomic_t rdma_stat_rq_poll;
70914 -extern atomic_t rdma_stat_rq_prod;
70915 -extern atomic_t rdma_stat_sq_poll;
70916 -extern atomic_t rdma_stat_sq_prod;
70917 +extern atomic_unchecked_t rdma_stat_recv;
70918 +extern atomic_unchecked_t rdma_stat_read;
70919 +extern atomic_unchecked_t rdma_stat_write;
70920 +extern atomic_unchecked_t rdma_stat_sq_starve;
70921 +extern atomic_unchecked_t rdma_stat_rq_starve;
70922 +extern atomic_unchecked_t rdma_stat_rq_poll;
70923 +extern atomic_unchecked_t rdma_stat_rq_prod;
70924 +extern atomic_unchecked_t rdma_stat_sq_poll;
70925 +extern atomic_unchecked_t rdma_stat_sq_prod;
70926
70927 #define RPCRDMA_VERSION 1
70928
70929 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
70930 index ff374ab..7fd2ecb 100644
70931 --- a/include/linux/sunrpc/svcauth.h
70932 +++ b/include/linux/sunrpc/svcauth.h
70933 @@ -109,7 +109,7 @@ struct auth_ops {
70934 int (*release)(struct svc_rqst *rq);
70935 void (*domain_release)(struct auth_domain *);
70936 int (*set_client)(struct svc_rqst *rq);
70937 -};
70938 +} __do_const;
70939
70940 #define SVC_GARBAGE 1
70941 #define SVC_SYSERR 2
70942 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
70943 index a5ffd32..0935dea 100644
70944 --- a/include/linux/swiotlb.h
70945 +++ b/include/linux/swiotlb.h
70946 @@ -60,7 +60,8 @@ extern void
70947
70948 extern void
70949 swiotlb_free_coherent(struct device *hwdev, size_t size,
70950 - void *vaddr, dma_addr_t dma_handle);
70951 + void *vaddr, dma_addr_t dma_handle,
70952 + struct dma_attrs *attrs);
70953
70954 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
70955 unsigned long offset, size_t size,
70956 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
70957 index 313a8e0..1da8fc6 100644
70958 --- a/include/linux/syscalls.h
70959 +++ b/include/linux/syscalls.h
70960 @@ -634,7 +634,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
70961 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
70962 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
70963 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
70964 - struct sockaddr __user *, int);
70965 + struct sockaddr __user *, int) __intentional_overflow(0);
70966 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
70967 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
70968 unsigned int vlen, unsigned flags);
70969 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
70970 index 27b3b0b..e093dd9 100644
70971 --- a/include/linux/syscore_ops.h
70972 +++ b/include/linux/syscore_ops.h
70973 @@ -16,7 +16,7 @@ struct syscore_ops {
70974 int (*suspend)(void);
70975 void (*resume)(void);
70976 void (*shutdown)(void);
70977 -};
70978 +} __do_const;
70979
70980 extern void register_syscore_ops(struct syscore_ops *ops);
70981 extern void unregister_syscore_ops(struct syscore_ops *ops);
70982 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
70983 index 14a8ff2..af52bad 100644
70984 --- a/include/linux/sysctl.h
70985 +++ b/include/linux/sysctl.h
70986 @@ -34,13 +34,13 @@ struct ctl_table_root;
70987 struct ctl_table_header;
70988 struct ctl_dir;
70989
70990 -typedef struct ctl_table ctl_table;
70991 -
70992 typedef int proc_handler (struct ctl_table *ctl, int write,
70993 void __user *buffer, size_t *lenp, loff_t *ppos);
70994
70995 extern int proc_dostring(struct ctl_table *, int,
70996 void __user *, size_t *, loff_t *);
70997 +extern int proc_dostring_modpriv(struct ctl_table *, int,
70998 + void __user *, size_t *, loff_t *);
70999 extern int proc_dointvec(struct ctl_table *, int,
71000 void __user *, size_t *, loff_t *);
71001 extern int proc_dointvec_minmax(struct ctl_table *, int,
71002 @@ -115,7 +115,9 @@ struct ctl_table
71003 struct ctl_table_poll *poll;
71004 void *extra1;
71005 void *extra2;
71006 -};
71007 +} __do_const;
71008 +typedef struct ctl_table __no_const ctl_table_no_const;
71009 +typedef struct ctl_table ctl_table;
71010
71011 struct ctl_node {
71012 struct rb_node node;
71013 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
71014 index e2cee22..3ddb921 100644
71015 --- a/include/linux/sysfs.h
71016 +++ b/include/linux/sysfs.h
71017 @@ -31,7 +31,8 @@ struct attribute {
71018 struct lock_class_key *key;
71019 struct lock_class_key skey;
71020 #endif
71021 -};
71022 +} __do_const;
71023 +typedef struct attribute __no_const attribute_no_const;
71024
71025 /**
71026 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
71027 @@ -59,8 +60,8 @@ struct attribute_group {
71028 umode_t (*is_visible)(struct kobject *,
71029 struct attribute *, int);
71030 struct attribute **attrs;
71031 -};
71032 -
71033 +} __do_const;
71034 +typedef struct attribute_group __no_const attribute_group_no_const;
71035
71036
71037 /**
71038 @@ -107,7 +108,8 @@ struct bin_attribute {
71039 char *, loff_t, size_t);
71040 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
71041 struct vm_area_struct *vma);
71042 -};
71043 +} __do_const;
71044 +typedef struct bin_attribute __no_const bin_attribute_no_const;
71045
71046 /**
71047 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
71048 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
71049 index 7faf933..9b85a0c 100644
71050 --- a/include/linux/sysrq.h
71051 +++ b/include/linux/sysrq.h
71052 @@ -16,6 +16,7 @@
71053
71054 #include <linux/errno.h>
71055 #include <linux/types.h>
71056 +#include <linux/compiler.h>
71057
71058 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
71059 #define SYSRQ_DEFAULT_ENABLE 1
71060 @@ -36,7 +37,7 @@ struct sysrq_key_op {
71061 char *help_msg;
71062 char *action_msg;
71063 int enable_mask;
71064 -};
71065 +} __do_const;
71066
71067 #ifdef CONFIG_MAGIC_SYSRQ
71068
71069 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
71070 index e7e0473..7989295 100644
71071 --- a/include/linux/thread_info.h
71072 +++ b/include/linux/thread_info.h
71073 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
71074 #error "no set_restore_sigmask() provided and default one won't work"
71075 #endif
71076
71077 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
71078 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
71079 +{
71080 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
71081 + if (!__builtin_constant_p(n))
71082 +#endif
71083 + __check_object_size(ptr, n, to_user);
71084 +}
71085 +
71086 #endif /* __KERNEL__ */
71087
71088 #endif /* _LINUX_THREAD_INFO_H */
71089 diff --git a/include/linux/tty.h b/include/linux/tty.h
71090 index c75d886..04cb148 100644
71091 --- a/include/linux/tty.h
71092 +++ b/include/linux/tty.h
71093 @@ -194,7 +194,7 @@ struct tty_port {
71094 const struct tty_port_operations *ops; /* Port operations */
71095 spinlock_t lock; /* Lock protecting tty field */
71096 int blocked_open; /* Waiting to open */
71097 - int count; /* Usage count */
71098 + atomic_t count; /* Usage count */
71099 wait_queue_head_t open_wait; /* Open waiters */
71100 wait_queue_head_t close_wait; /* Close waiters */
71101 wait_queue_head_t delta_msr_wait; /* Modem status change */
71102 @@ -515,7 +515,7 @@ extern int tty_port_open(struct tty_port *port,
71103 struct tty_struct *tty, struct file *filp);
71104 static inline int tty_port_users(struct tty_port *port)
71105 {
71106 - return port->count + port->blocked_open;
71107 + return atomic_read(&port->count) + port->blocked_open;
71108 }
71109
71110 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
71111 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
71112 index 756a609..b302dd6 100644
71113 --- a/include/linux/tty_driver.h
71114 +++ b/include/linux/tty_driver.h
71115 @@ -285,7 +285,7 @@ struct tty_operations {
71116 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
71117 #endif
71118 const struct file_operations *proc_fops;
71119 -};
71120 +} __do_const;
71121
71122 struct tty_driver {
71123 int magic; /* magic number for this structure */
71124 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
71125 index 455a0d7..bf97ff5 100644
71126 --- a/include/linux/tty_ldisc.h
71127 +++ b/include/linux/tty_ldisc.h
71128 @@ -146,7 +146,7 @@ struct tty_ldisc_ops {
71129
71130 struct module *owner;
71131
71132 - int refcount;
71133 + atomic_t refcount;
71134 };
71135
71136 struct tty_ldisc {
71137 diff --git a/include/linux/types.h b/include/linux/types.h
71138 index 4d118ba..c3ee9bf 100644
71139 --- a/include/linux/types.h
71140 +++ b/include/linux/types.h
71141 @@ -176,10 +176,26 @@ typedef struct {
71142 int counter;
71143 } atomic_t;
71144
71145 +#ifdef CONFIG_PAX_REFCOUNT
71146 +typedef struct {
71147 + int counter;
71148 +} atomic_unchecked_t;
71149 +#else
71150 +typedef atomic_t atomic_unchecked_t;
71151 +#endif
71152 +
71153 #ifdef CONFIG_64BIT
71154 typedef struct {
71155 long counter;
71156 } atomic64_t;
71157 +
71158 +#ifdef CONFIG_PAX_REFCOUNT
71159 +typedef struct {
71160 + long counter;
71161 +} atomic64_unchecked_t;
71162 +#else
71163 +typedef atomic64_t atomic64_unchecked_t;
71164 +#endif
71165 #endif
71166
71167 struct list_head {
71168 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
71169 index 5ca0951..ab496a5 100644
71170 --- a/include/linux/uaccess.h
71171 +++ b/include/linux/uaccess.h
71172 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
71173 long ret; \
71174 mm_segment_t old_fs = get_fs(); \
71175 \
71176 - set_fs(KERNEL_DS); \
71177 pagefault_disable(); \
71178 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
71179 - pagefault_enable(); \
71180 + set_fs(KERNEL_DS); \
71181 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
71182 set_fs(old_fs); \
71183 + pagefault_enable(); \
71184 ret; \
71185 })
71186
71187 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
71188 index 8e522cbc..aa8572d 100644
71189 --- a/include/linux/uidgid.h
71190 +++ b/include/linux/uidgid.h
71191 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
71192
71193 #endif /* CONFIG_USER_NS */
71194
71195 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
71196 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
71197 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
71198 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
71199 +
71200 #endif /* _LINUX_UIDGID_H */
71201 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
71202 index 99c1b4d..562e6f3 100644
71203 --- a/include/linux/unaligned/access_ok.h
71204 +++ b/include/linux/unaligned/access_ok.h
71205 @@ -4,34 +4,34 @@
71206 #include <linux/kernel.h>
71207 #include <asm/byteorder.h>
71208
71209 -static inline u16 get_unaligned_le16(const void *p)
71210 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
71211 {
71212 - return le16_to_cpup((__le16 *)p);
71213 + return le16_to_cpup((const __le16 *)p);
71214 }
71215
71216 -static inline u32 get_unaligned_le32(const void *p)
71217 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
71218 {
71219 - return le32_to_cpup((__le32 *)p);
71220 + return le32_to_cpup((const __le32 *)p);
71221 }
71222
71223 -static inline u64 get_unaligned_le64(const void *p)
71224 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
71225 {
71226 - return le64_to_cpup((__le64 *)p);
71227 + return le64_to_cpup((const __le64 *)p);
71228 }
71229
71230 -static inline u16 get_unaligned_be16(const void *p)
71231 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
71232 {
71233 - return be16_to_cpup((__be16 *)p);
71234 + return be16_to_cpup((const __be16 *)p);
71235 }
71236
71237 -static inline u32 get_unaligned_be32(const void *p)
71238 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
71239 {
71240 - return be32_to_cpup((__be32 *)p);
71241 + return be32_to_cpup((const __be32 *)p);
71242 }
71243
71244 -static inline u64 get_unaligned_be64(const void *p)
71245 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
71246 {
71247 - return be64_to_cpup((__be64 *)p);
71248 + return be64_to_cpup((const __be64 *)p);
71249 }
71250
71251 static inline void put_unaligned_le16(u16 val, void *p)
71252 diff --git a/include/linux/usb.h b/include/linux/usb.h
71253 index 4d22d0f..8d0e8f8 100644
71254 --- a/include/linux/usb.h
71255 +++ b/include/linux/usb.h
71256 @@ -554,7 +554,7 @@ struct usb_device {
71257 int maxchild;
71258
71259 u32 quirks;
71260 - atomic_t urbnum;
71261 + atomic_unchecked_t urbnum;
71262
71263 unsigned long active_duration;
71264
71265 @@ -1604,7 +1604,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
71266
71267 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
71268 __u8 request, __u8 requesttype, __u16 value, __u16 index,
71269 - void *data, __u16 size, int timeout);
71270 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
71271 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
71272 void *data, int len, int *actual_length, int timeout);
71273 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
71274 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
71275 index c5d36c6..108f4f9 100644
71276 --- a/include/linux/usb/renesas_usbhs.h
71277 +++ b/include/linux/usb/renesas_usbhs.h
71278 @@ -39,7 +39,7 @@ enum {
71279 */
71280 struct renesas_usbhs_driver_callback {
71281 int (*notify_hotplug)(struct platform_device *pdev);
71282 -};
71283 +} __no_const;
71284
71285 /*
71286 * callback functions for platform
71287 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
71288 index 6f8fbcf..8259001 100644
71289 --- a/include/linux/vermagic.h
71290 +++ b/include/linux/vermagic.h
71291 @@ -25,9 +25,35 @@
71292 #define MODULE_ARCH_VERMAGIC ""
71293 #endif
71294
71295 +#ifdef CONFIG_PAX_REFCOUNT
71296 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
71297 +#else
71298 +#define MODULE_PAX_REFCOUNT ""
71299 +#endif
71300 +
71301 +#ifdef CONSTIFY_PLUGIN
71302 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
71303 +#else
71304 +#define MODULE_CONSTIFY_PLUGIN ""
71305 +#endif
71306 +
71307 +#ifdef STACKLEAK_PLUGIN
71308 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
71309 +#else
71310 +#define MODULE_STACKLEAK_PLUGIN ""
71311 +#endif
71312 +
71313 +#ifdef CONFIG_GRKERNSEC
71314 +#define MODULE_GRSEC "GRSEC "
71315 +#else
71316 +#define MODULE_GRSEC ""
71317 +#endif
71318 +
71319 #define VERMAGIC_STRING \
71320 UTS_RELEASE " " \
71321 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
71322 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
71323 - MODULE_ARCH_VERMAGIC
71324 + MODULE_ARCH_VERMAGIC \
71325 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
71326 + MODULE_GRSEC
71327
71328 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
71329 index 6071e91..ca6a489 100644
71330 --- a/include/linux/vmalloc.h
71331 +++ b/include/linux/vmalloc.h
71332 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
71333 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
71334 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
71335 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
71336 +
71337 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
71338 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
71339 +#endif
71340 +
71341 /* bits [20..32] reserved for arch specific ioremap internals */
71342
71343 /*
71344 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
71345 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
71346 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
71347 unsigned long start, unsigned long end, gfp_t gfp_mask,
71348 - pgprot_t prot, int node, const void *caller);
71349 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
71350 extern void vfree(const void *addr);
71351
71352 extern void *vmap(struct page **pages, unsigned int count,
71353 @@ -124,8 +129,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
71354 extern void free_vm_area(struct vm_struct *area);
71355
71356 /* for /dev/kmem */
71357 -extern long vread(char *buf, char *addr, unsigned long count);
71358 -extern long vwrite(char *buf, char *addr, unsigned long count);
71359 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
71360 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
71361
71362 /*
71363 * Internals. Dont't use..
71364 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
71365 index 5fd71a7..e5ef9a9 100644
71366 --- a/include/linux/vmstat.h
71367 +++ b/include/linux/vmstat.h
71368 @@ -95,18 +95,18 @@ static inline void vm_events_fold_cpu(int cpu)
71369 /*
71370 * Zone based page accounting with per cpu differentials.
71371 */
71372 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
71373 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
71374
71375 static inline void zone_page_state_add(long x, struct zone *zone,
71376 enum zone_stat_item item)
71377 {
71378 - atomic_long_add(x, &zone->vm_stat[item]);
71379 - atomic_long_add(x, &vm_stat[item]);
71380 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
71381 + atomic_long_add_unchecked(x, &vm_stat[item]);
71382 }
71383
71384 static inline unsigned long global_page_state(enum zone_stat_item item)
71385 {
71386 - long x = atomic_long_read(&vm_stat[item]);
71387 + long x = atomic_long_read_unchecked(&vm_stat[item]);
71388 #ifdef CONFIG_SMP
71389 if (x < 0)
71390 x = 0;
71391 @@ -117,7 +117,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
71392 static inline unsigned long zone_page_state(struct zone *zone,
71393 enum zone_stat_item item)
71394 {
71395 - long x = atomic_long_read(&zone->vm_stat[item]);
71396 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
71397 #ifdef CONFIG_SMP
71398 if (x < 0)
71399 x = 0;
71400 @@ -134,7 +134,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
71401 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
71402 enum zone_stat_item item)
71403 {
71404 - long x = atomic_long_read(&zone->vm_stat[item]);
71405 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
71406
71407 #ifdef CONFIG_SMP
71408 int cpu;
71409 @@ -226,8 +226,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
71410
71411 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
71412 {
71413 - atomic_long_inc(&zone->vm_stat[item]);
71414 - atomic_long_inc(&vm_stat[item]);
71415 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
71416 + atomic_long_inc_unchecked(&vm_stat[item]);
71417 }
71418
71419 static inline void __inc_zone_page_state(struct page *page,
71420 @@ -238,8 +238,8 @@ static inline void __inc_zone_page_state(struct page *page,
71421
71422 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
71423 {
71424 - atomic_long_dec(&zone->vm_stat[item]);
71425 - atomic_long_dec(&vm_stat[item]);
71426 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
71427 + atomic_long_dec_unchecked(&vm_stat[item]);
71428 }
71429
71430 static inline void __dec_zone_page_state(struct page *page,
71431 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
71432 index fdbafc6..49dfe4f 100644
71433 --- a/include/linux/xattr.h
71434 +++ b/include/linux/xattr.h
71435 @@ -28,7 +28,7 @@ struct xattr_handler {
71436 size_t size, int handler_flags);
71437 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
71438 size_t size, int flags, int handler_flags);
71439 -};
71440 +} __do_const;
71441
71442 struct xattr {
71443 char *name;
71444 @@ -37,6 +37,9 @@ struct xattr {
71445 };
71446
71447 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
71448 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
71449 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
71450 +#endif
71451 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
71452 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
71453 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
71454 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
71455 index 9c5a6b4..09c9438 100644
71456 --- a/include/linux/zlib.h
71457 +++ b/include/linux/zlib.h
71458 @@ -31,6 +31,7 @@
71459 #define _ZLIB_H
71460
71461 #include <linux/zconf.h>
71462 +#include <linux/compiler.h>
71463
71464 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
71465 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
71466 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
71467
71468 /* basic functions */
71469
71470 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
71471 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
71472 /*
71473 Returns the number of bytes that needs to be allocated for a per-
71474 stream workspace with the specified parameters. A pointer to this
71475 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
71476 index 95d1c91..6798cca 100644
71477 --- a/include/media/v4l2-dev.h
71478 +++ b/include/media/v4l2-dev.h
71479 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
71480 int (*mmap) (struct file *, struct vm_area_struct *);
71481 int (*open) (struct file *);
71482 int (*release) (struct file *);
71483 -};
71484 +} __do_const;
71485
71486 /*
71487 * Newer version of video_device, handled by videodev2.c
71488 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
71489 index 4118ad1..cb7e25f 100644
71490 --- a/include/media/v4l2-ioctl.h
71491 +++ b/include/media/v4l2-ioctl.h
71492 @@ -284,7 +284,6 @@ struct v4l2_ioctl_ops {
71493 bool valid_prio, int cmd, void *arg);
71494 };
71495
71496 -
71497 /* v4l debugging and diagnostics */
71498
71499 /* Debug bitmask flags to be used on V4L2 */
71500 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
71501 index adcbb20..62c2559 100644
71502 --- a/include/net/9p/transport.h
71503 +++ b/include/net/9p/transport.h
71504 @@ -57,7 +57,7 @@ struct p9_trans_module {
71505 int (*cancel) (struct p9_client *, struct p9_req_t *req);
71506 int (*zc_request)(struct p9_client *, struct p9_req_t *,
71507 char *, char *, int , int, int, int);
71508 -};
71509 +} __do_const;
71510
71511 void v9fs_register_trans(struct p9_trans_module *m);
71512 void v9fs_unregister_trans(struct p9_trans_module *m);
71513 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
71514 index cdd3302..76f8ede 100644
71515 --- a/include/net/bluetooth/l2cap.h
71516 +++ b/include/net/bluetooth/l2cap.h
71517 @@ -551,7 +551,7 @@ struct l2cap_ops {
71518 void (*defer) (struct l2cap_chan *chan);
71519 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
71520 unsigned long len, int nb);
71521 -};
71522 +} __do_const;
71523
71524 struct l2cap_conn {
71525 struct hci_conn *hcon;
71526 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
71527 index 9e5425b..8136ffc 100644
71528 --- a/include/net/caif/cfctrl.h
71529 +++ b/include/net/caif/cfctrl.h
71530 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
71531 void (*radioset_rsp)(void);
71532 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
71533 struct cflayer *client_layer);
71534 -};
71535 +} __no_const;
71536
71537 /* Link Setup Parameters for CAIF-Links. */
71538 struct cfctrl_link_param {
71539 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
71540 struct cfctrl {
71541 struct cfsrvl serv;
71542 struct cfctrl_rsp res;
71543 - atomic_t req_seq_no;
71544 - atomic_t rsp_seq_no;
71545 + atomic_unchecked_t req_seq_no;
71546 + atomic_unchecked_t rsp_seq_no;
71547 struct list_head list;
71548 /* Protects from simultaneous access to first_req list */
71549 spinlock_t info_list_lock;
71550 diff --git a/include/net/flow.h b/include/net/flow.h
71551 index 628e11b..4c475df 100644
71552 --- a/include/net/flow.h
71553 +++ b/include/net/flow.h
71554 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
71555
71556 extern void flow_cache_flush(void);
71557 extern void flow_cache_flush_deferred(void);
71558 -extern atomic_t flow_cache_genid;
71559 +extern atomic_unchecked_t flow_cache_genid;
71560
71561 #endif
71562 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
71563 index bdfbe68..4402ebe 100644
71564 --- a/include/net/genetlink.h
71565 +++ b/include/net/genetlink.h
71566 @@ -118,7 +118,7 @@ struct genl_ops {
71567 struct netlink_callback *cb);
71568 int (*done)(struct netlink_callback *cb);
71569 struct list_head ops_list;
71570 -};
71571 +} __do_const;
71572
71573 extern int genl_register_family(struct genl_family *family);
71574 extern int genl_register_family_with_ops(struct genl_family *family,
71575 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
71576 index 734d9b5..48a9a4b 100644
71577 --- a/include/net/gro_cells.h
71578 +++ b/include/net/gro_cells.h
71579 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
71580 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
71581
71582 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
71583 - atomic_long_inc(&dev->rx_dropped);
71584 + atomic_long_inc_unchecked(&dev->rx_dropped);
71585 kfree_skb(skb);
71586 return;
71587 }
71588 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
71589 index 1832927..ce39aea 100644
71590 --- a/include/net/inet_connection_sock.h
71591 +++ b/include/net/inet_connection_sock.h
71592 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
71593 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
71594 int (*bind_conflict)(const struct sock *sk,
71595 const struct inet_bind_bucket *tb, bool relax);
71596 -};
71597 +} __do_const;
71598
71599 /** inet_connection_sock - INET connection oriented sock
71600 *
71601 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
71602 index 53f464d..ba76aaa 100644
71603 --- a/include/net/inetpeer.h
71604 +++ b/include/net/inetpeer.h
71605 @@ -47,8 +47,8 @@ struct inet_peer {
71606 */
71607 union {
71608 struct {
71609 - atomic_t rid; /* Frag reception counter */
71610 - atomic_t ip_id_count; /* IP ID for the next packet */
71611 + atomic_unchecked_t rid; /* Frag reception counter */
71612 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
71613 };
71614 struct rcu_head rcu;
71615 struct inet_peer *gc_next;
71616 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
71617 more++;
71618 inet_peer_refcheck(p);
71619 do {
71620 - old = atomic_read(&p->ip_id_count);
71621 + old = atomic_read_unchecked(&p->ip_id_count);
71622 new = old + more;
71623 if (!new)
71624 new = 1;
71625 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
71626 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
71627 return new;
71628 }
71629
71630 diff --git a/include/net/ip.h b/include/net/ip.h
71631 index a68f838..74518ab 100644
71632 --- a/include/net/ip.h
71633 +++ b/include/net/ip.h
71634 @@ -202,7 +202,7 @@ extern struct local_ports {
71635 } sysctl_local_ports;
71636 extern void inet_get_local_port_range(int *low, int *high);
71637
71638 -extern unsigned long *sysctl_local_reserved_ports;
71639 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
71640 static inline int inet_is_reserved_local_port(int port)
71641 {
71642 return test_bit(port, sysctl_local_reserved_ports);
71643 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
71644 index e49db91..76a81de 100644
71645 --- a/include/net/ip_fib.h
71646 +++ b/include/net/ip_fib.h
71647 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
71648
71649 #define FIB_RES_SADDR(net, res) \
71650 ((FIB_RES_NH(res).nh_saddr_genid == \
71651 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
71652 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
71653 FIB_RES_NH(res).nh_saddr : \
71654 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
71655 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
71656 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
71657 index fce8e6b..3ca4916 100644
71658 --- a/include/net/ip_vs.h
71659 +++ b/include/net/ip_vs.h
71660 @@ -599,7 +599,7 @@ struct ip_vs_conn {
71661 struct ip_vs_conn *control; /* Master control connection */
71662 atomic_t n_control; /* Number of controlled ones */
71663 struct ip_vs_dest *dest; /* real server */
71664 - atomic_t in_pkts; /* incoming packet counter */
71665 + atomic_unchecked_t in_pkts; /* incoming packet counter */
71666
71667 /* packet transmitter for different forwarding methods. If it
71668 mangles the packet, it must return NF_DROP or better NF_STOLEN,
71669 @@ -737,7 +737,7 @@ struct ip_vs_dest {
71670 __be16 port; /* port number of the server */
71671 union nf_inet_addr addr; /* IP address of the server */
71672 volatile unsigned int flags; /* dest status flags */
71673 - atomic_t conn_flags; /* flags to copy to conn */
71674 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
71675 atomic_t weight; /* server weight */
71676
71677 atomic_t refcnt; /* reference counter */
71678 @@ -981,11 +981,11 @@ struct netns_ipvs {
71679 /* ip_vs_lblc */
71680 int sysctl_lblc_expiration;
71681 struct ctl_table_header *lblc_ctl_header;
71682 - struct ctl_table *lblc_ctl_table;
71683 + ctl_table_no_const *lblc_ctl_table;
71684 /* ip_vs_lblcr */
71685 int sysctl_lblcr_expiration;
71686 struct ctl_table_header *lblcr_ctl_header;
71687 - struct ctl_table *lblcr_ctl_table;
71688 + ctl_table_no_const *lblcr_ctl_table;
71689 /* ip_vs_est */
71690 struct list_head est_list; /* estimator list */
71691 spinlock_t est_lock;
71692 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
71693 index 80ffde3..968b0f4 100644
71694 --- a/include/net/irda/ircomm_tty.h
71695 +++ b/include/net/irda/ircomm_tty.h
71696 @@ -35,6 +35,7 @@
71697 #include <linux/termios.h>
71698 #include <linux/timer.h>
71699 #include <linux/tty.h> /* struct tty_struct */
71700 +#include <asm/local.h>
71701
71702 #include <net/irda/irias_object.h>
71703 #include <net/irda/ircomm_core.h>
71704 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
71705 index 714cc9a..ea05f3e 100644
71706 --- a/include/net/iucv/af_iucv.h
71707 +++ b/include/net/iucv/af_iucv.h
71708 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
71709 struct iucv_sock_list {
71710 struct hlist_head head;
71711 rwlock_t lock;
71712 - atomic_t autobind_name;
71713 + atomic_unchecked_t autobind_name;
71714 };
71715
71716 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
71717 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
71718 index df83f69..9b640b8 100644
71719 --- a/include/net/llc_c_ac.h
71720 +++ b/include/net/llc_c_ac.h
71721 @@ -87,7 +87,7 @@
71722 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
71723 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
71724
71725 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
71726 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
71727
71728 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
71729 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
71730 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
71731 index 6ca3113..f8026dd 100644
71732 --- a/include/net/llc_c_ev.h
71733 +++ b/include/net/llc_c_ev.h
71734 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
71735 return (struct llc_conn_state_ev *)skb->cb;
71736 }
71737
71738 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
71739 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
71740 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
71741 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
71742
71743 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
71744 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
71745 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
71746 index 0e79cfb..f46db31 100644
71747 --- a/include/net/llc_c_st.h
71748 +++ b/include/net/llc_c_st.h
71749 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
71750 u8 next_state;
71751 llc_conn_ev_qfyr_t *ev_qualifiers;
71752 llc_conn_action_t *ev_actions;
71753 -};
71754 +} __do_const;
71755
71756 struct llc_conn_state {
71757 u8 current_state;
71758 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
71759 index 37a3bbd..55a4241 100644
71760 --- a/include/net/llc_s_ac.h
71761 +++ b/include/net/llc_s_ac.h
71762 @@ -23,7 +23,7 @@
71763 #define SAP_ACT_TEST_IND 9
71764
71765 /* All action functions must look like this */
71766 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
71767 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
71768
71769 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
71770 struct sk_buff *skb);
71771 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
71772 index 567c681..cd73ac0 100644
71773 --- a/include/net/llc_s_st.h
71774 +++ b/include/net/llc_s_st.h
71775 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
71776 llc_sap_ev_t ev;
71777 u8 next_state;
71778 llc_sap_action_t *ev_actions;
71779 -};
71780 +} __do_const;
71781
71782 struct llc_sap_state {
71783 u8 curr_state;
71784 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
71785 index f7eba13..91ed983 100644
71786 --- a/include/net/mac80211.h
71787 +++ b/include/net/mac80211.h
71788 @@ -4119,7 +4119,7 @@ struct rate_control_ops {
71789 void (*add_sta_debugfs)(void *priv, void *priv_sta,
71790 struct dentry *dir);
71791 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
71792 -};
71793 +} __do_const;
71794
71795 static inline int rate_supported(struct ieee80211_sta *sta,
71796 enum ieee80211_band band,
71797 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
71798 index 7e748ad..5c6229b 100644
71799 --- a/include/net/neighbour.h
71800 +++ b/include/net/neighbour.h
71801 @@ -123,7 +123,7 @@ struct neigh_ops {
71802 void (*error_report)(struct neighbour *, struct sk_buff *);
71803 int (*output)(struct neighbour *, struct sk_buff *);
71804 int (*connected_output)(struct neighbour *, struct sk_buff *);
71805 -};
71806 +} __do_const;
71807
71808 struct pneigh_entry {
71809 struct pneigh_entry *next;
71810 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
71811 index de644bc..dfbcc4c 100644
71812 --- a/include/net/net_namespace.h
71813 +++ b/include/net/net_namespace.h
71814 @@ -115,7 +115,7 @@ struct net {
71815 #endif
71816 struct netns_ipvs *ipvs;
71817 struct sock *diag_nlsk;
71818 - atomic_t rt_genid;
71819 + atomic_unchecked_t rt_genid;
71820 };
71821
71822 /*
71823 @@ -272,7 +272,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
71824 #define __net_init __init
71825 #define __net_exit __exit_refok
71826 #define __net_initdata __initdata
71827 +#ifdef CONSTIFY_PLUGIN
71828 #define __net_initconst __initconst
71829 +#else
71830 +#define __net_initconst __initdata
71831 +#endif
71832 #endif
71833
71834 struct pernet_operations {
71835 @@ -282,7 +286,7 @@ struct pernet_operations {
71836 void (*exit_batch)(struct list_head *net_exit_list);
71837 int *id;
71838 size_t size;
71839 -};
71840 +} __do_const;
71841
71842 /*
71843 * Use these carefully. If you implement a network device and it
71844 @@ -330,12 +334,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
71845
71846 static inline int rt_genid(struct net *net)
71847 {
71848 - return atomic_read(&net->rt_genid);
71849 + return atomic_read_unchecked(&net->rt_genid);
71850 }
71851
71852 static inline void rt_genid_bump(struct net *net)
71853 {
71854 - atomic_inc(&net->rt_genid);
71855 + atomic_inc_unchecked(&net->rt_genid);
71856 }
71857
71858 #endif /* __NET_NET_NAMESPACE_H */
71859 diff --git a/include/net/netdma.h b/include/net/netdma.h
71860 index 8ba8ce2..99b7fff 100644
71861 --- a/include/net/netdma.h
71862 +++ b/include/net/netdma.h
71863 @@ -24,7 +24,7 @@
71864 #include <linux/dmaengine.h>
71865 #include <linux/skbuff.h>
71866
71867 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
71868 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
71869 struct sk_buff *skb, int offset, struct iovec *to,
71870 size_t len, struct dma_pinned_list *pinned_list);
71871
71872 diff --git a/include/net/netlink.h b/include/net/netlink.h
71873 index 9690b0f..87aded7 100644
71874 --- a/include/net/netlink.h
71875 +++ b/include/net/netlink.h
71876 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
71877 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
71878 {
71879 if (mark)
71880 - skb_trim(skb, (unsigned char *) mark - skb->data);
71881 + skb_trim(skb, (const unsigned char *) mark - skb->data);
71882 }
71883
71884 /**
71885 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
71886 index c9c0c53..53f24c3 100644
71887 --- a/include/net/netns/conntrack.h
71888 +++ b/include/net/netns/conntrack.h
71889 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
71890 struct nf_proto_net {
71891 #ifdef CONFIG_SYSCTL
71892 struct ctl_table_header *ctl_table_header;
71893 - struct ctl_table *ctl_table;
71894 + ctl_table_no_const *ctl_table;
71895 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
71896 struct ctl_table_header *ctl_compat_header;
71897 - struct ctl_table *ctl_compat_table;
71898 + ctl_table_no_const *ctl_compat_table;
71899 #endif
71900 #endif
71901 unsigned int users;
71902 @@ -58,7 +58,7 @@ struct nf_ip_net {
71903 struct nf_icmp_net icmpv6;
71904 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
71905 struct ctl_table_header *ctl_table_header;
71906 - struct ctl_table *ctl_table;
71907 + ctl_table_no_const *ctl_table;
71908 #endif
71909 };
71910
71911 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
71912 index 2ba9de8..47bd6c7 100644
71913 --- a/include/net/netns/ipv4.h
71914 +++ b/include/net/netns/ipv4.h
71915 @@ -67,7 +67,7 @@ struct netns_ipv4 {
71916 kgid_t sysctl_ping_group_range[2];
71917 long sysctl_tcp_mem[3];
71918
71919 - atomic_t dev_addr_genid;
71920 + atomic_unchecked_t dev_addr_genid;
71921
71922 #ifdef CONFIG_IP_MROUTE
71923 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
71924 diff --git a/include/net/protocol.h b/include/net/protocol.h
71925 index 047c047..b9dad15 100644
71926 --- a/include/net/protocol.h
71927 +++ b/include/net/protocol.h
71928 @@ -44,7 +44,7 @@ struct net_protocol {
71929 void (*err_handler)(struct sk_buff *skb, u32 info);
71930 unsigned int no_policy:1,
71931 netns_ok:1;
71932 -};
71933 +} __do_const;
71934
71935 #if IS_ENABLED(CONFIG_IPV6)
71936 struct inet6_protocol {
71937 @@ -57,7 +57,7 @@ struct inet6_protocol {
71938 u8 type, u8 code, int offset,
71939 __be32 info);
71940 unsigned int flags; /* INET6_PROTO_xxx */
71941 -};
71942 +} __do_const;
71943
71944 #define INET6_PROTO_NOPOLICY 0x1
71945 #define INET6_PROTO_FINAL 0x2
71946 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
71947 index 5a15fab..d799ea7 100644
71948 --- a/include/net/rtnetlink.h
71949 +++ b/include/net/rtnetlink.h
71950 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
71951 const struct net_device *dev);
71952 unsigned int (*get_num_tx_queues)(void);
71953 unsigned int (*get_num_rx_queues)(void);
71954 -};
71955 +} __do_const;
71956
71957 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
71958 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
71959 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
71960 index df85a0c..19ac300 100644
71961 --- a/include/net/sctp/sctp.h
71962 +++ b/include/net/sctp/sctp.h
71963 @@ -330,9 +330,9 @@ do { \
71964
71965 #else /* SCTP_DEBUG */
71966
71967 -#define SCTP_DEBUG_PRINTK(whatever...)
71968 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
71969 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
71970 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
71971 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
71972 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
71973 #define SCTP_ENABLE_DEBUG
71974 #define SCTP_DISABLE_DEBUG
71975 #define SCTP_ASSERT(expr, str, func)
71976 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
71977 index 2a82d13..62a31c2 100644
71978 --- a/include/net/sctp/sm.h
71979 +++ b/include/net/sctp/sm.h
71980 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
71981 typedef struct {
71982 sctp_state_fn_t *fn;
71983 const char *name;
71984 -} sctp_sm_table_entry_t;
71985 +} __do_const sctp_sm_table_entry_t;
71986
71987 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
71988 * currently in use.
71989 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
71990 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
71991
71992 /* Extern declarations for major data structures. */
71993 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
71994 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
71995
71996
71997 /* Get the size of a DATA chunk payload. */
71998 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
71999 index 0e0f9d2..cd05ebb 100644
72000 --- a/include/net/sctp/structs.h
72001 +++ b/include/net/sctp/structs.h
72002 @@ -517,7 +517,7 @@ struct sctp_pf {
72003 struct sctp_association *asoc);
72004 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
72005 struct sctp_af *af;
72006 -};
72007 +} __do_const;
72008
72009
72010 /* Structure to track chunk fragments that have been acked, but peer
72011 diff --git a/include/net/secure_seq.h b/include/net/secure_seq.h
72012 index c2e542b..6ca975b 100644
72013 --- a/include/net/secure_seq.h
72014 +++ b/include/net/secure_seq.h
72015 @@ -3,6 +3,7 @@
72016
72017 #include <linux/types.h>
72018
72019 +extern void net_secret_init(void);
72020 extern __u32 secure_ip_id(__be32 daddr);
72021 extern __u32 secure_ipv6_id(const __be32 daddr[4]);
72022 extern u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
72023 diff --git a/include/net/sock.h b/include/net/sock.h
72024 index 14f6e9d..7cd56d0 100644
72025 --- a/include/net/sock.h
72026 +++ b/include/net/sock.h
72027 @@ -325,7 +325,7 @@ struct sock {
72028 #ifdef CONFIG_RPS
72029 __u32 sk_rxhash;
72030 #endif
72031 - atomic_t sk_drops;
72032 + atomic_unchecked_t sk_drops;
72033 int sk_rcvbuf;
72034
72035 struct sk_filter __rcu *sk_filter;
72036 @@ -1784,7 +1784,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
72037 }
72038
72039 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
72040 - char __user *from, char *to,
72041 + char __user *from, unsigned char *to,
72042 int copy, int offset)
72043 {
72044 if (skb->ip_summed == CHECKSUM_NONE) {
72045 @@ -2043,7 +2043,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
72046 }
72047 }
72048
72049 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
72050 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
72051
72052 /**
72053 * sk_page_frag - return an appropriate page_frag
72054 diff --git a/include/net/tcp.h b/include/net/tcp.h
72055 index cf0694d..52a6881 100644
72056 --- a/include/net/tcp.h
72057 +++ b/include/net/tcp.h
72058 @@ -529,7 +529,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
72059 extern void tcp_xmit_retransmit_queue(struct sock *);
72060 extern void tcp_simple_retransmit(struct sock *);
72061 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
72062 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
72063 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
72064
72065 extern void tcp_send_probe0(struct sock *);
72066 extern void tcp_send_partial(struct sock *);
72067 @@ -700,8 +700,8 @@ struct tcp_skb_cb {
72068 struct inet6_skb_parm h6;
72069 #endif
72070 } header; /* For incoming frames */
72071 - __u32 seq; /* Starting sequence number */
72072 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
72073 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
72074 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
72075 __u32 when; /* used to compute rtt's */
72076 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
72077
72078 @@ -715,7 +715,7 @@ struct tcp_skb_cb {
72079
72080 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
72081 /* 1 byte hole */
72082 - __u32 ack_seq; /* Sequence number ACK'd */
72083 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
72084 };
72085
72086 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
72087 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
72088 index 24c8886..e6fb816 100644
72089 --- a/include/net/xfrm.h
72090 +++ b/include/net/xfrm.h
72091 @@ -304,7 +304,7 @@ struct xfrm_policy_afinfo {
72092 struct net_device *dev,
72093 const struct flowi *fl);
72094 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
72095 -};
72096 +} __do_const;
72097
72098 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
72099 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
72100 @@ -340,7 +340,7 @@ struct xfrm_state_afinfo {
72101 struct sk_buff *skb);
72102 int (*transport_finish)(struct sk_buff *skb,
72103 int async);
72104 -};
72105 +} __do_const;
72106
72107 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
72108 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
72109 @@ -423,7 +423,7 @@ struct xfrm_mode {
72110 struct module *owner;
72111 unsigned int encap;
72112 int flags;
72113 -};
72114 +} __do_const;
72115
72116 /* Flags for xfrm_mode. */
72117 enum {
72118 @@ -520,7 +520,7 @@ struct xfrm_policy {
72119 struct timer_list timer;
72120
72121 struct flow_cache_object flo;
72122 - atomic_t genid;
72123 + atomic_unchecked_t genid;
72124 u32 priority;
72125 u32 index;
72126 struct xfrm_mark mark;
72127 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
72128 index 1a046b1..ee0bef0 100644
72129 --- a/include/rdma/iw_cm.h
72130 +++ b/include/rdma/iw_cm.h
72131 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
72132 int backlog);
72133
72134 int (*destroy_listen)(struct iw_cm_id *cm_id);
72135 -};
72136 +} __no_const;
72137
72138 /**
72139 * iw_create_cm_id - Create an IW CM identifier.
72140 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
72141 index e1379b4..67eafbe 100644
72142 --- a/include/scsi/libfc.h
72143 +++ b/include/scsi/libfc.h
72144 @@ -762,6 +762,7 @@ struct libfc_function_template {
72145 */
72146 void (*disc_stop_final) (struct fc_lport *);
72147 };
72148 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
72149
72150 /**
72151 * struct fc_disc - Discovery context
72152 @@ -866,7 +867,7 @@ struct fc_lport {
72153 struct fc_vport *vport;
72154
72155 /* Operational Information */
72156 - struct libfc_function_template tt;
72157 + libfc_function_template_no_const tt;
72158 u8 link_up;
72159 u8 qfull;
72160 enum fc_lport_state state;
72161 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
72162 index a7f9cba..b1f44d0 100644
72163 --- a/include/scsi/scsi_device.h
72164 +++ b/include/scsi/scsi_device.h
72165 @@ -171,9 +171,9 @@ struct scsi_device {
72166 unsigned int max_device_blocked; /* what device_blocked counts down from */
72167 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
72168
72169 - atomic_t iorequest_cnt;
72170 - atomic_t iodone_cnt;
72171 - atomic_t ioerr_cnt;
72172 + atomic_unchecked_t iorequest_cnt;
72173 + atomic_unchecked_t iodone_cnt;
72174 + atomic_unchecked_t ioerr_cnt;
72175
72176 struct device sdev_gendev,
72177 sdev_dev;
72178 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
72179 index b797e8f..8e2c3aa 100644
72180 --- a/include/scsi/scsi_transport_fc.h
72181 +++ b/include/scsi/scsi_transport_fc.h
72182 @@ -751,7 +751,8 @@ struct fc_function_template {
72183 unsigned long show_host_system_hostname:1;
72184
72185 unsigned long disable_target_scan:1;
72186 -};
72187 +} __do_const;
72188 +typedef struct fc_function_template __no_const fc_function_template_no_const;
72189
72190
72191 /**
72192 diff --git a/include/sound/soc.h b/include/sound/soc.h
72193 index a6a059c..2243336 100644
72194 --- a/include/sound/soc.h
72195 +++ b/include/sound/soc.h
72196 @@ -771,7 +771,7 @@ struct snd_soc_codec_driver {
72197 /* probe ordering - for components with runtime dependencies */
72198 int probe_order;
72199 int remove_order;
72200 -};
72201 +} __do_const;
72202
72203 /* SoC platform interface */
72204 struct snd_soc_platform_driver {
72205 @@ -817,7 +817,7 @@ struct snd_soc_platform_driver {
72206 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
72207 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
72208 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
72209 -};
72210 +} __do_const;
72211
72212 struct snd_soc_platform {
72213 const char *name;
72214 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
72215 index c4af592..20c52d2 100644
72216 --- a/include/target/target_core_base.h
72217 +++ b/include/target/target_core_base.h
72218 @@ -657,7 +657,7 @@ struct se_device {
72219 spinlock_t stats_lock;
72220 /* Active commands on this virtual SE device */
72221 atomic_t simple_cmds;
72222 - atomic_t dev_ordered_id;
72223 + atomic_unchecked_t dev_ordered_id;
72224 atomic_t dev_ordered_sync;
72225 atomic_t dev_qf_count;
72226 int export_count;
72227 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
72228 new file mode 100644
72229 index 0000000..fb634b7
72230 --- /dev/null
72231 +++ b/include/trace/events/fs.h
72232 @@ -0,0 +1,53 @@
72233 +#undef TRACE_SYSTEM
72234 +#define TRACE_SYSTEM fs
72235 +
72236 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
72237 +#define _TRACE_FS_H
72238 +
72239 +#include <linux/fs.h>
72240 +#include <linux/tracepoint.h>
72241 +
72242 +TRACE_EVENT(do_sys_open,
72243 +
72244 + TP_PROTO(const char *filename, int flags, int mode),
72245 +
72246 + TP_ARGS(filename, flags, mode),
72247 +
72248 + TP_STRUCT__entry(
72249 + __string( filename, filename )
72250 + __field( int, flags )
72251 + __field( int, mode )
72252 + ),
72253 +
72254 + TP_fast_assign(
72255 + __assign_str(filename, filename);
72256 + __entry->flags = flags;
72257 + __entry->mode = mode;
72258 + ),
72259 +
72260 + TP_printk("\"%s\" %x %o",
72261 + __get_str(filename), __entry->flags, __entry->mode)
72262 +);
72263 +
72264 +TRACE_EVENT(open_exec,
72265 +
72266 + TP_PROTO(const char *filename),
72267 +
72268 + TP_ARGS(filename),
72269 +
72270 + TP_STRUCT__entry(
72271 + __string( filename, filename )
72272 + ),
72273 +
72274 + TP_fast_assign(
72275 + __assign_str(filename, filename);
72276 + ),
72277 +
72278 + TP_printk("\"%s\"",
72279 + __get_str(filename))
72280 +);
72281 +
72282 +#endif /* _TRACE_FS_H */
72283 +
72284 +/* This part must be outside protection */
72285 +#include <trace/define_trace.h>
72286 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
72287 index 1c09820..7f5ec79 100644
72288 --- a/include/trace/events/irq.h
72289 +++ b/include/trace/events/irq.h
72290 @@ -36,7 +36,7 @@ struct softirq_action;
72291 */
72292 TRACE_EVENT(irq_handler_entry,
72293
72294 - TP_PROTO(int irq, struct irqaction *action),
72295 + TP_PROTO(int irq, const struct irqaction *action),
72296
72297 TP_ARGS(irq, action),
72298
72299 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
72300 */
72301 TRACE_EVENT(irq_handler_exit,
72302
72303 - TP_PROTO(int irq, struct irqaction *action, int ret),
72304 + TP_PROTO(int irq, const struct irqaction *action, int ret),
72305
72306 TP_ARGS(irq, action, ret),
72307
72308 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
72309 index 7caf44c..23c6f27 100644
72310 --- a/include/uapi/linux/a.out.h
72311 +++ b/include/uapi/linux/a.out.h
72312 @@ -39,6 +39,14 @@ enum machine_type {
72313 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
72314 };
72315
72316 +/* Constants for the N_FLAGS field */
72317 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
72318 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
72319 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
72320 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
72321 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
72322 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
72323 +
72324 #if !defined (N_MAGIC)
72325 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
72326 #endif
72327 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
72328 index d876736..ccce5c0 100644
72329 --- a/include/uapi/linux/byteorder/little_endian.h
72330 +++ b/include/uapi/linux/byteorder/little_endian.h
72331 @@ -42,51 +42,51 @@
72332
72333 static inline __le64 __cpu_to_le64p(const __u64 *p)
72334 {
72335 - return (__force __le64)*p;
72336 + return (__force const __le64)*p;
72337 }
72338 -static inline __u64 __le64_to_cpup(const __le64 *p)
72339 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
72340 {
72341 - return (__force __u64)*p;
72342 + return (__force const __u64)*p;
72343 }
72344 static inline __le32 __cpu_to_le32p(const __u32 *p)
72345 {
72346 - return (__force __le32)*p;
72347 + return (__force const __le32)*p;
72348 }
72349 static inline __u32 __le32_to_cpup(const __le32 *p)
72350 {
72351 - return (__force __u32)*p;
72352 + return (__force const __u32)*p;
72353 }
72354 static inline __le16 __cpu_to_le16p(const __u16 *p)
72355 {
72356 - return (__force __le16)*p;
72357 + return (__force const __le16)*p;
72358 }
72359 static inline __u16 __le16_to_cpup(const __le16 *p)
72360 {
72361 - return (__force __u16)*p;
72362 + return (__force const __u16)*p;
72363 }
72364 static inline __be64 __cpu_to_be64p(const __u64 *p)
72365 {
72366 - return (__force __be64)__swab64p(p);
72367 + return (__force const __be64)__swab64p(p);
72368 }
72369 static inline __u64 __be64_to_cpup(const __be64 *p)
72370 {
72371 - return __swab64p((__u64 *)p);
72372 + return __swab64p((const __u64 *)p);
72373 }
72374 static inline __be32 __cpu_to_be32p(const __u32 *p)
72375 {
72376 - return (__force __be32)__swab32p(p);
72377 + return (__force const __be32)__swab32p(p);
72378 }
72379 -static inline __u32 __be32_to_cpup(const __be32 *p)
72380 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
72381 {
72382 - return __swab32p((__u32 *)p);
72383 + return __swab32p((const __u32 *)p);
72384 }
72385 static inline __be16 __cpu_to_be16p(const __u16 *p)
72386 {
72387 - return (__force __be16)__swab16p(p);
72388 + return (__force const __be16)__swab16p(p);
72389 }
72390 static inline __u16 __be16_to_cpup(const __be16 *p)
72391 {
72392 - return __swab16p((__u16 *)p);
72393 + return __swab16p((const __u16 *)p);
72394 }
72395 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
72396 #define __le64_to_cpus(x) do { (void)(x); } while (0)
72397 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
72398 index 8072d35..e77aeb8 100644
72399 --- a/include/uapi/linux/elf.h
72400 +++ b/include/uapi/linux/elf.h
72401 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
72402 #define PT_GNU_EH_FRAME 0x6474e550
72403
72404 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
72405 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
72406 +
72407 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
72408 +
72409 +/* Constants for the e_flags field */
72410 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
72411 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
72412 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
72413 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
72414 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
72415 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
72416
72417 /*
72418 * Extended Numbering
72419 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
72420 #define DT_DEBUG 21
72421 #define DT_TEXTREL 22
72422 #define DT_JMPREL 23
72423 +#define DT_FLAGS 30
72424 + #define DF_TEXTREL 0x00000004
72425 #define DT_ENCODING 32
72426 #define OLD_DT_LOOS 0x60000000
72427 #define DT_LOOS 0x6000000d
72428 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
72429 #define PF_W 0x2
72430 #define PF_X 0x1
72431
72432 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
72433 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
72434 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
72435 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
72436 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
72437 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
72438 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
72439 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
72440 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
72441 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
72442 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
72443 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
72444 +
72445 typedef struct elf32_phdr{
72446 Elf32_Word p_type;
72447 Elf32_Off p_offset;
72448 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
72449 #define EI_OSABI 7
72450 #define EI_PAD 8
72451
72452 +#define EI_PAX 14
72453 +
72454 #define ELFMAG0 0x7f /* EI_MAG */
72455 #define ELFMAG1 'E'
72456 #define ELFMAG2 'L'
72457 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
72458 index aa169c4..6a2771d 100644
72459 --- a/include/uapi/linux/personality.h
72460 +++ b/include/uapi/linux/personality.h
72461 @@ -30,6 +30,7 @@ enum {
72462 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
72463 ADDR_NO_RANDOMIZE | \
72464 ADDR_COMPAT_LAYOUT | \
72465 + ADDR_LIMIT_3GB | \
72466 MMAP_PAGE_ZERO)
72467
72468 /*
72469 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
72470 index 7530e74..e714828 100644
72471 --- a/include/uapi/linux/screen_info.h
72472 +++ b/include/uapi/linux/screen_info.h
72473 @@ -43,7 +43,8 @@ struct screen_info {
72474 __u16 pages; /* 0x32 */
72475 __u16 vesa_attributes; /* 0x34 */
72476 __u32 capabilities; /* 0x36 */
72477 - __u8 _reserved[6]; /* 0x3a */
72478 + __u16 vesapm_size; /* 0x3a */
72479 + __u8 _reserved[4]; /* 0x3c */
72480 } __attribute__((packed));
72481
72482 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
72483 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
72484 index 0e011eb..82681b1 100644
72485 --- a/include/uapi/linux/swab.h
72486 +++ b/include/uapi/linux/swab.h
72487 @@ -43,7 +43,7 @@
72488 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
72489 */
72490
72491 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
72492 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
72493 {
72494 #ifdef __HAVE_BUILTIN_BSWAP16__
72495 return __builtin_bswap16(val);
72496 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
72497 #endif
72498 }
72499
72500 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
72501 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
72502 {
72503 #ifdef __HAVE_BUILTIN_BSWAP32__
72504 return __builtin_bswap32(val);
72505 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
72506 #endif
72507 }
72508
72509 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
72510 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
72511 {
72512 #ifdef __HAVE_BUILTIN_BSWAP64__
72513 return __builtin_bswap64(val);
72514 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
72515 index 6d67213..8dab561 100644
72516 --- a/include/uapi/linux/sysctl.h
72517 +++ b/include/uapi/linux/sysctl.h
72518 @@ -155,7 +155,11 @@ enum
72519 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
72520 };
72521
72522 -
72523 +#ifdef CONFIG_PAX_SOFTMODE
72524 +enum {
72525 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
72526 +};
72527 +#endif
72528
72529 /* CTL_VM names: */
72530 enum
72531 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
72532 index e4629b9..6958086 100644
72533 --- a/include/uapi/linux/xattr.h
72534 +++ b/include/uapi/linux/xattr.h
72535 @@ -63,5 +63,9 @@
72536 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
72537 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
72538
72539 +/* User namespace */
72540 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
72541 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
72542 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
72543
72544 #endif /* _UAPI_LINUX_XATTR_H */
72545 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
72546 index f9466fa..f4e2b81 100644
72547 --- a/include/video/udlfb.h
72548 +++ b/include/video/udlfb.h
72549 @@ -53,10 +53,10 @@ struct dlfb_data {
72550 u32 pseudo_palette[256];
72551 int blank_mode; /*one of FB_BLANK_ */
72552 /* blit-only rendering path metrics, exposed through sysfs */
72553 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
72554 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
72555 - atomic_t bytes_sent; /* to usb, after compression including overhead */
72556 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
72557 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
72558 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
72559 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
72560 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
72561 };
72562
72563 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
72564 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
72565 index 1a91850..28573f8 100644
72566 --- a/include/video/uvesafb.h
72567 +++ b/include/video/uvesafb.h
72568 @@ -122,6 +122,7 @@ struct uvesafb_par {
72569 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
72570 u8 pmi_setpal; /* PMI for palette changes */
72571 u16 *pmi_base; /* protected mode interface location */
72572 + u8 *pmi_code; /* protected mode code location */
72573 void *pmi_start;
72574 void *pmi_pal;
72575 u8 *vbe_state_orig; /*
72576 diff --git a/init/Kconfig b/init/Kconfig
72577 index 5341d72..153f24f 100644
72578 --- a/init/Kconfig
72579 +++ b/init/Kconfig
72580 @@ -984,6 +984,7 @@ endif # CGROUPS
72581
72582 config CHECKPOINT_RESTORE
72583 bool "Checkpoint/restore support" if EXPERT
72584 + depends on !GRKERNSEC
72585 default n
72586 help
72587 Enables additional kernel features in a sake of checkpoint/restore.
72588 @@ -1471,7 +1472,7 @@ config SLUB_DEBUG
72589
72590 config COMPAT_BRK
72591 bool "Disable heap randomization"
72592 - default y
72593 + default n
72594 help
72595 Randomizing heap placement makes heap exploits harder, but it
72596 also breaks ancient binaries (including anything libc5 based).
72597 @@ -1734,7 +1735,7 @@ config INIT_ALL_POSSIBLE
72598 config STOP_MACHINE
72599 bool
72600 default y
72601 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
72602 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
72603 help
72604 Need stop_machine() primitive.
72605
72606 diff --git a/init/Makefile b/init/Makefile
72607 index 7bc47ee..6da2dc7 100644
72608 --- a/init/Makefile
72609 +++ b/init/Makefile
72610 @@ -2,6 +2,9 @@
72611 # Makefile for the linux kernel.
72612 #
72613
72614 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
72615 +asflags-y := $(GCC_PLUGINS_AFLAGS)
72616 +
72617 obj-y := main.o version.o mounts.o
72618 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
72619 obj-y += noinitramfs.o
72620 diff --git a/init/do_mounts.c b/init/do_mounts.c
72621 index a2b49f2..03a0e17c 100644
72622 --- a/init/do_mounts.c
72623 +++ b/init/do_mounts.c
72624 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
72625 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
72626 {
72627 struct super_block *s;
72628 - int err = sys_mount(name, "/root", fs, flags, data);
72629 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
72630 if (err)
72631 return err;
72632
72633 - sys_chdir("/root");
72634 + sys_chdir((const char __force_user *)"/root");
72635 s = current->fs->pwd.dentry->d_sb;
72636 ROOT_DEV = s->s_dev;
72637 printk(KERN_INFO
72638 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
72639 va_start(args, fmt);
72640 vsprintf(buf, fmt, args);
72641 va_end(args);
72642 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
72643 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
72644 if (fd >= 0) {
72645 sys_ioctl(fd, FDEJECT, 0);
72646 sys_close(fd);
72647 }
72648 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
72649 - fd = sys_open("/dev/console", O_RDWR, 0);
72650 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
72651 if (fd >= 0) {
72652 sys_ioctl(fd, TCGETS, (long)&termios);
72653 termios.c_lflag &= ~ICANON;
72654 sys_ioctl(fd, TCSETSF, (long)&termios);
72655 - sys_read(fd, &c, 1);
72656 + sys_read(fd, (char __user *)&c, 1);
72657 termios.c_lflag |= ICANON;
72658 sys_ioctl(fd, TCSETSF, (long)&termios);
72659 sys_close(fd);
72660 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
72661 mount_root();
72662 out:
72663 devtmpfs_mount("dev");
72664 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
72665 - sys_chroot(".");
72666 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
72667 + sys_chroot((const char __force_user *)".");
72668 }
72669 diff --git a/init/do_mounts.h b/init/do_mounts.h
72670 index f5b978a..69dbfe8 100644
72671 --- a/init/do_mounts.h
72672 +++ b/init/do_mounts.h
72673 @@ -15,15 +15,15 @@ extern int root_mountflags;
72674
72675 static inline int create_dev(char *name, dev_t dev)
72676 {
72677 - sys_unlink(name);
72678 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
72679 + sys_unlink((char __force_user *)name);
72680 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
72681 }
72682
72683 #if BITS_PER_LONG == 32
72684 static inline u32 bstat(char *name)
72685 {
72686 struct stat64 stat;
72687 - if (sys_stat64(name, &stat) != 0)
72688 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
72689 return 0;
72690 if (!S_ISBLK(stat.st_mode))
72691 return 0;
72692 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
72693 static inline u32 bstat(char *name)
72694 {
72695 struct stat stat;
72696 - if (sys_newstat(name, &stat) != 0)
72697 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
72698 return 0;
72699 if (!S_ISBLK(stat.st_mode))
72700 return 0;
72701 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
72702 index a32ec1c..ac08811 100644
72703 --- a/init/do_mounts_initrd.c
72704 +++ b/init/do_mounts_initrd.c
72705 @@ -58,8 +58,8 @@ static void __init handle_initrd(void)
72706 create_dev("/dev/root.old", Root_RAM0);
72707 /* mount initrd on rootfs' /root */
72708 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
72709 - sys_mkdir("/old", 0700);
72710 - sys_chdir("/old");
72711 + sys_mkdir((const char __force_user *)"/old", 0700);
72712 + sys_chdir((const char __force_user *)"/old");
72713
72714 /* try loading default modules from initrd */
72715 load_default_modules();
72716 @@ -76,31 +76,31 @@ static void __init handle_initrd(void)
72717 current->flags &= ~PF_FREEZER_SKIP;
72718
72719 /* move initrd to rootfs' /old */
72720 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
72721 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
72722 /* switch root and cwd back to / of rootfs */
72723 - sys_chroot("..");
72724 + sys_chroot((const char __force_user *)"..");
72725
72726 if (new_decode_dev(real_root_dev) == Root_RAM0) {
72727 - sys_chdir("/old");
72728 + sys_chdir((const char __force_user *)"/old");
72729 return;
72730 }
72731
72732 - sys_chdir("/");
72733 + sys_chdir((const char __force_user *)"/");
72734 ROOT_DEV = new_decode_dev(real_root_dev);
72735 mount_root();
72736
72737 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
72738 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
72739 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
72740 if (!error)
72741 printk("okay\n");
72742 else {
72743 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
72744 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
72745 if (error == -ENOENT)
72746 printk("/initrd does not exist. Ignored.\n");
72747 else
72748 printk("failed\n");
72749 printk(KERN_NOTICE "Unmounting old root\n");
72750 - sys_umount("/old", MNT_DETACH);
72751 + sys_umount((char __force_user *)"/old", MNT_DETACH);
72752 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
72753 if (fd < 0) {
72754 error = fd;
72755 @@ -123,11 +123,11 @@ int __init initrd_load(void)
72756 * mounted in the normal path.
72757 */
72758 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
72759 - sys_unlink("/initrd.image");
72760 + sys_unlink((const char __force_user *)"/initrd.image");
72761 handle_initrd();
72762 return 1;
72763 }
72764 }
72765 - sys_unlink("/initrd.image");
72766 + sys_unlink((const char __force_user *)"/initrd.image");
72767 return 0;
72768 }
72769 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
72770 index 8cb6db5..d729f50 100644
72771 --- a/init/do_mounts_md.c
72772 +++ b/init/do_mounts_md.c
72773 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
72774 partitioned ? "_d" : "", minor,
72775 md_setup_args[ent].device_names);
72776
72777 - fd = sys_open(name, 0, 0);
72778 + fd = sys_open((char __force_user *)name, 0, 0);
72779 if (fd < 0) {
72780 printk(KERN_ERR "md: open failed - cannot start "
72781 "array %s\n", name);
72782 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
72783 * array without it
72784 */
72785 sys_close(fd);
72786 - fd = sys_open(name, 0, 0);
72787 + fd = sys_open((char __force_user *)name, 0, 0);
72788 sys_ioctl(fd, BLKRRPART, 0);
72789 }
72790 sys_close(fd);
72791 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
72792
72793 wait_for_device_probe();
72794
72795 - fd = sys_open("/dev/md0", 0, 0);
72796 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
72797 if (fd >= 0) {
72798 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
72799 sys_close(fd);
72800 diff --git a/init/init_task.c b/init/init_task.c
72801 index ba0a7f36..2bcf1d5 100644
72802 --- a/init/init_task.c
72803 +++ b/init/init_task.c
72804 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
72805 * Initial thread structure. Alignment of this is handled by a special
72806 * linker map entry.
72807 */
72808 +#ifdef CONFIG_X86
72809 +union thread_union init_thread_union __init_task_data;
72810 +#else
72811 union thread_union init_thread_union __init_task_data =
72812 { INIT_THREAD_INFO(init_task) };
72813 +#endif
72814 diff --git a/init/initramfs.c b/init/initramfs.c
72815 index a67ef9d..3d88592 100644
72816 --- a/init/initramfs.c
72817 +++ b/init/initramfs.c
72818 @@ -84,7 +84,7 @@ static void __init free_hash(void)
72819 }
72820 }
72821
72822 -static long __init do_utime(char *filename, time_t mtime)
72823 +static long __init do_utime(char __force_user *filename, time_t mtime)
72824 {
72825 struct timespec t[2];
72826
72827 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
72828 struct dir_entry *de, *tmp;
72829 list_for_each_entry_safe(de, tmp, &dir_list, list) {
72830 list_del(&de->list);
72831 - do_utime(de->name, de->mtime);
72832 + do_utime((char __force_user *)de->name, de->mtime);
72833 kfree(de->name);
72834 kfree(de);
72835 }
72836 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
72837 if (nlink >= 2) {
72838 char *old = find_link(major, minor, ino, mode, collected);
72839 if (old)
72840 - return (sys_link(old, collected) < 0) ? -1 : 1;
72841 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
72842 }
72843 return 0;
72844 }
72845 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
72846 {
72847 struct stat st;
72848
72849 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
72850 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
72851 if (S_ISDIR(st.st_mode))
72852 - sys_rmdir(path);
72853 + sys_rmdir((char __force_user *)path);
72854 else
72855 - sys_unlink(path);
72856 + sys_unlink((char __force_user *)path);
72857 }
72858 }
72859
72860 @@ -315,7 +315,7 @@ static int __init do_name(void)
72861 int openflags = O_WRONLY|O_CREAT;
72862 if (ml != 1)
72863 openflags |= O_TRUNC;
72864 - wfd = sys_open(collected, openflags, mode);
72865 + wfd = sys_open((char __force_user *)collected, openflags, mode);
72866
72867 if (wfd >= 0) {
72868 sys_fchown(wfd, uid, gid);
72869 @@ -327,17 +327,17 @@ static int __init do_name(void)
72870 }
72871 }
72872 } else if (S_ISDIR(mode)) {
72873 - sys_mkdir(collected, mode);
72874 - sys_chown(collected, uid, gid);
72875 - sys_chmod(collected, mode);
72876 + sys_mkdir((char __force_user *)collected, mode);
72877 + sys_chown((char __force_user *)collected, uid, gid);
72878 + sys_chmod((char __force_user *)collected, mode);
72879 dir_add(collected, mtime);
72880 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
72881 S_ISFIFO(mode) || S_ISSOCK(mode)) {
72882 if (maybe_link() == 0) {
72883 - sys_mknod(collected, mode, rdev);
72884 - sys_chown(collected, uid, gid);
72885 - sys_chmod(collected, mode);
72886 - do_utime(collected, mtime);
72887 + sys_mknod((char __force_user *)collected, mode, rdev);
72888 + sys_chown((char __force_user *)collected, uid, gid);
72889 + sys_chmod((char __force_user *)collected, mode);
72890 + do_utime((char __force_user *)collected, mtime);
72891 }
72892 }
72893 return 0;
72894 @@ -346,15 +346,15 @@ static int __init do_name(void)
72895 static int __init do_copy(void)
72896 {
72897 if (count >= body_len) {
72898 - sys_write(wfd, victim, body_len);
72899 + sys_write(wfd, (char __force_user *)victim, body_len);
72900 sys_close(wfd);
72901 - do_utime(vcollected, mtime);
72902 + do_utime((char __force_user *)vcollected, mtime);
72903 kfree(vcollected);
72904 eat(body_len);
72905 state = SkipIt;
72906 return 0;
72907 } else {
72908 - sys_write(wfd, victim, count);
72909 + sys_write(wfd, (char __force_user *)victim, count);
72910 body_len -= count;
72911 eat(count);
72912 return 1;
72913 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
72914 {
72915 collected[N_ALIGN(name_len) + body_len] = '\0';
72916 clean_path(collected, 0);
72917 - sys_symlink(collected + N_ALIGN(name_len), collected);
72918 - sys_lchown(collected, uid, gid);
72919 - do_utime(collected, mtime);
72920 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
72921 + sys_lchown((char __force_user *)collected, uid, gid);
72922 + do_utime((char __force_user *)collected, mtime);
72923 state = SkipIt;
72924 next_state = Reset;
72925 return 0;
72926 diff --git a/init/main.c b/init/main.c
72927 index 63534a1..8abcaf1 100644
72928 --- a/init/main.c
72929 +++ b/init/main.c
72930 @@ -98,6 +98,8 @@ static inline void mark_rodata_ro(void) { }
72931 extern void tc_init(void);
72932 #endif
72933
72934 +extern void grsecurity_init(void);
72935 +
72936 /*
72937 * Debug helper: via this flag we know that we are in 'early bootup code'
72938 * where only the boot processor is running with IRQ disabled. This means
72939 @@ -151,6 +153,64 @@ static int __init set_reset_devices(char *str)
72940
72941 __setup("reset_devices", set_reset_devices);
72942
72943 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
72944 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
72945 +static int __init setup_grsec_proc_gid(char *str)
72946 +{
72947 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
72948 + return 1;
72949 +}
72950 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
72951 +#endif
72952 +
72953 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
72954 +unsigned long pax_user_shadow_base __read_only = 1UL << TASK_SIZE_MAX_SHIFT;
72955 +EXPORT_SYMBOL(pax_user_shadow_base);
72956 +extern char pax_enter_kernel_user[];
72957 +extern char pax_exit_kernel_user[];
72958 +extern pgdval_t clone_pgd_mask;
72959 +#endif
72960 +
72961 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
72962 +static int __init setup_pax_nouderef(char *str)
72963 +{
72964 +#ifdef CONFIG_X86_32
72965 + unsigned int cpu;
72966 + struct desc_struct *gdt;
72967 +
72968 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
72969 + gdt = get_cpu_gdt_table(cpu);
72970 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
72971 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
72972 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
72973 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
72974 + }
72975 + loadsegment(ds, __KERNEL_DS);
72976 + loadsegment(es, __KERNEL_DS);
72977 + loadsegment(ss, __KERNEL_DS);
72978 +#else
72979 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
72980 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
72981 + clone_pgd_mask = ~(pgdval_t)0UL;
72982 + pax_user_shadow_base = 0UL;
72983 +#endif
72984 +
72985 + return 0;
72986 +}
72987 +early_param("pax_nouderef", setup_pax_nouderef);
72988 +#endif
72989 +
72990 +#ifdef CONFIG_PAX_SOFTMODE
72991 +int pax_softmode;
72992 +
72993 +static int __init setup_pax_softmode(char *str)
72994 +{
72995 + get_option(&str, &pax_softmode);
72996 + return 1;
72997 +}
72998 +__setup("pax_softmode=", setup_pax_softmode);
72999 +#endif
73000 +
73001 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
73002 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
73003 static const char *panic_later, *panic_param;
73004 @@ -683,6 +743,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
73005 {
73006 int count = preempt_count();
73007 int ret;
73008 + const char *msg1 = "", *msg2 = "";
73009
73010 if (initcall_debug)
73011 ret = do_one_initcall_debug(fn);
73012 @@ -695,15 +756,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
73013 sprintf(msgbuf, "error code %d ", ret);
73014
73015 if (preempt_count() != count) {
73016 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
73017 + msg1 = " preemption imbalance";
73018 preempt_count() = count;
73019 }
73020 if (irqs_disabled()) {
73021 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
73022 + msg2 = " disabled interrupts";
73023 local_irq_enable();
73024 }
73025 - if (msgbuf[0]) {
73026 - printk("initcall %pF returned with %s\n", fn, msgbuf);
73027 + if (msgbuf[0] || *msg1 || *msg2) {
73028 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
73029 }
73030
73031 return ret;
73032 @@ -757,8 +818,14 @@ static void __init do_initcall_level(int level)
73033 level, level,
73034 &repair_env_string);
73035
73036 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
73037 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
73038 do_one_initcall(*fn);
73039 +
73040 +#ifdef LATENT_ENTROPY_PLUGIN
73041 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
73042 +#endif
73043 +
73044 + }
73045 }
73046
73047 static void __init do_initcalls(void)
73048 @@ -792,8 +859,14 @@ static void __init do_pre_smp_initcalls(void)
73049 {
73050 initcall_t *fn;
73051
73052 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
73053 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
73054 do_one_initcall(*fn);
73055 +
73056 +#ifdef LATENT_ENTROPY_PLUGIN
73057 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
73058 +#endif
73059 +
73060 + }
73061 }
73062
73063 /*
73064 @@ -890,7 +963,7 @@ static noinline void __init kernel_init_freeable(void)
73065 do_basic_setup();
73066
73067 /* Open the /dev/console on the rootfs, this should never fail */
73068 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
73069 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
73070 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
73071
73072 (void) sys_dup(0);
73073 @@ -903,11 +976,13 @@ static noinline void __init kernel_init_freeable(void)
73074 if (!ramdisk_execute_command)
73075 ramdisk_execute_command = "/init";
73076
73077 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
73078 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
73079 ramdisk_execute_command = NULL;
73080 prepare_namespace();
73081 }
73082
73083 + grsecurity_init();
73084 +
73085 /*
73086 * Ok, we have completed the initial bootup, and
73087 * we're essentially up and running. Get rid of the
73088 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
73089 index 130dfec..cc88451 100644
73090 --- a/ipc/ipc_sysctl.c
73091 +++ b/ipc/ipc_sysctl.c
73092 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
73093 static int proc_ipc_dointvec(ctl_table *table, int write,
73094 void __user *buffer, size_t *lenp, loff_t *ppos)
73095 {
73096 - struct ctl_table ipc_table;
73097 + ctl_table_no_const ipc_table;
73098
73099 memcpy(&ipc_table, table, sizeof(ipc_table));
73100 ipc_table.data = get_ipc(table);
73101 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
73102 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
73103 void __user *buffer, size_t *lenp, loff_t *ppos)
73104 {
73105 - struct ctl_table ipc_table;
73106 + ctl_table_no_const ipc_table;
73107
73108 memcpy(&ipc_table, table, sizeof(ipc_table));
73109 ipc_table.data = get_ipc(table);
73110 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
73111 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
73112 void __user *buffer, size_t *lenp, loff_t *ppos)
73113 {
73114 - struct ctl_table ipc_table;
73115 + ctl_table_no_const ipc_table;
73116 size_t lenp_bef = *lenp;
73117 int rc;
73118
73119 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
73120 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
73121 void __user *buffer, size_t *lenp, loff_t *ppos)
73122 {
73123 - struct ctl_table ipc_table;
73124 + ctl_table_no_const ipc_table;
73125 memcpy(&ipc_table, table, sizeof(ipc_table));
73126 ipc_table.data = get_ipc(table);
73127
73128 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
73129 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
73130 void __user *buffer, size_t *lenp, loff_t *ppos)
73131 {
73132 - struct ctl_table ipc_table;
73133 + ctl_table_no_const ipc_table;
73134 size_t lenp_bef = *lenp;
73135 int oldval;
73136 int rc;
73137 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
73138 index 383d638..943fdbb 100644
73139 --- a/ipc/mq_sysctl.c
73140 +++ b/ipc/mq_sysctl.c
73141 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
73142 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
73143 void __user *buffer, size_t *lenp, loff_t *ppos)
73144 {
73145 - struct ctl_table mq_table;
73146 + ctl_table_no_const mq_table;
73147 memcpy(&mq_table, table, sizeof(mq_table));
73148 mq_table.data = get_mq(table);
73149
73150 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
73151 index e4e47f6..a85e0ad 100644
73152 --- a/ipc/mqueue.c
73153 +++ b/ipc/mqueue.c
73154 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
73155 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
73156 info->attr.mq_msgsize);
73157
73158 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
73159 spin_lock(&mq_lock);
73160 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
73161 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
73162 diff --git a/ipc/msg.c b/ipc/msg.c
73163 index fede1d0..9778e0f8 100644
73164 --- a/ipc/msg.c
73165 +++ b/ipc/msg.c
73166 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
73167 return security_msg_queue_associate(msq, msgflg);
73168 }
73169
73170 +static struct ipc_ops msg_ops = {
73171 + .getnew = newque,
73172 + .associate = msg_security,
73173 + .more_checks = NULL
73174 +};
73175 +
73176 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
73177 {
73178 struct ipc_namespace *ns;
73179 - struct ipc_ops msg_ops;
73180 struct ipc_params msg_params;
73181
73182 ns = current->nsproxy->ipc_ns;
73183
73184 - msg_ops.getnew = newque;
73185 - msg_ops.associate = msg_security;
73186 - msg_ops.more_checks = NULL;
73187 -
73188 msg_params.key = key;
73189 msg_params.flg = msgflg;
73190
73191 diff --git a/ipc/sem.c b/ipc/sem.c
73192 index 58d31f1..cce7a55 100644
73193 --- a/ipc/sem.c
73194 +++ b/ipc/sem.c
73195 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
73196 return 0;
73197 }
73198
73199 +static struct ipc_ops sem_ops = {
73200 + .getnew = newary,
73201 + .associate = sem_security,
73202 + .more_checks = sem_more_checks
73203 +};
73204 +
73205 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
73206 {
73207 struct ipc_namespace *ns;
73208 - struct ipc_ops sem_ops;
73209 struct ipc_params sem_params;
73210
73211 ns = current->nsproxy->ipc_ns;
73212 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
73213 if (nsems < 0 || nsems > ns->sc_semmsl)
73214 return -EINVAL;
73215
73216 - sem_ops.getnew = newary;
73217 - sem_ops.associate = sem_security;
73218 - sem_ops.more_checks = sem_more_checks;
73219 -
73220 sem_params.key = key;
73221 sem_params.flg = semflg;
73222 sem_params.u.nsems = nsems;
73223 diff --git a/ipc/shm.c b/ipc/shm.c
73224 index 34af1fe..85fc1aa 100644
73225 --- a/ipc/shm.c
73226 +++ b/ipc/shm.c
73227 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
73228 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
73229 #endif
73230
73231 +#ifdef CONFIG_GRKERNSEC
73232 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
73233 + const time_t shm_createtime, const kuid_t cuid,
73234 + const int shmid);
73235 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
73236 + const time_t shm_createtime);
73237 +#endif
73238 +
73239 void shm_init_ns(struct ipc_namespace *ns)
73240 {
73241 ns->shm_ctlmax = SHMMAX;
73242 @@ -525,6 +533,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
73243 shp->shm_lprid = 0;
73244 shp->shm_atim = shp->shm_dtim = 0;
73245 shp->shm_ctim = get_seconds();
73246 +#ifdef CONFIG_GRKERNSEC
73247 + {
73248 + struct timespec timeval;
73249 + do_posix_clock_monotonic_gettime(&timeval);
73250 +
73251 + shp->shm_createtime = timeval.tv_sec;
73252 + }
73253 +#endif
73254 shp->shm_segsz = size;
73255 shp->shm_nattch = 0;
73256 shp->shm_file = file;
73257 @@ -576,18 +592,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
73258 return 0;
73259 }
73260
73261 +static struct ipc_ops shm_ops = {
73262 + .getnew = newseg,
73263 + .associate = shm_security,
73264 + .more_checks = shm_more_checks
73265 +};
73266 +
73267 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
73268 {
73269 struct ipc_namespace *ns;
73270 - struct ipc_ops shm_ops;
73271 struct ipc_params shm_params;
73272
73273 ns = current->nsproxy->ipc_ns;
73274
73275 - shm_ops.getnew = newseg;
73276 - shm_ops.associate = shm_security;
73277 - shm_ops.more_checks = shm_more_checks;
73278 -
73279 shm_params.key = key;
73280 shm_params.flg = shmflg;
73281 shm_params.u.size = size;
73282 @@ -1008,6 +1025,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
73283 f_mode = FMODE_READ | FMODE_WRITE;
73284 }
73285 if (shmflg & SHM_EXEC) {
73286 +
73287 +#ifdef CONFIG_PAX_MPROTECT
73288 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
73289 + goto out;
73290 +#endif
73291 +
73292 prot |= PROT_EXEC;
73293 acc_mode |= S_IXUGO;
73294 }
73295 @@ -1031,9 +1054,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
73296 if (err)
73297 goto out_unlock;
73298
73299 +#ifdef CONFIG_GRKERNSEC
73300 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
73301 + shp->shm_perm.cuid, shmid) ||
73302 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
73303 + err = -EACCES;
73304 + goto out_unlock;
73305 + }
73306 +#endif
73307 +
73308 path = shp->shm_file->f_path;
73309 path_get(&path);
73310 shp->shm_nattch++;
73311 +#ifdef CONFIG_GRKERNSEC
73312 + shp->shm_lapid = current->pid;
73313 +#endif
73314 size = i_size_read(path.dentry->d_inode);
73315 shm_unlock(shp);
73316
73317 diff --git a/kernel/acct.c b/kernel/acct.c
73318 index b9bd7f0..1762b4a 100644
73319 --- a/kernel/acct.c
73320 +++ b/kernel/acct.c
73321 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
73322 */
73323 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
73324 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
73325 - file->f_op->write(file, (char *)&ac,
73326 + file->f_op->write(file, (char __force_user *)&ac,
73327 sizeof(acct_t), &file->f_pos);
73328 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
73329 set_fs(fs);
73330 diff --git a/kernel/audit.c b/kernel/audit.c
73331 index d596e53..dbef3c3 100644
73332 --- a/kernel/audit.c
73333 +++ b/kernel/audit.c
73334 @@ -116,7 +116,7 @@ u32 audit_sig_sid = 0;
73335 3) suppressed due to audit_rate_limit
73336 4) suppressed due to audit_backlog_limit
73337 */
73338 -static atomic_t audit_lost = ATOMIC_INIT(0);
73339 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
73340
73341 /* The netlink socket. */
73342 static struct sock *audit_sock;
73343 @@ -238,7 +238,7 @@ void audit_log_lost(const char *message)
73344 unsigned long now;
73345 int print;
73346
73347 - atomic_inc(&audit_lost);
73348 + atomic_inc_unchecked(&audit_lost);
73349
73350 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
73351
73352 @@ -257,7 +257,7 @@ void audit_log_lost(const char *message)
73353 printk(KERN_WARNING
73354 "audit: audit_lost=%d audit_rate_limit=%d "
73355 "audit_backlog_limit=%d\n",
73356 - atomic_read(&audit_lost),
73357 + atomic_read_unchecked(&audit_lost),
73358 audit_rate_limit,
73359 audit_backlog_limit);
73360 audit_panic(message);
73361 @@ -681,7 +681,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
73362 status_set.pid = audit_pid;
73363 status_set.rate_limit = audit_rate_limit;
73364 status_set.backlog_limit = audit_backlog_limit;
73365 - status_set.lost = atomic_read(&audit_lost);
73366 + status_set.lost = atomic_read_unchecked(&audit_lost);
73367 status_set.backlog = skb_queue_len(&audit_skb_queue);
73368 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
73369 &status_set, sizeof(status_set));
73370 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
73371 index a371f85..da826c1 100644
73372 --- a/kernel/auditsc.c
73373 +++ b/kernel/auditsc.c
73374 @@ -2292,7 +2292,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
73375 }
73376
73377 /* global counter which is incremented every time something logs in */
73378 -static atomic_t session_id = ATOMIC_INIT(0);
73379 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
73380
73381 /**
73382 * audit_set_loginuid - set current task's audit_context loginuid
73383 @@ -2316,7 +2316,7 @@ int audit_set_loginuid(kuid_t loginuid)
73384 return -EPERM;
73385 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
73386
73387 - sessionid = atomic_inc_return(&session_id);
73388 + sessionid = atomic_inc_return_unchecked(&session_id);
73389 if (context && context->in_syscall) {
73390 struct audit_buffer *ab;
73391
73392 diff --git a/kernel/capability.c b/kernel/capability.c
73393 index f6c2ce5..982c0f9 100644
73394 --- a/kernel/capability.c
73395 +++ b/kernel/capability.c
73396 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
73397 * before modification is attempted and the application
73398 * fails.
73399 */
73400 + if (tocopy > ARRAY_SIZE(kdata))
73401 + return -EFAULT;
73402 +
73403 if (copy_to_user(dataptr, kdata, tocopy
73404 * sizeof(struct __user_cap_data_struct))) {
73405 return -EFAULT;
73406 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
73407 int ret;
73408
73409 rcu_read_lock();
73410 - ret = security_capable(__task_cred(t), ns, cap);
73411 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
73412 + gr_task_is_capable(t, __task_cred(t), cap);
73413 rcu_read_unlock();
73414
73415 - return (ret == 0);
73416 + return ret;
73417 }
73418
73419 /**
73420 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
73421 int ret;
73422
73423 rcu_read_lock();
73424 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
73425 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
73426 rcu_read_unlock();
73427
73428 - return (ret == 0);
73429 + return ret;
73430 }
73431
73432 /**
73433 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
73434 BUG();
73435 }
73436
73437 - if (security_capable(current_cred(), ns, cap) == 0) {
73438 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
73439 current->flags |= PF_SUPERPRIV;
73440 return true;
73441 }
73442 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
73443 }
73444 EXPORT_SYMBOL(ns_capable);
73445
73446 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
73447 +{
73448 + if (unlikely(!cap_valid(cap))) {
73449 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
73450 + BUG();
73451 + }
73452 +
73453 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
73454 + current->flags |= PF_SUPERPRIV;
73455 + return true;
73456 + }
73457 + return false;
73458 +}
73459 +EXPORT_SYMBOL(ns_capable_nolog);
73460 +
73461 /**
73462 * file_ns_capable - Determine if the file's opener had a capability in effect
73463 * @file: The file we want to check
73464 @@ -432,6 +451,12 @@ bool capable(int cap)
73465 }
73466 EXPORT_SYMBOL(capable);
73467
73468 +bool capable_nolog(int cap)
73469 +{
73470 + return ns_capable_nolog(&init_user_ns, cap);
73471 +}
73472 +EXPORT_SYMBOL(capable_nolog);
73473 +
73474 /**
73475 * nsown_capable - Check superior capability to one's own user_ns
73476 * @cap: The capability in question
73477 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
73478
73479 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
73480 }
73481 +
73482 +bool inode_capable_nolog(const struct inode *inode, int cap)
73483 +{
73484 + struct user_namespace *ns = current_user_ns();
73485 +
73486 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
73487 +}
73488 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
73489 index ba1f977..f840d9c 100644
73490 --- a/kernel/cgroup.c
73491 +++ b/kernel/cgroup.c
73492 @@ -5569,7 +5569,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
73493 struct css_set *cg = link->cg;
73494 struct task_struct *task;
73495 int count = 0;
73496 - seq_printf(seq, "css_set %p\n", cg);
73497 + seq_printf(seq, "css_set %pK\n", cg);
73498 list_for_each_entry(task, &cg->tasks, cg_list) {
73499 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
73500 seq_puts(seq, " ...\n");
73501 diff --git a/kernel/compat.c b/kernel/compat.c
73502 index 19971d8..02fe2df 100644
73503 --- a/kernel/compat.c
73504 +++ b/kernel/compat.c
73505 @@ -13,6 +13,7 @@
73506
73507 #include <linux/linkage.h>
73508 #include <linux/compat.h>
73509 +#include <linux/module.h>
73510 #include <linux/errno.h>
73511 #include <linux/time.h>
73512 #include <linux/signal.h>
73513 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
73514 mm_segment_t oldfs;
73515 long ret;
73516
73517 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
73518 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
73519 oldfs = get_fs();
73520 set_fs(KERNEL_DS);
73521 ret = hrtimer_nanosleep_restart(restart);
73522 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
73523 oldfs = get_fs();
73524 set_fs(KERNEL_DS);
73525 ret = hrtimer_nanosleep(&tu,
73526 - rmtp ? (struct timespec __user *)&rmt : NULL,
73527 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
73528 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
73529 set_fs(oldfs);
73530
73531 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
73532 mm_segment_t old_fs = get_fs();
73533
73534 set_fs(KERNEL_DS);
73535 - ret = sys_sigpending((old_sigset_t __user *) &s);
73536 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
73537 set_fs(old_fs);
73538 if (ret == 0)
73539 ret = put_user(s, set);
73540 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
73541 mm_segment_t old_fs = get_fs();
73542
73543 set_fs(KERNEL_DS);
73544 - ret = sys_old_getrlimit(resource, &r);
73545 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
73546 set_fs(old_fs);
73547
73548 if (!ret) {
73549 @@ -523,7 +524,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
73550 mm_segment_t old_fs = get_fs();
73551
73552 set_fs(KERNEL_DS);
73553 - ret = sys_getrusage(who, (struct rusage __user *) &r);
73554 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
73555 set_fs(old_fs);
73556
73557 if (ret)
73558 @@ -552,8 +553,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
73559 set_fs (KERNEL_DS);
73560 ret = sys_wait4(pid,
73561 (stat_addr ?
73562 - (unsigned int __user *) &status : NULL),
73563 - options, (struct rusage __user *) &r);
73564 + (unsigned int __force_user *) &status : NULL),
73565 + options, (struct rusage __force_user *) &r);
73566 set_fs (old_fs);
73567
73568 if (ret > 0) {
73569 @@ -579,8 +580,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
73570 memset(&info, 0, sizeof(info));
73571
73572 set_fs(KERNEL_DS);
73573 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
73574 - uru ? (struct rusage __user *)&ru : NULL);
73575 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
73576 + uru ? (struct rusage __force_user *)&ru : NULL);
73577 set_fs(old_fs);
73578
73579 if ((ret < 0) || (info.si_signo == 0))
73580 @@ -714,8 +715,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
73581 oldfs = get_fs();
73582 set_fs(KERNEL_DS);
73583 err = sys_timer_settime(timer_id, flags,
73584 - (struct itimerspec __user *) &newts,
73585 - (struct itimerspec __user *) &oldts);
73586 + (struct itimerspec __force_user *) &newts,
73587 + (struct itimerspec __force_user *) &oldts);
73588 set_fs(oldfs);
73589 if (!err && old && put_compat_itimerspec(old, &oldts))
73590 return -EFAULT;
73591 @@ -732,7 +733,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
73592 oldfs = get_fs();
73593 set_fs(KERNEL_DS);
73594 err = sys_timer_gettime(timer_id,
73595 - (struct itimerspec __user *) &ts);
73596 + (struct itimerspec __force_user *) &ts);
73597 set_fs(oldfs);
73598 if (!err && put_compat_itimerspec(setting, &ts))
73599 return -EFAULT;
73600 @@ -751,7 +752,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
73601 oldfs = get_fs();
73602 set_fs(KERNEL_DS);
73603 err = sys_clock_settime(which_clock,
73604 - (struct timespec __user *) &ts);
73605 + (struct timespec __force_user *) &ts);
73606 set_fs(oldfs);
73607 return err;
73608 }
73609 @@ -766,7 +767,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
73610 oldfs = get_fs();
73611 set_fs(KERNEL_DS);
73612 err = sys_clock_gettime(which_clock,
73613 - (struct timespec __user *) &ts);
73614 + (struct timespec __force_user *) &ts);
73615 set_fs(oldfs);
73616 if (!err && put_compat_timespec(&ts, tp))
73617 return -EFAULT;
73618 @@ -786,7 +787,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
73619
73620 oldfs = get_fs();
73621 set_fs(KERNEL_DS);
73622 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
73623 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
73624 set_fs(oldfs);
73625
73626 err = compat_put_timex(utp, &txc);
73627 @@ -806,7 +807,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
73628 oldfs = get_fs();
73629 set_fs(KERNEL_DS);
73630 err = sys_clock_getres(which_clock,
73631 - (struct timespec __user *) &ts);
73632 + (struct timespec __force_user *) &ts);
73633 set_fs(oldfs);
73634 if (!err && tp && put_compat_timespec(&ts, tp))
73635 return -EFAULT;
73636 @@ -818,9 +819,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
73637 long err;
73638 mm_segment_t oldfs;
73639 struct timespec tu;
73640 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
73641 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
73642
73643 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
73644 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
73645 oldfs = get_fs();
73646 set_fs(KERNEL_DS);
73647 err = clock_nanosleep_restart(restart);
73648 @@ -852,8 +853,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
73649 oldfs = get_fs();
73650 set_fs(KERNEL_DS);
73651 err = sys_clock_nanosleep(which_clock, flags,
73652 - (struct timespec __user *) &in,
73653 - (struct timespec __user *) &out);
73654 + (struct timespec __force_user *) &in,
73655 + (struct timespec __force_user *) &out);
73656 set_fs(oldfs);
73657
73658 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
73659 diff --git a/kernel/configs.c b/kernel/configs.c
73660 index 42e8fa0..9e7406b 100644
73661 --- a/kernel/configs.c
73662 +++ b/kernel/configs.c
73663 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
73664 struct proc_dir_entry *entry;
73665
73666 /* create the current config file */
73667 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
73668 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
73669 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
73670 + &ikconfig_file_ops);
73671 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
73672 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
73673 + &ikconfig_file_ops);
73674 +#endif
73675 +#else
73676 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
73677 &ikconfig_file_ops);
73678 +#endif
73679 +
73680 if (!entry)
73681 return -ENOMEM;
73682
73683 diff --git a/kernel/cred.c b/kernel/cred.c
73684 index e0573a4..3874e41 100644
73685 --- a/kernel/cred.c
73686 +++ b/kernel/cred.c
73687 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
73688 validate_creds(cred);
73689 alter_cred_subscribers(cred, -1);
73690 put_cred(cred);
73691 +
73692 +#ifdef CONFIG_GRKERNSEC_SETXID
73693 + cred = (struct cred *) tsk->delayed_cred;
73694 + if (cred != NULL) {
73695 + tsk->delayed_cred = NULL;
73696 + validate_creds(cred);
73697 + alter_cred_subscribers(cred, -1);
73698 + put_cred(cred);
73699 + }
73700 +#endif
73701 }
73702
73703 /**
73704 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
73705 * Always returns 0 thus allowing this function to be tail-called at the end
73706 * of, say, sys_setgid().
73707 */
73708 -int commit_creds(struct cred *new)
73709 +static int __commit_creds(struct cred *new)
73710 {
73711 struct task_struct *task = current;
73712 const struct cred *old = task->real_cred;
73713 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
73714
73715 get_cred(new); /* we will require a ref for the subj creds too */
73716
73717 + gr_set_role_label(task, new->uid, new->gid);
73718 +
73719 /* dumpability changes */
73720 if (!uid_eq(old->euid, new->euid) ||
73721 !gid_eq(old->egid, new->egid) ||
73722 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
73723 put_cred(old);
73724 return 0;
73725 }
73726 +#ifdef CONFIG_GRKERNSEC_SETXID
73727 +extern int set_user(struct cred *new);
73728 +
73729 +void gr_delayed_cred_worker(void)
73730 +{
73731 + const struct cred *new = current->delayed_cred;
73732 + struct cred *ncred;
73733 +
73734 + current->delayed_cred = NULL;
73735 +
73736 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
73737 + // from doing get_cred on it when queueing this
73738 + put_cred(new);
73739 + return;
73740 + } else if (new == NULL)
73741 + return;
73742 +
73743 + ncred = prepare_creds();
73744 + if (!ncred)
73745 + goto die;
73746 + // uids
73747 + ncred->uid = new->uid;
73748 + ncred->euid = new->euid;
73749 + ncred->suid = new->suid;
73750 + ncred->fsuid = new->fsuid;
73751 + // gids
73752 + ncred->gid = new->gid;
73753 + ncred->egid = new->egid;
73754 + ncred->sgid = new->sgid;
73755 + ncred->fsgid = new->fsgid;
73756 + // groups
73757 + if (set_groups(ncred, new->group_info) < 0) {
73758 + abort_creds(ncred);
73759 + goto die;
73760 + }
73761 + // caps
73762 + ncred->securebits = new->securebits;
73763 + ncred->cap_inheritable = new->cap_inheritable;
73764 + ncred->cap_permitted = new->cap_permitted;
73765 + ncred->cap_effective = new->cap_effective;
73766 + ncred->cap_bset = new->cap_bset;
73767 +
73768 + if (set_user(ncred)) {
73769 + abort_creds(ncred);
73770 + goto die;
73771 + }
73772 +
73773 + // from doing get_cred on it when queueing this
73774 + put_cred(new);
73775 +
73776 + __commit_creds(ncred);
73777 + return;
73778 +die:
73779 + // from doing get_cred on it when queueing this
73780 + put_cred(new);
73781 + do_group_exit(SIGKILL);
73782 +}
73783 +#endif
73784 +
73785 +int commit_creds(struct cred *new)
73786 +{
73787 +#ifdef CONFIG_GRKERNSEC_SETXID
73788 + int ret;
73789 + int schedule_it = 0;
73790 + struct task_struct *t;
73791 +
73792 + /* we won't get called with tasklist_lock held for writing
73793 + and interrupts disabled as the cred struct in that case is
73794 + init_cred
73795 + */
73796 + if (grsec_enable_setxid && !current_is_single_threaded() &&
73797 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
73798 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
73799 + schedule_it = 1;
73800 + }
73801 + ret = __commit_creds(new);
73802 + if (schedule_it) {
73803 + rcu_read_lock();
73804 + read_lock(&tasklist_lock);
73805 + for (t = next_thread(current); t != current;
73806 + t = next_thread(t)) {
73807 + if (t->delayed_cred == NULL) {
73808 + t->delayed_cred = get_cred(new);
73809 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
73810 + set_tsk_need_resched(t);
73811 + }
73812 + }
73813 + read_unlock(&tasklist_lock);
73814 + rcu_read_unlock();
73815 + }
73816 + return ret;
73817 +#else
73818 + return __commit_creds(new);
73819 +#endif
73820 +}
73821 +
73822 EXPORT_SYMBOL(commit_creds);
73823
73824 /**
73825 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
73826 index c26278f..e323fb8 100644
73827 --- a/kernel/debug/debug_core.c
73828 +++ b/kernel/debug/debug_core.c
73829 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
73830 */
73831 static atomic_t masters_in_kgdb;
73832 static atomic_t slaves_in_kgdb;
73833 -static atomic_t kgdb_break_tasklet_var;
73834 +static atomic_unchecked_t kgdb_break_tasklet_var;
73835 atomic_t kgdb_setting_breakpoint;
73836
73837 struct task_struct *kgdb_usethread;
73838 @@ -133,7 +133,7 @@ int kgdb_single_step;
73839 static pid_t kgdb_sstep_pid;
73840
73841 /* to keep track of the CPU which is doing the single stepping*/
73842 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
73843 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
73844
73845 /*
73846 * If you are debugging a problem where roundup (the collection of
73847 @@ -541,7 +541,7 @@ return_normal:
73848 * kernel will only try for the value of sstep_tries before
73849 * giving up and continuing on.
73850 */
73851 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
73852 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
73853 (kgdb_info[cpu].task &&
73854 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
73855 atomic_set(&kgdb_active, -1);
73856 @@ -635,8 +635,8 @@ cpu_master_loop:
73857 }
73858
73859 kgdb_restore:
73860 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
73861 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
73862 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
73863 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
73864 if (kgdb_info[sstep_cpu].task)
73865 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
73866 else
73867 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
73868 static void kgdb_tasklet_bpt(unsigned long ing)
73869 {
73870 kgdb_breakpoint();
73871 - atomic_set(&kgdb_break_tasklet_var, 0);
73872 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
73873 }
73874
73875 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
73876
73877 void kgdb_schedule_breakpoint(void)
73878 {
73879 - if (atomic_read(&kgdb_break_tasklet_var) ||
73880 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
73881 atomic_read(&kgdb_active) != -1 ||
73882 atomic_read(&kgdb_setting_breakpoint))
73883 return;
73884 - atomic_inc(&kgdb_break_tasklet_var);
73885 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
73886 tasklet_schedule(&kgdb_tasklet_breakpoint);
73887 }
73888 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
73889 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
73890 index 00eb8f7..d7e3244 100644
73891 --- a/kernel/debug/kdb/kdb_main.c
73892 +++ b/kernel/debug/kdb/kdb_main.c
73893 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
73894 continue;
73895
73896 kdb_printf("%-20s%8u 0x%p ", mod->name,
73897 - mod->core_size, (void *)mod);
73898 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
73899 #ifdef CONFIG_MODULE_UNLOAD
73900 kdb_printf("%4ld ", module_refcount(mod));
73901 #endif
73902 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
73903 kdb_printf(" (Loading)");
73904 else
73905 kdb_printf(" (Live)");
73906 - kdb_printf(" 0x%p", mod->module_core);
73907 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
73908
73909 #ifdef CONFIG_MODULE_UNLOAD
73910 {
73911 diff --git a/kernel/events/core.c b/kernel/events/core.c
73912 index 9fcb094..44cda04 100644
73913 --- a/kernel/events/core.c
73914 +++ b/kernel/events/core.c
73915 @@ -182,7 +182,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
73916 return 0;
73917 }
73918
73919 -static atomic64_t perf_event_id;
73920 +static atomic64_unchecked_t perf_event_id;
73921
73922 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
73923 enum event_type_t event_type);
73924 @@ -2677,7 +2677,7 @@ static void __perf_event_read(void *info)
73925
73926 static inline u64 perf_event_count(struct perf_event *event)
73927 {
73928 - return local64_read(&event->count) + atomic64_read(&event->child_count);
73929 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
73930 }
73931
73932 static u64 perf_event_read(struct perf_event *event)
73933 @@ -3007,9 +3007,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
73934 mutex_lock(&event->child_mutex);
73935 total += perf_event_read(event);
73936 *enabled += event->total_time_enabled +
73937 - atomic64_read(&event->child_total_time_enabled);
73938 + atomic64_read_unchecked(&event->child_total_time_enabled);
73939 *running += event->total_time_running +
73940 - atomic64_read(&event->child_total_time_running);
73941 + atomic64_read_unchecked(&event->child_total_time_running);
73942
73943 list_for_each_entry(child, &event->child_list, child_list) {
73944 total += perf_event_read(child);
73945 @@ -3412,10 +3412,10 @@ void perf_event_update_userpage(struct perf_event *event)
73946 userpg->offset -= local64_read(&event->hw.prev_count);
73947
73948 userpg->time_enabled = enabled +
73949 - atomic64_read(&event->child_total_time_enabled);
73950 + atomic64_read_unchecked(&event->child_total_time_enabled);
73951
73952 userpg->time_running = running +
73953 - atomic64_read(&event->child_total_time_running);
73954 + atomic64_read_unchecked(&event->child_total_time_running);
73955
73956 arch_perf_update_userpage(userpg, now);
73957
73958 @@ -3974,11 +3974,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
73959 values[n++] = perf_event_count(event);
73960 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
73961 values[n++] = enabled +
73962 - atomic64_read(&event->child_total_time_enabled);
73963 + atomic64_read_unchecked(&event->child_total_time_enabled);
73964 }
73965 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
73966 values[n++] = running +
73967 - atomic64_read(&event->child_total_time_running);
73968 + atomic64_read_unchecked(&event->child_total_time_running);
73969 }
73970 if (read_format & PERF_FORMAT_ID)
73971 values[n++] = primary_event_id(event);
73972 @@ -4726,12 +4726,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
73973 * need to add enough zero bytes after the string to handle
73974 * the 64bit alignment we do later.
73975 */
73976 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
73977 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
73978 if (!buf) {
73979 name = strncpy(tmp, "//enomem", sizeof(tmp));
73980 goto got_name;
73981 }
73982 - name = d_path(&file->f_path, buf, PATH_MAX);
73983 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
73984 if (IS_ERR(name)) {
73985 name = strncpy(tmp, "//toolong", sizeof(tmp));
73986 goto got_name;
73987 @@ -6167,7 +6167,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
73988 event->parent = parent_event;
73989
73990 event->ns = get_pid_ns(task_active_pid_ns(current));
73991 - event->id = atomic64_inc_return(&perf_event_id);
73992 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
73993
73994 event->state = PERF_EVENT_STATE_INACTIVE;
73995
73996 @@ -6795,10 +6795,10 @@ static void sync_child_event(struct perf_event *child_event,
73997 /*
73998 * Add back the child's count to the parent's count:
73999 */
74000 - atomic64_add(child_val, &parent_event->child_count);
74001 - atomic64_add(child_event->total_time_enabled,
74002 + atomic64_add_unchecked(child_val, &parent_event->child_count);
74003 + atomic64_add_unchecked(child_event->total_time_enabled,
74004 &parent_event->child_total_time_enabled);
74005 - atomic64_add(child_event->total_time_running,
74006 + atomic64_add_unchecked(child_event->total_time_running,
74007 &parent_event->child_total_time_running);
74008
74009 /*
74010 diff --git a/kernel/exit.c b/kernel/exit.c
74011 index 60bc027..ca6d727 100644
74012 --- a/kernel/exit.c
74013 +++ b/kernel/exit.c
74014 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
74015 struct task_struct *leader;
74016 int zap_leader;
74017 repeat:
74018 +#ifdef CONFIG_NET
74019 + gr_del_task_from_ip_table(p);
74020 +#endif
74021 +
74022 /* don't need to get the RCU readlock here - the process is dead and
74023 * can't be modifying its own credentials. But shut RCU-lockdep up */
74024 rcu_read_lock();
74025 @@ -340,7 +344,7 @@ int allow_signal(int sig)
74026 * know it'll be handled, so that they don't get converted to
74027 * SIGKILL or just silently dropped.
74028 */
74029 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
74030 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
74031 recalc_sigpending();
74032 spin_unlock_irq(&current->sighand->siglock);
74033 return 0;
74034 @@ -710,6 +714,8 @@ void do_exit(long code)
74035 struct task_struct *tsk = current;
74036 int group_dead;
74037
74038 + set_fs(USER_DS);
74039 +
74040 profile_task_exit(tsk);
74041
74042 WARN_ON(blk_needs_flush_plug(tsk));
74043 @@ -726,7 +732,6 @@ void do_exit(long code)
74044 * mm_release()->clear_child_tid() from writing to a user-controlled
74045 * kernel address.
74046 */
74047 - set_fs(USER_DS);
74048
74049 ptrace_event(PTRACE_EVENT_EXIT, code);
74050
74051 @@ -785,6 +790,9 @@ void do_exit(long code)
74052 tsk->exit_code = code;
74053 taskstats_exit(tsk, group_dead);
74054
74055 + gr_acl_handle_psacct(tsk, code);
74056 + gr_acl_handle_exit();
74057 +
74058 exit_mm(tsk);
74059
74060 if (group_dead)
74061 @@ -905,7 +913,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
74062 * Take down every thread in the group. This is called by fatal signals
74063 * as well as by sys_exit_group (below).
74064 */
74065 -void
74066 +__noreturn void
74067 do_group_exit(int exit_code)
74068 {
74069 struct signal_struct *sig = current->signal;
74070 diff --git a/kernel/fork.c b/kernel/fork.c
74071 index 1766d32..c0e44e2 100644
74072 --- a/kernel/fork.c
74073 +++ b/kernel/fork.c
74074 @@ -318,7 +318,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
74075 *stackend = STACK_END_MAGIC; /* for overflow detection */
74076
74077 #ifdef CONFIG_CC_STACKPROTECTOR
74078 - tsk->stack_canary = get_random_int();
74079 + tsk->stack_canary = pax_get_random_long();
74080 #endif
74081
74082 /*
74083 @@ -344,13 +344,81 @@ free_tsk:
74084 }
74085
74086 #ifdef CONFIG_MMU
74087 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
74088 +{
74089 + struct vm_area_struct *tmp;
74090 + unsigned long charge;
74091 + struct mempolicy *pol;
74092 + struct file *file;
74093 +
74094 + charge = 0;
74095 + if (mpnt->vm_flags & VM_ACCOUNT) {
74096 + unsigned long len = vma_pages(mpnt);
74097 +
74098 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
74099 + goto fail_nomem;
74100 + charge = len;
74101 + }
74102 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
74103 + if (!tmp)
74104 + goto fail_nomem;
74105 + *tmp = *mpnt;
74106 + tmp->vm_mm = mm;
74107 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
74108 + pol = mpol_dup(vma_policy(mpnt));
74109 + if (IS_ERR(pol))
74110 + goto fail_nomem_policy;
74111 + vma_set_policy(tmp, pol);
74112 + if (anon_vma_fork(tmp, mpnt))
74113 + goto fail_nomem_anon_vma_fork;
74114 + tmp->vm_flags &= ~VM_LOCKED;
74115 + tmp->vm_next = tmp->vm_prev = NULL;
74116 + tmp->vm_mirror = NULL;
74117 + file = tmp->vm_file;
74118 + if (file) {
74119 + struct inode *inode = file_inode(file);
74120 + struct address_space *mapping = file->f_mapping;
74121 +
74122 + get_file(file);
74123 + if (tmp->vm_flags & VM_DENYWRITE)
74124 + atomic_dec(&inode->i_writecount);
74125 + mutex_lock(&mapping->i_mmap_mutex);
74126 + if (tmp->vm_flags & VM_SHARED)
74127 + mapping->i_mmap_writable++;
74128 + flush_dcache_mmap_lock(mapping);
74129 + /* insert tmp into the share list, just after mpnt */
74130 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
74131 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
74132 + else
74133 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
74134 + flush_dcache_mmap_unlock(mapping);
74135 + mutex_unlock(&mapping->i_mmap_mutex);
74136 + }
74137 +
74138 + /*
74139 + * Clear hugetlb-related page reserves for children. This only
74140 + * affects MAP_PRIVATE mappings. Faults generated by the child
74141 + * are not guaranteed to succeed, even if read-only
74142 + */
74143 + if (is_vm_hugetlb_page(tmp))
74144 + reset_vma_resv_huge_pages(tmp);
74145 +
74146 + return tmp;
74147 +
74148 +fail_nomem_anon_vma_fork:
74149 + mpol_put(pol);
74150 +fail_nomem_policy:
74151 + kmem_cache_free(vm_area_cachep, tmp);
74152 +fail_nomem:
74153 + vm_unacct_memory(charge);
74154 + return NULL;
74155 +}
74156 +
74157 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74158 {
74159 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
74160 struct rb_node **rb_link, *rb_parent;
74161 int retval;
74162 - unsigned long charge;
74163 - struct mempolicy *pol;
74164
74165 uprobe_start_dup_mmap();
74166 down_write(&oldmm->mmap_sem);
74167 @@ -364,8 +432,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74168 mm->locked_vm = 0;
74169 mm->mmap = NULL;
74170 mm->mmap_cache = NULL;
74171 - mm->free_area_cache = oldmm->mmap_base;
74172 - mm->cached_hole_size = ~0UL;
74173 + mm->free_area_cache = oldmm->free_area_cache;
74174 + mm->cached_hole_size = oldmm->cached_hole_size;
74175 mm->map_count = 0;
74176 cpumask_clear(mm_cpumask(mm));
74177 mm->mm_rb = RB_ROOT;
74178 @@ -381,57 +449,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74179
74180 prev = NULL;
74181 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
74182 - struct file *file;
74183 -
74184 if (mpnt->vm_flags & VM_DONTCOPY) {
74185 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
74186 -vma_pages(mpnt));
74187 continue;
74188 }
74189 - charge = 0;
74190 - if (mpnt->vm_flags & VM_ACCOUNT) {
74191 - unsigned long len = vma_pages(mpnt);
74192 -
74193 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
74194 - goto fail_nomem;
74195 - charge = len;
74196 - }
74197 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
74198 - if (!tmp)
74199 - goto fail_nomem;
74200 - *tmp = *mpnt;
74201 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
74202 - pol = mpol_dup(vma_policy(mpnt));
74203 - retval = PTR_ERR(pol);
74204 - if (IS_ERR(pol))
74205 - goto fail_nomem_policy;
74206 - vma_set_policy(tmp, pol);
74207 - tmp->vm_mm = mm;
74208 - if (anon_vma_fork(tmp, mpnt))
74209 - goto fail_nomem_anon_vma_fork;
74210 - tmp->vm_flags &= ~VM_LOCKED;
74211 - tmp->vm_next = tmp->vm_prev = NULL;
74212 - file = tmp->vm_file;
74213 - if (file) {
74214 - struct inode *inode = file_inode(file);
74215 - struct address_space *mapping = file->f_mapping;
74216 -
74217 - get_file(file);
74218 - if (tmp->vm_flags & VM_DENYWRITE)
74219 - atomic_dec(&inode->i_writecount);
74220 - mutex_lock(&mapping->i_mmap_mutex);
74221 - if (tmp->vm_flags & VM_SHARED)
74222 - mapping->i_mmap_writable++;
74223 - flush_dcache_mmap_lock(mapping);
74224 - /* insert tmp into the share list, just after mpnt */
74225 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
74226 - vma_nonlinear_insert(tmp,
74227 - &mapping->i_mmap_nonlinear);
74228 - else
74229 - vma_interval_tree_insert_after(tmp, mpnt,
74230 - &mapping->i_mmap);
74231 - flush_dcache_mmap_unlock(mapping);
74232 - mutex_unlock(&mapping->i_mmap_mutex);
74233 + tmp = dup_vma(mm, oldmm, mpnt);
74234 + if (!tmp) {
74235 + retval = -ENOMEM;
74236 + goto out;
74237 }
74238
74239 /*
74240 @@ -463,6 +489,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
74241 if (retval)
74242 goto out;
74243 }
74244 +
74245 +#ifdef CONFIG_PAX_SEGMEXEC
74246 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
74247 + struct vm_area_struct *mpnt_m;
74248 +
74249 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
74250 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
74251 +
74252 + if (!mpnt->vm_mirror)
74253 + continue;
74254 +
74255 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
74256 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
74257 + mpnt->vm_mirror = mpnt_m;
74258 + } else {
74259 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
74260 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
74261 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
74262 + mpnt->vm_mirror->vm_mirror = mpnt;
74263 + }
74264 + }
74265 + BUG_ON(mpnt_m);
74266 + }
74267 +#endif
74268 +
74269 /* a new mm has just been created */
74270 arch_dup_mmap(oldmm, mm);
74271 retval = 0;
74272 @@ -472,14 +523,6 @@ out:
74273 up_write(&oldmm->mmap_sem);
74274 uprobe_end_dup_mmap();
74275 return retval;
74276 -fail_nomem_anon_vma_fork:
74277 - mpol_put(pol);
74278 -fail_nomem_policy:
74279 - kmem_cache_free(vm_area_cachep, tmp);
74280 -fail_nomem:
74281 - retval = -ENOMEM;
74282 - vm_unacct_memory(charge);
74283 - goto out;
74284 }
74285
74286 static inline int mm_alloc_pgd(struct mm_struct *mm)
74287 @@ -694,8 +737,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
74288 return ERR_PTR(err);
74289
74290 mm = get_task_mm(task);
74291 - if (mm && mm != current->mm &&
74292 - !ptrace_may_access(task, mode)) {
74293 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
74294 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
74295 mmput(mm);
74296 mm = ERR_PTR(-EACCES);
74297 }
74298 @@ -917,13 +960,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
74299 spin_unlock(&fs->lock);
74300 return -EAGAIN;
74301 }
74302 - fs->users++;
74303 + atomic_inc(&fs->users);
74304 spin_unlock(&fs->lock);
74305 return 0;
74306 }
74307 tsk->fs = copy_fs_struct(fs);
74308 if (!tsk->fs)
74309 return -ENOMEM;
74310 + /* Carry through gr_chroot_dentry and is_chrooted instead
74311 + of recomputing it here. Already copied when the task struct
74312 + is duplicated. This allows pivot_root to not be treated as
74313 + a chroot
74314 + */
74315 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
74316 +
74317 return 0;
74318 }
74319
74320 @@ -1196,6 +1246,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
74321 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
74322 #endif
74323 retval = -EAGAIN;
74324 +
74325 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
74326 +
74327 if (atomic_read(&p->real_cred->user->processes) >=
74328 task_rlimit(p, RLIMIT_NPROC)) {
74329 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
74330 @@ -1441,6 +1494,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
74331 goto bad_fork_free_pid;
74332 }
74333
74334 + /* synchronizes with gr_set_acls()
74335 + we need to call this past the point of no return for fork()
74336 + */
74337 + gr_copy_label(p);
74338 +
74339 if (clone_flags & CLONE_THREAD) {
74340 current->signal->nr_threads++;
74341 atomic_inc(&current->signal->live);
74342 @@ -1524,6 +1582,8 @@ bad_fork_cleanup_count:
74343 bad_fork_free:
74344 free_task(p);
74345 fork_out:
74346 + gr_log_forkfail(retval);
74347 +
74348 return ERR_PTR(retval);
74349 }
74350
74351 @@ -1574,6 +1634,23 @@ long do_fork(unsigned long clone_flags,
74352 return -EINVAL;
74353 }
74354
74355 +#ifdef CONFIG_GRKERNSEC
74356 + if (clone_flags & CLONE_NEWUSER) {
74357 + /*
74358 + * This doesn't really inspire confidence:
74359 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
74360 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
74361 + * Increases kernel attack surface in areas developers
74362 + * previously cared little about ("low importance due
74363 + * to requiring "root" capability")
74364 + * To be removed when this code receives *proper* review
74365 + */
74366 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
74367 + !capable(CAP_SETGID))
74368 + return -EPERM;
74369 + }
74370 +#endif
74371 +
74372 /*
74373 * Determine whether and which event to report to ptracer. When
74374 * called from kernel_thread or CLONE_UNTRACED is explicitly
74375 @@ -1608,6 +1685,8 @@ long do_fork(unsigned long clone_flags,
74376 if (clone_flags & CLONE_PARENT_SETTID)
74377 put_user(nr, parent_tidptr);
74378
74379 + gr_handle_brute_check();
74380 +
74381 if (clone_flags & CLONE_VFORK) {
74382 p->vfork_done = &vfork;
74383 init_completion(&vfork);
74384 @@ -1761,7 +1840,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
74385 return 0;
74386
74387 /* don't need lock here; in the worst case we'll do useless copy */
74388 - if (fs->users == 1)
74389 + if (atomic_read(&fs->users) == 1)
74390 return 0;
74391
74392 *new_fsp = copy_fs_struct(fs);
74393 @@ -1873,7 +1952,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
74394 fs = current->fs;
74395 spin_lock(&fs->lock);
74396 current->fs = new_fs;
74397 - if (--fs->users)
74398 + gr_set_chroot_entries(current, &current->fs->root);
74399 + if (atomic_dec_return(&fs->users))
74400 new_fs = NULL;
74401 else
74402 new_fs = fs;
74403 diff --git a/kernel/futex.c b/kernel/futex.c
74404 index b26dcfc..39e266a 100644
74405 --- a/kernel/futex.c
74406 +++ b/kernel/futex.c
74407 @@ -54,6 +54,7 @@
74408 #include <linux/mount.h>
74409 #include <linux/pagemap.h>
74410 #include <linux/syscalls.h>
74411 +#include <linux/ptrace.h>
74412 #include <linux/signal.h>
74413 #include <linux/export.h>
74414 #include <linux/magic.h>
74415 @@ -241,6 +242,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
74416 struct page *page, *page_head;
74417 int err, ro = 0;
74418
74419 +#ifdef CONFIG_PAX_SEGMEXEC
74420 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
74421 + return -EFAULT;
74422 +#endif
74423 +
74424 /*
74425 * The futex address must be "naturally" aligned.
74426 */
74427 @@ -2732,6 +2738,7 @@ static int __init futex_init(void)
74428 {
74429 u32 curval;
74430 int i;
74431 + mm_segment_t oldfs;
74432
74433 /*
74434 * This will fail and we want it. Some arch implementations do
74435 @@ -2743,8 +2750,11 @@ static int __init futex_init(void)
74436 * implementation, the non-functional ones will return
74437 * -ENOSYS.
74438 */
74439 + oldfs = get_fs();
74440 + set_fs(USER_DS);
74441 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
74442 futex_cmpxchg_enabled = 1;
74443 + set_fs(oldfs);
74444
74445 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
74446 plist_head_init(&futex_queues[i].chain);
74447 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
74448 index f9f44fd..29885e4 100644
74449 --- a/kernel/futex_compat.c
74450 +++ b/kernel/futex_compat.c
74451 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
74452 return 0;
74453 }
74454
74455 -static void __user *futex_uaddr(struct robust_list __user *entry,
74456 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
74457 compat_long_t futex_offset)
74458 {
74459 compat_uptr_t base = ptr_to_compat(entry);
74460 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
74461 index 9b22d03..6295b62 100644
74462 --- a/kernel/gcov/base.c
74463 +++ b/kernel/gcov/base.c
74464 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
74465 }
74466
74467 #ifdef CONFIG_MODULES
74468 -static inline int within(void *addr, void *start, unsigned long size)
74469 -{
74470 - return ((addr >= start) && (addr < start + size));
74471 -}
74472 -
74473 /* Update list and generate events when modules are unloaded. */
74474 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
74475 void *data)
74476 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
74477 prev = NULL;
74478 /* Remove entries located in module from linked list. */
74479 for (info = gcov_info_head; info; info = info->next) {
74480 - if (within(info, mod->module_core, mod->core_size)) {
74481 + if (within_module_core_rw((unsigned long)info, mod)) {
74482 if (prev)
74483 prev->next = info->next;
74484 else
74485 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
74486 index 7ef5556..8247f11 100644
74487 --- a/kernel/hrtimer.c
74488 +++ b/kernel/hrtimer.c
74489 @@ -1416,7 +1416,7 @@ void hrtimer_peek_ahead_timers(void)
74490 local_irq_restore(flags);
74491 }
74492
74493 -static void run_hrtimer_softirq(struct softirq_action *h)
74494 +static void run_hrtimer_softirq(void)
74495 {
74496 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
74497
74498 @@ -1758,7 +1758,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
74499 return NOTIFY_OK;
74500 }
74501
74502 -static struct notifier_block __cpuinitdata hrtimers_nb = {
74503 +static struct notifier_block hrtimers_nb = {
74504 .notifier_call = hrtimer_cpu_notify,
74505 };
74506
74507 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
74508 index 55fcce6..0e4cf34 100644
74509 --- a/kernel/irq_work.c
74510 +++ b/kernel/irq_work.c
74511 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
74512 return NOTIFY_OK;
74513 }
74514
74515 -static struct notifier_block cpu_notify;
74516 +static struct notifier_block cpu_notify = {
74517 + .notifier_call = irq_work_cpu_notify,
74518 + .priority = 0,
74519 +};
74520
74521 static __init int irq_work_init_cpu_notifier(void)
74522 {
74523 - cpu_notify.notifier_call = irq_work_cpu_notify;
74524 - cpu_notify.priority = 0;
74525 register_cpu_notifier(&cpu_notify);
74526 return 0;
74527 }
74528 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
74529 index 60f48fa..7f3a770 100644
74530 --- a/kernel/jump_label.c
74531 +++ b/kernel/jump_label.c
74532 @@ -13,6 +13,7 @@
74533 #include <linux/sort.h>
74534 #include <linux/err.h>
74535 #include <linux/static_key.h>
74536 +#include <linux/mm.h>
74537
74538 #ifdef HAVE_JUMP_LABEL
74539
74540 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
74541
74542 size = (((unsigned long)stop - (unsigned long)start)
74543 / sizeof(struct jump_entry));
74544 + pax_open_kernel();
74545 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
74546 + pax_close_kernel();
74547 }
74548
74549 static void jump_label_update(struct static_key *key, int enable);
74550 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
74551 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
74552 struct jump_entry *iter;
74553
74554 + pax_open_kernel();
74555 for (iter = iter_start; iter < iter_stop; iter++) {
74556 if (within_module_init(iter->code, mod))
74557 iter->code = 0;
74558 }
74559 + pax_close_kernel();
74560 }
74561
74562 static int
74563 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
74564 index 2169fee..706ccca 100644
74565 --- a/kernel/kallsyms.c
74566 +++ b/kernel/kallsyms.c
74567 @@ -11,6 +11,9 @@
74568 * Changed the compression method from stem compression to "table lookup"
74569 * compression (see scripts/kallsyms.c for a more complete description)
74570 */
74571 +#ifdef CONFIG_GRKERNSEC_HIDESYM
74572 +#define __INCLUDED_BY_HIDESYM 1
74573 +#endif
74574 #include <linux/kallsyms.h>
74575 #include <linux/module.h>
74576 #include <linux/init.h>
74577 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
74578
74579 static inline int is_kernel_inittext(unsigned long addr)
74580 {
74581 + if (system_state != SYSTEM_BOOTING)
74582 + return 0;
74583 +
74584 if (addr >= (unsigned long)_sinittext
74585 && addr <= (unsigned long)_einittext)
74586 return 1;
74587 return 0;
74588 }
74589
74590 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
74591 +#ifdef CONFIG_MODULES
74592 +static inline int is_module_text(unsigned long addr)
74593 +{
74594 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
74595 + return 1;
74596 +
74597 + addr = ktla_ktva(addr);
74598 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
74599 +}
74600 +#else
74601 +static inline int is_module_text(unsigned long addr)
74602 +{
74603 + return 0;
74604 +}
74605 +#endif
74606 +#endif
74607 +
74608 static inline int is_kernel_text(unsigned long addr)
74609 {
74610 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
74611 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
74612
74613 static inline int is_kernel(unsigned long addr)
74614 {
74615 +
74616 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
74617 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
74618 + return 1;
74619 +
74620 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
74621 +#else
74622 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
74623 +#endif
74624 +
74625 return 1;
74626 return in_gate_area_no_mm(addr);
74627 }
74628
74629 static int is_ksym_addr(unsigned long addr)
74630 {
74631 +
74632 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
74633 + if (is_module_text(addr))
74634 + return 0;
74635 +#endif
74636 +
74637 if (all_var)
74638 return is_kernel(addr);
74639
74640 @@ -470,7 +509,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
74641
74642 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
74643 {
74644 - iter->name[0] = '\0';
74645 iter->nameoff = get_symbol_offset(new_pos);
74646 iter->pos = new_pos;
74647 }
74648 @@ -518,6 +556,11 @@ static int s_show(struct seq_file *m, void *p)
74649 {
74650 struct kallsym_iter *iter = m->private;
74651
74652 +#ifdef CONFIG_GRKERNSEC_HIDESYM
74653 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
74654 + return 0;
74655 +#endif
74656 +
74657 /* Some debugging symbols have no name. Ignore them. */
74658 if (!iter->name[0])
74659 return 0;
74660 @@ -531,6 +574,7 @@ static int s_show(struct seq_file *m, void *p)
74661 */
74662 type = iter->exported ? toupper(iter->type) :
74663 tolower(iter->type);
74664 +
74665 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
74666 type, iter->name, iter->module_name);
74667 } else
74668 @@ -556,7 +600,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
74669 struct kallsym_iter *iter;
74670 int ret;
74671
74672 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
74673 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
74674 if (!iter)
74675 return -ENOMEM;
74676 reset_iter(iter, 0);
74677 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
74678 index e30ac0f..3528cac 100644
74679 --- a/kernel/kcmp.c
74680 +++ b/kernel/kcmp.c
74681 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
74682 struct task_struct *task1, *task2;
74683 int ret;
74684
74685 +#ifdef CONFIG_GRKERNSEC
74686 + return -ENOSYS;
74687 +#endif
74688 +
74689 rcu_read_lock();
74690
74691 /*
74692 diff --git a/kernel/kexec.c b/kernel/kexec.c
74693 index ffd4e11..c3ff6bf 100644
74694 --- a/kernel/kexec.c
74695 +++ b/kernel/kexec.c
74696 @@ -1048,7 +1048,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
74697 unsigned long flags)
74698 {
74699 struct compat_kexec_segment in;
74700 - struct kexec_segment out, __user *ksegments;
74701 + struct kexec_segment out;
74702 + struct kexec_segment __user *ksegments;
74703 unsigned long i, result;
74704
74705 /* Don't allow clients that don't understand the native
74706 diff --git a/kernel/kmod.c b/kernel/kmod.c
74707 index 56dd349..336e1dc 100644
74708 --- a/kernel/kmod.c
74709 +++ b/kernel/kmod.c
74710 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
74711 kfree(info->argv);
74712 }
74713
74714 -static int call_modprobe(char *module_name, int wait)
74715 +static int call_modprobe(char *module_name, char *module_param, int wait)
74716 {
74717 static char *envp[] = {
74718 "HOME=/",
74719 @@ -84,7 +84,7 @@ static int call_modprobe(char *module_name, int wait)
74720 NULL
74721 };
74722
74723 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
74724 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
74725 if (!argv)
74726 goto out;
74727
74728 @@ -96,7 +96,8 @@ static int call_modprobe(char *module_name, int wait)
74729 argv[1] = "-q";
74730 argv[2] = "--";
74731 argv[3] = module_name; /* check free_modprobe_argv() */
74732 - argv[4] = NULL;
74733 + argv[4] = module_param;
74734 + argv[5] = NULL;
74735
74736 return call_usermodehelper_fns(modprobe_path, argv, envp,
74737 wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
74738 @@ -121,9 +122,8 @@ out:
74739 * If module auto-loading support is disabled then this function
74740 * becomes a no-operation.
74741 */
74742 -int __request_module(bool wait, const char *fmt, ...)
74743 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
74744 {
74745 - va_list args;
74746 char module_name[MODULE_NAME_LEN];
74747 unsigned int max_modprobes;
74748 int ret;
74749 @@ -139,9 +139,7 @@ int __request_module(bool wait, const char *fmt, ...)
74750 */
74751 WARN_ON_ONCE(wait && current_is_async());
74752
74753 - va_start(args, fmt);
74754 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
74755 - va_end(args);
74756 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
74757 if (ret >= MODULE_NAME_LEN)
74758 return -ENAMETOOLONG;
74759
74760 @@ -149,6 +147,20 @@ int __request_module(bool wait, const char *fmt, ...)
74761 if (ret)
74762 return ret;
74763
74764 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
74765 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
74766 + /* hack to workaround consolekit/udisks stupidity */
74767 + read_lock(&tasklist_lock);
74768 + if (!strcmp(current->comm, "mount") &&
74769 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
74770 + read_unlock(&tasklist_lock);
74771 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
74772 + return -EPERM;
74773 + }
74774 + read_unlock(&tasklist_lock);
74775 + }
74776 +#endif
74777 +
74778 /* If modprobe needs a service that is in a module, we get a recursive
74779 * loop. Limit the number of running kmod threads to max_threads/2 or
74780 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
74781 @@ -177,11 +189,52 @@ int __request_module(bool wait, const char *fmt, ...)
74782
74783 trace_module_request(module_name, wait, _RET_IP_);
74784
74785 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
74786 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
74787
74788 atomic_dec(&kmod_concurrent);
74789 return ret;
74790 }
74791 +
74792 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
74793 +{
74794 + va_list args;
74795 + int ret;
74796 +
74797 + va_start(args, fmt);
74798 + ret = ____request_module(wait, module_param, fmt, args);
74799 + va_end(args);
74800 +
74801 + return ret;
74802 +}
74803 +
74804 +int __request_module(bool wait, const char *fmt, ...)
74805 +{
74806 + va_list args;
74807 + int ret;
74808 +
74809 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
74810 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
74811 + char module_param[MODULE_NAME_LEN];
74812 +
74813 + memset(module_param, 0, sizeof(module_param));
74814 +
74815 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
74816 +
74817 + va_start(args, fmt);
74818 + ret = ____request_module(wait, module_param, fmt, args);
74819 + va_end(args);
74820 +
74821 + return ret;
74822 + }
74823 +#endif
74824 +
74825 + va_start(args, fmt);
74826 + ret = ____request_module(wait, NULL, fmt, args);
74827 + va_end(args);
74828 +
74829 + return ret;
74830 +}
74831 +
74832 EXPORT_SYMBOL(__request_module);
74833 #endif /* CONFIG_MODULES */
74834
74835 @@ -292,7 +345,7 @@ static int wait_for_helper(void *data)
74836 *
74837 * Thus the __user pointer cast is valid here.
74838 */
74839 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
74840 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
74841
74842 /*
74843 * If ret is 0, either ____call_usermodehelper failed and the
74844 @@ -644,7 +697,7 @@ EXPORT_SYMBOL(call_usermodehelper_fns);
74845 static int proc_cap_handler(struct ctl_table *table, int write,
74846 void __user *buffer, size_t *lenp, loff_t *ppos)
74847 {
74848 - struct ctl_table t;
74849 + ctl_table_no_const t;
74850 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
74851 kernel_cap_t new_cap;
74852 int err, i;
74853 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
74854 index 3fed7f0..a3f95ed 100644
74855 --- a/kernel/kprobes.c
74856 +++ b/kernel/kprobes.c
74857 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
74858 * kernel image and loaded module images reside. This is required
74859 * so x86_64 can correctly handle the %rip-relative fixups.
74860 */
74861 - kip->insns = module_alloc(PAGE_SIZE);
74862 + kip->insns = module_alloc_exec(PAGE_SIZE);
74863 if (!kip->insns) {
74864 kfree(kip);
74865 return NULL;
74866 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
74867 */
74868 if (!list_is_singular(&kip->list)) {
74869 list_del(&kip->list);
74870 - module_free(NULL, kip->insns);
74871 + module_free_exec(NULL, kip->insns);
74872 kfree(kip);
74873 }
74874 return 1;
74875 @@ -2073,7 +2073,7 @@ static int __init init_kprobes(void)
74876 {
74877 int i, err = 0;
74878 unsigned long offset = 0, size = 0;
74879 - char *modname, namebuf[128];
74880 + char *modname, namebuf[KSYM_NAME_LEN];
74881 const char *symbol_name;
74882 void *addr;
74883 struct kprobe_blackpoint *kb;
74884 @@ -2158,11 +2158,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
74885 kprobe_type = "k";
74886
74887 if (sym)
74888 - seq_printf(pi, "%p %s %s+0x%x %s ",
74889 + seq_printf(pi, "%pK %s %s+0x%x %s ",
74890 p->addr, kprobe_type, sym, offset,
74891 (modname ? modname : " "));
74892 else
74893 - seq_printf(pi, "%p %s %p ",
74894 + seq_printf(pi, "%pK %s %pK ",
74895 p->addr, kprobe_type, p->addr);
74896
74897 if (!pp)
74898 @@ -2199,7 +2199,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
74899 const char *sym = NULL;
74900 unsigned int i = *(loff_t *) v;
74901 unsigned long offset = 0;
74902 - char *modname, namebuf[128];
74903 + char *modname, namebuf[KSYM_NAME_LEN];
74904
74905 head = &kprobe_table[i];
74906 preempt_disable();
74907 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
74908 index 6ada93c..dce7d5d 100644
74909 --- a/kernel/ksysfs.c
74910 +++ b/kernel/ksysfs.c
74911 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
74912 {
74913 if (count+1 > UEVENT_HELPER_PATH_LEN)
74914 return -ENOENT;
74915 + if (!capable(CAP_SYS_ADMIN))
74916 + return -EPERM;
74917 memcpy(uevent_helper, buf, count);
74918 uevent_helper[count] = '\0';
74919 if (count && uevent_helper[count-1] == '\n')
74920 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
74921 return count;
74922 }
74923
74924 -static struct bin_attribute notes_attr = {
74925 +static bin_attribute_no_const notes_attr __read_only = {
74926 .attr = {
74927 .name = "notes",
74928 .mode = S_IRUGO,
74929 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
74930 index 8a0efac..56f1e2d 100644
74931 --- a/kernel/lockdep.c
74932 +++ b/kernel/lockdep.c
74933 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
74934 end = (unsigned long) &_end,
74935 addr = (unsigned long) obj;
74936
74937 +#ifdef CONFIG_PAX_KERNEXEC
74938 + start = ktla_ktva(start);
74939 +#endif
74940 +
74941 /*
74942 * static variable?
74943 */
74944 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
74945 if (!static_obj(lock->key)) {
74946 debug_locks_off();
74947 printk("INFO: trying to register non-static key.\n");
74948 + printk("lock:%pS key:%pS.\n", lock, lock->key);
74949 printk("the code is fine but needs lockdep annotation.\n");
74950 printk("turning off the locking correctness validator.\n");
74951 dump_stack();
74952 @@ -3078,7 +3083,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
74953 if (!class)
74954 return 0;
74955 }
74956 - atomic_inc((atomic_t *)&class->ops);
74957 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
74958 if (very_verbose(class)) {
74959 printk("\nacquire class [%p] %s", class->key, class->name);
74960 if (class->name_version > 1)
74961 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
74962 index b2c71c5..7b88d63 100644
74963 --- a/kernel/lockdep_proc.c
74964 +++ b/kernel/lockdep_proc.c
74965 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
74966 return 0;
74967 }
74968
74969 - seq_printf(m, "%p", class->key);
74970 + seq_printf(m, "%pK", class->key);
74971 #ifdef CONFIG_DEBUG_LOCKDEP
74972 seq_printf(m, " OPS:%8ld", class->ops);
74973 #endif
74974 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
74975
74976 list_for_each_entry(entry, &class->locks_after, entry) {
74977 if (entry->distance == 1) {
74978 - seq_printf(m, " -> [%p] ", entry->class->key);
74979 + seq_printf(m, " -> [%pK] ", entry->class->key);
74980 print_name(m, entry->class);
74981 seq_puts(m, "\n");
74982 }
74983 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
74984 if (!class->key)
74985 continue;
74986
74987 - seq_printf(m, "[%p] ", class->key);
74988 + seq_printf(m, "[%pK] ", class->key);
74989 print_name(m, class);
74990 seq_puts(m, "\n");
74991 }
74992 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
74993 if (!i)
74994 seq_line(m, '-', 40-namelen, namelen);
74995
74996 - snprintf(ip, sizeof(ip), "[<%p>]",
74997 + snprintf(ip, sizeof(ip), "[<%pK>]",
74998 (void *)class->contention_point[i]);
74999 seq_printf(m, "%40s %14lu %29s %pS\n",
75000 name, stats->contention_point[i],
75001 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
75002 if (!i)
75003 seq_line(m, '-', 40-namelen, namelen);
75004
75005 - snprintf(ip, sizeof(ip), "[<%p>]",
75006 + snprintf(ip, sizeof(ip), "[<%pK>]",
75007 (void *)class->contending_point[i]);
75008 seq_printf(m, "%40s %14lu %29s %pS\n",
75009 name, stats->contending_point[i],
75010 diff --git a/kernel/module.c b/kernel/module.c
75011 index 0925c9a..6b044ac 100644
75012 --- a/kernel/module.c
75013 +++ b/kernel/module.c
75014 @@ -61,6 +61,7 @@
75015 #include <linux/pfn.h>
75016 #include <linux/bsearch.h>
75017 #include <linux/fips.h>
75018 +#include <linux/grsecurity.h>
75019 #include <uapi/linux/module.h>
75020 #include "module-internal.h"
75021
75022 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
75023
75024 /* Bounds of module allocation, for speeding __module_address.
75025 * Protected by module_mutex. */
75026 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
75027 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
75028 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
75029
75030 int register_module_notifier(struct notifier_block * nb)
75031 {
75032 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
75033 return true;
75034
75035 list_for_each_entry_rcu(mod, &modules, list) {
75036 - struct symsearch arr[] = {
75037 + struct symsearch modarr[] = {
75038 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
75039 NOT_GPL_ONLY, false },
75040 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
75041 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
75042 if (mod->state == MODULE_STATE_UNFORMED)
75043 continue;
75044
75045 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
75046 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
75047 return true;
75048 }
75049 return false;
75050 @@ -485,7 +487,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
75051 static int percpu_modalloc(struct module *mod,
75052 unsigned long size, unsigned long align)
75053 {
75054 - if (align > PAGE_SIZE) {
75055 + if (align-1 >= PAGE_SIZE) {
75056 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
75057 mod->name, align, PAGE_SIZE);
75058 align = PAGE_SIZE;
75059 @@ -1089,7 +1091,7 @@ struct module_attribute module_uevent =
75060 static ssize_t show_coresize(struct module_attribute *mattr,
75061 struct module_kobject *mk, char *buffer)
75062 {
75063 - return sprintf(buffer, "%u\n", mk->mod->core_size);
75064 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
75065 }
75066
75067 static struct module_attribute modinfo_coresize =
75068 @@ -1098,7 +1100,7 @@ static struct module_attribute modinfo_coresize =
75069 static ssize_t show_initsize(struct module_attribute *mattr,
75070 struct module_kobject *mk, char *buffer)
75071 {
75072 - return sprintf(buffer, "%u\n", mk->mod->init_size);
75073 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
75074 }
75075
75076 static struct module_attribute modinfo_initsize =
75077 @@ -1312,7 +1314,7 @@ resolve_symbol_wait(struct module *mod,
75078 */
75079 #ifdef CONFIG_SYSFS
75080
75081 -#ifdef CONFIG_KALLSYMS
75082 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
75083 static inline bool sect_empty(const Elf_Shdr *sect)
75084 {
75085 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
75086 @@ -1452,7 +1454,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
75087 {
75088 unsigned int notes, loaded, i;
75089 struct module_notes_attrs *notes_attrs;
75090 - struct bin_attribute *nattr;
75091 + bin_attribute_no_const *nattr;
75092
75093 /* failed to create section attributes, so can't create notes */
75094 if (!mod->sect_attrs)
75095 @@ -1564,7 +1566,7 @@ static void del_usage_links(struct module *mod)
75096 static int module_add_modinfo_attrs(struct module *mod)
75097 {
75098 struct module_attribute *attr;
75099 - struct module_attribute *temp_attr;
75100 + module_attribute_no_const *temp_attr;
75101 int error = 0;
75102 int i;
75103
75104 @@ -1778,21 +1780,21 @@ static void set_section_ro_nx(void *base,
75105
75106 static void unset_module_core_ro_nx(struct module *mod)
75107 {
75108 - set_page_attributes(mod->module_core + mod->core_text_size,
75109 - mod->module_core + mod->core_size,
75110 + set_page_attributes(mod->module_core_rw,
75111 + mod->module_core_rw + mod->core_size_rw,
75112 set_memory_x);
75113 - set_page_attributes(mod->module_core,
75114 - mod->module_core + mod->core_ro_size,
75115 + set_page_attributes(mod->module_core_rx,
75116 + mod->module_core_rx + mod->core_size_rx,
75117 set_memory_rw);
75118 }
75119
75120 static void unset_module_init_ro_nx(struct module *mod)
75121 {
75122 - set_page_attributes(mod->module_init + mod->init_text_size,
75123 - mod->module_init + mod->init_size,
75124 + set_page_attributes(mod->module_init_rw,
75125 + mod->module_init_rw + mod->init_size_rw,
75126 set_memory_x);
75127 - set_page_attributes(mod->module_init,
75128 - mod->module_init + mod->init_ro_size,
75129 + set_page_attributes(mod->module_init_rx,
75130 + mod->module_init_rx + mod->init_size_rx,
75131 set_memory_rw);
75132 }
75133
75134 @@ -1805,14 +1807,14 @@ void set_all_modules_text_rw(void)
75135 list_for_each_entry_rcu(mod, &modules, list) {
75136 if (mod->state == MODULE_STATE_UNFORMED)
75137 continue;
75138 - if ((mod->module_core) && (mod->core_text_size)) {
75139 - set_page_attributes(mod->module_core,
75140 - mod->module_core + mod->core_text_size,
75141 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
75142 + set_page_attributes(mod->module_core_rx,
75143 + mod->module_core_rx + mod->core_size_rx,
75144 set_memory_rw);
75145 }
75146 - if ((mod->module_init) && (mod->init_text_size)) {
75147 - set_page_attributes(mod->module_init,
75148 - mod->module_init + mod->init_text_size,
75149 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
75150 + set_page_attributes(mod->module_init_rx,
75151 + mod->module_init_rx + mod->init_size_rx,
75152 set_memory_rw);
75153 }
75154 }
75155 @@ -1828,14 +1830,14 @@ void set_all_modules_text_ro(void)
75156 list_for_each_entry_rcu(mod, &modules, list) {
75157 if (mod->state == MODULE_STATE_UNFORMED)
75158 continue;
75159 - if ((mod->module_core) && (mod->core_text_size)) {
75160 - set_page_attributes(mod->module_core,
75161 - mod->module_core + mod->core_text_size,
75162 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
75163 + set_page_attributes(mod->module_core_rx,
75164 + mod->module_core_rx + mod->core_size_rx,
75165 set_memory_ro);
75166 }
75167 - if ((mod->module_init) && (mod->init_text_size)) {
75168 - set_page_attributes(mod->module_init,
75169 - mod->module_init + mod->init_text_size,
75170 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
75171 + set_page_attributes(mod->module_init_rx,
75172 + mod->module_init_rx + mod->init_size_rx,
75173 set_memory_ro);
75174 }
75175 }
75176 @@ -1881,16 +1883,19 @@ static void free_module(struct module *mod)
75177
75178 /* This may be NULL, but that's OK */
75179 unset_module_init_ro_nx(mod);
75180 - module_free(mod, mod->module_init);
75181 + module_free(mod, mod->module_init_rw);
75182 + module_free_exec(mod, mod->module_init_rx);
75183 kfree(mod->args);
75184 percpu_modfree(mod);
75185
75186 /* Free lock-classes: */
75187 - lockdep_free_key_range(mod->module_core, mod->core_size);
75188 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
75189 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
75190
75191 /* Finally, free the core (containing the module structure) */
75192 unset_module_core_ro_nx(mod);
75193 - module_free(mod, mod->module_core);
75194 + module_free_exec(mod, mod->module_core_rx);
75195 + module_free(mod, mod->module_core_rw);
75196
75197 #ifdef CONFIG_MPU
75198 update_protections(current->mm);
75199 @@ -1960,9 +1965,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75200 int ret = 0;
75201 const struct kernel_symbol *ksym;
75202
75203 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75204 + int is_fs_load = 0;
75205 + int register_filesystem_found = 0;
75206 + char *p;
75207 +
75208 + p = strstr(mod->args, "grsec_modharden_fs");
75209 + if (p) {
75210 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
75211 + /* copy \0 as well */
75212 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
75213 + is_fs_load = 1;
75214 + }
75215 +#endif
75216 +
75217 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
75218 const char *name = info->strtab + sym[i].st_name;
75219
75220 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75221 + /* it's a real shame this will never get ripped and copied
75222 + upstream! ;(
75223 + */
75224 + if (is_fs_load && !strcmp(name, "register_filesystem"))
75225 + register_filesystem_found = 1;
75226 +#endif
75227 +
75228 switch (sym[i].st_shndx) {
75229 case SHN_COMMON:
75230 /* We compiled with -fno-common. These are not
75231 @@ -1983,7 +2010,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75232 ksym = resolve_symbol_wait(mod, info, name);
75233 /* Ok if resolved. */
75234 if (ksym && !IS_ERR(ksym)) {
75235 + pax_open_kernel();
75236 sym[i].st_value = ksym->value;
75237 + pax_close_kernel();
75238 break;
75239 }
75240
75241 @@ -2002,11 +2031,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
75242 secbase = (unsigned long)mod_percpu(mod);
75243 else
75244 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
75245 + pax_open_kernel();
75246 sym[i].st_value += secbase;
75247 + pax_close_kernel();
75248 break;
75249 }
75250 }
75251
75252 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75253 + if (is_fs_load && !register_filesystem_found) {
75254 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
75255 + ret = -EPERM;
75256 + }
75257 +#endif
75258 +
75259 return ret;
75260 }
75261
75262 @@ -2090,22 +2128,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
75263 || s->sh_entsize != ~0UL
75264 || strstarts(sname, ".init"))
75265 continue;
75266 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
75267 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
75268 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
75269 + else
75270 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
75271 pr_debug("\t%s\n", sname);
75272 }
75273 - switch (m) {
75274 - case 0: /* executable */
75275 - mod->core_size = debug_align(mod->core_size);
75276 - mod->core_text_size = mod->core_size;
75277 - break;
75278 - case 1: /* RO: text and ro-data */
75279 - mod->core_size = debug_align(mod->core_size);
75280 - mod->core_ro_size = mod->core_size;
75281 - break;
75282 - case 3: /* whole core */
75283 - mod->core_size = debug_align(mod->core_size);
75284 - break;
75285 - }
75286 }
75287
75288 pr_debug("Init section allocation order:\n");
75289 @@ -2119,23 +2147,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
75290 || s->sh_entsize != ~0UL
75291 || !strstarts(sname, ".init"))
75292 continue;
75293 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
75294 - | INIT_OFFSET_MASK);
75295 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
75296 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
75297 + else
75298 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
75299 + s->sh_entsize |= INIT_OFFSET_MASK;
75300 pr_debug("\t%s\n", sname);
75301 }
75302 - switch (m) {
75303 - case 0: /* executable */
75304 - mod->init_size = debug_align(mod->init_size);
75305 - mod->init_text_size = mod->init_size;
75306 - break;
75307 - case 1: /* RO: text and ro-data */
75308 - mod->init_size = debug_align(mod->init_size);
75309 - mod->init_ro_size = mod->init_size;
75310 - break;
75311 - case 3: /* whole init */
75312 - mod->init_size = debug_align(mod->init_size);
75313 - break;
75314 - }
75315 }
75316 }
75317
75318 @@ -2308,7 +2326,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
75319
75320 /* Put symbol section at end of init part of module. */
75321 symsect->sh_flags |= SHF_ALLOC;
75322 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
75323 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
75324 info->index.sym) | INIT_OFFSET_MASK;
75325 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
75326
75327 @@ -2325,13 +2343,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
75328 }
75329
75330 /* Append room for core symbols at end of core part. */
75331 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
75332 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
75333 - mod->core_size += strtab_size;
75334 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
75335 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
75336 + mod->core_size_rx += strtab_size;
75337
75338 /* Put string table section at end of init part of module. */
75339 strsect->sh_flags |= SHF_ALLOC;
75340 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
75341 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
75342 info->index.str) | INIT_OFFSET_MASK;
75343 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
75344 }
75345 @@ -2349,12 +2367,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
75346 /* Make sure we get permanent strtab: don't use info->strtab. */
75347 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
75348
75349 + pax_open_kernel();
75350 +
75351 /* Set types up while we still have access to sections. */
75352 for (i = 0; i < mod->num_symtab; i++)
75353 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
75354
75355 - mod->core_symtab = dst = mod->module_core + info->symoffs;
75356 - mod->core_strtab = s = mod->module_core + info->stroffs;
75357 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
75358 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
75359 src = mod->symtab;
75360 for (ndst = i = 0; i < mod->num_symtab; i++) {
75361 if (i == 0 ||
75362 @@ -2366,6 +2386,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
75363 }
75364 }
75365 mod->core_num_syms = ndst;
75366 +
75367 + pax_close_kernel();
75368 }
75369 #else
75370 static inline void layout_symtab(struct module *mod, struct load_info *info)
75371 @@ -2399,17 +2421,33 @@ void * __weak module_alloc(unsigned long size)
75372 return vmalloc_exec(size);
75373 }
75374
75375 -static void *module_alloc_update_bounds(unsigned long size)
75376 +static void *module_alloc_update_bounds_rw(unsigned long size)
75377 {
75378 void *ret = module_alloc(size);
75379
75380 if (ret) {
75381 mutex_lock(&module_mutex);
75382 /* Update module bounds. */
75383 - if ((unsigned long)ret < module_addr_min)
75384 - module_addr_min = (unsigned long)ret;
75385 - if ((unsigned long)ret + size > module_addr_max)
75386 - module_addr_max = (unsigned long)ret + size;
75387 + if ((unsigned long)ret < module_addr_min_rw)
75388 + module_addr_min_rw = (unsigned long)ret;
75389 + if ((unsigned long)ret + size > module_addr_max_rw)
75390 + module_addr_max_rw = (unsigned long)ret + size;
75391 + mutex_unlock(&module_mutex);
75392 + }
75393 + return ret;
75394 +}
75395 +
75396 +static void *module_alloc_update_bounds_rx(unsigned long size)
75397 +{
75398 + void *ret = module_alloc_exec(size);
75399 +
75400 + if (ret) {
75401 + mutex_lock(&module_mutex);
75402 + /* Update module bounds. */
75403 + if ((unsigned long)ret < module_addr_min_rx)
75404 + module_addr_min_rx = (unsigned long)ret;
75405 + if ((unsigned long)ret + size > module_addr_max_rx)
75406 + module_addr_max_rx = (unsigned long)ret + size;
75407 mutex_unlock(&module_mutex);
75408 }
75409 return ret;
75410 @@ -2685,8 +2723,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
75411 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
75412 {
75413 const char *modmagic = get_modinfo(info, "vermagic");
75414 + const char *license = get_modinfo(info, "license");
75415 int err;
75416
75417 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
75418 + if (!license || !license_is_gpl_compatible(license))
75419 + return -ENOEXEC;
75420 +#endif
75421 +
75422 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
75423 modmagic = NULL;
75424
75425 @@ -2712,7 +2756,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
75426 }
75427
75428 /* Set up license info based on the info section */
75429 - set_license(mod, get_modinfo(info, "license"));
75430 + set_license(mod, license);
75431
75432 return 0;
75433 }
75434 @@ -2806,7 +2850,7 @@ static int move_module(struct module *mod, struct load_info *info)
75435 void *ptr;
75436
75437 /* Do the allocs. */
75438 - ptr = module_alloc_update_bounds(mod->core_size);
75439 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
75440 /*
75441 * The pointer to this block is stored in the module structure
75442 * which is inside the block. Just mark it as not being a
75443 @@ -2816,11 +2860,11 @@ static int move_module(struct module *mod, struct load_info *info)
75444 if (!ptr)
75445 return -ENOMEM;
75446
75447 - memset(ptr, 0, mod->core_size);
75448 - mod->module_core = ptr;
75449 + memset(ptr, 0, mod->core_size_rw);
75450 + mod->module_core_rw = ptr;
75451
75452 - if (mod->init_size) {
75453 - ptr = module_alloc_update_bounds(mod->init_size);
75454 + if (mod->init_size_rw) {
75455 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
75456 /*
75457 * The pointer to this block is stored in the module structure
75458 * which is inside the block. This block doesn't need to be
75459 @@ -2829,13 +2873,45 @@ static int move_module(struct module *mod, struct load_info *info)
75460 */
75461 kmemleak_ignore(ptr);
75462 if (!ptr) {
75463 - module_free(mod, mod->module_core);
75464 + module_free(mod, mod->module_core_rw);
75465 return -ENOMEM;
75466 }
75467 - memset(ptr, 0, mod->init_size);
75468 - mod->module_init = ptr;
75469 + memset(ptr, 0, mod->init_size_rw);
75470 + mod->module_init_rw = ptr;
75471 } else
75472 - mod->module_init = NULL;
75473 + mod->module_init_rw = NULL;
75474 +
75475 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
75476 + kmemleak_not_leak(ptr);
75477 + if (!ptr) {
75478 + if (mod->module_init_rw)
75479 + module_free(mod, mod->module_init_rw);
75480 + module_free(mod, mod->module_core_rw);
75481 + return -ENOMEM;
75482 + }
75483 +
75484 + pax_open_kernel();
75485 + memset(ptr, 0, mod->core_size_rx);
75486 + pax_close_kernel();
75487 + mod->module_core_rx = ptr;
75488 +
75489 + if (mod->init_size_rx) {
75490 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
75491 + kmemleak_ignore(ptr);
75492 + if (!ptr && mod->init_size_rx) {
75493 + module_free_exec(mod, mod->module_core_rx);
75494 + if (mod->module_init_rw)
75495 + module_free(mod, mod->module_init_rw);
75496 + module_free(mod, mod->module_core_rw);
75497 + return -ENOMEM;
75498 + }
75499 +
75500 + pax_open_kernel();
75501 + memset(ptr, 0, mod->init_size_rx);
75502 + pax_close_kernel();
75503 + mod->module_init_rx = ptr;
75504 + } else
75505 + mod->module_init_rx = NULL;
75506
75507 /* Transfer each section which specifies SHF_ALLOC */
75508 pr_debug("final section addresses:\n");
75509 @@ -2846,16 +2922,45 @@ static int move_module(struct module *mod, struct load_info *info)
75510 if (!(shdr->sh_flags & SHF_ALLOC))
75511 continue;
75512
75513 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
75514 - dest = mod->module_init
75515 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
75516 - else
75517 - dest = mod->module_core + shdr->sh_entsize;
75518 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
75519 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
75520 + dest = mod->module_init_rw
75521 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
75522 + else
75523 + dest = mod->module_init_rx
75524 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
75525 + } else {
75526 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
75527 + dest = mod->module_core_rw + shdr->sh_entsize;
75528 + else
75529 + dest = mod->module_core_rx + shdr->sh_entsize;
75530 + }
75531 +
75532 + if (shdr->sh_type != SHT_NOBITS) {
75533 +
75534 +#ifdef CONFIG_PAX_KERNEXEC
75535 +#ifdef CONFIG_X86_64
75536 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
75537 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
75538 +#endif
75539 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
75540 + pax_open_kernel();
75541 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
75542 + pax_close_kernel();
75543 + } else
75544 +#endif
75545
75546 - if (shdr->sh_type != SHT_NOBITS)
75547 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
75548 + }
75549 /* Update sh_addr to point to copy in image. */
75550 - shdr->sh_addr = (unsigned long)dest;
75551 +
75552 +#ifdef CONFIG_PAX_KERNEXEC
75553 + if (shdr->sh_flags & SHF_EXECINSTR)
75554 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
75555 + else
75556 +#endif
75557 +
75558 + shdr->sh_addr = (unsigned long)dest;
75559 pr_debug("\t0x%lx %s\n",
75560 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
75561 }
75562 @@ -2912,12 +3017,12 @@ static void flush_module_icache(const struct module *mod)
75563 * Do it before processing of module parameters, so the module
75564 * can provide parameter accessor functions of its own.
75565 */
75566 - if (mod->module_init)
75567 - flush_icache_range((unsigned long)mod->module_init,
75568 - (unsigned long)mod->module_init
75569 - + mod->init_size);
75570 - flush_icache_range((unsigned long)mod->module_core,
75571 - (unsigned long)mod->module_core + mod->core_size);
75572 + if (mod->module_init_rx)
75573 + flush_icache_range((unsigned long)mod->module_init_rx,
75574 + (unsigned long)mod->module_init_rx
75575 + + mod->init_size_rx);
75576 + flush_icache_range((unsigned long)mod->module_core_rx,
75577 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
75578
75579 set_fs(old_fs);
75580 }
75581 @@ -2987,8 +3092,10 @@ out:
75582 static void module_deallocate(struct module *mod, struct load_info *info)
75583 {
75584 percpu_modfree(mod);
75585 - module_free(mod, mod->module_init);
75586 - module_free(mod, mod->module_core);
75587 + module_free_exec(mod, mod->module_init_rx);
75588 + module_free_exec(mod, mod->module_core_rx);
75589 + module_free(mod, mod->module_init_rw);
75590 + module_free(mod, mod->module_core_rw);
75591 }
75592
75593 int __weak module_finalize(const Elf_Ehdr *hdr,
75594 @@ -3001,7 +3108,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
75595 static int post_relocation(struct module *mod, const struct load_info *info)
75596 {
75597 /* Sort exception table now relocations are done. */
75598 + pax_open_kernel();
75599 sort_extable(mod->extable, mod->extable + mod->num_exentries);
75600 + pax_close_kernel();
75601
75602 /* Copy relocated percpu area over. */
75603 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
75604 @@ -3055,16 +3164,16 @@ static int do_init_module(struct module *mod)
75605 MODULE_STATE_COMING, mod);
75606
75607 /* Set RO and NX regions for core */
75608 - set_section_ro_nx(mod->module_core,
75609 - mod->core_text_size,
75610 - mod->core_ro_size,
75611 - mod->core_size);
75612 + set_section_ro_nx(mod->module_core_rx,
75613 + mod->core_size_rx,
75614 + mod->core_size_rx,
75615 + mod->core_size_rx);
75616
75617 /* Set RO and NX regions for init */
75618 - set_section_ro_nx(mod->module_init,
75619 - mod->init_text_size,
75620 - mod->init_ro_size,
75621 - mod->init_size);
75622 + set_section_ro_nx(mod->module_init_rx,
75623 + mod->init_size_rx,
75624 + mod->init_size_rx,
75625 + mod->init_size_rx);
75626
75627 do_mod_ctors(mod);
75628 /* Start the module */
75629 @@ -3126,11 +3235,12 @@ static int do_init_module(struct module *mod)
75630 mod->strtab = mod->core_strtab;
75631 #endif
75632 unset_module_init_ro_nx(mod);
75633 - module_free(mod, mod->module_init);
75634 - mod->module_init = NULL;
75635 - mod->init_size = 0;
75636 - mod->init_ro_size = 0;
75637 - mod->init_text_size = 0;
75638 + module_free(mod, mod->module_init_rw);
75639 + module_free_exec(mod, mod->module_init_rx);
75640 + mod->module_init_rw = NULL;
75641 + mod->module_init_rx = NULL;
75642 + mod->init_size_rw = 0;
75643 + mod->init_size_rx = 0;
75644 mutex_unlock(&module_mutex);
75645 wake_up_all(&module_wq);
75646
75647 @@ -3257,9 +3367,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
75648 if (err)
75649 goto free_unload;
75650
75651 + /* Now copy in args */
75652 + mod->args = strndup_user(uargs, ~0UL >> 1);
75653 + if (IS_ERR(mod->args)) {
75654 + err = PTR_ERR(mod->args);
75655 + goto free_unload;
75656 + }
75657 +
75658 /* Set up MODINFO_ATTR fields */
75659 setup_modinfo(mod, info);
75660
75661 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75662 + {
75663 + char *p, *p2;
75664 +
75665 + if (strstr(mod->args, "grsec_modharden_netdev")) {
75666 + 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);
75667 + err = -EPERM;
75668 + goto free_modinfo;
75669 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
75670 + p += sizeof("grsec_modharden_normal") - 1;
75671 + p2 = strstr(p, "_");
75672 + if (p2) {
75673 + *p2 = '\0';
75674 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
75675 + *p2 = '_';
75676 + }
75677 + err = -EPERM;
75678 + goto free_modinfo;
75679 + }
75680 + }
75681 +#endif
75682 +
75683 /* Fix up syms, so that st_value is a pointer to location. */
75684 err = simplify_symbols(mod, info);
75685 if (err < 0)
75686 @@ -3275,13 +3414,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
75687
75688 flush_module_icache(mod);
75689
75690 - /* Now copy in args */
75691 - mod->args = strndup_user(uargs, ~0UL >> 1);
75692 - if (IS_ERR(mod->args)) {
75693 - err = PTR_ERR(mod->args);
75694 - goto free_arch_cleanup;
75695 - }
75696 -
75697 dynamic_debug_setup(info->debug, info->num_debug);
75698
75699 /* Finally it's fully formed, ready to start executing. */
75700 @@ -3316,11 +3448,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
75701 ddebug_cleanup:
75702 dynamic_debug_remove(info->debug);
75703 synchronize_sched();
75704 - kfree(mod->args);
75705 - free_arch_cleanup:
75706 module_arch_cleanup(mod);
75707 free_modinfo:
75708 free_modinfo(mod);
75709 + kfree(mod->args);
75710 free_unload:
75711 module_unload_free(mod);
75712 unlink_mod:
75713 @@ -3403,10 +3534,16 @@ static const char *get_ksymbol(struct module *mod,
75714 unsigned long nextval;
75715
75716 /* At worse, next value is at end of module */
75717 - if (within_module_init(addr, mod))
75718 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
75719 + if (within_module_init_rx(addr, mod))
75720 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
75721 + else if (within_module_init_rw(addr, mod))
75722 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
75723 + else if (within_module_core_rx(addr, mod))
75724 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
75725 + else if (within_module_core_rw(addr, mod))
75726 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
75727 else
75728 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
75729 + return NULL;
75730
75731 /* Scan for closest preceding symbol, and next symbol. (ELF
75732 starts real symbols at 1). */
75733 @@ -3659,7 +3796,7 @@ static int m_show(struct seq_file *m, void *p)
75734 return 0;
75735
75736 seq_printf(m, "%s %u",
75737 - mod->name, mod->init_size + mod->core_size);
75738 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
75739 print_unload_info(m, mod);
75740
75741 /* Informative for users. */
75742 @@ -3668,7 +3805,7 @@ static int m_show(struct seq_file *m, void *p)
75743 mod->state == MODULE_STATE_COMING ? "Loading":
75744 "Live");
75745 /* Used by oprofile and other similar tools. */
75746 - seq_printf(m, " 0x%pK", mod->module_core);
75747 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
75748
75749 /* Taints info */
75750 if (mod->taints)
75751 @@ -3704,7 +3841,17 @@ static const struct file_operations proc_modules_operations = {
75752
75753 static int __init proc_modules_init(void)
75754 {
75755 +#ifndef CONFIG_GRKERNSEC_HIDESYM
75756 +#ifdef CONFIG_GRKERNSEC_PROC_USER
75757 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
75758 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75759 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
75760 +#else
75761 proc_create("modules", 0, NULL, &proc_modules_operations);
75762 +#endif
75763 +#else
75764 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
75765 +#endif
75766 return 0;
75767 }
75768 module_init(proc_modules_init);
75769 @@ -3765,14 +3912,14 @@ struct module *__module_address(unsigned long addr)
75770 {
75771 struct module *mod;
75772
75773 - if (addr < module_addr_min || addr > module_addr_max)
75774 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
75775 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
75776 return NULL;
75777
75778 list_for_each_entry_rcu(mod, &modules, list) {
75779 if (mod->state == MODULE_STATE_UNFORMED)
75780 continue;
75781 - if (within_module_core(addr, mod)
75782 - || within_module_init(addr, mod))
75783 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
75784 return mod;
75785 }
75786 return NULL;
75787 @@ -3807,11 +3954,20 @@ bool is_module_text_address(unsigned long addr)
75788 */
75789 struct module *__module_text_address(unsigned long addr)
75790 {
75791 - struct module *mod = __module_address(addr);
75792 + struct module *mod;
75793 +
75794 +#ifdef CONFIG_X86_32
75795 + addr = ktla_ktva(addr);
75796 +#endif
75797 +
75798 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
75799 + return NULL;
75800 +
75801 + mod = __module_address(addr);
75802 +
75803 if (mod) {
75804 /* Make sure it's within the text section. */
75805 - if (!within(addr, mod->module_init, mod->init_text_size)
75806 - && !within(addr, mod->module_core, mod->core_text_size))
75807 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
75808 mod = NULL;
75809 }
75810 return mod;
75811 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
75812 index 7e3443f..b2a1e6b 100644
75813 --- a/kernel/mutex-debug.c
75814 +++ b/kernel/mutex-debug.c
75815 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
75816 }
75817
75818 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
75819 - struct thread_info *ti)
75820 + struct task_struct *task)
75821 {
75822 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
75823
75824 /* Mark the current thread as blocked on the lock: */
75825 - ti->task->blocked_on = waiter;
75826 + task->blocked_on = waiter;
75827 }
75828
75829 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
75830 - struct thread_info *ti)
75831 + struct task_struct *task)
75832 {
75833 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
75834 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
75835 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
75836 - ti->task->blocked_on = NULL;
75837 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
75838 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
75839 + task->blocked_on = NULL;
75840
75841 list_del_init(&waiter->list);
75842 waiter->task = NULL;
75843 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
75844 index 0799fd3..d06ae3b 100644
75845 --- a/kernel/mutex-debug.h
75846 +++ b/kernel/mutex-debug.h
75847 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
75848 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
75849 extern void debug_mutex_add_waiter(struct mutex *lock,
75850 struct mutex_waiter *waiter,
75851 - struct thread_info *ti);
75852 + struct task_struct *task);
75853 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
75854 - struct thread_info *ti);
75855 + struct task_struct *task);
75856 extern void debug_mutex_unlock(struct mutex *lock);
75857 extern void debug_mutex_init(struct mutex *lock, const char *name,
75858 struct lock_class_key *key);
75859 diff --git a/kernel/mutex.c b/kernel/mutex.c
75860 index 52f2301..73f7528 100644
75861 --- a/kernel/mutex.c
75862 +++ b/kernel/mutex.c
75863 @@ -199,7 +199,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
75864 spin_lock_mutex(&lock->wait_lock, flags);
75865
75866 debug_mutex_lock_common(lock, &waiter);
75867 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
75868 + debug_mutex_add_waiter(lock, &waiter, task);
75869
75870 /* add waiting tasks to the end of the waitqueue (FIFO): */
75871 list_add_tail(&waiter.list, &lock->wait_list);
75872 @@ -228,8 +228,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
75873 * TASK_UNINTERRUPTIBLE case.)
75874 */
75875 if (unlikely(signal_pending_state(state, task))) {
75876 - mutex_remove_waiter(lock, &waiter,
75877 - task_thread_info(task));
75878 + mutex_remove_waiter(lock, &waiter, task);
75879 mutex_release(&lock->dep_map, 1, ip);
75880 spin_unlock_mutex(&lock->wait_lock, flags);
75881
75882 @@ -248,7 +247,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
75883 done:
75884 lock_acquired(&lock->dep_map, ip);
75885 /* got the lock - rejoice! */
75886 - mutex_remove_waiter(lock, &waiter, current_thread_info());
75887 + mutex_remove_waiter(lock, &waiter, task);
75888 mutex_set_owner(lock);
75889
75890 /* set it to 0 if there are no waiters left: */
75891 diff --git a/kernel/notifier.c b/kernel/notifier.c
75892 index 2d5cc4c..d9ea600 100644
75893 --- a/kernel/notifier.c
75894 +++ b/kernel/notifier.c
75895 @@ -5,6 +5,7 @@
75896 #include <linux/rcupdate.h>
75897 #include <linux/vmalloc.h>
75898 #include <linux/reboot.h>
75899 +#include <linux/mm.h>
75900
75901 /*
75902 * Notifier list for kernel code which wants to be called
75903 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
75904 while ((*nl) != NULL) {
75905 if (n->priority > (*nl)->priority)
75906 break;
75907 - nl = &((*nl)->next);
75908 + nl = (struct notifier_block **)&((*nl)->next);
75909 }
75910 - n->next = *nl;
75911 + pax_open_kernel();
75912 + *(const void **)&n->next = *nl;
75913 rcu_assign_pointer(*nl, n);
75914 + pax_close_kernel();
75915 return 0;
75916 }
75917
75918 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
75919 return 0;
75920 if (n->priority > (*nl)->priority)
75921 break;
75922 - nl = &((*nl)->next);
75923 + nl = (struct notifier_block **)&((*nl)->next);
75924 }
75925 - n->next = *nl;
75926 + pax_open_kernel();
75927 + *(const void **)&n->next = *nl;
75928 rcu_assign_pointer(*nl, n);
75929 + pax_close_kernel();
75930 return 0;
75931 }
75932
75933 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
75934 {
75935 while ((*nl) != NULL) {
75936 if ((*nl) == n) {
75937 + pax_open_kernel();
75938 rcu_assign_pointer(*nl, n->next);
75939 + pax_close_kernel();
75940 return 0;
75941 }
75942 - nl = &((*nl)->next);
75943 + nl = (struct notifier_block **)&((*nl)->next);
75944 }
75945 return -ENOENT;
75946 }
75947 diff --git a/kernel/panic.c b/kernel/panic.c
75948 index 7c57cc9..28f1b3f 100644
75949 --- a/kernel/panic.c
75950 +++ b/kernel/panic.c
75951 @@ -403,7 +403,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
75952 const char *board;
75953
75954 printk(KERN_WARNING "------------[ cut here ]------------\n");
75955 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
75956 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
75957 board = dmi_get_system_info(DMI_PRODUCT_NAME);
75958 if (board)
75959 printk(KERN_WARNING "Hardware name: %s\n", board);
75960 @@ -459,7 +459,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
75961 */
75962 void __stack_chk_fail(void)
75963 {
75964 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
75965 + dump_stack();
75966 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
75967 __builtin_return_address(0));
75968 }
75969 EXPORT_SYMBOL(__stack_chk_fail);
75970 diff --git a/kernel/pid.c b/kernel/pid.c
75971 index 047dc62..418d74b 100644
75972 --- a/kernel/pid.c
75973 +++ b/kernel/pid.c
75974 @@ -33,6 +33,7 @@
75975 #include <linux/rculist.h>
75976 #include <linux/bootmem.h>
75977 #include <linux/hash.h>
75978 +#include <linux/security.h>
75979 #include <linux/pid_namespace.h>
75980 #include <linux/init_task.h>
75981 #include <linux/syscalls.h>
75982 @@ -46,7 +47,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
75983
75984 int pid_max = PID_MAX_DEFAULT;
75985
75986 -#define RESERVED_PIDS 300
75987 +#define RESERVED_PIDS 500
75988
75989 int pid_max_min = RESERVED_PIDS + 1;
75990 int pid_max_max = PID_MAX_LIMIT;
75991 @@ -440,10 +441,18 @@ EXPORT_SYMBOL(pid_task);
75992 */
75993 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
75994 {
75995 + struct task_struct *task;
75996 +
75997 rcu_lockdep_assert(rcu_read_lock_held(),
75998 "find_task_by_pid_ns() needs rcu_read_lock()"
75999 " protection");
76000 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
76001 +
76002 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
76003 +
76004 + if (gr_pid_is_chrooted(task))
76005 + return NULL;
76006 +
76007 + return task;
76008 }
76009
76010 struct task_struct *find_task_by_vpid(pid_t vnr)
76011 @@ -451,6 +460,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
76012 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
76013 }
76014
76015 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
76016 +{
76017 + rcu_lockdep_assert(rcu_read_lock_held(),
76018 + "find_task_by_pid_ns() needs rcu_read_lock()"
76019 + " protection");
76020 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
76021 +}
76022 +
76023 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
76024 {
76025 struct pid *pid;
76026 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
76027 index bea15bd..789f3d0 100644
76028 --- a/kernel/pid_namespace.c
76029 +++ b/kernel/pid_namespace.c
76030 @@ -249,7 +249,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
76031 void __user *buffer, size_t *lenp, loff_t *ppos)
76032 {
76033 struct pid_namespace *pid_ns = task_active_pid_ns(current);
76034 - struct ctl_table tmp = *table;
76035 + ctl_table_no_const tmp = *table;
76036
76037 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
76038 return -EPERM;
76039 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
76040 index 8fd709c..542bf4b 100644
76041 --- a/kernel/posix-cpu-timers.c
76042 +++ b/kernel/posix-cpu-timers.c
76043 @@ -1592,14 +1592,14 @@ struct k_clock clock_posix_cpu = {
76044
76045 static __init int init_posix_cpu_timers(void)
76046 {
76047 - struct k_clock process = {
76048 + static struct k_clock process = {
76049 .clock_getres = process_cpu_clock_getres,
76050 .clock_get = process_cpu_clock_get,
76051 .timer_create = process_cpu_timer_create,
76052 .nsleep = process_cpu_nsleep,
76053 .nsleep_restart = process_cpu_nsleep_restart,
76054 };
76055 - struct k_clock thread = {
76056 + static struct k_clock thread = {
76057 .clock_getres = thread_cpu_clock_getres,
76058 .clock_get = thread_cpu_clock_get,
76059 .timer_create = thread_cpu_timer_create,
76060 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
76061 index 6edbb2c..334f085 100644
76062 --- a/kernel/posix-timers.c
76063 +++ b/kernel/posix-timers.c
76064 @@ -43,6 +43,7 @@
76065 #include <linux/idr.h>
76066 #include <linux/posix-clock.h>
76067 #include <linux/posix-timers.h>
76068 +#include <linux/grsecurity.h>
76069 #include <linux/syscalls.h>
76070 #include <linux/wait.h>
76071 #include <linux/workqueue.h>
76072 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
76073 * which we beg off on and pass to do_sys_settimeofday().
76074 */
76075
76076 -static struct k_clock posix_clocks[MAX_CLOCKS];
76077 +static struct k_clock *posix_clocks[MAX_CLOCKS];
76078
76079 /*
76080 * These ones are defined below.
76081 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
76082 */
76083 static __init int init_posix_timers(void)
76084 {
76085 - struct k_clock clock_realtime = {
76086 + static struct k_clock clock_realtime = {
76087 .clock_getres = hrtimer_get_res,
76088 .clock_get = posix_clock_realtime_get,
76089 .clock_set = posix_clock_realtime_set,
76090 @@ -239,7 +240,7 @@ static __init int init_posix_timers(void)
76091 .timer_get = common_timer_get,
76092 .timer_del = common_timer_del,
76093 };
76094 - struct k_clock clock_monotonic = {
76095 + static struct k_clock clock_monotonic = {
76096 .clock_getres = hrtimer_get_res,
76097 .clock_get = posix_ktime_get_ts,
76098 .nsleep = common_nsleep,
76099 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
76100 .timer_get = common_timer_get,
76101 .timer_del = common_timer_del,
76102 };
76103 - struct k_clock clock_monotonic_raw = {
76104 + static struct k_clock clock_monotonic_raw = {
76105 .clock_getres = hrtimer_get_res,
76106 .clock_get = posix_get_monotonic_raw,
76107 };
76108 - struct k_clock clock_realtime_coarse = {
76109 + static struct k_clock clock_realtime_coarse = {
76110 .clock_getres = posix_get_coarse_res,
76111 .clock_get = posix_get_realtime_coarse,
76112 };
76113 - struct k_clock clock_monotonic_coarse = {
76114 + static struct k_clock clock_monotonic_coarse = {
76115 .clock_getres = posix_get_coarse_res,
76116 .clock_get = posix_get_monotonic_coarse,
76117 };
76118 - struct k_clock clock_boottime = {
76119 + static struct k_clock clock_boottime = {
76120 .clock_getres = hrtimer_get_res,
76121 .clock_get = posix_get_boottime,
76122 .nsleep = common_nsleep,
76123 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
76124 return;
76125 }
76126
76127 - posix_clocks[clock_id] = *new_clock;
76128 + posix_clocks[clock_id] = new_clock;
76129 }
76130 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
76131
76132 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
76133 return (id & CLOCKFD_MASK) == CLOCKFD ?
76134 &clock_posix_dynamic : &clock_posix_cpu;
76135
76136 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
76137 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
76138 return NULL;
76139 - return &posix_clocks[id];
76140 + return posix_clocks[id];
76141 }
76142
76143 static int common_timer_create(struct k_itimer *new_timer)
76144 @@ -964,6 +965,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
76145 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
76146 return -EFAULT;
76147
76148 + /* only the CLOCK_REALTIME clock can be set, all other clocks
76149 + have their clock_set fptr set to a nosettime dummy function
76150 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
76151 + call common_clock_set, which calls do_sys_settimeofday, which
76152 + we hook
76153 + */
76154 +
76155 return kc->clock_set(which_clock, &new_tp);
76156 }
76157
76158 diff --git a/kernel/power/process.c b/kernel/power/process.c
76159 index 98088e0..aaf95c0 100644
76160 --- a/kernel/power/process.c
76161 +++ b/kernel/power/process.c
76162 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
76163 u64 elapsed_csecs64;
76164 unsigned int elapsed_csecs;
76165 bool wakeup = false;
76166 + bool timedout = false;
76167
76168 do_gettimeofday(&start);
76169
76170 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
76171
76172 while (true) {
76173 todo = 0;
76174 + if (time_after(jiffies, end_time))
76175 + timedout = true;
76176 read_lock(&tasklist_lock);
76177 do_each_thread(g, p) {
76178 if (p == current || !freeze_task(p))
76179 continue;
76180
76181 - if (!freezer_should_skip(p))
76182 + if (!freezer_should_skip(p)) {
76183 todo++;
76184 + if (timedout) {
76185 + printk(KERN_ERR "Task refusing to freeze:\n");
76186 + sched_show_task(p);
76187 + }
76188 + }
76189 } while_each_thread(g, p);
76190 read_unlock(&tasklist_lock);
76191
76192 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
76193 todo += wq_busy;
76194 }
76195
76196 - if (!todo || time_after(jiffies, end_time))
76197 + if (!todo || timedout)
76198 break;
76199
76200 if (pm_wakeup_pending()) {
76201 diff --git a/kernel/printk.c b/kernel/printk.c
76202 index abbdd9e..f294251 100644
76203 --- a/kernel/printk.c
76204 +++ b/kernel/printk.c
76205 @@ -615,11 +615,17 @@ static unsigned int devkmsg_poll(struct file *file, poll_table *wait)
76206 return ret;
76207 }
76208
76209 +static int check_syslog_permissions(int type, bool from_file);
76210 +
76211 static int devkmsg_open(struct inode *inode, struct file *file)
76212 {
76213 struct devkmsg_user *user;
76214 int err;
76215
76216 + err = check_syslog_permissions(SYSLOG_ACTION_OPEN, SYSLOG_FROM_FILE);
76217 + if (err)
76218 + return err;
76219 +
76220 /* write-only does not need any file context */
76221 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
76222 return 0;
76223 @@ -828,7 +834,7 @@ static int syslog_action_restricted(int type)
76224 if (dmesg_restrict)
76225 return 1;
76226 /* Unless restricted, we allow "read all" and "get buffer size" for everybody */
76227 - return type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
76228 + return type != SYSLOG_ACTION_OPEN && type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
76229 }
76230
76231 static int check_syslog_permissions(int type, bool from_file)
76232 @@ -840,6 +846,11 @@ static int check_syslog_permissions(int type, bool from_file)
76233 if (from_file && type != SYSLOG_ACTION_OPEN)
76234 return 0;
76235
76236 +#ifdef CONFIG_GRKERNSEC_DMESG
76237 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
76238 + return -EPERM;
76239 +#endif
76240 +
76241 if (syslog_action_restricted(type)) {
76242 if (capable(CAP_SYSLOG))
76243 return 0;
76244 diff --git a/kernel/profile.c b/kernel/profile.c
76245 index dc3384e..0de5b49 100644
76246 --- a/kernel/profile.c
76247 +++ b/kernel/profile.c
76248 @@ -37,7 +37,7 @@ struct profile_hit {
76249 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
76250 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
76251
76252 -static atomic_t *prof_buffer;
76253 +static atomic_unchecked_t *prof_buffer;
76254 static unsigned long prof_len, prof_shift;
76255
76256 int prof_on __read_mostly;
76257 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
76258 hits[i].pc = 0;
76259 continue;
76260 }
76261 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
76262 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
76263 hits[i].hits = hits[i].pc = 0;
76264 }
76265 }
76266 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
76267 * Add the current hit(s) and flush the write-queue out
76268 * to the global buffer:
76269 */
76270 - atomic_add(nr_hits, &prof_buffer[pc]);
76271 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
76272 for (i = 0; i < NR_PROFILE_HIT; ++i) {
76273 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
76274 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
76275 hits[i].pc = hits[i].hits = 0;
76276 }
76277 out:
76278 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
76279 {
76280 unsigned long pc;
76281 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
76282 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
76283 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
76284 }
76285 #endif /* !CONFIG_SMP */
76286
76287 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
76288 return -EFAULT;
76289 buf++; p++; count--; read++;
76290 }
76291 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
76292 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
76293 if (copy_to_user(buf, (void *)pnt, count))
76294 return -EFAULT;
76295 read += count;
76296 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
76297 }
76298 #endif
76299 profile_discard_flip_buffers();
76300 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
76301 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
76302 return count;
76303 }
76304
76305 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
76306 index acbd284..00bb0c9 100644
76307 --- a/kernel/ptrace.c
76308 +++ b/kernel/ptrace.c
76309 @@ -324,7 +324,7 @@ static int ptrace_attach(struct task_struct *task, long request,
76310 if (seize)
76311 flags |= PT_SEIZED;
76312 rcu_read_lock();
76313 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
76314 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
76315 flags |= PT_PTRACE_CAP;
76316 rcu_read_unlock();
76317 task->ptrace = flags;
76318 @@ -535,7 +535,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
76319 break;
76320 return -EIO;
76321 }
76322 - if (copy_to_user(dst, buf, retval))
76323 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
76324 return -EFAULT;
76325 copied += retval;
76326 src += retval;
76327 @@ -726,7 +726,7 @@ int ptrace_request(struct task_struct *child, long request,
76328 bool seized = child->ptrace & PT_SEIZED;
76329 int ret = -EIO;
76330 siginfo_t siginfo, *si;
76331 - void __user *datavp = (void __user *) data;
76332 + void __user *datavp = (__force void __user *) data;
76333 unsigned long __user *datalp = datavp;
76334 unsigned long flags;
76335
76336 @@ -928,14 +928,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
76337 goto out;
76338 }
76339
76340 + if (gr_handle_ptrace(child, request)) {
76341 + ret = -EPERM;
76342 + goto out_put_task_struct;
76343 + }
76344 +
76345 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
76346 ret = ptrace_attach(child, request, addr, data);
76347 /*
76348 * Some architectures need to do book-keeping after
76349 * a ptrace attach.
76350 */
76351 - if (!ret)
76352 + if (!ret) {
76353 arch_ptrace_attach(child);
76354 + gr_audit_ptrace(child);
76355 + }
76356 goto out_put_task_struct;
76357 }
76358
76359 @@ -963,7 +970,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
76360 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
76361 if (copied != sizeof(tmp))
76362 return -EIO;
76363 - return put_user(tmp, (unsigned long __user *)data);
76364 + return put_user(tmp, (__force unsigned long __user *)data);
76365 }
76366
76367 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
76368 @@ -1057,7 +1064,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
76369 }
76370
76371 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
76372 - compat_long_t addr, compat_long_t data)
76373 + compat_ulong_t addr, compat_ulong_t data)
76374 {
76375 struct task_struct *child;
76376 long ret;
76377 @@ -1073,14 +1080,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
76378 goto out;
76379 }
76380
76381 + if (gr_handle_ptrace(child, request)) {
76382 + ret = -EPERM;
76383 + goto out_put_task_struct;
76384 + }
76385 +
76386 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
76387 ret = ptrace_attach(child, request, addr, data);
76388 /*
76389 * Some architectures need to do book-keeping after
76390 * a ptrace attach.
76391 */
76392 - if (!ret)
76393 + if (!ret) {
76394 arch_ptrace_attach(child);
76395 + gr_audit_ptrace(child);
76396 + }
76397 goto out_put_task_struct;
76398 }
76399
76400 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
76401 index 48ab703..07561d4 100644
76402 --- a/kernel/rcupdate.c
76403 +++ b/kernel/rcupdate.c
76404 @@ -439,10 +439,10 @@ int rcu_jiffies_till_stall_check(void)
76405 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
76406 */
76407 if (till_stall_check < 3) {
76408 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
76409 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
76410 till_stall_check = 3;
76411 } else if (till_stall_check > 300) {
76412 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
76413 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
76414 till_stall_check = 300;
76415 }
76416 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
76417 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
76418 index a0714a5..2ab5e34 100644
76419 --- a/kernel/rcutiny.c
76420 +++ b/kernel/rcutiny.c
76421 @@ -46,7 +46,7 @@
76422 struct rcu_ctrlblk;
76423 static void invoke_rcu_callbacks(void);
76424 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
76425 -static void rcu_process_callbacks(struct softirq_action *unused);
76426 +static void rcu_process_callbacks(void);
76427 static void __call_rcu(struct rcu_head *head,
76428 void (*func)(struct rcu_head *rcu),
76429 struct rcu_ctrlblk *rcp);
76430 @@ -312,7 +312,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
76431 rcu_is_callbacks_kthread()));
76432 }
76433
76434 -static void rcu_process_callbacks(struct softirq_action *unused)
76435 +static void rcu_process_callbacks(void)
76436 {
76437 __rcu_process_callbacks(&rcu_sched_ctrlblk);
76438 __rcu_process_callbacks(&rcu_bh_ctrlblk);
76439 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
76440 index 8a23300..4255818 100644
76441 --- a/kernel/rcutiny_plugin.h
76442 +++ b/kernel/rcutiny_plugin.h
76443 @@ -945,7 +945,7 @@ static int rcu_kthread(void *arg)
76444 have_rcu_kthread_work = morework;
76445 local_irq_restore(flags);
76446 if (work)
76447 - rcu_process_callbacks(NULL);
76448 + rcu_process_callbacks();
76449 schedule_timeout_interruptible(1); /* Leave CPU for others. */
76450 }
76451
76452 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
76453 index e1f3a8c..42c94a2 100644
76454 --- a/kernel/rcutorture.c
76455 +++ b/kernel/rcutorture.c
76456 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
76457 { 0 };
76458 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
76459 { 0 };
76460 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
76461 -static atomic_t n_rcu_torture_alloc;
76462 -static atomic_t n_rcu_torture_alloc_fail;
76463 -static atomic_t n_rcu_torture_free;
76464 -static atomic_t n_rcu_torture_mberror;
76465 -static atomic_t n_rcu_torture_error;
76466 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
76467 +static atomic_unchecked_t n_rcu_torture_alloc;
76468 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
76469 +static atomic_unchecked_t n_rcu_torture_free;
76470 +static atomic_unchecked_t n_rcu_torture_mberror;
76471 +static atomic_unchecked_t n_rcu_torture_error;
76472 static long n_rcu_torture_barrier_error;
76473 static long n_rcu_torture_boost_ktrerror;
76474 static long n_rcu_torture_boost_rterror;
76475 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
76476
76477 spin_lock_bh(&rcu_torture_lock);
76478 if (list_empty(&rcu_torture_freelist)) {
76479 - atomic_inc(&n_rcu_torture_alloc_fail);
76480 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
76481 spin_unlock_bh(&rcu_torture_lock);
76482 return NULL;
76483 }
76484 - atomic_inc(&n_rcu_torture_alloc);
76485 + atomic_inc_unchecked(&n_rcu_torture_alloc);
76486 p = rcu_torture_freelist.next;
76487 list_del_init(p);
76488 spin_unlock_bh(&rcu_torture_lock);
76489 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
76490 static void
76491 rcu_torture_free(struct rcu_torture *p)
76492 {
76493 - atomic_inc(&n_rcu_torture_free);
76494 + atomic_inc_unchecked(&n_rcu_torture_free);
76495 spin_lock_bh(&rcu_torture_lock);
76496 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
76497 spin_unlock_bh(&rcu_torture_lock);
76498 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
76499 i = rp->rtort_pipe_count;
76500 if (i > RCU_TORTURE_PIPE_LEN)
76501 i = RCU_TORTURE_PIPE_LEN;
76502 - atomic_inc(&rcu_torture_wcount[i]);
76503 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
76504 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
76505 rp->rtort_mbtest = 0;
76506 rcu_torture_free(rp);
76507 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
76508 i = rp->rtort_pipe_count;
76509 if (i > RCU_TORTURE_PIPE_LEN)
76510 i = RCU_TORTURE_PIPE_LEN;
76511 - atomic_inc(&rcu_torture_wcount[i]);
76512 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
76513 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
76514 rp->rtort_mbtest = 0;
76515 list_del(&rp->rtort_free);
76516 @@ -990,7 +990,7 @@ rcu_torture_writer(void *arg)
76517 i = old_rp->rtort_pipe_count;
76518 if (i > RCU_TORTURE_PIPE_LEN)
76519 i = RCU_TORTURE_PIPE_LEN;
76520 - atomic_inc(&rcu_torture_wcount[i]);
76521 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
76522 old_rp->rtort_pipe_count++;
76523 cur_ops->deferred_free(old_rp);
76524 }
76525 @@ -1076,7 +1076,7 @@ static void rcu_torture_timer(unsigned long unused)
76526 return;
76527 }
76528 if (p->rtort_mbtest == 0)
76529 - atomic_inc(&n_rcu_torture_mberror);
76530 + atomic_inc_unchecked(&n_rcu_torture_mberror);
76531 spin_lock(&rand_lock);
76532 cur_ops->read_delay(&rand);
76533 n_rcu_torture_timers++;
76534 @@ -1146,7 +1146,7 @@ rcu_torture_reader(void *arg)
76535 continue;
76536 }
76537 if (p->rtort_mbtest == 0)
76538 - atomic_inc(&n_rcu_torture_mberror);
76539 + atomic_inc_unchecked(&n_rcu_torture_mberror);
76540 cur_ops->read_delay(&rand);
76541 preempt_disable();
76542 pipe_count = p->rtort_pipe_count;
76543 @@ -1209,11 +1209,11 @@ rcu_torture_printk(char *page)
76544 rcu_torture_current,
76545 rcu_torture_current_version,
76546 list_empty(&rcu_torture_freelist),
76547 - atomic_read(&n_rcu_torture_alloc),
76548 - atomic_read(&n_rcu_torture_alloc_fail),
76549 - atomic_read(&n_rcu_torture_free));
76550 + atomic_read_unchecked(&n_rcu_torture_alloc),
76551 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
76552 + atomic_read_unchecked(&n_rcu_torture_free));
76553 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
76554 - atomic_read(&n_rcu_torture_mberror),
76555 + atomic_read_unchecked(&n_rcu_torture_mberror),
76556 n_rcu_torture_boost_ktrerror,
76557 n_rcu_torture_boost_rterror);
76558 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
76559 @@ -1232,14 +1232,14 @@ rcu_torture_printk(char *page)
76560 n_barrier_attempts,
76561 n_rcu_torture_barrier_error);
76562 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
76563 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
76564 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
76565 n_rcu_torture_barrier_error != 0 ||
76566 n_rcu_torture_boost_ktrerror != 0 ||
76567 n_rcu_torture_boost_rterror != 0 ||
76568 n_rcu_torture_boost_failure != 0 ||
76569 i > 1) {
76570 cnt += sprintf(&page[cnt], "!!! ");
76571 - atomic_inc(&n_rcu_torture_error);
76572 + atomic_inc_unchecked(&n_rcu_torture_error);
76573 WARN_ON_ONCE(1);
76574 }
76575 cnt += sprintf(&page[cnt], "Reader Pipe: ");
76576 @@ -1253,7 +1253,7 @@ rcu_torture_printk(char *page)
76577 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
76578 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
76579 cnt += sprintf(&page[cnt], " %d",
76580 - atomic_read(&rcu_torture_wcount[i]));
76581 + atomic_read_unchecked(&rcu_torture_wcount[i]));
76582 }
76583 cnt += sprintf(&page[cnt], "\n");
76584 if (cur_ops->stats)
76585 @@ -1962,7 +1962,7 @@ rcu_torture_cleanup(void)
76586
76587 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
76588
76589 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
76590 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
76591 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
76592 else if (n_online_successes != n_online_attempts ||
76593 n_offline_successes != n_offline_attempts)
76594 @@ -2031,18 +2031,18 @@ rcu_torture_init(void)
76595
76596 rcu_torture_current = NULL;
76597 rcu_torture_current_version = 0;
76598 - atomic_set(&n_rcu_torture_alloc, 0);
76599 - atomic_set(&n_rcu_torture_alloc_fail, 0);
76600 - atomic_set(&n_rcu_torture_free, 0);
76601 - atomic_set(&n_rcu_torture_mberror, 0);
76602 - atomic_set(&n_rcu_torture_error, 0);
76603 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
76604 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
76605 + atomic_set_unchecked(&n_rcu_torture_free, 0);
76606 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
76607 + atomic_set_unchecked(&n_rcu_torture_error, 0);
76608 n_rcu_torture_barrier_error = 0;
76609 n_rcu_torture_boost_ktrerror = 0;
76610 n_rcu_torture_boost_rterror = 0;
76611 n_rcu_torture_boost_failure = 0;
76612 n_rcu_torture_boosts = 0;
76613 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
76614 - atomic_set(&rcu_torture_wcount[i], 0);
76615 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
76616 for_each_possible_cpu(cpu) {
76617 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
76618 per_cpu(rcu_torture_count, cpu)[i] = 0;
76619 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
76620 index 5b8ad82..17274d1 100644
76621 --- a/kernel/rcutree.c
76622 +++ b/kernel/rcutree.c
76623 @@ -353,9 +353,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
76624 rcu_prepare_for_idle(smp_processor_id());
76625 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
76626 smp_mb__before_atomic_inc(); /* See above. */
76627 - atomic_inc(&rdtp->dynticks);
76628 + atomic_inc_unchecked(&rdtp->dynticks);
76629 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
76630 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
76631 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
76632
76633 /*
76634 * It is illegal to enter an extended quiescent state while
76635 @@ -491,10 +491,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
76636 int user)
76637 {
76638 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
76639 - atomic_inc(&rdtp->dynticks);
76640 + atomic_inc_unchecked(&rdtp->dynticks);
76641 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
76642 smp_mb__after_atomic_inc(); /* See above. */
76643 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
76644 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
76645 rcu_cleanup_after_idle(smp_processor_id());
76646 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
76647 if (!user && !is_idle_task(current)) {
76648 @@ -633,14 +633,14 @@ void rcu_nmi_enter(void)
76649 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
76650
76651 if (rdtp->dynticks_nmi_nesting == 0 &&
76652 - (atomic_read(&rdtp->dynticks) & 0x1))
76653 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
76654 return;
76655 rdtp->dynticks_nmi_nesting++;
76656 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
76657 - atomic_inc(&rdtp->dynticks);
76658 + atomic_inc_unchecked(&rdtp->dynticks);
76659 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
76660 smp_mb__after_atomic_inc(); /* See above. */
76661 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
76662 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
76663 }
76664
76665 /**
76666 @@ -659,9 +659,9 @@ void rcu_nmi_exit(void)
76667 return;
76668 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
76669 smp_mb__before_atomic_inc(); /* See above. */
76670 - atomic_inc(&rdtp->dynticks);
76671 + atomic_inc_unchecked(&rdtp->dynticks);
76672 smp_mb__after_atomic_inc(); /* Force delay to next write. */
76673 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
76674 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
76675 }
76676
76677 /**
76678 @@ -675,7 +675,7 @@ int rcu_is_cpu_idle(void)
76679 int ret;
76680
76681 preempt_disable();
76682 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
76683 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
76684 preempt_enable();
76685 return ret;
76686 }
76687 @@ -743,7 +743,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
76688 */
76689 static int dyntick_save_progress_counter(struct rcu_data *rdp)
76690 {
76691 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
76692 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
76693 return (rdp->dynticks_snap & 0x1) == 0;
76694 }
76695
76696 @@ -758,7 +758,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
76697 unsigned int curr;
76698 unsigned int snap;
76699
76700 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
76701 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
76702 snap = (unsigned int)rdp->dynticks_snap;
76703
76704 /*
76705 @@ -1698,7 +1698,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
76706 rsp->qlen += rdp->qlen;
76707 rdp->n_cbs_orphaned += rdp->qlen;
76708 rdp->qlen_lazy = 0;
76709 - ACCESS_ONCE(rdp->qlen) = 0;
76710 + ACCESS_ONCE_RW(rdp->qlen) = 0;
76711 }
76712
76713 /*
76714 @@ -1944,7 +1944,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
76715 }
76716 smp_mb(); /* List handling before counting for rcu_barrier(). */
76717 rdp->qlen_lazy -= count_lazy;
76718 - ACCESS_ONCE(rdp->qlen) -= count;
76719 + ACCESS_ONCE_RW(rdp->qlen) -= count;
76720 rdp->n_cbs_invoked += count;
76721
76722 /* Reinstate batch limit if we have worked down the excess. */
76723 @@ -2137,7 +2137,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
76724 /*
76725 * Do RCU core processing for the current CPU.
76726 */
76727 -static void rcu_process_callbacks(struct softirq_action *unused)
76728 +static void rcu_process_callbacks(void)
76729 {
76730 struct rcu_state *rsp;
76731
76732 @@ -2260,7 +2260,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
76733 local_irq_restore(flags);
76734 return;
76735 }
76736 - ACCESS_ONCE(rdp->qlen)++;
76737 + ACCESS_ONCE_RW(rdp->qlen)++;
76738 if (lazy)
76739 rdp->qlen_lazy++;
76740 else
76741 @@ -2469,11 +2469,11 @@ void synchronize_sched_expedited(void)
76742 * counter wrap on a 32-bit system. Quite a few more CPUs would of
76743 * course be required on a 64-bit system.
76744 */
76745 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
76746 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
76747 (ulong)atomic_long_read(&rsp->expedited_done) +
76748 ULONG_MAX / 8)) {
76749 synchronize_sched();
76750 - atomic_long_inc(&rsp->expedited_wrap);
76751 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
76752 return;
76753 }
76754
76755 @@ -2481,7 +2481,7 @@ void synchronize_sched_expedited(void)
76756 * Take a ticket. Note that atomic_inc_return() implies a
76757 * full memory barrier.
76758 */
76759 - snap = atomic_long_inc_return(&rsp->expedited_start);
76760 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
76761 firstsnap = snap;
76762 get_online_cpus();
76763 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
76764 @@ -2494,14 +2494,14 @@ void synchronize_sched_expedited(void)
76765 synchronize_sched_expedited_cpu_stop,
76766 NULL) == -EAGAIN) {
76767 put_online_cpus();
76768 - atomic_long_inc(&rsp->expedited_tryfail);
76769 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
76770
76771 /* Check to see if someone else did our work for us. */
76772 s = atomic_long_read(&rsp->expedited_done);
76773 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
76774 /* ensure test happens before caller kfree */
76775 smp_mb__before_atomic_inc(); /* ^^^ */
76776 - atomic_long_inc(&rsp->expedited_workdone1);
76777 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
76778 return;
76779 }
76780
76781 @@ -2510,7 +2510,7 @@ void synchronize_sched_expedited(void)
76782 udelay(trycount * num_online_cpus());
76783 } else {
76784 wait_rcu_gp(call_rcu_sched);
76785 - atomic_long_inc(&rsp->expedited_normal);
76786 + atomic_long_inc_unchecked(&rsp->expedited_normal);
76787 return;
76788 }
76789
76790 @@ -2519,7 +2519,7 @@ void synchronize_sched_expedited(void)
76791 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
76792 /* ensure test happens before caller kfree */
76793 smp_mb__before_atomic_inc(); /* ^^^ */
76794 - atomic_long_inc(&rsp->expedited_workdone2);
76795 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
76796 return;
76797 }
76798
76799 @@ -2531,10 +2531,10 @@ void synchronize_sched_expedited(void)
76800 * period works for us.
76801 */
76802 get_online_cpus();
76803 - snap = atomic_long_read(&rsp->expedited_start);
76804 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
76805 smp_mb(); /* ensure read is before try_stop_cpus(). */
76806 }
76807 - atomic_long_inc(&rsp->expedited_stoppedcpus);
76808 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
76809
76810 /*
76811 * Everyone up to our most recent fetch is covered by our grace
76812 @@ -2543,16 +2543,16 @@ void synchronize_sched_expedited(void)
76813 * than we did already did their update.
76814 */
76815 do {
76816 - atomic_long_inc(&rsp->expedited_done_tries);
76817 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
76818 s = atomic_long_read(&rsp->expedited_done);
76819 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
76820 /* ensure test happens before caller kfree */
76821 smp_mb__before_atomic_inc(); /* ^^^ */
76822 - atomic_long_inc(&rsp->expedited_done_lost);
76823 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
76824 break;
76825 }
76826 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
76827 - atomic_long_inc(&rsp->expedited_done_exit);
76828 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
76829
76830 put_online_cpus();
76831 }
76832 @@ -2726,7 +2726,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
76833 * ACCESS_ONCE() to prevent the compiler from speculating
76834 * the increment to precede the early-exit check.
76835 */
76836 - ACCESS_ONCE(rsp->n_barrier_done)++;
76837 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
76838 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
76839 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
76840 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
76841 @@ -2776,7 +2776,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
76842
76843 /* Increment ->n_barrier_done to prevent duplicate work. */
76844 smp_mb(); /* Keep increment after above mechanism. */
76845 - ACCESS_ONCE(rsp->n_barrier_done)++;
76846 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
76847 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
76848 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
76849 smp_mb(); /* Keep increment before caller's subsequent code. */
76850 @@ -2821,10 +2821,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
76851 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
76852 init_callback_list(rdp);
76853 rdp->qlen_lazy = 0;
76854 - ACCESS_ONCE(rdp->qlen) = 0;
76855 + ACCESS_ONCE_RW(rdp->qlen) = 0;
76856 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
76857 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
76858 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
76859 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
76860 rdp->cpu = cpu;
76861 rdp->rsp = rsp;
76862 rcu_boot_init_nocb_percpu_data(rdp);
76863 @@ -2857,8 +2857,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
76864 rdp->blimit = blimit;
76865 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
76866 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
76867 - atomic_set(&rdp->dynticks->dynticks,
76868 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
76869 + atomic_set_unchecked(&rdp->dynticks->dynticks,
76870 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
76871 rcu_prepare_for_idle_init(cpu);
76872 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
76873
76874 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
76875 index c896b50..c357252 100644
76876 --- a/kernel/rcutree.h
76877 +++ b/kernel/rcutree.h
76878 @@ -86,7 +86,7 @@ struct rcu_dynticks {
76879 long long dynticks_nesting; /* Track irq/process nesting level. */
76880 /* Process level is worth LLONG_MAX/2. */
76881 int dynticks_nmi_nesting; /* Track NMI nesting level. */
76882 - atomic_t dynticks; /* Even value for idle, else odd. */
76883 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
76884 #ifdef CONFIG_RCU_FAST_NO_HZ
76885 int dyntick_drain; /* Prepare-for-idle state variable. */
76886 unsigned long dyntick_holdoff;
76887 @@ -416,17 +416,17 @@ struct rcu_state {
76888 /* _rcu_barrier(). */
76889 /* End of fields guarded by barrier_mutex. */
76890
76891 - atomic_long_t expedited_start; /* Starting ticket. */
76892 - atomic_long_t expedited_done; /* Done ticket. */
76893 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
76894 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
76895 - atomic_long_t expedited_workdone1; /* # done by others #1. */
76896 - atomic_long_t expedited_workdone2; /* # done by others #2. */
76897 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
76898 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
76899 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
76900 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
76901 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
76902 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
76903 + atomic_long_t expedited_done; /* Done ticket. */
76904 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
76905 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
76906 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
76907 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
76908 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
76909 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
76910 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
76911 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
76912 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
76913
76914 unsigned long jiffies_force_qs; /* Time at which to invoke */
76915 /* force_quiescent_state(). */
76916 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
76917 index c1cc7e1..f62e436 100644
76918 --- a/kernel/rcutree_plugin.h
76919 +++ b/kernel/rcutree_plugin.h
76920 @@ -892,7 +892,7 @@ void synchronize_rcu_expedited(void)
76921
76922 /* Clean up and exit. */
76923 smp_mb(); /* ensure expedited GP seen before counter increment. */
76924 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
76925 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
76926 unlock_mb_ret:
76927 mutex_unlock(&sync_rcu_preempt_exp_mutex);
76928 mb_ret:
76929 @@ -1440,7 +1440,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
76930 free_cpumask_var(cm);
76931 }
76932
76933 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
76934 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
76935 .store = &rcu_cpu_kthread_task,
76936 .thread_should_run = rcu_cpu_kthread_should_run,
76937 .thread_fn = rcu_cpu_kthread,
76938 @@ -2072,7 +2072,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
76939 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
76940 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
76941 cpu, ticks_value, ticks_title,
76942 - atomic_read(&rdtp->dynticks) & 0xfff,
76943 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
76944 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
76945 fast_no_hz);
76946 }
76947 @@ -2192,7 +2192,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
76948
76949 /* Enqueue the callback on the nocb list and update counts. */
76950 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
76951 - ACCESS_ONCE(*old_rhpp) = rhp;
76952 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
76953 atomic_long_add(rhcount, &rdp->nocb_q_count);
76954 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
76955
76956 @@ -2384,12 +2384,12 @@ static int rcu_nocb_kthread(void *arg)
76957 * Extract queued callbacks, update counts, and wait
76958 * for a grace period to elapse.
76959 */
76960 - ACCESS_ONCE(rdp->nocb_head) = NULL;
76961 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
76962 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
76963 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
76964 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
76965 - ACCESS_ONCE(rdp->nocb_p_count) += c;
76966 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
76967 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
76968 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
76969 wait_rcu_gp(rdp->rsp->call_remote);
76970
76971 /* Each pass through the following loop invokes a callback. */
76972 @@ -2411,8 +2411,8 @@ static int rcu_nocb_kthread(void *arg)
76973 list = next;
76974 }
76975 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
76976 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
76977 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
76978 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
76979 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
76980 rdp->n_nocbs_invoked += c;
76981 }
76982 return 0;
76983 @@ -2438,7 +2438,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
76984 rdp = per_cpu_ptr(rsp->rda, cpu);
76985 t = kthread_run(rcu_nocb_kthread, rdp, "rcuo%d", cpu);
76986 BUG_ON(IS_ERR(t));
76987 - ACCESS_ONCE(rdp->nocb_kthread) = t;
76988 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
76989 }
76990 }
76991
76992 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
76993 index 93f8e8f..cf812ae 100644
76994 --- a/kernel/rcutree_trace.c
76995 +++ b/kernel/rcutree_trace.c
76996 @@ -123,7 +123,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
76997 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
76998 rdp->passed_quiesce, rdp->qs_pending);
76999 seq_printf(m, " dt=%d/%llx/%d df=%lu",
77000 - atomic_read(&rdp->dynticks->dynticks),
77001 + atomic_read_unchecked(&rdp->dynticks->dynticks),
77002 rdp->dynticks->dynticks_nesting,
77003 rdp->dynticks->dynticks_nmi_nesting,
77004 rdp->dynticks_fqs);
77005 @@ -184,17 +184,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
77006 struct rcu_state *rsp = (struct rcu_state *)m->private;
77007
77008 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",
77009 - atomic_long_read(&rsp->expedited_start),
77010 + atomic_long_read_unchecked(&rsp->expedited_start),
77011 atomic_long_read(&rsp->expedited_done),
77012 - atomic_long_read(&rsp->expedited_wrap),
77013 - atomic_long_read(&rsp->expedited_tryfail),
77014 - atomic_long_read(&rsp->expedited_workdone1),
77015 - atomic_long_read(&rsp->expedited_workdone2),
77016 - atomic_long_read(&rsp->expedited_normal),
77017 - atomic_long_read(&rsp->expedited_stoppedcpus),
77018 - atomic_long_read(&rsp->expedited_done_tries),
77019 - atomic_long_read(&rsp->expedited_done_lost),
77020 - atomic_long_read(&rsp->expedited_done_exit));
77021 + atomic_long_read_unchecked(&rsp->expedited_wrap),
77022 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
77023 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
77024 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
77025 + atomic_long_read_unchecked(&rsp->expedited_normal),
77026 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
77027 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
77028 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
77029 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
77030 return 0;
77031 }
77032
77033 diff --git a/kernel/resource.c b/kernel/resource.c
77034 index 73f35d4..4684fc4 100644
77035 --- a/kernel/resource.c
77036 +++ b/kernel/resource.c
77037 @@ -143,8 +143,18 @@ static const struct file_operations proc_iomem_operations = {
77038
77039 static int __init ioresources_init(void)
77040 {
77041 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
77042 +#ifdef CONFIG_GRKERNSEC_PROC_USER
77043 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
77044 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
77045 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
77046 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
77047 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
77048 +#endif
77049 +#else
77050 proc_create("ioports", 0, NULL, &proc_ioports_operations);
77051 proc_create("iomem", 0, NULL, &proc_iomem_operations);
77052 +#endif
77053 return 0;
77054 }
77055 __initcall(ioresources_init);
77056 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
77057 index 7890b10..8b68605f 100644
77058 --- a/kernel/rtmutex-tester.c
77059 +++ b/kernel/rtmutex-tester.c
77060 @@ -21,7 +21,7 @@
77061 #define MAX_RT_TEST_MUTEXES 8
77062
77063 static spinlock_t rttest_lock;
77064 -static atomic_t rttest_event;
77065 +static atomic_unchecked_t rttest_event;
77066
77067 struct test_thread_data {
77068 int opcode;
77069 @@ -62,7 +62,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77070
77071 case RTTEST_LOCKCONT:
77072 td->mutexes[td->opdata] = 1;
77073 - td->event = atomic_add_return(1, &rttest_event);
77074 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77075 return 0;
77076
77077 case RTTEST_RESET:
77078 @@ -75,7 +75,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77079 return 0;
77080
77081 case RTTEST_RESETEVENT:
77082 - atomic_set(&rttest_event, 0);
77083 + atomic_set_unchecked(&rttest_event, 0);
77084 return 0;
77085
77086 default:
77087 @@ -92,9 +92,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77088 return ret;
77089
77090 td->mutexes[id] = 1;
77091 - td->event = atomic_add_return(1, &rttest_event);
77092 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77093 rt_mutex_lock(&mutexes[id]);
77094 - td->event = atomic_add_return(1, &rttest_event);
77095 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77096 td->mutexes[id] = 4;
77097 return 0;
77098
77099 @@ -105,9 +105,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77100 return ret;
77101
77102 td->mutexes[id] = 1;
77103 - td->event = atomic_add_return(1, &rttest_event);
77104 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77105 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
77106 - td->event = atomic_add_return(1, &rttest_event);
77107 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77108 td->mutexes[id] = ret ? 0 : 4;
77109 return ret ? -EINTR : 0;
77110
77111 @@ -116,9 +116,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
77112 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
77113 return ret;
77114
77115 - td->event = atomic_add_return(1, &rttest_event);
77116 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77117 rt_mutex_unlock(&mutexes[id]);
77118 - td->event = atomic_add_return(1, &rttest_event);
77119 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77120 td->mutexes[id] = 0;
77121 return 0;
77122
77123 @@ -165,7 +165,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77124 break;
77125
77126 td->mutexes[dat] = 2;
77127 - td->event = atomic_add_return(1, &rttest_event);
77128 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77129 break;
77130
77131 default:
77132 @@ -185,7 +185,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77133 return;
77134
77135 td->mutexes[dat] = 3;
77136 - td->event = atomic_add_return(1, &rttest_event);
77137 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77138 break;
77139
77140 case RTTEST_LOCKNOWAIT:
77141 @@ -197,7 +197,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
77142 return;
77143
77144 td->mutexes[dat] = 1;
77145 - td->event = atomic_add_return(1, &rttest_event);
77146 + td->event = atomic_add_return_unchecked(1, &rttest_event);
77147 return;
77148
77149 default:
77150 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
77151 index 64de5f8..7735e12 100644
77152 --- a/kernel/sched/auto_group.c
77153 +++ b/kernel/sched/auto_group.c
77154 @@ -11,7 +11,7 @@
77155
77156 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
77157 static struct autogroup autogroup_default;
77158 -static atomic_t autogroup_seq_nr;
77159 +static atomic_unchecked_t autogroup_seq_nr;
77160
77161 void __init autogroup_init(struct task_struct *init_task)
77162 {
77163 @@ -81,7 +81,7 @@ static inline struct autogroup *autogroup_create(void)
77164
77165 kref_init(&ag->kref);
77166 init_rwsem(&ag->lock);
77167 - ag->id = atomic_inc_return(&autogroup_seq_nr);
77168 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
77169 ag->tg = tg;
77170 #ifdef CONFIG_RT_GROUP_SCHED
77171 /*
77172 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
77173 index 67d0465..4cf9361 100644
77174 --- a/kernel/sched/core.c
77175 +++ b/kernel/sched/core.c
77176 @@ -3406,7 +3406,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
77177 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
77178 * positive (at least 1, or number of jiffies left till timeout) if completed.
77179 */
77180 -long __sched
77181 +long __sched __intentional_overflow(-1)
77182 wait_for_completion_interruptible_timeout(struct completion *x,
77183 unsigned long timeout)
77184 {
77185 @@ -3423,7 +3423,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
77186 *
77187 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
77188 */
77189 -int __sched wait_for_completion_killable(struct completion *x)
77190 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
77191 {
77192 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
77193 if (t == -ERESTARTSYS)
77194 @@ -3444,7 +3444,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
77195 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
77196 * positive (at least 1, or number of jiffies left till timeout) if completed.
77197 */
77198 -long __sched
77199 +long __sched __intentional_overflow(-1)
77200 wait_for_completion_killable_timeout(struct completion *x,
77201 unsigned long timeout)
77202 {
77203 @@ -3670,6 +3670,8 @@ int can_nice(const struct task_struct *p, const int nice)
77204 /* convert nice value [19,-20] to rlimit style value [1,40] */
77205 int nice_rlim = 20 - nice;
77206
77207 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
77208 +
77209 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
77210 capable(CAP_SYS_NICE));
77211 }
77212 @@ -3703,7 +3705,8 @@ SYSCALL_DEFINE1(nice, int, increment)
77213 if (nice > 19)
77214 nice = 19;
77215
77216 - if (increment < 0 && !can_nice(current, nice))
77217 + if (increment < 0 && (!can_nice(current, nice) ||
77218 + gr_handle_chroot_nice()))
77219 return -EPERM;
77220
77221 retval = security_task_setnice(current, nice);
77222 @@ -3857,6 +3860,7 @@ recheck:
77223 unsigned long rlim_rtprio =
77224 task_rlimit(p, RLIMIT_RTPRIO);
77225
77226 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
77227 /* can't set/change the rt policy */
77228 if (policy != p->policy && !rlim_rtprio)
77229 return -EPERM;
77230 @@ -4954,7 +4958,7 @@ static void migrate_tasks(unsigned int dead_cpu)
77231
77232 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
77233
77234 -static struct ctl_table sd_ctl_dir[] = {
77235 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
77236 {
77237 .procname = "sched_domain",
77238 .mode = 0555,
77239 @@ -4971,17 +4975,17 @@ static struct ctl_table sd_ctl_root[] = {
77240 {}
77241 };
77242
77243 -static struct ctl_table *sd_alloc_ctl_entry(int n)
77244 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
77245 {
77246 - struct ctl_table *entry =
77247 + ctl_table_no_const *entry =
77248 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
77249
77250 return entry;
77251 }
77252
77253 -static void sd_free_ctl_entry(struct ctl_table **tablep)
77254 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
77255 {
77256 - struct ctl_table *entry;
77257 + ctl_table_no_const *entry;
77258
77259 /*
77260 * In the intermediate directories, both the child directory and
77261 @@ -4989,22 +4993,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
77262 * will always be set. In the lowest directory the names are
77263 * static strings and all have proc handlers.
77264 */
77265 - for (entry = *tablep; entry->mode; entry++) {
77266 - if (entry->child)
77267 - sd_free_ctl_entry(&entry->child);
77268 + for (entry = tablep; entry->mode; entry++) {
77269 + if (entry->child) {
77270 + sd_free_ctl_entry(entry->child);
77271 + pax_open_kernel();
77272 + entry->child = NULL;
77273 + pax_close_kernel();
77274 + }
77275 if (entry->proc_handler == NULL)
77276 kfree(entry->procname);
77277 }
77278
77279 - kfree(*tablep);
77280 - *tablep = NULL;
77281 + kfree(tablep);
77282 }
77283
77284 static int min_load_idx = 0;
77285 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
77286
77287 static void
77288 -set_table_entry(struct ctl_table *entry,
77289 +set_table_entry(ctl_table_no_const *entry,
77290 const char *procname, void *data, int maxlen,
77291 umode_t mode, proc_handler *proc_handler,
77292 bool load_idx)
77293 @@ -5024,7 +5031,7 @@ set_table_entry(struct ctl_table *entry,
77294 static struct ctl_table *
77295 sd_alloc_ctl_domain_table(struct sched_domain *sd)
77296 {
77297 - struct ctl_table *table = sd_alloc_ctl_entry(13);
77298 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
77299
77300 if (table == NULL)
77301 return NULL;
77302 @@ -5059,9 +5066,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
77303 return table;
77304 }
77305
77306 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
77307 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
77308 {
77309 - struct ctl_table *entry, *table;
77310 + ctl_table_no_const *entry, *table;
77311 struct sched_domain *sd;
77312 int domain_num = 0, i;
77313 char buf[32];
77314 @@ -5088,11 +5095,13 @@ static struct ctl_table_header *sd_sysctl_header;
77315 static void register_sched_domain_sysctl(void)
77316 {
77317 int i, cpu_num = num_possible_cpus();
77318 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
77319 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
77320 char buf[32];
77321
77322 WARN_ON(sd_ctl_dir[0].child);
77323 + pax_open_kernel();
77324 sd_ctl_dir[0].child = entry;
77325 + pax_close_kernel();
77326
77327 if (entry == NULL)
77328 return;
77329 @@ -5115,8 +5124,12 @@ static void unregister_sched_domain_sysctl(void)
77330 if (sd_sysctl_header)
77331 unregister_sysctl_table(sd_sysctl_header);
77332 sd_sysctl_header = NULL;
77333 - if (sd_ctl_dir[0].child)
77334 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
77335 + if (sd_ctl_dir[0].child) {
77336 + sd_free_ctl_entry(sd_ctl_dir[0].child);
77337 + pax_open_kernel();
77338 + sd_ctl_dir[0].child = NULL;
77339 + pax_close_kernel();
77340 + }
77341 }
77342 #else
77343 static void register_sched_domain_sysctl(void)
77344 @@ -5215,7 +5228,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
77345 * happens before everything else. This has to be lower priority than
77346 * the notifier in the perf_event subsystem, though.
77347 */
77348 -static struct notifier_block __cpuinitdata migration_notifier = {
77349 +static struct notifier_block migration_notifier = {
77350 .notifier_call = migration_call,
77351 .priority = CPU_PRI_MIGRATION,
77352 };
77353 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
77354 index 7a33e59..2f7730c 100644
77355 --- a/kernel/sched/fair.c
77356 +++ b/kernel/sched/fair.c
77357 @@ -830,7 +830,7 @@ void task_numa_fault(int node, int pages, bool migrated)
77358
77359 static void reset_ptenuma_scan(struct task_struct *p)
77360 {
77361 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
77362 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
77363 p->mm->numa_scan_offset = 0;
77364 }
77365
77366 @@ -5654,7 +5654,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
77367 * run_rebalance_domains is triggered when needed from the scheduler tick.
77368 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
77369 */
77370 -static void run_rebalance_domains(struct softirq_action *h)
77371 +static void run_rebalance_domains(void)
77372 {
77373 int this_cpu = smp_processor_id();
77374 struct rq *this_rq = cpu_rq(this_cpu);
77375 diff --git a/kernel/signal.c b/kernel/signal.c
77376 index 598dc06..471310a 100644
77377 --- a/kernel/signal.c
77378 +++ b/kernel/signal.c
77379 @@ -50,12 +50,12 @@ static struct kmem_cache *sigqueue_cachep;
77380
77381 int print_fatal_signals __read_mostly;
77382
77383 -static void __user *sig_handler(struct task_struct *t, int sig)
77384 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
77385 {
77386 return t->sighand->action[sig - 1].sa.sa_handler;
77387 }
77388
77389 -static int sig_handler_ignored(void __user *handler, int sig)
77390 +static int sig_handler_ignored(__sighandler_t handler, int sig)
77391 {
77392 /* Is it explicitly or implicitly ignored? */
77393 return handler == SIG_IGN ||
77394 @@ -64,7 +64,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
77395
77396 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
77397 {
77398 - void __user *handler;
77399 + __sighandler_t handler;
77400
77401 handler = sig_handler(t, sig);
77402
77403 @@ -368,6 +368,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
77404 atomic_inc(&user->sigpending);
77405 rcu_read_unlock();
77406
77407 + if (!override_rlimit)
77408 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
77409 +
77410 if (override_rlimit ||
77411 atomic_read(&user->sigpending) <=
77412 task_rlimit(t, RLIMIT_SIGPENDING)) {
77413 @@ -495,7 +498,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
77414
77415 int unhandled_signal(struct task_struct *tsk, int sig)
77416 {
77417 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
77418 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
77419 if (is_global_init(tsk))
77420 return 1;
77421 if (handler != SIG_IGN && handler != SIG_DFL)
77422 @@ -815,6 +818,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
77423 }
77424 }
77425
77426 + /* allow glibc communication via tgkill to other threads in our
77427 + thread group */
77428 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
77429 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
77430 + && gr_handle_signal(t, sig))
77431 + return -EPERM;
77432 +
77433 return security_task_kill(t, info, sig, 0);
77434 }
77435
77436 @@ -1197,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
77437 return send_signal(sig, info, p, 1);
77438 }
77439
77440 -static int
77441 +int
77442 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
77443 {
77444 return send_signal(sig, info, t, 0);
77445 @@ -1234,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
77446 unsigned long int flags;
77447 int ret, blocked, ignored;
77448 struct k_sigaction *action;
77449 + int is_unhandled = 0;
77450
77451 spin_lock_irqsave(&t->sighand->siglock, flags);
77452 action = &t->sighand->action[sig-1];
77453 @@ -1248,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
77454 }
77455 if (action->sa.sa_handler == SIG_DFL)
77456 t->signal->flags &= ~SIGNAL_UNKILLABLE;
77457 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
77458 + is_unhandled = 1;
77459 ret = specific_send_sig_info(sig, info, t);
77460 spin_unlock_irqrestore(&t->sighand->siglock, flags);
77461
77462 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
77463 + normal operation */
77464 + if (is_unhandled) {
77465 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
77466 + gr_handle_crash(t, sig);
77467 + }
77468 +
77469 return ret;
77470 }
77471
77472 @@ -1317,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
77473 ret = check_kill_permission(sig, info, p);
77474 rcu_read_unlock();
77475
77476 - if (!ret && sig)
77477 + if (!ret && sig) {
77478 ret = do_send_sig_info(sig, info, p, true);
77479 + if (!ret)
77480 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
77481 + }
77482
77483 return ret;
77484 }
77485 @@ -2923,7 +2946,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
77486 int error = -ESRCH;
77487
77488 rcu_read_lock();
77489 - p = find_task_by_vpid(pid);
77490 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
77491 + /* allow glibc communication via tgkill to other threads in our
77492 + thread group */
77493 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
77494 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
77495 + p = find_task_by_vpid_unrestricted(pid);
77496 + else
77497 +#endif
77498 + p = find_task_by_vpid(pid);
77499 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
77500 error = check_kill_permission(sig, info, p);
77501 /*
77502 @@ -3237,8 +3268,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
77503 }
77504 seg = get_fs();
77505 set_fs(KERNEL_DS);
77506 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
77507 - (stack_t __force __user *) &uoss,
77508 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
77509 + (stack_t __force_user *) &uoss,
77510 compat_user_stack_pointer());
77511 set_fs(seg);
77512 if (ret >= 0 && uoss_ptr) {
77513 diff --git a/kernel/smp.c b/kernel/smp.c
77514 index 8e451f3..8322029 100644
77515 --- a/kernel/smp.c
77516 +++ b/kernel/smp.c
77517 @@ -73,7 +73,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
77518 return NOTIFY_OK;
77519 }
77520
77521 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
77522 +static struct notifier_block hotplug_cfd_notifier = {
77523 .notifier_call = hotplug_cfd,
77524 };
77525
77526 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
77527 index 02fc5c9..e54c335 100644
77528 --- a/kernel/smpboot.c
77529 +++ b/kernel/smpboot.c
77530 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
77531 }
77532 smpboot_unpark_thread(plug_thread, cpu);
77533 }
77534 - list_add(&plug_thread->list, &hotplug_threads);
77535 + pax_list_add(&plug_thread->list, &hotplug_threads);
77536 out:
77537 mutex_unlock(&smpboot_threads_lock);
77538 return ret;
77539 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
77540 {
77541 get_online_cpus();
77542 mutex_lock(&smpboot_threads_lock);
77543 - list_del(&plug_thread->list);
77544 + pax_list_del(&plug_thread->list);
77545 smpboot_destroy_threads(plug_thread);
77546 mutex_unlock(&smpboot_threads_lock);
77547 put_online_cpus();
77548 diff --git a/kernel/softirq.c b/kernel/softirq.c
77549 index 14d7758..012121f 100644
77550 --- a/kernel/softirq.c
77551 +++ b/kernel/softirq.c
77552 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
77553 EXPORT_SYMBOL(irq_stat);
77554 #endif
77555
77556 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
77557 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
77558
77559 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
77560
77561 -char *softirq_to_name[NR_SOFTIRQS] = {
77562 +const char * const softirq_to_name[NR_SOFTIRQS] = {
77563 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
77564 "TASKLET", "SCHED", "HRTIMER", "RCU"
77565 };
77566 @@ -244,7 +244,7 @@ restart:
77567 kstat_incr_softirqs_this_cpu(vec_nr);
77568
77569 trace_softirq_entry(vec_nr);
77570 - h->action(h);
77571 + h->action();
77572 trace_softirq_exit(vec_nr);
77573 if (unlikely(prev_count != preempt_count())) {
77574 printk(KERN_ERR "huh, entered softirq %u %s %p"
77575 @@ -389,7 +389,7 @@ void __raise_softirq_irqoff(unsigned int nr)
77576 or_softirq_pending(1UL << nr);
77577 }
77578
77579 -void open_softirq(int nr, void (*action)(struct softirq_action *))
77580 +void __init open_softirq(int nr, void (*action)(void))
77581 {
77582 softirq_vec[nr].action = action;
77583 }
77584 @@ -445,7 +445,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
77585
77586 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
77587
77588 -static void tasklet_action(struct softirq_action *a)
77589 +static void tasklet_action(void)
77590 {
77591 struct tasklet_struct *list;
77592
77593 @@ -480,7 +480,7 @@ static void tasklet_action(struct softirq_action *a)
77594 }
77595 }
77596
77597 -static void tasklet_hi_action(struct softirq_action *a)
77598 +static void tasklet_hi_action(void)
77599 {
77600 struct tasklet_struct *list;
77601
77602 @@ -716,7 +716,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
77603 return NOTIFY_OK;
77604 }
77605
77606 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
77607 +static struct notifier_block remote_softirq_cpu_notifier = {
77608 .notifier_call = remote_softirq_cpu_notify,
77609 };
77610
77611 @@ -833,11 +833,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
77612 return NOTIFY_OK;
77613 }
77614
77615 -static struct notifier_block __cpuinitdata cpu_nfb = {
77616 +static struct notifier_block cpu_nfb = {
77617 .notifier_call = cpu_callback
77618 };
77619
77620 -static struct smp_hotplug_thread softirq_threads = {
77621 +static struct smp_hotplug_thread softirq_threads __read_only = {
77622 .store = &ksoftirqd,
77623 .thread_should_run = ksoftirqd_should_run,
77624 .thread_fn = run_ksoftirqd,
77625 diff --git a/kernel/srcu.c b/kernel/srcu.c
77626 index 01d5ccb..cdcbee6 100644
77627 --- a/kernel/srcu.c
77628 +++ b/kernel/srcu.c
77629 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
77630
77631 idx = ACCESS_ONCE(sp->completed) & 0x1;
77632 preempt_disable();
77633 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
77634 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
77635 smp_mb(); /* B */ /* Avoid leaking the critical section. */
77636 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
77637 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
77638 preempt_enable();
77639 return idx;
77640 }
77641 diff --git a/kernel/sys.c b/kernel/sys.c
77642 index 0da73cf..a22106a 100644
77643 --- a/kernel/sys.c
77644 +++ b/kernel/sys.c
77645 @@ -158,6 +158,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
77646 error = -EACCES;
77647 goto out;
77648 }
77649 +
77650 + if (gr_handle_chroot_setpriority(p, niceval)) {
77651 + error = -EACCES;
77652 + goto out;
77653 + }
77654 +
77655 no_nice = security_task_setnice(p, niceval);
77656 if (no_nice) {
77657 error = no_nice;
77658 @@ -598,6 +604,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
77659 goto error;
77660 }
77661
77662 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
77663 + goto error;
77664 +
77665 if (rgid != (gid_t) -1 ||
77666 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
77667 new->sgid = new->egid;
77668 @@ -633,6 +642,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
77669 old = current_cred();
77670
77671 retval = -EPERM;
77672 +
77673 + if (gr_check_group_change(kgid, kgid, kgid))
77674 + goto error;
77675 +
77676 if (nsown_capable(CAP_SETGID))
77677 new->gid = new->egid = new->sgid = new->fsgid = kgid;
77678 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
77679 @@ -650,7 +663,7 @@ error:
77680 /*
77681 * change the user struct in a credentials set to match the new UID
77682 */
77683 -static int set_user(struct cred *new)
77684 +int set_user(struct cred *new)
77685 {
77686 struct user_struct *new_user;
77687
77688 @@ -730,6 +743,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
77689 goto error;
77690 }
77691
77692 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
77693 + goto error;
77694 +
77695 if (!uid_eq(new->uid, old->uid)) {
77696 retval = set_user(new);
77697 if (retval < 0)
77698 @@ -780,6 +796,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
77699 old = current_cred();
77700
77701 retval = -EPERM;
77702 +
77703 + if (gr_check_crash_uid(kuid))
77704 + goto error;
77705 + if (gr_check_user_change(kuid, kuid, kuid))
77706 + goto error;
77707 +
77708 if (nsown_capable(CAP_SETUID)) {
77709 new->suid = new->uid = kuid;
77710 if (!uid_eq(kuid, old->uid)) {
77711 @@ -849,6 +871,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
77712 goto error;
77713 }
77714
77715 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
77716 + goto error;
77717 +
77718 if (ruid != (uid_t) -1) {
77719 new->uid = kruid;
77720 if (!uid_eq(kruid, old->uid)) {
77721 @@ -931,6 +956,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
77722 goto error;
77723 }
77724
77725 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
77726 + goto error;
77727 +
77728 if (rgid != (gid_t) -1)
77729 new->gid = krgid;
77730 if (egid != (gid_t) -1)
77731 @@ -992,12 +1020,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
77732 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
77733 nsown_capable(CAP_SETUID)) {
77734 if (!uid_eq(kuid, old->fsuid)) {
77735 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
77736 + goto error;
77737 +
77738 new->fsuid = kuid;
77739 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
77740 goto change_okay;
77741 }
77742 }
77743
77744 +error:
77745 abort_creds(new);
77746 return old_fsuid;
77747
77748 @@ -1030,12 +1062,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
77749 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
77750 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
77751 nsown_capable(CAP_SETGID)) {
77752 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
77753 + goto error;
77754 +
77755 if (!gid_eq(kgid, old->fsgid)) {
77756 new->fsgid = kgid;
77757 goto change_okay;
77758 }
77759 }
77760
77761 +error:
77762 abort_creds(new);
77763 return old_fsgid;
77764
77765 @@ -1343,19 +1379,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
77766 return -EFAULT;
77767
77768 down_read(&uts_sem);
77769 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
77770 + error = __copy_to_user(name->sysname, &utsname()->sysname,
77771 __OLD_UTS_LEN);
77772 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
77773 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
77774 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
77775 __OLD_UTS_LEN);
77776 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
77777 - error |= __copy_to_user(&name->release, &utsname()->release,
77778 + error |= __copy_to_user(name->release, &utsname()->release,
77779 __OLD_UTS_LEN);
77780 error |= __put_user(0, name->release + __OLD_UTS_LEN);
77781 - error |= __copy_to_user(&name->version, &utsname()->version,
77782 + error |= __copy_to_user(name->version, &utsname()->version,
77783 __OLD_UTS_LEN);
77784 error |= __put_user(0, name->version + __OLD_UTS_LEN);
77785 - error |= __copy_to_user(&name->machine, &utsname()->machine,
77786 + error |= __copy_to_user(name->machine, &utsname()->machine,
77787 __OLD_UTS_LEN);
77788 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
77789 up_read(&uts_sem);
77790 @@ -1557,6 +1593,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
77791 */
77792 new_rlim->rlim_cur = 1;
77793 }
77794 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
77795 + is changed to a lower value. Since tasks can be created by the same
77796 + user in between this limit change and an execve by this task, force
77797 + a recheck only for this task by setting PF_NPROC_EXCEEDED
77798 + */
77799 + if (resource == RLIMIT_NPROC)
77800 + tsk->flags |= PF_NPROC_EXCEEDED;
77801 }
77802 if (!retval) {
77803 if (old_rlim)
77804 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
77805 index afc1dc6..71b5c39 100644
77806 --- a/kernel/sysctl.c
77807 +++ b/kernel/sysctl.c
77808 @@ -93,7 +93,6 @@
77809
77810
77811 #if defined(CONFIG_SYSCTL)
77812 -
77813 /* External variables not in a header file. */
77814 extern int sysctl_overcommit_memory;
77815 extern int sysctl_overcommit_ratio;
77816 @@ -178,10 +177,8 @@ static int proc_taint(struct ctl_table *table, int write,
77817 void __user *buffer, size_t *lenp, loff_t *ppos);
77818 #endif
77819
77820 -#ifdef CONFIG_PRINTK
77821 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
77822 void __user *buffer, size_t *lenp, loff_t *ppos);
77823 -#endif
77824
77825 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
77826 void __user *buffer, size_t *lenp, loff_t *ppos);
77827 @@ -212,6 +209,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
77828
77829 #endif
77830
77831 +extern struct ctl_table grsecurity_table[];
77832 +
77833 static struct ctl_table kern_table[];
77834 static struct ctl_table vm_table[];
77835 static struct ctl_table fs_table[];
77836 @@ -226,6 +225,20 @@ extern struct ctl_table epoll_table[];
77837 int sysctl_legacy_va_layout;
77838 #endif
77839
77840 +#ifdef CONFIG_PAX_SOFTMODE
77841 +static ctl_table pax_table[] = {
77842 + {
77843 + .procname = "softmode",
77844 + .data = &pax_softmode,
77845 + .maxlen = sizeof(unsigned int),
77846 + .mode = 0600,
77847 + .proc_handler = &proc_dointvec,
77848 + },
77849 +
77850 + { }
77851 +};
77852 +#endif
77853 +
77854 /* The default sysctl tables: */
77855
77856 static struct ctl_table sysctl_base_table[] = {
77857 @@ -274,6 +287,22 @@ static int max_extfrag_threshold = 1000;
77858 #endif
77859
77860 static struct ctl_table kern_table[] = {
77861 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
77862 + {
77863 + .procname = "grsecurity",
77864 + .mode = 0500,
77865 + .child = grsecurity_table,
77866 + },
77867 +#endif
77868 +
77869 +#ifdef CONFIG_PAX_SOFTMODE
77870 + {
77871 + .procname = "pax",
77872 + .mode = 0500,
77873 + .child = pax_table,
77874 + },
77875 +#endif
77876 +
77877 {
77878 .procname = "sched_child_runs_first",
77879 .data = &sysctl_sched_child_runs_first,
77880 @@ -608,7 +637,7 @@ static struct ctl_table kern_table[] = {
77881 .data = &modprobe_path,
77882 .maxlen = KMOD_PATH_LEN,
77883 .mode = 0644,
77884 - .proc_handler = proc_dostring,
77885 + .proc_handler = proc_dostring_modpriv,
77886 },
77887 {
77888 .procname = "modules_disabled",
77889 @@ -775,16 +804,20 @@ static struct ctl_table kern_table[] = {
77890 .extra1 = &zero,
77891 .extra2 = &one,
77892 },
77893 +#endif
77894 {
77895 .procname = "kptr_restrict",
77896 .data = &kptr_restrict,
77897 .maxlen = sizeof(int),
77898 .mode = 0644,
77899 .proc_handler = proc_dointvec_minmax_sysadmin,
77900 +#ifdef CONFIG_GRKERNSEC_HIDESYM
77901 + .extra1 = &two,
77902 +#else
77903 .extra1 = &zero,
77904 +#endif
77905 .extra2 = &two,
77906 },
77907 -#endif
77908 {
77909 .procname = "ngroups_max",
77910 .data = &ngroups_max,
77911 @@ -1283,6 +1316,13 @@ static struct ctl_table vm_table[] = {
77912 .proc_handler = proc_dointvec_minmax,
77913 .extra1 = &zero,
77914 },
77915 + {
77916 + .procname = "heap_stack_gap",
77917 + .data = &sysctl_heap_stack_gap,
77918 + .maxlen = sizeof(sysctl_heap_stack_gap),
77919 + .mode = 0644,
77920 + .proc_handler = proc_doulongvec_minmax,
77921 + },
77922 #else
77923 {
77924 .procname = "nr_trim_pages",
77925 @@ -1733,6 +1773,16 @@ int proc_dostring(struct ctl_table *table, int write,
77926 buffer, lenp, ppos);
77927 }
77928
77929 +int proc_dostring_modpriv(struct ctl_table *table, int write,
77930 + void __user *buffer, size_t *lenp, loff_t *ppos)
77931 +{
77932 + if (write && !capable(CAP_SYS_MODULE))
77933 + return -EPERM;
77934 +
77935 + return _proc_do_string(table->data, table->maxlen, write,
77936 + buffer, lenp, ppos);
77937 +}
77938 +
77939 static size_t proc_skip_spaces(char **buf)
77940 {
77941 size_t ret;
77942 @@ -1838,6 +1888,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
77943 len = strlen(tmp);
77944 if (len > *size)
77945 len = *size;
77946 + if (len > sizeof(tmp))
77947 + len = sizeof(tmp);
77948 if (copy_to_user(*buf, tmp, len))
77949 return -EFAULT;
77950 *size -= len;
77951 @@ -2002,7 +2054,7 @@ int proc_dointvec(struct ctl_table *table, int write,
77952 static int proc_taint(struct ctl_table *table, int write,
77953 void __user *buffer, size_t *lenp, loff_t *ppos)
77954 {
77955 - struct ctl_table t;
77956 + ctl_table_no_const t;
77957 unsigned long tmptaint = get_taint();
77958 int err;
77959
77960 @@ -2030,7 +2082,6 @@ static int proc_taint(struct ctl_table *table, int write,
77961 return err;
77962 }
77963
77964 -#ifdef CONFIG_PRINTK
77965 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
77966 void __user *buffer, size_t *lenp, loff_t *ppos)
77967 {
77968 @@ -2039,7 +2090,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
77969
77970 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
77971 }
77972 -#endif
77973
77974 struct do_proc_dointvec_minmax_conv_param {
77975 int *min;
77976 @@ -2186,8 +2236,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
77977 *i = val;
77978 } else {
77979 val = convdiv * (*i) / convmul;
77980 - if (!first)
77981 + if (!first) {
77982 err = proc_put_char(&buffer, &left, '\t');
77983 + if (err)
77984 + break;
77985 + }
77986 err = proc_put_long(&buffer, &left, val, false);
77987 if (err)
77988 break;
77989 @@ -2579,6 +2632,12 @@ int proc_dostring(struct ctl_table *table, int write,
77990 return -ENOSYS;
77991 }
77992
77993 +int proc_dostring_modpriv(struct ctl_table *table, int write,
77994 + void __user *buffer, size_t *lenp, loff_t *ppos)
77995 +{
77996 + return -ENOSYS;
77997 +}
77998 +
77999 int proc_dointvec(struct ctl_table *table, int write,
78000 void __user *buffer, size_t *lenp, loff_t *ppos)
78001 {
78002 @@ -2635,5 +2694,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
78003 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
78004 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
78005 EXPORT_SYMBOL(proc_dostring);
78006 +EXPORT_SYMBOL(proc_dostring_modpriv);
78007 EXPORT_SYMBOL(proc_doulongvec_minmax);
78008 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
78009 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
78010 index 145bb4d..b2aa969 100644
78011 --- a/kernel/taskstats.c
78012 +++ b/kernel/taskstats.c
78013 @@ -28,9 +28,12 @@
78014 #include <linux/fs.h>
78015 #include <linux/file.h>
78016 #include <linux/pid_namespace.h>
78017 +#include <linux/grsecurity.h>
78018 #include <net/genetlink.h>
78019 #include <linux/atomic.h>
78020
78021 +extern int gr_is_taskstats_denied(int pid);
78022 +
78023 /*
78024 * Maximum length of a cpumask that can be specified in
78025 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
78026 @@ -570,6 +573,9 @@ err:
78027
78028 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
78029 {
78030 + if (gr_is_taskstats_denied(current->pid))
78031 + return -EACCES;
78032 +
78033 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
78034 return cmd_attr_register_cpumask(info);
78035 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
78036 diff --git a/kernel/time.c b/kernel/time.c
78037 index f8342a4..288f13b 100644
78038 --- a/kernel/time.c
78039 +++ b/kernel/time.c
78040 @@ -171,6 +171,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
78041 return error;
78042
78043 if (tz) {
78044 + /* we log in do_settimeofday called below, so don't log twice
78045 + */
78046 + if (!tv)
78047 + gr_log_timechange();
78048 +
78049 sys_tz = *tz;
78050 update_vsyscall_tz();
78051 if (firsttime) {
78052 @@ -501,7 +506,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
78053 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
78054 * value to a scaled second value.
78055 */
78056 -unsigned long
78057 +unsigned long __intentional_overflow(-1)
78058 timespec_to_jiffies(const struct timespec *value)
78059 {
78060 unsigned long sec = value->tv_sec;
78061 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
78062 index f11d83b..d016d91 100644
78063 --- a/kernel/time/alarmtimer.c
78064 +++ b/kernel/time/alarmtimer.c
78065 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
78066 struct platform_device *pdev;
78067 int error = 0;
78068 int i;
78069 - struct k_clock alarm_clock = {
78070 + static struct k_clock alarm_clock = {
78071 .clock_getres = alarm_clock_getres,
78072 .clock_get = alarm_clock_get,
78073 .timer_create = alarm_timer_create,
78074 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
78075 index 90ad470..1814e9a 100644
78076 --- a/kernel/time/tick-broadcast.c
78077 +++ b/kernel/time/tick-broadcast.c
78078 @@ -138,7 +138,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
78079 * then clear the broadcast bit.
78080 */
78081 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
78082 - int cpu = smp_processor_id();
78083 + cpu = smp_processor_id();
78084 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
78085 tick_broadcast_clear_oneshot(cpu);
78086 } else {
78087 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
78088 index 9a0bc98..fceb7d0 100644
78089 --- a/kernel/time/timekeeping.c
78090 +++ b/kernel/time/timekeeping.c
78091 @@ -15,6 +15,7 @@
78092 #include <linux/init.h>
78093 #include <linux/mm.h>
78094 #include <linux/sched.h>
78095 +#include <linux/grsecurity.h>
78096 #include <linux/syscore_ops.h>
78097 #include <linux/clocksource.h>
78098 #include <linux/jiffies.h>
78099 @@ -448,6 +449,8 @@ int do_settimeofday(const struct timespec *tv)
78100 if (!timespec_valid_strict(tv))
78101 return -EINVAL;
78102
78103 + gr_log_timechange();
78104 +
78105 write_seqlock_irqsave(&tk->lock, flags);
78106
78107 timekeeping_forward_now(tk);
78108 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
78109 index af5a7e9..715611a 100644
78110 --- a/kernel/time/timer_list.c
78111 +++ b/kernel/time/timer_list.c
78112 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
78113
78114 static void print_name_offset(struct seq_file *m, void *sym)
78115 {
78116 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78117 + SEQ_printf(m, "<%p>", NULL);
78118 +#else
78119 char symname[KSYM_NAME_LEN];
78120
78121 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
78122 SEQ_printf(m, "<%pK>", sym);
78123 else
78124 SEQ_printf(m, "%s", symname);
78125 +#endif
78126 }
78127
78128 static void
78129 @@ -112,7 +116,11 @@ next_one:
78130 static void
78131 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
78132 {
78133 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78134 + SEQ_printf(m, " .base: %p\n", NULL);
78135 +#else
78136 SEQ_printf(m, " .base: %pK\n", base);
78137 +#endif
78138 SEQ_printf(m, " .index: %d\n",
78139 base->index);
78140 SEQ_printf(m, " .resolution: %Lu nsecs\n",
78141 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
78142 {
78143 struct proc_dir_entry *pe;
78144
78145 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78146 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
78147 +#else
78148 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
78149 +#endif
78150 if (!pe)
78151 return -ENOMEM;
78152 return 0;
78153 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
78154 index 0b537f2..40d6c20 100644
78155 --- a/kernel/time/timer_stats.c
78156 +++ b/kernel/time/timer_stats.c
78157 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
78158 static unsigned long nr_entries;
78159 static struct entry entries[MAX_ENTRIES];
78160
78161 -static atomic_t overflow_count;
78162 +static atomic_unchecked_t overflow_count;
78163
78164 /*
78165 * The entries are in a hash-table, for fast lookup:
78166 @@ -140,7 +140,7 @@ static void reset_entries(void)
78167 nr_entries = 0;
78168 memset(entries, 0, sizeof(entries));
78169 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
78170 - atomic_set(&overflow_count, 0);
78171 + atomic_set_unchecked(&overflow_count, 0);
78172 }
78173
78174 static struct entry *alloc_entry(void)
78175 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
78176 if (likely(entry))
78177 entry->count++;
78178 else
78179 - atomic_inc(&overflow_count);
78180 + atomic_inc_unchecked(&overflow_count);
78181
78182 out_unlock:
78183 raw_spin_unlock_irqrestore(lock, flags);
78184 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
78185
78186 static void print_name_offset(struct seq_file *m, unsigned long addr)
78187 {
78188 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78189 + seq_printf(m, "<%p>", NULL);
78190 +#else
78191 char symname[KSYM_NAME_LEN];
78192
78193 if (lookup_symbol_name(addr, symname) < 0)
78194 - seq_printf(m, "<%p>", (void *)addr);
78195 + seq_printf(m, "<%pK>", (void *)addr);
78196 else
78197 seq_printf(m, "%s", symname);
78198 +#endif
78199 }
78200
78201 static int tstats_show(struct seq_file *m, void *v)
78202 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
78203
78204 seq_puts(m, "Timer Stats Version: v0.2\n");
78205 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
78206 - if (atomic_read(&overflow_count))
78207 + if (atomic_read_unchecked(&overflow_count))
78208 seq_printf(m, "Overflow: %d entries\n",
78209 - atomic_read(&overflow_count));
78210 + atomic_read_unchecked(&overflow_count));
78211
78212 for (i = 0; i < nr_entries; i++) {
78213 entry = entries + i;
78214 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
78215 {
78216 struct proc_dir_entry *pe;
78217
78218 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78219 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
78220 +#else
78221 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
78222 +#endif
78223 if (!pe)
78224 return -ENOMEM;
78225 return 0;
78226 diff --git a/kernel/timer.c b/kernel/timer.c
78227 index dbf7a78..e2148f0 100644
78228 --- a/kernel/timer.c
78229 +++ b/kernel/timer.c
78230 @@ -1363,7 +1363,7 @@ void update_process_times(int user_tick)
78231 /*
78232 * This function runs timers and the timer-tq in bottom half context.
78233 */
78234 -static void run_timer_softirq(struct softirq_action *h)
78235 +static void run_timer_softirq(void)
78236 {
78237 struct tvec_base *base = __this_cpu_read(tvec_bases);
78238
78239 @@ -1481,7 +1481,7 @@ static void process_timeout(unsigned long __data)
78240 *
78241 * In all cases the return value is guaranteed to be non-negative.
78242 */
78243 -signed long __sched schedule_timeout(signed long timeout)
78244 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
78245 {
78246 struct timer_list timer;
78247 unsigned long expire;
78248 @@ -1772,7 +1772,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
78249 return NOTIFY_OK;
78250 }
78251
78252 -static struct notifier_block __cpuinitdata timers_nb = {
78253 +static struct notifier_block timers_nb = {
78254 .notifier_call = timer_cpu_notify,
78255 };
78256
78257 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
78258 index 5a0f781..1497f95 100644
78259 --- a/kernel/trace/blktrace.c
78260 +++ b/kernel/trace/blktrace.c
78261 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
78262 struct blk_trace *bt = filp->private_data;
78263 char buf[16];
78264
78265 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
78266 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
78267
78268 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
78269 }
78270 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
78271 return 1;
78272
78273 bt = buf->chan->private_data;
78274 - atomic_inc(&bt->dropped);
78275 + atomic_inc_unchecked(&bt->dropped);
78276 return 0;
78277 }
78278
78279 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
78280
78281 bt->dir = dir;
78282 bt->dev = dev;
78283 - atomic_set(&bt->dropped, 0);
78284 + atomic_set_unchecked(&bt->dropped, 0);
78285
78286 ret = -EIO;
78287 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
78288 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
78289 index 0a0e2a6..943495e 100644
78290 --- a/kernel/trace/ftrace.c
78291 +++ b/kernel/trace/ftrace.c
78292 @@ -1909,12 +1909,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
78293 if (unlikely(ftrace_disabled))
78294 return 0;
78295
78296 + ret = ftrace_arch_code_modify_prepare();
78297 + FTRACE_WARN_ON(ret);
78298 + if (ret)
78299 + return 0;
78300 +
78301 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
78302 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
78303 if (ret) {
78304 ftrace_bug(ret, ip);
78305 - return 0;
78306 }
78307 - return 1;
78308 + return ret ? 0 : 1;
78309 }
78310
78311 /*
78312 @@ -2986,7 +2991,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
78313
78314 int
78315 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
78316 - void *data)
78317 + void *data)
78318 {
78319 struct ftrace_func_probe *entry;
78320 struct ftrace_page *pg;
78321 @@ -3854,8 +3859,10 @@ static int ftrace_process_locs(struct module *mod,
78322 if (!count)
78323 return 0;
78324
78325 + pax_open_kernel();
78326 sort(start, count, sizeof(*start),
78327 ftrace_cmp_ips, ftrace_swap_ips);
78328 + pax_close_kernel();
78329
78330 start_pg = ftrace_allocate_pages(count);
78331 if (!start_pg)
78332 @@ -4574,8 +4581,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
78333 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
78334
78335 static int ftrace_graph_active;
78336 -static struct notifier_block ftrace_suspend_notifier;
78337 -
78338 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
78339 {
78340 return 0;
78341 @@ -4719,6 +4724,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
78342 return NOTIFY_DONE;
78343 }
78344
78345 +static struct notifier_block ftrace_suspend_notifier = {
78346 + .notifier_call = ftrace_suspend_notifier_call
78347 +};
78348 +
78349 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
78350 trace_func_graph_ent_t entryfunc)
78351 {
78352 @@ -4732,7 +4741,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
78353 goto out;
78354 }
78355
78356 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
78357 register_pm_notifier(&ftrace_suspend_notifier);
78358
78359 ftrace_graph_active++;
78360 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
78361 index 6989df2..c2265cf 100644
78362 --- a/kernel/trace/ring_buffer.c
78363 +++ b/kernel/trace/ring_buffer.c
78364 @@ -349,9 +349,9 @@ struct buffer_data_page {
78365 */
78366 struct buffer_page {
78367 struct list_head list; /* list of buffer pages */
78368 - local_t write; /* index for next write */
78369 + local_unchecked_t write; /* index for next write */
78370 unsigned read; /* index for next read */
78371 - local_t entries; /* entries on this page */
78372 + local_unchecked_t entries; /* entries on this page */
78373 unsigned long real_end; /* real end of data */
78374 struct buffer_data_page *page; /* Actual data page */
78375 };
78376 @@ -464,8 +464,8 @@ struct ring_buffer_per_cpu {
78377 unsigned long last_overrun;
78378 local_t entries_bytes;
78379 local_t entries;
78380 - local_t overrun;
78381 - local_t commit_overrun;
78382 + local_unchecked_t overrun;
78383 + local_unchecked_t commit_overrun;
78384 local_t dropped_events;
78385 local_t committing;
78386 local_t commits;
78387 @@ -864,8 +864,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
78388 *
78389 * We add a counter to the write field to denote this.
78390 */
78391 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
78392 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
78393 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
78394 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
78395
78396 /*
78397 * Just make sure we have seen our old_write and synchronize
78398 @@ -893,8 +893,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
78399 * cmpxchg to only update if an interrupt did not already
78400 * do it for us. If the cmpxchg fails, we don't care.
78401 */
78402 - (void)local_cmpxchg(&next_page->write, old_write, val);
78403 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
78404 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
78405 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
78406
78407 /*
78408 * No need to worry about races with clearing out the commit.
78409 @@ -1253,12 +1253,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
78410
78411 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
78412 {
78413 - return local_read(&bpage->entries) & RB_WRITE_MASK;
78414 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
78415 }
78416
78417 static inline unsigned long rb_page_write(struct buffer_page *bpage)
78418 {
78419 - return local_read(&bpage->write) & RB_WRITE_MASK;
78420 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
78421 }
78422
78423 static int
78424 @@ -1353,7 +1353,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
78425 * bytes consumed in ring buffer from here.
78426 * Increment overrun to account for the lost events.
78427 */
78428 - local_add(page_entries, &cpu_buffer->overrun);
78429 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
78430 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
78431 }
78432
78433 @@ -1909,7 +1909,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
78434 * it is our responsibility to update
78435 * the counters.
78436 */
78437 - local_add(entries, &cpu_buffer->overrun);
78438 + local_add_unchecked(entries, &cpu_buffer->overrun);
78439 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
78440
78441 /*
78442 @@ -2059,7 +2059,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
78443 if (tail == BUF_PAGE_SIZE)
78444 tail_page->real_end = 0;
78445
78446 - local_sub(length, &tail_page->write);
78447 + local_sub_unchecked(length, &tail_page->write);
78448 return;
78449 }
78450
78451 @@ -2094,7 +2094,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
78452 rb_event_set_padding(event);
78453
78454 /* Set the write back to the previous setting */
78455 - local_sub(length, &tail_page->write);
78456 + local_sub_unchecked(length, &tail_page->write);
78457 return;
78458 }
78459
78460 @@ -2106,7 +2106,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
78461
78462 /* Set write to end of buffer */
78463 length = (tail + length) - BUF_PAGE_SIZE;
78464 - local_sub(length, &tail_page->write);
78465 + local_sub_unchecked(length, &tail_page->write);
78466 }
78467
78468 /*
78469 @@ -2132,7 +2132,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
78470 * about it.
78471 */
78472 if (unlikely(next_page == commit_page)) {
78473 - local_inc(&cpu_buffer->commit_overrun);
78474 + local_inc_unchecked(&cpu_buffer->commit_overrun);
78475 goto out_reset;
78476 }
78477
78478 @@ -2188,7 +2188,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
78479 cpu_buffer->tail_page) &&
78480 (cpu_buffer->commit_page ==
78481 cpu_buffer->reader_page))) {
78482 - local_inc(&cpu_buffer->commit_overrun);
78483 + local_inc_unchecked(&cpu_buffer->commit_overrun);
78484 goto out_reset;
78485 }
78486 }
78487 @@ -2236,7 +2236,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
78488 length += RB_LEN_TIME_EXTEND;
78489
78490 tail_page = cpu_buffer->tail_page;
78491 - write = local_add_return(length, &tail_page->write);
78492 + write = local_add_return_unchecked(length, &tail_page->write);
78493
78494 /* set write to only the index of the write */
78495 write &= RB_WRITE_MASK;
78496 @@ -2253,7 +2253,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
78497 kmemcheck_annotate_bitfield(event, bitfield);
78498 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
78499
78500 - local_inc(&tail_page->entries);
78501 + local_inc_unchecked(&tail_page->entries);
78502
78503 /*
78504 * If this is the first commit on the page, then update
78505 @@ -2286,7 +2286,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
78506
78507 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
78508 unsigned long write_mask =
78509 - local_read(&bpage->write) & ~RB_WRITE_MASK;
78510 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
78511 unsigned long event_length = rb_event_length(event);
78512 /*
78513 * This is on the tail page. It is possible that
78514 @@ -2296,7 +2296,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
78515 */
78516 old_index += write_mask;
78517 new_index += write_mask;
78518 - index = local_cmpxchg(&bpage->write, old_index, new_index);
78519 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
78520 if (index == old_index) {
78521 /* update counters */
78522 local_sub(event_length, &cpu_buffer->entries_bytes);
78523 @@ -2670,7 +2670,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
78524
78525 /* Do the likely case first */
78526 if (likely(bpage->page == (void *)addr)) {
78527 - local_dec(&bpage->entries);
78528 + local_dec_unchecked(&bpage->entries);
78529 return;
78530 }
78531
78532 @@ -2682,7 +2682,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
78533 start = bpage;
78534 do {
78535 if (bpage->page == (void *)addr) {
78536 - local_dec(&bpage->entries);
78537 + local_dec_unchecked(&bpage->entries);
78538 return;
78539 }
78540 rb_inc_page(cpu_buffer, &bpage);
78541 @@ -2964,7 +2964,7 @@ static inline unsigned long
78542 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
78543 {
78544 return local_read(&cpu_buffer->entries) -
78545 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
78546 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
78547 }
78548
78549 /**
78550 @@ -3053,7 +3053,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
78551 return 0;
78552
78553 cpu_buffer = buffer->buffers[cpu];
78554 - ret = local_read(&cpu_buffer->overrun);
78555 + ret = local_read_unchecked(&cpu_buffer->overrun);
78556
78557 return ret;
78558 }
78559 @@ -3076,7 +3076,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
78560 return 0;
78561
78562 cpu_buffer = buffer->buffers[cpu];
78563 - ret = local_read(&cpu_buffer->commit_overrun);
78564 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
78565
78566 return ret;
78567 }
78568 @@ -3161,7 +3161,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
78569 /* if you care about this being correct, lock the buffer */
78570 for_each_buffer_cpu(buffer, cpu) {
78571 cpu_buffer = buffer->buffers[cpu];
78572 - overruns += local_read(&cpu_buffer->overrun);
78573 + overruns += local_read_unchecked(&cpu_buffer->overrun);
78574 }
78575
78576 return overruns;
78577 @@ -3337,8 +3337,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
78578 /*
78579 * Reset the reader page to size zero.
78580 */
78581 - local_set(&cpu_buffer->reader_page->write, 0);
78582 - local_set(&cpu_buffer->reader_page->entries, 0);
78583 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
78584 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
78585 local_set(&cpu_buffer->reader_page->page->commit, 0);
78586 cpu_buffer->reader_page->real_end = 0;
78587
78588 @@ -3372,7 +3372,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
78589 * want to compare with the last_overrun.
78590 */
78591 smp_mb();
78592 - overwrite = local_read(&(cpu_buffer->overrun));
78593 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
78594
78595 /*
78596 * Here's the tricky part.
78597 @@ -3942,8 +3942,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
78598
78599 cpu_buffer->head_page
78600 = list_entry(cpu_buffer->pages, struct buffer_page, list);
78601 - local_set(&cpu_buffer->head_page->write, 0);
78602 - local_set(&cpu_buffer->head_page->entries, 0);
78603 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
78604 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
78605 local_set(&cpu_buffer->head_page->page->commit, 0);
78606
78607 cpu_buffer->head_page->read = 0;
78608 @@ -3953,14 +3953,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
78609
78610 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
78611 INIT_LIST_HEAD(&cpu_buffer->new_pages);
78612 - local_set(&cpu_buffer->reader_page->write, 0);
78613 - local_set(&cpu_buffer->reader_page->entries, 0);
78614 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
78615 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
78616 local_set(&cpu_buffer->reader_page->page->commit, 0);
78617 cpu_buffer->reader_page->read = 0;
78618
78619 local_set(&cpu_buffer->entries_bytes, 0);
78620 - local_set(&cpu_buffer->overrun, 0);
78621 - local_set(&cpu_buffer->commit_overrun, 0);
78622 + local_set_unchecked(&cpu_buffer->overrun, 0);
78623 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
78624 local_set(&cpu_buffer->dropped_events, 0);
78625 local_set(&cpu_buffer->entries, 0);
78626 local_set(&cpu_buffer->committing, 0);
78627 @@ -4364,8 +4364,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
78628 rb_init_page(bpage);
78629 bpage = reader->page;
78630 reader->page = *data_page;
78631 - local_set(&reader->write, 0);
78632 - local_set(&reader->entries, 0);
78633 + local_set_unchecked(&reader->write, 0);
78634 + local_set_unchecked(&reader->entries, 0);
78635 reader->read = 0;
78636 *data_page = bpage;
78637
78638 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
78639 index 3f28192..a29e8b0 100644
78640 --- a/kernel/trace/trace.c
78641 +++ b/kernel/trace/trace.c
78642 @@ -2893,7 +2893,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
78643 return 0;
78644 }
78645
78646 -int set_tracer_flag(unsigned int mask, int enabled)
78647 +int set_tracer_flag(unsigned long mask, int enabled)
78648 {
78649 /* do nothing if flag is already set */
78650 if (!!(trace_flags & mask) == !!enabled)
78651 @@ -4637,10 +4637,9 @@ static const struct file_operations tracing_dyn_info_fops = {
78652 };
78653 #endif
78654
78655 -static struct dentry *d_tracer;
78656 -
78657 struct dentry *tracing_init_dentry(void)
78658 {
78659 + static struct dentry *d_tracer;
78660 static int once;
78661
78662 if (d_tracer)
78663 @@ -4660,10 +4659,9 @@ struct dentry *tracing_init_dentry(void)
78664 return d_tracer;
78665 }
78666
78667 -static struct dentry *d_percpu;
78668 -
78669 static struct dentry *tracing_dentry_percpu(void)
78670 {
78671 + static struct dentry *d_percpu;
78672 static int once;
78673 struct dentry *d_tracer;
78674
78675 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
78676 index 2081971..09f861e 100644
78677 --- a/kernel/trace/trace.h
78678 +++ b/kernel/trace/trace.h
78679 @@ -948,7 +948,7 @@ extern const char *__stop___trace_bprintk_fmt[];
78680 void trace_printk_init_buffers(void);
78681 void trace_printk_start_comm(void);
78682 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
78683 -int set_tracer_flag(unsigned int mask, int enabled);
78684 +int set_tracer_flag(unsigned long mask, int enabled);
78685
78686 #undef FTRACE_ENTRY
78687 #define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter) \
78688 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
78689 index 57e9b28..eebe41c 100644
78690 --- a/kernel/trace/trace_events.c
78691 +++ b/kernel/trace/trace_events.c
78692 @@ -1329,10 +1329,6 @@ static LIST_HEAD(ftrace_module_file_list);
78693 struct ftrace_module_file_ops {
78694 struct list_head list;
78695 struct module *mod;
78696 - struct file_operations id;
78697 - struct file_operations enable;
78698 - struct file_operations format;
78699 - struct file_operations filter;
78700 };
78701
78702 static struct ftrace_module_file_ops *
78703 @@ -1353,17 +1349,12 @@ trace_create_file_ops(struct module *mod)
78704
78705 file_ops->mod = mod;
78706
78707 - file_ops->id = ftrace_event_id_fops;
78708 - file_ops->id.owner = mod;
78709 -
78710 - file_ops->enable = ftrace_enable_fops;
78711 - file_ops->enable.owner = mod;
78712 -
78713 - file_ops->filter = ftrace_event_filter_fops;
78714 - file_ops->filter.owner = mod;
78715 -
78716 - file_ops->format = ftrace_event_format_fops;
78717 - file_ops->format.owner = mod;
78718 + pax_open_kernel();
78719 + mod->trace_id.owner = mod;
78720 + mod->trace_enable.owner = mod;
78721 + mod->trace_filter.owner = mod;
78722 + mod->trace_format.owner = mod;
78723 + pax_close_kernel();
78724
78725 list_add(&file_ops->list, &ftrace_module_file_list);
78726
78727 @@ -1387,8 +1378,8 @@ static void trace_module_add_events(struct module *mod)
78728
78729 for_each_event(call, start, end) {
78730 __trace_add_event_call(*call, mod,
78731 - &file_ops->id, &file_ops->enable,
78732 - &file_ops->filter, &file_ops->format);
78733 + &mod->trace_id, &mod->trace_enable,
78734 + &mod->trace_filter, &mod->trace_format);
78735 }
78736 }
78737
78738 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
78739 index fd3c8aa..5f324a6 100644
78740 --- a/kernel/trace/trace_mmiotrace.c
78741 +++ b/kernel/trace/trace_mmiotrace.c
78742 @@ -24,7 +24,7 @@ struct header_iter {
78743 static struct trace_array *mmio_trace_array;
78744 static bool overrun_detected;
78745 static unsigned long prev_overruns;
78746 -static atomic_t dropped_count;
78747 +static atomic_unchecked_t dropped_count;
78748
78749 static void mmio_reset_data(struct trace_array *tr)
78750 {
78751 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
78752
78753 static unsigned long count_overruns(struct trace_iterator *iter)
78754 {
78755 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
78756 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
78757 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
78758
78759 if (over > prev_overruns)
78760 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
78761 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
78762 sizeof(*entry), 0, pc);
78763 if (!event) {
78764 - atomic_inc(&dropped_count);
78765 + atomic_inc_unchecked(&dropped_count);
78766 return;
78767 }
78768 entry = ring_buffer_event_data(event);
78769 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
78770 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
78771 sizeof(*entry), 0, pc);
78772 if (!event) {
78773 - atomic_inc(&dropped_count);
78774 + atomic_inc_unchecked(&dropped_count);
78775 return;
78776 }
78777 entry = ring_buffer_event_data(event);
78778 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
78779 index 697e88d..1a79993 100644
78780 --- a/kernel/trace/trace_output.c
78781 +++ b/kernel/trace/trace_output.c
78782 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
78783
78784 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
78785 if (!IS_ERR(p)) {
78786 - p = mangle_path(s->buffer + s->len, p, "\n");
78787 + p = mangle_path(s->buffer + s->len, p, "\n\\");
78788 if (p) {
78789 s->len = p - s->buffer;
78790 return 1;
78791 @@ -851,14 +851,16 @@ int register_ftrace_event(struct trace_event *event)
78792 goto out;
78793 }
78794
78795 + pax_open_kernel();
78796 if (event->funcs->trace == NULL)
78797 - event->funcs->trace = trace_nop_print;
78798 + *(void **)&event->funcs->trace = trace_nop_print;
78799 if (event->funcs->raw == NULL)
78800 - event->funcs->raw = trace_nop_print;
78801 + *(void **)&event->funcs->raw = trace_nop_print;
78802 if (event->funcs->hex == NULL)
78803 - event->funcs->hex = trace_nop_print;
78804 + *(void **)&event->funcs->hex = trace_nop_print;
78805 if (event->funcs->binary == NULL)
78806 - event->funcs->binary = trace_nop_print;
78807 + *(void **)&event->funcs->binary = trace_nop_print;
78808 + pax_close_kernel();
78809
78810 key = event->type & (EVENT_HASHSIZE - 1);
78811
78812 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
78813 index b20428c..4845a10 100644
78814 --- a/kernel/trace/trace_stack.c
78815 +++ b/kernel/trace/trace_stack.c
78816 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
78817 return;
78818
78819 /* we do not handle interrupt stacks yet */
78820 - if (!object_is_on_stack(stack))
78821 + if (!object_starts_on_stack(stack))
78822 return;
78823
78824 local_irq_save(flags);
78825 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
78826 index e134d8f..a018cdd 100644
78827 --- a/kernel/user_namespace.c
78828 +++ b/kernel/user_namespace.c
78829 @@ -853,7 +853,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
78830 if (atomic_read(&current->mm->mm_users) > 1)
78831 return -EINVAL;
78832
78833 - if (current->fs->users != 1)
78834 + if (atomic_read(&current->fs->users) != 1)
78835 return -EINVAL;
78836
78837 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
78838 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
78839 index 4f69f9a..7c6f8f8 100644
78840 --- a/kernel/utsname_sysctl.c
78841 +++ b/kernel/utsname_sysctl.c
78842 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
78843 static int proc_do_uts_string(ctl_table *table, int write,
78844 void __user *buffer, size_t *lenp, loff_t *ppos)
78845 {
78846 - struct ctl_table uts_table;
78847 + ctl_table_no_const uts_table;
78848 int r;
78849 memcpy(&uts_table, table, sizeof(uts_table));
78850 uts_table.data = get_uts(table, write);
78851 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
78852 index 4a94467..80a6f9c 100644
78853 --- a/kernel/watchdog.c
78854 +++ b/kernel/watchdog.c
78855 @@ -526,7 +526,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
78856 }
78857 #endif /* CONFIG_SYSCTL */
78858
78859 -static struct smp_hotplug_thread watchdog_threads = {
78860 +static struct smp_hotplug_thread watchdog_threads __read_only = {
78861 .store = &softlockup_watchdog,
78862 .thread_should_run = watchdog_should_run,
78863 .thread_fn = watchdog,
78864 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
78865 index 28be08c..47bab92 100644
78866 --- a/lib/Kconfig.debug
78867 +++ b/lib/Kconfig.debug
78868 @@ -549,7 +549,7 @@ config DEBUG_MUTEXES
78869
78870 config DEBUG_LOCK_ALLOC
78871 bool "Lock debugging: detect incorrect freeing of live locks"
78872 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
78873 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
78874 select DEBUG_SPINLOCK
78875 select DEBUG_MUTEXES
78876 select LOCKDEP
78877 @@ -563,7 +563,7 @@ config DEBUG_LOCK_ALLOC
78878
78879 config PROVE_LOCKING
78880 bool "Lock debugging: prove locking correctness"
78881 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
78882 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
78883 select LOCKDEP
78884 select DEBUG_SPINLOCK
78885 select DEBUG_MUTEXES
78886 @@ -614,7 +614,7 @@ config LOCKDEP
78887
78888 config LOCK_STAT
78889 bool "Lock usage statistics"
78890 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
78891 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
78892 select LOCKDEP
78893 select DEBUG_SPINLOCK
78894 select DEBUG_MUTEXES
78895 @@ -1282,6 +1282,7 @@ config LATENCYTOP
78896 depends on DEBUG_KERNEL
78897 depends on STACKTRACE_SUPPORT
78898 depends on PROC_FS
78899 + depends on !GRKERNSEC_HIDESYM
78900 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
78901 select KALLSYMS
78902 select KALLSYMS_ALL
78903 @@ -1310,7 +1311,7 @@ config INTERVAL_TREE_TEST
78904
78905 config PROVIDE_OHCI1394_DMA_INIT
78906 bool "Remote debugging over FireWire early on boot"
78907 - depends on PCI && X86
78908 + depends on PCI && X86 && !GRKERNSEC
78909 help
78910 If you want to debug problems which hang or crash the kernel early
78911 on boot and the crashing machine has a FireWire port, you can use
78912 @@ -1339,7 +1340,7 @@ config PROVIDE_OHCI1394_DMA_INIT
78913
78914 config FIREWIRE_OHCI_REMOTE_DMA
78915 bool "Remote debugging over FireWire with firewire-ohci"
78916 - depends on FIREWIRE_OHCI
78917 + depends on FIREWIRE_OHCI && !GRKERNSEC
78918 help
78919 This option lets you use the FireWire bus for remote debugging
78920 with help of the firewire-ohci driver. It enables unfiltered
78921 diff --git a/lib/Makefile b/lib/Makefile
78922 index 6e2cc56..9b13738 100644
78923 --- a/lib/Makefile
78924 +++ b/lib/Makefile
78925 @@ -47,7 +47,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
78926
78927 obj-$(CONFIG_BTREE) += btree.o
78928 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
78929 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
78930 +obj-y += list_debug.o
78931 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
78932
78933 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
78934 diff --git a/lib/bitmap.c b/lib/bitmap.c
78935 index 06f7e4f..f3cf2b0 100644
78936 --- a/lib/bitmap.c
78937 +++ b/lib/bitmap.c
78938 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
78939 {
78940 int c, old_c, totaldigits, ndigits, nchunks, nbits;
78941 u32 chunk;
78942 - const char __user __force *ubuf = (const char __user __force *)buf;
78943 + const char __user *ubuf = (const char __force_user *)buf;
78944
78945 bitmap_zero(maskp, nmaskbits);
78946
78947 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
78948 {
78949 if (!access_ok(VERIFY_READ, ubuf, ulen))
78950 return -EFAULT;
78951 - return __bitmap_parse((const char __force *)ubuf,
78952 + return __bitmap_parse((const char __force_kernel *)ubuf,
78953 ulen, 1, maskp, nmaskbits);
78954
78955 }
78956 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
78957 {
78958 unsigned a, b;
78959 int c, old_c, totaldigits;
78960 - const char __user __force *ubuf = (const char __user __force *)buf;
78961 + const char __user *ubuf = (const char __force_user *)buf;
78962 int exp_digit, in_range;
78963
78964 totaldigits = c = 0;
78965 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
78966 {
78967 if (!access_ok(VERIFY_READ, ubuf, ulen))
78968 return -EFAULT;
78969 - return __bitmap_parselist((const char __force *)ubuf,
78970 + return __bitmap_parselist((const char __force_kernel *)ubuf,
78971 ulen, 1, maskp, nmaskbits);
78972 }
78973 EXPORT_SYMBOL(bitmap_parselist_user);
78974 diff --git a/lib/bug.c b/lib/bug.c
78975 index 1686034..a9c00c8 100644
78976 --- a/lib/bug.c
78977 +++ b/lib/bug.c
78978 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
78979 return BUG_TRAP_TYPE_NONE;
78980
78981 bug = find_bug(bugaddr);
78982 + if (!bug)
78983 + return BUG_TRAP_TYPE_NONE;
78984
78985 file = NULL;
78986 line = 0;
78987 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
78988 index 37061ed..da83f48 100644
78989 --- a/lib/debugobjects.c
78990 +++ b/lib/debugobjects.c
78991 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
78992 if (limit > 4)
78993 return;
78994
78995 - is_on_stack = object_is_on_stack(addr);
78996 + is_on_stack = object_starts_on_stack(addr);
78997 if (is_on_stack == onstack)
78998 return;
78999
79000 diff --git a/lib/devres.c b/lib/devres.c
79001 index 8235331..5881053 100644
79002 --- a/lib/devres.c
79003 +++ b/lib/devres.c
79004 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
79005 void devm_iounmap(struct device *dev, void __iomem *addr)
79006 {
79007 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
79008 - (void *)addr));
79009 + (void __force *)addr));
79010 iounmap(addr);
79011 }
79012 EXPORT_SYMBOL(devm_iounmap);
79013 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
79014 {
79015 ioport_unmap(addr);
79016 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
79017 - devm_ioport_map_match, (void *)addr));
79018 + devm_ioport_map_match, (void __force *)addr));
79019 }
79020 EXPORT_SYMBOL(devm_ioport_unmap);
79021 #endif /* CONFIG_HAS_IOPORT */
79022 diff --git a/lib/div64.c b/lib/div64.c
79023 index a163b6c..9618fa5 100644
79024 --- a/lib/div64.c
79025 +++ b/lib/div64.c
79026 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
79027 EXPORT_SYMBOL(__div64_32);
79028
79029 #ifndef div_s64_rem
79030 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
79031 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
79032 {
79033 u64 quotient;
79034
79035 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
79036 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
79037 */
79038 #ifndef div64_u64
79039 -u64 div64_u64(u64 dividend, u64 divisor)
79040 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
79041 {
79042 u32 high = divisor >> 32;
79043 u64 quot;
79044 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
79045 index d87a17a..ac0d79a 100644
79046 --- a/lib/dma-debug.c
79047 +++ b/lib/dma-debug.c
79048 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
79049
79050 void dma_debug_add_bus(struct bus_type *bus)
79051 {
79052 - struct notifier_block *nb;
79053 + notifier_block_no_const *nb;
79054
79055 if (global_disable)
79056 return;
79057 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
79058
79059 static void check_for_stack(struct device *dev, void *addr)
79060 {
79061 - if (object_is_on_stack(addr))
79062 + if (object_starts_on_stack(addr))
79063 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
79064 "stack [addr=%p]\n", addr);
79065 }
79066 diff --git a/lib/inflate.c b/lib/inflate.c
79067 index 013a761..c28f3fc 100644
79068 --- a/lib/inflate.c
79069 +++ b/lib/inflate.c
79070 @@ -269,7 +269,7 @@ static void free(void *where)
79071 malloc_ptr = free_mem_ptr;
79072 }
79073 #else
79074 -#define malloc(a) kmalloc(a, GFP_KERNEL)
79075 +#define malloc(a) kmalloc((a), GFP_KERNEL)
79076 #define free(a) kfree(a)
79077 #endif
79078
79079 diff --git a/lib/ioremap.c b/lib/ioremap.c
79080 index 0c9216c..863bd89 100644
79081 --- a/lib/ioremap.c
79082 +++ b/lib/ioremap.c
79083 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
79084 unsigned long next;
79085
79086 phys_addr -= addr;
79087 - pmd = pmd_alloc(&init_mm, pud, addr);
79088 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
79089 if (!pmd)
79090 return -ENOMEM;
79091 do {
79092 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
79093 unsigned long next;
79094
79095 phys_addr -= addr;
79096 - pud = pud_alloc(&init_mm, pgd, addr);
79097 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
79098 if (!pud)
79099 return -ENOMEM;
79100 do {
79101 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
79102 index bd2bea9..6b3c95e 100644
79103 --- a/lib/is_single_threaded.c
79104 +++ b/lib/is_single_threaded.c
79105 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
79106 struct task_struct *p, *t;
79107 bool ret;
79108
79109 + if (!mm)
79110 + return true;
79111 +
79112 if (atomic_read(&task->signal->live) != 1)
79113 return false;
79114
79115 diff --git a/lib/kobject.c b/lib/kobject.c
79116 index a654866..a4fd13d 100644
79117 --- a/lib/kobject.c
79118 +++ b/lib/kobject.c
79119 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
79120
79121
79122 static DEFINE_SPINLOCK(kobj_ns_type_lock);
79123 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
79124 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
79125
79126 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
79127 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
79128 {
79129 enum kobj_ns_type type = ops->type;
79130 int error;
79131 diff --git a/lib/list_debug.c b/lib/list_debug.c
79132 index c24c2f7..06e070b 100644
79133 --- a/lib/list_debug.c
79134 +++ b/lib/list_debug.c
79135 @@ -11,7 +11,9 @@
79136 #include <linux/bug.h>
79137 #include <linux/kernel.h>
79138 #include <linux/rculist.h>
79139 +#include <linux/mm.h>
79140
79141 +#ifdef CONFIG_DEBUG_LIST
79142 /*
79143 * Insert a new entry between two known consecutive entries.
79144 *
79145 @@ -19,21 +21,32 @@
79146 * the prev/next entries already!
79147 */
79148
79149 -void __list_add(struct list_head *new,
79150 - struct list_head *prev,
79151 - struct list_head *next)
79152 +static bool __list_add_debug(struct list_head *new,
79153 + struct list_head *prev,
79154 + struct list_head *next)
79155 {
79156 - WARN(next->prev != prev,
79157 + if (WARN(next->prev != prev,
79158 "list_add corruption. next->prev should be "
79159 "prev (%p), but was %p. (next=%p).\n",
79160 - prev, next->prev, next);
79161 - WARN(prev->next != next,
79162 + prev, next->prev, next) ||
79163 + WARN(prev->next != next,
79164 "list_add corruption. prev->next should be "
79165 "next (%p), but was %p. (prev=%p).\n",
79166 - next, prev->next, prev);
79167 - WARN(new == prev || new == next,
79168 - "list_add double add: new=%p, prev=%p, next=%p.\n",
79169 - new, prev, next);
79170 + next, prev->next, prev) ||
79171 + WARN(new == prev || new == next,
79172 + "list_add double add: new=%p, prev=%p, next=%p.\n",
79173 + new, prev, next))
79174 + return false;
79175 + return true;
79176 +}
79177 +
79178 +void __list_add(struct list_head *new,
79179 + struct list_head *prev,
79180 + struct list_head *next)
79181 +{
79182 + if (!__list_add_debug(new, prev, next))
79183 + return;
79184 +
79185 next->prev = new;
79186 new->next = next;
79187 new->prev = prev;
79188 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
79189 }
79190 EXPORT_SYMBOL(__list_add);
79191
79192 -void __list_del_entry(struct list_head *entry)
79193 +static bool __list_del_entry_debug(struct list_head *entry)
79194 {
79195 struct list_head *prev, *next;
79196
79197 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
79198 WARN(next->prev != entry,
79199 "list_del corruption. next->prev should be %p, "
79200 "but was %p\n", entry, next->prev))
79201 + return false;
79202 + return true;
79203 +}
79204 +
79205 +void __list_del_entry(struct list_head *entry)
79206 +{
79207 + if (!__list_del_entry_debug(entry))
79208 return;
79209
79210 - __list_del(prev, next);
79211 + __list_del(entry->prev, entry->next);
79212 }
79213 EXPORT_SYMBOL(__list_del_entry);
79214
79215 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
79216 void __list_add_rcu(struct list_head *new,
79217 struct list_head *prev, struct list_head *next)
79218 {
79219 - WARN(next->prev != prev,
79220 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
79221 - prev, next->prev, next);
79222 - WARN(prev->next != next,
79223 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
79224 - next, prev->next, prev);
79225 + if (!__list_add_debug(new, prev, next))
79226 + return;
79227 +
79228 new->next = next;
79229 new->prev = prev;
79230 rcu_assign_pointer(list_next_rcu(prev), new);
79231 next->prev = new;
79232 }
79233 EXPORT_SYMBOL(__list_add_rcu);
79234 +#endif
79235 +
79236 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
79237 +{
79238 +#ifdef CONFIG_DEBUG_LIST
79239 + if (!__list_add_debug(new, prev, next))
79240 + return;
79241 +#endif
79242 +
79243 + pax_open_kernel();
79244 + next->prev = new;
79245 + new->next = next;
79246 + new->prev = prev;
79247 + prev->next = new;
79248 + pax_close_kernel();
79249 +}
79250 +EXPORT_SYMBOL(__pax_list_add);
79251 +
79252 +void pax_list_del(struct list_head *entry)
79253 +{
79254 +#ifdef CONFIG_DEBUG_LIST
79255 + if (!__list_del_entry_debug(entry))
79256 + return;
79257 +#endif
79258 +
79259 + pax_open_kernel();
79260 + __list_del(entry->prev, entry->next);
79261 + entry->next = LIST_POISON1;
79262 + entry->prev = LIST_POISON2;
79263 + pax_close_kernel();
79264 +}
79265 +EXPORT_SYMBOL(pax_list_del);
79266 +
79267 +void pax_list_del_init(struct list_head *entry)
79268 +{
79269 + pax_open_kernel();
79270 + __list_del(entry->prev, entry->next);
79271 + INIT_LIST_HEAD(entry);
79272 + pax_close_kernel();
79273 +}
79274 +EXPORT_SYMBOL(pax_list_del_init);
79275 +
79276 +void __pax_list_add_rcu(struct list_head *new,
79277 + struct list_head *prev, struct list_head *next)
79278 +{
79279 +#ifdef CONFIG_DEBUG_LIST
79280 + if (!__list_add_debug(new, prev, next))
79281 + return;
79282 +#endif
79283 +
79284 + pax_open_kernel();
79285 + new->next = next;
79286 + new->prev = prev;
79287 + rcu_assign_pointer(list_next_rcu(prev), new);
79288 + next->prev = new;
79289 + pax_close_kernel();
79290 +}
79291 +EXPORT_SYMBOL(__pax_list_add_rcu);
79292 +
79293 +void pax_list_del_rcu(struct list_head *entry)
79294 +{
79295 +#ifdef CONFIG_DEBUG_LIST
79296 + if (!__list_del_entry_debug(entry))
79297 + return;
79298 +#endif
79299 +
79300 + pax_open_kernel();
79301 + __list_del(entry->prev, entry->next);
79302 + entry->next = LIST_POISON1;
79303 + entry->prev = LIST_POISON2;
79304 + pax_close_kernel();
79305 +}
79306 +EXPORT_SYMBOL(pax_list_del_rcu);
79307 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
79308 index e796429..6e38f9f 100644
79309 --- a/lib/radix-tree.c
79310 +++ b/lib/radix-tree.c
79311 @@ -92,7 +92,7 @@ struct radix_tree_preload {
79312 int nr;
79313 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
79314 };
79315 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
79316 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
79317
79318 static inline void *ptr_to_indirect(void *ptr)
79319 {
79320 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
79321 index bb2b201..46abaf9 100644
79322 --- a/lib/strncpy_from_user.c
79323 +++ b/lib/strncpy_from_user.c
79324 @@ -21,7 +21,7 @@
79325 */
79326 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
79327 {
79328 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
79329 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
79330 long res = 0;
79331
79332 /*
79333 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
79334 index a28df52..3d55877 100644
79335 --- a/lib/strnlen_user.c
79336 +++ b/lib/strnlen_user.c
79337 @@ -26,7 +26,7 @@
79338 */
79339 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
79340 {
79341 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
79342 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
79343 long align, res = 0;
79344 unsigned long c;
79345
79346 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
79347 index d23762e..e21eab2 100644
79348 --- a/lib/swiotlb.c
79349 +++ b/lib/swiotlb.c
79350 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
79351
79352 void
79353 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
79354 - dma_addr_t dev_addr)
79355 + dma_addr_t dev_addr, struct dma_attrs *attrs)
79356 {
79357 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
79358
79359 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
79360 index 0d62fd7..b7bc911 100644
79361 --- a/lib/vsprintf.c
79362 +++ b/lib/vsprintf.c
79363 @@ -16,6 +16,9 @@
79364 * - scnprintf and vscnprintf
79365 */
79366
79367 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79368 +#define __INCLUDED_BY_HIDESYM 1
79369 +#endif
79370 #include <stdarg.h>
79371 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
79372 #include <linux/types.h>
79373 @@ -974,7 +977,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
79374 return number(buf, end, *(const netdev_features_t *)addr, spec);
79375 }
79376
79377 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79378 +int kptr_restrict __read_mostly = 2;
79379 +#else
79380 int kptr_restrict __read_mostly;
79381 +#endif
79382
79383 /*
79384 * Show a '%p' thing. A kernel extension is that the '%p' is followed
79385 @@ -988,6 +995,8 @@ int kptr_restrict __read_mostly;
79386 * - 'S' For symbolic direct pointers with offset
79387 * - 's' For symbolic direct pointers without offset
79388 * - 'B' For backtraced symbolic direct pointers with offset
79389 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
79390 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
79391 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
79392 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
79393 * - 'M' For a 6-byte MAC address, it prints the address in the
79394 @@ -1044,12 +1053,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
79395
79396 if (!ptr && *fmt != 'K') {
79397 /*
79398 - * Print (null) with the same width as a pointer so it makes
79399 + * Print (nil) with the same width as a pointer so it makes
79400 * tabular output look nice.
79401 */
79402 if (spec.field_width == -1)
79403 spec.field_width = default_width;
79404 - return string(buf, end, "(null)", spec);
79405 + return string(buf, end, "(nil)", spec);
79406 }
79407
79408 switch (*fmt) {
79409 @@ -1059,6 +1068,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
79410 /* Fallthrough */
79411 case 'S':
79412 case 's':
79413 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79414 + break;
79415 +#else
79416 + return symbol_string(buf, end, ptr, spec, *fmt);
79417 +#endif
79418 + case 'A':
79419 case 'B':
79420 return symbol_string(buf, end, ptr, spec, *fmt);
79421 case 'R':
79422 @@ -1099,6 +1114,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
79423 va_end(va);
79424 return buf;
79425 }
79426 + case 'P':
79427 + break;
79428 case 'K':
79429 /*
79430 * %pK cannot be used in IRQ context because its test
79431 @@ -1128,6 +1145,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
79432 return number(buf, end,
79433 (unsigned long long) *((phys_addr_t *)ptr), spec);
79434 }
79435 +
79436 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79437 + /* 'P' = approved pointers to copy to userland,
79438 + as in the /proc/kallsyms case, as we make it display nothing
79439 + for non-root users, and the real contents for root users
79440 + Also ignore 'K' pointers, since we force their NULLing for non-root users
79441 + above
79442 + */
79443 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
79444 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
79445 + dump_stack();
79446 + ptr = NULL;
79447 + }
79448 +#endif
79449 +
79450 spec.flags |= SMALL;
79451 if (spec.field_width == -1) {
79452 spec.field_width = default_width;
79453 @@ -1849,11 +1881,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
79454 typeof(type) value; \
79455 if (sizeof(type) == 8) { \
79456 args = PTR_ALIGN(args, sizeof(u32)); \
79457 - *(u32 *)&value = *(u32 *)args; \
79458 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
79459 + *(u32 *)&value = *(const u32 *)args; \
79460 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
79461 } else { \
79462 args = PTR_ALIGN(args, sizeof(type)); \
79463 - value = *(typeof(type) *)args; \
79464 + value = *(const typeof(type) *)args; \
79465 } \
79466 args += sizeof(type); \
79467 value; \
79468 @@ -1916,7 +1948,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
79469 case FORMAT_TYPE_STR: {
79470 const char *str_arg = args;
79471 args += strlen(str_arg) + 1;
79472 - str = string(str, end, (char *)str_arg, spec);
79473 + str = string(str, end, str_arg, spec);
79474 break;
79475 }
79476
79477 diff --git a/localversion-grsec b/localversion-grsec
79478 new file mode 100644
79479 index 0000000..7cd6065
79480 --- /dev/null
79481 +++ b/localversion-grsec
79482 @@ -0,0 +1 @@
79483 +-grsec
79484 diff --git a/mm/Kconfig b/mm/Kconfig
79485 index 3bea74f..e821c99 100644
79486 --- a/mm/Kconfig
79487 +++ b/mm/Kconfig
79488 @@ -311,10 +311,10 @@ config KSM
79489 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
79490
79491 config DEFAULT_MMAP_MIN_ADDR
79492 - int "Low address space to protect from user allocation"
79493 + int "Low address space to protect from user allocation"
79494 depends on MMU
79495 - default 4096
79496 - help
79497 + default 65536
79498 + help
79499 This is the portion of low virtual memory which should be protected
79500 from userspace allocation. Keeping a user from writing to low pages
79501 can help reduce the impact of kernel NULL pointer bugs.
79502 @@ -345,7 +345,7 @@ config MEMORY_FAILURE
79503
79504 config HWPOISON_INJECT
79505 tristate "HWPoison pages injector"
79506 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
79507 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
79508 select PROC_PAGE_MONITOR
79509
79510 config NOMMU_INITIAL_TRIM_EXCESS
79511 diff --git a/mm/filemap.c b/mm/filemap.c
79512 index e1979fd..dda5120 100644
79513 --- a/mm/filemap.c
79514 +++ b/mm/filemap.c
79515 @@ -1748,7 +1748,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
79516 struct address_space *mapping = file->f_mapping;
79517
79518 if (!mapping->a_ops->readpage)
79519 - return -ENOEXEC;
79520 + return -ENODEV;
79521 file_accessed(file);
79522 vma->vm_ops = &generic_file_vm_ops;
79523 return 0;
79524 @@ -2088,6 +2088,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
79525 *pos = i_size_read(inode);
79526
79527 if (limit != RLIM_INFINITY) {
79528 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
79529 if (*pos >= limit) {
79530 send_sig(SIGXFSZ, current, 0);
79531 return -EFBIG;
79532 diff --git a/mm/fremap.c b/mm/fremap.c
79533 index 87da359..3f41cb1 100644
79534 --- a/mm/fremap.c
79535 +++ b/mm/fremap.c
79536 @@ -158,6 +158,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
79537 retry:
79538 vma = find_vma(mm, start);
79539
79540 +#ifdef CONFIG_PAX_SEGMEXEC
79541 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
79542 + goto out;
79543 +#endif
79544 +
79545 /*
79546 * Make sure the vma is shared, that it supports prefaulting,
79547 * and that the remapped range is valid and fully within
79548 diff --git a/mm/highmem.c b/mm/highmem.c
79549 index b32b70c..e512eb0 100644
79550 --- a/mm/highmem.c
79551 +++ b/mm/highmem.c
79552 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
79553 * So no dangers, even with speculative execution.
79554 */
79555 page = pte_page(pkmap_page_table[i]);
79556 + pax_open_kernel();
79557 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
79558 -
79559 + pax_close_kernel();
79560 set_page_address(page, NULL);
79561 need_flush = 1;
79562 }
79563 @@ -198,9 +199,11 @@ start:
79564 }
79565 }
79566 vaddr = PKMAP_ADDR(last_pkmap_nr);
79567 +
79568 + pax_open_kernel();
79569 set_pte_at(&init_mm, vaddr,
79570 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
79571 -
79572 + pax_close_kernel();
79573 pkmap_count[last_pkmap_nr] = 1;
79574 set_page_address(page, (void *)vaddr);
79575
79576 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
79577 index 1a12f5b..a85b8fc 100644
79578 --- a/mm/hugetlb.c
79579 +++ b/mm/hugetlb.c
79580 @@ -2005,15 +2005,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
79581 struct hstate *h = &default_hstate;
79582 unsigned long tmp;
79583 int ret;
79584 + ctl_table_no_const hugetlb_table;
79585
79586 tmp = h->max_huge_pages;
79587
79588 if (write && h->order >= MAX_ORDER)
79589 return -EINVAL;
79590
79591 - table->data = &tmp;
79592 - table->maxlen = sizeof(unsigned long);
79593 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
79594 + hugetlb_table = *table;
79595 + hugetlb_table.data = &tmp;
79596 + hugetlb_table.maxlen = sizeof(unsigned long);
79597 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
79598 if (ret)
79599 goto out;
79600
79601 @@ -2070,15 +2072,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
79602 struct hstate *h = &default_hstate;
79603 unsigned long tmp;
79604 int ret;
79605 + ctl_table_no_const hugetlb_table;
79606
79607 tmp = h->nr_overcommit_huge_pages;
79608
79609 if (write && h->order >= MAX_ORDER)
79610 return -EINVAL;
79611
79612 - table->data = &tmp;
79613 - table->maxlen = sizeof(unsigned long);
79614 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
79615 + hugetlb_table = *table;
79616 + hugetlb_table.data = &tmp;
79617 + hugetlb_table.maxlen = sizeof(unsigned long);
79618 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
79619 if (ret)
79620 goto out;
79621
79622 @@ -2512,6 +2516,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
79623 return 1;
79624 }
79625
79626 +#ifdef CONFIG_PAX_SEGMEXEC
79627 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
79628 +{
79629 + struct mm_struct *mm = vma->vm_mm;
79630 + struct vm_area_struct *vma_m;
79631 + unsigned long address_m;
79632 + pte_t *ptep_m;
79633 +
79634 + vma_m = pax_find_mirror_vma(vma);
79635 + if (!vma_m)
79636 + return;
79637 +
79638 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
79639 + address_m = address + SEGMEXEC_TASK_SIZE;
79640 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
79641 + get_page(page_m);
79642 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
79643 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
79644 +}
79645 +#endif
79646 +
79647 /*
79648 * Hugetlb_cow() should be called with page lock of the original hugepage held.
79649 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
79650 @@ -2630,6 +2655,11 @@ retry_avoidcopy:
79651 make_huge_pte(vma, new_page, 1));
79652 page_remove_rmap(old_page);
79653 hugepage_add_new_anon_rmap(new_page, vma, address);
79654 +
79655 +#ifdef CONFIG_PAX_SEGMEXEC
79656 + pax_mirror_huge_pte(vma, address, new_page);
79657 +#endif
79658 +
79659 /* Make the old page be freed below */
79660 new_page = old_page;
79661 }
79662 @@ -2788,6 +2818,10 @@ retry:
79663 && (vma->vm_flags & VM_SHARED)));
79664 set_huge_pte_at(mm, address, ptep, new_pte);
79665
79666 +#ifdef CONFIG_PAX_SEGMEXEC
79667 + pax_mirror_huge_pte(vma, address, page);
79668 +#endif
79669 +
79670 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
79671 /* Optimization, do the COW without a second fault */
79672 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
79673 @@ -2817,6 +2851,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
79674 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
79675 struct hstate *h = hstate_vma(vma);
79676
79677 +#ifdef CONFIG_PAX_SEGMEXEC
79678 + struct vm_area_struct *vma_m;
79679 +#endif
79680 +
79681 address &= huge_page_mask(h);
79682
79683 ptep = huge_pte_offset(mm, address);
79684 @@ -2830,6 +2868,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
79685 VM_FAULT_SET_HINDEX(hstate_index(h));
79686 }
79687
79688 +#ifdef CONFIG_PAX_SEGMEXEC
79689 + vma_m = pax_find_mirror_vma(vma);
79690 + if (vma_m) {
79691 + unsigned long address_m;
79692 +
79693 + if (vma->vm_start > vma_m->vm_start) {
79694 + address_m = address;
79695 + address -= SEGMEXEC_TASK_SIZE;
79696 + vma = vma_m;
79697 + h = hstate_vma(vma);
79698 + } else
79699 + address_m = address + SEGMEXEC_TASK_SIZE;
79700 +
79701 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
79702 + return VM_FAULT_OOM;
79703 + address_m &= HPAGE_MASK;
79704 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
79705 + }
79706 +#endif
79707 +
79708 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
79709 if (!ptep)
79710 return VM_FAULT_OOM;
79711 diff --git a/mm/internal.h b/mm/internal.h
79712 index 8562de0..7fdfe92 100644
79713 --- a/mm/internal.h
79714 +++ b/mm/internal.h
79715 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
79716 * in mm/page_alloc.c
79717 */
79718 extern void __free_pages_bootmem(struct page *page, unsigned int order);
79719 +extern void free_compound_page(struct page *page);
79720 extern void prep_compound_page(struct page *page, unsigned long order);
79721 #ifdef CONFIG_MEMORY_FAILURE
79722 extern bool is_free_buddy_page(struct page *page);
79723 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
79724 index c8d7f31..2dbeffd 100644
79725 --- a/mm/kmemleak.c
79726 +++ b/mm/kmemleak.c
79727 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
79728
79729 for (i = 0; i < object->trace_len; i++) {
79730 void *ptr = (void *)object->trace[i];
79731 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
79732 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
79733 }
79734 }
79735
79736 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
79737 return -ENOMEM;
79738 }
79739
79740 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
79741 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
79742 &kmemleak_fops);
79743 if (!dentry)
79744 pr_warning("Failed to create the debugfs kmemleak file\n");
79745 diff --git a/mm/maccess.c b/mm/maccess.c
79746 index d53adf9..03a24bf 100644
79747 --- a/mm/maccess.c
79748 +++ b/mm/maccess.c
79749 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
79750 set_fs(KERNEL_DS);
79751 pagefault_disable();
79752 ret = __copy_from_user_inatomic(dst,
79753 - (__force const void __user *)src, size);
79754 + (const void __force_user *)src, size);
79755 pagefault_enable();
79756 set_fs(old_fs);
79757
79758 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
79759
79760 set_fs(KERNEL_DS);
79761 pagefault_disable();
79762 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
79763 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
79764 pagefault_enable();
79765 set_fs(old_fs);
79766
79767 diff --git a/mm/madvise.c b/mm/madvise.c
79768 index c58c94b..86ec14e 100644
79769 --- a/mm/madvise.c
79770 +++ b/mm/madvise.c
79771 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
79772 pgoff_t pgoff;
79773 unsigned long new_flags = vma->vm_flags;
79774
79775 +#ifdef CONFIG_PAX_SEGMEXEC
79776 + struct vm_area_struct *vma_m;
79777 +#endif
79778 +
79779 switch (behavior) {
79780 case MADV_NORMAL:
79781 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
79782 @@ -126,6 +130,13 @@ success:
79783 /*
79784 * vm_flags is protected by the mmap_sem held in write mode.
79785 */
79786 +
79787 +#ifdef CONFIG_PAX_SEGMEXEC
79788 + vma_m = pax_find_mirror_vma(vma);
79789 + if (vma_m)
79790 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
79791 +#endif
79792 +
79793 vma->vm_flags = new_flags;
79794
79795 out:
79796 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
79797 struct vm_area_struct ** prev,
79798 unsigned long start, unsigned long end)
79799 {
79800 +
79801 +#ifdef CONFIG_PAX_SEGMEXEC
79802 + struct vm_area_struct *vma_m;
79803 +#endif
79804 +
79805 *prev = vma;
79806 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
79807 return -EINVAL;
79808 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
79809 zap_page_range(vma, start, end - start, &details);
79810 } else
79811 zap_page_range(vma, start, end - start, NULL);
79812 +
79813 +#ifdef CONFIG_PAX_SEGMEXEC
79814 + vma_m = pax_find_mirror_vma(vma);
79815 + if (vma_m) {
79816 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
79817 + struct zap_details details = {
79818 + .nonlinear_vma = vma_m,
79819 + .last_index = ULONG_MAX,
79820 + };
79821 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
79822 + } else
79823 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
79824 + }
79825 +#endif
79826 +
79827 return 0;
79828 }
79829
79830 @@ -491,6 +522,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
79831 if (end < start)
79832 goto out;
79833
79834 +#ifdef CONFIG_PAX_SEGMEXEC
79835 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
79836 + if (end > SEGMEXEC_TASK_SIZE)
79837 + goto out;
79838 + } else
79839 +#endif
79840 +
79841 + if (end > TASK_SIZE)
79842 + goto out;
79843 +
79844 error = 0;
79845 if (end == start)
79846 goto out;
79847 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
79848 index df0694c..bc95539 100644
79849 --- a/mm/memory-failure.c
79850 +++ b/mm/memory-failure.c
79851 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
79852
79853 int sysctl_memory_failure_recovery __read_mostly = 1;
79854
79855 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
79856 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
79857
79858 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
79859
79860 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
79861 pfn, t->comm, t->pid);
79862 si.si_signo = SIGBUS;
79863 si.si_errno = 0;
79864 - si.si_addr = (void *)addr;
79865 + si.si_addr = (void __user *)addr;
79866 #ifdef __ARCH_SI_TRAPNO
79867 si.si_trapno = trapno;
79868 #endif
79869 @@ -760,7 +760,7 @@ static struct page_state {
79870 unsigned long res;
79871 char *msg;
79872 int (*action)(struct page *p, unsigned long pfn);
79873 -} error_states[] = {
79874 +} __do_const error_states[] = {
79875 { reserved, reserved, "reserved kernel", me_kernel },
79876 /*
79877 * free pages are specially detected outside this table:
79878 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
79879 nr_pages = 1 << compound_order(hpage);
79880 else /* normal page or thp */
79881 nr_pages = 1;
79882 - atomic_long_add(nr_pages, &num_poisoned_pages);
79883 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
79884
79885 /*
79886 * We need/can do nothing about count=0 pages.
79887 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
79888 if (!PageHWPoison(hpage)
79889 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
79890 || (p != hpage && TestSetPageHWPoison(hpage))) {
79891 - atomic_long_sub(nr_pages, &num_poisoned_pages);
79892 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
79893 return 0;
79894 }
79895 set_page_hwpoison_huge_page(hpage);
79896 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
79897 }
79898 if (hwpoison_filter(p)) {
79899 if (TestClearPageHWPoison(p))
79900 - atomic_long_sub(nr_pages, &num_poisoned_pages);
79901 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
79902 unlock_page(hpage);
79903 put_page(hpage);
79904 return 0;
79905 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
79906 return 0;
79907 }
79908 if (TestClearPageHWPoison(p))
79909 - atomic_long_sub(nr_pages, &num_poisoned_pages);
79910 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
79911 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
79912 return 0;
79913 }
79914 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
79915 */
79916 if (TestClearPageHWPoison(page)) {
79917 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
79918 - atomic_long_sub(nr_pages, &num_poisoned_pages);
79919 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
79920 freeit = 1;
79921 if (PageHuge(page))
79922 clear_page_hwpoison_huge_page(page);
79923 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
79924 } else {
79925 set_page_hwpoison_huge_page(hpage);
79926 dequeue_hwpoisoned_huge_page(hpage);
79927 - atomic_long_add(1 << compound_trans_order(hpage),
79928 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
79929 &num_poisoned_pages);
79930 }
79931 /* keep elevated page count for bad page */
79932 @@ -1552,11 +1552,11 @@ int soft_offline_page(struct page *page, int flags)
79933 if (PageHuge(page)) {
79934 set_page_hwpoison_huge_page(hpage);
79935 dequeue_hwpoisoned_huge_page(hpage);
79936 - atomic_long_add(1 << compound_trans_order(hpage),
79937 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
79938 &num_poisoned_pages);
79939 } else {
79940 SetPageHWPoison(page);
79941 - atomic_long_inc(&num_poisoned_pages);
79942 + atomic_long_inc_unchecked(&num_poisoned_pages);
79943 }
79944 }
79945 /* keep elevated page count for bad page */
79946 @@ -1596,7 +1596,7 @@ static int __soft_offline_page(struct page *page, int flags)
79947 put_page(page);
79948 pr_info("soft_offline: %#lx: invalidated\n", pfn);
79949 SetPageHWPoison(page);
79950 - atomic_long_inc(&num_poisoned_pages);
79951 + atomic_long_inc_unchecked(&num_poisoned_pages);
79952 return 0;
79953 }
79954
79955 @@ -1626,7 +1626,7 @@ static int __soft_offline_page(struct page *page, int flags)
79956 ret = -EIO;
79957 } else {
79958 SetPageHWPoison(page);
79959 - atomic_long_inc(&num_poisoned_pages);
79960 + atomic_long_inc_unchecked(&num_poisoned_pages);
79961 }
79962 } else {
79963 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
79964 diff --git a/mm/memory.c b/mm/memory.c
79965 index ba94dec..08ffe0d 100644
79966 --- a/mm/memory.c
79967 +++ b/mm/memory.c
79968 @@ -438,6 +438,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
79969 free_pte_range(tlb, pmd, addr);
79970 } while (pmd++, addr = next, addr != end);
79971
79972 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
79973 start &= PUD_MASK;
79974 if (start < floor)
79975 return;
79976 @@ -452,6 +453,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
79977 pmd = pmd_offset(pud, start);
79978 pud_clear(pud);
79979 pmd_free_tlb(tlb, pmd, start);
79980 +#endif
79981 +
79982 }
79983
79984 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
79985 @@ -471,6 +474,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
79986 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
79987 } while (pud++, addr = next, addr != end);
79988
79989 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
79990 start &= PGDIR_MASK;
79991 if (start < floor)
79992 return;
79993 @@ -485,6 +489,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
79994 pud = pud_offset(pgd, start);
79995 pgd_clear(pgd);
79996 pud_free_tlb(tlb, pud, start);
79997 +#endif
79998 +
79999 }
80000
80001 /*
80002 @@ -1644,12 +1650,6 @@ no_page_table:
80003 return page;
80004 }
80005
80006 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
80007 -{
80008 - return stack_guard_page_start(vma, addr) ||
80009 - stack_guard_page_end(vma, addr+PAGE_SIZE);
80010 -}
80011 -
80012 /**
80013 * __get_user_pages() - pin user pages in memory
80014 * @tsk: task_struct of target task
80015 @@ -1736,10 +1736,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80016
80017 i = 0;
80018
80019 - do {
80020 + while (nr_pages) {
80021 struct vm_area_struct *vma;
80022
80023 - vma = find_extend_vma(mm, start);
80024 + vma = find_vma(mm, start);
80025 if (!vma && in_gate_area(mm, start)) {
80026 unsigned long pg = start & PAGE_MASK;
80027 pgd_t *pgd;
80028 @@ -1788,7 +1788,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80029 goto next_page;
80030 }
80031
80032 - if (!vma ||
80033 + if (!vma || start < vma->vm_start ||
80034 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
80035 !(vm_flags & vma->vm_flags))
80036 return i ? : -EFAULT;
80037 @@ -1817,11 +1817,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
80038 int ret;
80039 unsigned int fault_flags = 0;
80040
80041 - /* For mlock, just skip the stack guard page. */
80042 - if (foll_flags & FOLL_MLOCK) {
80043 - if (stack_guard_page(vma, start))
80044 - goto next_page;
80045 - }
80046 if (foll_flags & FOLL_WRITE)
80047 fault_flags |= FAULT_FLAG_WRITE;
80048 if (nonblocking)
80049 @@ -1901,7 +1896,7 @@ next_page:
80050 start += page_increm * PAGE_SIZE;
80051 nr_pages -= page_increm;
80052 } while (nr_pages && start < vma->vm_end);
80053 - } while (nr_pages);
80054 + }
80055 return i;
80056 }
80057 EXPORT_SYMBOL(__get_user_pages);
80058 @@ -2108,6 +2103,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
80059 page_add_file_rmap(page);
80060 set_pte_at(mm, addr, pte, mk_pte(page, prot));
80061
80062 +#ifdef CONFIG_PAX_SEGMEXEC
80063 + pax_mirror_file_pte(vma, addr, page, ptl);
80064 +#endif
80065 +
80066 retval = 0;
80067 pte_unmap_unlock(pte, ptl);
80068 return retval;
80069 @@ -2152,9 +2151,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
80070 if (!page_count(page))
80071 return -EINVAL;
80072 if (!(vma->vm_flags & VM_MIXEDMAP)) {
80073 +
80074 +#ifdef CONFIG_PAX_SEGMEXEC
80075 + struct vm_area_struct *vma_m;
80076 +#endif
80077 +
80078 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
80079 BUG_ON(vma->vm_flags & VM_PFNMAP);
80080 vma->vm_flags |= VM_MIXEDMAP;
80081 +
80082 +#ifdef CONFIG_PAX_SEGMEXEC
80083 + vma_m = pax_find_mirror_vma(vma);
80084 + if (vma_m)
80085 + vma_m->vm_flags |= VM_MIXEDMAP;
80086 +#endif
80087 +
80088 }
80089 return insert_page(vma, addr, page, vma->vm_page_prot);
80090 }
80091 @@ -2237,6 +2248,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
80092 unsigned long pfn)
80093 {
80094 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
80095 + BUG_ON(vma->vm_mirror);
80096
80097 if (addr < vma->vm_start || addr >= vma->vm_end)
80098 return -EFAULT;
80099 @@ -2484,7 +2496,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
80100
80101 BUG_ON(pud_huge(*pud));
80102
80103 - pmd = pmd_alloc(mm, pud, addr);
80104 + pmd = (mm == &init_mm) ?
80105 + pmd_alloc_kernel(mm, pud, addr) :
80106 + pmd_alloc(mm, pud, addr);
80107 if (!pmd)
80108 return -ENOMEM;
80109 do {
80110 @@ -2504,7 +2518,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
80111 unsigned long next;
80112 int err;
80113
80114 - pud = pud_alloc(mm, pgd, addr);
80115 + pud = (mm == &init_mm) ?
80116 + pud_alloc_kernel(mm, pgd, addr) :
80117 + pud_alloc(mm, pgd, addr);
80118 if (!pud)
80119 return -ENOMEM;
80120 do {
80121 @@ -2592,6 +2608,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
80122 copy_user_highpage(dst, src, va, vma);
80123 }
80124
80125 +#ifdef CONFIG_PAX_SEGMEXEC
80126 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
80127 +{
80128 + struct mm_struct *mm = vma->vm_mm;
80129 + spinlock_t *ptl;
80130 + pte_t *pte, entry;
80131 +
80132 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
80133 + entry = *pte;
80134 + if (!pte_present(entry)) {
80135 + if (!pte_none(entry)) {
80136 + BUG_ON(pte_file(entry));
80137 + free_swap_and_cache(pte_to_swp_entry(entry));
80138 + pte_clear_not_present_full(mm, address, pte, 0);
80139 + }
80140 + } else {
80141 + struct page *page;
80142 +
80143 + flush_cache_page(vma, address, pte_pfn(entry));
80144 + entry = ptep_clear_flush(vma, address, pte);
80145 + BUG_ON(pte_dirty(entry));
80146 + page = vm_normal_page(vma, address, entry);
80147 + if (page) {
80148 + update_hiwater_rss(mm);
80149 + if (PageAnon(page))
80150 + dec_mm_counter_fast(mm, MM_ANONPAGES);
80151 + else
80152 + dec_mm_counter_fast(mm, MM_FILEPAGES);
80153 + page_remove_rmap(page);
80154 + page_cache_release(page);
80155 + }
80156 + }
80157 + pte_unmap_unlock(pte, ptl);
80158 +}
80159 +
80160 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
80161 + *
80162 + * the ptl of the lower mapped page is held on entry and is not released on exit
80163 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
80164 + */
80165 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
80166 +{
80167 + struct mm_struct *mm = vma->vm_mm;
80168 + unsigned long address_m;
80169 + spinlock_t *ptl_m;
80170 + struct vm_area_struct *vma_m;
80171 + pmd_t *pmd_m;
80172 + pte_t *pte_m, entry_m;
80173 +
80174 + BUG_ON(!page_m || !PageAnon(page_m));
80175 +
80176 + vma_m = pax_find_mirror_vma(vma);
80177 + if (!vma_m)
80178 + return;
80179 +
80180 + BUG_ON(!PageLocked(page_m));
80181 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80182 + address_m = address + SEGMEXEC_TASK_SIZE;
80183 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
80184 + pte_m = pte_offset_map(pmd_m, address_m);
80185 + ptl_m = pte_lockptr(mm, pmd_m);
80186 + if (ptl != ptl_m) {
80187 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
80188 + if (!pte_none(*pte_m))
80189 + goto out;
80190 + }
80191 +
80192 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
80193 + page_cache_get(page_m);
80194 + page_add_anon_rmap(page_m, vma_m, address_m);
80195 + inc_mm_counter_fast(mm, MM_ANONPAGES);
80196 + set_pte_at(mm, address_m, pte_m, entry_m);
80197 + update_mmu_cache(vma_m, address_m, pte_m);
80198 +out:
80199 + if (ptl != ptl_m)
80200 + spin_unlock(ptl_m);
80201 + pte_unmap(pte_m);
80202 + unlock_page(page_m);
80203 +}
80204 +
80205 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
80206 +{
80207 + struct mm_struct *mm = vma->vm_mm;
80208 + unsigned long address_m;
80209 + spinlock_t *ptl_m;
80210 + struct vm_area_struct *vma_m;
80211 + pmd_t *pmd_m;
80212 + pte_t *pte_m, entry_m;
80213 +
80214 + BUG_ON(!page_m || PageAnon(page_m));
80215 +
80216 + vma_m = pax_find_mirror_vma(vma);
80217 + if (!vma_m)
80218 + return;
80219 +
80220 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80221 + address_m = address + SEGMEXEC_TASK_SIZE;
80222 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
80223 + pte_m = pte_offset_map(pmd_m, address_m);
80224 + ptl_m = pte_lockptr(mm, pmd_m);
80225 + if (ptl != ptl_m) {
80226 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
80227 + if (!pte_none(*pte_m))
80228 + goto out;
80229 + }
80230 +
80231 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
80232 + page_cache_get(page_m);
80233 + page_add_file_rmap(page_m);
80234 + inc_mm_counter_fast(mm, MM_FILEPAGES);
80235 + set_pte_at(mm, address_m, pte_m, entry_m);
80236 + update_mmu_cache(vma_m, address_m, pte_m);
80237 +out:
80238 + if (ptl != ptl_m)
80239 + spin_unlock(ptl_m);
80240 + pte_unmap(pte_m);
80241 +}
80242 +
80243 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
80244 +{
80245 + struct mm_struct *mm = vma->vm_mm;
80246 + unsigned long address_m;
80247 + spinlock_t *ptl_m;
80248 + struct vm_area_struct *vma_m;
80249 + pmd_t *pmd_m;
80250 + pte_t *pte_m, entry_m;
80251 +
80252 + vma_m = pax_find_mirror_vma(vma);
80253 + if (!vma_m)
80254 + return;
80255 +
80256 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80257 + address_m = address + SEGMEXEC_TASK_SIZE;
80258 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
80259 + pte_m = pte_offset_map(pmd_m, address_m);
80260 + ptl_m = pte_lockptr(mm, pmd_m);
80261 + if (ptl != ptl_m) {
80262 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
80263 + if (!pte_none(*pte_m))
80264 + goto out;
80265 + }
80266 +
80267 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
80268 + set_pte_at(mm, address_m, pte_m, entry_m);
80269 +out:
80270 + if (ptl != ptl_m)
80271 + spin_unlock(ptl_m);
80272 + pte_unmap(pte_m);
80273 +}
80274 +
80275 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
80276 +{
80277 + struct page *page_m;
80278 + pte_t entry;
80279 +
80280 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
80281 + goto out;
80282 +
80283 + entry = *pte;
80284 + page_m = vm_normal_page(vma, address, entry);
80285 + if (!page_m)
80286 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
80287 + else if (PageAnon(page_m)) {
80288 + if (pax_find_mirror_vma(vma)) {
80289 + pte_unmap_unlock(pte, ptl);
80290 + lock_page(page_m);
80291 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
80292 + if (pte_same(entry, *pte))
80293 + pax_mirror_anon_pte(vma, address, page_m, ptl);
80294 + else
80295 + unlock_page(page_m);
80296 + }
80297 + } else
80298 + pax_mirror_file_pte(vma, address, page_m, ptl);
80299 +
80300 +out:
80301 + pte_unmap_unlock(pte, ptl);
80302 +}
80303 +#endif
80304 +
80305 /*
80306 * This routine handles present pages, when users try to write
80307 * to a shared page. It is done by copying the page to a new address
80308 @@ -2808,6 +3004,12 @@ gotten:
80309 */
80310 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
80311 if (likely(pte_same(*page_table, orig_pte))) {
80312 +
80313 +#ifdef CONFIG_PAX_SEGMEXEC
80314 + if (pax_find_mirror_vma(vma))
80315 + BUG_ON(!trylock_page(new_page));
80316 +#endif
80317 +
80318 if (old_page) {
80319 if (!PageAnon(old_page)) {
80320 dec_mm_counter_fast(mm, MM_FILEPAGES);
80321 @@ -2859,6 +3061,10 @@ gotten:
80322 page_remove_rmap(old_page);
80323 }
80324
80325 +#ifdef CONFIG_PAX_SEGMEXEC
80326 + pax_mirror_anon_pte(vma, address, new_page, ptl);
80327 +#endif
80328 +
80329 /* Free the old page.. */
80330 new_page = old_page;
80331 ret |= VM_FAULT_WRITE;
80332 @@ -3134,6 +3340,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
80333 swap_free(entry);
80334 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
80335 try_to_free_swap(page);
80336 +
80337 +#ifdef CONFIG_PAX_SEGMEXEC
80338 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
80339 +#endif
80340 +
80341 unlock_page(page);
80342 if (page != swapcache) {
80343 /*
80344 @@ -3157,6 +3368,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
80345
80346 /* No need to invalidate - it was non-present before */
80347 update_mmu_cache(vma, address, page_table);
80348 +
80349 +#ifdef CONFIG_PAX_SEGMEXEC
80350 + pax_mirror_anon_pte(vma, address, page, ptl);
80351 +#endif
80352 +
80353 unlock:
80354 pte_unmap_unlock(page_table, ptl);
80355 out:
80356 @@ -3176,40 +3392,6 @@ out_release:
80357 }
80358
80359 /*
80360 - * This is like a special single-page "expand_{down|up}wards()",
80361 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
80362 - * doesn't hit another vma.
80363 - */
80364 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
80365 -{
80366 - address &= PAGE_MASK;
80367 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
80368 - struct vm_area_struct *prev = vma->vm_prev;
80369 -
80370 - /*
80371 - * Is there a mapping abutting this one below?
80372 - *
80373 - * That's only ok if it's the same stack mapping
80374 - * that has gotten split..
80375 - */
80376 - if (prev && prev->vm_end == address)
80377 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
80378 -
80379 - expand_downwards(vma, address - PAGE_SIZE);
80380 - }
80381 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
80382 - struct vm_area_struct *next = vma->vm_next;
80383 -
80384 - /* As VM_GROWSDOWN but s/below/above/ */
80385 - if (next && next->vm_start == address + PAGE_SIZE)
80386 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
80387 -
80388 - expand_upwards(vma, address + PAGE_SIZE);
80389 - }
80390 - return 0;
80391 -}
80392 -
80393 -/*
80394 * We enter with non-exclusive mmap_sem (to exclude vma changes,
80395 * but allow concurrent faults), and pte mapped but not yet locked.
80396 * We return with mmap_sem still held, but pte unmapped and unlocked.
80397 @@ -3218,27 +3400,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
80398 unsigned long address, pte_t *page_table, pmd_t *pmd,
80399 unsigned int flags)
80400 {
80401 - struct page *page;
80402 + struct page *page = NULL;
80403 spinlock_t *ptl;
80404 pte_t entry;
80405
80406 - pte_unmap(page_table);
80407 -
80408 - /* Check if we need to add a guard page to the stack */
80409 - if (check_stack_guard_page(vma, address) < 0)
80410 - return VM_FAULT_SIGBUS;
80411 -
80412 - /* Use the zero-page for reads */
80413 if (!(flags & FAULT_FLAG_WRITE)) {
80414 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
80415 vma->vm_page_prot));
80416 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
80417 + ptl = pte_lockptr(mm, pmd);
80418 + spin_lock(ptl);
80419 if (!pte_none(*page_table))
80420 goto unlock;
80421 goto setpte;
80422 }
80423
80424 /* Allocate our own private page. */
80425 + pte_unmap(page_table);
80426 +
80427 if (unlikely(anon_vma_prepare(vma)))
80428 goto oom;
80429 page = alloc_zeroed_user_highpage_movable(vma, address);
80430 @@ -3257,6 +3435,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
80431 if (!pte_none(*page_table))
80432 goto release;
80433
80434 +#ifdef CONFIG_PAX_SEGMEXEC
80435 + if (pax_find_mirror_vma(vma))
80436 + BUG_ON(!trylock_page(page));
80437 +#endif
80438 +
80439 inc_mm_counter_fast(mm, MM_ANONPAGES);
80440 page_add_new_anon_rmap(page, vma, address);
80441 setpte:
80442 @@ -3264,6 +3447,12 @@ setpte:
80443
80444 /* No need to invalidate - it was non-present before */
80445 update_mmu_cache(vma, address, page_table);
80446 +
80447 +#ifdef CONFIG_PAX_SEGMEXEC
80448 + if (page)
80449 + pax_mirror_anon_pte(vma, address, page, ptl);
80450 +#endif
80451 +
80452 unlock:
80453 pte_unmap_unlock(page_table, ptl);
80454 return 0;
80455 @@ -3407,6 +3596,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80456 */
80457 /* Only go through if we didn't race with anybody else... */
80458 if (likely(pte_same(*page_table, orig_pte))) {
80459 +
80460 +#ifdef CONFIG_PAX_SEGMEXEC
80461 + if (anon && pax_find_mirror_vma(vma))
80462 + BUG_ON(!trylock_page(page));
80463 +#endif
80464 +
80465 flush_icache_page(vma, page);
80466 entry = mk_pte(page, vma->vm_page_prot);
80467 if (flags & FAULT_FLAG_WRITE)
80468 @@ -3426,6 +3621,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80469
80470 /* no need to invalidate: a not-present page won't be cached */
80471 update_mmu_cache(vma, address, page_table);
80472 +
80473 +#ifdef CONFIG_PAX_SEGMEXEC
80474 + if (anon)
80475 + pax_mirror_anon_pte(vma, address, page, ptl);
80476 + else
80477 + pax_mirror_file_pte(vma, address, page, ptl);
80478 +#endif
80479 +
80480 } else {
80481 if (cow_page)
80482 mem_cgroup_uncharge_page(cow_page);
80483 @@ -3747,6 +3950,12 @@ int handle_pte_fault(struct mm_struct *mm,
80484 if (flags & FAULT_FLAG_WRITE)
80485 flush_tlb_fix_spurious_fault(vma, address);
80486 }
80487 +
80488 +#ifdef CONFIG_PAX_SEGMEXEC
80489 + pax_mirror_pte(vma, address, pte, pmd, ptl);
80490 + return 0;
80491 +#endif
80492 +
80493 unlock:
80494 pte_unmap_unlock(pte, ptl);
80495 return 0;
80496 @@ -3763,6 +3972,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80497 pmd_t *pmd;
80498 pte_t *pte;
80499
80500 +#ifdef CONFIG_PAX_SEGMEXEC
80501 + struct vm_area_struct *vma_m;
80502 +#endif
80503 +
80504 __set_current_state(TASK_RUNNING);
80505
80506 count_vm_event(PGFAULT);
80507 @@ -3774,6 +3987,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80508 if (unlikely(is_vm_hugetlb_page(vma)))
80509 return hugetlb_fault(mm, vma, address, flags);
80510
80511 +#ifdef CONFIG_PAX_SEGMEXEC
80512 + vma_m = pax_find_mirror_vma(vma);
80513 + if (vma_m) {
80514 + unsigned long address_m;
80515 + pgd_t *pgd_m;
80516 + pud_t *pud_m;
80517 + pmd_t *pmd_m;
80518 +
80519 + if (vma->vm_start > vma_m->vm_start) {
80520 + address_m = address;
80521 + address -= SEGMEXEC_TASK_SIZE;
80522 + vma = vma_m;
80523 + } else
80524 + address_m = address + SEGMEXEC_TASK_SIZE;
80525 +
80526 + pgd_m = pgd_offset(mm, address_m);
80527 + pud_m = pud_alloc(mm, pgd_m, address_m);
80528 + if (!pud_m)
80529 + return VM_FAULT_OOM;
80530 + pmd_m = pmd_alloc(mm, pud_m, address_m);
80531 + if (!pmd_m)
80532 + return VM_FAULT_OOM;
80533 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
80534 + return VM_FAULT_OOM;
80535 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
80536 + }
80537 +#endif
80538 +
80539 retry:
80540 pgd = pgd_offset(mm, address);
80541 pud = pud_alloc(mm, pgd, address);
80542 @@ -3872,6 +4113,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
80543 spin_unlock(&mm->page_table_lock);
80544 return 0;
80545 }
80546 +
80547 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
80548 +{
80549 + pud_t *new = pud_alloc_one(mm, address);
80550 + if (!new)
80551 + return -ENOMEM;
80552 +
80553 + smp_wmb(); /* See comment in __pte_alloc */
80554 +
80555 + spin_lock(&mm->page_table_lock);
80556 + if (pgd_present(*pgd)) /* Another has populated it */
80557 + pud_free(mm, new);
80558 + else
80559 + pgd_populate_kernel(mm, pgd, new);
80560 + spin_unlock(&mm->page_table_lock);
80561 + return 0;
80562 +}
80563 #endif /* __PAGETABLE_PUD_FOLDED */
80564
80565 #ifndef __PAGETABLE_PMD_FOLDED
80566 @@ -3902,6 +4160,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
80567 spin_unlock(&mm->page_table_lock);
80568 return 0;
80569 }
80570 +
80571 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
80572 +{
80573 + pmd_t *new = pmd_alloc_one(mm, address);
80574 + if (!new)
80575 + return -ENOMEM;
80576 +
80577 + smp_wmb(); /* See comment in __pte_alloc */
80578 +
80579 + spin_lock(&mm->page_table_lock);
80580 +#ifndef __ARCH_HAS_4LEVEL_HACK
80581 + if (pud_present(*pud)) /* Another has populated it */
80582 + pmd_free(mm, new);
80583 + else
80584 + pud_populate_kernel(mm, pud, new);
80585 +#else
80586 + if (pgd_present(*pud)) /* Another has populated it */
80587 + pmd_free(mm, new);
80588 + else
80589 + pgd_populate_kernel(mm, pud, new);
80590 +#endif /* __ARCH_HAS_4LEVEL_HACK */
80591 + spin_unlock(&mm->page_table_lock);
80592 + return 0;
80593 +}
80594 #endif /* __PAGETABLE_PMD_FOLDED */
80595
80596 #if !defined(__HAVE_ARCH_GATE_AREA)
80597 @@ -3915,7 +4197,7 @@ static int __init gate_vma_init(void)
80598 gate_vma.vm_start = FIXADDR_USER_START;
80599 gate_vma.vm_end = FIXADDR_USER_END;
80600 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
80601 - gate_vma.vm_page_prot = __P101;
80602 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
80603
80604 return 0;
80605 }
80606 @@ -4049,8 +4331,8 @@ out:
80607 return ret;
80608 }
80609
80610 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
80611 - void *buf, int len, int write)
80612 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
80613 + void *buf, size_t len, int write)
80614 {
80615 resource_size_t phys_addr;
80616 unsigned long prot = 0;
80617 @@ -4075,8 +4357,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
80618 * Access another process' address space as given in mm. If non-NULL, use the
80619 * given task for page fault accounting.
80620 */
80621 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
80622 - unsigned long addr, void *buf, int len, int write)
80623 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
80624 + unsigned long addr, void *buf, size_t len, int write)
80625 {
80626 struct vm_area_struct *vma;
80627 void *old_buf = buf;
80628 @@ -4084,7 +4366,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
80629 down_read(&mm->mmap_sem);
80630 /* ignore errors, just check how much was successfully transferred */
80631 while (len) {
80632 - int bytes, ret, offset;
80633 + ssize_t bytes, ret, offset;
80634 void *maddr;
80635 struct page *page = NULL;
80636
80637 @@ -4143,8 +4425,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
80638 *
80639 * The caller must hold a reference on @mm.
80640 */
80641 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
80642 - void *buf, int len, int write)
80643 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
80644 + void *buf, size_t len, int write)
80645 {
80646 return __access_remote_vm(NULL, mm, addr, buf, len, write);
80647 }
80648 @@ -4154,11 +4436,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
80649 * Source/target buffer must be kernel space,
80650 * Do not walk the page table directly, use get_user_pages
80651 */
80652 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
80653 - void *buf, int len, int write)
80654 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
80655 + void *buf, size_t len, int write)
80656 {
80657 struct mm_struct *mm;
80658 - int ret;
80659 + ssize_t ret;
80660
80661 mm = get_task_mm(tsk);
80662 if (!mm)
80663 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
80664 index 7431001..0f8344e 100644
80665 --- a/mm/mempolicy.c
80666 +++ b/mm/mempolicy.c
80667 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
80668 unsigned long vmstart;
80669 unsigned long vmend;
80670
80671 +#ifdef CONFIG_PAX_SEGMEXEC
80672 + struct vm_area_struct *vma_m;
80673 +#endif
80674 +
80675 vma = find_vma(mm, start);
80676 if (!vma || vma->vm_start > start)
80677 return -EFAULT;
80678 @@ -744,9 +748,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
80679 if (err)
80680 goto out;
80681 }
80682 +
80683 err = vma_replace_policy(vma, new_pol);
80684 if (err)
80685 goto out;
80686 +
80687 +#ifdef CONFIG_PAX_SEGMEXEC
80688 + vma_m = pax_find_mirror_vma(vma);
80689 + if (vma_m) {
80690 + err = vma_replace_policy(vma_m, new_pol);
80691 + if (err)
80692 + goto out;
80693 + }
80694 +#endif
80695 +
80696 }
80697
80698 out:
80699 @@ -1202,6 +1217,17 @@ static long do_mbind(unsigned long start, unsigned long len,
80700
80701 if (end < start)
80702 return -EINVAL;
80703 +
80704 +#ifdef CONFIG_PAX_SEGMEXEC
80705 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
80706 + if (end > SEGMEXEC_TASK_SIZE)
80707 + return -EINVAL;
80708 + } else
80709 +#endif
80710 +
80711 + if (end > TASK_SIZE)
80712 + return -EINVAL;
80713 +
80714 if (end == start)
80715 return 0;
80716
80717 @@ -1430,8 +1456,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
80718 */
80719 tcred = __task_cred(task);
80720 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
80721 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
80722 - !capable(CAP_SYS_NICE)) {
80723 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
80724 rcu_read_unlock();
80725 err = -EPERM;
80726 goto out_put;
80727 @@ -1462,6 +1487,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
80728 goto out;
80729 }
80730
80731 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
80732 + if (mm != current->mm &&
80733 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
80734 + mmput(mm);
80735 + err = -EPERM;
80736 + goto out;
80737 + }
80738 +#endif
80739 +
80740 err = do_migrate_pages(mm, old, new,
80741 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
80742
80743 diff --git a/mm/migrate.c b/mm/migrate.c
80744 index 3bbaf5d..299b0e9 100644
80745 --- a/mm/migrate.c
80746 +++ b/mm/migrate.c
80747 @@ -1382,8 +1382,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
80748 */
80749 tcred = __task_cred(task);
80750 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
80751 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
80752 - !capable(CAP_SYS_NICE)) {
80753 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
80754 rcu_read_unlock();
80755 err = -EPERM;
80756 goto out;
80757 diff --git a/mm/mlock.c b/mm/mlock.c
80758 index 79b7cf7..c60424f 100644
80759 --- a/mm/mlock.c
80760 +++ b/mm/mlock.c
80761 @@ -13,6 +13,7 @@
80762 #include <linux/pagemap.h>
80763 #include <linux/mempolicy.h>
80764 #include <linux/syscalls.h>
80765 +#include <linux/security.h>
80766 #include <linux/sched.h>
80767 #include <linux/export.h>
80768 #include <linux/rmap.h>
80769 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
80770 {
80771 unsigned long nstart, end, tmp;
80772 struct vm_area_struct * vma, * prev;
80773 - int error;
80774 + int error = 0;
80775
80776 VM_BUG_ON(start & ~PAGE_MASK);
80777 VM_BUG_ON(len != PAGE_ALIGN(len));
80778 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
80779 return -EINVAL;
80780 if (end == start)
80781 return 0;
80782 + if (end > TASK_SIZE)
80783 + return -EINVAL;
80784 +
80785 vma = find_vma(current->mm, start);
80786 if (!vma || vma->vm_start > start)
80787 return -ENOMEM;
80788 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
80789 for (nstart = start ; ; ) {
80790 vm_flags_t newflags;
80791
80792 +#ifdef CONFIG_PAX_SEGMEXEC
80793 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
80794 + break;
80795 +#endif
80796 +
80797 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
80798
80799 newflags = vma->vm_flags & ~VM_LOCKED;
80800 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
80801 lock_limit >>= PAGE_SHIFT;
80802
80803 /* check against resource limits */
80804 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
80805 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
80806 error = do_mlock(start, len, 1);
80807 up_write(&current->mm->mmap_sem);
80808 @@ -500,6 +510,12 @@ static int do_mlockall(int flags)
80809 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
80810 vm_flags_t newflags;
80811
80812 +#ifdef CONFIG_PAX_SEGMEXEC
80813 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
80814 + break;
80815 +#endif
80816 +
80817 + BUG_ON(vma->vm_end > TASK_SIZE);
80818 newflags = vma->vm_flags & ~VM_LOCKED;
80819 if (flags & MCL_CURRENT)
80820 newflags |= VM_LOCKED;
80821 @@ -532,6 +548,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
80822 lock_limit >>= PAGE_SHIFT;
80823
80824 ret = -ENOMEM;
80825 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
80826 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
80827 capable(CAP_IPC_LOCK))
80828 ret = do_mlockall(flags);
80829 diff --git a/mm/mmap.c b/mm/mmap.c
80830 index e17fc06..72fc5fd 100644
80831 --- a/mm/mmap.c
80832 +++ b/mm/mmap.c
80833 @@ -33,6 +33,7 @@
80834 #include <linux/uprobes.h>
80835 #include <linux/rbtree_augmented.h>
80836 #include <linux/sched/sysctl.h>
80837 +#include <linux/random.h>
80838
80839 #include <asm/uaccess.h>
80840 #include <asm/cacheflush.h>
80841 @@ -49,6 +50,16 @@
80842 #define arch_rebalance_pgtables(addr, len) (addr)
80843 #endif
80844
80845 +static inline void verify_mm_writelocked(struct mm_struct *mm)
80846 +{
80847 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
80848 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
80849 + up_read(&mm->mmap_sem);
80850 + BUG();
80851 + }
80852 +#endif
80853 +}
80854 +
80855 static void unmap_region(struct mm_struct *mm,
80856 struct vm_area_struct *vma, struct vm_area_struct *prev,
80857 unsigned long start, unsigned long end);
80858 @@ -68,22 +79,32 @@ static void unmap_region(struct mm_struct *mm,
80859 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
80860 *
80861 */
80862 -pgprot_t protection_map[16] = {
80863 +pgprot_t protection_map[16] __read_only = {
80864 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
80865 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
80866 };
80867
80868 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
80869 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
80870 {
80871 - return __pgprot(pgprot_val(protection_map[vm_flags &
80872 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
80873 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
80874 pgprot_val(arch_vm_get_page_prot(vm_flags)));
80875 +
80876 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
80877 + if (!(__supported_pte_mask & _PAGE_NX) &&
80878 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
80879 + (vm_flags & (VM_READ | VM_WRITE)))
80880 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
80881 +#endif
80882 +
80883 + return prot;
80884 }
80885 EXPORT_SYMBOL(vm_get_page_prot);
80886
80887 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
80888 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
80889 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
80890 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
80891 /*
80892 * Make sure vm_committed_as in one cacheline and not cacheline shared with
80893 * other variables. It can be updated by several CPUs frequently.
80894 @@ -239,6 +260,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
80895 struct vm_area_struct *next = vma->vm_next;
80896
80897 might_sleep();
80898 + BUG_ON(vma->vm_mirror);
80899 if (vma->vm_ops && vma->vm_ops->close)
80900 vma->vm_ops->close(vma);
80901 if (vma->vm_file)
80902 @@ -283,6 +305,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
80903 * not page aligned -Ram Gupta
80904 */
80905 rlim = rlimit(RLIMIT_DATA);
80906 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
80907 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
80908 (mm->end_data - mm->start_data) > rlim)
80909 goto out;
80910 @@ -897,6 +920,12 @@ static int
80911 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
80912 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
80913 {
80914 +
80915 +#ifdef CONFIG_PAX_SEGMEXEC
80916 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
80917 + return 0;
80918 +#endif
80919 +
80920 if (is_mergeable_vma(vma, file, vm_flags) &&
80921 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
80922 if (vma->vm_pgoff == vm_pgoff)
80923 @@ -916,6 +945,12 @@ static int
80924 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
80925 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
80926 {
80927 +
80928 +#ifdef CONFIG_PAX_SEGMEXEC
80929 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
80930 + return 0;
80931 +#endif
80932 +
80933 if (is_mergeable_vma(vma, file, vm_flags) &&
80934 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
80935 pgoff_t vm_pglen;
80936 @@ -958,13 +993,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
80937 struct vm_area_struct *vma_merge(struct mm_struct *mm,
80938 struct vm_area_struct *prev, unsigned long addr,
80939 unsigned long end, unsigned long vm_flags,
80940 - struct anon_vma *anon_vma, struct file *file,
80941 + struct anon_vma *anon_vma, struct file *file,
80942 pgoff_t pgoff, struct mempolicy *policy)
80943 {
80944 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
80945 struct vm_area_struct *area, *next;
80946 int err;
80947
80948 +#ifdef CONFIG_PAX_SEGMEXEC
80949 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
80950 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
80951 +
80952 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
80953 +#endif
80954 +
80955 /*
80956 * We later require that vma->vm_flags == vm_flags,
80957 * so this tests vma->vm_flags & VM_SPECIAL, too.
80958 @@ -980,6 +1022,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
80959 if (next && next->vm_end == end) /* cases 6, 7, 8 */
80960 next = next->vm_next;
80961
80962 +#ifdef CONFIG_PAX_SEGMEXEC
80963 + if (prev)
80964 + prev_m = pax_find_mirror_vma(prev);
80965 + if (area)
80966 + area_m = pax_find_mirror_vma(area);
80967 + if (next)
80968 + next_m = pax_find_mirror_vma(next);
80969 +#endif
80970 +
80971 /*
80972 * Can it merge with the predecessor?
80973 */
80974 @@ -999,9 +1050,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
80975 /* cases 1, 6 */
80976 err = vma_adjust(prev, prev->vm_start,
80977 next->vm_end, prev->vm_pgoff, NULL);
80978 - } else /* cases 2, 5, 7 */
80979 +
80980 +#ifdef CONFIG_PAX_SEGMEXEC
80981 + if (!err && prev_m)
80982 + err = vma_adjust(prev_m, prev_m->vm_start,
80983 + next_m->vm_end, prev_m->vm_pgoff, NULL);
80984 +#endif
80985 +
80986 + } else { /* cases 2, 5, 7 */
80987 err = vma_adjust(prev, prev->vm_start,
80988 end, prev->vm_pgoff, NULL);
80989 +
80990 +#ifdef CONFIG_PAX_SEGMEXEC
80991 + if (!err && prev_m)
80992 + err = vma_adjust(prev_m, prev_m->vm_start,
80993 + end_m, prev_m->vm_pgoff, NULL);
80994 +#endif
80995 +
80996 + }
80997 if (err)
80998 return NULL;
80999 khugepaged_enter_vma_merge(prev);
81000 @@ -1015,12 +1081,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
81001 mpol_equal(policy, vma_policy(next)) &&
81002 can_vma_merge_before(next, vm_flags,
81003 anon_vma, file, pgoff+pglen)) {
81004 - if (prev && addr < prev->vm_end) /* case 4 */
81005 + if (prev && addr < prev->vm_end) { /* case 4 */
81006 err = vma_adjust(prev, prev->vm_start,
81007 addr, prev->vm_pgoff, NULL);
81008 - else /* cases 3, 8 */
81009 +
81010 +#ifdef CONFIG_PAX_SEGMEXEC
81011 + if (!err && prev_m)
81012 + err = vma_adjust(prev_m, prev_m->vm_start,
81013 + addr_m, prev_m->vm_pgoff, NULL);
81014 +#endif
81015 +
81016 + } else { /* cases 3, 8 */
81017 err = vma_adjust(area, addr, next->vm_end,
81018 next->vm_pgoff - pglen, NULL);
81019 +
81020 +#ifdef CONFIG_PAX_SEGMEXEC
81021 + if (!err && area_m)
81022 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
81023 + next_m->vm_pgoff - pglen, NULL);
81024 +#endif
81025 +
81026 + }
81027 if (err)
81028 return NULL;
81029 khugepaged_enter_vma_merge(area);
81030 @@ -1129,8 +1210,10 @@ none:
81031 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
81032 struct file *file, long pages)
81033 {
81034 - const unsigned long stack_flags
81035 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
81036 +
81037 +#ifdef CONFIG_PAX_RANDMMAP
81038 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
81039 +#endif
81040
81041 mm->total_vm += pages;
81042
81043 @@ -1138,7 +1221,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
81044 mm->shared_vm += pages;
81045 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
81046 mm->exec_vm += pages;
81047 - } else if (flags & stack_flags)
81048 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
81049 mm->stack_vm += pages;
81050 }
81051 #endif /* CONFIG_PROC_FS */
81052 @@ -1177,7 +1260,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81053 * (the exception is when the underlying filesystem is noexec
81054 * mounted, in which case we dont add PROT_EXEC.)
81055 */
81056 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
81057 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
81058 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
81059 prot |= PROT_EXEC;
81060
81061 @@ -1203,7 +1286,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81062 /* Obtain the address to map to. we verify (or select) it and ensure
81063 * that it represents a valid section of the address space.
81064 */
81065 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
81066 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
81067 if (addr & ~PAGE_MASK)
81068 return addr;
81069
81070 @@ -1214,6 +1297,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81071 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
81072 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
81073
81074 +#ifdef CONFIG_PAX_MPROTECT
81075 + if (mm->pax_flags & MF_PAX_MPROTECT) {
81076 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
81077 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
81078 + gr_log_rwxmmap(file);
81079 +
81080 +#ifdef CONFIG_PAX_EMUPLT
81081 + vm_flags &= ~VM_EXEC;
81082 +#else
81083 + return -EPERM;
81084 +#endif
81085 +
81086 + }
81087 +
81088 + if (!(vm_flags & VM_EXEC))
81089 + vm_flags &= ~VM_MAYEXEC;
81090 +#else
81091 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
81092 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
81093 +#endif
81094 + else
81095 + vm_flags &= ~VM_MAYWRITE;
81096 + }
81097 +#endif
81098 +
81099 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81100 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
81101 + vm_flags &= ~VM_PAGEEXEC;
81102 +#endif
81103 +
81104 if (flags & MAP_LOCKED)
81105 if (!can_do_mlock())
81106 return -EPERM;
81107 @@ -1225,6 +1338,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81108 locked += mm->locked_vm;
81109 lock_limit = rlimit(RLIMIT_MEMLOCK);
81110 lock_limit >>= PAGE_SHIFT;
81111 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
81112 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
81113 return -EAGAIN;
81114 }
81115 @@ -1305,6 +1419,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
81116 vm_flags |= VM_NORESERVE;
81117 }
81118
81119 + if (!gr_acl_handle_mmap(file, prot))
81120 + return -EACCES;
81121 +
81122 addr = mmap_region(file, addr, len, vm_flags, pgoff);
81123 if (!IS_ERR_VALUE(addr) &&
81124 ((vm_flags & VM_LOCKED) ||
81125 @@ -1392,7 +1509,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
81126 vm_flags_t vm_flags = vma->vm_flags;
81127
81128 /* If it was private or non-writable, the write bit is already clear */
81129 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
81130 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
81131 return 0;
81132
81133 /* The backer wishes to know when pages are first written to? */
81134 @@ -1440,16 +1557,30 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
81135 unsigned long charged = 0;
81136 struct inode *inode = file ? file_inode(file) : NULL;
81137
81138 +#ifdef CONFIG_PAX_SEGMEXEC
81139 + struct vm_area_struct *vma_m = NULL;
81140 +#endif
81141 +
81142 + /*
81143 + * mm->mmap_sem is required to protect against another thread
81144 + * changing the mappings in case we sleep.
81145 + */
81146 + verify_mm_writelocked(mm);
81147 +
81148 /* Clear old maps */
81149 error = -ENOMEM;
81150 -munmap_back:
81151 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
81152 if (do_munmap(mm, addr, len))
81153 return -ENOMEM;
81154 - goto munmap_back;
81155 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
81156 }
81157
81158 /* Check against address space limit. */
81159 +
81160 +#ifdef CONFIG_PAX_RANDMMAP
81161 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
81162 +#endif
81163 +
81164 if (!may_expand_vm(mm, len >> PAGE_SHIFT))
81165 return -ENOMEM;
81166
81167 @@ -1481,6 +1612,16 @@ munmap_back:
81168 goto unacct_error;
81169 }
81170
81171 +#ifdef CONFIG_PAX_SEGMEXEC
81172 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
81173 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
81174 + if (!vma_m) {
81175 + error = -ENOMEM;
81176 + goto free_vma;
81177 + }
81178 + }
81179 +#endif
81180 +
81181 vma->vm_mm = mm;
81182 vma->vm_start = addr;
81183 vma->vm_end = addr + len;
81184 @@ -1505,6 +1646,13 @@ munmap_back:
81185 if (error)
81186 goto unmap_and_free_vma;
81187
81188 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81189 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
81190 + vma->vm_flags |= VM_PAGEEXEC;
81191 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
81192 + }
81193 +#endif
81194 +
81195 /* Can addr have changed??
81196 *
81197 * Answer: Yes, several device drivers can do it in their
81198 @@ -1543,6 +1691,11 @@ munmap_back:
81199 vma_link(mm, vma, prev, rb_link, rb_parent);
81200 file = vma->vm_file;
81201
81202 +#ifdef CONFIG_PAX_SEGMEXEC
81203 + if (vma_m)
81204 + BUG_ON(pax_mirror_vma(vma_m, vma));
81205 +#endif
81206 +
81207 /* Once vma denies write, undo our temporary denial count */
81208 if (correct_wcount)
81209 atomic_inc(&inode->i_writecount);
81210 @@ -1550,6 +1703,7 @@ out:
81211 perf_event_mmap(vma);
81212
81213 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
81214 + track_exec_limit(mm, addr, addr + len, vm_flags);
81215 if (vm_flags & VM_LOCKED) {
81216 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
81217 vma == get_gate_vma(current->mm)))
81218 @@ -1573,6 +1727,12 @@ unmap_and_free_vma:
81219 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
81220 charged = 0;
81221 free_vma:
81222 +
81223 +#ifdef CONFIG_PAX_SEGMEXEC
81224 + if (vma_m)
81225 + kmem_cache_free(vm_area_cachep, vma_m);
81226 +#endif
81227 +
81228 kmem_cache_free(vm_area_cachep, vma);
81229 unacct_error:
81230 if (charged)
81231 @@ -1580,6 +1740,62 @@ unacct_error:
81232 return error;
81233 }
81234
81235 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
81236 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
81237 +{
81238 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
81239 + return (random32() & 0xFF) << PAGE_SHIFT;
81240 +
81241 + return 0;
81242 +}
81243 +#endif
81244 +
81245 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
81246 +{
81247 + if (!vma) {
81248 +#ifdef CONFIG_STACK_GROWSUP
81249 + if (addr > sysctl_heap_stack_gap)
81250 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
81251 + else
81252 + vma = find_vma(current->mm, 0);
81253 + if (vma && (vma->vm_flags & VM_GROWSUP))
81254 + return false;
81255 +#endif
81256 + return true;
81257 + }
81258 +
81259 + if (addr + len > vma->vm_start)
81260 + return false;
81261 +
81262 + if (vma->vm_flags & VM_GROWSDOWN)
81263 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
81264 +#ifdef CONFIG_STACK_GROWSUP
81265 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
81266 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
81267 +#endif
81268 + else if (offset)
81269 + return offset <= vma->vm_start - addr - len;
81270 +
81271 + return true;
81272 +}
81273 +
81274 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
81275 +{
81276 + if (vma->vm_start < len)
81277 + return -ENOMEM;
81278 +
81279 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
81280 + if (offset <= vma->vm_start - len)
81281 + return vma->vm_start - len - offset;
81282 + else
81283 + return -ENOMEM;
81284 + }
81285 +
81286 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
81287 + return vma->vm_start - len - sysctl_heap_stack_gap;
81288 + return -ENOMEM;
81289 +}
81290 +
81291 unsigned long unmapped_area(struct vm_unmapped_area_info *info)
81292 {
81293 /*
81294 @@ -1799,6 +2015,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
81295 struct mm_struct *mm = current->mm;
81296 struct vm_area_struct *vma;
81297 struct vm_unmapped_area_info info;
81298 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
81299
81300 if (len > TASK_SIZE)
81301 return -ENOMEM;
81302 @@ -1806,29 +2023,45 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
81303 if (flags & MAP_FIXED)
81304 return addr;
81305
81306 +#ifdef CONFIG_PAX_RANDMMAP
81307 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
81308 +#endif
81309 +
81310 if (addr) {
81311 addr = PAGE_ALIGN(addr);
81312 vma = find_vma(mm, addr);
81313 - if (TASK_SIZE - len >= addr &&
81314 - (!vma || addr + len <= vma->vm_start))
81315 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
81316 return addr;
81317 }
81318
81319 info.flags = 0;
81320 info.length = len;
81321 info.low_limit = TASK_UNMAPPED_BASE;
81322 +
81323 +#ifdef CONFIG_PAX_RANDMMAP
81324 + if (mm->pax_flags & MF_PAX_RANDMMAP)
81325 + info.low_limit += mm->delta_mmap;
81326 +#endif
81327 +
81328 info.high_limit = TASK_SIZE;
81329 info.align_mask = 0;
81330 + info.threadstack_offset = offset;
81331 return vm_unmapped_area(&info);
81332 }
81333 #endif
81334
81335 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
81336 {
81337 +
81338 +#ifdef CONFIG_PAX_SEGMEXEC
81339 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
81340 + return;
81341 +#endif
81342 +
81343 /*
81344 * Is this a new hole at the lowest possible address?
81345 */
81346 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
81347 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
81348 mm->free_area_cache = addr;
81349 }
81350
81351 @@ -1846,6 +2079,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81352 struct mm_struct *mm = current->mm;
81353 unsigned long addr = addr0;
81354 struct vm_unmapped_area_info info;
81355 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
81356
81357 /* requested length too big for entire address space */
81358 if (len > TASK_SIZE)
81359 @@ -1854,12 +2088,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81360 if (flags & MAP_FIXED)
81361 return addr;
81362
81363 +#ifdef CONFIG_PAX_RANDMMAP
81364 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
81365 +#endif
81366 +
81367 /* requesting a specific address */
81368 if (addr) {
81369 addr = PAGE_ALIGN(addr);
81370 vma = find_vma(mm, addr);
81371 - if (TASK_SIZE - len >= addr &&
81372 - (!vma || addr + len <= vma->vm_start))
81373 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
81374 return addr;
81375 }
81376
81377 @@ -1868,6 +2105,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81378 info.low_limit = PAGE_SIZE;
81379 info.high_limit = mm->mmap_base;
81380 info.align_mask = 0;
81381 + info.threadstack_offset = offset;
81382 addr = vm_unmapped_area(&info);
81383
81384 /*
81385 @@ -1880,6 +2118,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81386 VM_BUG_ON(addr != -ENOMEM);
81387 info.flags = 0;
81388 info.low_limit = TASK_UNMAPPED_BASE;
81389 +
81390 +#ifdef CONFIG_PAX_RANDMMAP
81391 + if (mm->pax_flags & MF_PAX_RANDMMAP)
81392 + info.low_limit += mm->delta_mmap;
81393 +#endif
81394 +
81395 info.high_limit = TASK_SIZE;
81396 addr = vm_unmapped_area(&info);
81397 }
81398 @@ -1890,6 +2134,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
81399
81400 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
81401 {
81402 +
81403 +#ifdef CONFIG_PAX_SEGMEXEC
81404 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
81405 + return;
81406 +#endif
81407 +
81408 /*
81409 * Is this a new hole at the highest possible address?
81410 */
81411 @@ -1897,8 +2147,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
81412 mm->free_area_cache = addr;
81413
81414 /* dont allow allocations above current base */
81415 - if (mm->free_area_cache > mm->mmap_base)
81416 + if (mm->free_area_cache > mm->mmap_base) {
81417 mm->free_area_cache = mm->mmap_base;
81418 + mm->cached_hole_size = ~0UL;
81419 + }
81420 }
81421
81422 unsigned long
81423 @@ -1997,6 +2249,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
81424 return vma;
81425 }
81426
81427 +#ifdef CONFIG_PAX_SEGMEXEC
81428 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
81429 +{
81430 + struct vm_area_struct *vma_m;
81431 +
81432 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
81433 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
81434 + BUG_ON(vma->vm_mirror);
81435 + return NULL;
81436 + }
81437 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
81438 + vma_m = vma->vm_mirror;
81439 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
81440 + BUG_ON(vma->vm_file != vma_m->vm_file);
81441 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
81442 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
81443 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
81444 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
81445 + return vma_m;
81446 +}
81447 +#endif
81448 +
81449 /*
81450 * Verify that the stack growth is acceptable and
81451 * update accounting. This is shared with both the
81452 @@ -2013,6 +2287,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
81453 return -ENOMEM;
81454
81455 /* Stack limit test */
81456 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
81457 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
81458 return -ENOMEM;
81459
81460 @@ -2023,6 +2298,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
81461 locked = mm->locked_vm + grow;
81462 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
81463 limit >>= PAGE_SHIFT;
81464 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
81465 if (locked > limit && !capable(CAP_IPC_LOCK))
81466 return -ENOMEM;
81467 }
81468 @@ -2052,37 +2328,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
81469 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
81470 * vma is the last one with address > vma->vm_end. Have to extend vma.
81471 */
81472 +#ifndef CONFIG_IA64
81473 +static
81474 +#endif
81475 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
81476 {
81477 int error;
81478 + bool locknext;
81479
81480 if (!(vma->vm_flags & VM_GROWSUP))
81481 return -EFAULT;
81482
81483 + /* Also guard against wrapping around to address 0. */
81484 + if (address < PAGE_ALIGN(address+1))
81485 + address = PAGE_ALIGN(address+1);
81486 + else
81487 + return -ENOMEM;
81488 +
81489 /*
81490 * We must make sure the anon_vma is allocated
81491 * so that the anon_vma locking is not a noop.
81492 */
81493 if (unlikely(anon_vma_prepare(vma)))
81494 return -ENOMEM;
81495 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
81496 + if (locknext && anon_vma_prepare(vma->vm_next))
81497 + return -ENOMEM;
81498 vma_lock_anon_vma(vma);
81499 + if (locknext)
81500 + vma_lock_anon_vma(vma->vm_next);
81501
81502 /*
81503 * vma->vm_start/vm_end cannot change under us because the caller
81504 * is required to hold the mmap_sem in read mode. We need the
81505 - * anon_vma lock to serialize against concurrent expand_stacks.
81506 - * Also guard against wrapping around to address 0.
81507 + * anon_vma locks to serialize against concurrent expand_stacks
81508 + * and expand_upwards.
81509 */
81510 - if (address < PAGE_ALIGN(address+4))
81511 - address = PAGE_ALIGN(address+4);
81512 - else {
81513 - vma_unlock_anon_vma(vma);
81514 - return -ENOMEM;
81515 - }
81516 error = 0;
81517
81518 /* Somebody else might have raced and expanded it already */
81519 - if (address > vma->vm_end) {
81520 + 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)
81521 + error = -ENOMEM;
81522 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
81523 unsigned long size, grow;
81524
81525 size = address - vma->vm_start;
81526 @@ -2117,6 +2404,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
81527 }
81528 }
81529 }
81530 + if (locknext)
81531 + vma_unlock_anon_vma(vma->vm_next);
81532 vma_unlock_anon_vma(vma);
81533 khugepaged_enter_vma_merge(vma);
81534 validate_mm(vma->vm_mm);
81535 @@ -2131,6 +2420,8 @@ int expand_downwards(struct vm_area_struct *vma,
81536 unsigned long address)
81537 {
81538 int error;
81539 + bool lockprev = false;
81540 + struct vm_area_struct *prev;
81541
81542 /*
81543 * We must make sure the anon_vma is allocated
81544 @@ -2144,6 +2435,15 @@ int expand_downwards(struct vm_area_struct *vma,
81545 if (error)
81546 return error;
81547
81548 + prev = vma->vm_prev;
81549 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
81550 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
81551 +#endif
81552 + if (lockprev && anon_vma_prepare(prev))
81553 + return -ENOMEM;
81554 + if (lockprev)
81555 + vma_lock_anon_vma(prev);
81556 +
81557 vma_lock_anon_vma(vma);
81558
81559 /*
81560 @@ -2153,9 +2453,17 @@ int expand_downwards(struct vm_area_struct *vma,
81561 */
81562
81563 /* Somebody else might have raced and expanded it already */
81564 - if (address < vma->vm_start) {
81565 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
81566 + error = -ENOMEM;
81567 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
81568 unsigned long size, grow;
81569
81570 +#ifdef CONFIG_PAX_SEGMEXEC
81571 + struct vm_area_struct *vma_m;
81572 +
81573 + vma_m = pax_find_mirror_vma(vma);
81574 +#endif
81575 +
81576 size = vma->vm_end - address;
81577 grow = (vma->vm_start - address) >> PAGE_SHIFT;
81578
81579 @@ -2180,6 +2488,18 @@ int expand_downwards(struct vm_area_struct *vma,
81580 vma->vm_pgoff -= grow;
81581 anon_vma_interval_tree_post_update_vma(vma);
81582 vma_gap_update(vma);
81583 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
81584 +
81585 +#ifdef CONFIG_PAX_SEGMEXEC
81586 + if (vma_m) {
81587 + anon_vma_interval_tree_pre_update_vma(vma_m);
81588 + vma_m->vm_start -= grow << PAGE_SHIFT;
81589 + vma_m->vm_pgoff -= grow;
81590 + anon_vma_interval_tree_post_update_vma(vma_m);
81591 + vma_gap_update(vma_m);
81592 + }
81593 +#endif
81594 +
81595 spin_unlock(&vma->vm_mm->page_table_lock);
81596
81597 perf_event_mmap(vma);
81598 @@ -2284,6 +2604,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
81599 do {
81600 long nrpages = vma_pages(vma);
81601
81602 +#ifdef CONFIG_PAX_SEGMEXEC
81603 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
81604 + vma = remove_vma(vma);
81605 + continue;
81606 + }
81607 +#endif
81608 +
81609 if (vma->vm_flags & VM_ACCOUNT)
81610 nr_accounted += nrpages;
81611 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
81612 @@ -2329,6 +2656,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
81613 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
81614 vma->vm_prev = NULL;
81615 do {
81616 +
81617 +#ifdef CONFIG_PAX_SEGMEXEC
81618 + if (vma->vm_mirror) {
81619 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
81620 + vma->vm_mirror->vm_mirror = NULL;
81621 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
81622 + vma->vm_mirror = NULL;
81623 + }
81624 +#endif
81625 +
81626 vma_rb_erase(vma, &mm->mm_rb);
81627 mm->map_count--;
81628 tail_vma = vma;
81629 @@ -2360,14 +2697,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81630 struct vm_area_struct *new;
81631 int err = -ENOMEM;
81632
81633 +#ifdef CONFIG_PAX_SEGMEXEC
81634 + struct vm_area_struct *vma_m, *new_m = NULL;
81635 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
81636 +#endif
81637 +
81638 if (is_vm_hugetlb_page(vma) && (addr &
81639 ~(huge_page_mask(hstate_vma(vma)))))
81640 return -EINVAL;
81641
81642 +#ifdef CONFIG_PAX_SEGMEXEC
81643 + vma_m = pax_find_mirror_vma(vma);
81644 +#endif
81645 +
81646 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81647 if (!new)
81648 goto out_err;
81649
81650 +#ifdef CONFIG_PAX_SEGMEXEC
81651 + if (vma_m) {
81652 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
81653 + if (!new_m) {
81654 + kmem_cache_free(vm_area_cachep, new);
81655 + goto out_err;
81656 + }
81657 + }
81658 +#endif
81659 +
81660 /* most fields are the same, copy all, and then fixup */
81661 *new = *vma;
81662
81663 @@ -2380,6 +2736,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81664 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
81665 }
81666
81667 +#ifdef CONFIG_PAX_SEGMEXEC
81668 + if (vma_m) {
81669 + *new_m = *vma_m;
81670 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
81671 + new_m->vm_mirror = new;
81672 + new->vm_mirror = new_m;
81673 +
81674 + if (new_below)
81675 + new_m->vm_end = addr_m;
81676 + else {
81677 + new_m->vm_start = addr_m;
81678 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
81679 + }
81680 + }
81681 +#endif
81682 +
81683 pol = mpol_dup(vma_policy(vma));
81684 if (IS_ERR(pol)) {
81685 err = PTR_ERR(pol);
81686 @@ -2402,6 +2774,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81687 else
81688 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
81689
81690 +#ifdef CONFIG_PAX_SEGMEXEC
81691 + if (!err && vma_m) {
81692 + if (anon_vma_clone(new_m, vma_m))
81693 + goto out_free_mpol;
81694 +
81695 + mpol_get(pol);
81696 + vma_set_policy(new_m, pol);
81697 +
81698 + if (new_m->vm_file)
81699 + get_file(new_m->vm_file);
81700 +
81701 + if (new_m->vm_ops && new_m->vm_ops->open)
81702 + new_m->vm_ops->open(new_m);
81703 +
81704 + if (new_below)
81705 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
81706 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
81707 + else
81708 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
81709 +
81710 + if (err) {
81711 + if (new_m->vm_ops && new_m->vm_ops->close)
81712 + new_m->vm_ops->close(new_m);
81713 + if (new_m->vm_file)
81714 + fput(new_m->vm_file);
81715 + mpol_put(pol);
81716 + }
81717 + }
81718 +#endif
81719 +
81720 /* Success. */
81721 if (!err)
81722 return 0;
81723 @@ -2411,10 +2813,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81724 new->vm_ops->close(new);
81725 if (new->vm_file)
81726 fput(new->vm_file);
81727 - unlink_anon_vmas(new);
81728 out_free_mpol:
81729 mpol_put(pol);
81730 out_free_vma:
81731 +
81732 +#ifdef CONFIG_PAX_SEGMEXEC
81733 + if (new_m) {
81734 + unlink_anon_vmas(new_m);
81735 + kmem_cache_free(vm_area_cachep, new_m);
81736 + }
81737 +#endif
81738 +
81739 + unlink_anon_vmas(new);
81740 kmem_cache_free(vm_area_cachep, new);
81741 out_err:
81742 return err;
81743 @@ -2427,6 +2837,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
81744 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
81745 unsigned long addr, int new_below)
81746 {
81747 +
81748 +#ifdef CONFIG_PAX_SEGMEXEC
81749 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
81750 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
81751 + if (mm->map_count >= sysctl_max_map_count-1)
81752 + return -ENOMEM;
81753 + } else
81754 +#endif
81755 +
81756 if (mm->map_count >= sysctl_max_map_count)
81757 return -ENOMEM;
81758
81759 @@ -2438,11 +2857,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
81760 * work. This now handles partial unmappings.
81761 * Jeremy Fitzhardinge <jeremy@goop.org>
81762 */
81763 +#ifdef CONFIG_PAX_SEGMEXEC
81764 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
81765 {
81766 + int ret = __do_munmap(mm, start, len);
81767 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
81768 + return ret;
81769 +
81770 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
81771 +}
81772 +
81773 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
81774 +#else
81775 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
81776 +#endif
81777 +{
81778 unsigned long end;
81779 struct vm_area_struct *vma, *prev, *last;
81780
81781 + /*
81782 + * mm->mmap_sem is required to protect against another thread
81783 + * changing the mappings in case we sleep.
81784 + */
81785 + verify_mm_writelocked(mm);
81786 +
81787 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
81788 return -EINVAL;
81789
81790 @@ -2517,6 +2955,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
81791 /* Fix up all other VM information */
81792 remove_vma_list(mm, vma);
81793
81794 + track_exec_limit(mm, start, end, 0UL);
81795 +
81796 return 0;
81797 }
81798
81799 @@ -2525,6 +2965,13 @@ int vm_munmap(unsigned long start, size_t len)
81800 int ret;
81801 struct mm_struct *mm = current->mm;
81802
81803 +
81804 +#ifdef CONFIG_PAX_SEGMEXEC
81805 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
81806 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
81807 + return -EINVAL;
81808 +#endif
81809 +
81810 down_write(&mm->mmap_sem);
81811 ret = do_munmap(mm, start, len);
81812 up_write(&mm->mmap_sem);
81813 @@ -2538,16 +2985,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
81814 return vm_munmap(addr, len);
81815 }
81816
81817 -static inline void verify_mm_writelocked(struct mm_struct *mm)
81818 -{
81819 -#ifdef CONFIG_DEBUG_VM
81820 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
81821 - WARN_ON(1);
81822 - up_read(&mm->mmap_sem);
81823 - }
81824 -#endif
81825 -}
81826 -
81827 /*
81828 * this is really a simplified "do_mmap". it only handles
81829 * anonymous maps. eventually we may be able to do some
81830 @@ -2561,6 +2998,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
81831 struct rb_node ** rb_link, * rb_parent;
81832 pgoff_t pgoff = addr >> PAGE_SHIFT;
81833 int error;
81834 + unsigned long charged;
81835
81836 len = PAGE_ALIGN(len);
81837 if (!len)
81838 @@ -2568,16 +3006,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
81839
81840 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
81841
81842 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
81843 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
81844 + flags &= ~VM_EXEC;
81845 +
81846 +#ifdef CONFIG_PAX_MPROTECT
81847 + if (mm->pax_flags & MF_PAX_MPROTECT)
81848 + flags &= ~VM_MAYEXEC;
81849 +#endif
81850 +
81851 + }
81852 +#endif
81853 +
81854 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
81855 if (error & ~PAGE_MASK)
81856 return error;
81857
81858 + charged = len >> PAGE_SHIFT;
81859 +
81860 /*
81861 * mlock MCL_FUTURE?
81862 */
81863 if (mm->def_flags & VM_LOCKED) {
81864 unsigned long locked, lock_limit;
81865 - locked = len >> PAGE_SHIFT;
81866 + locked = charged;
81867 locked += mm->locked_vm;
81868 lock_limit = rlimit(RLIMIT_MEMLOCK);
81869 lock_limit >>= PAGE_SHIFT;
81870 @@ -2594,21 +3046,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
81871 /*
81872 * Clear old maps. this also does some error checking for us
81873 */
81874 - munmap_back:
81875 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
81876 if (do_munmap(mm, addr, len))
81877 return -ENOMEM;
81878 - goto munmap_back;
81879 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
81880 }
81881
81882 /* Check against address space limits *after* clearing old maps... */
81883 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
81884 + if (!may_expand_vm(mm, charged))
81885 return -ENOMEM;
81886
81887 if (mm->map_count > sysctl_max_map_count)
81888 return -ENOMEM;
81889
81890 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
81891 + if (security_vm_enough_memory_mm(mm, charged))
81892 return -ENOMEM;
81893
81894 /* Can we just expand an old private anonymous mapping? */
81895 @@ -2622,7 +3073,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
81896 */
81897 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
81898 if (!vma) {
81899 - vm_unacct_memory(len >> PAGE_SHIFT);
81900 + vm_unacct_memory(charged);
81901 return -ENOMEM;
81902 }
81903
81904 @@ -2636,9 +3087,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
81905 vma_link(mm, vma, prev, rb_link, rb_parent);
81906 out:
81907 perf_event_mmap(vma);
81908 - mm->total_vm += len >> PAGE_SHIFT;
81909 + mm->total_vm += charged;
81910 if (flags & VM_LOCKED)
81911 - mm->locked_vm += (len >> PAGE_SHIFT);
81912 + mm->locked_vm += charged;
81913 + track_exec_limit(mm, addr, addr + len, flags);
81914 return addr;
81915 }
81916
81917 @@ -2700,6 +3152,7 @@ void exit_mmap(struct mm_struct *mm)
81918 while (vma) {
81919 if (vma->vm_flags & VM_ACCOUNT)
81920 nr_accounted += vma_pages(vma);
81921 + vma->vm_mirror = NULL;
81922 vma = remove_vma(vma);
81923 }
81924 vm_unacct_memory(nr_accounted);
81925 @@ -2716,6 +3169,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
81926 struct vm_area_struct *prev;
81927 struct rb_node **rb_link, *rb_parent;
81928
81929 +#ifdef CONFIG_PAX_SEGMEXEC
81930 + struct vm_area_struct *vma_m = NULL;
81931 +#endif
81932 +
81933 + if (security_mmap_addr(vma->vm_start))
81934 + return -EPERM;
81935 +
81936 /*
81937 * The vm_pgoff of a purely anonymous vma should be irrelevant
81938 * until its first write fault, when page's anon_vma and index
81939 @@ -2739,7 +3199,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
81940 security_vm_enough_memory_mm(mm, vma_pages(vma)))
81941 return -ENOMEM;
81942
81943 +#ifdef CONFIG_PAX_SEGMEXEC
81944 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
81945 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
81946 + if (!vma_m)
81947 + return -ENOMEM;
81948 + }
81949 +#endif
81950 +
81951 vma_link(mm, vma, prev, rb_link, rb_parent);
81952 +
81953 +#ifdef CONFIG_PAX_SEGMEXEC
81954 + if (vma_m)
81955 + BUG_ON(pax_mirror_vma(vma_m, vma));
81956 +#endif
81957 +
81958 return 0;
81959 }
81960
81961 @@ -2759,6 +3233,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
81962 struct mempolicy *pol;
81963 bool faulted_in_anon_vma = true;
81964
81965 + BUG_ON(vma->vm_mirror);
81966 +
81967 /*
81968 * If anonymous vma has not yet been faulted, update new pgoff
81969 * to match new location, to increase its chance of merging.
81970 @@ -2825,6 +3301,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
81971 return NULL;
81972 }
81973
81974 +#ifdef CONFIG_PAX_SEGMEXEC
81975 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
81976 +{
81977 + struct vm_area_struct *prev_m;
81978 + struct rb_node **rb_link_m, *rb_parent_m;
81979 + struct mempolicy *pol_m;
81980 +
81981 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
81982 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
81983 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
81984 + *vma_m = *vma;
81985 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
81986 + if (anon_vma_clone(vma_m, vma))
81987 + return -ENOMEM;
81988 + pol_m = vma_policy(vma_m);
81989 + mpol_get(pol_m);
81990 + vma_set_policy(vma_m, pol_m);
81991 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
81992 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
81993 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
81994 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
81995 + if (vma_m->vm_file)
81996 + get_file(vma_m->vm_file);
81997 + if (vma_m->vm_ops && vma_m->vm_ops->open)
81998 + vma_m->vm_ops->open(vma_m);
81999 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
82000 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
82001 + vma_m->vm_mirror = vma;
82002 + vma->vm_mirror = vma_m;
82003 + return 0;
82004 +}
82005 +#endif
82006 +
82007 /*
82008 * Return true if the calling process may expand its vm space by the passed
82009 * number of pages
82010 @@ -2836,6 +3345,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
82011
82012 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
82013
82014 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
82015 if (cur + npages > lim)
82016 return 0;
82017 return 1;
82018 @@ -2906,6 +3416,22 @@ int install_special_mapping(struct mm_struct *mm,
82019 vma->vm_start = addr;
82020 vma->vm_end = addr + len;
82021
82022 +#ifdef CONFIG_PAX_MPROTECT
82023 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82024 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82025 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
82026 + return -EPERM;
82027 + if (!(vm_flags & VM_EXEC))
82028 + vm_flags &= ~VM_MAYEXEC;
82029 +#else
82030 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82031 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82032 +#endif
82033 + else
82034 + vm_flags &= ~VM_MAYWRITE;
82035 + }
82036 +#endif
82037 +
82038 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
82039 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82040
82041 diff --git a/mm/mprotect.c b/mm/mprotect.c
82042 index 94722a4..07d9926 100644
82043 --- a/mm/mprotect.c
82044 +++ b/mm/mprotect.c
82045 @@ -23,10 +23,18 @@
82046 #include <linux/mmu_notifier.h>
82047 #include <linux/migrate.h>
82048 #include <linux/perf_event.h>
82049 +#include <linux/sched/sysctl.h>
82050 +
82051 +#ifdef CONFIG_PAX_MPROTECT
82052 +#include <linux/elf.h>
82053 +#include <linux/binfmts.h>
82054 +#endif
82055 +
82056 #include <asm/uaccess.h>
82057 #include <asm/pgtable.h>
82058 #include <asm/cacheflush.h>
82059 #include <asm/tlbflush.h>
82060 +#include <asm/mmu_context.h>
82061
82062 #ifndef pgprot_modify
82063 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
82064 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
82065 return pages;
82066 }
82067
82068 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
82069 +/* called while holding the mmap semaphor for writing except stack expansion */
82070 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
82071 +{
82072 + unsigned long oldlimit, newlimit = 0UL;
82073 +
82074 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
82075 + return;
82076 +
82077 + spin_lock(&mm->page_table_lock);
82078 + oldlimit = mm->context.user_cs_limit;
82079 + if ((prot & VM_EXEC) && oldlimit < end)
82080 + /* USER_CS limit moved up */
82081 + newlimit = end;
82082 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
82083 + /* USER_CS limit moved down */
82084 + newlimit = start;
82085 +
82086 + if (newlimit) {
82087 + mm->context.user_cs_limit = newlimit;
82088 +
82089 +#ifdef CONFIG_SMP
82090 + wmb();
82091 + cpus_clear(mm->context.cpu_user_cs_mask);
82092 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
82093 +#endif
82094 +
82095 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
82096 + }
82097 + spin_unlock(&mm->page_table_lock);
82098 + if (newlimit == end) {
82099 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
82100 +
82101 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
82102 + if (is_vm_hugetlb_page(vma))
82103 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
82104 + else
82105 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
82106 + }
82107 +}
82108 +#endif
82109 +
82110 int
82111 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82112 unsigned long start, unsigned long end, unsigned long newflags)
82113 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82114 int error;
82115 int dirty_accountable = 0;
82116
82117 +#ifdef CONFIG_PAX_SEGMEXEC
82118 + struct vm_area_struct *vma_m = NULL;
82119 + unsigned long start_m, end_m;
82120 +
82121 + start_m = start + SEGMEXEC_TASK_SIZE;
82122 + end_m = end + SEGMEXEC_TASK_SIZE;
82123 +#endif
82124 +
82125 if (newflags == oldflags) {
82126 *pprev = vma;
82127 return 0;
82128 }
82129
82130 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
82131 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
82132 +
82133 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
82134 + return -ENOMEM;
82135 +
82136 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
82137 + return -ENOMEM;
82138 + }
82139 +
82140 /*
82141 * If we make a private mapping writable we increase our commit;
82142 * but (without finer accounting) cannot reduce our commit if we
82143 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
82144 }
82145 }
82146
82147 +#ifdef CONFIG_PAX_SEGMEXEC
82148 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
82149 + if (start != vma->vm_start) {
82150 + error = split_vma(mm, vma, start, 1);
82151 + if (error)
82152 + goto fail;
82153 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
82154 + *pprev = (*pprev)->vm_next;
82155 + }
82156 +
82157 + if (end != vma->vm_end) {
82158 + error = split_vma(mm, vma, end, 0);
82159 + if (error)
82160 + goto fail;
82161 + }
82162 +
82163 + if (pax_find_mirror_vma(vma)) {
82164 + error = __do_munmap(mm, start_m, end_m - start_m);
82165 + if (error)
82166 + goto fail;
82167 + } else {
82168 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82169 + if (!vma_m) {
82170 + error = -ENOMEM;
82171 + goto fail;
82172 + }
82173 + vma->vm_flags = newflags;
82174 + error = pax_mirror_vma(vma_m, vma);
82175 + if (error) {
82176 + vma->vm_flags = oldflags;
82177 + goto fail;
82178 + }
82179 + }
82180 + }
82181 +#endif
82182 +
82183 /*
82184 * First try to merge with previous and/or next vma.
82185 */
82186 @@ -296,9 +400,21 @@ success:
82187 * vm_flags and vm_page_prot are protected by the mmap_sem
82188 * held in write mode.
82189 */
82190 +
82191 +#ifdef CONFIG_PAX_SEGMEXEC
82192 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
82193 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
82194 +#endif
82195 +
82196 vma->vm_flags = newflags;
82197 +
82198 +#ifdef CONFIG_PAX_MPROTECT
82199 + if (mm->binfmt && mm->binfmt->handle_mprotect)
82200 + mm->binfmt->handle_mprotect(vma, newflags);
82201 +#endif
82202 +
82203 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
82204 - vm_get_page_prot(newflags));
82205 + vm_get_page_prot(vma->vm_flags));
82206
82207 if (vma_wants_writenotify(vma)) {
82208 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
82209 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82210 end = start + len;
82211 if (end <= start)
82212 return -ENOMEM;
82213 +
82214 +#ifdef CONFIG_PAX_SEGMEXEC
82215 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
82216 + if (end > SEGMEXEC_TASK_SIZE)
82217 + return -EINVAL;
82218 + } else
82219 +#endif
82220 +
82221 + if (end > TASK_SIZE)
82222 + return -EINVAL;
82223 +
82224 if (!arch_validate_prot(prot))
82225 return -EINVAL;
82226
82227 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82228 /*
82229 * Does the application expect PROT_READ to imply PROT_EXEC:
82230 */
82231 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
82232 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
82233 prot |= PROT_EXEC;
82234
82235 vm_flags = calc_vm_prot_bits(prot);
82236 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82237 if (start > vma->vm_start)
82238 prev = vma;
82239
82240 +#ifdef CONFIG_PAX_MPROTECT
82241 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
82242 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
82243 +#endif
82244 +
82245 for (nstart = start ; ; ) {
82246 unsigned long newflags;
82247
82248 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82249
82250 /* newflags >> 4 shift VM_MAY% in place of VM_% */
82251 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
82252 + if (prot & (PROT_WRITE | PROT_EXEC))
82253 + gr_log_rwxmprotect(vma->vm_file);
82254 +
82255 + error = -EACCES;
82256 + goto out;
82257 + }
82258 +
82259 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
82260 error = -EACCES;
82261 goto out;
82262 }
82263 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
82264 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
82265 if (error)
82266 goto out;
82267 +
82268 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
82269 +
82270 nstart = tmp;
82271
82272 if (nstart < prev->vm_end)
82273 diff --git a/mm/mremap.c b/mm/mremap.c
82274 index 463a257..c0c7a92 100644
82275 --- a/mm/mremap.c
82276 +++ b/mm/mremap.c
82277 @@ -126,6 +126,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
82278 continue;
82279 pte = ptep_get_and_clear(mm, old_addr, old_pte);
82280 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
82281 +
82282 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
82283 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
82284 + pte = pte_exprotect(pte);
82285 +#endif
82286 +
82287 set_pte_at(mm, new_addr, new_pte, pte);
82288 }
82289
82290 @@ -318,6 +324,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
82291 if (is_vm_hugetlb_page(vma))
82292 goto Einval;
82293
82294 +#ifdef CONFIG_PAX_SEGMEXEC
82295 + if (pax_find_mirror_vma(vma))
82296 + goto Einval;
82297 +#endif
82298 +
82299 /* We can't remap across vm area boundaries */
82300 if (old_len > vma->vm_end - addr)
82301 goto Efault;
82302 @@ -373,20 +384,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
82303 unsigned long ret = -EINVAL;
82304 unsigned long charged = 0;
82305 unsigned long map_flags;
82306 + unsigned long pax_task_size = TASK_SIZE;
82307
82308 if (new_addr & ~PAGE_MASK)
82309 goto out;
82310
82311 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
82312 +#ifdef CONFIG_PAX_SEGMEXEC
82313 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
82314 + pax_task_size = SEGMEXEC_TASK_SIZE;
82315 +#endif
82316 +
82317 + pax_task_size -= PAGE_SIZE;
82318 +
82319 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
82320 goto out;
82321
82322 /* Check if the location we're moving into overlaps the
82323 * old location at all, and fail if it does.
82324 */
82325 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
82326 - goto out;
82327 -
82328 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
82329 + if (addr + old_len > new_addr && new_addr + new_len > addr)
82330 goto out;
82331
82332 ret = do_munmap(mm, new_addr, new_len);
82333 @@ -455,6 +471,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
82334 unsigned long ret = -EINVAL;
82335 unsigned long charged = 0;
82336 bool locked = false;
82337 + unsigned long pax_task_size = TASK_SIZE;
82338
82339 down_write(&current->mm->mmap_sem);
82340
82341 @@ -475,6 +492,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
82342 if (!new_len)
82343 goto out;
82344
82345 +#ifdef CONFIG_PAX_SEGMEXEC
82346 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
82347 + pax_task_size = SEGMEXEC_TASK_SIZE;
82348 +#endif
82349 +
82350 + pax_task_size -= PAGE_SIZE;
82351 +
82352 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
82353 + old_len > pax_task_size || addr > pax_task_size-old_len)
82354 + goto out;
82355 +
82356 if (flags & MREMAP_FIXED) {
82357 if (flags & MREMAP_MAYMOVE)
82358 ret = mremap_to(addr, old_len, new_addr, new_len,
82359 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
82360 new_addr = addr;
82361 }
82362 ret = addr;
82363 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
82364 goto out;
82365 }
82366 }
82367 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
82368 goto out;
82369 }
82370
82371 + map_flags = vma->vm_flags;
82372 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
82373 + if (!(ret & ~PAGE_MASK)) {
82374 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
82375 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
82376 + }
82377 }
82378 out:
82379 if (ret & ~PAGE_MASK)
82380 diff --git a/mm/nommu.c b/mm/nommu.c
82381 index e001768..9b52b30 100644
82382 --- a/mm/nommu.c
82383 +++ b/mm/nommu.c
82384 @@ -63,7 +63,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
82385 int sysctl_overcommit_ratio = 50; /* default is 50% */
82386 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
82387 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
82388 -int heap_stack_gap = 0;
82389
82390 atomic_long_t mmap_pages_allocated;
82391
82392 @@ -841,15 +840,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
82393 EXPORT_SYMBOL(find_vma);
82394
82395 /*
82396 - * find a VMA
82397 - * - we don't extend stack VMAs under NOMMU conditions
82398 - */
82399 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
82400 -{
82401 - return find_vma(mm, addr);
82402 -}
82403 -
82404 -/*
82405 * expand a stack to a given address
82406 * - not supported under NOMMU conditions
82407 */
82408 @@ -1560,6 +1550,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82409
82410 /* most fields are the same, copy all, and then fixup */
82411 *new = *vma;
82412 + INIT_LIST_HEAD(&new->anon_vma_chain);
82413 *region = *vma->vm_region;
82414 new->vm_region = region;
82415
82416 @@ -1992,8 +1983,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
82417 }
82418 EXPORT_SYMBOL(generic_file_remap_pages);
82419
82420 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82421 - unsigned long addr, void *buf, int len, int write)
82422 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82423 + unsigned long addr, void *buf, size_t len, int write)
82424 {
82425 struct vm_area_struct *vma;
82426
82427 @@ -2034,8 +2025,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82428 *
82429 * The caller must hold a reference on @mm.
82430 */
82431 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
82432 - void *buf, int len, int write)
82433 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
82434 + void *buf, size_t len, int write)
82435 {
82436 return __access_remote_vm(NULL, mm, addr, buf, len, write);
82437 }
82438 @@ -2044,7 +2035,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
82439 * Access another process' address space.
82440 * - source/target buffer must be kernel space
82441 */
82442 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
82443 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
82444 {
82445 struct mm_struct *mm;
82446
82447 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
82448 index efe6814..64b4701 100644
82449 --- a/mm/page-writeback.c
82450 +++ b/mm/page-writeback.c
82451 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
82452 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
82453 * - the bdi dirty thresh drops quickly due to change of JBOD workload
82454 */
82455 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
82456 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
82457 unsigned long thresh,
82458 unsigned long bg_thresh,
82459 unsigned long dirty,
82460 @@ -1634,7 +1634,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
82461 }
82462 }
82463
82464 -static struct notifier_block __cpuinitdata ratelimit_nb = {
82465 +static struct notifier_block ratelimit_nb = {
82466 .notifier_call = ratelimit_handler,
82467 .next = NULL,
82468 };
82469 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
82470 index 8fcced7..ebcd481 100644
82471 --- a/mm/page_alloc.c
82472 +++ b/mm/page_alloc.c
82473 @@ -59,6 +59,7 @@
82474 #include <linux/migrate.h>
82475 #include <linux/page-debug-flags.h>
82476 #include <linux/sched/rt.h>
82477 +#include <linux/random.h>
82478
82479 #include <asm/tlbflush.h>
82480 #include <asm/div64.h>
82481 @@ -344,7 +345,7 @@ out:
82482 * This usage means that zero-order pages may not be compound.
82483 */
82484
82485 -static void free_compound_page(struct page *page)
82486 +void free_compound_page(struct page *page)
82487 {
82488 __free_pages_ok(page, compound_order(page));
82489 }
82490 @@ -701,6 +702,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
82491 int i;
82492 int bad = 0;
82493
82494 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
82495 + unsigned long index = 1UL << order;
82496 +#endif
82497 +
82498 trace_mm_page_free(page, order);
82499 kmemcheck_free_shadow(page, order);
82500
82501 @@ -716,6 +721,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
82502 debug_check_no_obj_freed(page_address(page),
82503 PAGE_SIZE << order);
82504 }
82505 +
82506 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
82507 + for (; index; --index)
82508 + sanitize_highpage(page + index - 1);
82509 +#endif
82510 +
82511 arch_free_page(page, order);
82512 kernel_map_pages(page, 1 << order, 0);
82513
82514 @@ -738,6 +749,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
82515 local_irq_restore(flags);
82516 }
82517
82518 +#ifdef CONFIG_PAX_LATENT_ENTROPY
82519 +bool __meminitdata extra_latent_entropy;
82520 +
82521 +static int __init setup_pax_extra_latent_entropy(char *str)
82522 +{
82523 + extra_latent_entropy = true;
82524 + return 0;
82525 +}
82526 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
82527 +
82528 +volatile u64 latent_entropy;
82529 +#endif
82530 +
82531 /*
82532 * Read access to zone->managed_pages is safe because it's unsigned long,
82533 * but we still need to serialize writers. Currently all callers of
82534 @@ -760,6 +784,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
82535 set_page_count(p, 0);
82536 }
82537
82538 +#ifdef CONFIG_PAX_LATENT_ENTROPY
82539 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
82540 + u64 hash = 0;
82541 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
82542 + const u64 *data = lowmem_page_address(page);
82543 +
82544 + for (index = 0; index < end; index++)
82545 + hash ^= hash + data[index];
82546 + latent_entropy ^= hash;
82547 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
82548 + }
82549 +#endif
82550 +
82551 page_zone(page)->managed_pages += 1 << order;
82552 set_page_refcounted(page);
82553 __free_pages(page, order);
82554 @@ -869,8 +906,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
82555 arch_alloc_page(page, order);
82556 kernel_map_pages(page, 1 << order, 1);
82557
82558 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
82559 if (gfp_flags & __GFP_ZERO)
82560 prep_zero_page(page, order, gfp_flags);
82561 +#endif
82562
82563 if (order && (gfp_flags & __GFP_COMP))
82564 prep_compound_page(page, order);
82565 diff --git a/mm/percpu.c b/mm/percpu.c
82566 index 8c8e08f..73a5cda 100644
82567 --- a/mm/percpu.c
82568 +++ b/mm/percpu.c
82569 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
82570 static unsigned int pcpu_high_unit_cpu __read_mostly;
82571
82572 /* the address of the first chunk which starts with the kernel static area */
82573 -void *pcpu_base_addr __read_mostly;
82574 +void *pcpu_base_addr __read_only;
82575 EXPORT_SYMBOL_GPL(pcpu_base_addr);
82576
82577 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
82578 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
82579 index fd26d04..0cea1b0 100644
82580 --- a/mm/process_vm_access.c
82581 +++ b/mm/process_vm_access.c
82582 @@ -13,6 +13,7 @@
82583 #include <linux/uio.h>
82584 #include <linux/sched.h>
82585 #include <linux/highmem.h>
82586 +#include <linux/security.h>
82587 #include <linux/ptrace.h>
82588 #include <linux/slab.h>
82589 #include <linux/syscalls.h>
82590 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
82591 size_t iov_l_curr_offset = 0;
82592 ssize_t iov_len;
82593
82594 + return -ENOSYS; // PaX: until properly audited
82595 +
82596 /*
82597 * Work out how many pages of struct pages we're going to need
82598 * when eventually calling get_user_pages
82599 */
82600 for (i = 0; i < riovcnt; i++) {
82601 iov_len = rvec[i].iov_len;
82602 - if (iov_len > 0) {
82603 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
82604 - + iov_len)
82605 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
82606 - / PAGE_SIZE + 1;
82607 - nr_pages = max(nr_pages, nr_pages_iov);
82608 - }
82609 + if (iov_len <= 0)
82610 + continue;
82611 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
82612 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
82613 + nr_pages = max(nr_pages, nr_pages_iov);
82614 }
82615
82616 if (nr_pages == 0)
82617 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
82618 goto free_proc_pages;
82619 }
82620
82621 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
82622 + rc = -EPERM;
82623 + goto put_task_struct;
82624 + }
82625 +
82626 mm = mm_access(task, PTRACE_MODE_ATTACH);
82627 if (!mm || IS_ERR(mm)) {
82628 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
82629 diff --git a/mm/rmap.c b/mm/rmap.c
82630 index 807c96b..0e05279 100644
82631 --- a/mm/rmap.c
82632 +++ b/mm/rmap.c
82633 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
82634 struct anon_vma *anon_vma = vma->anon_vma;
82635 struct anon_vma_chain *avc;
82636
82637 +#ifdef CONFIG_PAX_SEGMEXEC
82638 + struct anon_vma_chain *avc_m = NULL;
82639 +#endif
82640 +
82641 might_sleep();
82642 if (unlikely(!anon_vma)) {
82643 struct mm_struct *mm = vma->vm_mm;
82644 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
82645 if (!avc)
82646 goto out_enomem;
82647
82648 +#ifdef CONFIG_PAX_SEGMEXEC
82649 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
82650 + if (!avc_m)
82651 + goto out_enomem_free_avc;
82652 +#endif
82653 +
82654 anon_vma = find_mergeable_anon_vma(vma);
82655 allocated = NULL;
82656 if (!anon_vma) {
82657 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
82658 /* page_table_lock to protect against threads */
82659 spin_lock(&mm->page_table_lock);
82660 if (likely(!vma->anon_vma)) {
82661 +
82662 +#ifdef CONFIG_PAX_SEGMEXEC
82663 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
82664 +
82665 + if (vma_m) {
82666 + BUG_ON(vma_m->anon_vma);
82667 + vma_m->anon_vma = anon_vma;
82668 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
82669 + avc_m = NULL;
82670 + }
82671 +#endif
82672 +
82673 vma->anon_vma = anon_vma;
82674 anon_vma_chain_link(vma, avc, anon_vma);
82675 allocated = NULL;
82676 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
82677
82678 if (unlikely(allocated))
82679 put_anon_vma(allocated);
82680 +
82681 +#ifdef CONFIG_PAX_SEGMEXEC
82682 + if (unlikely(avc_m))
82683 + anon_vma_chain_free(avc_m);
82684 +#endif
82685 +
82686 if (unlikely(avc))
82687 anon_vma_chain_free(avc);
82688 }
82689 return 0;
82690
82691 out_enomem_free_avc:
82692 +
82693 +#ifdef CONFIG_PAX_SEGMEXEC
82694 + if (avc_m)
82695 + anon_vma_chain_free(avc_m);
82696 +#endif
82697 +
82698 anon_vma_chain_free(avc);
82699 out_enomem:
82700 return -ENOMEM;
82701 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
82702 * Attach the anon_vmas from src to dst.
82703 * Returns 0 on success, -ENOMEM on failure.
82704 */
82705 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
82706 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
82707 {
82708 struct anon_vma_chain *avc, *pavc;
82709 struct anon_vma *root = NULL;
82710 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
82711 * the corresponding VMA in the parent process is attached to.
82712 * Returns 0 on success, non-zero on failure.
82713 */
82714 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
82715 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
82716 {
82717 struct anon_vma_chain *avc;
82718 struct anon_vma *anon_vma;
82719 diff --git a/mm/shmem.c b/mm/shmem.c
82720 index 1c44af7..cefe9a6 100644
82721 --- a/mm/shmem.c
82722 +++ b/mm/shmem.c
82723 @@ -31,7 +31,7 @@
82724 #include <linux/export.h>
82725 #include <linux/swap.h>
82726
82727 -static struct vfsmount *shm_mnt;
82728 +struct vfsmount *shm_mnt;
82729
82730 #ifdef CONFIG_SHMEM
82731 /*
82732 @@ -75,7 +75,7 @@ static struct vfsmount *shm_mnt;
82733 #define BOGO_DIRENT_SIZE 20
82734
82735 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
82736 -#define SHORT_SYMLINK_LEN 128
82737 +#define SHORT_SYMLINK_LEN 64
82738
82739 /*
82740 * shmem_fallocate and shmem_writepage communicate via inode->i_private
82741 @@ -2201,6 +2201,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
82742 static int shmem_xattr_validate(const char *name)
82743 {
82744 struct { const char *prefix; size_t len; } arr[] = {
82745 +
82746 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
82747 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
82748 +#endif
82749 +
82750 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
82751 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
82752 };
82753 @@ -2256,6 +2261,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
82754 if (err)
82755 return err;
82756
82757 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
82758 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
82759 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
82760 + return -EOPNOTSUPP;
82761 + if (size > 8)
82762 + return -EINVAL;
82763 + }
82764 +#endif
82765 +
82766 return simple_xattr_set(&info->xattrs, name, value, size, flags);
82767 }
82768
82769 @@ -2568,8 +2582,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
82770 int err = -ENOMEM;
82771
82772 /* Round up to L1_CACHE_BYTES to resist false sharing */
82773 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
82774 - L1_CACHE_BYTES), GFP_KERNEL);
82775 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
82776 if (!sbinfo)
82777 return -ENOMEM;
82778
82779 diff --git a/mm/slab.c b/mm/slab.c
82780 index 856e4a1..fafb820 100644
82781 --- a/mm/slab.c
82782 +++ b/mm/slab.c
82783 @@ -306,7 +306,7 @@ struct kmem_list3 {
82784 * Need this for bootstrapping a per node allocator.
82785 */
82786 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
82787 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
82788 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
82789 #define CACHE_CACHE 0
82790 #define SIZE_AC MAX_NUMNODES
82791 #define SIZE_L3 (2 * MAX_NUMNODES)
82792 @@ -407,10 +407,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
82793 if ((x)->max_freeable < i) \
82794 (x)->max_freeable = i; \
82795 } while (0)
82796 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
82797 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
82798 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
82799 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
82800 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
82801 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
82802 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
82803 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
82804 #else
82805 #define STATS_INC_ACTIVE(x) do { } while (0)
82806 #define STATS_DEC_ACTIVE(x) do { } while (0)
82807 @@ -518,7 +518,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
82808 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
82809 */
82810 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
82811 - const struct slab *slab, void *obj)
82812 + const struct slab *slab, const void *obj)
82813 {
82814 u32 offset = (obj - slab->s_mem);
82815 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
82816 @@ -539,12 +539,13 @@ EXPORT_SYMBOL(malloc_sizes);
82817 struct cache_names {
82818 char *name;
82819 char *name_dma;
82820 + char *name_usercopy;
82821 };
82822
82823 static struct cache_names __initdata cache_names[] = {
82824 -#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
82825 +#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)", .name_usercopy = "size-" #x "(USERCOPY)" },
82826 #include <linux/kmalloc_sizes.h>
82827 - {NULL,}
82828 + {NULL}
82829 #undef CACHE
82830 };
82831
82832 @@ -729,6 +730,12 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
82833 if (unlikely(gfpflags & GFP_DMA))
82834 return csizep->cs_dmacachep;
82835 #endif
82836 +
82837 +#ifdef CONFIG_PAX_USERCOPY_SLABS
82838 + if (unlikely(gfpflags & GFP_USERCOPY))
82839 + return csizep->cs_usercopycachep;
82840 +#endif
82841 +
82842 return csizep->cs_cachep;
82843 }
82844
82845 @@ -1482,7 +1489,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
82846 return notifier_from_errno(err);
82847 }
82848
82849 -static struct notifier_block __cpuinitdata cpucache_notifier = {
82850 +static struct notifier_block cpucache_notifier = {
82851 &cpuup_callback, NULL, 0
82852 };
82853
82854 @@ -1667,12 +1674,12 @@ void __init kmem_cache_init(void)
82855 */
82856
82857 sizes[INDEX_AC].cs_cachep = create_kmalloc_cache(names[INDEX_AC].name,
82858 - sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS);
82859 + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
82860
82861 if (INDEX_AC != INDEX_L3)
82862 sizes[INDEX_L3].cs_cachep =
82863 create_kmalloc_cache(names[INDEX_L3].name,
82864 - sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS);
82865 + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
82866
82867 slab_early_init = 0;
82868
82869 @@ -1686,13 +1693,20 @@ void __init kmem_cache_init(void)
82870 */
82871 if (!sizes->cs_cachep)
82872 sizes->cs_cachep = create_kmalloc_cache(names->name,
82873 - sizes->cs_size, ARCH_KMALLOC_FLAGS);
82874 + sizes->cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
82875
82876 #ifdef CONFIG_ZONE_DMA
82877 sizes->cs_dmacachep = create_kmalloc_cache(
82878 names->name_dma, sizes->cs_size,
82879 SLAB_CACHE_DMA|ARCH_KMALLOC_FLAGS);
82880 #endif
82881 +
82882 +#ifdef CONFIG_PAX_USERCOPY_SLABS
82883 + sizes->cs_usercopycachep = create_kmalloc_cache(
82884 + names->name_usercopy, sizes->cs_size,
82885 + ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
82886 +#endif
82887 +
82888 sizes++;
82889 names++;
82890 }
82891 @@ -3924,6 +3938,7 @@ void kfree(const void *objp)
82892
82893 if (unlikely(ZERO_OR_NULL_PTR(objp)))
82894 return;
82895 + VM_BUG_ON(!virt_addr_valid(objp));
82896 local_irq_save(flags);
82897 kfree_debugcheck(objp);
82898 c = virt_to_cache(objp);
82899 @@ -4365,10 +4380,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
82900 }
82901 /* cpu stats */
82902 {
82903 - unsigned long allochit = atomic_read(&cachep->allochit);
82904 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
82905 - unsigned long freehit = atomic_read(&cachep->freehit);
82906 - unsigned long freemiss = atomic_read(&cachep->freemiss);
82907 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
82908 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
82909 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
82910 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
82911
82912 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
82913 allochit, allocmiss, freehit, freemiss);
82914 @@ -4600,13 +4615,71 @@ static const struct file_operations proc_slabstats_operations = {
82915 static int __init slab_proc_init(void)
82916 {
82917 #ifdef CONFIG_DEBUG_SLAB_LEAK
82918 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
82919 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
82920 #endif
82921 return 0;
82922 }
82923 module_init(slab_proc_init);
82924 #endif
82925
82926 +bool is_usercopy_object(const void *ptr)
82927 +{
82928 + struct page *page;
82929 + struct kmem_cache *cachep;
82930 +
82931 + if (ZERO_OR_NULL_PTR(ptr))
82932 + return false;
82933 +
82934 + if (!slab_is_available())
82935 + return false;
82936 +
82937 + if (!virt_addr_valid(ptr))
82938 + return false;
82939 +
82940 + page = virt_to_head_page(ptr);
82941 +
82942 + if (!PageSlab(page))
82943 + return false;
82944 +
82945 + cachep = page->slab_cache;
82946 + return cachep->flags & SLAB_USERCOPY;
82947 +}
82948 +
82949 +#ifdef CONFIG_PAX_USERCOPY
82950 +const char *check_heap_object(const void *ptr, unsigned long n)
82951 +{
82952 + struct page *page;
82953 + struct kmem_cache *cachep;
82954 + struct slab *slabp;
82955 + unsigned int objnr;
82956 + unsigned long offset;
82957 +
82958 + if (ZERO_OR_NULL_PTR(ptr))
82959 + return "<null>";
82960 +
82961 + if (!virt_addr_valid(ptr))
82962 + return NULL;
82963 +
82964 + page = virt_to_head_page(ptr);
82965 +
82966 + if (!PageSlab(page))
82967 + return NULL;
82968 +
82969 + cachep = page->slab_cache;
82970 + if (!(cachep->flags & SLAB_USERCOPY))
82971 + return cachep->name;
82972 +
82973 + slabp = page->slab_page;
82974 + objnr = obj_to_index(cachep, slabp, ptr);
82975 + BUG_ON(objnr >= cachep->num);
82976 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
82977 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
82978 + return NULL;
82979 +
82980 + return cachep->name;
82981 +}
82982 +#endif
82983 +
82984 /**
82985 * ksize - get the actual amount of memory allocated for a given object
82986 * @objp: Pointer to the object
82987 diff --git a/mm/slab.h b/mm/slab.h
82988 index 34a98d6..73633d1 100644
82989 --- a/mm/slab.h
82990 +++ b/mm/slab.h
82991 @@ -58,7 +58,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
82992
82993 /* Legal flag mask for kmem_cache_create(), for various configurations */
82994 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
82995 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
82996 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
82997
82998 #if defined(CONFIG_DEBUG_SLAB)
82999 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
83000 @@ -220,6 +220,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
83001 return s;
83002
83003 page = virt_to_head_page(x);
83004 +
83005 + BUG_ON(!PageSlab(page));
83006 +
83007 cachep = page->slab_cache;
83008 if (slab_equal_or_root(cachep, s))
83009 return cachep;
83010 diff --git a/mm/slab_common.c b/mm/slab_common.c
83011 index 3f3cd97..93b0236 100644
83012 --- a/mm/slab_common.c
83013 +++ b/mm/slab_common.c
83014 @@ -22,7 +22,7 @@
83015
83016 #include "slab.h"
83017
83018 -enum slab_state slab_state;
83019 +enum slab_state slab_state __read_only;
83020 LIST_HEAD(slab_caches);
83021 DEFINE_MUTEX(slab_mutex);
83022 struct kmem_cache *kmem_cache;
83023 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
83024
83025 err = __kmem_cache_create(s, flags);
83026 if (!err) {
83027 - s->refcount = 1;
83028 + atomic_set(&s->refcount, 1);
83029 list_add(&s->list, &slab_caches);
83030 memcg_cache_list_add(memcg, s);
83031 } else {
83032 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
83033
83034 get_online_cpus();
83035 mutex_lock(&slab_mutex);
83036 - s->refcount--;
83037 - if (!s->refcount) {
83038 + if (atomic_dec_and_test(&s->refcount)) {
83039 list_del(&s->list);
83040
83041 if (!__kmem_cache_shutdown(s)) {
83042 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
83043 panic("Creation of kmalloc slab %s size=%zd failed. Reason %d\n",
83044 name, size, err);
83045
83046 - s->refcount = -1; /* Exempt from merging for now */
83047 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
83048 }
83049
83050 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
83051 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
83052
83053 create_boot_cache(s, name, size, flags);
83054 list_add(&s->list, &slab_caches);
83055 - s->refcount = 1;
83056 + atomic_set(&s->refcount, 1);
83057 return s;
83058 }
83059
83060 diff --git a/mm/slob.c b/mm/slob.c
83061 index eeed4a0..6ee34ec 100644
83062 --- a/mm/slob.c
83063 +++ b/mm/slob.c
83064 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
83065 /*
83066 * Return the size of a slob block.
83067 */
83068 -static slobidx_t slob_units(slob_t *s)
83069 +static slobidx_t slob_units(const slob_t *s)
83070 {
83071 if (s->units > 0)
83072 return s->units;
83073 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
83074 /*
83075 * Return the next free slob block pointer after this one.
83076 */
83077 -static slob_t *slob_next(slob_t *s)
83078 +static slob_t *slob_next(const slob_t *s)
83079 {
83080 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
83081 slobidx_t next;
83082 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
83083 /*
83084 * Returns true if s is the last free block in its page.
83085 */
83086 -static int slob_last(slob_t *s)
83087 +static int slob_last(const slob_t *s)
83088 {
83089 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
83090 }
83091
83092 -static void *slob_new_pages(gfp_t gfp, int order, int node)
83093 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
83094 {
83095 - void *page;
83096 + struct page *page;
83097
83098 #ifdef CONFIG_NUMA
83099 if (node != NUMA_NO_NODE)
83100 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
83101 if (!page)
83102 return NULL;
83103
83104 - return page_address(page);
83105 + __SetPageSlab(page);
83106 + return page;
83107 }
83108
83109 -static void slob_free_pages(void *b, int order)
83110 +static void slob_free_pages(struct page *sp, int order)
83111 {
83112 if (current->reclaim_state)
83113 current->reclaim_state->reclaimed_slab += 1 << order;
83114 - free_pages((unsigned long)b, order);
83115 + __ClearPageSlab(sp);
83116 + reset_page_mapcount(sp);
83117 + sp->private = 0;
83118 + __free_pages(sp, order);
83119 }
83120
83121 /*
83122 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
83123
83124 /* Not enough space: must allocate a new page */
83125 if (!b) {
83126 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
83127 - if (!b)
83128 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
83129 + if (!sp)
83130 return NULL;
83131 - sp = virt_to_page(b);
83132 - __SetPageSlab(sp);
83133 + b = page_address(sp);
83134
83135 spin_lock_irqsave(&slob_lock, flags);
83136 sp->units = SLOB_UNITS(PAGE_SIZE);
83137 sp->freelist = b;
83138 + sp->private = 0;
83139 INIT_LIST_HEAD(&sp->list);
83140 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
83141 set_slob_page_free(sp, slob_list);
83142 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
83143 if (slob_page_free(sp))
83144 clear_slob_page_free(sp);
83145 spin_unlock_irqrestore(&slob_lock, flags);
83146 - __ClearPageSlab(sp);
83147 - page_mapcount_reset(sp);
83148 - slob_free_pages(b, 0);
83149 + slob_free_pages(sp, 0);
83150 return;
83151 }
83152
83153 @@ -424,11 +426,10 @@ out:
83154 */
83155
83156 static __always_inline void *
83157 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
83158 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
83159 {
83160 - unsigned int *m;
83161 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83162 - void *ret;
83163 + slob_t *m;
83164 + void *ret = NULL;
83165
83166 gfp &= gfp_allowed_mask;
83167
83168 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
83169
83170 if (!m)
83171 return NULL;
83172 - *m = size;
83173 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
83174 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
83175 + m[0].units = size;
83176 + m[1].units = align;
83177 ret = (void *)m + align;
83178
83179 trace_kmalloc_node(caller, ret,
83180 size, size + align, gfp, node);
83181 } else {
83182 unsigned int order = get_order(size);
83183 + struct page *page;
83184
83185 if (likely(order))
83186 gfp |= __GFP_COMP;
83187 - ret = slob_new_pages(gfp, order, node);
83188 + page = slob_new_pages(gfp, order, node);
83189 + if (page) {
83190 + ret = page_address(page);
83191 + page->private = size;
83192 + }
83193
83194 trace_kmalloc_node(caller, ret,
83195 size, PAGE_SIZE << order, gfp, node);
83196 }
83197
83198 - kmemleak_alloc(ret, size, 1, gfp);
83199 + return ret;
83200 +}
83201 +
83202 +static __always_inline void *
83203 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
83204 +{
83205 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83206 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
83207 +
83208 + if (!ZERO_OR_NULL_PTR(ret))
83209 + kmemleak_alloc(ret, size, 1, gfp);
83210 return ret;
83211 }
83212
83213 @@ -493,34 +512,112 @@ void kfree(const void *block)
83214 return;
83215 kmemleak_free(block);
83216
83217 + VM_BUG_ON(!virt_addr_valid(block));
83218 sp = virt_to_page(block);
83219 - if (PageSlab(sp)) {
83220 + VM_BUG_ON(!PageSlab(sp));
83221 + if (!sp->private) {
83222 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83223 - unsigned int *m = (unsigned int *)(block - align);
83224 - slob_free(m, *m + align);
83225 - } else
83226 + slob_t *m = (slob_t *)(block - align);
83227 + slob_free(m, m[0].units + align);
83228 + } else {
83229 + __ClearPageSlab(sp);
83230 + reset_page_mapcount(sp);
83231 + sp->private = 0;
83232 __free_pages(sp, compound_order(sp));
83233 + }
83234 }
83235 EXPORT_SYMBOL(kfree);
83236
83237 +bool is_usercopy_object(const void *ptr)
83238 +{
83239 + if (!slab_is_available())
83240 + return false;
83241 +
83242 + // PAX: TODO
83243 +
83244 + return false;
83245 +}
83246 +
83247 +#ifdef CONFIG_PAX_USERCOPY
83248 +const char *check_heap_object(const void *ptr, unsigned long n)
83249 +{
83250 + struct page *page;
83251 + const slob_t *free;
83252 + const void *base;
83253 + unsigned long flags;
83254 +
83255 + if (ZERO_OR_NULL_PTR(ptr))
83256 + return "<null>";
83257 +
83258 + if (!virt_addr_valid(ptr))
83259 + return NULL;
83260 +
83261 + page = virt_to_head_page(ptr);
83262 + if (!PageSlab(page))
83263 + return NULL;
83264 +
83265 + if (page->private) {
83266 + base = page;
83267 + if (base <= ptr && n <= page->private - (ptr - base))
83268 + return NULL;
83269 + return "<slob>";
83270 + }
83271 +
83272 + /* some tricky double walking to find the chunk */
83273 + spin_lock_irqsave(&slob_lock, flags);
83274 + base = (void *)((unsigned long)ptr & PAGE_MASK);
83275 + free = page->freelist;
83276 +
83277 + while (!slob_last(free) && (void *)free <= ptr) {
83278 + base = free + slob_units(free);
83279 + free = slob_next(free);
83280 + }
83281 +
83282 + while (base < (void *)free) {
83283 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
83284 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
83285 + int offset;
83286 +
83287 + if (ptr < base + align)
83288 + break;
83289 +
83290 + offset = ptr - base - align;
83291 + if (offset >= m) {
83292 + base += size;
83293 + continue;
83294 + }
83295 +
83296 + if (n > m - offset)
83297 + break;
83298 +
83299 + spin_unlock_irqrestore(&slob_lock, flags);
83300 + return NULL;
83301 + }
83302 +
83303 + spin_unlock_irqrestore(&slob_lock, flags);
83304 + return "<slob>";
83305 +}
83306 +#endif
83307 +
83308 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
83309 size_t ksize(const void *block)
83310 {
83311 struct page *sp;
83312 int align;
83313 - unsigned int *m;
83314 + slob_t *m;
83315
83316 BUG_ON(!block);
83317 if (unlikely(block == ZERO_SIZE_PTR))
83318 return 0;
83319
83320 sp = virt_to_page(block);
83321 - if (unlikely(!PageSlab(sp)))
83322 - return PAGE_SIZE << compound_order(sp);
83323 + VM_BUG_ON(!PageSlab(sp));
83324 + if (sp->private)
83325 + return sp->private;
83326
83327 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
83328 - m = (unsigned int *)(block - align);
83329 - return SLOB_UNITS(*m) * SLOB_UNIT;
83330 + m = (slob_t *)(block - align);
83331 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
83332 }
83333 EXPORT_SYMBOL(ksize);
83334
83335 @@ -536,23 +633,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
83336
83337 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
83338 {
83339 - void *b;
83340 + void *b = NULL;
83341
83342 flags &= gfp_allowed_mask;
83343
83344 lockdep_trace_alloc(flags);
83345
83346 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83347 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
83348 +#else
83349 if (c->size < PAGE_SIZE) {
83350 b = slob_alloc(c->size, flags, c->align, node);
83351 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
83352 SLOB_UNITS(c->size) * SLOB_UNIT,
83353 flags, node);
83354 } else {
83355 - b = slob_new_pages(flags, get_order(c->size), node);
83356 + struct page *sp;
83357 +
83358 + sp = slob_new_pages(flags, get_order(c->size), node);
83359 + if (sp) {
83360 + b = page_address(sp);
83361 + sp->private = c->size;
83362 + }
83363 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
83364 PAGE_SIZE << get_order(c->size),
83365 flags, node);
83366 }
83367 +#endif
83368
83369 if (c->ctor)
83370 c->ctor(b);
83371 @@ -564,10 +671,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
83372
83373 static void __kmem_cache_free(void *b, int size)
83374 {
83375 - if (size < PAGE_SIZE)
83376 + struct page *sp;
83377 +
83378 + sp = virt_to_page(b);
83379 + BUG_ON(!PageSlab(sp));
83380 + if (!sp->private)
83381 slob_free(b, size);
83382 else
83383 - slob_free_pages(b, get_order(size));
83384 + slob_free_pages(sp, get_order(size));
83385 }
83386
83387 static void kmem_rcu_free(struct rcu_head *head)
83388 @@ -580,17 +691,31 @@ static void kmem_rcu_free(struct rcu_head *head)
83389
83390 void kmem_cache_free(struct kmem_cache *c, void *b)
83391 {
83392 + int size = c->size;
83393 +
83394 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83395 + if (size + c->align < PAGE_SIZE) {
83396 + size += c->align;
83397 + b -= c->align;
83398 + }
83399 +#endif
83400 +
83401 kmemleak_free_recursive(b, c->flags);
83402 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
83403 struct slob_rcu *slob_rcu;
83404 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
83405 - slob_rcu->size = c->size;
83406 + slob_rcu = b + (size - sizeof(struct slob_rcu));
83407 + slob_rcu->size = size;
83408 call_rcu(&slob_rcu->head, kmem_rcu_free);
83409 } else {
83410 - __kmem_cache_free(b, c->size);
83411 + __kmem_cache_free(b, size);
83412 }
83413
83414 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83415 + trace_kfree(_RET_IP_, b);
83416 +#else
83417 trace_kmem_cache_free(_RET_IP_, b);
83418 +#endif
83419 +
83420 }
83421 EXPORT_SYMBOL(kmem_cache_free);
83422
83423 diff --git a/mm/slub.c b/mm/slub.c
83424 index 4aec537..a64753d 100644
83425 --- a/mm/slub.c
83426 +++ b/mm/slub.c
83427 @@ -197,7 +197,7 @@ struct track {
83428
83429 enum track_item { TRACK_ALLOC, TRACK_FREE };
83430
83431 -#ifdef CONFIG_SYSFS
83432 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83433 static int sysfs_slab_add(struct kmem_cache *);
83434 static int sysfs_slab_alias(struct kmem_cache *, const char *);
83435 static void sysfs_slab_remove(struct kmem_cache *);
83436 @@ -518,7 +518,7 @@ static void print_track(const char *s, struct track *t)
83437 if (!t->addr)
83438 return;
83439
83440 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
83441 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
83442 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
83443 #ifdef CONFIG_STACKTRACE
83444 {
83445 @@ -2653,7 +2653,7 @@ static int slub_min_objects;
83446 * Merge control. If this is set then no merging of slab caches will occur.
83447 * (Could be removed. This was introduced to pacify the merge skeptics.)
83448 */
83449 -static int slub_nomerge;
83450 +static int slub_nomerge = 1;
83451
83452 /*
83453 * Calculate the order of allocation given an slab object size.
83454 @@ -3181,6 +3181,10 @@ EXPORT_SYMBOL(kmalloc_caches);
83455 static struct kmem_cache *kmalloc_dma_caches[SLUB_PAGE_SHIFT];
83456 #endif
83457
83458 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83459 +static struct kmem_cache *kmalloc_usercopy_caches[SLUB_PAGE_SHIFT];
83460 +#endif
83461 +
83462 static int __init setup_slub_min_order(char *str)
83463 {
83464 get_option(&str, &slub_min_order);
83465 @@ -3272,6 +3276,13 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
83466 return kmalloc_dma_caches[index];
83467
83468 #endif
83469 +
83470 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83471 + if (flags & SLAB_USERCOPY)
83472 + return kmalloc_usercopy_caches[index];
83473 +
83474 +#endif
83475 +
83476 return kmalloc_caches[index];
83477 }
83478
83479 @@ -3340,6 +3351,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
83480 EXPORT_SYMBOL(__kmalloc_node);
83481 #endif
83482
83483 +bool is_usercopy_object(const void *ptr)
83484 +{
83485 + struct page *page;
83486 + struct kmem_cache *s;
83487 +
83488 + if (ZERO_OR_NULL_PTR(ptr))
83489 + return false;
83490 +
83491 + if (!slab_is_available())
83492 + return false;
83493 +
83494 + if (!virt_addr_valid(ptr))
83495 + return false;
83496 +
83497 + page = virt_to_head_page(ptr);
83498 +
83499 + if (!PageSlab(page))
83500 + return false;
83501 +
83502 + s = page->slab_cache;
83503 + return s->flags & SLAB_USERCOPY;
83504 +}
83505 +
83506 +#ifdef CONFIG_PAX_USERCOPY
83507 +const char *check_heap_object(const void *ptr, unsigned long n)
83508 +{
83509 + struct page *page;
83510 + struct kmem_cache *s;
83511 + unsigned long offset;
83512 +
83513 + if (ZERO_OR_NULL_PTR(ptr))
83514 + return "<null>";
83515 +
83516 + if (!virt_addr_valid(ptr))
83517 + return NULL;
83518 +
83519 + page = virt_to_head_page(ptr);
83520 +
83521 + if (!PageSlab(page))
83522 + return NULL;
83523 +
83524 + s = page->slab_cache;
83525 + if (!(s->flags & SLAB_USERCOPY))
83526 + return s->name;
83527 +
83528 + offset = (ptr - page_address(page)) % s->size;
83529 + if (offset <= s->object_size && n <= s->object_size - offset)
83530 + return NULL;
83531 +
83532 + return s->name;
83533 +}
83534 +#endif
83535 +
83536 size_t ksize(const void *object)
83537 {
83538 struct page *page;
83539 @@ -3404,6 +3468,7 @@ void kfree(const void *x)
83540 if (unlikely(ZERO_OR_NULL_PTR(x)))
83541 return;
83542
83543 + VM_BUG_ON(!virt_addr_valid(x));
83544 page = virt_to_head_page(x);
83545 if (unlikely(!PageSlab(page))) {
83546 BUG_ON(!PageCompound(page));
83547 @@ -3712,17 +3777,17 @@ void __init kmem_cache_init(void)
83548
83549 /* Caches that are not of the two-to-the-power-of size */
83550 if (KMALLOC_MIN_SIZE <= 32) {
83551 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
83552 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
83553 caches++;
83554 }
83555
83556 if (KMALLOC_MIN_SIZE <= 64) {
83557 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
83558 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
83559 caches++;
83560 }
83561
83562 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
83563 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
83564 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
83565 caches++;
83566 }
83567
83568 @@ -3764,6 +3829,22 @@ void __init kmem_cache_init(void)
83569 }
83570 }
83571 #endif
83572 +
83573 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83574 + for (i = 0; i < SLUB_PAGE_SHIFT; i++) {
83575 + struct kmem_cache *s = kmalloc_caches[i];
83576 +
83577 + if (s && s->size) {
83578 + char *name = kasprintf(GFP_NOWAIT,
83579 + "usercopy-kmalloc-%d", s->object_size);
83580 +
83581 + BUG_ON(!name);
83582 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(name,
83583 + s->object_size, SLAB_USERCOPY);
83584 + }
83585 + }
83586 +#endif
83587 +
83588 printk(KERN_INFO
83589 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
83590 " CPUs=%d, Nodes=%d\n",
83591 @@ -3790,7 +3871,7 @@ static int slab_unmergeable(struct kmem_cache *s)
83592 /*
83593 * We may have set a slab to be unmergeable during bootstrap.
83594 */
83595 - if (s->refcount < 0)
83596 + if (atomic_read(&s->refcount) < 0)
83597 return 1;
83598
83599 return 0;
83600 @@ -3848,7 +3929,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
83601
83602 s = find_mergeable(memcg, size, align, flags, name, ctor);
83603 if (s) {
83604 - s->refcount++;
83605 + atomic_inc(&s->refcount);
83606 /*
83607 * Adjust the object sizes so that we clear
83608 * the complete object on kzalloc.
83609 @@ -3857,7 +3938,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
83610 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
83611
83612 if (sysfs_slab_alias(s, name)) {
83613 - s->refcount--;
83614 + atomic_dec(&s->refcount);
83615 s = NULL;
83616 }
83617 }
83618 @@ -3919,7 +4000,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
83619 return NOTIFY_OK;
83620 }
83621
83622 -static struct notifier_block __cpuinitdata slab_notifier = {
83623 +static struct notifier_block slab_notifier = {
83624 .notifier_call = slab_cpuup_callback
83625 };
83626
83627 @@ -3977,7 +4058,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
83628 }
83629 #endif
83630
83631 -#ifdef CONFIG_SYSFS
83632 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83633 static int count_inuse(struct page *page)
83634 {
83635 return page->inuse;
83636 @@ -4364,12 +4445,12 @@ static void resiliency_test(void)
83637 validate_slab_cache(kmalloc_caches[9]);
83638 }
83639 #else
83640 -#ifdef CONFIG_SYSFS
83641 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83642 static void resiliency_test(void) {};
83643 #endif
83644 #endif
83645
83646 -#ifdef CONFIG_SYSFS
83647 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83648 enum slab_stat_type {
83649 SL_ALL, /* All slabs */
83650 SL_PARTIAL, /* Only partially allocated slabs */
83651 @@ -4613,7 +4694,7 @@ SLAB_ATTR_RO(ctor);
83652
83653 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
83654 {
83655 - return sprintf(buf, "%d\n", s->refcount - 1);
83656 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
83657 }
83658 SLAB_ATTR_RO(aliases);
83659
83660 @@ -5266,6 +5347,7 @@ static char *create_unique_id(struct kmem_cache *s)
83661 return name;
83662 }
83663
83664 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83665 static int sysfs_slab_add(struct kmem_cache *s)
83666 {
83667 int err;
83668 @@ -5323,6 +5405,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
83669 kobject_del(&s->kobj);
83670 kobject_put(&s->kobj);
83671 }
83672 +#endif
83673
83674 /*
83675 * Need to buffer aliases during bootup until sysfs becomes
83676 @@ -5336,6 +5419,7 @@ struct saved_alias {
83677
83678 static struct saved_alias *alias_list;
83679
83680 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
83681 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
83682 {
83683 struct saved_alias *al;
83684 @@ -5358,6 +5442,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
83685 alias_list = al;
83686 return 0;
83687 }
83688 +#endif
83689
83690 static int __init slab_sysfs_init(void)
83691 {
83692 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
83693 index 1b7e22a..3fcd4f3 100644
83694 --- a/mm/sparse-vmemmap.c
83695 +++ b/mm/sparse-vmemmap.c
83696 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
83697 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
83698 if (!p)
83699 return NULL;
83700 - pud_populate(&init_mm, pud, p);
83701 + pud_populate_kernel(&init_mm, pud, p);
83702 }
83703 return pud;
83704 }
83705 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
83706 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
83707 if (!p)
83708 return NULL;
83709 - pgd_populate(&init_mm, pgd, p);
83710 + pgd_populate_kernel(&init_mm, pgd, p);
83711 }
83712 return pgd;
83713 }
83714 diff --git a/mm/sparse.c b/mm/sparse.c
83715 index 7ca6dc8..6472aa1 100644
83716 --- a/mm/sparse.c
83717 +++ b/mm/sparse.c
83718 @@ -783,7 +783,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
83719
83720 for (i = 0; i < PAGES_PER_SECTION; i++) {
83721 if (PageHWPoison(&memmap[i])) {
83722 - atomic_long_sub(1, &num_poisoned_pages);
83723 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
83724 ClearPageHWPoison(&memmap[i]);
83725 }
83726 }
83727 diff --git a/mm/swap.c b/mm/swap.c
83728 index 8a529a0..154ef26 100644
83729 --- a/mm/swap.c
83730 +++ b/mm/swap.c
83731 @@ -30,6 +30,7 @@
83732 #include <linux/backing-dev.h>
83733 #include <linux/memcontrol.h>
83734 #include <linux/gfp.h>
83735 +#include <linux/hugetlb.h>
83736
83737 #include "internal.h"
83738
83739 @@ -72,6 +73,8 @@ static void __put_compound_page(struct page *page)
83740
83741 __page_cache_release(page);
83742 dtor = get_compound_page_dtor(page);
83743 + if (!PageHuge(page))
83744 + BUG_ON(dtor != free_compound_page);
83745 (*dtor)(page);
83746 }
83747
83748 diff --git a/mm/swapfile.c b/mm/swapfile.c
83749 index a1f7772..9e982ac 100644
83750 --- a/mm/swapfile.c
83751 +++ b/mm/swapfile.c
83752 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
83753
83754 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
83755 /* Activity counter to indicate that a swapon or swapoff has occurred */
83756 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
83757 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
83758
83759 static inline unsigned char swap_count(unsigned char ent)
83760 {
83761 @@ -1683,7 +1683,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
83762 }
83763 filp_close(swap_file, NULL);
83764 err = 0;
83765 - atomic_inc(&proc_poll_event);
83766 + atomic_inc_unchecked(&proc_poll_event);
83767 wake_up_interruptible(&proc_poll_wait);
83768
83769 out_dput:
83770 @@ -1700,8 +1700,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
83771
83772 poll_wait(file, &proc_poll_wait, wait);
83773
83774 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
83775 - seq->poll_event = atomic_read(&proc_poll_event);
83776 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
83777 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
83778 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
83779 }
83780
83781 @@ -1799,7 +1799,7 @@ static int swaps_open(struct inode *inode, struct file *file)
83782 return ret;
83783
83784 seq = file->private_data;
83785 - seq->poll_event = atomic_read(&proc_poll_event);
83786 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
83787 return 0;
83788 }
83789
83790 @@ -2142,7 +2142,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
83791 (frontswap_map) ? "FS" : "");
83792
83793 mutex_unlock(&swapon_mutex);
83794 - atomic_inc(&proc_poll_event);
83795 + atomic_inc_unchecked(&proc_poll_event);
83796 wake_up_interruptible(&proc_poll_wait);
83797
83798 if (S_ISREG(inode->i_mode))
83799 diff --git a/mm/util.c b/mm/util.c
83800 index ab1424d..7c5bd5a 100644
83801 --- a/mm/util.c
83802 +++ b/mm/util.c
83803 @@ -294,6 +294,12 @@ done:
83804 void arch_pick_mmap_layout(struct mm_struct *mm)
83805 {
83806 mm->mmap_base = TASK_UNMAPPED_BASE;
83807 +
83808 +#ifdef CONFIG_PAX_RANDMMAP
83809 + if (mm->pax_flags & MF_PAX_RANDMMAP)
83810 + mm->mmap_base += mm->delta_mmap;
83811 +#endif
83812 +
83813 mm->get_unmapped_area = arch_get_unmapped_area;
83814 mm->unmap_area = arch_unmap_area;
83815 }
83816 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
83817 index 0f751f2..ef398a0 100644
83818 --- a/mm/vmalloc.c
83819 +++ b/mm/vmalloc.c
83820 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
83821
83822 pte = pte_offset_kernel(pmd, addr);
83823 do {
83824 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
83825 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
83826 +
83827 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
83828 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
83829 + BUG_ON(!pte_exec(*pte));
83830 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
83831 + continue;
83832 + }
83833 +#endif
83834 +
83835 + {
83836 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
83837 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
83838 + }
83839 } while (pte++, addr += PAGE_SIZE, addr != end);
83840 }
83841
83842 @@ -100,16 +111,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
83843 pte = pte_alloc_kernel(pmd, addr);
83844 if (!pte)
83845 return -ENOMEM;
83846 +
83847 + pax_open_kernel();
83848 do {
83849 struct page *page = pages[*nr];
83850
83851 - if (WARN_ON(!pte_none(*pte)))
83852 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
83853 + if (pgprot_val(prot) & _PAGE_NX)
83854 +#endif
83855 +
83856 + if (!pte_none(*pte)) {
83857 + pax_close_kernel();
83858 + WARN_ON(1);
83859 return -EBUSY;
83860 - if (WARN_ON(!page))
83861 + }
83862 + if (!page) {
83863 + pax_close_kernel();
83864 + WARN_ON(1);
83865 return -ENOMEM;
83866 + }
83867 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
83868 (*nr)++;
83869 } while (pte++, addr += PAGE_SIZE, addr != end);
83870 + pax_close_kernel();
83871 return 0;
83872 }
83873
83874 @@ -119,7 +143,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
83875 pmd_t *pmd;
83876 unsigned long next;
83877
83878 - pmd = pmd_alloc(&init_mm, pud, addr);
83879 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
83880 if (!pmd)
83881 return -ENOMEM;
83882 do {
83883 @@ -136,7 +160,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
83884 pud_t *pud;
83885 unsigned long next;
83886
83887 - pud = pud_alloc(&init_mm, pgd, addr);
83888 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
83889 if (!pud)
83890 return -ENOMEM;
83891 do {
83892 @@ -191,11 +215,20 @@ int is_vmalloc_or_module_addr(const void *x)
83893 * and fall back on vmalloc() if that fails. Others
83894 * just put it in the vmalloc space.
83895 */
83896 -#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
83897 +#ifdef CONFIG_MODULES
83898 +#ifdef MODULES_VADDR
83899 unsigned long addr = (unsigned long)x;
83900 if (addr >= MODULES_VADDR && addr < MODULES_END)
83901 return 1;
83902 #endif
83903 +
83904 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
83905 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
83906 + return 1;
83907 +#endif
83908 +
83909 +#endif
83910 +
83911 return is_vmalloc_addr(x);
83912 }
83913
83914 @@ -216,8 +249,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
83915
83916 if (!pgd_none(*pgd)) {
83917 pud_t *pud = pud_offset(pgd, addr);
83918 +#ifdef CONFIG_X86
83919 + if (!pud_large(*pud))
83920 +#endif
83921 if (!pud_none(*pud)) {
83922 pmd_t *pmd = pmd_offset(pud, addr);
83923 +#ifdef CONFIG_X86
83924 + if (!pmd_large(*pmd))
83925 +#endif
83926 if (!pmd_none(*pmd)) {
83927 pte_t *ptep, pte;
83928
83929 @@ -329,7 +368,7 @@ static void purge_vmap_area_lazy(void);
83930 * Allocate a region of KVA of the specified size and alignment, within the
83931 * vstart and vend.
83932 */
83933 -static struct vmap_area *alloc_vmap_area(unsigned long size,
83934 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
83935 unsigned long align,
83936 unsigned long vstart, unsigned long vend,
83937 int node, gfp_t gfp_mask)
83938 @@ -1328,6 +1367,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
83939 struct vm_struct *area;
83940
83941 BUG_ON(in_interrupt());
83942 +
83943 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
83944 + if (flags & VM_KERNEXEC) {
83945 + if (start != VMALLOC_START || end != VMALLOC_END)
83946 + return NULL;
83947 + start = (unsigned long)MODULES_EXEC_VADDR;
83948 + end = (unsigned long)MODULES_EXEC_END;
83949 + }
83950 +#endif
83951 +
83952 if (flags & VM_IOREMAP) {
83953 int bit = fls(size);
83954
83955 @@ -1569,6 +1618,11 @@ void *vmap(struct page **pages, unsigned int count,
83956 if (count > totalram_pages)
83957 return NULL;
83958
83959 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
83960 + if (!(pgprot_val(prot) & _PAGE_NX))
83961 + flags |= VM_KERNEXEC;
83962 +#endif
83963 +
83964 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
83965 __builtin_return_address(0));
83966 if (!area)
83967 @@ -1670,6 +1724,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
83968 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
83969 goto fail;
83970
83971 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
83972 + if (!(pgprot_val(prot) & _PAGE_NX))
83973 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
83974 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
83975 + else
83976 +#endif
83977 +
83978 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
83979 start, end, node, gfp_mask, caller);
83980 if (!area)
83981 @@ -1845,10 +1906,9 @@ EXPORT_SYMBOL(vzalloc_node);
83982 * For tight control over page level allocator and protection flags
83983 * use __vmalloc() instead.
83984 */
83985 -
83986 void *vmalloc_exec(unsigned long size)
83987 {
83988 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
83989 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
83990 NUMA_NO_NODE, __builtin_return_address(0));
83991 }
83992
83993 @@ -2139,6 +2199,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
83994 unsigned long uaddr = vma->vm_start;
83995 unsigned long usize = vma->vm_end - vma->vm_start;
83996
83997 + BUG_ON(vma->vm_mirror);
83998 +
83999 if ((PAGE_SIZE-1) & (unsigned long)addr)
84000 return -EINVAL;
84001
84002 @@ -2578,7 +2640,11 @@ static int s_show(struct seq_file *m, void *p)
84003 v->addr, v->addr + v->size, v->size);
84004
84005 if (v->caller)
84006 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84007 + seq_printf(m, " %pK", v->caller);
84008 +#else
84009 seq_printf(m, " %pS", v->caller);
84010 +#endif
84011
84012 if (v->nr_pages)
84013 seq_printf(m, " pages=%d", v->nr_pages);
84014 diff --git a/mm/vmstat.c b/mm/vmstat.c
84015 index e1d8ed1..253fa3c 100644
84016 --- a/mm/vmstat.c
84017 +++ b/mm/vmstat.c
84018 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
84019 *
84020 * vm_stat contains the global counters
84021 */
84022 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
84023 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
84024 EXPORT_SYMBOL(vm_stat);
84025
84026 #ifdef CONFIG_SMP
84027 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
84028 v = p->vm_stat_diff[i];
84029 p->vm_stat_diff[i] = 0;
84030 local_irq_restore(flags);
84031 - atomic_long_add(v, &zone->vm_stat[i]);
84032 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
84033 global_diff[i] += v;
84034 #ifdef CONFIG_NUMA
84035 /* 3 seconds idle till flush */
84036 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
84037
84038 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
84039 if (global_diff[i])
84040 - atomic_long_add(global_diff[i], &vm_stat[i]);
84041 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
84042 }
84043
84044 void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
84045 @@ -503,8 +503,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
84046 if (pset->vm_stat_diff[i]) {
84047 int v = pset->vm_stat_diff[i];
84048 pset->vm_stat_diff[i] = 0;
84049 - atomic_long_add(v, &zone->vm_stat[i]);
84050 - atomic_long_add(v, &vm_stat[i]);
84051 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
84052 + atomic_long_add_unchecked(v, &vm_stat[i]);
84053 }
84054 }
84055 #endif
84056 @@ -1224,7 +1224,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
84057 return NOTIFY_OK;
84058 }
84059
84060 -static struct notifier_block __cpuinitdata vmstat_notifier =
84061 +static struct notifier_block vmstat_notifier =
84062 { &vmstat_cpuup_callback, NULL, 0 };
84063 #endif
84064
84065 @@ -1239,10 +1239,20 @@ static int __init setup_vmstat(void)
84066 start_cpu_timer(cpu);
84067 #endif
84068 #ifdef CONFIG_PROC_FS
84069 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
84070 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
84071 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
84072 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
84073 + {
84074 + mode_t gr_mode = S_IRUGO;
84075 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84076 + gr_mode = S_IRUSR;
84077 +#endif
84078 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
84079 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
84080 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
84081 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
84082 +#else
84083 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
84084 +#endif
84085 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
84086 + }
84087 #endif
84088 return 0;
84089 }
84090 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
84091 index 85addcd..c429a13 100644
84092 --- a/net/8021q/vlan.c
84093 +++ b/net/8021q/vlan.c
84094 @@ -114,6 +114,13 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
84095 if (vlan_id)
84096 vlan_vid_del(real_dev, vlan_id);
84097
84098 + /* Take it out of our own structures, but be sure to interlock with
84099 + * HW accelerating devices or SW vlan input packet processing if
84100 + * VLAN is not 0 (leave it there for 802.1p).
84101 + */
84102 + if (vlan_id)
84103 + vlan_vid_del(real_dev, vlan_id);
84104 +
84105 /* Get rid of the vlan's reference to real_dev */
84106 dev_put(real_dev);
84107 }
84108 @@ -496,7 +503,7 @@ out:
84109 return NOTIFY_DONE;
84110 }
84111
84112 -static struct notifier_block vlan_notifier_block __read_mostly = {
84113 +static struct notifier_block vlan_notifier_block = {
84114 .notifier_call = vlan_device_event,
84115 };
84116
84117 @@ -571,8 +578,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
84118 err = -EPERM;
84119 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
84120 break;
84121 - if ((args.u.name_type >= 0) &&
84122 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
84123 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
84124 struct vlan_net *vn;
84125
84126 vn = net_generic(net, vlan_net_id);
84127 diff --git a/net/9p/mod.c b/net/9p/mod.c
84128 index 6ab36ae..6f1841b 100644
84129 --- a/net/9p/mod.c
84130 +++ b/net/9p/mod.c
84131 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
84132 void v9fs_register_trans(struct p9_trans_module *m)
84133 {
84134 spin_lock(&v9fs_trans_lock);
84135 - list_add_tail(&m->list, &v9fs_trans_list);
84136 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
84137 spin_unlock(&v9fs_trans_lock);
84138 }
84139 EXPORT_SYMBOL(v9fs_register_trans);
84140 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
84141 void v9fs_unregister_trans(struct p9_trans_module *m)
84142 {
84143 spin_lock(&v9fs_trans_lock);
84144 - list_del_init(&m->list);
84145 + pax_list_del_init((struct list_head *)&m->list);
84146 spin_unlock(&v9fs_trans_lock);
84147 }
84148 EXPORT_SYMBOL(v9fs_unregister_trans);
84149 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
84150 index 02efb25..41541a9 100644
84151 --- a/net/9p/trans_fd.c
84152 +++ b/net/9p/trans_fd.c
84153 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
84154 oldfs = get_fs();
84155 set_fs(get_ds());
84156 /* The cast to a user pointer is valid due to the set_fs() */
84157 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
84158 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
84159 set_fs(oldfs);
84160
84161 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
84162 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
84163 index 876fbe8..8bbea9f 100644
84164 --- a/net/atm/atm_misc.c
84165 +++ b/net/atm/atm_misc.c
84166 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
84167 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
84168 return 1;
84169 atm_return(vcc, truesize);
84170 - atomic_inc(&vcc->stats->rx_drop);
84171 + atomic_inc_unchecked(&vcc->stats->rx_drop);
84172 return 0;
84173 }
84174 EXPORT_SYMBOL(atm_charge);
84175 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
84176 }
84177 }
84178 atm_return(vcc, guess);
84179 - atomic_inc(&vcc->stats->rx_drop);
84180 + atomic_inc_unchecked(&vcc->stats->rx_drop);
84181 return NULL;
84182 }
84183 EXPORT_SYMBOL(atm_alloc_charge);
84184 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
84185
84186 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
84187 {
84188 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
84189 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
84190 __SONET_ITEMS
84191 #undef __HANDLE_ITEM
84192 }
84193 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
84194
84195 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
84196 {
84197 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
84198 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
84199 __SONET_ITEMS
84200 #undef __HANDLE_ITEM
84201 }
84202 diff --git a/net/atm/lec.h b/net/atm/lec.h
84203 index a86aff9..3a0d6f6 100644
84204 --- a/net/atm/lec.h
84205 +++ b/net/atm/lec.h
84206 @@ -48,7 +48,7 @@ struct lane2_ops {
84207 const u8 *tlvs, u32 sizeoftlvs);
84208 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
84209 const u8 *tlvs, u32 sizeoftlvs);
84210 -};
84211 +} __no_const;
84212
84213 /*
84214 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
84215 diff --git a/net/atm/proc.c b/net/atm/proc.c
84216 index 6ac35ff..ac0e136 100644
84217 --- a/net/atm/proc.c
84218 +++ b/net/atm/proc.c
84219 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
84220 const struct k_atm_aal_stats *stats)
84221 {
84222 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
84223 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
84224 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
84225 - atomic_read(&stats->rx_drop));
84226 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
84227 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
84228 + atomic_read_unchecked(&stats->rx_drop));
84229 }
84230
84231 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
84232 diff --git a/net/atm/resources.c b/net/atm/resources.c
84233 index 0447d5d..3cf4728 100644
84234 --- a/net/atm/resources.c
84235 +++ b/net/atm/resources.c
84236 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
84237 static void copy_aal_stats(struct k_atm_aal_stats *from,
84238 struct atm_aal_stats *to)
84239 {
84240 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
84241 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
84242 __AAL_STAT_ITEMS
84243 #undef __HANDLE_ITEM
84244 }
84245 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
84246 static void subtract_aal_stats(struct k_atm_aal_stats *from,
84247 struct atm_aal_stats *to)
84248 {
84249 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
84250 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
84251 __AAL_STAT_ITEMS
84252 #undef __HANDLE_ITEM
84253 }
84254 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
84255 index d5744b7..506bae3 100644
84256 --- a/net/ax25/sysctl_net_ax25.c
84257 +++ b/net/ax25/sysctl_net_ax25.c
84258 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
84259 {
84260 char path[sizeof("net/ax25/") + IFNAMSIZ];
84261 int k;
84262 - struct ctl_table *table;
84263 + ctl_table_no_const *table;
84264
84265 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
84266 if (!table)
84267 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
84268 index a5bb0a7..e1d8b97 100644
84269 --- a/net/batman-adv/bat_iv_ogm.c
84270 +++ b/net/batman-adv/bat_iv_ogm.c
84271 @@ -63,7 +63,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
84272
84273 /* randomize initial seqno to avoid collision */
84274 get_random_bytes(&random_seqno, sizeof(random_seqno));
84275 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
84276 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
84277
84278 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
84279 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
84280 @@ -611,9 +611,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
84281 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
84282
84283 /* change sequence number to network order */
84284 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
84285 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
84286 batadv_ogm_packet->seqno = htonl(seqno);
84287 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
84288 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
84289
84290 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
84291 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
84292 @@ -1013,7 +1013,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
84293 return;
84294
84295 /* could be changed by schedule_own_packet() */
84296 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
84297 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
84298
84299 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
84300 has_directlink_flag = 1;
84301 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
84302 index 368219e..53f56f9 100644
84303 --- a/net/batman-adv/hard-interface.c
84304 +++ b/net/batman-adv/hard-interface.c
84305 @@ -370,7 +370,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
84306 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
84307 dev_add_pack(&hard_iface->batman_adv_ptype);
84308
84309 - atomic_set(&hard_iface->frag_seqno, 1);
84310 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
84311 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
84312 hard_iface->net_dev->name);
84313
84314 @@ -514,7 +514,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
84315 /* This can't be called via a bat_priv callback because
84316 * we have no bat_priv yet.
84317 */
84318 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
84319 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
84320 hard_iface->bat_iv.ogm_buff = NULL;
84321
84322 return hard_iface;
84323 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
84324 index 2711e87..4ca48fa 100644
84325 --- a/net/batman-adv/soft-interface.c
84326 +++ b/net/batman-adv/soft-interface.c
84327 @@ -252,7 +252,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
84328 primary_if->net_dev->dev_addr, ETH_ALEN);
84329
84330 /* set broadcast sequence number */
84331 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
84332 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
84333 bcast_packet->seqno = htonl(seqno);
84334
84335 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
84336 @@ -527,7 +527,7 @@ struct net_device *batadv_softif_create(const char *name)
84337 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
84338
84339 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
84340 - atomic_set(&bat_priv->bcast_seqno, 1);
84341 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
84342 atomic_set(&bat_priv->tt.vn, 0);
84343 atomic_set(&bat_priv->tt.local_changes, 0);
84344 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
84345 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
84346 index 4cd87a0..348e705 100644
84347 --- a/net/batman-adv/types.h
84348 +++ b/net/batman-adv/types.h
84349 @@ -51,7 +51,7 @@
84350 struct batadv_hard_iface_bat_iv {
84351 unsigned char *ogm_buff;
84352 int ogm_buff_len;
84353 - atomic_t ogm_seqno;
84354 + atomic_unchecked_t ogm_seqno;
84355 };
84356
84357 /**
84358 @@ -75,7 +75,7 @@ struct batadv_hard_iface {
84359 int16_t if_num;
84360 char if_status;
84361 struct net_device *net_dev;
84362 - atomic_t frag_seqno;
84363 + atomic_unchecked_t frag_seqno;
84364 struct kobject *hardif_obj;
84365 atomic_t refcount;
84366 struct packet_type batman_adv_ptype;
84367 @@ -495,7 +495,7 @@ struct batadv_priv {
84368 #ifdef CONFIG_BATMAN_ADV_DEBUG
84369 atomic_t log_level;
84370 #endif
84371 - atomic_t bcast_seqno;
84372 + atomic_unchecked_t bcast_seqno;
84373 atomic_t bcast_queue_left;
84374 atomic_t batman_queue_left;
84375 char num_ifaces;
84376 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
84377 index 50e079f..49ce2d2 100644
84378 --- a/net/batman-adv/unicast.c
84379 +++ b/net/batman-adv/unicast.c
84380 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
84381 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
84382 frag2->flags = large_tail;
84383
84384 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
84385 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
84386 frag1->seqno = htons(seqno - 1);
84387 frag2->seqno = htons(seqno);
84388
84389 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
84390 index 6a93614..1415549 100644
84391 --- a/net/bluetooth/hci_sock.c
84392 +++ b/net/bluetooth/hci_sock.c
84393 @@ -929,7 +929,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
84394 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
84395 }
84396
84397 - len = min_t(unsigned int, len, sizeof(uf));
84398 + len = min((size_t)len, sizeof(uf));
84399 if (copy_from_user(&uf, optval, len)) {
84400 err = -EFAULT;
84401 break;
84402 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
84403 index 7c7e932..7a7815d 100644
84404 --- a/net/bluetooth/l2cap_core.c
84405 +++ b/net/bluetooth/l2cap_core.c
84406 @@ -3395,8 +3395,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
84407 break;
84408
84409 case L2CAP_CONF_RFC:
84410 - if (olen == sizeof(rfc))
84411 - memcpy(&rfc, (void *)val, olen);
84412 + if (olen != sizeof(rfc))
84413 + break;
84414 +
84415 + memcpy(&rfc, (void *)val, olen);
84416
84417 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
84418 rfc.mode != chan->mode)
84419 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
84420 index 1bcfb84..dad9f98 100644
84421 --- a/net/bluetooth/l2cap_sock.c
84422 +++ b/net/bluetooth/l2cap_sock.c
84423 @@ -479,7 +479,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
84424 struct sock *sk = sock->sk;
84425 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
84426 struct l2cap_options opts;
84427 - int len, err = 0;
84428 + int err = 0;
84429 + size_t len = optlen;
84430 u32 opt;
84431
84432 BT_DBG("sk %p", sk);
84433 @@ -501,7 +502,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
84434 opts.max_tx = chan->max_tx;
84435 opts.txwin_size = chan->tx_win;
84436
84437 - len = min_t(unsigned int, sizeof(opts), optlen);
84438 + len = min(sizeof(opts), len);
84439 if (copy_from_user((char *) &opts, optval, len)) {
84440 err = -EFAULT;
84441 break;
84442 @@ -581,7 +582,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
84443 struct bt_security sec;
84444 struct bt_power pwr;
84445 struct l2cap_conn *conn;
84446 - int len, err = 0;
84447 + int err = 0;
84448 + size_t len = optlen;
84449 u32 opt;
84450
84451 BT_DBG("sk %p", sk);
84452 @@ -604,7 +606,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
84453
84454 sec.level = BT_SECURITY_LOW;
84455
84456 - len = min_t(unsigned int, sizeof(sec), optlen);
84457 + len = min(sizeof(sec), len);
84458 if (copy_from_user((char *) &sec, optval, len)) {
84459 err = -EFAULT;
84460 break;
84461 @@ -701,7 +703,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
84462
84463 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
84464
84465 - len = min_t(unsigned int, sizeof(pwr), optlen);
84466 + len = min(sizeof(pwr), len);
84467 if (copy_from_user((char *) &pwr, optval, len)) {
84468 err = -EFAULT;
84469 break;
84470 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
84471 index 7c9224b..381009e 100644
84472 --- a/net/bluetooth/rfcomm/sock.c
84473 +++ b/net/bluetooth/rfcomm/sock.c
84474 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
84475 struct sock *sk = sock->sk;
84476 struct bt_security sec;
84477 int err = 0;
84478 - size_t len;
84479 + size_t len = optlen;
84480 u32 opt;
84481
84482 BT_DBG("sk %p", sk);
84483 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
84484
84485 sec.level = BT_SECURITY_LOW;
84486
84487 - len = min_t(unsigned int, sizeof(sec), optlen);
84488 + len = min(sizeof(sec), len);
84489 if (copy_from_user((char *) &sec, optval, len)) {
84490 err = -EFAULT;
84491 break;
84492 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
84493 index b6e44ad..5b0d514 100644
84494 --- a/net/bluetooth/rfcomm/tty.c
84495 +++ b/net/bluetooth/rfcomm/tty.c
84496 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
84497 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
84498
84499 spin_lock_irqsave(&dev->port.lock, flags);
84500 - if (dev->port.count > 0) {
84501 + if (atomic_read(&dev->port.count) > 0) {
84502 spin_unlock_irqrestore(&dev->port.lock, flags);
84503 return;
84504 }
84505 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
84506 return -ENODEV;
84507
84508 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
84509 - dev->channel, dev->port.count);
84510 + dev->channel, atomic_read(&dev->port.count));
84511
84512 spin_lock_irqsave(&dev->port.lock, flags);
84513 - if (++dev->port.count > 1) {
84514 + if (atomic_inc_return(&dev->port.count) > 1) {
84515 spin_unlock_irqrestore(&dev->port.lock, flags);
84516 return 0;
84517 }
84518 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
84519 return;
84520
84521 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
84522 - dev->port.count);
84523 + atomic_read(&dev->port.count));
84524
84525 spin_lock_irqsave(&dev->port.lock, flags);
84526 - if (!--dev->port.count) {
84527 + if (!atomic_dec_return(&dev->port.count)) {
84528 spin_unlock_irqrestore(&dev->port.lock, flags);
84529 if (dev->tty_dev->parent)
84530 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
84531 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
84532 index 8d493c9..3849e49 100644
84533 --- a/net/bridge/netfilter/ebtables.c
84534 +++ b/net/bridge/netfilter/ebtables.c
84535 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
84536 tmp.valid_hooks = t->table->valid_hooks;
84537 }
84538 mutex_unlock(&ebt_mutex);
84539 - if (copy_to_user(user, &tmp, *len) != 0){
84540 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
84541 BUGPRINT("c2u Didn't work\n");
84542 ret = -EFAULT;
84543 break;
84544 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
84545 goto out;
84546 tmp.valid_hooks = t->valid_hooks;
84547
84548 - if (copy_to_user(user, &tmp, *len) != 0) {
84549 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
84550 ret = -EFAULT;
84551 break;
84552 }
84553 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
84554 tmp.entries_size = t->table->entries_size;
84555 tmp.valid_hooks = t->table->valid_hooks;
84556
84557 - if (copy_to_user(user, &tmp, *len) != 0) {
84558 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
84559 ret = -EFAULT;
84560 break;
84561 }
84562 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
84563 index a376ec1..1fbd6be 100644
84564 --- a/net/caif/cfctrl.c
84565 +++ b/net/caif/cfctrl.c
84566 @@ -10,6 +10,7 @@
84567 #include <linux/spinlock.h>
84568 #include <linux/slab.h>
84569 #include <linux/pkt_sched.h>
84570 +#include <linux/sched.h>
84571 #include <net/caif/caif_layer.h>
84572 #include <net/caif/cfpkt.h>
84573 #include <net/caif/cfctrl.h>
84574 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
84575 memset(&dev_info, 0, sizeof(dev_info));
84576 dev_info.id = 0xff;
84577 cfsrvl_init(&this->serv, 0, &dev_info, false);
84578 - atomic_set(&this->req_seq_no, 1);
84579 - atomic_set(&this->rsp_seq_no, 1);
84580 + atomic_set_unchecked(&this->req_seq_no, 1);
84581 + atomic_set_unchecked(&this->rsp_seq_no, 1);
84582 this->serv.layer.receive = cfctrl_recv;
84583 sprintf(this->serv.layer.name, "ctrl");
84584 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
84585 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
84586 struct cfctrl_request_info *req)
84587 {
84588 spin_lock_bh(&ctrl->info_list_lock);
84589 - atomic_inc(&ctrl->req_seq_no);
84590 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
84591 + atomic_inc_unchecked(&ctrl->req_seq_no);
84592 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
84593 list_add_tail(&req->list, &ctrl->list);
84594 spin_unlock_bh(&ctrl->info_list_lock);
84595 }
84596 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
84597 if (p != first)
84598 pr_warn("Requests are not received in order\n");
84599
84600 - atomic_set(&ctrl->rsp_seq_no,
84601 + atomic_set_unchecked(&ctrl->rsp_seq_no,
84602 p->sequence_no);
84603 list_del(&p->list);
84604 goto out;
84605 diff --git a/net/can/af_can.c b/net/can/af_can.c
84606 index c48e522..1223690 100644
84607 --- a/net/can/af_can.c
84608 +++ b/net/can/af_can.c
84609 @@ -870,7 +870,7 @@ static const struct net_proto_family can_family_ops = {
84610 };
84611
84612 /* notifier block for netdevice event */
84613 -static struct notifier_block can_netdev_notifier __read_mostly = {
84614 +static struct notifier_block can_netdev_notifier = {
84615 .notifier_call = can_notifier,
84616 };
84617
84618 diff --git a/net/can/gw.c b/net/can/gw.c
84619 index 117814a..ad4fb73 100644
84620 --- a/net/can/gw.c
84621 +++ b/net/can/gw.c
84622 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
84623 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
84624
84625 static HLIST_HEAD(cgw_list);
84626 -static struct notifier_block notifier;
84627
84628 static struct kmem_cache *cgw_cache __read_mostly;
84629
84630 @@ -928,6 +927,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
84631 return err;
84632 }
84633
84634 +static struct notifier_block notifier = {
84635 + .notifier_call = cgw_notifier
84636 +};
84637 +
84638 static __init int cgw_module_init(void)
84639 {
84640 /* sanitize given module parameter */
84641 @@ -943,7 +946,6 @@ static __init int cgw_module_init(void)
84642 return -ENOMEM;
84643
84644 /* set notifier */
84645 - notifier.notifier_call = cgw_notifier;
84646 register_netdevice_notifier(&notifier);
84647
84648 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
84649 diff --git a/net/compat.c b/net/compat.c
84650 index 79ae884..17c5c09 100644
84651 --- a/net/compat.c
84652 +++ b/net/compat.c
84653 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
84654 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
84655 __get_user(kmsg->msg_flags, &umsg->msg_flags))
84656 return -EFAULT;
84657 - kmsg->msg_name = compat_ptr(tmp1);
84658 - kmsg->msg_iov = compat_ptr(tmp2);
84659 - kmsg->msg_control = compat_ptr(tmp3);
84660 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
84661 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
84662 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
84663 return 0;
84664 }
84665
84666 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
84667
84668 if (kern_msg->msg_namelen) {
84669 if (mode == VERIFY_READ) {
84670 - int err = move_addr_to_kernel(kern_msg->msg_name,
84671 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
84672 kern_msg->msg_namelen,
84673 kern_address);
84674 if (err < 0)
84675 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
84676 kern_msg->msg_name = NULL;
84677
84678 tot_len = iov_from_user_compat_to_kern(kern_iov,
84679 - (struct compat_iovec __user *)kern_msg->msg_iov,
84680 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
84681 kern_msg->msg_iovlen);
84682 if (tot_len >= 0)
84683 kern_msg->msg_iov = kern_iov;
84684 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
84685
84686 #define CMSG_COMPAT_FIRSTHDR(msg) \
84687 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
84688 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
84689 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
84690 (struct compat_cmsghdr __user *)NULL)
84691
84692 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
84693 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
84694 (ucmlen) <= (unsigned long) \
84695 ((mhdr)->msg_controllen - \
84696 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
84697 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
84698
84699 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
84700 struct compat_cmsghdr __user *cmsg, int cmsg_len)
84701 {
84702 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
84703 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
84704 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
84705 msg->msg_controllen)
84706 return NULL;
84707 return (struct compat_cmsghdr __user *)ptr;
84708 @@ -219,7 +219,7 @@ Efault:
84709
84710 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
84711 {
84712 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
84713 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
84714 struct compat_cmsghdr cmhdr;
84715 struct compat_timeval ctv;
84716 struct compat_timespec cts[3];
84717 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
84718
84719 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
84720 {
84721 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
84722 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
84723 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
84724 int fdnum = scm->fp->count;
84725 struct file **fp = scm->fp->fp;
84726 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
84727 return -EFAULT;
84728 old_fs = get_fs();
84729 set_fs(KERNEL_DS);
84730 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
84731 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
84732 set_fs(old_fs);
84733
84734 return err;
84735 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
84736 len = sizeof(ktime);
84737 old_fs = get_fs();
84738 set_fs(KERNEL_DS);
84739 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
84740 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
84741 set_fs(old_fs);
84742
84743 if (!err) {
84744 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
84745 case MCAST_JOIN_GROUP:
84746 case MCAST_LEAVE_GROUP:
84747 {
84748 - struct compat_group_req __user *gr32 = (void *)optval;
84749 + struct compat_group_req __user *gr32 = (void __user *)optval;
84750 struct group_req __user *kgr =
84751 compat_alloc_user_space(sizeof(struct group_req));
84752 u32 interface;
84753 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
84754 case MCAST_BLOCK_SOURCE:
84755 case MCAST_UNBLOCK_SOURCE:
84756 {
84757 - struct compat_group_source_req __user *gsr32 = (void *)optval;
84758 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
84759 struct group_source_req __user *kgsr = compat_alloc_user_space(
84760 sizeof(struct group_source_req));
84761 u32 interface;
84762 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
84763 }
84764 case MCAST_MSFILTER:
84765 {
84766 - struct compat_group_filter __user *gf32 = (void *)optval;
84767 + struct compat_group_filter __user *gf32 = (void __user *)optval;
84768 struct group_filter __user *kgf;
84769 u32 interface, fmode, numsrc;
84770
84771 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
84772 char __user *optval, int __user *optlen,
84773 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
84774 {
84775 - struct compat_group_filter __user *gf32 = (void *)optval;
84776 + struct compat_group_filter __user *gf32 = (void __user *)optval;
84777 struct group_filter __user *kgf;
84778 int __user *koptlen;
84779 u32 interface, fmode, numsrc;
84780 @@ -796,7 +796,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
84781
84782 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
84783 return -EINVAL;
84784 - if (copy_from_user(a, args, nas[call]))
84785 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
84786 return -EFAULT;
84787 a0 = a[0];
84788 a1 = a[1];
84789 diff --git a/net/core/datagram.c b/net/core/datagram.c
84790 index 368f9c3..f82d4a3 100644
84791 --- a/net/core/datagram.c
84792 +++ b/net/core/datagram.c
84793 @@ -289,7 +289,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
84794 }
84795
84796 kfree_skb(skb);
84797 - atomic_inc(&sk->sk_drops);
84798 + atomic_inc_unchecked(&sk->sk_drops);
84799 sk_mem_reclaim_partial(sk);
84800
84801 return err;
84802 diff --git a/net/core/dev.c b/net/core/dev.c
84803 index b24ab0e9..1c424bc 100644
84804 --- a/net/core/dev.c
84805 +++ b/net/core/dev.c
84806 @@ -1617,7 +1617,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
84807 {
84808 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
84809 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
84810 - atomic_long_inc(&dev->rx_dropped);
84811 + atomic_long_inc_unchecked(&dev->rx_dropped);
84812 kfree_skb(skb);
84813 return NET_RX_DROP;
84814 }
84815 @@ -1626,7 +1626,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
84816 skb_orphan(skb);
84817
84818 if (unlikely(!is_skb_forwardable(dev, skb))) {
84819 - atomic_long_inc(&dev->rx_dropped);
84820 + atomic_long_inc_unchecked(&dev->rx_dropped);
84821 kfree_skb(skb);
84822 return NET_RX_DROP;
84823 }
84824 @@ -2351,7 +2351,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
84825
84826 struct dev_gso_cb {
84827 void (*destructor)(struct sk_buff *skb);
84828 -};
84829 +} __no_const;
84830
84831 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
84832
84833 @@ -3093,7 +3093,7 @@ enqueue:
84834
84835 local_irq_restore(flags);
84836
84837 - atomic_long_inc(&skb->dev->rx_dropped);
84838 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
84839 kfree_skb(skb);
84840 return NET_RX_DROP;
84841 }
84842 @@ -3165,7 +3165,7 @@ int netif_rx_ni(struct sk_buff *skb)
84843 }
84844 EXPORT_SYMBOL(netif_rx_ni);
84845
84846 -static void net_tx_action(struct softirq_action *h)
84847 +static void net_tx_action(void)
84848 {
84849 struct softnet_data *sd = &__get_cpu_var(softnet_data);
84850
84851 @@ -3490,7 +3490,7 @@ ncls:
84852 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
84853 } else {
84854 drop:
84855 - atomic_long_inc(&skb->dev->rx_dropped);
84856 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
84857 kfree_skb(skb);
84858 /* Jamal, now you will not able to escape explaining
84859 * me how you were going to use this. :-)
84860 @@ -4095,7 +4095,7 @@ void netif_napi_del(struct napi_struct *napi)
84861 }
84862 EXPORT_SYMBOL(netif_napi_del);
84863
84864 -static void net_rx_action(struct softirq_action *h)
84865 +static void net_rx_action(void)
84866 {
84867 struct softnet_data *sd = &__get_cpu_var(softnet_data);
84868 unsigned long time_limit = jiffies + 2;
84869 @@ -5522,7 +5522,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
84870 } else {
84871 netdev_stats_to_stats64(storage, &dev->stats);
84872 }
84873 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
84874 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
84875 return storage;
84876 }
84877 EXPORT_SYMBOL(dev_get_stats);
84878 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
84879 index 6cc0481..59cfb00 100644
84880 --- a/net/core/dev_ioctl.c
84881 +++ b/net/core/dev_ioctl.c
84882 @@ -376,9 +376,13 @@ void dev_load(struct net *net, const char *name)
84883 if (no_module && capable(CAP_NET_ADMIN))
84884 no_module = request_module("netdev-%s", name);
84885 if (no_module && capable(CAP_SYS_MODULE)) {
84886 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
84887 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
84888 +#else
84889 if (!request_module("%s", name))
84890 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
84891 name);
84892 +#endif
84893 }
84894 }
84895 EXPORT_SYMBOL(dev_load);
84896 diff --git a/net/core/flow.c b/net/core/flow.c
84897 index 2bfd081..53c6058 100644
84898 --- a/net/core/flow.c
84899 +++ b/net/core/flow.c
84900 @@ -61,7 +61,7 @@ struct flow_cache {
84901 struct timer_list rnd_timer;
84902 };
84903
84904 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
84905 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
84906 EXPORT_SYMBOL(flow_cache_genid);
84907 static struct flow_cache flow_cache_global;
84908 static struct kmem_cache *flow_cachep __read_mostly;
84909 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
84910
84911 static int flow_entry_valid(struct flow_cache_entry *fle)
84912 {
84913 - if (atomic_read(&flow_cache_genid) != fle->genid)
84914 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
84915 return 0;
84916 if (fle->object && !fle->object->ops->check(fle->object))
84917 return 0;
84918 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
84919 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
84920 fcp->hash_count++;
84921 }
84922 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
84923 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
84924 flo = fle->object;
84925 if (!flo)
84926 goto ret_object;
84927 @@ -279,7 +279,7 @@ nocache:
84928 }
84929 flo = resolver(net, key, family, dir, flo, ctx);
84930 if (fle) {
84931 - fle->genid = atomic_read(&flow_cache_genid);
84932 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
84933 if (!IS_ERR(flo))
84934 fle->object = flo;
84935 else
84936 diff --git a/net/core/iovec.c b/net/core/iovec.c
84937 index 7e7aeb0..2a998cb 100644
84938 --- a/net/core/iovec.c
84939 +++ b/net/core/iovec.c
84940 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
84941 if (m->msg_namelen) {
84942 if (mode == VERIFY_READ) {
84943 void __user *namep;
84944 - namep = (void __user __force *) m->msg_name;
84945 + namep = (void __force_user *) m->msg_name;
84946 err = move_addr_to_kernel(namep, m->msg_namelen,
84947 address);
84948 if (err < 0)
84949 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
84950 }
84951
84952 size = m->msg_iovlen * sizeof(struct iovec);
84953 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
84954 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
84955 return -EFAULT;
84956
84957 m->msg_iov = iov;
84958 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
84959 index 3863b8f..85c99a6 100644
84960 --- a/net/core/neighbour.c
84961 +++ b/net/core/neighbour.c
84962 @@ -2778,7 +2778,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
84963 size_t *lenp, loff_t *ppos)
84964 {
84965 int size, ret;
84966 - ctl_table tmp = *ctl;
84967 + ctl_table_no_const tmp = *ctl;
84968
84969 tmp.extra1 = &zero;
84970 tmp.extra2 = &unres_qlen_max;
84971 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
84972 index 3174f19..5810985 100644
84973 --- a/net/core/net-procfs.c
84974 +++ b/net/core/net-procfs.c
84975 @@ -271,8 +271,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
84976 else
84977 seq_printf(seq, "%04x", ntohs(pt->type));
84978
84979 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84980 + seq_printf(seq, " %-8s %pF\n",
84981 + pt->dev ? pt->dev->name : "", NULL);
84982 +#else
84983 seq_printf(seq, " %-8s %pF\n",
84984 pt->dev ? pt->dev->name : "", pt->func);
84985 +#endif
84986 }
84987
84988 return 0;
84989 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
84990 index 7427ab5..389f411 100644
84991 --- a/net/core/net-sysfs.c
84992 +++ b/net/core/net-sysfs.c
84993 @@ -1321,7 +1321,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
84994 }
84995 EXPORT_SYMBOL(netdev_class_remove_file);
84996
84997 -int netdev_kobject_init(void)
84998 +int __init netdev_kobject_init(void)
84999 {
85000 kobj_ns_type_register(&net_ns_type_operations);
85001 return class_register(&net_class);
85002 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
85003 index 80e271d..2980cc2 100644
85004 --- a/net/core/net_namespace.c
85005 +++ b/net/core/net_namespace.c
85006 @@ -442,7 +442,7 @@ static int __register_pernet_operations(struct list_head *list,
85007 int error;
85008 LIST_HEAD(net_exit_list);
85009
85010 - list_add_tail(&ops->list, list);
85011 + pax_list_add_tail((struct list_head *)&ops->list, list);
85012 if (ops->init || (ops->id && ops->size)) {
85013 for_each_net(net) {
85014 error = ops_init(ops, net);
85015 @@ -455,7 +455,7 @@ static int __register_pernet_operations(struct list_head *list,
85016
85017 out_undo:
85018 /* If I have an error cleanup all namespaces I initialized */
85019 - list_del(&ops->list);
85020 + pax_list_del((struct list_head *)&ops->list);
85021 ops_exit_list(ops, &net_exit_list);
85022 ops_free_list(ops, &net_exit_list);
85023 return error;
85024 @@ -466,7 +466,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
85025 struct net *net;
85026 LIST_HEAD(net_exit_list);
85027
85028 - list_del(&ops->list);
85029 + pax_list_del((struct list_head *)&ops->list);
85030 for_each_net(net)
85031 list_add_tail(&net->exit_list, &net_exit_list);
85032 ops_exit_list(ops, &net_exit_list);
85033 @@ -600,7 +600,7 @@ int register_pernet_device(struct pernet_operations *ops)
85034 mutex_lock(&net_mutex);
85035 error = register_pernet_operations(&pernet_list, ops);
85036 if (!error && (first_device == &pernet_list))
85037 - first_device = &ops->list;
85038 + first_device = (struct list_head *)&ops->list;
85039 mutex_unlock(&net_mutex);
85040 return error;
85041 }
85042 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
85043 index 23854b5..ff4fda4 100644
85044 --- a/net/core/rtnetlink.c
85045 +++ b/net/core/rtnetlink.c
85046 @@ -58,7 +58,7 @@ struct rtnl_link {
85047 rtnl_doit_func doit;
85048 rtnl_dumpit_func dumpit;
85049 rtnl_calcit_func calcit;
85050 -};
85051 +} __no_const;
85052
85053 static DEFINE_MUTEX(rtnl_mutex);
85054
85055 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
85056 if (rtnl_link_ops_get(ops->kind))
85057 return -EEXIST;
85058
85059 - if (!ops->dellink)
85060 - ops->dellink = unregister_netdevice_queue;
85061 + if (!ops->dellink) {
85062 + pax_open_kernel();
85063 + *(void **)&ops->dellink = unregister_netdevice_queue;
85064 + pax_close_kernel();
85065 + }
85066
85067 - list_add_tail(&ops->list, &link_ops);
85068 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
85069 return 0;
85070 }
85071 EXPORT_SYMBOL_GPL(__rtnl_link_register);
85072 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
85073 for_each_net(net) {
85074 __rtnl_kill_links(net, ops);
85075 }
85076 - list_del(&ops->list);
85077 + pax_list_del((struct list_head *)&ops->list);
85078 }
85079 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
85080
85081 diff --git a/net/core/scm.c b/net/core/scm.c
85082 index 2dc6cda..2159524 100644
85083 --- a/net/core/scm.c
85084 +++ b/net/core/scm.c
85085 @@ -226,7 +226,7 @@ EXPORT_SYMBOL(__scm_send);
85086 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
85087 {
85088 struct cmsghdr __user *cm
85089 - = (__force struct cmsghdr __user *)msg->msg_control;
85090 + = (struct cmsghdr __force_user *)msg->msg_control;
85091 struct cmsghdr cmhdr;
85092 int cmlen = CMSG_LEN(len);
85093 int err;
85094 @@ -249,7 +249,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
85095 err = -EFAULT;
85096 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
85097 goto out;
85098 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
85099 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
85100 goto out;
85101 cmlen = CMSG_SPACE(len);
85102 if (msg->msg_controllen < cmlen)
85103 @@ -265,7 +265,7 @@ EXPORT_SYMBOL(put_cmsg);
85104 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
85105 {
85106 struct cmsghdr __user *cm
85107 - = (__force struct cmsghdr __user*)msg->msg_control;
85108 + = (struct cmsghdr __force_user *)msg->msg_control;
85109
85110 int fdmax = 0;
85111 int fdnum = scm->fp->count;
85112 @@ -285,7 +285,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
85113 if (fdnum < fdmax)
85114 fdmax = fdnum;
85115
85116 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
85117 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
85118 i++, cmfptr++)
85119 {
85120 struct socket *sock;
85121 diff --git a/net/core/secure_seq.c b/net/core/secure_seq.c
85122 index e61a8bb..6a2f13c 100644
85123 --- a/net/core/secure_seq.c
85124 +++ b/net/core/secure_seq.c
85125 @@ -12,12 +12,10 @@
85126
85127 static u32 net_secret[MD5_MESSAGE_BYTES / 4] ____cacheline_aligned;
85128
85129 -static int __init net_secret_init(void)
85130 +void net_secret_init(void)
85131 {
85132 get_random_bytes(net_secret, sizeof(net_secret));
85133 - return 0;
85134 }
85135 -late_initcall(net_secret_init);
85136
85137 #ifdef CONFIG_INET
85138 static u32 seq_scale(u32 seq)
85139 diff --git a/net/core/sock.c b/net/core/sock.c
85140 index b261a79..8fe17ab 100644
85141 --- a/net/core/sock.c
85142 +++ b/net/core/sock.c
85143 @@ -390,7 +390,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
85144 struct sk_buff_head *list = &sk->sk_receive_queue;
85145
85146 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
85147 - atomic_inc(&sk->sk_drops);
85148 + atomic_inc_unchecked(&sk->sk_drops);
85149 trace_sock_rcvqueue_full(sk, skb);
85150 return -ENOMEM;
85151 }
85152 @@ -400,7 +400,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
85153 return err;
85154
85155 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
85156 - atomic_inc(&sk->sk_drops);
85157 + atomic_inc_unchecked(&sk->sk_drops);
85158 return -ENOBUFS;
85159 }
85160
85161 @@ -420,7 +420,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
85162 skb_dst_force(skb);
85163
85164 spin_lock_irqsave(&list->lock, flags);
85165 - skb->dropcount = atomic_read(&sk->sk_drops);
85166 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
85167 __skb_queue_tail(list, skb);
85168 spin_unlock_irqrestore(&list->lock, flags);
85169
85170 @@ -440,7 +440,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
85171 skb->dev = NULL;
85172
85173 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
85174 - atomic_inc(&sk->sk_drops);
85175 + atomic_inc_unchecked(&sk->sk_drops);
85176 goto discard_and_relse;
85177 }
85178 if (nested)
85179 @@ -458,7 +458,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
85180 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
85181 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
85182 bh_unlock_sock(sk);
85183 - atomic_inc(&sk->sk_drops);
85184 + atomic_inc_unchecked(&sk->sk_drops);
85185 goto discard_and_relse;
85186 }
85187
85188 @@ -942,12 +942,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
85189 struct timeval tm;
85190 } v;
85191
85192 - int lv = sizeof(int);
85193 - int len;
85194 + unsigned int lv = sizeof(int);
85195 + unsigned int len;
85196
85197 if (get_user(len, optlen))
85198 return -EFAULT;
85199 - if (len < 0)
85200 + if (len > INT_MAX)
85201 return -EINVAL;
85202
85203 memset(&v, 0, sizeof(v));
85204 @@ -1099,11 +1099,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
85205
85206 case SO_PEERNAME:
85207 {
85208 - char address[128];
85209 + char address[_K_SS_MAXSIZE];
85210
85211 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
85212 return -ENOTCONN;
85213 - if (lv < len)
85214 + if (lv < len || sizeof address < len)
85215 return -EINVAL;
85216 if (copy_to_user(optval, address, len))
85217 return -EFAULT;
85218 @@ -1166,7 +1166,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
85219
85220 if (len > lv)
85221 len = lv;
85222 - if (copy_to_user(optval, &v, len))
85223 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
85224 return -EFAULT;
85225 lenout:
85226 if (put_user(len, optlen))
85227 @@ -2296,7 +2296,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
85228 */
85229 smp_wmb();
85230 atomic_set(&sk->sk_refcnt, 1);
85231 - atomic_set(&sk->sk_drops, 0);
85232 + atomic_set_unchecked(&sk->sk_drops, 0);
85233 }
85234 EXPORT_SYMBOL(sock_init_data);
85235
85236 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
85237 index a29e90c..922399c 100644
85238 --- a/net/core/sock_diag.c
85239 +++ b/net/core/sock_diag.c
85240 @@ -9,26 +9,33 @@
85241 #include <linux/inet_diag.h>
85242 #include <linux/sock_diag.h>
85243
85244 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
85245 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
85246 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
85247 static DEFINE_MUTEX(sock_diag_table_mutex);
85248
85249 int sock_diag_check_cookie(void *sk, __u32 *cookie)
85250 {
85251 +#ifndef CONFIG_GRKERNSEC_HIDESYM
85252 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
85253 cookie[1] != INET_DIAG_NOCOOKIE) &&
85254 ((u32)(unsigned long)sk != cookie[0] ||
85255 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
85256 return -ESTALE;
85257 else
85258 +#endif
85259 return 0;
85260 }
85261 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
85262
85263 void sock_diag_save_cookie(void *sk, __u32 *cookie)
85264 {
85265 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85266 + cookie[0] = 0;
85267 + cookie[1] = 0;
85268 +#else
85269 cookie[0] = (u32)(unsigned long)sk;
85270 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
85271 +#endif
85272 }
85273 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
85274
85275 @@ -75,8 +82,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
85276 mutex_lock(&sock_diag_table_mutex);
85277 if (sock_diag_handlers[hndl->family])
85278 err = -EBUSY;
85279 - else
85280 + else {
85281 + pax_open_kernel();
85282 sock_diag_handlers[hndl->family] = hndl;
85283 + pax_close_kernel();
85284 + }
85285 mutex_unlock(&sock_diag_table_mutex);
85286
85287 return err;
85288 @@ -92,7 +102,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
85289
85290 mutex_lock(&sock_diag_table_mutex);
85291 BUG_ON(sock_diag_handlers[family] != hnld);
85292 + pax_open_kernel();
85293 sock_diag_handlers[family] = NULL;
85294 + pax_close_kernel();
85295 mutex_unlock(&sock_diag_table_mutex);
85296 }
85297 EXPORT_SYMBOL_GPL(sock_diag_unregister);
85298 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
85299 index cfdb46a..cef55e1 100644
85300 --- a/net/core/sysctl_net_core.c
85301 +++ b/net/core/sysctl_net_core.c
85302 @@ -28,7 +28,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
85303 {
85304 unsigned int orig_size, size;
85305 int ret, i;
85306 - ctl_table tmp = {
85307 + ctl_table_no_const tmp = {
85308 .data = &size,
85309 .maxlen = sizeof(size),
85310 .mode = table->mode
85311 @@ -211,13 +211,12 @@ static struct ctl_table netns_core_table[] = {
85312
85313 static __net_init int sysctl_core_net_init(struct net *net)
85314 {
85315 - struct ctl_table *tbl;
85316 + ctl_table_no_const *tbl = NULL;
85317
85318 net->core.sysctl_somaxconn = SOMAXCONN;
85319
85320 - tbl = netns_core_table;
85321 if (!net_eq(net, &init_net)) {
85322 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
85323 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
85324 if (tbl == NULL)
85325 goto err_dup;
85326
85327 @@ -227,17 +226,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
85328 if (net->user_ns != &init_user_ns) {
85329 tbl[0].procname = NULL;
85330 }
85331 - }
85332 -
85333 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
85334 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
85335 + } else
85336 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
85337 if (net->core.sysctl_hdr == NULL)
85338 goto err_reg;
85339
85340 return 0;
85341
85342 err_reg:
85343 - if (tbl != netns_core_table)
85344 - kfree(tbl);
85345 + kfree(tbl);
85346 err_dup:
85347 return -ENOMEM;
85348 }
85349 @@ -252,7 +250,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
85350 kfree(tbl);
85351 }
85352
85353 -static __net_initdata struct pernet_operations sysctl_core_ops = {
85354 +static __net_initconst struct pernet_operations sysctl_core_ops = {
85355 .init = sysctl_core_net_init,
85356 .exit = sysctl_core_net_exit,
85357 };
85358 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
85359 index c21f200..bc4565b 100644
85360 --- a/net/decnet/af_decnet.c
85361 +++ b/net/decnet/af_decnet.c
85362 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
85363 .sysctl_rmem = sysctl_decnet_rmem,
85364 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
85365 .obj_size = sizeof(struct dn_sock),
85366 + .slab_flags = SLAB_USERCOPY,
85367 };
85368
85369 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
85370 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
85371 index a55eecc..dd8428c 100644
85372 --- a/net/decnet/sysctl_net_decnet.c
85373 +++ b/net/decnet/sysctl_net_decnet.c
85374 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
85375
85376 if (len > *lenp) len = *lenp;
85377
85378 - if (copy_to_user(buffer, addr, len))
85379 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
85380 return -EFAULT;
85381
85382 *lenp = len;
85383 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
85384
85385 if (len > *lenp) len = *lenp;
85386
85387 - if (copy_to_user(buffer, devname, len))
85388 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
85389 return -EFAULT;
85390
85391 *lenp = len;
85392 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
85393 index c929d9c..df10cde 100644
85394 --- a/net/ipv4/af_inet.c
85395 +++ b/net/ipv4/af_inet.c
85396 @@ -115,6 +115,7 @@
85397 #include <net/inet_common.h>
85398 #include <net/xfrm.h>
85399 #include <net/net_namespace.h>
85400 +#include <net/secure_seq.h>
85401 #ifdef CONFIG_IP_MROUTE
85402 #include <linux/mroute.h>
85403 #endif
85404 @@ -263,8 +264,10 @@ void build_ehash_secret(void)
85405 get_random_bytes(&rnd, sizeof(rnd));
85406 } while (rnd == 0);
85407
85408 - if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0)
85409 + if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0) {
85410 get_random_bytes(&ipv6_hash_secret, sizeof(ipv6_hash_secret));
85411 + net_secret_init();
85412 + }
85413 }
85414 EXPORT_SYMBOL(build_ehash_secret);
85415
85416 @@ -1699,13 +1702,9 @@ static int __init inet_init(void)
85417
85418 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
85419
85420 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
85421 - if (!sysctl_local_reserved_ports)
85422 - goto out;
85423 -
85424 rc = proto_register(&tcp_prot, 1);
85425 if (rc)
85426 - goto out_free_reserved_ports;
85427 + goto out;
85428
85429 rc = proto_register(&udp_prot, 1);
85430 if (rc)
85431 @@ -1814,8 +1813,6 @@ out_unregister_udp_proto:
85432 proto_unregister(&udp_prot);
85433 out_unregister_tcp_proto:
85434 proto_unregister(&tcp_prot);
85435 -out_free_reserved_ports:
85436 - kfree(sysctl_local_reserved_ports);
85437 goto out;
85438 }
85439
85440 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
85441 index 2e7f194..0fa4d6d 100644
85442 --- a/net/ipv4/ah4.c
85443 +++ b/net/ipv4/ah4.c
85444 @@ -420,7 +420,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
85445 return;
85446
85447 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
85448 - atomic_inc(&flow_cache_genid);
85449 + atomic_inc_unchecked(&flow_cache_genid);
85450 rt_genid_bump(net);
85451
85452 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
85453 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
85454 index c6287cd..e9bc96a 100644
85455 --- a/net/ipv4/devinet.c
85456 +++ b/net/ipv4/devinet.c
85457 @@ -1992,7 +1992,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
85458 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
85459 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
85460
85461 -static struct devinet_sysctl_table {
85462 +static const struct devinet_sysctl_table {
85463 struct ctl_table_header *sysctl_header;
85464 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
85465 } devinet_sysctl = {
85466 @@ -2110,7 +2110,7 @@ static __net_init int devinet_init_net(struct net *net)
85467 int err;
85468 struct ipv4_devconf *all, *dflt;
85469 #ifdef CONFIG_SYSCTL
85470 - struct ctl_table *tbl = ctl_forward_entry;
85471 + ctl_table_no_const *tbl = NULL;
85472 struct ctl_table_header *forw_hdr;
85473 #endif
85474
85475 @@ -2128,7 +2128,7 @@ static __net_init int devinet_init_net(struct net *net)
85476 goto err_alloc_dflt;
85477
85478 #ifdef CONFIG_SYSCTL
85479 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
85480 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
85481 if (tbl == NULL)
85482 goto err_alloc_ctl;
85483
85484 @@ -2148,7 +2148,10 @@ static __net_init int devinet_init_net(struct net *net)
85485 goto err_reg_dflt;
85486
85487 err = -ENOMEM;
85488 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
85489 + if (!net_eq(net, &init_net))
85490 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
85491 + else
85492 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
85493 if (forw_hdr == NULL)
85494 goto err_reg_ctl;
85495 net->ipv4.forw_hdr = forw_hdr;
85496 @@ -2164,8 +2167,7 @@ err_reg_ctl:
85497 err_reg_dflt:
85498 __devinet_sysctl_unregister(all);
85499 err_reg_all:
85500 - if (tbl != ctl_forward_entry)
85501 - kfree(tbl);
85502 + kfree(tbl);
85503 err_alloc_ctl:
85504 #endif
85505 if (dflt != &ipv4_devconf_dflt)
85506 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
85507 index 4cfe34d..a6ba66e 100644
85508 --- a/net/ipv4/esp4.c
85509 +++ b/net/ipv4/esp4.c
85510 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
85511 return;
85512
85513 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
85514 - atomic_inc(&flow_cache_genid);
85515 + atomic_inc_unchecked(&flow_cache_genid);
85516 rt_genid_bump(net);
85517
85518 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
85519 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
85520 index eb4bb12..ee4ec7d 100644
85521 --- a/net/ipv4/fib_frontend.c
85522 +++ b/net/ipv4/fib_frontend.c
85523 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
85524 #ifdef CONFIG_IP_ROUTE_MULTIPATH
85525 fib_sync_up(dev);
85526 #endif
85527 - atomic_inc(&net->ipv4.dev_addr_genid);
85528 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
85529 rt_cache_flush(dev_net(dev));
85530 break;
85531 case NETDEV_DOWN:
85532 fib_del_ifaddr(ifa, NULL);
85533 - atomic_inc(&net->ipv4.dev_addr_genid);
85534 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
85535 if (ifa->ifa_dev->ifa_list == NULL) {
85536 /* Last address was deleted from this interface.
85537 * Disable IP.
85538 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
85539 #ifdef CONFIG_IP_ROUTE_MULTIPATH
85540 fib_sync_up(dev);
85541 #endif
85542 - atomic_inc(&net->ipv4.dev_addr_genid);
85543 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
85544 rt_cache_flush(net);
85545 break;
85546 case NETDEV_DOWN:
85547 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
85548 index 8f6cb7a..34507f9 100644
85549 --- a/net/ipv4/fib_semantics.c
85550 +++ b/net/ipv4/fib_semantics.c
85551 @@ -765,7 +765,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
85552 nh->nh_saddr = inet_select_addr(nh->nh_dev,
85553 nh->nh_gw,
85554 nh->nh_parent->fib_scope);
85555 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
85556 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
85557
85558 return nh->nh_saddr;
85559 }
85560 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
85561 index 786d97a..1889c0d 100644
85562 --- a/net/ipv4/inet_connection_sock.c
85563 +++ b/net/ipv4/inet_connection_sock.c
85564 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
85565 .range = { 32768, 61000 },
85566 };
85567
85568 -unsigned long *sysctl_local_reserved_ports;
85569 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
85570 EXPORT_SYMBOL(sysctl_local_reserved_ports);
85571
85572 void inet_get_local_port_range(int *low, int *high)
85573 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
85574 index 6af375a..c493c74 100644
85575 --- a/net/ipv4/inet_hashtables.c
85576 +++ b/net/ipv4/inet_hashtables.c
85577 @@ -18,12 +18,15 @@
85578 #include <linux/sched.h>
85579 #include <linux/slab.h>
85580 #include <linux/wait.h>
85581 +#include <linux/security.h>
85582
85583 #include <net/inet_connection_sock.h>
85584 #include <net/inet_hashtables.h>
85585 #include <net/secure_seq.h>
85586 #include <net/ip.h>
85587
85588 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
85589 +
85590 /*
85591 * Allocate and initialize a new local port bind bucket.
85592 * The bindhash mutex for snum's hash chain must be held here.
85593 @@ -554,6 +557,8 @@ ok:
85594 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
85595 spin_unlock(&head->lock);
85596
85597 + gr_update_task_in_ip_table(current, inet_sk(sk));
85598 +
85599 if (tw) {
85600 inet_twsk_deschedule(tw, death_row);
85601 while (twrefcnt) {
85602 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
85603 index 000e3d2..5472da3 100644
85604 --- a/net/ipv4/inetpeer.c
85605 +++ b/net/ipv4/inetpeer.c
85606 @@ -503,8 +503,8 @@ relookup:
85607 if (p) {
85608 p->daddr = *daddr;
85609 atomic_set(&p->refcnt, 1);
85610 - atomic_set(&p->rid, 0);
85611 - atomic_set(&p->ip_id_count,
85612 + atomic_set_unchecked(&p->rid, 0);
85613 + atomic_set_unchecked(&p->ip_id_count,
85614 (daddr->family == AF_INET) ?
85615 secure_ip_id(daddr->addr.a4) :
85616 secure_ipv6_id(daddr->addr.a6));
85617 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
85618 index 52c273e..579060b 100644
85619 --- a/net/ipv4/ip_fragment.c
85620 +++ b/net/ipv4/ip_fragment.c
85621 @@ -311,7 +311,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
85622 return 0;
85623
85624 start = qp->rid;
85625 - end = atomic_inc_return(&peer->rid);
85626 + end = atomic_inc_return_unchecked(&peer->rid);
85627 qp->rid = end;
85628
85629 rc = qp->q.fragments && (end - start) > max;
85630 @@ -788,12 +788,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
85631
85632 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
85633 {
85634 - struct ctl_table *table;
85635 + ctl_table_no_const *table = NULL;
85636 struct ctl_table_header *hdr;
85637
85638 - table = ip4_frags_ns_ctl_table;
85639 if (!net_eq(net, &init_net)) {
85640 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
85641 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
85642 if (table == NULL)
85643 goto err_alloc;
85644
85645 @@ -804,9 +803,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
85646 /* Don't export sysctls to unprivileged users */
85647 if (net->user_ns != &init_user_ns)
85648 table[0].procname = NULL;
85649 - }
85650 + hdr = register_net_sysctl(net, "net/ipv4", table);
85651 + } else
85652 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
85653
85654 - hdr = register_net_sysctl(net, "net/ipv4", table);
85655 if (hdr == NULL)
85656 goto err_reg;
85657
85658 @@ -814,8 +814,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
85659 return 0;
85660
85661 err_reg:
85662 - if (!net_eq(net, &init_net))
85663 - kfree(table);
85664 + kfree(table);
85665 err_alloc:
85666 return -ENOMEM;
85667 }
85668 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
85669 index 91d66db..4af7d99 100644
85670 --- a/net/ipv4/ip_gre.c
85671 +++ b/net/ipv4/ip_gre.c
85672 @@ -124,7 +124,7 @@ static bool log_ecn_error = true;
85673 module_param(log_ecn_error, bool, 0644);
85674 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
85675
85676 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
85677 +static struct rtnl_link_ops ipgre_link_ops;
85678 static int ipgre_tunnel_init(struct net_device *dev);
85679 static void ipgre_tunnel_setup(struct net_device *dev);
85680 static int ipgre_tunnel_bind_dev(struct net_device *dev);
85681 @@ -1823,7 +1823,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
85682 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
85683 };
85684
85685 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
85686 +static struct rtnl_link_ops ipgre_link_ops = {
85687 .kind = "gre",
85688 .maxtype = IFLA_GRE_MAX,
85689 .policy = ipgre_policy,
85690 @@ -1836,7 +1836,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
85691 .fill_info = ipgre_fill_info,
85692 };
85693
85694 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
85695 +static struct rtnl_link_ops ipgre_tap_ops = {
85696 .kind = "gretap",
85697 .maxtype = IFLA_GRE_MAX,
85698 .policy = ipgre_policy,
85699 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
85700 index d9c4f11..02b82dbc 100644
85701 --- a/net/ipv4/ip_sockglue.c
85702 +++ b/net/ipv4/ip_sockglue.c
85703 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
85704 len = min_t(unsigned int, len, opt->optlen);
85705 if (put_user(len, optlen))
85706 return -EFAULT;
85707 - if (copy_to_user(optval, opt->__data, len))
85708 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
85709 + copy_to_user(optval, opt->__data, len))
85710 return -EFAULT;
85711 return 0;
85712 }
85713 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
85714 if (sk->sk_type != SOCK_STREAM)
85715 return -ENOPROTOOPT;
85716
85717 - msg.msg_control = optval;
85718 + msg.msg_control = (void __force_kernel *)optval;
85719 msg.msg_controllen = len;
85720 msg.msg_flags = flags;
85721
85722 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
85723 index c3a4233..1412161 100644
85724 --- a/net/ipv4/ip_vti.c
85725 +++ b/net/ipv4/ip_vti.c
85726 @@ -47,7 +47,7 @@
85727 #define HASH_SIZE 16
85728 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
85729
85730 -static struct rtnl_link_ops vti_link_ops __read_mostly;
85731 +static struct rtnl_link_ops vti_link_ops;
85732
85733 static int vti_net_id __read_mostly;
85734 struct vti_net {
85735 @@ -886,7 +886,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
85736 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
85737 };
85738
85739 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
85740 +static struct rtnl_link_ops vti_link_ops = {
85741 .kind = "vti",
85742 .maxtype = IFLA_VTI_MAX,
85743 .policy = vti_policy,
85744 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
85745 index f01d1b1..8fe03ad 100644
85746 --- a/net/ipv4/ipcomp.c
85747 +++ b/net/ipv4/ipcomp.c
85748 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
85749 return;
85750
85751 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
85752 - atomic_inc(&flow_cache_genid);
85753 + atomic_inc_unchecked(&flow_cache_genid);
85754 rt_genid_bump(net);
85755
85756 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
85757 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
85758 index bf6c5cf..ab2e9c6 100644
85759 --- a/net/ipv4/ipconfig.c
85760 +++ b/net/ipv4/ipconfig.c
85761 @@ -323,7 +323,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
85762
85763 mm_segment_t oldfs = get_fs();
85764 set_fs(get_ds());
85765 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
85766 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
85767 set_fs(oldfs);
85768 return res;
85769 }
85770 @@ -334,7 +334,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
85771
85772 mm_segment_t oldfs = get_fs();
85773 set_fs(get_ds());
85774 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
85775 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
85776 set_fs(oldfs);
85777 return res;
85778 }
85779 @@ -345,7 +345,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
85780
85781 mm_segment_t oldfs = get_fs();
85782 set_fs(get_ds());
85783 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
85784 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
85785 set_fs(oldfs);
85786 return res;
85787 }
85788 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
85789 index 8f024d4..8b3500c 100644
85790 --- a/net/ipv4/ipip.c
85791 +++ b/net/ipv4/ipip.c
85792 @@ -138,7 +138,7 @@ struct ipip_net {
85793 static int ipip_tunnel_init(struct net_device *dev);
85794 static void ipip_tunnel_setup(struct net_device *dev);
85795 static void ipip_dev_free(struct net_device *dev);
85796 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
85797 +static struct rtnl_link_ops ipip_link_ops;
85798
85799 static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev,
85800 struct rtnl_link_stats64 *tot)
85801 @@ -974,7 +974,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
85802 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
85803 };
85804
85805 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
85806 +static struct rtnl_link_ops ipip_link_ops = {
85807 .kind = "ipip",
85808 .maxtype = IFLA_IPTUN_MAX,
85809 .policy = ipip_policy,
85810 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
85811 index 7dc6a97..229c61b 100644
85812 --- a/net/ipv4/netfilter/arp_tables.c
85813 +++ b/net/ipv4/netfilter/arp_tables.c
85814 @@ -879,14 +879,14 @@ static int compat_table_info(const struct xt_table_info *info,
85815 #endif
85816
85817 static int get_info(struct net *net, void __user *user,
85818 - const int *len, int compat)
85819 + int len, int compat)
85820 {
85821 char name[XT_TABLE_MAXNAMELEN];
85822 struct xt_table *t;
85823 int ret;
85824
85825 - if (*len != sizeof(struct arpt_getinfo)) {
85826 - duprintf("length %u != %Zu\n", *len,
85827 + if (len != sizeof(struct arpt_getinfo)) {
85828 + duprintf("length %u != %Zu\n", len,
85829 sizeof(struct arpt_getinfo));
85830 return -EINVAL;
85831 }
85832 @@ -923,7 +923,7 @@ static int get_info(struct net *net, void __user *user,
85833 info.size = private->size;
85834 strcpy(info.name, name);
85835
85836 - if (copy_to_user(user, &info, *len) != 0)
85837 + if (copy_to_user(user, &info, len) != 0)
85838 ret = -EFAULT;
85839 else
85840 ret = 0;
85841 @@ -1682,7 +1682,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
85842
85843 switch (cmd) {
85844 case ARPT_SO_GET_INFO:
85845 - ret = get_info(sock_net(sk), user, len, 1);
85846 + ret = get_info(sock_net(sk), user, *len, 1);
85847 break;
85848 case ARPT_SO_GET_ENTRIES:
85849 ret = compat_get_entries(sock_net(sk), user, len);
85850 @@ -1727,7 +1727,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
85851
85852 switch (cmd) {
85853 case ARPT_SO_GET_INFO:
85854 - ret = get_info(sock_net(sk), user, len, 0);
85855 + ret = get_info(sock_net(sk), user, *len, 0);
85856 break;
85857
85858 case ARPT_SO_GET_ENTRIES:
85859 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
85860 index 3efcf87..5247916 100644
85861 --- a/net/ipv4/netfilter/ip_tables.c
85862 +++ b/net/ipv4/netfilter/ip_tables.c
85863 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
85864 #endif
85865
85866 static int get_info(struct net *net, void __user *user,
85867 - const int *len, int compat)
85868 + int len, int compat)
85869 {
85870 char name[XT_TABLE_MAXNAMELEN];
85871 struct xt_table *t;
85872 int ret;
85873
85874 - if (*len != sizeof(struct ipt_getinfo)) {
85875 - duprintf("length %u != %zu\n", *len,
85876 + if (len != sizeof(struct ipt_getinfo)) {
85877 + duprintf("length %u != %zu\n", len,
85878 sizeof(struct ipt_getinfo));
85879 return -EINVAL;
85880 }
85881 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
85882 info.size = private->size;
85883 strcpy(info.name, name);
85884
85885 - if (copy_to_user(user, &info, *len) != 0)
85886 + if (copy_to_user(user, &info, len) != 0)
85887 ret = -EFAULT;
85888 else
85889 ret = 0;
85890 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
85891
85892 switch (cmd) {
85893 case IPT_SO_GET_INFO:
85894 - ret = get_info(sock_net(sk), user, len, 1);
85895 + ret = get_info(sock_net(sk), user, *len, 1);
85896 break;
85897 case IPT_SO_GET_ENTRIES:
85898 ret = compat_get_entries(sock_net(sk), user, len);
85899 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
85900
85901 switch (cmd) {
85902 case IPT_SO_GET_INFO:
85903 - ret = get_info(sock_net(sk), user, len, 0);
85904 + ret = get_info(sock_net(sk), user, *len, 0);
85905 break;
85906
85907 case IPT_SO_GET_ENTRIES:
85908 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
85909 index 2e91006..f084394 100644
85910 --- a/net/ipv4/ping.c
85911 +++ b/net/ipv4/ping.c
85912 @@ -844,7 +844,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
85913 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
85914 0, sock_i_ino(sp),
85915 atomic_read(&sp->sk_refcnt), sp,
85916 - atomic_read(&sp->sk_drops), len);
85917 + atomic_read_unchecked(&sp->sk_drops), len);
85918 }
85919
85920 static int ping_seq_show(struct seq_file *seq, void *v)
85921 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
85922 index dd44e0a..06dcca4 100644
85923 --- a/net/ipv4/raw.c
85924 +++ b/net/ipv4/raw.c
85925 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
85926 int raw_rcv(struct sock *sk, struct sk_buff *skb)
85927 {
85928 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
85929 - atomic_inc(&sk->sk_drops);
85930 + atomic_inc_unchecked(&sk->sk_drops);
85931 kfree_skb(skb);
85932 return NET_RX_DROP;
85933 }
85934 @@ -745,16 +745,20 @@ static int raw_init(struct sock *sk)
85935
85936 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
85937 {
85938 + struct icmp_filter filter;
85939 +
85940 if (optlen > sizeof(struct icmp_filter))
85941 optlen = sizeof(struct icmp_filter);
85942 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
85943 + if (copy_from_user(&filter, optval, optlen))
85944 return -EFAULT;
85945 + raw_sk(sk)->filter = filter;
85946 return 0;
85947 }
85948
85949 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
85950 {
85951 int len, ret = -EFAULT;
85952 + struct icmp_filter filter;
85953
85954 if (get_user(len, optlen))
85955 goto out;
85956 @@ -764,8 +768,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
85957 if (len > sizeof(struct icmp_filter))
85958 len = sizeof(struct icmp_filter);
85959 ret = -EFAULT;
85960 - if (put_user(len, optlen) ||
85961 - copy_to_user(optval, &raw_sk(sk)->filter, len))
85962 + filter = raw_sk(sk)->filter;
85963 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
85964 goto out;
85965 ret = 0;
85966 out: return ret;
85967 @@ -994,7 +998,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
85968 0, 0L, 0,
85969 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
85970 0, sock_i_ino(sp),
85971 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
85972 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
85973 }
85974
85975 static int raw_seq_show(struct seq_file *seq, void *v)
85976 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
85977 index 6e28514..5e1b055 100644
85978 --- a/net/ipv4/route.c
85979 +++ b/net/ipv4/route.c
85980 @@ -2553,34 +2553,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
85981 .maxlen = sizeof(int),
85982 .mode = 0200,
85983 .proc_handler = ipv4_sysctl_rtcache_flush,
85984 + .extra1 = &init_net,
85985 },
85986 { },
85987 };
85988
85989 static __net_init int sysctl_route_net_init(struct net *net)
85990 {
85991 - struct ctl_table *tbl;
85992 + ctl_table_no_const *tbl = NULL;
85993
85994 - tbl = ipv4_route_flush_table;
85995 if (!net_eq(net, &init_net)) {
85996 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
85997 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
85998 if (tbl == NULL)
85999 goto err_dup;
86000
86001 /* Don't export sysctls to unprivileged users */
86002 if (net->user_ns != &init_user_ns)
86003 tbl[0].procname = NULL;
86004 - }
86005 - tbl[0].extra1 = net;
86006 + tbl[0].extra1 = net;
86007 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
86008 + } else
86009 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
86010
86011 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
86012 if (net->ipv4.route_hdr == NULL)
86013 goto err_reg;
86014 return 0;
86015
86016 err_reg:
86017 - if (tbl != ipv4_route_flush_table)
86018 - kfree(tbl);
86019 + kfree(tbl);
86020 err_dup:
86021 return -ENOMEM;
86022 }
86023 @@ -2603,7 +2603,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
86024
86025 static __net_init int rt_genid_init(struct net *net)
86026 {
86027 - atomic_set(&net->rt_genid, 0);
86028 + atomic_set_unchecked(&net->rt_genid, 0);
86029 get_random_bytes(&net->ipv4.dev_addr_genid,
86030 sizeof(net->ipv4.dev_addr_genid));
86031 return 0;
86032 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
86033 index 960fd29..d55bf64 100644
86034 --- a/net/ipv4/sysctl_net_ipv4.c
86035 +++ b/net/ipv4/sysctl_net_ipv4.c
86036 @@ -55,7 +55,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
86037 {
86038 int ret;
86039 int range[2];
86040 - ctl_table tmp = {
86041 + ctl_table_no_const tmp = {
86042 .data = &range,
86043 .maxlen = sizeof(range),
86044 .mode = table->mode,
86045 @@ -108,7 +108,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
86046 int ret;
86047 gid_t urange[2];
86048 kgid_t low, high;
86049 - ctl_table tmp = {
86050 + ctl_table_no_const tmp = {
86051 .data = &urange,
86052 .maxlen = sizeof(urange),
86053 .mode = table->mode,
86054 @@ -139,7 +139,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
86055 void __user *buffer, size_t *lenp, loff_t *ppos)
86056 {
86057 char val[TCP_CA_NAME_MAX];
86058 - ctl_table tbl = {
86059 + ctl_table_no_const tbl = {
86060 .data = val,
86061 .maxlen = TCP_CA_NAME_MAX,
86062 };
86063 @@ -158,7 +158,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
86064 void __user *buffer, size_t *lenp,
86065 loff_t *ppos)
86066 {
86067 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
86068 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
86069 int ret;
86070
86071 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
86072 @@ -175,7 +175,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
86073 void __user *buffer, size_t *lenp,
86074 loff_t *ppos)
86075 {
86076 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
86077 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
86078 int ret;
86079
86080 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
86081 @@ -201,15 +201,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
86082 struct mem_cgroup *memcg;
86083 #endif
86084
86085 - ctl_table tmp = {
86086 + ctl_table_no_const tmp = {
86087 .data = &vec,
86088 .maxlen = sizeof(vec),
86089 .mode = ctl->mode,
86090 };
86091
86092 if (!write) {
86093 - ctl->data = &net->ipv4.sysctl_tcp_mem;
86094 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
86095 + ctl_table_no_const tcp_mem = *ctl;
86096 +
86097 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
86098 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
86099 }
86100
86101 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
86102 @@ -236,7 +238,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
86103 static int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
86104 size_t *lenp, loff_t *ppos)
86105 {
86106 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
86107 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
86108 struct tcp_fastopen_context *ctxt;
86109 int ret;
86110 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
86111 @@ -477,7 +479,7 @@ static struct ctl_table ipv4_table[] = {
86112 },
86113 {
86114 .procname = "ip_local_reserved_ports",
86115 - .data = NULL, /* initialized in sysctl_ipv4_init */
86116 + .data = sysctl_local_reserved_ports,
86117 .maxlen = 65536,
86118 .mode = 0644,
86119 .proc_handler = proc_do_large_bitmap,
86120 @@ -856,11 +858,10 @@ static struct ctl_table ipv4_net_table[] = {
86121
86122 static __net_init int ipv4_sysctl_init_net(struct net *net)
86123 {
86124 - struct ctl_table *table;
86125 + ctl_table_no_const *table = NULL;
86126
86127 - table = ipv4_net_table;
86128 if (!net_eq(net, &init_net)) {
86129 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
86130 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
86131 if (table == NULL)
86132 goto err_alloc;
86133
86134 @@ -895,15 +896,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
86135
86136 tcp_init_mem(net);
86137
86138 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
86139 + if (!net_eq(net, &init_net))
86140 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
86141 + else
86142 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
86143 if (net->ipv4.ipv4_hdr == NULL)
86144 goto err_reg;
86145
86146 return 0;
86147
86148 err_reg:
86149 - if (!net_eq(net, &init_net))
86150 - kfree(table);
86151 + kfree(table);
86152 err_alloc:
86153 return -ENOMEM;
86154 }
86155 @@ -925,16 +928,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
86156 static __init int sysctl_ipv4_init(void)
86157 {
86158 struct ctl_table_header *hdr;
86159 - struct ctl_table *i;
86160 -
86161 - for (i = ipv4_table; i->procname; i++) {
86162 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
86163 - i->data = sysctl_local_reserved_ports;
86164 - break;
86165 - }
86166 - }
86167 - if (!i->procname)
86168 - return -EINVAL;
86169
86170 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
86171 if (hdr == NULL)
86172 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
86173 index 13b9c08..d33a8d0 100644
86174 --- a/net/ipv4/tcp_input.c
86175 +++ b/net/ipv4/tcp_input.c
86176 @@ -4724,7 +4724,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
86177 * simplifies code)
86178 */
86179 static void
86180 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
86181 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
86182 struct sk_buff *head, struct sk_buff *tail,
86183 u32 start, u32 end)
86184 {
86185 @@ -5838,6 +5838,7 @@ discard:
86186 tcp_paws_reject(&tp->rx_opt, 0))
86187 goto discard_and_undo;
86188
86189 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
86190 if (th->syn) {
86191 /* We see SYN without ACK. It is attempt of
86192 * simultaneous connect with crossed SYNs.
86193 @@ -5888,6 +5889,7 @@ discard:
86194 goto discard;
86195 #endif
86196 }
86197 +#endif
86198 /* "fifth, if neither of the SYN or RST bits is set then
86199 * drop the segment and return."
86200 */
86201 @@ -5932,7 +5934,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
86202 goto discard;
86203
86204 if (th->syn) {
86205 - if (th->fin)
86206 + if (th->fin || th->urg || th->psh)
86207 goto discard;
86208 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
86209 return 1;
86210 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
86211 index d09203c..fd5cc91 100644
86212 --- a/net/ipv4/tcp_ipv4.c
86213 +++ b/net/ipv4/tcp_ipv4.c
86214 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
86215 EXPORT_SYMBOL(sysctl_tcp_low_latency);
86216
86217
86218 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86219 +extern int grsec_enable_blackhole;
86220 +#endif
86221 +
86222 #ifdef CONFIG_TCP_MD5SIG
86223 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
86224 __be32 daddr, __be32 saddr, const struct tcphdr *th);
86225 @@ -1897,6 +1901,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
86226 return 0;
86227
86228 reset:
86229 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86230 + if (!grsec_enable_blackhole)
86231 +#endif
86232 tcp_v4_send_reset(rsk, skb);
86233 discard:
86234 kfree_skb(skb);
86235 @@ -1996,12 +2003,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
86236 TCP_SKB_CB(skb)->sacked = 0;
86237
86238 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
86239 - if (!sk)
86240 + if (!sk) {
86241 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86242 + ret = 1;
86243 +#endif
86244 goto no_tcp_socket;
86245 -
86246 + }
86247 process:
86248 - if (sk->sk_state == TCP_TIME_WAIT)
86249 + if (sk->sk_state == TCP_TIME_WAIT) {
86250 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86251 + ret = 2;
86252 +#endif
86253 goto do_time_wait;
86254 + }
86255
86256 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
86257 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
86258 @@ -2052,6 +2066,10 @@ no_tcp_socket:
86259 bad_packet:
86260 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
86261 } else {
86262 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86263 + if (!grsec_enable_blackhole || (ret == 1 &&
86264 + (skb->dev->flags & IFF_LOOPBACK)))
86265 +#endif
86266 tcp_v4_send_reset(NULL, skb);
86267 }
86268
86269 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
86270 index b83a49c..6c562a7 100644
86271 --- a/net/ipv4/tcp_minisocks.c
86272 +++ b/net/ipv4/tcp_minisocks.c
86273 @@ -27,6 +27,10 @@
86274 #include <net/inet_common.h>
86275 #include <net/xfrm.h>
86276
86277 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86278 +extern int grsec_enable_blackhole;
86279 +#endif
86280 +
86281 int sysctl_tcp_syncookies __read_mostly = 1;
86282 EXPORT_SYMBOL(sysctl_tcp_syncookies);
86283
86284 @@ -744,7 +748,10 @@ embryonic_reset:
86285 * avoid becoming vulnerable to outside attack aiming at
86286 * resetting legit local connections.
86287 */
86288 - req->rsk_ops->send_reset(sk, skb);
86289 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86290 + if (!grsec_enable_blackhole)
86291 +#endif
86292 + req->rsk_ops->send_reset(sk, skb);
86293 } else if (fastopen) { /* received a valid RST pkt */
86294 reqsk_fastopen_remove(sk, req, true);
86295 tcp_reset(sk);
86296 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
86297 index d4943f6..e7a74a5 100644
86298 --- a/net/ipv4/tcp_probe.c
86299 +++ b/net/ipv4/tcp_probe.c
86300 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
86301 if (cnt + width >= len)
86302 break;
86303
86304 - if (copy_to_user(buf + cnt, tbuf, width))
86305 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
86306 return -EFAULT;
86307 cnt += width;
86308 }
86309 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
86310 index b78aac3..e18230b 100644
86311 --- a/net/ipv4/tcp_timer.c
86312 +++ b/net/ipv4/tcp_timer.c
86313 @@ -22,6 +22,10 @@
86314 #include <linux/gfp.h>
86315 #include <net/tcp.h>
86316
86317 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86318 +extern int grsec_lastack_retries;
86319 +#endif
86320 +
86321 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
86322 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
86323 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
86324 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
86325 }
86326 }
86327
86328 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86329 + if ((sk->sk_state == TCP_LAST_ACK) &&
86330 + (grsec_lastack_retries > 0) &&
86331 + (grsec_lastack_retries < retry_until))
86332 + retry_until = grsec_lastack_retries;
86333 +#endif
86334 +
86335 if (retransmits_timed_out(sk, retry_until,
86336 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
86337 /* Has it gone just too far? */
86338 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
86339 index 0a073a2..ddf6279 100644
86340 --- a/net/ipv4/udp.c
86341 +++ b/net/ipv4/udp.c
86342 @@ -87,6 +87,7 @@
86343 #include <linux/types.h>
86344 #include <linux/fcntl.h>
86345 #include <linux/module.h>
86346 +#include <linux/security.h>
86347 #include <linux/socket.h>
86348 #include <linux/sockios.h>
86349 #include <linux/igmp.h>
86350 @@ -111,6 +112,10 @@
86351 #include <trace/events/skb.h>
86352 #include "udp_impl.h"
86353
86354 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86355 +extern int grsec_enable_blackhole;
86356 +#endif
86357 +
86358 struct udp_table udp_table __read_mostly;
86359 EXPORT_SYMBOL(udp_table);
86360
86361 @@ -594,6 +599,9 @@ found:
86362 return s;
86363 }
86364
86365 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
86366 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
86367 +
86368 /*
86369 * This routine is called by the ICMP module when it gets some
86370 * sort of error condition. If err < 0 then the socket should
86371 @@ -889,9 +897,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
86372 dport = usin->sin_port;
86373 if (dport == 0)
86374 return -EINVAL;
86375 +
86376 + err = gr_search_udp_sendmsg(sk, usin);
86377 + if (err)
86378 + return err;
86379 } else {
86380 if (sk->sk_state != TCP_ESTABLISHED)
86381 return -EDESTADDRREQ;
86382 +
86383 + err = gr_search_udp_sendmsg(sk, NULL);
86384 + if (err)
86385 + return err;
86386 +
86387 daddr = inet->inet_daddr;
86388 dport = inet->inet_dport;
86389 /* Open fast path for connected socket.
86390 @@ -1133,7 +1150,7 @@ static unsigned int first_packet_length(struct sock *sk)
86391 udp_lib_checksum_complete(skb)) {
86392 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
86393 IS_UDPLITE(sk));
86394 - atomic_inc(&sk->sk_drops);
86395 + atomic_inc_unchecked(&sk->sk_drops);
86396 __skb_unlink(skb, rcvq);
86397 __skb_queue_tail(&list_kill, skb);
86398 }
86399 @@ -1219,6 +1236,10 @@ try_again:
86400 if (!skb)
86401 goto out;
86402
86403 + err = gr_search_udp_recvmsg(sk, skb);
86404 + if (err)
86405 + goto out_free;
86406 +
86407 ulen = skb->len - sizeof(struct udphdr);
86408 copied = len;
86409 if (copied > ulen)
86410 @@ -1252,7 +1273,7 @@ try_again:
86411 if (unlikely(err)) {
86412 trace_kfree_skb(skb, udp_recvmsg);
86413 if (!peeked) {
86414 - atomic_inc(&sk->sk_drops);
86415 + atomic_inc_unchecked(&sk->sk_drops);
86416 UDP_INC_STATS_USER(sock_net(sk),
86417 UDP_MIB_INERRORS, is_udplite);
86418 }
86419 @@ -1535,7 +1556,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86420
86421 drop:
86422 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
86423 - atomic_inc(&sk->sk_drops);
86424 + atomic_inc_unchecked(&sk->sk_drops);
86425 kfree_skb(skb);
86426 return -1;
86427 }
86428 @@ -1554,7 +1575,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
86429 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
86430
86431 if (!skb1) {
86432 - atomic_inc(&sk->sk_drops);
86433 + atomic_inc_unchecked(&sk->sk_drops);
86434 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
86435 IS_UDPLITE(sk));
86436 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
86437 @@ -1723,6 +1744,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
86438 goto csum_error;
86439
86440 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
86441 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86442 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
86443 +#endif
86444 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
86445
86446 /*
86447 @@ -2152,7 +2176,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
86448 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
86449 0, sock_i_ino(sp),
86450 atomic_read(&sp->sk_refcnt), sp,
86451 - atomic_read(&sp->sk_drops), len);
86452 + atomic_read_unchecked(&sp->sk_drops), len);
86453 }
86454
86455 int udp4_seq_show(struct seq_file *seq, void *v)
86456 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
86457 index 9a459be..086b866 100644
86458 --- a/net/ipv4/xfrm4_policy.c
86459 +++ b/net/ipv4/xfrm4_policy.c
86460 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
86461
86462 static int __net_init xfrm4_net_init(struct net *net)
86463 {
86464 - struct ctl_table *table;
86465 + ctl_table_no_const *table = NULL;
86466 struct ctl_table_header *hdr;
86467
86468 - table = xfrm4_policy_table;
86469 if (!net_eq(net, &init_net)) {
86470 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
86471 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
86472 if (!table)
86473 goto err_alloc;
86474
86475 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
86476 - }
86477 -
86478 - hdr = register_net_sysctl(net, "net/ipv4", table);
86479 + hdr = register_net_sysctl(net, "net/ipv4", table);
86480 + } else
86481 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
86482 if (!hdr)
86483 goto err_reg;
86484
86485 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
86486 return 0;
86487
86488 err_reg:
86489 - if (!net_eq(net, &init_net))
86490 - kfree(table);
86491 + kfree(table);
86492 err_alloc:
86493 return -ENOMEM;
86494 }
86495 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
86496 index dae802c..bfa4baa 100644
86497 --- a/net/ipv6/addrconf.c
86498 +++ b/net/ipv6/addrconf.c
86499 @@ -2274,7 +2274,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
86500 p.iph.ihl = 5;
86501 p.iph.protocol = IPPROTO_IPV6;
86502 p.iph.ttl = 64;
86503 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
86504 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
86505
86506 if (ops->ndo_do_ioctl) {
86507 mm_segment_t oldfs = get_fs();
86508 @@ -4410,7 +4410,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
86509 int *valp = ctl->data;
86510 int val = *valp;
86511 loff_t pos = *ppos;
86512 - ctl_table lctl;
86513 + ctl_table_no_const lctl;
86514 int ret;
86515
86516 /*
86517 @@ -4492,7 +4492,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
86518 int *valp = ctl->data;
86519 int val = *valp;
86520 loff_t pos = *ppos;
86521 - ctl_table lctl;
86522 + ctl_table_no_const lctl;
86523 int ret;
86524
86525 /*
86526 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
86527 index fff5bdd..15194fb 100644
86528 --- a/net/ipv6/icmp.c
86529 +++ b/net/ipv6/icmp.c
86530 @@ -973,7 +973,7 @@ ctl_table ipv6_icmp_table_template[] = {
86531
86532 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
86533 {
86534 - struct ctl_table *table;
86535 + ctl_table_no_const *table;
86536
86537 table = kmemdup(ipv6_icmp_table_template,
86538 sizeof(ipv6_icmp_table_template),
86539 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
86540 index e4efffe..d415772 100644
86541 --- a/net/ipv6/ip6_gre.c
86542 +++ b/net/ipv6/ip6_gre.c
86543 @@ -73,7 +73,7 @@ struct ip6gre_net {
86544 struct net_device *fb_tunnel_dev;
86545 };
86546
86547 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
86548 +static struct rtnl_link_ops ip6gre_link_ops;
86549 static int ip6gre_tunnel_init(struct net_device *dev);
86550 static void ip6gre_tunnel_setup(struct net_device *dev);
86551 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
86552 @@ -1335,7 +1335,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
86553 }
86554
86555
86556 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
86557 +static struct inet6_protocol ip6gre_protocol = {
86558 .handler = ip6gre_rcv,
86559 .err_handler = ip6gre_err,
86560 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
86561 @@ -1669,7 +1669,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
86562 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
86563 };
86564
86565 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
86566 +static struct rtnl_link_ops ip6gre_link_ops = {
86567 .kind = "ip6gre",
86568 .maxtype = IFLA_GRE_MAX,
86569 .policy = ip6gre_policy,
86570 @@ -1682,7 +1682,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
86571 .fill_info = ip6gre_fill_info,
86572 };
86573
86574 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
86575 +static struct rtnl_link_ops ip6gre_tap_ops = {
86576 .kind = "ip6gretap",
86577 .maxtype = IFLA_GRE_MAX,
86578 .policy = ip6gre_policy,
86579 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
86580 index fff83cb..82d49dd 100644
86581 --- a/net/ipv6/ip6_tunnel.c
86582 +++ b/net/ipv6/ip6_tunnel.c
86583 @@ -87,7 +87,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
86584
86585 static int ip6_tnl_dev_init(struct net_device *dev);
86586 static void ip6_tnl_dev_setup(struct net_device *dev);
86587 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
86588 +static struct rtnl_link_ops ip6_link_ops;
86589
86590 static int ip6_tnl_net_id __read_mostly;
86591 struct ip6_tnl_net {
86592 @@ -1684,7 +1684,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
86593 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
86594 };
86595
86596 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
86597 +static struct rtnl_link_ops ip6_link_ops = {
86598 .kind = "ip6tnl",
86599 .maxtype = IFLA_IPTUN_MAX,
86600 .policy = ip6_tnl_policy,
86601 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
86602 index d1e2e8e..51c19ae 100644
86603 --- a/net/ipv6/ipv6_sockglue.c
86604 +++ b/net/ipv6/ipv6_sockglue.c
86605 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
86606 if (sk->sk_type != SOCK_STREAM)
86607 return -ENOPROTOOPT;
86608
86609 - msg.msg_control = optval;
86610 + msg.msg_control = (void __force_kernel *)optval;
86611 msg.msg_controllen = len;
86612 msg.msg_flags = flags;
86613
86614 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
86615 index 341b54a..591e8ed 100644
86616 --- a/net/ipv6/netfilter/ip6_tables.c
86617 +++ b/net/ipv6/netfilter/ip6_tables.c
86618 @@ -1076,14 +1076,14 @@ static int compat_table_info(const struct xt_table_info *info,
86619 #endif
86620
86621 static int get_info(struct net *net, void __user *user,
86622 - const int *len, int compat)
86623 + int len, int compat)
86624 {
86625 char name[XT_TABLE_MAXNAMELEN];
86626 struct xt_table *t;
86627 int ret;
86628
86629 - if (*len != sizeof(struct ip6t_getinfo)) {
86630 - duprintf("length %u != %zu\n", *len,
86631 + if (len != sizeof(struct ip6t_getinfo)) {
86632 + duprintf("length %u != %zu\n", len,
86633 sizeof(struct ip6t_getinfo));
86634 return -EINVAL;
86635 }
86636 @@ -1120,7 +1120,7 @@ static int get_info(struct net *net, void __user *user,
86637 info.size = private->size;
86638 strcpy(info.name, name);
86639
86640 - if (copy_to_user(user, &info, *len) != 0)
86641 + if (copy_to_user(user, &info, len) != 0)
86642 ret = -EFAULT;
86643 else
86644 ret = 0;
86645 @@ -1974,7 +1974,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86646
86647 switch (cmd) {
86648 case IP6T_SO_GET_INFO:
86649 - ret = get_info(sock_net(sk), user, len, 1);
86650 + ret = get_info(sock_net(sk), user, *len, 1);
86651 break;
86652 case IP6T_SO_GET_ENTRIES:
86653 ret = compat_get_entries(sock_net(sk), user, len);
86654 @@ -2021,7 +2021,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86655
86656 switch (cmd) {
86657 case IP6T_SO_GET_INFO:
86658 - ret = get_info(sock_net(sk), user, len, 0);
86659 + ret = get_info(sock_net(sk), user, *len, 0);
86660 break;
86661
86662 case IP6T_SO_GET_ENTRIES:
86663 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
86664 index 6700069..1e50f42 100644
86665 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
86666 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
86667 @@ -89,12 +89,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
86668
86669 static int nf_ct_frag6_sysctl_register(struct net *net)
86670 {
86671 - struct ctl_table *table;
86672 + ctl_table_no_const *table = NULL;
86673 struct ctl_table_header *hdr;
86674
86675 - table = nf_ct_frag6_sysctl_table;
86676 if (!net_eq(net, &init_net)) {
86677 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
86678 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
86679 GFP_KERNEL);
86680 if (table == NULL)
86681 goto err_alloc;
86682 @@ -102,9 +101,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
86683 table[0].data = &net->nf_frag.frags.timeout;
86684 table[1].data = &net->nf_frag.frags.low_thresh;
86685 table[2].data = &net->nf_frag.frags.high_thresh;
86686 - }
86687 -
86688 - hdr = register_net_sysctl(net, "net/netfilter", table);
86689 + hdr = register_net_sysctl(net, "net/netfilter", table);
86690 + } else
86691 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
86692 if (hdr == NULL)
86693 goto err_reg;
86694
86695 @@ -112,8 +111,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
86696 return 0;
86697
86698 err_reg:
86699 - if (!net_eq(net, &init_net))
86700 - kfree(table);
86701 + kfree(table);
86702 err_alloc:
86703 return -ENOMEM;
86704 }
86705 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
86706 index 330b5e7..796fbf1 100644
86707 --- a/net/ipv6/raw.c
86708 +++ b/net/ipv6/raw.c
86709 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
86710 {
86711 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
86712 skb_checksum_complete(skb)) {
86713 - atomic_inc(&sk->sk_drops);
86714 + atomic_inc_unchecked(&sk->sk_drops);
86715 kfree_skb(skb);
86716 return NET_RX_DROP;
86717 }
86718 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
86719 struct raw6_sock *rp = raw6_sk(sk);
86720
86721 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
86722 - atomic_inc(&sk->sk_drops);
86723 + atomic_inc_unchecked(&sk->sk_drops);
86724 kfree_skb(skb);
86725 return NET_RX_DROP;
86726 }
86727 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
86728
86729 if (inet->hdrincl) {
86730 if (skb_checksum_complete(skb)) {
86731 - atomic_inc(&sk->sk_drops);
86732 + atomic_inc_unchecked(&sk->sk_drops);
86733 kfree_skb(skb);
86734 return NET_RX_DROP;
86735 }
86736 @@ -603,7 +603,7 @@ out:
86737 return err;
86738 }
86739
86740 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
86741 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
86742 struct flowi6 *fl6, struct dst_entry **dstp,
86743 unsigned int flags)
86744 {
86745 @@ -915,12 +915,15 @@ do_confirm:
86746 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
86747 char __user *optval, int optlen)
86748 {
86749 + struct icmp6_filter filter;
86750 +
86751 switch (optname) {
86752 case ICMPV6_FILTER:
86753 if (optlen > sizeof(struct icmp6_filter))
86754 optlen = sizeof(struct icmp6_filter);
86755 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
86756 + if (copy_from_user(&filter, optval, optlen))
86757 return -EFAULT;
86758 + raw6_sk(sk)->filter = filter;
86759 return 0;
86760 default:
86761 return -ENOPROTOOPT;
86762 @@ -933,6 +936,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
86763 char __user *optval, int __user *optlen)
86764 {
86765 int len;
86766 + struct icmp6_filter filter;
86767
86768 switch (optname) {
86769 case ICMPV6_FILTER:
86770 @@ -944,7 +948,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
86771 len = sizeof(struct icmp6_filter);
86772 if (put_user(len, optlen))
86773 return -EFAULT;
86774 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
86775 + filter = raw6_sk(sk)->filter;
86776 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
86777 return -EFAULT;
86778 return 0;
86779 default:
86780 @@ -1252,7 +1257,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
86781 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
86782 0,
86783 sock_i_ino(sp),
86784 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
86785 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
86786 }
86787
86788 static int raw6_seq_show(struct seq_file *seq, void *v)
86789 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
86790 index 0ba10e5..c14a4f6 100644
86791 --- a/net/ipv6/reassembly.c
86792 +++ b/net/ipv6/reassembly.c
86793 @@ -602,12 +602,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
86794
86795 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
86796 {
86797 - struct ctl_table *table;
86798 + ctl_table_no_const *table = NULL;
86799 struct ctl_table_header *hdr;
86800
86801 - table = ip6_frags_ns_ctl_table;
86802 if (!net_eq(net, &init_net)) {
86803 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
86804 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
86805 if (table == NULL)
86806 goto err_alloc;
86807
86808 @@ -618,9 +617,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
86809 /* Don't export sysctls to unprivileged users */
86810 if (net->user_ns != &init_user_ns)
86811 table[0].procname = NULL;
86812 - }
86813 + hdr = register_net_sysctl(net, "net/ipv6", table);
86814 + } else
86815 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
86816
86817 - hdr = register_net_sysctl(net, "net/ipv6", table);
86818 if (hdr == NULL)
86819 goto err_reg;
86820
86821 @@ -628,8 +628,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
86822 return 0;
86823
86824 err_reg:
86825 - if (!net_eq(net, &init_net))
86826 - kfree(table);
86827 + kfree(table);
86828 err_alloc:
86829 return -ENOMEM;
86830 }
86831 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
86832 index e5fe004..9fe3e8e 100644
86833 --- a/net/ipv6/route.c
86834 +++ b/net/ipv6/route.c
86835 @@ -2881,7 +2881,7 @@ ctl_table ipv6_route_table_template[] = {
86836
86837 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
86838 {
86839 - struct ctl_table *table;
86840 + ctl_table_no_const *table;
86841
86842 table = kmemdup(ipv6_route_table_template,
86843 sizeof(ipv6_route_table_template),
86844 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
86845 index 02f96dc..4a5a6e5 100644
86846 --- a/net/ipv6/sit.c
86847 +++ b/net/ipv6/sit.c
86848 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
86849 static void ipip6_dev_free(struct net_device *dev);
86850 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
86851 __be32 *v4dst);
86852 -static struct rtnl_link_ops sit_link_ops __read_mostly;
86853 +static struct rtnl_link_ops sit_link_ops;
86854
86855 static int sit_net_id __read_mostly;
86856 struct sit_net {
86857 @@ -1486,7 +1486,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
86858 #endif
86859 };
86860
86861 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
86862 +static struct rtnl_link_ops sit_link_ops = {
86863 .kind = "sit",
86864 .maxtype = IFLA_IPTUN_MAX,
86865 .policy = ipip6_policy,
86866 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
86867 index e85c48b..b8268d3 100644
86868 --- a/net/ipv6/sysctl_net_ipv6.c
86869 +++ b/net/ipv6/sysctl_net_ipv6.c
86870 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
86871
86872 static int __net_init ipv6_sysctl_net_init(struct net *net)
86873 {
86874 - struct ctl_table *ipv6_table;
86875 + ctl_table_no_const *ipv6_table;
86876 struct ctl_table *ipv6_route_table;
86877 struct ctl_table *ipv6_icmp_table;
86878 int err;
86879 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
86880 index 46a5be8..415688d 100644
86881 --- a/net/ipv6/tcp_ipv6.c
86882 +++ b/net/ipv6/tcp_ipv6.c
86883 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
86884 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
86885 }
86886
86887 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86888 +extern int grsec_enable_blackhole;
86889 +#endif
86890 +
86891 static void tcp_v6_hash(struct sock *sk)
86892 {
86893 if (sk->sk_state != TCP_CLOSE) {
86894 @@ -1446,6 +1450,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
86895 return 0;
86896
86897 reset:
86898 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86899 + if (!grsec_enable_blackhole)
86900 +#endif
86901 tcp_v6_send_reset(sk, skb);
86902 discard:
86903 if (opt_skb)
86904 @@ -1527,12 +1534,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
86905 TCP_SKB_CB(skb)->sacked = 0;
86906
86907 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
86908 - if (!sk)
86909 + if (!sk) {
86910 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86911 + ret = 1;
86912 +#endif
86913 goto no_tcp_socket;
86914 + }
86915
86916 process:
86917 - if (sk->sk_state == TCP_TIME_WAIT)
86918 + if (sk->sk_state == TCP_TIME_WAIT) {
86919 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86920 + ret = 2;
86921 +#endif
86922 goto do_time_wait;
86923 + }
86924
86925 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
86926 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
86927 @@ -1581,6 +1596,10 @@ no_tcp_socket:
86928 bad_packet:
86929 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
86930 } else {
86931 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86932 + if (!grsec_enable_blackhole || (ret == 1 &&
86933 + (skb->dev->flags & IFF_LOOPBACK)))
86934 +#endif
86935 tcp_v6_send_reset(NULL, skb);
86936 }
86937
86938 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
86939 index d8e5e85..5a447f4 100644
86940 --- a/net/ipv6/udp.c
86941 +++ b/net/ipv6/udp.c
86942 @@ -52,6 +52,10 @@
86943 #include <trace/events/skb.h>
86944 #include "udp_impl.h"
86945
86946 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86947 +extern int grsec_enable_blackhole;
86948 +#endif
86949 +
86950 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
86951 {
86952 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
86953 @@ -419,7 +423,7 @@ try_again:
86954 if (unlikely(err)) {
86955 trace_kfree_skb(skb, udpv6_recvmsg);
86956 if (!peeked) {
86957 - atomic_inc(&sk->sk_drops);
86958 + atomic_inc_unchecked(&sk->sk_drops);
86959 if (is_udp4)
86960 UDP_INC_STATS_USER(sock_net(sk),
86961 UDP_MIB_INERRORS,
86962 @@ -657,7 +661,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86963 return rc;
86964 drop:
86965 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
86966 - atomic_inc(&sk->sk_drops);
86967 + atomic_inc_unchecked(&sk->sk_drops);
86968 kfree_skb(skb);
86969 return -1;
86970 }
86971 @@ -715,7 +719,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
86972 if (likely(skb1 == NULL))
86973 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
86974 if (!skb1) {
86975 - atomic_inc(&sk->sk_drops);
86976 + atomic_inc_unchecked(&sk->sk_drops);
86977 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
86978 IS_UDPLITE(sk));
86979 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
86980 @@ -852,6 +856,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
86981 goto discard;
86982
86983 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
86984 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
86985 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
86986 +#endif
86987 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
86988
86989 kfree_skb(skb);
86990 @@ -1377,7 +1384,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
86991 0,
86992 sock_i_ino(sp),
86993 atomic_read(&sp->sk_refcnt), sp,
86994 - atomic_read(&sp->sk_drops));
86995 + atomic_read_unchecked(&sp->sk_drops));
86996 }
86997
86998 int udp6_seq_show(struct seq_file *seq, void *v)
86999 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
87000 index 4ef7bdb..9e97017 100644
87001 --- a/net/ipv6/xfrm6_policy.c
87002 +++ b/net/ipv6/xfrm6_policy.c
87003 @@ -322,19 +322,19 @@ static struct ctl_table xfrm6_policy_table[] = {
87004
87005 static int __net_init xfrm6_net_init(struct net *net)
87006 {
87007 - struct ctl_table *table;
87008 + ctl_table_no_const *table = NULL;
87009 struct ctl_table_header *hdr;
87010
87011 - table = xfrm6_policy_table;
87012 if (!net_eq(net, &init_net)) {
87013 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
87014 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
87015 if (!table)
87016 goto err_alloc;
87017
87018 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
87019 - }
87020 + hdr = register_net_sysctl(net, "net/ipv6", table);
87021 + } else
87022 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
87023
87024 - hdr = register_net_sysctl(net, "net/ipv6", table);
87025 if (!hdr)
87026 goto err_reg;
87027
87028 @@ -342,8 +342,7 @@ static int __net_init xfrm6_net_init(struct net *net)
87029 return 0;
87030
87031 err_reg:
87032 - if (!net_eq(net, &init_net))
87033 - kfree(table);
87034 + kfree(table);
87035 err_alloc:
87036 return -ENOMEM;
87037 }
87038 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
87039 index 362ba47..66196f4 100644
87040 --- a/net/irda/ircomm/ircomm_tty.c
87041 +++ b/net/irda/ircomm/ircomm_tty.c
87042 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87043 add_wait_queue(&port->open_wait, &wait);
87044
87045 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
87046 - __FILE__, __LINE__, tty->driver->name, port->count);
87047 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87048
87049 spin_lock_irqsave(&port->lock, flags);
87050 if (!tty_hung_up_p(filp))
87051 - port->count--;
87052 + atomic_dec(&port->count);
87053 port->blocked_open++;
87054 spin_unlock_irqrestore(&port->lock, flags);
87055
87056 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87057 }
87058
87059 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
87060 - __FILE__, __LINE__, tty->driver->name, port->count);
87061 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87062
87063 schedule();
87064 }
87065 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
87066
87067 spin_lock_irqsave(&port->lock, flags);
87068 if (!tty_hung_up_p(filp))
87069 - port->count++;
87070 + atomic_inc(&port->count);
87071 port->blocked_open--;
87072 spin_unlock_irqrestore(&port->lock, flags);
87073
87074 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
87075 - __FILE__, __LINE__, tty->driver->name, port->count);
87076 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
87077
87078 if (!retval)
87079 port->flags |= ASYNC_NORMAL_ACTIVE;
87080 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
87081
87082 /* ++ is not atomic, so this should be protected - Jean II */
87083 spin_lock_irqsave(&self->port.lock, flags);
87084 - self->port.count++;
87085 + atomic_inc(&self->port.count);
87086 spin_unlock_irqrestore(&self->port.lock, flags);
87087 tty_port_tty_set(&self->port, tty);
87088
87089 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
87090 - self->line, self->port.count);
87091 + self->line, atomic_read(&self->port.count));
87092
87093 /* Not really used by us, but lets do it anyway */
87094 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
87095 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
87096 tty_kref_put(port->tty);
87097 }
87098 port->tty = NULL;
87099 - port->count = 0;
87100 + atomic_set(&port->count, 0);
87101 spin_unlock_irqrestore(&port->lock, flags);
87102
87103 wake_up_interruptible(&port->open_wait);
87104 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
87105 seq_putc(m, '\n');
87106
87107 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
87108 - seq_printf(m, "Open count: %d\n", self->port.count);
87109 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
87110 seq_printf(m, "Max data size: %d\n", self->max_data_size);
87111 seq_printf(m, "Max header size: %d\n", self->max_header_size);
87112
87113 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
87114 index 206ce6d..cfb27cd 100644
87115 --- a/net/iucv/af_iucv.c
87116 +++ b/net/iucv/af_iucv.c
87117 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
87118
87119 write_lock_bh(&iucv_sk_list.lock);
87120
87121 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
87122 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
87123 while (__iucv_get_sock_by_name(name)) {
87124 sprintf(name, "%08x",
87125 - atomic_inc_return(&iucv_sk_list.autobind_name));
87126 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
87127 }
87128
87129 write_unlock_bh(&iucv_sk_list.lock);
87130 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
87131 index 4fe76ff..426a904 100644
87132 --- a/net/iucv/iucv.c
87133 +++ b/net/iucv/iucv.c
87134 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
87135 return NOTIFY_OK;
87136 }
87137
87138 -static struct notifier_block __refdata iucv_cpu_notifier = {
87139 +static struct notifier_block iucv_cpu_notifier = {
87140 .notifier_call = iucv_cpu_notify,
87141 };
87142
87143 diff --git a/net/key/af_key.c b/net/key/af_key.c
87144 index 5b1e5af..2358147 100644
87145 --- a/net/key/af_key.c
87146 +++ b/net/key/af_key.c
87147 @@ -3041,10 +3041,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
87148 static u32 get_acqseq(void)
87149 {
87150 u32 res;
87151 - static atomic_t acqseq;
87152 + static atomic_unchecked_t acqseq;
87153
87154 do {
87155 - res = atomic_inc_return(&acqseq);
87156 + res = atomic_inc_return_unchecked(&acqseq);
87157 } while (!res);
87158 return res;
87159 }
87160 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
87161 index 843d8c4..6e0a0ff 100644
87162 --- a/net/mac80211/cfg.c
87163 +++ b/net/mac80211/cfg.c
87164 @@ -799,7 +799,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
87165 ret = ieee80211_vif_use_channel(sdata, chandef,
87166 IEEE80211_CHANCTX_EXCLUSIVE);
87167 }
87168 - } else if (local->open_count == local->monitors) {
87169 + } else if (local_read(&local->open_count) == local->monitors) {
87170 local->_oper_channel = chandef->chan;
87171 local->_oper_channel_type = cfg80211_get_chandef_type(chandef);
87172 ieee80211_hw_config(local, 0);
87173 @@ -2834,7 +2834,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
87174 else
87175 local->probe_req_reg--;
87176
87177 - if (!local->open_count)
87178 + if (!local_read(&local->open_count))
87179 break;
87180
87181 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
87182 @@ -3297,8 +3297,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
87183 if (chanctx_conf) {
87184 *chandef = chanctx_conf->def;
87185 ret = 0;
87186 - } else if (local->open_count > 0 &&
87187 - local->open_count == local->monitors &&
87188 + } else if (atomic_read(&local->open_count) > 0 &&
87189 + atomic_read(&local->open_count) == local->monitors &&
87190 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
87191 if (local->use_chanctx)
87192 *chandef = local->monitor_chandef;
87193 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
87194 index 5672533..6738c93 100644
87195 --- a/net/mac80211/ieee80211_i.h
87196 +++ b/net/mac80211/ieee80211_i.h
87197 @@ -28,6 +28,7 @@
87198 #include <net/ieee80211_radiotap.h>
87199 #include <net/cfg80211.h>
87200 #include <net/mac80211.h>
87201 +#include <asm/local.h>
87202 #include "key.h"
87203 #include "sta_info.h"
87204 #include "debug.h"
87205 @@ -897,7 +898,7 @@ struct ieee80211_local {
87206 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
87207 spinlock_t queue_stop_reason_lock;
87208
87209 - int open_count;
87210 + local_t open_count;
87211 int monitors, cooked_mntrs;
87212 /* number of interfaces with corresponding FIF_ flags */
87213 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
87214 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
87215 index d51ca9d..042c35f 100644
87216 --- a/net/mac80211/iface.c
87217 +++ b/net/mac80211/iface.c
87218 @@ -495,7 +495,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
87219 break;
87220 }
87221
87222 - if (local->open_count == 0) {
87223 + if (local_read(&local->open_count) == 0) {
87224 res = drv_start(local);
87225 if (res)
87226 goto err_del_bss;
87227 @@ -540,7 +540,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
87228 break;
87229 }
87230
87231 - if (local->monitors == 0 && local->open_count == 0) {
87232 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
87233 res = ieee80211_add_virtual_monitor(local);
87234 if (res)
87235 goto err_stop;
87236 @@ -649,7 +649,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
87237 atomic_inc(&local->iff_promiscs);
87238
87239 if (coming_up)
87240 - local->open_count++;
87241 + local_inc(&local->open_count);
87242
87243 if (hw_reconf_flags)
87244 ieee80211_hw_config(local, hw_reconf_flags);
87245 @@ -663,7 +663,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
87246 err_del_interface:
87247 drv_remove_interface(local, sdata);
87248 err_stop:
87249 - if (!local->open_count)
87250 + if (!local_read(&local->open_count))
87251 drv_stop(local);
87252 err_del_bss:
87253 sdata->bss = NULL;
87254 @@ -806,7 +806,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
87255 }
87256
87257 if (going_down)
87258 - local->open_count--;
87259 + local_dec(&local->open_count);
87260
87261 switch (sdata->vif.type) {
87262 case NL80211_IFTYPE_AP_VLAN:
87263 @@ -871,7 +871,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
87264
87265 ieee80211_recalc_ps(local, -1);
87266
87267 - if (local->open_count == 0) {
87268 + if (local_read(&local->open_count) == 0) {
87269 if (local->ops->napi_poll)
87270 napi_disable(&local->napi);
87271 ieee80211_clear_tx_pending(local);
87272 @@ -897,7 +897,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
87273 }
87274 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
87275
87276 - if (local->monitors == local->open_count && local->monitors > 0)
87277 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
87278 ieee80211_add_virtual_monitor(local);
87279 }
87280
87281 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
87282 index 1a8591b..ef5db54 100644
87283 --- a/net/mac80211/main.c
87284 +++ b/net/mac80211/main.c
87285 @@ -180,7 +180,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
87286 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
87287 IEEE80211_CONF_CHANGE_POWER);
87288
87289 - if (changed && local->open_count) {
87290 + if (changed && local_read(&local->open_count)) {
87291 ret = drv_config(local, changed);
87292 /*
87293 * Goal:
87294 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
87295 index 835584c..be46e67 100644
87296 --- a/net/mac80211/pm.c
87297 +++ b/net/mac80211/pm.c
87298 @@ -33,7 +33,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
87299 struct sta_info *sta;
87300 struct ieee80211_chanctx *ctx;
87301
87302 - if (!local->open_count)
87303 + if (!local_read(&local->open_count))
87304 goto suspend;
87305
87306 ieee80211_scan_cancel(local);
87307 @@ -75,7 +75,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
87308 cancel_work_sync(&local->dynamic_ps_enable_work);
87309 del_timer_sync(&local->dynamic_ps_timer);
87310
87311 - local->wowlan = wowlan && local->open_count;
87312 + local->wowlan = wowlan && local_read(&local->open_count);
87313 if (local->wowlan) {
87314 int err = drv_suspend(local, wowlan);
87315 if (err < 0) {
87316 @@ -214,7 +214,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
87317 mutex_unlock(&local->chanctx_mtx);
87318
87319 /* stop hardware - this must stop RX */
87320 - if (local->open_count)
87321 + if (local_read(&local->open_count))
87322 ieee80211_stop_device(local);
87323
87324 suspend:
87325 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
87326 index dd88381..eef4dd6 100644
87327 --- a/net/mac80211/rate.c
87328 +++ b/net/mac80211/rate.c
87329 @@ -493,7 +493,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
87330
87331 ASSERT_RTNL();
87332
87333 - if (local->open_count)
87334 + if (local_read(&local->open_count))
87335 return -EBUSY;
87336
87337 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
87338 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
87339 index c97a065..ff61928 100644
87340 --- a/net/mac80211/rc80211_pid_debugfs.c
87341 +++ b/net/mac80211/rc80211_pid_debugfs.c
87342 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
87343
87344 spin_unlock_irqrestore(&events->lock, status);
87345
87346 - if (copy_to_user(buf, pb, p))
87347 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
87348 return -EFAULT;
87349
87350 return p;
87351 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
87352 index 0f38f43..e53d4a8 100644
87353 --- a/net/mac80211/util.c
87354 +++ b/net/mac80211/util.c
87355 @@ -1388,7 +1388,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
87356 }
87357 #endif
87358 /* everything else happens only if HW was up & running */
87359 - if (!local->open_count)
87360 + if (!local_read(&local->open_count))
87361 goto wake_up;
87362
87363 /*
87364 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
87365 index 56d22ca..87c778f 100644
87366 --- a/net/netfilter/Kconfig
87367 +++ b/net/netfilter/Kconfig
87368 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
87369
87370 To compile it as a module, choose M here. If unsure, say N.
87371
87372 +config NETFILTER_XT_MATCH_GRADM
87373 + tristate '"gradm" match support'
87374 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
87375 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
87376 + ---help---
87377 + The gradm match allows to match on grsecurity RBAC being enabled.
87378 + It is useful when iptables rules are applied early on bootup to
87379 + prevent connections to the machine (except from a trusted host)
87380 + while the RBAC system is disabled.
87381 +
87382 config NETFILTER_XT_MATCH_HASHLIMIT
87383 tristate '"hashlimit" match support'
87384 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
87385 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
87386 index a1abf87..dbcb7ee 100644
87387 --- a/net/netfilter/Makefile
87388 +++ b/net/netfilter/Makefile
87389 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
87390 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
87391 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
87392 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
87393 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
87394 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
87395 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
87396 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
87397 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
87398 index 1ba9dbc..e39f4ca 100644
87399 --- a/net/netfilter/ipset/ip_set_core.c
87400 +++ b/net/netfilter/ipset/ip_set_core.c
87401 @@ -1801,7 +1801,7 @@ done:
87402 return ret;
87403 }
87404
87405 -static struct nf_sockopt_ops so_set __read_mostly = {
87406 +static struct nf_sockopt_ops so_set = {
87407 .pf = PF_INET,
87408 .get_optmin = SO_IP_SET,
87409 .get_optmax = SO_IP_SET + 1,
87410 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
87411 index 704e514..d644cc2 100644
87412 --- a/net/netfilter/ipvs/ip_vs_conn.c
87413 +++ b/net/netfilter/ipvs/ip_vs_conn.c
87414 @@ -551,7 +551,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
87415 /* Increase the refcnt counter of the dest */
87416 atomic_inc(&dest->refcnt);
87417
87418 - conn_flags = atomic_read(&dest->conn_flags);
87419 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
87420 if (cp->protocol != IPPROTO_UDP)
87421 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
87422 flags = cp->flags;
87423 @@ -895,7 +895,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
87424 atomic_set(&cp->refcnt, 1);
87425
87426 atomic_set(&cp->n_control, 0);
87427 - atomic_set(&cp->in_pkts, 0);
87428 + atomic_set_unchecked(&cp->in_pkts, 0);
87429
87430 atomic_inc(&ipvs->conn_count);
87431 if (flags & IP_VS_CONN_F_NO_CPORT)
87432 @@ -1174,7 +1174,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
87433
87434 /* Don't drop the entry if its number of incoming packets is not
87435 located in [0, 8] */
87436 - i = atomic_read(&cp->in_pkts);
87437 + i = atomic_read_unchecked(&cp->in_pkts);
87438 if (i > 8 || i < 0) return 0;
87439
87440 if (!todrop_rate[i]) return 0;
87441 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
87442 index 61f49d2..6c8c5bc 100644
87443 --- a/net/netfilter/ipvs/ip_vs_core.c
87444 +++ b/net/netfilter/ipvs/ip_vs_core.c
87445 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
87446 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
87447 /* do not touch skb anymore */
87448
87449 - atomic_inc(&cp->in_pkts);
87450 + atomic_inc_unchecked(&cp->in_pkts);
87451 ip_vs_conn_put(cp);
87452 return ret;
87453 }
87454 @@ -1689,7 +1689,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
87455 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
87456 pkts = sysctl_sync_threshold(ipvs);
87457 else
87458 - pkts = atomic_add_return(1, &cp->in_pkts);
87459 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
87460
87461 if (ipvs->sync_state & IP_VS_STATE_MASTER)
87462 ip_vs_sync_conn(net, cp, pkts);
87463 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
87464 index 9e2d1cc..7f8f569 100644
87465 --- a/net/netfilter/ipvs/ip_vs_ctl.c
87466 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
87467 @@ -787,7 +787,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
87468 ip_vs_rs_hash(ipvs, dest);
87469 write_unlock_bh(&ipvs->rs_lock);
87470 }
87471 - atomic_set(&dest->conn_flags, conn_flags);
87472 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
87473
87474 /* bind the service */
87475 if (!dest->svc) {
87476 @@ -1688,7 +1688,7 @@ proc_do_sync_ports(ctl_table *table, int write,
87477 * align with netns init in ip_vs_control_net_init()
87478 */
87479
87480 -static struct ctl_table vs_vars[] = {
87481 +static ctl_table_no_const vs_vars[] __read_only = {
87482 {
87483 .procname = "amemthresh",
87484 .maxlen = sizeof(int),
87485 @@ -2087,7 +2087,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
87486 " %-7s %-6d %-10d %-10d\n",
87487 &dest->addr.in6,
87488 ntohs(dest->port),
87489 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
87490 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
87491 atomic_read(&dest->weight),
87492 atomic_read(&dest->activeconns),
87493 atomic_read(&dest->inactconns));
87494 @@ -2098,7 +2098,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
87495 "%-7s %-6d %-10d %-10d\n",
87496 ntohl(dest->addr.ip),
87497 ntohs(dest->port),
87498 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
87499 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
87500 atomic_read(&dest->weight),
87501 atomic_read(&dest->activeconns),
87502 atomic_read(&dest->inactconns));
87503 @@ -2568,7 +2568,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
87504
87505 entry.addr = dest->addr.ip;
87506 entry.port = dest->port;
87507 - entry.conn_flags = atomic_read(&dest->conn_flags);
87508 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
87509 entry.weight = atomic_read(&dest->weight);
87510 entry.u_threshold = dest->u_threshold;
87511 entry.l_threshold = dest->l_threshold;
87512 @@ -3104,7 +3104,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
87513 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
87514 nla_put_u16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
87515 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
87516 - (atomic_read(&dest->conn_flags) &
87517 + (atomic_read_unchecked(&dest->conn_flags) &
87518 IP_VS_CONN_F_FWD_MASK)) ||
87519 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
87520 atomic_read(&dest->weight)) ||
87521 @@ -3694,7 +3694,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
87522 {
87523 int idx;
87524 struct netns_ipvs *ipvs = net_ipvs(net);
87525 - struct ctl_table *tbl;
87526 + ctl_table_no_const *tbl;
87527
87528 atomic_set(&ipvs->dropentry, 0);
87529 spin_lock_init(&ipvs->dropentry_lock);
87530 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
87531 index fdd89b9..bd96aa9 100644
87532 --- a/net/netfilter/ipvs/ip_vs_lblc.c
87533 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
87534 @@ -115,7 +115,7 @@ struct ip_vs_lblc_table {
87535 * IPVS LBLC sysctl table
87536 */
87537 #ifdef CONFIG_SYSCTL
87538 -static ctl_table vs_vars_table[] = {
87539 +static ctl_table_no_const vs_vars_table[] __read_only = {
87540 {
87541 .procname = "lblc_expiration",
87542 .data = NULL,
87543 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
87544 index c03b6a3..8ce3681 100644
87545 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
87546 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
87547 @@ -288,7 +288,7 @@ struct ip_vs_lblcr_table {
87548 * IPVS LBLCR sysctl table
87549 */
87550
87551 -static ctl_table vs_vars_table[] = {
87552 +static ctl_table_no_const vs_vars_table[] __read_only = {
87553 {
87554 .procname = "lblcr_expiration",
87555 .data = NULL,
87556 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
87557 index 44fd10c..2a163b3 100644
87558 --- a/net/netfilter/ipvs/ip_vs_sync.c
87559 +++ b/net/netfilter/ipvs/ip_vs_sync.c
87560 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
87561 cp = cp->control;
87562 if (cp) {
87563 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
87564 - pkts = atomic_add_return(1, &cp->in_pkts);
87565 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
87566 else
87567 pkts = sysctl_sync_threshold(ipvs);
87568 ip_vs_sync_conn(net, cp->control, pkts);
87569 @@ -758,7 +758,7 @@ control:
87570 if (!cp)
87571 return;
87572 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
87573 - pkts = atomic_add_return(1, &cp->in_pkts);
87574 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
87575 else
87576 pkts = sysctl_sync_threshold(ipvs);
87577 goto sloop;
87578 @@ -885,7 +885,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
87579
87580 if (opt)
87581 memcpy(&cp->in_seq, opt, sizeof(*opt));
87582 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
87583 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
87584 cp->state = state;
87585 cp->old_state = cp->state;
87586 /*
87587 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
87588 index ee6b7a9..f9a89f6 100644
87589 --- a/net/netfilter/ipvs/ip_vs_xmit.c
87590 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
87591 @@ -1210,7 +1210,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
87592 else
87593 rc = NF_ACCEPT;
87594 /* do not touch skb anymore */
87595 - atomic_inc(&cp->in_pkts);
87596 + atomic_inc_unchecked(&cp->in_pkts);
87597 goto out;
87598 }
87599
87600 @@ -1332,7 +1332,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
87601 else
87602 rc = NF_ACCEPT;
87603 /* do not touch skb anymore */
87604 - atomic_inc(&cp->in_pkts);
87605 + atomic_inc_unchecked(&cp->in_pkts);
87606 goto out;
87607 }
87608
87609 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
87610 index 2d3030a..7ba1c0a 100644
87611 --- a/net/netfilter/nf_conntrack_acct.c
87612 +++ b/net/netfilter/nf_conntrack_acct.c
87613 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
87614 #ifdef CONFIG_SYSCTL
87615 static int nf_conntrack_acct_init_sysctl(struct net *net)
87616 {
87617 - struct ctl_table *table;
87618 + ctl_table_no_const *table;
87619
87620 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
87621 GFP_KERNEL);
87622 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
87623 index c8e001a..f842a8b 100644
87624 --- a/net/netfilter/nf_conntrack_core.c
87625 +++ b/net/netfilter/nf_conntrack_core.c
87626 @@ -1594,6 +1594,10 @@ void nf_conntrack_init_end(void)
87627 #define DYING_NULLS_VAL ((1<<30)+1)
87628 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
87629
87630 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87631 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
87632 +#endif
87633 +
87634 int nf_conntrack_init_net(struct net *net)
87635 {
87636 int ret;
87637 @@ -1608,7 +1612,11 @@ int nf_conntrack_init_net(struct net *net)
87638 goto err_stat;
87639 }
87640
87641 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87642 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
87643 +#else
87644 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
87645 +#endif
87646 if (!net->ct.slabname) {
87647 ret = -ENOMEM;
87648 goto err_slabname;
87649 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
87650 index b5d2eb8..61ef19a 100644
87651 --- a/net/netfilter/nf_conntrack_ecache.c
87652 +++ b/net/netfilter/nf_conntrack_ecache.c
87653 @@ -186,7 +186,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
87654 #ifdef CONFIG_SYSCTL
87655 static int nf_conntrack_event_init_sysctl(struct net *net)
87656 {
87657 - struct ctl_table *table;
87658 + ctl_table_no_const *table;
87659
87660 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
87661 GFP_KERNEL);
87662 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
87663 index 94b4b98..97cf0ad 100644
87664 --- a/net/netfilter/nf_conntrack_helper.c
87665 +++ b/net/netfilter/nf_conntrack_helper.c
87666 @@ -56,7 +56,7 @@ static struct ctl_table helper_sysctl_table[] = {
87667
87668 static int nf_conntrack_helper_init_sysctl(struct net *net)
87669 {
87670 - struct ctl_table *table;
87671 + ctl_table_no_const *table;
87672
87673 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
87674 GFP_KERNEL);
87675 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
87676 index 58ab405..50eb8d3 100644
87677 --- a/net/netfilter/nf_conntrack_proto.c
87678 +++ b/net/netfilter/nf_conntrack_proto.c
87679 @@ -51,7 +51,7 @@ nf_ct_register_sysctl(struct net *net,
87680
87681 static void
87682 nf_ct_unregister_sysctl(struct ctl_table_header **header,
87683 - struct ctl_table **table,
87684 + ctl_table_no_const **table,
87685 unsigned int users)
87686 {
87687 if (users > 0)
87688 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
87689 index fedee39..d62a93d 100644
87690 --- a/net/netfilter/nf_conntrack_standalone.c
87691 +++ b/net/netfilter/nf_conntrack_standalone.c
87692 @@ -470,7 +470,7 @@ static ctl_table nf_ct_netfilter_table[] = {
87693
87694 static int nf_conntrack_standalone_init_sysctl(struct net *net)
87695 {
87696 - struct ctl_table *table;
87697 + ctl_table_no_const *table;
87698
87699 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
87700 GFP_KERNEL);
87701 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
87702 index 902fb0a..87f7fdb 100644
87703 --- a/net/netfilter/nf_conntrack_timestamp.c
87704 +++ b/net/netfilter/nf_conntrack_timestamp.c
87705 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
87706 #ifdef CONFIG_SYSCTL
87707 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
87708 {
87709 - struct ctl_table *table;
87710 + ctl_table_no_const *table;
87711
87712 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
87713 GFP_KERNEL);
87714 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
87715 index 9e31269..bc4c1b7 100644
87716 --- a/net/netfilter/nf_log.c
87717 +++ b/net/netfilter/nf_log.c
87718 @@ -215,7 +215,7 @@ static const struct file_operations nflog_file_ops = {
87719
87720 #ifdef CONFIG_SYSCTL
87721 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
87722 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
87723 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
87724 static struct ctl_table_header *nf_log_dir_header;
87725
87726 static int nf_log_proc_dostring(ctl_table *table, int write,
87727 @@ -246,14 +246,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
87728 rcu_assign_pointer(nf_loggers[tindex], logger);
87729 mutex_unlock(&nf_log_mutex);
87730 } else {
87731 + ctl_table_no_const nf_log_table = *table;
87732 +
87733 mutex_lock(&nf_log_mutex);
87734 logger = rcu_dereference_protected(nf_loggers[tindex],
87735 lockdep_is_held(&nf_log_mutex));
87736 if (!logger)
87737 - table->data = "NONE";
87738 + nf_log_table.data = "NONE";
87739 else
87740 - table->data = logger->name;
87741 - r = proc_dostring(table, write, buffer, lenp, ppos);
87742 + nf_log_table.data = logger->name;
87743 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
87744 mutex_unlock(&nf_log_mutex);
87745 }
87746
87747 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
87748 index f042ae5..30ea486 100644
87749 --- a/net/netfilter/nf_sockopt.c
87750 +++ b/net/netfilter/nf_sockopt.c
87751 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
87752 }
87753 }
87754
87755 - list_add(&reg->list, &nf_sockopts);
87756 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
87757 out:
87758 mutex_unlock(&nf_sockopt_mutex);
87759 return ret;
87760 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
87761 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
87762 {
87763 mutex_lock(&nf_sockopt_mutex);
87764 - list_del(&reg->list);
87765 + pax_list_del((struct list_head *)&reg->list);
87766 mutex_unlock(&nf_sockopt_mutex);
87767 }
87768 EXPORT_SYMBOL(nf_unregister_sockopt);
87769 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
87770 index f248db5..3778ad9 100644
87771 --- a/net/netfilter/nfnetlink_log.c
87772 +++ b/net/netfilter/nfnetlink_log.c
87773 @@ -72,7 +72,7 @@ struct nfulnl_instance {
87774 };
87775
87776 static DEFINE_SPINLOCK(instances_lock);
87777 -static atomic_t global_seq;
87778 +static atomic_unchecked_t global_seq;
87779
87780 #define INSTANCE_BUCKETS 16
87781 static struct hlist_head instance_table[INSTANCE_BUCKETS];
87782 @@ -536,7 +536,7 @@ __build_packet_message(struct nfulnl_instance *inst,
87783 /* global sequence number */
87784 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
87785 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
87786 - htonl(atomic_inc_return(&global_seq))))
87787 + htonl(atomic_inc_return_unchecked(&global_seq))))
87788 goto nla_put_failure;
87789
87790 if (data_len) {
87791 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
87792 new file mode 100644
87793 index 0000000..c566332
87794 --- /dev/null
87795 +++ b/net/netfilter/xt_gradm.c
87796 @@ -0,0 +1,51 @@
87797 +/*
87798 + * gradm match for netfilter
87799 + * Copyright © Zbigniew Krzystolik, 2010
87800 + *
87801 + * This program is free software; you can redistribute it and/or modify
87802 + * it under the terms of the GNU General Public License; either version
87803 + * 2 or 3 as published by the Free Software Foundation.
87804 + */
87805 +#include <linux/module.h>
87806 +#include <linux/moduleparam.h>
87807 +#include <linux/skbuff.h>
87808 +#include <linux/netfilter/x_tables.h>
87809 +#include <linux/grsecurity.h>
87810 +#include <linux/netfilter/xt_gradm.h>
87811 +
87812 +static bool
87813 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
87814 +{
87815 + const struct xt_gradm_mtinfo *info = par->matchinfo;
87816 + bool retval = false;
87817 + if (gr_acl_is_enabled())
87818 + retval = true;
87819 + return retval ^ info->invflags;
87820 +}
87821 +
87822 +static struct xt_match gradm_mt_reg __read_mostly = {
87823 + .name = "gradm",
87824 + .revision = 0,
87825 + .family = NFPROTO_UNSPEC,
87826 + .match = gradm_mt,
87827 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
87828 + .me = THIS_MODULE,
87829 +};
87830 +
87831 +static int __init gradm_mt_init(void)
87832 +{
87833 + return xt_register_match(&gradm_mt_reg);
87834 +}
87835 +
87836 +static void __exit gradm_mt_exit(void)
87837 +{
87838 + xt_unregister_match(&gradm_mt_reg);
87839 +}
87840 +
87841 +module_init(gradm_mt_init);
87842 +module_exit(gradm_mt_exit);
87843 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
87844 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
87845 +MODULE_LICENSE("GPL");
87846 +MODULE_ALIAS("ipt_gradm");
87847 +MODULE_ALIAS("ip6t_gradm");
87848 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
87849 index 4fe4fb4..87a89e5 100644
87850 --- a/net/netfilter/xt_statistic.c
87851 +++ b/net/netfilter/xt_statistic.c
87852 @@ -19,7 +19,7 @@
87853 #include <linux/module.h>
87854
87855 struct xt_statistic_priv {
87856 - atomic_t count;
87857 + atomic_unchecked_t count;
87858 } ____cacheline_aligned_in_smp;
87859
87860 MODULE_LICENSE("GPL");
87861 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
87862 break;
87863 case XT_STATISTIC_MODE_NTH:
87864 do {
87865 - oval = atomic_read(&info->master->count);
87866 + oval = atomic_read_unchecked(&info->master->count);
87867 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
87868 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
87869 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
87870 if (nval == 0)
87871 ret = !ret;
87872 break;
87873 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
87874 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
87875 if (info->master == NULL)
87876 return -ENOMEM;
87877 - atomic_set(&info->master->count, info->u.nth.count);
87878 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
87879
87880 return 0;
87881 }
87882 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
87883 index 1e3fd5b..ad397ea 100644
87884 --- a/net/netlink/af_netlink.c
87885 +++ b/net/netlink/af_netlink.c
87886 @@ -781,7 +781,7 @@ static void netlink_overrun(struct sock *sk)
87887 sk->sk_error_report(sk);
87888 }
87889 }
87890 - atomic_inc(&sk->sk_drops);
87891 + atomic_inc_unchecked(&sk->sk_drops);
87892 }
87893
87894 static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
87895 @@ -2063,7 +2063,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
87896 sk_wmem_alloc_get(s),
87897 nlk->cb,
87898 atomic_read(&s->sk_refcnt),
87899 - atomic_read(&s->sk_drops),
87900 + atomic_read_unchecked(&s->sk_drops),
87901 sock_i_ino(s)
87902 );
87903
87904 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
87905 index 5a55be3..7630745 100644
87906 --- a/net/netlink/genetlink.c
87907 +++ b/net/netlink/genetlink.c
87908 @@ -296,18 +296,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
87909 goto errout;
87910 }
87911
87912 + pax_open_kernel();
87913 if (ops->dumpit)
87914 - ops->flags |= GENL_CMD_CAP_DUMP;
87915 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
87916 if (ops->doit)
87917 - ops->flags |= GENL_CMD_CAP_DO;
87918 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
87919 if (ops->policy)
87920 - ops->flags |= GENL_CMD_CAP_HASPOL;
87921 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
87922 + pax_close_kernel();
87923
87924 genl_lock();
87925 - list_add_tail(&ops->ops_list, &family->ops_list);
87926 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
87927 genl_unlock();
87928
87929 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
87930 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
87931 err = 0;
87932 errout:
87933 return err;
87934 @@ -337,9 +339,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
87935 genl_lock();
87936 list_for_each_entry(rc, &family->ops_list, ops_list) {
87937 if (rc == ops) {
87938 - list_del(&ops->ops_list);
87939 + pax_list_del((struct list_head *)&ops->ops_list);
87940 genl_unlock();
87941 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
87942 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
87943 return 0;
87944 }
87945 }
87946 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
87947 index 103bd70..f21aad3 100644
87948 --- a/net/netrom/af_netrom.c
87949 +++ b/net/netrom/af_netrom.c
87950 @@ -834,6 +834,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
87951 struct sock *sk = sock->sk;
87952 struct nr_sock *nr = nr_sk(sk);
87953
87954 + memset(sax, 0, sizeof(*sax));
87955 lock_sock(sk);
87956 if (peer != 0) {
87957 if (sk->sk_state != TCP_ESTABLISHED) {
87958 @@ -848,7 +849,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
87959 *uaddr_len = sizeof(struct full_sockaddr_ax25);
87960 } else {
87961 sax->fsa_ax25.sax25_family = AF_NETROM;
87962 - sax->fsa_ax25.sax25_ndigis = 0;
87963 sax->fsa_ax25.sax25_call = nr->source_addr;
87964 *uaddr_len = sizeof(struct sockaddr_ax25);
87965 }
87966 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
87967 index 1d6793d..056b191 100644
87968 --- a/net/packet/af_packet.c
87969 +++ b/net/packet/af_packet.c
87970 @@ -1578,7 +1578,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
87971
87972 spin_lock(&sk->sk_receive_queue.lock);
87973 po->stats.tp_packets++;
87974 - skb->dropcount = atomic_read(&sk->sk_drops);
87975 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
87976 __skb_queue_tail(&sk->sk_receive_queue, skb);
87977 spin_unlock(&sk->sk_receive_queue.lock);
87978 sk->sk_data_ready(sk, skb->len);
87979 @@ -1587,7 +1587,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
87980 drop_n_acct:
87981 spin_lock(&sk->sk_receive_queue.lock);
87982 po->stats.tp_drops++;
87983 - atomic_inc(&sk->sk_drops);
87984 + atomic_inc_unchecked(&sk->sk_drops);
87985 spin_unlock(&sk->sk_receive_queue.lock);
87986
87987 drop_n_restore:
87988 @@ -2565,6 +2565,7 @@ out:
87989
87990 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
87991 {
87992 + struct sock_extended_err ee;
87993 struct sock_exterr_skb *serr;
87994 struct sk_buff *skb, *skb2;
87995 int copied, err;
87996 @@ -2586,8 +2587,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
87997 sock_recv_timestamp(msg, sk, skb);
87998
87999 serr = SKB_EXT_ERR(skb);
88000 + ee = serr->ee;
88001 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
88002 - sizeof(serr->ee), &serr->ee);
88003 + sizeof ee, &ee);
88004
88005 msg->msg_flags |= MSG_ERRQUEUE;
88006 err = copied;
88007 @@ -3212,7 +3214,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
88008 case PACKET_HDRLEN:
88009 if (len > sizeof(int))
88010 len = sizeof(int);
88011 - if (copy_from_user(&val, optval, len))
88012 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
88013 return -EFAULT;
88014 switch (val) {
88015 case TPACKET_V1:
88016 @@ -3254,7 +3256,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
88017 len = lv;
88018 if (put_user(len, optlen))
88019 return -EFAULT;
88020 - if (copy_to_user(optval, data, len))
88021 + if (len > sizeof(st) || copy_to_user(optval, data, len))
88022 return -EFAULT;
88023 return 0;
88024 }
88025 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
88026 index 5a940db..d6a502d 100644
88027 --- a/net/phonet/af_phonet.c
88028 +++ b/net/phonet/af_phonet.c
88029 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
88030 {
88031 int err = 0;
88032
88033 - if (protocol >= PHONET_NPROTO)
88034 + if (protocol < 0 || protocol >= PHONET_NPROTO)
88035 return -EINVAL;
88036
88037 err = proto_register(pp->prot, 1);
88038 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
88039 index e774117..900b8b7 100644
88040 --- a/net/phonet/pep.c
88041 +++ b/net/phonet/pep.c
88042 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
88043
88044 case PNS_PEP_CTRL_REQ:
88045 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
88046 - atomic_inc(&sk->sk_drops);
88047 + atomic_inc_unchecked(&sk->sk_drops);
88048 break;
88049 }
88050 __skb_pull(skb, 4);
88051 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
88052 }
88053
88054 if (pn->rx_credits == 0) {
88055 - atomic_inc(&sk->sk_drops);
88056 + atomic_inc_unchecked(&sk->sk_drops);
88057 err = -ENOBUFS;
88058 break;
88059 }
88060 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
88061 }
88062
88063 if (pn->rx_credits == 0) {
88064 - atomic_inc(&sk->sk_drops);
88065 + atomic_inc_unchecked(&sk->sk_drops);
88066 err = NET_RX_DROP;
88067 break;
88068 }
88069 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
88070 index 1afd138..0b42453 100644
88071 --- a/net/phonet/socket.c
88072 +++ b/net/phonet/socket.c
88073 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
88074 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
88075 sock_i_ino(sk),
88076 atomic_read(&sk->sk_refcnt), sk,
88077 - atomic_read(&sk->sk_drops), &len);
88078 + atomic_read_unchecked(&sk->sk_drops), &len);
88079 }
88080 seq_printf(seq, "%*s\n", 127 - len, "");
88081 return 0;
88082 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
88083 index d6bbbbd..61561e4 100644
88084 --- a/net/phonet/sysctl.c
88085 +++ b/net/phonet/sysctl.c
88086 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
88087 {
88088 int ret;
88089 int range[2] = {local_port_range[0], local_port_range[1]};
88090 - ctl_table tmp = {
88091 + ctl_table_no_const tmp = {
88092 .data = &range,
88093 .maxlen = sizeof(range),
88094 .mode = table->mode,
88095 diff --git a/net/rds/cong.c b/net/rds/cong.c
88096 index e5b65ac..f3b6fb7 100644
88097 --- a/net/rds/cong.c
88098 +++ b/net/rds/cong.c
88099 @@ -78,7 +78,7 @@
88100 * finds that the saved generation number is smaller than the global generation
88101 * number, it wakes up the process.
88102 */
88103 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
88104 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
88105
88106 /*
88107 * Congestion monitoring
88108 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
88109 rdsdebug("waking map %p for %pI4\n",
88110 map, &map->m_addr);
88111 rds_stats_inc(s_cong_update_received);
88112 - atomic_inc(&rds_cong_generation);
88113 + atomic_inc_unchecked(&rds_cong_generation);
88114 if (waitqueue_active(&map->m_waitq))
88115 wake_up(&map->m_waitq);
88116 if (waitqueue_active(&rds_poll_waitq))
88117 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
88118
88119 int rds_cong_updated_since(unsigned long *recent)
88120 {
88121 - unsigned long gen = atomic_read(&rds_cong_generation);
88122 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
88123
88124 if (likely(*recent == gen))
88125 return 0;
88126 diff --git a/net/rds/ib.h b/net/rds/ib.h
88127 index 7280ab8..e04f4ea 100644
88128 --- a/net/rds/ib.h
88129 +++ b/net/rds/ib.h
88130 @@ -128,7 +128,7 @@ struct rds_ib_connection {
88131 /* sending acks */
88132 unsigned long i_ack_flags;
88133 #ifdef KERNEL_HAS_ATOMIC64
88134 - atomic64_t i_ack_next; /* next ACK to send */
88135 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
88136 #else
88137 spinlock_t i_ack_lock; /* protect i_ack_next */
88138 u64 i_ack_next; /* next ACK to send */
88139 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
88140 index 31b74f5..dc1fbfa 100644
88141 --- a/net/rds/ib_cm.c
88142 +++ b/net/rds/ib_cm.c
88143 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
88144 /* Clear the ACK state */
88145 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
88146 #ifdef KERNEL_HAS_ATOMIC64
88147 - atomic64_set(&ic->i_ack_next, 0);
88148 + atomic64_set_unchecked(&ic->i_ack_next, 0);
88149 #else
88150 ic->i_ack_next = 0;
88151 #endif
88152 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
88153 index 8eb9501..0c386ff 100644
88154 --- a/net/rds/ib_recv.c
88155 +++ b/net/rds/ib_recv.c
88156 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
88157 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
88158 int ack_required)
88159 {
88160 - atomic64_set(&ic->i_ack_next, seq);
88161 + atomic64_set_unchecked(&ic->i_ack_next, seq);
88162 if (ack_required) {
88163 smp_mb__before_clear_bit();
88164 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
88165 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
88166 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
88167 smp_mb__after_clear_bit();
88168
88169 - return atomic64_read(&ic->i_ack_next);
88170 + return atomic64_read_unchecked(&ic->i_ack_next);
88171 }
88172 #endif
88173
88174 diff --git a/net/rds/iw.h b/net/rds/iw.h
88175 index 04ce3b1..48119a6 100644
88176 --- a/net/rds/iw.h
88177 +++ b/net/rds/iw.h
88178 @@ -134,7 +134,7 @@ struct rds_iw_connection {
88179 /* sending acks */
88180 unsigned long i_ack_flags;
88181 #ifdef KERNEL_HAS_ATOMIC64
88182 - atomic64_t i_ack_next; /* next ACK to send */
88183 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
88184 #else
88185 spinlock_t i_ack_lock; /* protect i_ack_next */
88186 u64 i_ack_next; /* next ACK to send */
88187 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
88188 index a91e1db..cf3053f 100644
88189 --- a/net/rds/iw_cm.c
88190 +++ b/net/rds/iw_cm.c
88191 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
88192 /* Clear the ACK state */
88193 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
88194 #ifdef KERNEL_HAS_ATOMIC64
88195 - atomic64_set(&ic->i_ack_next, 0);
88196 + atomic64_set_unchecked(&ic->i_ack_next, 0);
88197 #else
88198 ic->i_ack_next = 0;
88199 #endif
88200 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
88201 index 4503335..db566b4 100644
88202 --- a/net/rds/iw_recv.c
88203 +++ b/net/rds/iw_recv.c
88204 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
88205 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
88206 int ack_required)
88207 {
88208 - atomic64_set(&ic->i_ack_next, seq);
88209 + atomic64_set_unchecked(&ic->i_ack_next, seq);
88210 if (ack_required) {
88211 smp_mb__before_clear_bit();
88212 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
88213 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
88214 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
88215 smp_mb__after_clear_bit();
88216
88217 - return atomic64_read(&ic->i_ack_next);
88218 + return atomic64_read_unchecked(&ic->i_ack_next);
88219 }
88220 #endif
88221
88222 diff --git a/net/rds/rds.h b/net/rds/rds.h
88223 index ec1d731..90a3a8d 100644
88224 --- a/net/rds/rds.h
88225 +++ b/net/rds/rds.h
88226 @@ -449,7 +449,7 @@ struct rds_transport {
88227 void (*sync_mr)(void *trans_private, int direction);
88228 void (*free_mr)(void *trans_private, int invalidate);
88229 void (*flush_mrs)(void);
88230 -};
88231 +} __do_const;
88232
88233 struct rds_sock {
88234 struct sock rs_sk;
88235 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
88236 index edac9ef..16bcb98 100644
88237 --- a/net/rds/tcp.c
88238 +++ b/net/rds/tcp.c
88239 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
88240 int val = 1;
88241
88242 set_fs(KERNEL_DS);
88243 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
88244 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
88245 sizeof(val));
88246 set_fs(oldfs);
88247 }
88248 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
88249 index 81cf5a4..b5826ff 100644
88250 --- a/net/rds/tcp_send.c
88251 +++ b/net/rds/tcp_send.c
88252 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
88253
88254 oldfs = get_fs();
88255 set_fs(KERNEL_DS);
88256 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
88257 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
88258 sizeof(val));
88259 set_fs(oldfs);
88260 }
88261 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
88262 index e61aa60..f07cc89 100644
88263 --- a/net/rxrpc/af_rxrpc.c
88264 +++ b/net/rxrpc/af_rxrpc.c
88265 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
88266 __be32 rxrpc_epoch;
88267
88268 /* current debugging ID */
88269 -atomic_t rxrpc_debug_id;
88270 +atomic_unchecked_t rxrpc_debug_id;
88271
88272 /* count of skbs currently in use */
88273 atomic_t rxrpc_n_skbs;
88274 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
88275 index e4d9cbc..b229649 100644
88276 --- a/net/rxrpc/ar-ack.c
88277 +++ b/net/rxrpc/ar-ack.c
88278 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
88279
88280 _enter("{%d,%d,%d,%d},",
88281 call->acks_hard, call->acks_unacked,
88282 - atomic_read(&call->sequence),
88283 + atomic_read_unchecked(&call->sequence),
88284 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
88285
88286 stop = 0;
88287 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
88288
88289 /* each Tx packet has a new serial number */
88290 sp->hdr.serial =
88291 - htonl(atomic_inc_return(&call->conn->serial));
88292 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
88293
88294 hdr = (struct rxrpc_header *) txb->head;
88295 hdr->serial = sp->hdr.serial;
88296 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
88297 */
88298 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
88299 {
88300 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
88301 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
88302 }
88303
88304 /*
88305 @@ -629,7 +629,7 @@ process_further:
88306
88307 latest = ntohl(sp->hdr.serial);
88308 hard = ntohl(ack.firstPacket);
88309 - tx = atomic_read(&call->sequence);
88310 + tx = atomic_read_unchecked(&call->sequence);
88311
88312 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
88313 latest,
88314 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
88315 goto maybe_reschedule;
88316
88317 send_ACK_with_skew:
88318 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
88319 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
88320 ntohl(ack.serial));
88321 send_ACK:
88322 mtu = call->conn->trans->peer->if_mtu;
88323 @@ -1173,7 +1173,7 @@ send_ACK:
88324 ackinfo.rxMTU = htonl(5692);
88325 ackinfo.jumbo_max = htonl(4);
88326
88327 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
88328 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
88329 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
88330 ntohl(hdr.serial),
88331 ntohs(ack.maxSkew),
88332 @@ -1191,7 +1191,7 @@ send_ACK:
88333 send_message:
88334 _debug("send message");
88335
88336 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
88337 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
88338 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
88339 send_message_2:
88340
88341 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
88342 index a3bbb36..3341fb9 100644
88343 --- a/net/rxrpc/ar-call.c
88344 +++ b/net/rxrpc/ar-call.c
88345 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
88346 spin_lock_init(&call->lock);
88347 rwlock_init(&call->state_lock);
88348 atomic_set(&call->usage, 1);
88349 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
88350 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88351 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
88352
88353 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
88354 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
88355 index 4106ca9..a338d7a 100644
88356 --- a/net/rxrpc/ar-connection.c
88357 +++ b/net/rxrpc/ar-connection.c
88358 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
88359 rwlock_init(&conn->lock);
88360 spin_lock_init(&conn->state_lock);
88361 atomic_set(&conn->usage, 1);
88362 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
88363 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88364 conn->avail_calls = RXRPC_MAXCALLS;
88365 conn->size_align = 4;
88366 conn->header_size = sizeof(struct rxrpc_header);
88367 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
88368 index e7ed43a..6afa140 100644
88369 --- a/net/rxrpc/ar-connevent.c
88370 +++ b/net/rxrpc/ar-connevent.c
88371 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
88372
88373 len = iov[0].iov_len + iov[1].iov_len;
88374
88375 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
88376 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
88377 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
88378
88379 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
88380 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
88381 index 529572f..c758ca7 100644
88382 --- a/net/rxrpc/ar-input.c
88383 +++ b/net/rxrpc/ar-input.c
88384 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
88385 /* track the latest serial number on this connection for ACK packet
88386 * information */
88387 serial = ntohl(sp->hdr.serial);
88388 - hi_serial = atomic_read(&call->conn->hi_serial);
88389 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
88390 while (serial > hi_serial)
88391 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
88392 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
88393 serial);
88394
88395 /* request ACK generation for any ACK or DATA packet that requests
88396 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
88397 index a693aca..81e7293 100644
88398 --- a/net/rxrpc/ar-internal.h
88399 +++ b/net/rxrpc/ar-internal.h
88400 @@ -272,8 +272,8 @@ struct rxrpc_connection {
88401 int error; /* error code for local abort */
88402 int debug_id; /* debug ID for printks */
88403 unsigned int call_counter; /* call ID counter */
88404 - atomic_t serial; /* packet serial number counter */
88405 - atomic_t hi_serial; /* highest serial number received */
88406 + atomic_unchecked_t serial; /* packet serial number counter */
88407 + atomic_unchecked_t hi_serial; /* highest serial number received */
88408 u8 avail_calls; /* number of calls available */
88409 u8 size_align; /* data size alignment (for security) */
88410 u8 header_size; /* rxrpc + security header size */
88411 @@ -346,7 +346,7 @@ struct rxrpc_call {
88412 spinlock_t lock;
88413 rwlock_t state_lock; /* lock for state transition */
88414 atomic_t usage;
88415 - atomic_t sequence; /* Tx data packet sequence counter */
88416 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
88417 u32 abort_code; /* local/remote abort code */
88418 enum { /* current state of call */
88419 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
88420 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
88421 */
88422 extern atomic_t rxrpc_n_skbs;
88423 extern __be32 rxrpc_epoch;
88424 -extern atomic_t rxrpc_debug_id;
88425 +extern atomic_unchecked_t rxrpc_debug_id;
88426 extern struct workqueue_struct *rxrpc_workqueue;
88427
88428 /*
88429 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
88430 index 87f7135..74d3703 100644
88431 --- a/net/rxrpc/ar-local.c
88432 +++ b/net/rxrpc/ar-local.c
88433 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
88434 spin_lock_init(&local->lock);
88435 rwlock_init(&local->services_lock);
88436 atomic_set(&local->usage, 1);
88437 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
88438 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88439 memcpy(&local->srx, srx, sizeof(*srx));
88440 }
88441
88442 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
88443 index e1ac183..b43e10e 100644
88444 --- a/net/rxrpc/ar-output.c
88445 +++ b/net/rxrpc/ar-output.c
88446 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
88447 sp->hdr.cid = call->cid;
88448 sp->hdr.callNumber = call->call_id;
88449 sp->hdr.seq =
88450 - htonl(atomic_inc_return(&call->sequence));
88451 + htonl(atomic_inc_return_unchecked(&call->sequence));
88452 sp->hdr.serial =
88453 - htonl(atomic_inc_return(&conn->serial));
88454 + htonl(atomic_inc_return_unchecked(&conn->serial));
88455 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
88456 sp->hdr.userStatus = 0;
88457 sp->hdr.securityIndex = conn->security_ix;
88458 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
88459 index bebaa43..2644591 100644
88460 --- a/net/rxrpc/ar-peer.c
88461 +++ b/net/rxrpc/ar-peer.c
88462 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
88463 INIT_LIST_HEAD(&peer->error_targets);
88464 spin_lock_init(&peer->lock);
88465 atomic_set(&peer->usage, 1);
88466 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
88467 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88468 memcpy(&peer->srx, srx, sizeof(*srx));
88469
88470 rxrpc_assess_MTU_size(peer);
88471 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
88472 index 38047f7..9f48511 100644
88473 --- a/net/rxrpc/ar-proc.c
88474 +++ b/net/rxrpc/ar-proc.c
88475 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
88476 atomic_read(&conn->usage),
88477 rxrpc_conn_states[conn->state],
88478 key_serial(conn->key),
88479 - atomic_read(&conn->serial),
88480 - atomic_read(&conn->hi_serial));
88481 + atomic_read_unchecked(&conn->serial),
88482 + atomic_read_unchecked(&conn->hi_serial));
88483
88484 return 0;
88485 }
88486 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
88487 index 92df566..87ec1bf 100644
88488 --- a/net/rxrpc/ar-transport.c
88489 +++ b/net/rxrpc/ar-transport.c
88490 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
88491 spin_lock_init(&trans->client_lock);
88492 rwlock_init(&trans->conn_lock);
88493 atomic_set(&trans->usage, 1);
88494 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
88495 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
88496
88497 if (peer->srx.transport.family == AF_INET) {
88498 switch (peer->srx.transport_type) {
88499 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
88500 index f226709..0e735a8 100644
88501 --- a/net/rxrpc/rxkad.c
88502 +++ b/net/rxrpc/rxkad.c
88503 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
88504
88505 len = iov[0].iov_len + iov[1].iov_len;
88506
88507 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
88508 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
88509 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
88510
88511 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
88512 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
88513
88514 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
88515
88516 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
88517 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
88518 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
88519
88520 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
88521 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
88522 index 391a245..296b3d7 100644
88523 --- a/net/sctp/ipv6.c
88524 +++ b/net/sctp/ipv6.c
88525 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
88526 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
88527 };
88528
88529 -static struct sctp_af sctp_af_inet6 = {
88530 +static struct sctp_af sctp_af_inet6 __read_only = {
88531 .sa_family = AF_INET6,
88532 .sctp_xmit = sctp_v6_xmit,
88533 .setsockopt = ipv6_setsockopt,
88534 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
88535 #endif
88536 };
88537
88538 -static struct sctp_pf sctp_pf_inet6 = {
88539 +static struct sctp_pf sctp_pf_inet6 __read_only = {
88540 .event_msgname = sctp_inet6_event_msgname,
88541 .skb_msgname = sctp_inet6_skb_msgname,
88542 .af_supported = sctp_inet6_af_supported,
88543 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
88544
88545 void sctp_v6_pf_exit(void)
88546 {
88547 - list_del(&sctp_af_inet6.list);
88548 + pax_list_del(&sctp_af_inet6.list);
88549 }
88550
88551 /* Initialize IPv6 support and register with socket layer. */
88552 diff --git a/net/sctp/probe.c b/net/sctp/probe.c
88553 index ad0dba8..e62c225 100644
88554 --- a/net/sctp/probe.c
88555 +++ b/net/sctp/probe.c
88556 @@ -63,7 +63,7 @@ static struct {
88557 struct timespec tstart;
88558 } sctpw;
88559
88560 -static void printl(const char *fmt, ...)
88561 +static __printf(1, 2) void printl(const char *fmt, ...)
88562 {
88563 va_list args;
88564 int len;
88565 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
88566 index ab3bba8..2fbab4e 100644
88567 --- a/net/sctp/proc.c
88568 +++ b/net/sctp/proc.c
88569 @@ -336,7 +336,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
88570 seq_printf(seq,
88571 "%8pK %8pK %-3d %-3d %-2d %-4d "
88572 "%4d %8d %8d %7d %5lu %-5d %5d ",
88573 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
88574 + assoc, sk,
88575 + sctp_sk(sk)->type, sk->sk_state,
88576 assoc->state, hash,
88577 assoc->assoc_id,
88578 assoc->sndbuf_used,
88579 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
88580 index 1c2e46c..f91cf5e 100644
88581 --- a/net/sctp/protocol.c
88582 +++ b/net/sctp/protocol.c
88583 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
88584 return 0;
88585 }
88586
88587 + pax_open_kernel();
88588 INIT_LIST_HEAD(&af->list);
88589 - list_add_tail(&af->list, &sctp_address_families);
88590 + pax_close_kernel();
88591 + pax_list_add_tail(&af->list, &sctp_address_families);
88592 return 1;
88593 }
88594
88595 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
88596
88597 static struct sctp_af sctp_af_inet;
88598
88599 -static struct sctp_pf sctp_pf_inet = {
88600 +static struct sctp_pf sctp_pf_inet __read_only = {
88601 .event_msgname = sctp_inet_event_msgname,
88602 .skb_msgname = sctp_inet_skb_msgname,
88603 .af_supported = sctp_inet_af_supported,
88604 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
88605 };
88606
88607 /* IPv4 address related functions. */
88608 -static struct sctp_af sctp_af_inet = {
88609 +static struct sctp_af sctp_af_inet __read_only = {
88610 .sa_family = AF_INET,
88611 .sctp_xmit = sctp_v4_xmit,
88612 .setsockopt = ip_setsockopt,
88613 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
88614
88615 static void sctp_v4_pf_exit(void)
88616 {
88617 - list_del(&sctp_af_inet.list);
88618 + pax_list_del(&sctp_af_inet.list);
88619 }
88620
88621 static int sctp_v4_protosw_init(void)
88622 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
88623 index 8aab894..f6b7e7d 100644
88624 --- a/net/sctp/sm_sideeffect.c
88625 +++ b/net/sctp/sm_sideeffect.c
88626 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
88627 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
88628 }
88629
88630 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
88631 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
88632 NULL,
88633 sctp_generate_t1_cookie_event,
88634 sctp_generate_t1_init_event,
88635 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
88636 index b907073..57fef6c 100644
88637 --- a/net/sctp/socket.c
88638 +++ b/net/sctp/socket.c
88639 @@ -2166,11 +2166,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
88640 {
88641 struct sctp_association *asoc;
88642 struct sctp_ulpevent *event;
88643 + struct sctp_event_subscribe subscribe;
88644
88645 if (optlen > sizeof(struct sctp_event_subscribe))
88646 return -EINVAL;
88647 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
88648 + if (copy_from_user(&subscribe, optval, optlen))
88649 return -EFAULT;
88650 + sctp_sk(sk)->subscribe = subscribe;
88651
88652 /*
88653 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
88654 @@ -4215,13 +4217,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
88655 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
88656 int __user *optlen)
88657 {
88658 + struct sctp_event_subscribe subscribe;
88659 +
88660 if (len <= 0)
88661 return -EINVAL;
88662 if (len > sizeof(struct sctp_event_subscribe))
88663 len = sizeof(struct sctp_event_subscribe);
88664 if (put_user(len, optlen))
88665 return -EFAULT;
88666 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
88667 + subscribe = sctp_sk(sk)->subscribe;
88668 + if (copy_to_user(optval, &subscribe, len))
88669 return -EFAULT;
88670 return 0;
88671 }
88672 @@ -4239,6 +4244,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
88673 */
88674 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
88675 {
88676 + __u32 autoclose;
88677 +
88678 /* Applicable to UDP-style socket only */
88679 if (sctp_style(sk, TCP))
88680 return -EOPNOTSUPP;
88681 @@ -4247,7 +4254,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
88682 len = sizeof(int);
88683 if (put_user(len, optlen))
88684 return -EFAULT;
88685 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
88686 + autoclose = sctp_sk(sk)->autoclose;
88687 + if (copy_to_user(optval, &autoclose, sizeof(int)))
88688 return -EFAULT;
88689 return 0;
88690 }
88691 @@ -4619,12 +4627,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
88692 */
88693 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
88694 {
88695 + struct sctp_initmsg initmsg;
88696 +
88697 if (len < sizeof(struct sctp_initmsg))
88698 return -EINVAL;
88699 len = sizeof(struct sctp_initmsg);
88700 if (put_user(len, optlen))
88701 return -EFAULT;
88702 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
88703 + initmsg = sctp_sk(sk)->initmsg;
88704 + if (copy_to_user(optval, &initmsg, len))
88705 return -EFAULT;
88706 return 0;
88707 }
88708 @@ -4665,6 +4676,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
88709 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
88710 if (space_left < addrlen)
88711 return -ENOMEM;
88712 + if (addrlen > sizeof(temp) || addrlen < 0)
88713 + return -EFAULT;
88714 if (copy_to_user(to, &temp, addrlen))
88715 return -EFAULT;
88716 to += addrlen;
88717 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
88718 index bf3c6e8..376d8d0 100644
88719 --- a/net/sctp/sysctl.c
88720 +++ b/net/sctp/sysctl.c
88721 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
88722 {
88723 struct net *net = current->nsproxy->net_ns;
88724 char tmp[8];
88725 - ctl_table tbl;
88726 + ctl_table_no_const tbl;
88727 int ret;
88728 int changed = 0;
88729 char *none = "none";
88730 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
88731
88732 int sctp_sysctl_net_register(struct net *net)
88733 {
88734 - struct ctl_table *table;
88735 + ctl_table_no_const *table;
88736 int i;
88737
88738 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
88739 diff --git a/net/socket.c b/net/socket.c
88740 index 88f759a..c6933de 100644
88741 --- a/net/socket.c
88742 +++ b/net/socket.c
88743 @@ -88,6 +88,7 @@
88744 #include <linux/magic.h>
88745 #include <linux/slab.h>
88746 #include <linux/xattr.h>
88747 +#include <linux/in.h>
88748
88749 #include <asm/uaccess.h>
88750 #include <asm/unistd.h>
88751 @@ -105,6 +106,8 @@
88752 #include <linux/sockios.h>
88753 #include <linux/atalk.h>
88754
88755 +#include <linux/grsock.h>
88756 +
88757 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
88758 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
88759 unsigned long nr_segs, loff_t pos);
88760 @@ -321,7 +324,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
88761 &sockfs_dentry_operations, SOCKFS_MAGIC);
88762 }
88763
88764 -static struct vfsmount *sock_mnt __read_mostly;
88765 +struct vfsmount *sock_mnt __read_mostly;
88766
88767 static struct file_system_type sock_fs_type = {
88768 .name = "sockfs",
88769 @@ -1268,6 +1271,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
88770 return -EAFNOSUPPORT;
88771 if (type < 0 || type >= SOCK_MAX)
88772 return -EINVAL;
88773 + if (protocol < 0)
88774 + return -EINVAL;
88775
88776 /* Compatibility.
88777
88778 @@ -1399,6 +1404,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
88779 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
88780 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
88781
88782 + if(!gr_search_socket(family, type, protocol)) {
88783 + retval = -EACCES;
88784 + goto out;
88785 + }
88786 +
88787 + if (gr_handle_sock_all(family, type, protocol)) {
88788 + retval = -EACCES;
88789 + goto out;
88790 + }
88791 +
88792 retval = sock_create(family, type, protocol, &sock);
88793 if (retval < 0)
88794 goto out;
88795 @@ -1526,6 +1541,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
88796 if (sock) {
88797 err = move_addr_to_kernel(umyaddr, addrlen, &address);
88798 if (err >= 0) {
88799 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
88800 + err = -EACCES;
88801 + goto error;
88802 + }
88803 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
88804 + if (err)
88805 + goto error;
88806 +
88807 err = security_socket_bind(sock,
88808 (struct sockaddr *)&address,
88809 addrlen);
88810 @@ -1534,6 +1557,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
88811 (struct sockaddr *)
88812 &address, addrlen);
88813 }
88814 +error:
88815 fput_light(sock->file, fput_needed);
88816 }
88817 return err;
88818 @@ -1557,10 +1581,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
88819 if ((unsigned int)backlog > somaxconn)
88820 backlog = somaxconn;
88821
88822 + if (gr_handle_sock_server_other(sock->sk)) {
88823 + err = -EPERM;
88824 + goto error;
88825 + }
88826 +
88827 + err = gr_search_listen(sock);
88828 + if (err)
88829 + goto error;
88830 +
88831 err = security_socket_listen(sock, backlog);
88832 if (!err)
88833 err = sock->ops->listen(sock, backlog);
88834
88835 +error:
88836 fput_light(sock->file, fput_needed);
88837 }
88838 return err;
88839 @@ -1604,6 +1638,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
88840 newsock->type = sock->type;
88841 newsock->ops = sock->ops;
88842
88843 + if (gr_handle_sock_server_other(sock->sk)) {
88844 + err = -EPERM;
88845 + sock_release(newsock);
88846 + goto out_put;
88847 + }
88848 +
88849 + err = gr_search_accept(sock);
88850 + if (err) {
88851 + sock_release(newsock);
88852 + goto out_put;
88853 + }
88854 +
88855 /*
88856 * We don't need try_module_get here, as the listening socket (sock)
88857 * has the protocol module (sock->ops->owner) held.
88858 @@ -1649,6 +1695,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
88859 fd_install(newfd, newfile);
88860 err = newfd;
88861
88862 + gr_attach_curr_ip(newsock->sk);
88863 +
88864 out_put:
88865 fput_light(sock->file, fput_needed);
88866 out:
88867 @@ -1681,6 +1729,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
88868 int, addrlen)
88869 {
88870 struct socket *sock;
88871 + struct sockaddr *sck;
88872 struct sockaddr_storage address;
88873 int err, fput_needed;
88874
88875 @@ -1691,6 +1740,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
88876 if (err < 0)
88877 goto out_put;
88878
88879 + sck = (struct sockaddr *)&address;
88880 +
88881 + if (gr_handle_sock_client(sck)) {
88882 + err = -EACCES;
88883 + goto out_put;
88884 + }
88885 +
88886 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
88887 + if (err)
88888 + goto out_put;
88889 +
88890 err =
88891 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
88892 if (err)
88893 @@ -1772,6 +1832,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
88894 * the protocol.
88895 */
88896
88897 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
88898 +
88899 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
88900 unsigned int, flags, struct sockaddr __user *, addr,
88901 int, addr_len)
88902 @@ -1838,7 +1900,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
88903 struct socket *sock;
88904 struct iovec iov;
88905 struct msghdr msg;
88906 - struct sockaddr_storage address;
88907 + struct sockaddr_storage address = { };
88908 int err, err2;
88909 int fput_needed;
88910
88911 @@ -2045,7 +2107,7 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
88912 * checking falls down on this.
88913 */
88914 if (copy_from_user(ctl_buf,
88915 - (void __user __force *)msg_sys->msg_control,
88916 + (void __force_user *)msg_sys->msg_control,
88917 ctl_len))
88918 goto out_freectl;
88919 msg_sys->msg_control = ctl_buf;
88920 @@ -2185,7 +2247,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
88921 int err, total_len, len;
88922
88923 /* kernel mode address */
88924 - struct sockaddr_storage addr;
88925 + struct sockaddr_storage addr = { };
88926
88927 /* user mode address pointers */
88928 struct sockaddr __user *uaddr;
88929 @@ -2213,7 +2275,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
88930 * kernel msghdr to use the kernel address space)
88931 */
88932
88933 - uaddr = (__force void __user *)msg_sys->msg_name;
88934 + uaddr = (void __force_user *)msg_sys->msg_name;
88935 uaddr_len = COMPAT_NAMELEN(msg);
88936 if (MSG_CMSG_COMPAT & flags) {
88937 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
88938 @@ -2952,7 +3014,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
88939 old_fs = get_fs();
88940 set_fs(KERNEL_DS);
88941 err = dev_ioctl(net, cmd,
88942 - (struct ifreq __user __force *) &kifr);
88943 + (struct ifreq __force_user *) &kifr);
88944 set_fs(old_fs);
88945
88946 return err;
88947 @@ -3061,7 +3123,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
88948
88949 old_fs = get_fs();
88950 set_fs(KERNEL_DS);
88951 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
88952 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
88953 set_fs(old_fs);
88954
88955 if (cmd == SIOCGIFMAP && !err) {
88956 @@ -3166,7 +3228,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
88957 ret |= __get_user(rtdev, &(ur4->rt_dev));
88958 if (rtdev) {
88959 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
88960 - r4.rt_dev = (char __user __force *)devname;
88961 + r4.rt_dev = (char __force_user *)devname;
88962 devname[15] = 0;
88963 } else
88964 r4.rt_dev = NULL;
88965 @@ -3392,8 +3454,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
88966 int __user *uoptlen;
88967 int err;
88968
88969 - uoptval = (char __user __force *) optval;
88970 - uoptlen = (int __user __force *) optlen;
88971 + uoptval = (char __force_user *) optval;
88972 + uoptlen = (int __force_user *) optlen;
88973
88974 set_fs(KERNEL_DS);
88975 if (level == SOL_SOCKET)
88976 @@ -3413,7 +3475,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
88977 char __user *uoptval;
88978 int err;
88979
88980 - uoptval = (char __user __force *) optval;
88981 + uoptval = (char __force_user *) optval;
88982
88983 set_fs(KERNEL_DS);
88984 if (level == SOL_SOCKET)
88985 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
88986 index d5f35f1..da2680b5 100644
88987 --- a/net/sunrpc/clnt.c
88988 +++ b/net/sunrpc/clnt.c
88989 @@ -1283,7 +1283,9 @@ call_start(struct rpc_task *task)
88990 (RPC_IS_ASYNC(task) ? "async" : "sync"));
88991
88992 /* Increment call count */
88993 - task->tk_msg.rpc_proc->p_count++;
88994 + pax_open_kernel();
88995 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
88996 + pax_close_kernel();
88997 clnt->cl_stats->rpccnt++;
88998 task->tk_action = call_reserve;
88999 }
89000 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
89001 index f8529fc..ce8c643 100644
89002 --- a/net/sunrpc/sched.c
89003 +++ b/net/sunrpc/sched.c
89004 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
89005 #ifdef RPC_DEBUG
89006 static void rpc_task_set_debuginfo(struct rpc_task *task)
89007 {
89008 - static atomic_t rpc_pid;
89009 + static atomic_unchecked_t rpc_pid;
89010
89011 - task->tk_pid = atomic_inc_return(&rpc_pid);
89012 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
89013 }
89014 #else
89015 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
89016 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
89017 index 89a588b..ba2cef8 100644
89018 --- a/net/sunrpc/svc.c
89019 +++ b/net/sunrpc/svc.c
89020 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
89021 svc_putnl(resv, RPC_SUCCESS);
89022
89023 /* Bump per-procedure stats counter */
89024 - procp->pc_count++;
89025 + pax_open_kernel();
89026 + (*(unsigned int *)&procp->pc_count)++;
89027 + pax_close_kernel();
89028
89029 /* Initialize storage for argp and resp */
89030 memset(rqstp->rq_argp, 0, procp->pc_argsize);
89031 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
89032 index 8343737..677025e 100644
89033 --- a/net/sunrpc/xprtrdma/svc_rdma.c
89034 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
89035 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
89036 static unsigned int min_max_inline = 4096;
89037 static unsigned int max_max_inline = 65536;
89038
89039 -atomic_t rdma_stat_recv;
89040 -atomic_t rdma_stat_read;
89041 -atomic_t rdma_stat_write;
89042 -atomic_t rdma_stat_sq_starve;
89043 -atomic_t rdma_stat_rq_starve;
89044 -atomic_t rdma_stat_rq_poll;
89045 -atomic_t rdma_stat_rq_prod;
89046 -atomic_t rdma_stat_sq_poll;
89047 -atomic_t rdma_stat_sq_prod;
89048 +atomic_unchecked_t rdma_stat_recv;
89049 +atomic_unchecked_t rdma_stat_read;
89050 +atomic_unchecked_t rdma_stat_write;
89051 +atomic_unchecked_t rdma_stat_sq_starve;
89052 +atomic_unchecked_t rdma_stat_rq_starve;
89053 +atomic_unchecked_t rdma_stat_rq_poll;
89054 +atomic_unchecked_t rdma_stat_rq_prod;
89055 +atomic_unchecked_t rdma_stat_sq_poll;
89056 +atomic_unchecked_t rdma_stat_sq_prod;
89057
89058 /* Temporary NFS request map and context caches */
89059 struct kmem_cache *svc_rdma_map_cachep;
89060 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
89061 len -= *ppos;
89062 if (len > *lenp)
89063 len = *lenp;
89064 - if (len && copy_to_user(buffer, str_buf, len))
89065 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
89066 return -EFAULT;
89067 *lenp = len;
89068 *ppos += len;
89069 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
89070 {
89071 .procname = "rdma_stat_read",
89072 .data = &rdma_stat_read,
89073 - .maxlen = sizeof(atomic_t),
89074 + .maxlen = sizeof(atomic_unchecked_t),
89075 .mode = 0644,
89076 .proc_handler = read_reset_stat,
89077 },
89078 {
89079 .procname = "rdma_stat_recv",
89080 .data = &rdma_stat_recv,
89081 - .maxlen = sizeof(atomic_t),
89082 + .maxlen = sizeof(atomic_unchecked_t),
89083 .mode = 0644,
89084 .proc_handler = read_reset_stat,
89085 },
89086 {
89087 .procname = "rdma_stat_write",
89088 .data = &rdma_stat_write,
89089 - .maxlen = sizeof(atomic_t),
89090 + .maxlen = sizeof(atomic_unchecked_t),
89091 .mode = 0644,
89092 .proc_handler = read_reset_stat,
89093 },
89094 {
89095 .procname = "rdma_stat_sq_starve",
89096 .data = &rdma_stat_sq_starve,
89097 - .maxlen = sizeof(atomic_t),
89098 + .maxlen = sizeof(atomic_unchecked_t),
89099 .mode = 0644,
89100 .proc_handler = read_reset_stat,
89101 },
89102 {
89103 .procname = "rdma_stat_rq_starve",
89104 .data = &rdma_stat_rq_starve,
89105 - .maxlen = sizeof(atomic_t),
89106 + .maxlen = sizeof(atomic_unchecked_t),
89107 .mode = 0644,
89108 .proc_handler = read_reset_stat,
89109 },
89110 {
89111 .procname = "rdma_stat_rq_poll",
89112 .data = &rdma_stat_rq_poll,
89113 - .maxlen = sizeof(atomic_t),
89114 + .maxlen = sizeof(atomic_unchecked_t),
89115 .mode = 0644,
89116 .proc_handler = read_reset_stat,
89117 },
89118 {
89119 .procname = "rdma_stat_rq_prod",
89120 .data = &rdma_stat_rq_prod,
89121 - .maxlen = sizeof(atomic_t),
89122 + .maxlen = sizeof(atomic_unchecked_t),
89123 .mode = 0644,
89124 .proc_handler = read_reset_stat,
89125 },
89126 {
89127 .procname = "rdma_stat_sq_poll",
89128 .data = &rdma_stat_sq_poll,
89129 - .maxlen = sizeof(atomic_t),
89130 + .maxlen = sizeof(atomic_unchecked_t),
89131 .mode = 0644,
89132 .proc_handler = read_reset_stat,
89133 },
89134 {
89135 .procname = "rdma_stat_sq_prod",
89136 .data = &rdma_stat_sq_prod,
89137 - .maxlen = sizeof(atomic_t),
89138 + .maxlen = sizeof(atomic_unchecked_t),
89139 .mode = 0644,
89140 .proc_handler = read_reset_stat,
89141 },
89142 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
89143 index 0ce7552..d074459 100644
89144 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
89145 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
89146 @@ -501,7 +501,7 @@ next_sge:
89147 svc_rdma_put_context(ctxt, 0);
89148 goto out;
89149 }
89150 - atomic_inc(&rdma_stat_read);
89151 + atomic_inc_unchecked(&rdma_stat_read);
89152
89153 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
89154 chl_map->ch[ch_no].count -= read_wr.num_sge;
89155 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
89156 dto_q);
89157 list_del_init(&ctxt->dto_q);
89158 } else {
89159 - atomic_inc(&rdma_stat_rq_starve);
89160 + atomic_inc_unchecked(&rdma_stat_rq_starve);
89161 clear_bit(XPT_DATA, &xprt->xpt_flags);
89162 ctxt = NULL;
89163 }
89164 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
89165 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
89166 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
89167 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
89168 - atomic_inc(&rdma_stat_recv);
89169 + atomic_inc_unchecked(&rdma_stat_recv);
89170
89171 /* Build up the XDR from the receive buffers. */
89172 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
89173 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
89174 index c1d124d..acfc59e 100644
89175 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
89176 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
89177 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
89178 write_wr.wr.rdma.remote_addr = to;
89179
89180 /* Post It */
89181 - atomic_inc(&rdma_stat_write);
89182 + atomic_inc_unchecked(&rdma_stat_write);
89183 if (svc_rdma_send(xprt, &write_wr))
89184 goto err;
89185 return 0;
89186 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
89187 index 62e4f9b..dd3f2d7 100644
89188 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
89189 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
89190 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
89191 return;
89192
89193 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
89194 - atomic_inc(&rdma_stat_rq_poll);
89195 + atomic_inc_unchecked(&rdma_stat_rq_poll);
89196
89197 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
89198 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
89199 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
89200 }
89201
89202 if (ctxt)
89203 - atomic_inc(&rdma_stat_rq_prod);
89204 + atomic_inc_unchecked(&rdma_stat_rq_prod);
89205
89206 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
89207 /*
89208 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
89209 return;
89210
89211 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
89212 - atomic_inc(&rdma_stat_sq_poll);
89213 + atomic_inc_unchecked(&rdma_stat_sq_poll);
89214 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
89215 if (wc.status != IB_WC_SUCCESS)
89216 /* Close the transport */
89217 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
89218 }
89219
89220 if (ctxt)
89221 - atomic_inc(&rdma_stat_sq_prod);
89222 + atomic_inc_unchecked(&rdma_stat_sq_prod);
89223 }
89224
89225 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
89226 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
89227 spin_lock_bh(&xprt->sc_lock);
89228 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
89229 spin_unlock_bh(&xprt->sc_lock);
89230 - atomic_inc(&rdma_stat_sq_starve);
89231 + atomic_inc_unchecked(&rdma_stat_sq_starve);
89232
89233 /* See if we can opportunistically reap SQ WR to make room */
89234 sq_cq_reap(xprt);
89235 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
89236 index 9bc6db0..47ac8c0 100644
89237 --- a/net/sysctl_net.c
89238 +++ b/net/sysctl_net.c
89239 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
89240 kgid_t root_gid = make_kgid(net->user_ns, 0);
89241
89242 /* Allow network administrator to have same access as root. */
89243 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
89244 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
89245 uid_eq(root_uid, current_uid())) {
89246 int mode = (table->mode >> 6) & 7;
89247 return (mode << 6) | (mode << 3) | mode;
89248 diff --git a/net/tipc/link.c b/net/tipc/link.c
89249 index daa6080..2bbbe70 100644
89250 --- a/net/tipc/link.c
89251 +++ b/net/tipc/link.c
89252 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
89253 struct tipc_msg fragm_hdr;
89254 struct sk_buff *buf, *buf_chain, *prev;
89255 u32 fragm_crs, fragm_rest, hsz, sect_rest;
89256 - const unchar *sect_crs;
89257 + const unchar __user *sect_crs;
89258 int curr_sect;
89259 u32 fragm_no;
89260
89261 @@ -1242,7 +1242,7 @@ again:
89262
89263 if (!sect_rest) {
89264 sect_rest = msg_sect[++curr_sect].iov_len;
89265 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
89266 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
89267 }
89268
89269 if (sect_rest < fragm_rest)
89270 @@ -1261,7 +1261,7 @@ error:
89271 }
89272 } else
89273 skb_copy_to_linear_data_offset(buf, fragm_crs,
89274 - sect_crs, sz);
89275 + (const void __force_kernel *)sect_crs, sz);
89276 sect_crs += sz;
89277 sect_rest -= sz;
89278 fragm_crs += sz;
89279 @@ -2306,8 +2306,11 @@ static int link_recv_changeover_msg(struct tipc_link **l_ptr,
89280 struct tipc_msg *tunnel_msg = buf_msg(tunnel_buf);
89281 u32 msg_typ = msg_type(tunnel_msg);
89282 u32 msg_count = msg_msgcnt(tunnel_msg);
89283 + u32 bearer_id = msg_bearer_id(tunnel_msg);
89284
89285 - dest_link = (*l_ptr)->owner->links[msg_bearer_id(tunnel_msg)];
89286 + if (bearer_id >= MAX_BEARERS)
89287 + goto exit;
89288 + dest_link = (*l_ptr)->owner->links[bearer_id];
89289 if (!dest_link)
89290 goto exit;
89291 if (dest_link == *l_ptr) {
89292 @@ -2521,14 +2524,16 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
89293 struct tipc_msg *imsg = (struct tipc_msg *)msg_data(fragm);
89294 u32 msg_sz = msg_size(imsg);
89295 u32 fragm_sz = msg_data_sz(fragm);
89296 - u32 exp_fragm_cnt = msg_sz/fragm_sz + !!(msg_sz % fragm_sz);
89297 + u32 exp_fragm_cnt;
89298 u32 max = TIPC_MAX_USER_MSG_SIZE + NAMED_H_SIZE;
89299 +
89300 if (msg_type(imsg) == TIPC_MCAST_MSG)
89301 max = TIPC_MAX_USER_MSG_SIZE + MCAST_H_SIZE;
89302 - if (msg_size(imsg) > max) {
89303 + if (fragm_sz == 0 || msg_size(imsg) > max) {
89304 kfree_skb(fbuf);
89305 return 0;
89306 }
89307 + exp_fragm_cnt = msg_sz / fragm_sz + !!(msg_sz % fragm_sz);
89308 pbuf = tipc_buf_acquire(msg_size(imsg));
89309 if (pbuf != NULL) {
89310 pbuf->next = *pending;
89311 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
89312 index f2db8a8..9245aa4 100644
89313 --- a/net/tipc/msg.c
89314 +++ b/net/tipc/msg.c
89315 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
89316 msg_sect[cnt].iov_len);
89317 else
89318 skb_copy_to_linear_data_offset(*buf, pos,
89319 - msg_sect[cnt].iov_base,
89320 + (const void __force_kernel *)msg_sect[cnt].iov_base,
89321 msg_sect[cnt].iov_len);
89322 pos += msg_sect[cnt].iov_len;
89323 }
89324 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
89325 index 6b42d47..2ac24d5 100644
89326 --- a/net/tipc/subscr.c
89327 +++ b/net/tipc/subscr.c
89328 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
89329 {
89330 struct iovec msg_sect;
89331
89332 - msg_sect.iov_base = (void *)&sub->evt;
89333 + msg_sect.iov_base = (void __force_user *)&sub->evt;
89334 msg_sect.iov_len = sizeof(struct tipc_event);
89335
89336 sub->evt.event = htohl(event, sub->swap);
89337 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
89338 index 2db702d..09a77488 100644
89339 --- a/net/unix/af_unix.c
89340 +++ b/net/unix/af_unix.c
89341 @@ -783,6 +783,12 @@ static struct sock *unix_find_other(struct net *net,
89342 err = -ECONNREFUSED;
89343 if (!S_ISSOCK(inode->i_mode))
89344 goto put_fail;
89345 +
89346 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
89347 + err = -EACCES;
89348 + goto put_fail;
89349 + }
89350 +
89351 u = unix_find_socket_byinode(inode);
89352 if (!u)
89353 goto put_fail;
89354 @@ -803,6 +809,13 @@ static struct sock *unix_find_other(struct net *net,
89355 if (u) {
89356 struct dentry *dentry;
89357 dentry = unix_sk(u)->path.dentry;
89358 +
89359 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
89360 + err = -EPERM;
89361 + sock_put(u);
89362 + goto fail;
89363 + }
89364 +
89365 if (dentry)
89366 touch_atime(&unix_sk(u)->path);
89367 } else
89368 @@ -836,12 +849,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
89369 */
89370 err = security_path_mknod(&path, dentry, mode, 0);
89371 if (!err) {
89372 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
89373 + err = -EACCES;
89374 + goto out;
89375 + }
89376 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
89377 if (!err) {
89378 res->mnt = mntget(path.mnt);
89379 res->dentry = dget(dentry);
89380 + gr_handle_create(dentry, path.mnt);
89381 }
89382 }
89383 +out:
89384 done_path_create(&path, dentry);
89385 return err;
89386 }
89387 @@ -2323,9 +2342,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
89388 seq_puts(seq, "Num RefCount Protocol Flags Type St "
89389 "Inode Path\n");
89390 else {
89391 - struct sock *s = v;
89392 + struct sock *s = v, *peer;
89393 struct unix_sock *u = unix_sk(s);
89394 unix_state_lock(s);
89395 + peer = unix_peer(s);
89396 + unix_state_unlock(s);
89397 +
89398 + unix_state_double_lock(s, peer);
89399
89400 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
89401 s,
89402 @@ -2352,8 +2375,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
89403 }
89404 for ( ; i < len; i++)
89405 seq_putc(seq, u->addr->name->sun_path[i]);
89406 - }
89407 - unix_state_unlock(s);
89408 + } else if (peer)
89409 + seq_printf(seq, " P%lu", sock_i_ino(peer));
89410 +
89411 + unix_state_double_unlock(s, peer);
89412 seq_putc(seq, '\n');
89413 }
89414
89415 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
89416 index 8800604..0526440 100644
89417 --- a/net/unix/sysctl_net_unix.c
89418 +++ b/net/unix/sysctl_net_unix.c
89419 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
89420
89421 int __net_init unix_sysctl_register(struct net *net)
89422 {
89423 - struct ctl_table *table;
89424 + ctl_table_no_const *table;
89425
89426 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
89427 if (table == NULL)
89428 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
89429 index c8717c1..08539f5 100644
89430 --- a/net/wireless/wext-core.c
89431 +++ b/net/wireless/wext-core.c
89432 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
89433 */
89434
89435 /* Support for very large requests */
89436 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
89437 - (user_length > descr->max_tokens)) {
89438 + if (user_length > descr->max_tokens) {
89439 /* Allow userspace to GET more than max so
89440 * we can support any size GET requests.
89441 * There is still a limit : -ENOMEM.
89442 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
89443 }
89444 }
89445
89446 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
89447 - /*
89448 - * If this is a GET, but not NOMAX, it means that the extra
89449 - * data is not bounded by userspace, but by max_tokens. Thus
89450 - * set the length to max_tokens. This matches the extra data
89451 - * allocation.
89452 - * The driver should fill it with the number of tokens it
89453 - * provided, and it may check iwp->length rather than having
89454 - * knowledge of max_tokens. If the driver doesn't change the
89455 - * iwp->length, this ioctl just copies back max_token tokens
89456 - * filled with zeroes. Hopefully the driver isn't claiming
89457 - * them to be valid data.
89458 - */
89459 - iwp->length = descr->max_tokens;
89460 - }
89461 -
89462 err = handler(dev, info, (union iwreq_data *) iwp, extra);
89463
89464 iwp->length += essid_compat;
89465 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
89466 index 167c67d..3f2ae427 100644
89467 --- a/net/xfrm/xfrm_policy.c
89468 +++ b/net/xfrm/xfrm_policy.c
89469 @@ -334,7 +334,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
89470 {
89471 policy->walk.dead = 1;
89472
89473 - atomic_inc(&policy->genid);
89474 + atomic_inc_unchecked(&policy->genid);
89475
89476 del_timer(&policy->polq.hold_timer);
89477 xfrm_queue_purge(&policy->polq.hold_queue);
89478 @@ -659,7 +659,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
89479 hlist_add_head(&policy->bydst, chain);
89480 xfrm_pol_hold(policy);
89481 net->xfrm.policy_count[dir]++;
89482 - atomic_inc(&flow_cache_genid);
89483 + atomic_inc_unchecked(&flow_cache_genid);
89484 rt_genid_bump(net);
89485 if (delpol) {
89486 xfrm_policy_requeue(delpol, policy);
89487 @@ -1611,7 +1611,7 @@ free_dst:
89488 goto out;
89489 }
89490
89491 -static int inline
89492 +static inline int
89493 xfrm_dst_alloc_copy(void **target, const void *src, int size)
89494 {
89495 if (!*target) {
89496 @@ -1623,7 +1623,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
89497 return 0;
89498 }
89499
89500 -static int inline
89501 +static inline int
89502 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
89503 {
89504 #ifdef CONFIG_XFRM_SUB_POLICY
89505 @@ -1635,7 +1635,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
89506 #endif
89507 }
89508
89509 -static int inline
89510 +static inline int
89511 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
89512 {
89513 #ifdef CONFIG_XFRM_SUB_POLICY
89514 @@ -1729,7 +1729,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
89515
89516 xdst->num_pols = num_pols;
89517 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
89518 - xdst->policy_genid = atomic_read(&pols[0]->genid);
89519 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
89520
89521 return xdst;
89522 }
89523 @@ -2598,7 +2598,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
89524 if (xdst->xfrm_genid != dst->xfrm->genid)
89525 return 0;
89526 if (xdst->num_pols > 0 &&
89527 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
89528 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
89529 return 0;
89530
89531 mtu = dst_mtu(dst->child);
89532 @@ -2686,8 +2686,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
89533 dst_ops->link_failure = xfrm_link_failure;
89534 if (likely(dst_ops->neigh_lookup == NULL))
89535 dst_ops->neigh_lookup = xfrm_neigh_lookup;
89536 - if (likely(afinfo->garbage_collect == NULL))
89537 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
89538 + if (likely(afinfo->garbage_collect == NULL)) {
89539 + pax_open_kernel();
89540 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
89541 + pax_close_kernel();
89542 + }
89543 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
89544 }
89545 spin_unlock(&xfrm_policy_afinfo_lock);
89546 @@ -2741,7 +2744,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
89547 dst_ops->check = NULL;
89548 dst_ops->negative_advice = NULL;
89549 dst_ops->link_failure = NULL;
89550 - afinfo->garbage_collect = NULL;
89551 + pax_open_kernel();
89552 + *(void **)&afinfo->garbage_collect = NULL;
89553 + pax_close_kernel();
89554 }
89555 return err;
89556 }
89557 @@ -3124,7 +3129,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
89558 sizeof(pol->xfrm_vec[i].saddr));
89559 pol->xfrm_vec[i].encap_family = mp->new_family;
89560 /* flush bundles */
89561 - atomic_inc(&pol->genid);
89562 + atomic_inc_unchecked(&pol->genid);
89563 }
89564 }
89565
89566 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
89567 index 2c341bd..4404211 100644
89568 --- a/net/xfrm/xfrm_state.c
89569 +++ b/net/xfrm/xfrm_state.c
89570 @@ -177,12 +177,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
89571
89572 if (unlikely(afinfo == NULL))
89573 return -EAFNOSUPPORT;
89574 - typemap = afinfo->type_map;
89575 + typemap = (const struct xfrm_type **)afinfo->type_map;
89576 spin_lock_bh(&xfrm_type_lock);
89577
89578 - if (likely(typemap[type->proto] == NULL))
89579 + if (likely(typemap[type->proto] == NULL)) {
89580 + pax_open_kernel();
89581 typemap[type->proto] = type;
89582 - else
89583 + pax_close_kernel();
89584 + } else
89585 err = -EEXIST;
89586 spin_unlock_bh(&xfrm_type_lock);
89587 xfrm_state_put_afinfo(afinfo);
89588 @@ -198,13 +200,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
89589
89590 if (unlikely(afinfo == NULL))
89591 return -EAFNOSUPPORT;
89592 - typemap = afinfo->type_map;
89593 + typemap = (const struct xfrm_type **)afinfo->type_map;
89594 spin_lock_bh(&xfrm_type_lock);
89595
89596 if (unlikely(typemap[type->proto] != type))
89597 err = -ENOENT;
89598 - else
89599 + else {
89600 + pax_open_kernel();
89601 typemap[type->proto] = NULL;
89602 + pax_close_kernel();
89603 + }
89604 spin_unlock_bh(&xfrm_type_lock);
89605 xfrm_state_put_afinfo(afinfo);
89606 return err;
89607 @@ -214,7 +219,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
89608 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
89609 {
89610 struct xfrm_state_afinfo *afinfo;
89611 - const struct xfrm_type **typemap;
89612 const struct xfrm_type *type;
89613 int modload_attempted = 0;
89614
89615 @@ -222,9 +226,8 @@ retry:
89616 afinfo = xfrm_state_get_afinfo(family);
89617 if (unlikely(afinfo == NULL))
89618 return NULL;
89619 - typemap = afinfo->type_map;
89620
89621 - type = typemap[proto];
89622 + type = afinfo->type_map[proto];
89623 if (unlikely(type && !try_module_get(type->owner)))
89624 type = NULL;
89625 if (!type && !modload_attempted) {
89626 @@ -258,7 +261,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
89627 return -EAFNOSUPPORT;
89628
89629 err = -EEXIST;
89630 - modemap = afinfo->mode_map;
89631 + modemap = (struct xfrm_mode **)afinfo->mode_map;
89632 spin_lock_bh(&xfrm_mode_lock);
89633 if (modemap[mode->encap])
89634 goto out;
89635 @@ -267,8 +270,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
89636 if (!try_module_get(afinfo->owner))
89637 goto out;
89638
89639 - mode->afinfo = afinfo;
89640 + pax_open_kernel();
89641 + *(const void **)&mode->afinfo = afinfo;
89642 modemap[mode->encap] = mode;
89643 + pax_close_kernel();
89644 err = 0;
89645
89646 out:
89647 @@ -292,10 +297,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
89648 return -EAFNOSUPPORT;
89649
89650 err = -ENOENT;
89651 - modemap = afinfo->mode_map;
89652 + modemap = (struct xfrm_mode **)afinfo->mode_map;
89653 spin_lock_bh(&xfrm_mode_lock);
89654 if (likely(modemap[mode->encap] == mode)) {
89655 + pax_open_kernel();
89656 modemap[mode->encap] = NULL;
89657 + pax_close_kernel();
89658 module_put(mode->afinfo->owner);
89659 err = 0;
89660 }
89661 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
89662 index 05a6e3d..6716ec9 100644
89663 --- a/net/xfrm/xfrm_sysctl.c
89664 +++ b/net/xfrm/xfrm_sysctl.c
89665 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
89666
89667 int __net_init xfrm_sysctl_init(struct net *net)
89668 {
89669 - struct ctl_table *table;
89670 + ctl_table_no_const *table;
89671
89672 __xfrm_sysctl_init(net);
89673
89674 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
89675 index 0e801c3..5c8ad3b 100644
89676 --- a/scripts/Makefile.build
89677 +++ b/scripts/Makefile.build
89678 @@ -111,7 +111,7 @@ endif
89679 endif
89680
89681 # Do not include host rules unless needed
89682 -ifneq ($(hostprogs-y)$(hostprogs-m),)
89683 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
89684 include scripts/Makefile.host
89685 endif
89686
89687 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
89688 index 686cb0d..9d653bf 100644
89689 --- a/scripts/Makefile.clean
89690 +++ b/scripts/Makefile.clean
89691 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
89692 __clean-files := $(extra-y) $(always) \
89693 $(targets) $(clean-files) \
89694 $(host-progs) \
89695 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
89696 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
89697 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
89698
89699 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
89700
89701 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
89702 index 1ac414f..38575f7 100644
89703 --- a/scripts/Makefile.host
89704 +++ b/scripts/Makefile.host
89705 @@ -31,6 +31,8 @@
89706 # Note: Shared libraries consisting of C++ files are not supported
89707
89708 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
89709 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
89710 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
89711
89712 # C code
89713 # Executables compiled from a single .c file
89714 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
89715 # Shared libaries (only .c supported)
89716 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
89717 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
89718 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
89719 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
89720 # Remove .so files from "xxx-objs"
89721 host-cobjs := $(filter-out %.so,$(host-cobjs))
89722 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
89723
89724 -#Object (.o) files used by the shared libaries
89725 +# Object (.o) files used by the shared libaries
89726 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
89727 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
89728
89729 # output directory for programs/.o files
89730 # hostprogs-y := tools/build may have been specified. Retrieve directory
89731 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
89732 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
89733 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
89734 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
89735 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
89736 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
89737 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
89738 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
89739
89740 obj-dirs += $(host-objdirs)
89741 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
89742 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
89743 $(call if_changed_dep,host-cshobjs)
89744
89745 +# Compile .c file, create position independent .o file
89746 +# host-cxxshobjs -> .o
89747 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
89748 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
89749 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
89750 + $(call if_changed_dep,host-cxxshobjs)
89751 +
89752 # Link a shared library, based on position independent .o files
89753 # *.o -> .so shared library (host-cshlib)
89754 quiet_cmd_host-cshlib = HOSTLLD -shared $@
89755 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
89756 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
89757 $(call if_changed,host-cshlib)
89758
89759 +# Link a shared library, based on position independent .o files
89760 +# *.o -> .so shared library (host-cxxshlib)
89761 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
89762 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
89763 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
89764 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
89765 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
89766 + $(call if_changed,host-cxxshlib)
89767 +
89768 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
89769 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
89770 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
89771
89772 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
89773 index 7f6425e..9864506 100644
89774 --- a/scripts/basic/fixdep.c
89775 +++ b/scripts/basic/fixdep.c
89776 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
89777 /*
89778 * Lookup a value in the configuration string.
89779 */
89780 -static int is_defined_config(const char *name, int len, unsigned int hash)
89781 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
89782 {
89783 struct item *aux;
89784
89785 @@ -211,10 +211,10 @@ static void clear_config(void)
89786 /*
89787 * Record the use of a CONFIG_* word.
89788 */
89789 -static void use_config(const char *m, int slen)
89790 +static void use_config(const char *m, unsigned int slen)
89791 {
89792 unsigned int hash = strhash(m, slen);
89793 - int c, i;
89794 + unsigned int c, i;
89795
89796 if (is_defined_config(m, slen, hash))
89797 return;
89798 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
89799
89800 static void parse_config_file(const char *map, size_t len)
89801 {
89802 - const int *end = (const int *) (map + len);
89803 + const unsigned int *end = (const unsigned int *) (map + len);
89804 /* start at +1, so that p can never be < map */
89805 - const int *m = (const int *) map + 1;
89806 + const unsigned int *m = (const unsigned int *) map + 1;
89807 const char *p, *q;
89808
89809 for (; m < end; m++) {
89810 @@ -406,7 +406,7 @@ static void print_deps(void)
89811 static void traps(void)
89812 {
89813 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
89814 - int *p = (int *)test;
89815 + unsigned int *p = (unsigned int *)test;
89816
89817 if (*p != INT_CONF) {
89818 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
89819 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
89820 new file mode 100644
89821 index 0000000..5e0222d
89822 --- /dev/null
89823 +++ b/scripts/gcc-plugin.sh
89824 @@ -0,0 +1,17 @@
89825 +#!/bin/bash
89826 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
89827 +#include "gcc-plugin.h"
89828 +#include "tree.h"
89829 +#include "tm.h"
89830 +#include "rtl.h"
89831 +#ifdef ENABLE_BUILD_WITH_CXX
89832 +#warning $2
89833 +#else
89834 +#warning $1
89835 +#endif
89836 +EOF`
89837 +if [ $? -eq 0 ]
89838 +then
89839 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
89840 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
89841 +fi
89842 diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
89843 index 581ca99..a6ff02e 100644
89844 --- a/scripts/headers_install.pl
89845 +++ b/scripts/headers_install.pl
89846 @@ -35,6 +35,7 @@ foreach my $filename (@files) {
89847 $line =~ s/([\s(])__user\s/$1/g;
89848 $line =~ s/([\s(])__force\s/$1/g;
89849 $line =~ s/([\s(])__iomem\s/$1/g;
89850 + $line =~ s/(\s?)__intentional_overflow\([-\d\s,]*\)\s?/$1/g;
89851 $line =~ s/\s__attribute_const__\s/ /g;
89852 $line =~ s/\s__attribute_const__$//g;
89853 $line =~ s/\b__packed\b/__attribute__((packed))/g;
89854 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
89855 index 3d569d6..0c09522 100644
89856 --- a/scripts/link-vmlinux.sh
89857 +++ b/scripts/link-vmlinux.sh
89858 @@ -159,7 +159,7 @@ else
89859 fi;
89860
89861 # final build of init/
89862 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
89863 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
89864
89865 kallsymso=""
89866 kallsyms_vmlinux=""
89867 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
89868 index 771ac17..9f0d3ee 100644
89869 --- a/scripts/mod/file2alias.c
89870 +++ b/scripts/mod/file2alias.c
89871 @@ -140,7 +140,7 @@ static void device_id_check(const char *modname, const char *device_id,
89872 unsigned long size, unsigned long id_size,
89873 void *symval)
89874 {
89875 - int i;
89876 + unsigned int i;
89877
89878 if (size % id_size || size < id_size) {
89879 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
89880 @@ -168,7 +168,7 @@ static void device_id_check(const char *modname, const char *device_id,
89881 /* USB is special because the bcdDevice can be matched against a numeric range */
89882 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
89883 static void do_usb_entry(void *symval,
89884 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
89885 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
89886 unsigned char range_lo, unsigned char range_hi,
89887 unsigned char max, struct module *mod)
89888 {
89889 @@ -278,7 +278,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
89890 {
89891 unsigned int devlo, devhi;
89892 unsigned char chi, clo, max;
89893 - int ndigits;
89894 + unsigned int ndigits;
89895
89896 DEF_FIELD(symval, usb_device_id, match_flags);
89897 DEF_FIELD(symval, usb_device_id, idVendor);
89898 @@ -531,7 +531,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
89899 for (i = 0; i < count; i++) {
89900 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
89901 char acpi_id[sizeof(*id)];
89902 - int j;
89903 + unsigned int j;
89904
89905 buf_printf(&mod->dev_table_buf,
89906 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
89907 @@ -560,7 +560,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
89908
89909 for (j = 0; j < PNP_MAX_DEVICES; j++) {
89910 const char *id = (char *)(*devs)[j].id;
89911 - int i2, j2;
89912 + unsigned int i2, j2;
89913 int dup = 0;
89914
89915 if (!id[0])
89916 @@ -586,7 +586,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
89917 /* add an individual alias for every device entry */
89918 if (!dup) {
89919 char acpi_id[PNP_ID_LEN];
89920 - int k;
89921 + unsigned int k;
89922
89923 buf_printf(&mod->dev_table_buf,
89924 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
89925 @@ -938,7 +938,7 @@ static void dmi_ascii_filter(char *d, const char *s)
89926 static int do_dmi_entry(const char *filename, void *symval,
89927 char *alias)
89928 {
89929 - int i, j;
89930 + unsigned int i, j;
89931 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
89932 sprintf(alias, "dmi*");
89933
89934 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
89935 index 78b30c1..536850d 100644
89936 --- a/scripts/mod/modpost.c
89937 +++ b/scripts/mod/modpost.c
89938 @@ -931,6 +931,7 @@ enum mismatch {
89939 ANY_INIT_TO_ANY_EXIT,
89940 ANY_EXIT_TO_ANY_INIT,
89941 EXPORT_TO_INIT_EXIT,
89942 + DATA_TO_TEXT
89943 };
89944
89945 struct sectioncheck {
89946 @@ -1045,6 +1046,12 @@ const struct sectioncheck sectioncheck[] = {
89947 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
89948 .mismatch = EXPORT_TO_INIT_EXIT,
89949 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
89950 +},
89951 +/* Do not reference code from writable data */
89952 +{
89953 + .fromsec = { DATA_SECTIONS, NULL },
89954 + .tosec = { TEXT_SECTIONS, NULL },
89955 + .mismatch = DATA_TO_TEXT
89956 }
89957 };
89958
89959 @@ -1167,10 +1174,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
89960 continue;
89961 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
89962 continue;
89963 - if (sym->st_value == addr)
89964 - return sym;
89965 /* Find a symbol nearby - addr are maybe negative */
89966 d = sym->st_value - addr;
89967 + if (d == 0)
89968 + return sym;
89969 if (d < 0)
89970 d = addr - sym->st_value;
89971 if (d < distance) {
89972 @@ -1449,6 +1456,14 @@ static void report_sec_mismatch(const char *modname,
89973 tosym, prl_to, prl_to, tosym);
89974 free(prl_to);
89975 break;
89976 + case DATA_TO_TEXT:
89977 +#if 0
89978 + fprintf(stderr,
89979 + "The %s %s:%s references\n"
89980 + "the %s %s:%s%s\n",
89981 + from, fromsec, fromsym, to, tosec, tosym, to_p);
89982 +#endif
89983 + break;
89984 }
89985 fprintf(stderr, "\n");
89986 }
89987 @@ -1683,7 +1698,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
89988 static void check_sec_ref(struct module *mod, const char *modname,
89989 struct elf_info *elf)
89990 {
89991 - int i;
89992 + unsigned int i;
89993 Elf_Shdr *sechdrs = elf->sechdrs;
89994
89995 /* Walk through all sections */
89996 @@ -1781,7 +1796,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
89997 va_end(ap);
89998 }
89999
90000 -void buf_write(struct buffer *buf, const char *s, int len)
90001 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
90002 {
90003 if (buf->size - buf->pos < len) {
90004 buf->size += len + SZ;
90005 @@ -1999,7 +2014,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
90006 if (fstat(fileno(file), &st) < 0)
90007 goto close_write;
90008
90009 - if (st.st_size != b->pos)
90010 + if (st.st_size != (off_t)b->pos)
90011 goto close_write;
90012
90013 tmp = NOFAIL(malloc(b->pos));
90014 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
90015 index 51207e4..f7d603d 100644
90016 --- a/scripts/mod/modpost.h
90017 +++ b/scripts/mod/modpost.h
90018 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
90019
90020 struct buffer {
90021 char *p;
90022 - int pos;
90023 - int size;
90024 + unsigned int pos;
90025 + unsigned int size;
90026 };
90027
90028 void __attribute__((format(printf, 2, 3)))
90029 buf_printf(struct buffer *buf, const char *fmt, ...);
90030
90031 void
90032 -buf_write(struct buffer *buf, const char *s, int len);
90033 +buf_write(struct buffer *buf, const char *s, unsigned int len);
90034
90035 struct module {
90036 struct module *next;
90037 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
90038 index 9dfcd6d..099068e 100644
90039 --- a/scripts/mod/sumversion.c
90040 +++ b/scripts/mod/sumversion.c
90041 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
90042 goto out;
90043 }
90044
90045 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
90046 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
90047 warn("writing sum in %s failed: %s\n",
90048 filename, strerror(errno));
90049 goto out;
90050 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
90051 index acb8650..b8c5f02 100644
90052 --- a/scripts/package/builddeb
90053 +++ b/scripts/package/builddeb
90054 @@ -246,6 +246,7 @@ fi
90055 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
90056 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
90057 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
90058 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
90059 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
90060 mkdir -p "$destdir"
90061 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
90062 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
90063 index 68bb4ef..2f419e1 100644
90064 --- a/scripts/pnmtologo.c
90065 +++ b/scripts/pnmtologo.c
90066 @@ -244,14 +244,14 @@ static void write_header(void)
90067 fprintf(out, " * Linux logo %s\n", logoname);
90068 fputs(" */\n\n", out);
90069 fputs("#include <linux/linux_logo.h>\n\n", out);
90070 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
90071 + fprintf(out, "static unsigned char %s_data[] = {\n",
90072 logoname);
90073 }
90074
90075 static void write_footer(void)
90076 {
90077 fputs("\n};\n\n", out);
90078 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
90079 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
90080 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
90081 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
90082 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
90083 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
90084 fputs("\n};\n\n", out);
90085
90086 /* write logo clut */
90087 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
90088 + fprintf(out, "static unsigned char %s_clut[] = {\n",
90089 logoname);
90090 write_hex_cnt = 0;
90091 for (i = 0; i < logo_clutsize; i++) {
90092 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
90093 index f5eb43d..1814de8 100644
90094 --- a/scripts/sortextable.h
90095 +++ b/scripts/sortextable.h
90096 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
90097 const char *secstrtab;
90098 const char *strtab;
90099 char *extab_image;
90100 - int extab_index = 0;
90101 - int i;
90102 - int idx;
90103 + unsigned int extab_index = 0;
90104 + unsigned int i;
90105 + unsigned int idx;
90106
90107 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
90108 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
90109 diff --git a/security/Kconfig b/security/Kconfig
90110 index e9c6ac7..eef8ada 100644
90111 --- a/security/Kconfig
90112 +++ b/security/Kconfig
90113 @@ -4,6 +4,943 @@
90114
90115 menu "Security options"
90116
90117 +menu "Grsecurity"
90118 +
90119 + config ARCH_TRACK_EXEC_LIMIT
90120 + bool
90121 +
90122 + config PAX_KERNEXEC_PLUGIN
90123 + bool
90124 +
90125 + config PAX_PER_CPU_PGD
90126 + bool
90127 +
90128 + config TASK_SIZE_MAX_SHIFT
90129 + int
90130 + depends on X86_64
90131 + default 47 if !PAX_PER_CPU_PGD
90132 + default 42 if PAX_PER_CPU_PGD
90133 +
90134 + config PAX_ENABLE_PAE
90135 + bool
90136 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
90137 +
90138 + config PAX_USERCOPY_SLABS
90139 + bool
90140 +
90141 +config GRKERNSEC
90142 + bool "Grsecurity"
90143 + select CRYPTO
90144 + select CRYPTO_SHA256
90145 + select PROC_FS
90146 + select STOP_MACHINE
90147 + help
90148 + If you say Y here, you will be able to configure many features
90149 + that will enhance the security of your system. It is highly
90150 + recommended that you say Y here and read through the help
90151 + for each option so that you fully understand the features and
90152 + can evaluate their usefulness for your machine.
90153 +
90154 +choice
90155 + prompt "Configuration Method"
90156 + depends on GRKERNSEC
90157 + default GRKERNSEC_CONFIG_CUSTOM
90158 + help
90159 +
90160 +config GRKERNSEC_CONFIG_AUTO
90161 + bool "Automatic"
90162 + help
90163 + If you choose this configuration method, you'll be able to answer a small
90164 + number of simple questions about how you plan to use this kernel.
90165 + The settings of grsecurity and PaX will be automatically configured for
90166 + the highest commonly-used settings within the provided constraints.
90167 +
90168 + If you require additional configuration, custom changes can still be made
90169 + from the "custom configuration" menu.
90170 +
90171 +config GRKERNSEC_CONFIG_CUSTOM
90172 + bool "Custom"
90173 + help
90174 + If you choose this configuration method, you'll be able to configure all
90175 + grsecurity and PaX settings manually. Via this method, no options are
90176 + automatically enabled.
90177 +
90178 +endchoice
90179 +
90180 +choice
90181 + prompt "Usage Type"
90182 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
90183 + default GRKERNSEC_CONFIG_SERVER
90184 + help
90185 +
90186 +config GRKERNSEC_CONFIG_SERVER
90187 + bool "Server"
90188 + help
90189 + Choose this option if you plan to use this kernel on a server.
90190 +
90191 +config GRKERNSEC_CONFIG_DESKTOP
90192 + bool "Desktop"
90193 + help
90194 + Choose this option if you plan to use this kernel on a desktop.
90195 +
90196 +endchoice
90197 +
90198 +choice
90199 + prompt "Virtualization Type"
90200 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
90201 + default GRKERNSEC_CONFIG_VIRT_NONE
90202 + help
90203 +
90204 +config GRKERNSEC_CONFIG_VIRT_NONE
90205 + bool "None"
90206 + help
90207 + Choose this option if this kernel will be run on bare metal.
90208 +
90209 +config GRKERNSEC_CONFIG_VIRT_GUEST
90210 + bool "Guest"
90211 + help
90212 + Choose this option if this kernel will be run as a VM guest.
90213 +
90214 +config GRKERNSEC_CONFIG_VIRT_HOST
90215 + bool "Host"
90216 + help
90217 + Choose this option if this kernel will be run as a VM host.
90218 +
90219 +endchoice
90220 +
90221 +choice
90222 + prompt "Virtualization Hardware"
90223 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
90224 + help
90225 +
90226 +config GRKERNSEC_CONFIG_VIRT_EPT
90227 + bool "EPT/RVI Processor Support"
90228 + depends on X86
90229 + help
90230 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
90231 + hardware virtualization. This allows for additional kernel hardening protections
90232 + to operate without additional performance impact.
90233 +
90234 + To see if your Intel processor supports EPT, see:
90235 + http://ark.intel.com/Products/VirtualizationTechnology
90236 + (Most Core i3/5/7 support EPT)
90237 +
90238 + To see if your AMD processor supports RVI, see:
90239 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
90240 +
90241 +config GRKERNSEC_CONFIG_VIRT_SOFT
90242 + bool "First-gen/No Hardware Virtualization"
90243 + help
90244 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
90245 + support hardware virtualization or doesn't support the EPT/RVI extensions.
90246 +
90247 +endchoice
90248 +
90249 +choice
90250 + prompt "Virtualization Software"
90251 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
90252 + help
90253 +
90254 +config GRKERNSEC_CONFIG_VIRT_XEN
90255 + bool "Xen"
90256 + help
90257 + Choose this option if this kernel is running as a Xen guest or host.
90258 +
90259 +config GRKERNSEC_CONFIG_VIRT_VMWARE
90260 + bool "VMWare"
90261 + help
90262 + Choose this option if this kernel is running as a VMWare guest or host.
90263 +
90264 +config GRKERNSEC_CONFIG_VIRT_KVM
90265 + bool "KVM"
90266 + help
90267 + Choose this option if this kernel is running as a KVM guest or host.
90268 +
90269 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
90270 + bool "VirtualBox"
90271 + help
90272 + Choose this option if this kernel is running as a VirtualBox guest or host.
90273 +
90274 +endchoice
90275 +
90276 +choice
90277 + prompt "Required Priorities"
90278 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
90279 + default GRKERNSEC_CONFIG_PRIORITY_PERF
90280 + help
90281 +
90282 +config GRKERNSEC_CONFIG_PRIORITY_PERF
90283 + bool "Performance"
90284 + help
90285 + Choose this option if performance is of highest priority for this deployment
90286 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
90287 + clearing of structures intended for userland, and freed memory sanitizing will
90288 + be disabled.
90289 +
90290 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
90291 + bool "Security"
90292 + help
90293 + Choose this option if security is of highest priority for this deployment of
90294 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
90295 + for userland, and freed memory sanitizing will be enabled for this kernel.
90296 + In a worst-case scenario, these features can introduce a 20% performance hit
90297 + (UDEREF on x64 contributing half of this hit).
90298 +
90299 +endchoice
90300 +
90301 +menu "Default Special Groups"
90302 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
90303 +
90304 +config GRKERNSEC_PROC_GID
90305 + int "GID exempted from /proc restrictions"
90306 + default 1001
90307 + help
90308 + Setting this GID determines which group will be exempted from
90309 + grsecurity's /proc restrictions, allowing users of the specified
90310 + group to view network statistics and the existence of other users'
90311 + processes on the system. This GID may also be chosen at boot time
90312 + via "grsec_proc_gid=" on the kernel commandline.
90313 +
90314 +config GRKERNSEC_TPE_UNTRUSTED_GID
90315 + int "GID for TPE-untrusted users"
90316 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
90317 + default 1005
90318 + help
90319 + Setting this GID determines which group untrusted users should
90320 + be added to. These users will be placed under grsecurity's Trusted Path
90321 + Execution mechanism, preventing them from executing their own binaries.
90322 + The users will only be able to execute binaries in directories owned and
90323 + writable only by the root user. If the sysctl option is enabled, a sysctl
90324 + option with name "tpe_gid" is created.
90325 +
90326 +config GRKERNSEC_TPE_TRUSTED_GID
90327 + int "GID for TPE-trusted users"
90328 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
90329 + default 1005
90330 + help
90331 + Setting this GID determines what group TPE restrictions will be
90332 + *disabled* for. If the sysctl option is enabled, a sysctl option
90333 + with name "tpe_gid" is created.
90334 +
90335 +config GRKERNSEC_SYMLINKOWN_GID
90336 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
90337 + depends on GRKERNSEC_CONFIG_SERVER
90338 + default 1006
90339 + help
90340 + Setting this GID determines what group kernel-enforced
90341 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
90342 + is enabled, a sysctl option with name "symlinkown_gid" is created.
90343 +
90344 +
90345 +endmenu
90346 +
90347 +menu "Customize Configuration"
90348 +depends on GRKERNSEC
90349 +
90350 +menu "PaX"
90351 +
90352 +config PAX
90353 + bool "Enable various PaX features"
90354 + default y if GRKERNSEC_CONFIG_AUTO
90355 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
90356 + help
90357 + This allows you to enable various PaX features. PaX adds
90358 + intrusion prevention mechanisms to the kernel that reduce
90359 + the risks posed by exploitable memory corruption bugs.
90360 +
90361 +menu "PaX Control"
90362 + depends on PAX
90363 +
90364 +config PAX_SOFTMODE
90365 + bool 'Support soft mode'
90366 + help
90367 + Enabling this option will allow you to run PaX in soft mode, that
90368 + is, PaX features will not be enforced by default, only on executables
90369 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
90370 + support as they are the only way to mark executables for soft mode use.
90371 +
90372 + Soft mode can be activated by using the "pax_softmode=1" kernel command
90373 + line option on boot. Furthermore you can control various PaX features
90374 + at runtime via the entries in /proc/sys/kernel/pax.
90375 +
90376 +config PAX_EI_PAX
90377 + bool 'Use legacy ELF header marking'
90378 + default y if GRKERNSEC_CONFIG_AUTO
90379 + help
90380 + Enabling this option will allow you to control PaX features on
90381 + a per executable basis via the 'chpax' utility available at
90382 + http://pax.grsecurity.net/. The control flags will be read from
90383 + an otherwise reserved part of the ELF header. This marking has
90384 + numerous drawbacks (no support for soft-mode, toolchain does not
90385 + know about the non-standard use of the ELF header) therefore it
90386 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
90387 + support.
90388 +
90389 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
90390 + support as well, they will override the legacy EI_PAX marks.
90391 +
90392 + If you enable none of the marking options then all applications
90393 + will run with PaX enabled on them by default.
90394 +
90395 +config PAX_PT_PAX_FLAGS
90396 + bool 'Use ELF program header marking'
90397 + default y if GRKERNSEC_CONFIG_AUTO
90398 + help
90399 + Enabling this option will allow you to control PaX features on
90400 + a per executable basis via the 'paxctl' utility available at
90401 + http://pax.grsecurity.net/. The control flags will be read from
90402 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
90403 + has the benefits of supporting both soft mode and being fully
90404 + integrated into the toolchain (the binutils patch is available
90405 + from http://pax.grsecurity.net).
90406 +
90407 + Note that if you enable the legacy EI_PAX marking support as well,
90408 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
90409 +
90410 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
90411 + must make sure that the marks are the same if a binary has both marks.
90412 +
90413 + If you enable none of the marking options then all applications
90414 + will run with PaX enabled on them by default.
90415 +
90416 +config PAX_XATTR_PAX_FLAGS
90417 + bool 'Use filesystem extended attributes marking'
90418 + default y if GRKERNSEC_CONFIG_AUTO
90419 + select CIFS_XATTR if CIFS
90420 + select EXT2_FS_XATTR if EXT2_FS
90421 + select EXT3_FS_XATTR if EXT3_FS
90422 + select EXT4_FS_XATTR if EXT4_FS
90423 + select JFFS2_FS_XATTR if JFFS2_FS
90424 + select REISERFS_FS_XATTR if REISERFS_FS
90425 + select SQUASHFS_XATTR if SQUASHFS
90426 + select TMPFS_XATTR if TMPFS
90427 + select UBIFS_FS_XATTR if UBIFS_FS
90428 + help
90429 + Enabling this option will allow you to control PaX features on
90430 + a per executable basis via the 'setfattr' utility. The control
90431 + flags will be read from the user.pax.flags extended attribute of
90432 + the file. This marking has the benefit of supporting binary-only
90433 + applications that self-check themselves (e.g., skype) and would
90434 + not tolerate chpax/paxctl changes. The main drawback is that
90435 + extended attributes are not supported by some filesystems (e.g.,
90436 + isofs, udf, vfat) so copying files through such filesystems will
90437 + lose the extended attributes and these PaX markings.
90438 +
90439 + Note that if you enable the legacy EI_PAX marking support as well,
90440 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
90441 +
90442 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
90443 + must make sure that the marks are the same if a binary has both marks.
90444 +
90445 + If you enable none of the marking options then all applications
90446 + will run with PaX enabled on them by default.
90447 +
90448 +choice
90449 + prompt 'MAC system integration'
90450 + default PAX_HAVE_ACL_FLAGS
90451 + help
90452 + Mandatory Access Control systems have the option of controlling
90453 + PaX flags on a per executable basis, choose the method supported
90454 + by your particular system.
90455 +
90456 + - "none": if your MAC system does not interact with PaX,
90457 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
90458 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
90459 +
90460 + NOTE: this option is for developers/integrators only.
90461 +
90462 + config PAX_NO_ACL_FLAGS
90463 + bool 'none'
90464 +
90465 + config PAX_HAVE_ACL_FLAGS
90466 + bool 'direct'
90467 +
90468 + config PAX_HOOK_ACL_FLAGS
90469 + bool 'hook'
90470 +endchoice
90471 +
90472 +endmenu
90473 +
90474 +menu "Non-executable pages"
90475 + depends on PAX
90476 +
90477 +config PAX_NOEXEC
90478 + bool "Enforce non-executable pages"
90479 + default y if GRKERNSEC_CONFIG_AUTO
90480 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
90481 + help
90482 + By design some architectures do not allow for protecting memory
90483 + pages against execution or even if they do, Linux does not make
90484 + use of this feature. In practice this means that if a page is
90485 + readable (such as the stack or heap) it is also executable.
90486 +
90487 + There is a well known exploit technique that makes use of this
90488 + fact and a common programming mistake where an attacker can
90489 + introduce code of his choice somewhere in the attacked program's
90490 + memory (typically the stack or the heap) and then execute it.
90491 +
90492 + If the attacked program was running with different (typically
90493 + higher) privileges than that of the attacker, then he can elevate
90494 + his own privilege level (e.g. get a root shell, write to files for
90495 + which he does not have write access to, etc).
90496 +
90497 + Enabling this option will let you choose from various features
90498 + that prevent the injection and execution of 'foreign' code in
90499 + a program.
90500 +
90501 + This will also break programs that rely on the old behaviour and
90502 + expect that dynamically allocated memory via the malloc() family
90503 + of functions is executable (which it is not). Notable examples
90504 + are the XFree86 4.x server, the java runtime and wine.
90505 +
90506 +config PAX_PAGEEXEC
90507 + bool "Paging based non-executable pages"
90508 + default y if GRKERNSEC_CONFIG_AUTO
90509 + 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)
90510 + select S390_SWITCH_AMODE if S390
90511 + select S390_EXEC_PROTECT if S390
90512 + select ARCH_TRACK_EXEC_LIMIT if X86_32
90513 + help
90514 + This implementation is based on the paging feature of the CPU.
90515 + On i386 without hardware non-executable bit support there is a
90516 + variable but usually low performance impact, however on Intel's
90517 + P4 core based CPUs it is very high so you should not enable this
90518 + for kernels meant to be used on such CPUs.
90519 +
90520 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
90521 + with hardware non-executable bit support there is no performance
90522 + impact, on ppc the impact is negligible.
90523 +
90524 + Note that several architectures require various emulations due to
90525 + badly designed userland ABIs, this will cause a performance impact
90526 + but will disappear as soon as userland is fixed. For example, ppc
90527 + userland MUST have been built with secure-plt by a recent toolchain.
90528 +
90529 +config PAX_SEGMEXEC
90530 + bool "Segmentation based non-executable pages"
90531 + default y if GRKERNSEC_CONFIG_AUTO
90532 + depends on PAX_NOEXEC && X86_32
90533 + help
90534 + This implementation is based on the segmentation feature of the
90535 + CPU and has a very small performance impact, however applications
90536 + will be limited to a 1.5 GB address space instead of the normal
90537 + 3 GB.
90538 +
90539 +config PAX_EMUTRAMP
90540 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
90541 + default y if PARISC
90542 + help
90543 + There are some programs and libraries that for one reason or
90544 + another attempt to execute special small code snippets from
90545 + non-executable memory pages. Most notable examples are the
90546 + signal handler return code generated by the kernel itself and
90547 + the GCC trampolines.
90548 +
90549 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
90550 + such programs will no longer work under your kernel.
90551 +
90552 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
90553 + utilities to enable trampoline emulation for the affected programs
90554 + yet still have the protection provided by the non-executable pages.
90555 +
90556 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
90557 + your system will not even boot.
90558 +
90559 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
90560 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
90561 + for the affected files.
90562 +
90563 + NOTE: enabling this feature *may* open up a loophole in the
90564 + protection provided by non-executable pages that an attacker
90565 + could abuse. Therefore the best solution is to not have any
90566 + files on your system that would require this option. This can
90567 + be achieved by not using libc5 (which relies on the kernel
90568 + signal handler return code) and not using or rewriting programs
90569 + that make use of the nested function implementation of GCC.
90570 + Skilled users can just fix GCC itself so that it implements
90571 + nested function calls in a way that does not interfere with PaX.
90572 +
90573 +config PAX_EMUSIGRT
90574 + bool "Automatically emulate sigreturn trampolines"
90575 + depends on PAX_EMUTRAMP && PARISC
90576 + default y
90577 + help
90578 + Enabling this option will have the kernel automatically detect
90579 + and emulate signal return trampolines executing on the stack
90580 + that would otherwise lead to task termination.
90581 +
90582 + This solution is intended as a temporary one for users with
90583 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
90584 + Modula-3 runtime, etc) or executables linked to such, basically
90585 + everything that does not specify its own SA_RESTORER function in
90586 + normal executable memory like glibc 2.1+ does.
90587 +
90588 + On parisc you MUST enable this option, otherwise your system will
90589 + not even boot.
90590 +
90591 + NOTE: this feature cannot be disabled on a per executable basis
90592 + and since it *does* open up a loophole in the protection provided
90593 + by non-executable pages, the best solution is to not have any
90594 + files on your system that would require this option.
90595 +
90596 +config PAX_MPROTECT
90597 + bool "Restrict mprotect()"
90598 + default y if GRKERNSEC_CONFIG_AUTO
90599 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
90600 + help
90601 + Enabling this option will prevent programs from
90602 + - changing the executable status of memory pages that were
90603 + not originally created as executable,
90604 + - making read-only executable pages writable again,
90605 + - creating executable pages from anonymous memory,
90606 + - making read-only-after-relocations (RELRO) data pages writable again.
90607 +
90608 + You should say Y here to complete the protection provided by
90609 + the enforcement of non-executable pages.
90610 +
90611 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
90612 + this feature on a per file basis.
90613 +
90614 +config PAX_MPROTECT_COMPAT
90615 + bool "Use legacy/compat protection demoting (read help)"
90616 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
90617 + depends on PAX_MPROTECT
90618 + help
90619 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
90620 + by sending the proper error code to the application. For some broken
90621 + userland, this can cause problems with Python or other applications. The
90622 + current implementation however allows for applications like clamav to
90623 + detect if JIT compilation/execution is allowed and to fall back gracefully
90624 + to an interpreter-based mode if it does not. While we encourage everyone
90625 + to use the current implementation as-is and push upstream to fix broken
90626 + userland (note that the RWX logging option can assist with this), in some
90627 + environments this may not be possible. Having to disable MPROTECT
90628 + completely on certain binaries reduces the security benefit of PaX,
90629 + so this option is provided for those environments to revert to the old
90630 + behavior.
90631 +
90632 +config PAX_ELFRELOCS
90633 + bool "Allow ELF text relocations (read help)"
90634 + depends on PAX_MPROTECT
90635 + default n
90636 + help
90637 + Non-executable pages and mprotect() restrictions are effective
90638 + in preventing the introduction of new executable code into an
90639 + attacked task's address space. There remain only two venues
90640 + for this kind of attack: if the attacker can execute already
90641 + existing code in the attacked task then he can either have it
90642 + create and mmap() a file containing his code or have it mmap()
90643 + an already existing ELF library that does not have position
90644 + independent code in it and use mprotect() on it to make it
90645 + writable and copy his code there. While protecting against
90646 + the former approach is beyond PaX, the latter can be prevented
90647 + by having only PIC ELF libraries on one's system (which do not
90648 + need to relocate their code). If you are sure this is your case,
90649 + as is the case with all modern Linux distributions, then leave
90650 + this option disabled. You should say 'n' here.
90651 +
90652 +config PAX_ETEXECRELOCS
90653 + bool "Allow ELF ET_EXEC text relocations"
90654 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
90655 + select PAX_ELFRELOCS
90656 + default y
90657 + help
90658 + On some architectures there are incorrectly created applications
90659 + that require text relocations and would not work without enabling
90660 + this option. If you are an alpha, ia64 or parisc user, you should
90661 + enable this option and disable it once you have made sure that
90662 + none of your applications need it.
90663 +
90664 +config PAX_EMUPLT
90665 + bool "Automatically emulate ELF PLT"
90666 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
90667 + default y
90668 + help
90669 + Enabling this option will have the kernel automatically detect
90670 + and emulate the Procedure Linkage Table entries in ELF files.
90671 + On some architectures such entries are in writable memory, and
90672 + become non-executable leading to task termination. Therefore
90673 + it is mandatory that you enable this option on alpha, parisc,
90674 + sparc and sparc64, otherwise your system would not even boot.
90675 +
90676 + NOTE: this feature *does* open up a loophole in the protection
90677 + provided by the non-executable pages, therefore the proper
90678 + solution is to modify the toolchain to produce a PLT that does
90679 + not need to be writable.
90680 +
90681 +config PAX_DLRESOLVE
90682 + bool 'Emulate old glibc resolver stub'
90683 + depends on PAX_EMUPLT && SPARC
90684 + default n
90685 + help
90686 + This option is needed if userland has an old glibc (before 2.4)
90687 + that puts a 'save' instruction into the runtime generated resolver
90688 + stub that needs special emulation.
90689 +
90690 +config PAX_KERNEXEC
90691 + bool "Enforce non-executable kernel pages"
90692 + 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))
90693 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
90694 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
90695 + select PAX_KERNEXEC_PLUGIN if X86_64
90696 + help
90697 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
90698 + that is, enabling this option will make it harder to inject
90699 + and execute 'foreign' code in kernel memory itself.
90700 +
90701 +choice
90702 + prompt "Return Address Instrumentation Method"
90703 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
90704 + depends on PAX_KERNEXEC_PLUGIN
90705 + help
90706 + Select the method used to instrument function pointer dereferences.
90707 + Note that binary modules cannot be instrumented by this approach.
90708 +
90709 + Note that the implementation requires a gcc with plugin support,
90710 + i.e., gcc 4.5 or newer. You may need to install the supporting
90711 + headers explicitly in addition to the normal gcc package.
90712 +
90713 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
90714 + bool "bts"
90715 + help
90716 + This method is compatible with binary only modules but has
90717 + a higher runtime overhead.
90718 +
90719 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
90720 + bool "or"
90721 + depends on !PARAVIRT
90722 + help
90723 + This method is incompatible with binary only modules but has
90724 + a lower runtime overhead.
90725 +endchoice
90726 +
90727 +config PAX_KERNEXEC_PLUGIN_METHOD
90728 + string
90729 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
90730 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
90731 + default ""
90732 +
90733 +config PAX_KERNEXEC_MODULE_TEXT
90734 + int "Minimum amount of memory reserved for module code"
90735 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
90736 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
90737 + depends on PAX_KERNEXEC && X86_32 && MODULES
90738 + help
90739 + Due to implementation details the kernel must reserve a fixed
90740 + amount of memory for module code at compile time that cannot be
90741 + changed at runtime. Here you can specify the minimum amount
90742 + in MB that will be reserved. Due to the same implementation
90743 + details this size will always be rounded up to the next 2/4 MB
90744 + boundary (depends on PAE) so the actually available memory for
90745 + module code will usually be more than this minimum.
90746 +
90747 + The default 4 MB should be enough for most users but if you have
90748 + an excessive number of modules (e.g., most distribution configs
90749 + compile many drivers as modules) or use huge modules such as
90750 + nvidia's kernel driver, you will need to adjust this amount.
90751 + A good rule of thumb is to look at your currently loaded kernel
90752 + modules and add up their sizes.
90753 +
90754 +endmenu
90755 +
90756 +menu "Address Space Layout Randomization"
90757 + depends on PAX
90758 +
90759 +config PAX_ASLR
90760 + bool "Address Space Layout Randomization"
90761 + default y if GRKERNSEC_CONFIG_AUTO
90762 + help
90763 + Many if not most exploit techniques rely on the knowledge of
90764 + certain addresses in the attacked program. The following options
90765 + will allow the kernel to apply a certain amount of randomization
90766 + to specific parts of the program thereby forcing an attacker to
90767 + guess them in most cases. Any failed guess will most likely crash
90768 + the attacked program which allows the kernel to detect such attempts
90769 + and react on them. PaX itself provides no reaction mechanisms,
90770 + instead it is strongly encouraged that you make use of Nergal's
90771 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
90772 + (http://www.grsecurity.net/) built-in crash detection features or
90773 + develop one yourself.
90774 +
90775 + By saying Y here you can choose to randomize the following areas:
90776 + - top of the task's kernel stack
90777 + - top of the task's userland stack
90778 + - base address for mmap() requests that do not specify one
90779 + (this includes all libraries)
90780 + - base address of the main executable
90781 +
90782 + It is strongly recommended to say Y here as address space layout
90783 + randomization has negligible impact on performance yet it provides
90784 + a very effective protection.
90785 +
90786 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
90787 + this feature on a per file basis.
90788 +
90789 +config PAX_RANDKSTACK
90790 + bool "Randomize kernel stack base"
90791 + default y if GRKERNSEC_CONFIG_AUTO
90792 + depends on X86_TSC && X86
90793 + help
90794 + By saying Y here the kernel will randomize every task's kernel
90795 + stack on every system call. This will not only force an attacker
90796 + to guess it but also prevent him from making use of possible
90797 + leaked information about it.
90798 +
90799 + Since the kernel stack is a rather scarce resource, randomization
90800 + may cause unexpected stack overflows, therefore you should very
90801 + carefully test your system. Note that once enabled in the kernel
90802 + configuration, this feature cannot be disabled on a per file basis.
90803 +
90804 +config PAX_RANDUSTACK
90805 + bool "Randomize user stack base"
90806 + default y if GRKERNSEC_CONFIG_AUTO
90807 + depends on PAX_ASLR
90808 + help
90809 + By saying Y here the kernel will randomize every task's userland
90810 + stack. The randomization is done in two steps where the second
90811 + one may apply a big amount of shift to the top of the stack and
90812 + cause problems for programs that want to use lots of memory (more
90813 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
90814 + For this reason the second step can be controlled by 'chpax' or
90815 + 'paxctl' on a per file basis.
90816 +
90817 +config PAX_RANDMMAP
90818 + bool "Randomize mmap() base"
90819 + default y if GRKERNSEC_CONFIG_AUTO
90820 + depends on PAX_ASLR
90821 + help
90822 + By saying Y here the kernel will use a randomized base address for
90823 + mmap() requests that do not specify one themselves. As a result
90824 + all dynamically loaded libraries will appear at random addresses
90825 + and therefore be harder to exploit by a technique where an attacker
90826 + attempts to execute library code for his purposes (e.g. spawn a
90827 + shell from an exploited program that is running at an elevated
90828 + privilege level).
90829 +
90830 + Furthermore, if a program is relinked as a dynamic ELF file, its
90831 + base address will be randomized as well, completing the full
90832 + randomization of the address space layout. Attacking such programs
90833 + becomes a guess game. You can find an example of doing this at
90834 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
90835 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
90836 +
90837 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
90838 + feature on a per file basis.
90839 +
90840 +endmenu
90841 +
90842 +menu "Miscellaneous hardening features"
90843 +
90844 +config PAX_MEMORY_SANITIZE
90845 + bool "Sanitize all freed memory"
90846 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
90847 + depends on !HIBERNATION
90848 + help
90849 + By saying Y here the kernel will erase memory pages as soon as they
90850 + are freed. This in turn reduces the lifetime of data stored in the
90851 + pages, making it less likely that sensitive information such as
90852 + passwords, cryptographic secrets, etc stay in memory for too long.
90853 +
90854 + This is especially useful for programs whose runtime is short, long
90855 + lived processes and the kernel itself benefit from this as long as
90856 + they operate on whole memory pages and ensure timely freeing of pages
90857 + that may hold sensitive information.
90858 +
90859 + The tradeoff is performance impact, on a single CPU system kernel
90860 + compilation sees a 3% slowdown, other systems and workloads may vary
90861 + and you are advised to test this feature on your expected workload
90862 + before deploying it.
90863 +
90864 + Note that this feature does not protect data stored in live pages,
90865 + e.g., process memory swapped to disk may stay there for a long time.
90866 +
90867 +config PAX_MEMORY_STACKLEAK
90868 + bool "Sanitize kernel stack"
90869 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
90870 + depends on X86
90871 + help
90872 + By saying Y here the kernel will erase the kernel stack before it
90873 + returns from a system call. This in turn reduces the information
90874 + that a kernel stack leak bug can reveal.
90875 +
90876 + Note that such a bug can still leak information that was put on
90877 + the stack by the current system call (the one eventually triggering
90878 + the bug) but traces of earlier system calls on the kernel stack
90879 + cannot leak anymore.
90880 +
90881 + The tradeoff is performance impact: on a single CPU system kernel
90882 + compilation sees a 1% slowdown, other systems and workloads may vary
90883 + and you are advised to test this feature on your expected workload
90884 + before deploying it.
90885 +
90886 + Note that the full feature requires a gcc with plugin support,
90887 + i.e., gcc 4.5 or newer. You may need to install the supporting
90888 + headers explicitly in addition to the normal gcc package. Using
90889 + older gcc versions means that functions with large enough stack
90890 + frames may leave uninitialized memory behind that may be exposed
90891 + to a later syscall leaking the stack.
90892 +
90893 +config PAX_MEMORY_STRUCTLEAK
90894 + bool "Forcibly initialize local variables copied to userland"
90895 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
90896 + help
90897 + By saying Y here the kernel will zero initialize some local
90898 + variables that are going to be copied to userland. This in
90899 + turn prevents unintended information leakage from the kernel
90900 + stack should later code forget to explicitly set all parts of
90901 + the copied variable.
90902 +
90903 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
90904 + at a much smaller coverage.
90905 +
90906 + Note that the implementation requires a gcc with plugin support,
90907 + i.e., gcc 4.5 or newer. You may need to install the supporting
90908 + headers explicitly in addition to the normal gcc package.
90909 +
90910 +config PAX_MEMORY_UDEREF
90911 + bool "Prevent invalid userland pointer dereference"
90912 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
90913 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
90914 + select PAX_PER_CPU_PGD if X86_64
90915 + help
90916 + By saying Y here the kernel will be prevented from dereferencing
90917 + userland pointers in contexts where the kernel expects only kernel
90918 + pointers. This is both a useful runtime debugging feature and a
90919 + security measure that prevents exploiting a class of kernel bugs.
90920 +
90921 + The tradeoff is that some virtualization solutions may experience
90922 + a huge slowdown and therefore you should not enable this feature
90923 + for kernels meant to run in such environments. Whether a given VM
90924 + solution is affected or not is best determined by simply trying it
90925 + out, the performance impact will be obvious right on boot as this
90926 + mechanism engages from very early on. A good rule of thumb is that
90927 + VMs running on CPUs without hardware virtualization support (i.e.,
90928 + the majority of IA-32 CPUs) will likely experience the slowdown.
90929 +
90930 +config PAX_REFCOUNT
90931 + bool "Prevent various kernel object reference counter overflows"
90932 + default y if GRKERNSEC_CONFIG_AUTO
90933 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
90934 + help
90935 + By saying Y here the kernel will detect and prevent overflowing
90936 + various (but not all) kinds of object reference counters. Such
90937 + overflows can normally occur due to bugs only and are often, if
90938 + not always, exploitable.
90939 +
90940 + The tradeoff is that data structures protected by an overflowed
90941 + refcount will never be freed and therefore will leak memory. Note
90942 + that this leak also happens even without this protection but in
90943 + that case the overflow can eventually trigger the freeing of the
90944 + data structure while it is still being used elsewhere, resulting
90945 + in the exploitable situation that this feature prevents.
90946 +
90947 + Since this has a negligible performance impact, you should enable
90948 + this feature.
90949 +
90950 +config PAX_CONSTIFY_PLUGIN
90951 + bool "Automatically constify eligible structures"
90952 + default y
90953 + depends on !UML && PAX_KERNEXEC
90954 + help
90955 + By saying Y here the compiler will automatically constify a class
90956 + of types that contain only function pointers. This reduces the
90957 + kernel's attack surface and also produces a better memory layout.
90958 +
90959 + Note that the implementation requires a gcc with plugin support,
90960 + i.e., gcc 4.5 or newer. You may need to install the supporting
90961 + headers explicitly in addition to the normal gcc package.
90962 +
90963 + Note that if some code really has to modify constified variables
90964 + then the source code will have to be patched to allow it. Examples
90965 + can be found in PaX itself (the no_const attribute) and for some
90966 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
90967 +
90968 +config PAX_USERCOPY
90969 + bool "Harden heap object copies between kernel and userland"
90970 + default y if GRKERNSEC_CONFIG_AUTO
90971 + depends on ARM || IA64 || PPC || SPARC || X86
90972 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
90973 + select PAX_USERCOPY_SLABS
90974 + help
90975 + By saying Y here the kernel will enforce the size of heap objects
90976 + when they are copied in either direction between the kernel and
90977 + userland, even if only a part of the heap object is copied.
90978 +
90979 + Specifically, this checking prevents information leaking from the
90980 + kernel heap during kernel to userland copies (if the kernel heap
90981 + object is otherwise fully initialized) and prevents kernel heap
90982 + overflows during userland to kernel copies.
90983 +
90984 + Note that the current implementation provides the strictest bounds
90985 + checks for the SLUB allocator.
90986 +
90987 + Enabling this option also enables per-slab cache protection against
90988 + data in a given cache being copied into/out of via userland
90989 + accessors. Though the whitelist of regions will be reduced over
90990 + time, it notably protects important data structures like task structs.
90991 +
90992 + If frame pointers are enabled on x86, this option will also restrict
90993 + copies into and out of the kernel stack to local variables within a
90994 + single frame.
90995 +
90996 + Since this has a negligible performance impact, you should enable
90997 + this feature.
90998 +
90999 +config PAX_USERCOPY_DEBUG
91000 + bool
91001 + depends on X86 && PAX_USERCOPY
91002 + default n
91003 +
91004 +config PAX_SIZE_OVERFLOW
91005 + bool "Prevent various integer overflows in function size parameters"
91006 + default y if GRKERNSEC_CONFIG_AUTO
91007 + depends on X86
91008 + help
91009 + By saying Y here the kernel recomputes expressions of function
91010 + arguments marked by a size_overflow attribute with double integer
91011 + precision (DImode/TImode for 32/64 bit integer types).
91012 +
91013 + The recomputed argument is checked against TYPE_MAX and an event
91014 + is logged on overflow and the triggering process is killed.
91015 +
91016 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
91017 +
91018 + Note that the implementation requires a gcc with plugin support,
91019 + i.e., gcc 4.5 or newer. You may need to install the supporting
91020 + headers explicitly in addition to the normal gcc package.
91021 +
91022 +config PAX_LATENT_ENTROPY
91023 + bool "Generate some entropy during boot"
91024 + default y if GRKERNSEC_CONFIG_AUTO
91025 + help
91026 + By saying Y here the kernel will instrument early boot code to
91027 + extract some entropy from both original and artificially created
91028 + program state. This will help especially embedded systems where
91029 + there is little 'natural' source of entropy normally. The cost
91030 + is some slowdown of the boot process.
91031 +
91032 + When pax_extra_latent_entropy is passed on the kernel command line,
91033 + entropy will be extracted from up to the first 4GB of RAM while the
91034 + runtime memory allocator is being initialized. This costs even more
91035 + slowdown of the boot process.
91036 +
91037 + Note that the implementation requires a gcc with plugin support,
91038 + i.e., gcc 4.5 or newer. You may need to install the supporting
91039 + headers explicitly in addition to the normal gcc package.
91040 +
91041 + Note that entropy extracted this way is not cryptographically
91042 + secure!
91043 +
91044 +endmenu
91045 +
91046 +endmenu
91047 +
91048 +source grsecurity/Kconfig
91049 +
91050 +endmenu
91051 +
91052 +endmenu
91053 +
91054 source security/keys/Kconfig
91055
91056 config SECURITY_DMESG_RESTRICT
91057 @@ -103,7 +1040,7 @@ config INTEL_TXT
91058 config LSM_MMAP_MIN_ADDR
91059 int "Low address space for LSM to protect from user allocation"
91060 depends on SECURITY && SECURITY_SELINUX
91061 - default 32768 if ARM
91062 + default 32768 if ALPHA || ARM || PARISC || SPARC32
91063 default 65536
91064 help
91065 This is the portion of low virtual memory which should be protected
91066 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
91067 index b21830e..a7d1a17 100644
91068 --- a/security/apparmor/lsm.c
91069 +++ b/security/apparmor/lsm.c
91070 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
91071 return error;
91072 }
91073
91074 -static struct security_operations apparmor_ops = {
91075 +static struct security_operations apparmor_ops __read_only = {
91076 .name = "apparmor",
91077
91078 .ptrace_access_check = apparmor_ptrace_access_check,
91079 diff --git a/security/commoncap.c b/security/commoncap.c
91080 index c44b6fe..932df30 100644
91081 --- a/security/commoncap.c
91082 +++ b/security/commoncap.c
91083 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
91084 return 0;
91085 }
91086
91087 +/* returns:
91088 + 1 for suid privilege
91089 + 2 for sgid privilege
91090 + 3 for fscap privilege
91091 +*/
91092 +int is_privileged_binary(const struct dentry *dentry)
91093 +{
91094 + struct cpu_vfs_cap_data capdata;
91095 + struct inode *inode = dentry->d_inode;
91096 +
91097 + if (!inode || S_ISDIR(inode->i_mode))
91098 + return 0;
91099 +
91100 + if (inode->i_mode & S_ISUID)
91101 + return 1;
91102 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
91103 + return 2;
91104 +
91105 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
91106 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
91107 + return 3;
91108 + }
91109 +
91110 + return 0;
91111 +}
91112 +
91113 /*
91114 * Attempt to get the on-exec apply capability sets for an executable file from
91115 * its xattrs and, if present, apply them to the proposed credentials being
91116 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
91117 const struct cred *cred = current_cred();
91118 kuid_t root_uid = make_kuid(cred->user_ns, 0);
91119
91120 + if (gr_acl_enable_at_secure())
91121 + return 1;
91122 +
91123 if (!uid_eq(cred->uid, root_uid)) {
91124 if (bprm->cap_effective)
91125 return 1;
91126 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
91127 index a41c9c1..83da6dd 100644
91128 --- a/security/integrity/ima/ima.h
91129 +++ b/security/integrity/ima/ima.h
91130 @@ -97,8 +97,8 @@ int ima_init_crypto(void);
91131 extern spinlock_t ima_queue_lock;
91132
91133 struct ima_h_table {
91134 - atomic_long_t len; /* number of stored measurements in the list */
91135 - atomic_long_t violations;
91136 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
91137 + atomic_long_unchecked_t violations;
91138 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
91139 };
91140 extern struct ima_h_table ima_htable;
91141 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
91142 index 1c03e8f1..398a941 100644
91143 --- a/security/integrity/ima/ima_api.c
91144 +++ b/security/integrity/ima/ima_api.c
91145 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
91146 int result;
91147
91148 /* can overflow, only indicator */
91149 - atomic_long_inc(&ima_htable.violations);
91150 + atomic_long_inc_unchecked(&ima_htable.violations);
91151
91152 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
91153 if (!entry) {
91154 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
91155 index 38477c9..87a60c7 100644
91156 --- a/security/integrity/ima/ima_fs.c
91157 +++ b/security/integrity/ima/ima_fs.c
91158 @@ -28,12 +28,12 @@
91159 static int valid_policy = 1;
91160 #define TMPBUFLEN 12
91161 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
91162 - loff_t *ppos, atomic_long_t *val)
91163 + loff_t *ppos, atomic_long_unchecked_t *val)
91164 {
91165 char tmpbuf[TMPBUFLEN];
91166 ssize_t len;
91167
91168 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
91169 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
91170 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
91171 }
91172
91173 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
91174 index ff63fe0..809cd96 100644
91175 --- a/security/integrity/ima/ima_queue.c
91176 +++ b/security/integrity/ima/ima_queue.c
91177 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
91178 INIT_LIST_HEAD(&qe->later);
91179 list_add_tail_rcu(&qe->later, &ima_measurements);
91180
91181 - atomic_long_inc(&ima_htable.len);
91182 + atomic_long_inc_unchecked(&ima_htable.len);
91183 key = ima_hash_key(entry->digest);
91184 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
91185 return 0;
91186 diff --git a/security/keys/compat.c b/security/keys/compat.c
91187 index d65fa7f..cbfe366 100644
91188 --- a/security/keys/compat.c
91189 +++ b/security/keys/compat.c
91190 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
91191 if (ret == 0)
91192 goto no_payload_free;
91193
91194 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
91195 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
91196 err:
91197 if (iov != iovstack)
91198 kfree(iov);
91199 diff --git a/security/keys/key.c b/security/keys/key.c
91200 index 8fb7c7b..ba3610d 100644
91201 --- a/security/keys/key.c
91202 +++ b/security/keys/key.c
91203 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
91204
91205 atomic_set(&key->usage, 1);
91206 init_rwsem(&key->sem);
91207 - lockdep_set_class(&key->sem, &type->lock_class);
91208 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
91209 key->type = type;
91210 key->user = user;
91211 key->quotalen = quotalen;
91212 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
91213 struct key_type *p;
91214 int ret;
91215
91216 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
91217 + pax_open_kernel();
91218 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
91219 + pax_close_kernel();
91220
91221 ret = -EEXIST;
91222 down_write(&key_types_sem);
91223 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
91224 }
91225
91226 /* store the type */
91227 - list_add(&ktype->link, &key_types_list);
91228 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
91229
91230 pr_notice("Key type %s registered\n", ktype->name);
91231 ret = 0;
91232 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
91233 void unregister_key_type(struct key_type *ktype)
91234 {
91235 down_write(&key_types_sem);
91236 - list_del_init(&ktype->link);
91237 + pax_list_del_init((struct list_head *)&ktype->link);
91238 downgrade_write(&key_types_sem);
91239 key_gc_keytype(ktype);
91240 pr_notice("Key type %s unregistered\n", ktype->name);
91241 @@ -1084,10 +1086,10 @@ void __init key_init(void)
91242 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
91243
91244 /* add the special key types */
91245 - list_add_tail(&key_type_keyring.link, &key_types_list);
91246 - list_add_tail(&key_type_dead.link, &key_types_list);
91247 - list_add_tail(&key_type_user.link, &key_types_list);
91248 - list_add_tail(&key_type_logon.link, &key_types_list);
91249 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
91250 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
91251 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
91252 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
91253
91254 /* record the root user tracking */
91255 rb_link_node(&root_key_user.node,
91256 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
91257 index 4b5c948..2054dc1 100644
91258 --- a/security/keys/keyctl.c
91259 +++ b/security/keys/keyctl.c
91260 @@ -986,7 +986,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
91261 /*
91262 * Copy the iovec data from userspace
91263 */
91264 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
91265 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
91266 unsigned ioc)
91267 {
91268 for (; ioc > 0; ioc--) {
91269 @@ -1008,7 +1008,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
91270 * If successful, 0 will be returned.
91271 */
91272 long keyctl_instantiate_key_common(key_serial_t id,
91273 - const struct iovec *payload_iov,
91274 + const struct iovec __user *payload_iov,
91275 unsigned ioc,
91276 size_t plen,
91277 key_serial_t ringid)
91278 @@ -1103,7 +1103,7 @@ long keyctl_instantiate_key(key_serial_t id,
91279 [0].iov_len = plen
91280 };
91281
91282 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
91283 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
91284 }
91285
91286 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
91287 @@ -1136,7 +1136,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
91288 if (ret == 0)
91289 goto no_payload_free;
91290
91291 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
91292 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
91293 err:
91294 if (iov != iovstack)
91295 kfree(iov);
91296 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
91297 index 6ece7f2..ecdb55c 100644
91298 --- a/security/keys/keyring.c
91299 +++ b/security/keys/keyring.c
91300 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
91301 ret = -EFAULT;
91302
91303 for (loop = 0; loop < klist->nkeys; loop++) {
91304 + key_serial_t serial;
91305 key = rcu_deref_link_locked(klist, loop,
91306 keyring);
91307 + serial = key->serial;
91308
91309 tmp = sizeof(key_serial_t);
91310 if (tmp > buflen)
91311 tmp = buflen;
91312
91313 - if (copy_to_user(buffer,
91314 - &key->serial,
91315 - tmp) != 0)
91316 + if (copy_to_user(buffer, &serial, tmp))
91317 goto error;
91318
91319 buflen -= tmp;
91320 diff --git a/security/min_addr.c b/security/min_addr.c
91321 index f728728..6457a0c 100644
91322 --- a/security/min_addr.c
91323 +++ b/security/min_addr.c
91324 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
91325 */
91326 static void update_mmap_min_addr(void)
91327 {
91328 +#ifndef SPARC
91329 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
91330 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
91331 mmap_min_addr = dac_mmap_min_addr;
91332 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
91333 #else
91334 mmap_min_addr = dac_mmap_min_addr;
91335 #endif
91336 +#endif
91337 }
91338
91339 /*
91340 diff --git a/security/security.c b/security/security.c
91341 index 03f248b..5710c33 100644
91342 --- a/security/security.c
91343 +++ b/security/security.c
91344 @@ -20,6 +20,7 @@
91345 #include <linux/ima.h>
91346 #include <linux/evm.h>
91347 #include <linux/fsnotify.h>
91348 +#include <linux/mm.h>
91349 #include <linux/mman.h>
91350 #include <linux/mount.h>
91351 #include <linux/personality.h>
91352 @@ -32,8 +33,8 @@
91353 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
91354 CONFIG_DEFAULT_SECURITY;
91355
91356 -static struct security_operations *security_ops;
91357 -static struct security_operations default_security_ops = {
91358 +static struct security_operations *security_ops __read_only;
91359 +static struct security_operations default_security_ops __read_only = {
91360 .name = "default",
91361 };
91362
91363 @@ -74,7 +75,9 @@ int __init security_init(void)
91364
91365 void reset_security_ops(void)
91366 {
91367 + pax_open_kernel();
91368 security_ops = &default_security_ops;
91369 + pax_close_kernel();
91370 }
91371
91372 /* Save user chosen LSM */
91373 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
91374 index 7171a95..c35e879 100644
91375 --- a/security/selinux/hooks.c
91376 +++ b/security/selinux/hooks.c
91377 @@ -96,8 +96,6 @@
91378
91379 #define NUM_SEL_MNT_OPTS 5
91380
91381 -extern struct security_operations *security_ops;
91382 -
91383 /* SECMARK reference count */
91384 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
91385
91386 @@ -5498,7 +5496,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
91387
91388 #endif
91389
91390 -static struct security_operations selinux_ops = {
91391 +static struct security_operations selinux_ops __read_only = {
91392 .name = "selinux",
91393
91394 .ptrace_access_check = selinux_ptrace_access_check,
91395 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
91396 index 65f67cb..3f141ef 100644
91397 --- a/security/selinux/include/xfrm.h
91398 +++ b/security/selinux/include/xfrm.h
91399 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
91400
91401 static inline void selinux_xfrm_notify_policyload(void)
91402 {
91403 - atomic_inc(&flow_cache_genid);
91404 + atomic_inc_unchecked(&flow_cache_genid);
91405 rt_genid_bump(&init_net);
91406 }
91407 #else
91408 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
91409 index fa64740..bc95b74 100644
91410 --- a/security/smack/smack_lsm.c
91411 +++ b/security/smack/smack_lsm.c
91412 @@ -3392,7 +3392,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
91413 return 0;
91414 }
91415
91416 -struct security_operations smack_ops = {
91417 +struct security_operations smack_ops __read_only = {
91418 .name = "smack",
91419
91420 .ptrace_access_check = smack_ptrace_access_check,
91421 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
91422 index 390c646..f2f8db3 100644
91423 --- a/security/tomoyo/mount.c
91424 +++ b/security/tomoyo/mount.c
91425 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
91426 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
91427 need_dev = -1; /* dev_name is a directory */
91428 } else {
91429 + if (!capable(CAP_SYS_ADMIN)) {
91430 + error = -EPERM;
91431 + goto out;
91432 + }
91433 fstype = get_fs_type(type);
91434 if (!fstype) {
91435 error = -ENODEV;
91436 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
91437 index a2ee362..5754f34 100644
91438 --- a/security/tomoyo/tomoyo.c
91439 +++ b/security/tomoyo/tomoyo.c
91440 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
91441 * tomoyo_security_ops is a "struct security_operations" which is used for
91442 * registering TOMOYO.
91443 */
91444 -static struct security_operations tomoyo_security_ops = {
91445 +static struct security_operations tomoyo_security_ops __read_only = {
91446 .name = "tomoyo",
91447 .cred_alloc_blank = tomoyo_cred_alloc_blank,
91448 .cred_prepare = tomoyo_cred_prepare,
91449 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
91450 index 20ef514..4182bed 100644
91451 --- a/security/yama/Kconfig
91452 +++ b/security/yama/Kconfig
91453 @@ -1,6 +1,6 @@
91454 config SECURITY_YAMA
91455 bool "Yama support"
91456 - depends on SECURITY
91457 + depends on SECURITY && !GRKERNSEC
91458 select SECURITYFS
91459 select SECURITY_PATH
91460 default n
91461 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
91462 index 13c88fbc..f8c115e 100644
91463 --- a/security/yama/yama_lsm.c
91464 +++ b/security/yama/yama_lsm.c
91465 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
91466 }
91467
91468 #ifndef CONFIG_SECURITY_YAMA_STACKED
91469 -static struct security_operations yama_ops = {
91470 +static struct security_operations yama_ops __read_only = {
91471 .name = "yama",
91472
91473 .ptrace_access_check = yama_ptrace_access_check,
91474 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
91475 #endif
91476
91477 #ifdef CONFIG_SYSCTL
91478 +static int zero __read_only;
91479 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
91480 +
91481 static int yama_dointvec_minmax(struct ctl_table *table, int write,
91482 void __user *buffer, size_t *lenp, loff_t *ppos)
91483 {
91484 - int rc;
91485 + ctl_table_no_const yama_table;
91486
91487 if (write && !capable(CAP_SYS_PTRACE))
91488 return -EPERM;
91489
91490 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
91491 - if (rc)
91492 - return rc;
91493 -
91494 + yama_table = *table;
91495 /* Lock the max value if it ever gets set. */
91496 - if (write && *(int *)table->data == *(int *)table->extra2)
91497 - table->extra1 = table->extra2;
91498 -
91499 - return rc;
91500 + if (ptrace_scope == max_scope)
91501 + yama_table.extra1 = &max_scope;
91502 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
91503 }
91504
91505 -static int zero;
91506 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
91507 -
91508 struct ctl_path yama_sysctl_path[] = {
91509 { .procname = "kernel", },
91510 { .procname = "yama", },
91511 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
91512 index 4cedc69..e59d8a3 100644
91513 --- a/sound/aoa/codecs/onyx.c
91514 +++ b/sound/aoa/codecs/onyx.c
91515 @@ -54,7 +54,7 @@ struct onyx {
91516 spdif_locked:1,
91517 analog_locked:1,
91518 original_mute:2;
91519 - int open_count;
91520 + local_t open_count;
91521 struct codec_info *codec_info;
91522
91523 /* mutex serializes concurrent access to the device
91524 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
91525 struct onyx *onyx = cii->codec_data;
91526
91527 mutex_lock(&onyx->mutex);
91528 - onyx->open_count++;
91529 + local_inc(&onyx->open_count);
91530 mutex_unlock(&onyx->mutex);
91531
91532 return 0;
91533 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
91534 struct onyx *onyx = cii->codec_data;
91535
91536 mutex_lock(&onyx->mutex);
91537 - onyx->open_count--;
91538 - if (!onyx->open_count)
91539 + if (local_dec_and_test(&onyx->open_count))
91540 onyx->spdif_locked = onyx->analog_locked = 0;
91541 mutex_unlock(&onyx->mutex);
91542
91543 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
91544 index ffd2025..df062c9 100644
91545 --- a/sound/aoa/codecs/onyx.h
91546 +++ b/sound/aoa/codecs/onyx.h
91547 @@ -11,6 +11,7 @@
91548 #include <linux/i2c.h>
91549 #include <asm/pmac_low_i2c.h>
91550 #include <asm/prom.h>
91551 +#include <asm/local.h>
91552
91553 /* PCM3052 register definitions */
91554
91555 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
91556 index 4c1cc51..16040040 100644
91557 --- a/sound/core/oss/pcm_oss.c
91558 +++ b/sound/core/oss/pcm_oss.c
91559 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
91560 if (in_kernel) {
91561 mm_segment_t fs;
91562 fs = snd_enter_user();
91563 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
91564 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
91565 snd_leave_user(fs);
91566 } else {
91567 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
91568 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
91569 }
91570 if (ret != -EPIPE && ret != -ESTRPIPE)
91571 break;
91572 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
91573 if (in_kernel) {
91574 mm_segment_t fs;
91575 fs = snd_enter_user();
91576 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
91577 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
91578 snd_leave_user(fs);
91579 } else {
91580 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
91581 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
91582 }
91583 if (ret == -EPIPE) {
91584 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
91585 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
91586 struct snd_pcm_plugin_channel *channels;
91587 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
91588 if (!in_kernel) {
91589 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
91590 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
91591 return -EFAULT;
91592 buf = runtime->oss.buffer;
91593 }
91594 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
91595 }
91596 } else {
91597 tmp = snd_pcm_oss_write2(substream,
91598 - (const char __force *)buf,
91599 + (const char __force_kernel *)buf,
91600 runtime->oss.period_bytes, 0);
91601 if (tmp <= 0)
91602 goto err;
91603 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
91604 struct snd_pcm_runtime *runtime = substream->runtime;
91605 snd_pcm_sframes_t frames, frames1;
91606 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
91607 - char __user *final_dst = (char __force __user *)buf;
91608 + char __user *final_dst = (char __force_user *)buf;
91609 if (runtime->oss.plugin_first) {
91610 struct snd_pcm_plugin_channel *channels;
91611 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
91612 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
91613 xfer += tmp;
91614 runtime->oss.buffer_used -= tmp;
91615 } else {
91616 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
91617 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
91618 runtime->oss.period_bytes, 0);
91619 if (tmp <= 0)
91620 goto err;
91621 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
91622 size1);
91623 size1 /= runtime->channels; /* frames */
91624 fs = snd_enter_user();
91625 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
91626 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
91627 snd_leave_user(fs);
91628 }
91629 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
91630 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
91631 index af49721..e85058e 100644
91632 --- a/sound/core/pcm_compat.c
91633 +++ b/sound/core/pcm_compat.c
91634 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
91635 int err;
91636
91637 fs = snd_enter_user();
91638 - err = snd_pcm_delay(substream, &delay);
91639 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
91640 snd_leave_user(fs);
91641 if (err < 0)
91642 return err;
91643 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
91644 index eb560fa..69a4995 100644
91645 --- a/sound/core/pcm_native.c
91646 +++ b/sound/core/pcm_native.c
91647 @@ -2806,11 +2806,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
91648 switch (substream->stream) {
91649 case SNDRV_PCM_STREAM_PLAYBACK:
91650 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
91651 - (void __user *)arg);
91652 + (void __force_user *)arg);
91653 break;
91654 case SNDRV_PCM_STREAM_CAPTURE:
91655 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
91656 - (void __user *)arg);
91657 + (void __force_user *)arg);
91658 break;
91659 default:
91660 result = -EINVAL;
91661 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
91662 index 040c60e..989a19a 100644
91663 --- a/sound/core/seq/seq_device.c
91664 +++ b/sound/core/seq/seq_device.c
91665 @@ -64,7 +64,7 @@ struct ops_list {
91666 int argsize; /* argument size */
91667
91668 /* operators */
91669 - struct snd_seq_dev_ops ops;
91670 + struct snd_seq_dev_ops *ops;
91671
91672 /* registered devices */
91673 struct list_head dev_list; /* list of devices */
91674 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
91675
91676 mutex_lock(&ops->reg_mutex);
91677 /* copy driver operators */
91678 - ops->ops = *entry;
91679 + ops->ops = entry;
91680 ops->driver |= DRIVER_LOADED;
91681 ops->argsize = argsize;
91682
91683 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
91684 dev->name, ops->id, ops->argsize, dev->argsize);
91685 return -EINVAL;
91686 }
91687 - if (ops->ops.init_device(dev) >= 0) {
91688 + if (ops->ops->init_device(dev) >= 0) {
91689 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
91690 ops->num_init_devices++;
91691 } else {
91692 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
91693 dev->name, ops->id, ops->argsize, dev->argsize);
91694 return -EINVAL;
91695 }
91696 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
91697 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
91698 dev->status = SNDRV_SEQ_DEVICE_FREE;
91699 dev->driver_data = NULL;
91700 ops->num_init_devices--;
91701 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
91702 index 4e0dd22..7a1f32c 100644
91703 --- a/sound/drivers/mts64.c
91704 +++ b/sound/drivers/mts64.c
91705 @@ -29,6 +29,7 @@
91706 #include <sound/initval.h>
91707 #include <sound/rawmidi.h>
91708 #include <sound/control.h>
91709 +#include <asm/local.h>
91710
91711 #define CARD_NAME "Miditerminal 4140"
91712 #define DRIVER_NAME "MTS64"
91713 @@ -67,7 +68,7 @@ struct mts64 {
91714 struct pardevice *pardev;
91715 int pardev_claimed;
91716
91717 - int open_count;
91718 + local_t open_count;
91719 int current_midi_output_port;
91720 int current_midi_input_port;
91721 u8 mode[MTS64_NUM_INPUT_PORTS];
91722 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
91723 {
91724 struct mts64 *mts = substream->rmidi->private_data;
91725
91726 - if (mts->open_count == 0) {
91727 + if (local_read(&mts->open_count) == 0) {
91728 /* We don't need a spinlock here, because this is just called
91729 if the device has not been opened before.
91730 So there aren't any IRQs from the device */
91731 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
91732
91733 msleep(50);
91734 }
91735 - ++(mts->open_count);
91736 + local_inc(&mts->open_count);
91737
91738 return 0;
91739 }
91740 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
91741 struct mts64 *mts = substream->rmidi->private_data;
91742 unsigned long flags;
91743
91744 - --(mts->open_count);
91745 - if (mts->open_count == 0) {
91746 + if (local_dec_return(&mts->open_count) == 0) {
91747 /* We need the spinlock_irqsave here because we can still
91748 have IRQs at this point */
91749 spin_lock_irqsave(&mts->lock, flags);
91750 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
91751
91752 msleep(500);
91753
91754 - } else if (mts->open_count < 0)
91755 - mts->open_count = 0;
91756 + } else if (local_read(&mts->open_count) < 0)
91757 + local_set(&mts->open_count, 0);
91758
91759 return 0;
91760 }
91761 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
91762 index b953fb4..1999c01 100644
91763 --- a/sound/drivers/opl4/opl4_lib.c
91764 +++ b/sound/drivers/opl4/opl4_lib.c
91765 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
91766 MODULE_DESCRIPTION("OPL4 driver");
91767 MODULE_LICENSE("GPL");
91768
91769 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
91770 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
91771 {
91772 int timeout = 10;
91773 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
91774 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
91775 index 991018d..8984740 100644
91776 --- a/sound/drivers/portman2x4.c
91777 +++ b/sound/drivers/portman2x4.c
91778 @@ -48,6 +48,7 @@
91779 #include <sound/initval.h>
91780 #include <sound/rawmidi.h>
91781 #include <sound/control.h>
91782 +#include <asm/local.h>
91783
91784 #define CARD_NAME "Portman 2x4"
91785 #define DRIVER_NAME "portman"
91786 @@ -85,7 +86,7 @@ struct portman {
91787 struct pardevice *pardev;
91788 int pardev_claimed;
91789
91790 - int open_count;
91791 + local_t open_count;
91792 int mode[PORTMAN_NUM_INPUT_PORTS];
91793 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
91794 };
91795 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
91796 index ea995af..f1bfa37 100644
91797 --- a/sound/firewire/amdtp.c
91798 +++ b/sound/firewire/amdtp.c
91799 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
91800 ptr = s->pcm_buffer_pointer + data_blocks;
91801 if (ptr >= pcm->runtime->buffer_size)
91802 ptr -= pcm->runtime->buffer_size;
91803 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
91804 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
91805
91806 s->pcm_period_pointer += data_blocks;
91807 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
91808 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
91809 */
91810 void amdtp_out_stream_update(struct amdtp_out_stream *s)
91811 {
91812 - ACCESS_ONCE(s->source_node_id_field) =
91813 + ACCESS_ONCE_RW(s->source_node_id_field) =
91814 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
91815 }
91816 EXPORT_SYMBOL(amdtp_out_stream_update);
91817 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
91818 index b680c5e..061b7a0 100644
91819 --- a/sound/firewire/amdtp.h
91820 +++ b/sound/firewire/amdtp.h
91821 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
91822 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
91823 struct snd_pcm_substream *pcm)
91824 {
91825 - ACCESS_ONCE(s->pcm) = pcm;
91826 + ACCESS_ONCE_RW(s->pcm) = pcm;
91827 }
91828
91829 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
91830 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
91831 index d428ffe..751ef78 100644
91832 --- a/sound/firewire/isight.c
91833 +++ b/sound/firewire/isight.c
91834 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
91835 ptr += count;
91836 if (ptr >= runtime->buffer_size)
91837 ptr -= runtime->buffer_size;
91838 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
91839 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
91840
91841 isight->period_counter += count;
91842 if (isight->period_counter >= runtime->period_size) {
91843 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
91844 if (err < 0)
91845 return err;
91846
91847 - ACCESS_ONCE(isight->pcm_active) = true;
91848 + ACCESS_ONCE_RW(isight->pcm_active) = true;
91849
91850 return 0;
91851 }
91852 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
91853 {
91854 struct isight *isight = substream->private_data;
91855
91856 - ACCESS_ONCE(isight->pcm_active) = false;
91857 + ACCESS_ONCE_RW(isight->pcm_active) = false;
91858
91859 mutex_lock(&isight->mutex);
91860 isight_stop_streaming(isight);
91861 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
91862
91863 switch (cmd) {
91864 case SNDRV_PCM_TRIGGER_START:
91865 - ACCESS_ONCE(isight->pcm_running) = true;
91866 + ACCESS_ONCE_RW(isight->pcm_running) = true;
91867 break;
91868 case SNDRV_PCM_TRIGGER_STOP:
91869 - ACCESS_ONCE(isight->pcm_running) = false;
91870 + ACCESS_ONCE_RW(isight->pcm_running) = false;
91871 break;
91872 default:
91873 return -EINVAL;
91874 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
91875 index 844a555..985ab83 100644
91876 --- a/sound/firewire/scs1x.c
91877 +++ b/sound/firewire/scs1x.c
91878 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
91879 {
91880 struct scs *scs = stream->rmidi->private_data;
91881
91882 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
91883 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
91884 if (up) {
91885 scs->output_idle = false;
91886 tasklet_schedule(&scs->tasklet);
91887 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
91888 {
91889 struct scs *scs = stream->rmidi->private_data;
91890
91891 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
91892 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
91893 }
91894
91895 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
91896 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
91897
91898 snd_card_disconnect(scs->card);
91899
91900 - ACCESS_ONCE(scs->output) = NULL;
91901 - ACCESS_ONCE(scs->input) = NULL;
91902 + ACCESS_ONCE_RW(scs->output) = NULL;
91903 + ACCESS_ONCE_RW(scs->input) = NULL;
91904
91905 wait_event(scs->idle_wait, scs->output_idle);
91906
91907 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
91908 index 048439a..3be9f6f 100644
91909 --- a/sound/oss/sb_audio.c
91910 +++ b/sound/oss/sb_audio.c
91911 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
91912 buf16 = (signed short *)(localbuf + localoffs);
91913 while (c)
91914 {
91915 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
91916 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
91917 if (copy_from_user(lbuf8,
91918 userbuf+useroffs + p,
91919 locallen))
91920 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
91921 index 7d8803a..559f8d0 100644
91922 --- a/sound/oss/swarm_cs4297a.c
91923 +++ b/sound/oss/swarm_cs4297a.c
91924 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
91925 {
91926 struct cs4297a_state *s;
91927 u32 pwr, id;
91928 - mm_segment_t fs;
91929 int rval;
91930 #ifndef CONFIG_BCM_CS4297A_CSWARM
91931 u64 cfg;
91932 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
91933 if (!rval) {
91934 char *sb1250_duart_present;
91935
91936 +#if 0
91937 + mm_segment_t fs;
91938 fs = get_fs();
91939 set_fs(KERNEL_DS);
91940 -#if 0
91941 val = SOUND_MASK_LINE;
91942 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
91943 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
91944 val = initvol[i].vol;
91945 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
91946 }
91947 + set_fs(fs);
91948 // cs4297a_write_ac97(s, 0x18, 0x0808);
91949 #else
91950 // cs4297a_write_ac97(s, 0x5e, 0x180);
91951 cs4297a_write_ac97(s, 0x02, 0x0808);
91952 cs4297a_write_ac97(s, 0x18, 0x0808);
91953 #endif
91954 - set_fs(fs);
91955
91956 list_add(&s->list, &cs4297a_devs);
91957
91958 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
91959 index 4631a23..001ae57 100644
91960 --- a/sound/pci/ymfpci/ymfpci.h
91961 +++ b/sound/pci/ymfpci/ymfpci.h
91962 @@ -358,7 +358,7 @@ struct snd_ymfpci {
91963 spinlock_t reg_lock;
91964 spinlock_t voice_lock;
91965 wait_queue_head_t interrupt_sleep;
91966 - atomic_t interrupt_sleep_count;
91967 + atomic_unchecked_t interrupt_sleep_count;
91968 struct snd_info_entry *proc_entry;
91969 const struct firmware *dsp_microcode;
91970 const struct firmware *controller_microcode;
91971 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
91972 index 22056c5..25d3244 100644
91973 --- a/sound/pci/ymfpci/ymfpci_main.c
91974 +++ b/sound/pci/ymfpci/ymfpci_main.c
91975 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
91976 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
91977 break;
91978 }
91979 - if (atomic_read(&chip->interrupt_sleep_count)) {
91980 - atomic_set(&chip->interrupt_sleep_count, 0);
91981 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
91982 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
91983 wake_up(&chip->interrupt_sleep);
91984 }
91985 __end:
91986 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
91987 continue;
91988 init_waitqueue_entry(&wait, current);
91989 add_wait_queue(&chip->interrupt_sleep, &wait);
91990 - atomic_inc(&chip->interrupt_sleep_count);
91991 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
91992 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
91993 remove_wait_queue(&chip->interrupt_sleep, &wait);
91994 }
91995 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
91996 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
91997 spin_unlock(&chip->reg_lock);
91998
91999 - if (atomic_read(&chip->interrupt_sleep_count)) {
92000 - atomic_set(&chip->interrupt_sleep_count, 0);
92001 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
92002 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92003 wake_up(&chip->interrupt_sleep);
92004 }
92005 }
92006 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
92007 spin_lock_init(&chip->reg_lock);
92008 spin_lock_init(&chip->voice_lock);
92009 init_waitqueue_head(&chip->interrupt_sleep);
92010 - atomic_set(&chip->interrupt_sleep_count, 0);
92011 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
92012 chip->card = card;
92013 chip->pci = pci;
92014 chip->irq = -1;
92015 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
92016 new file mode 100644
92017 index 0000000..50f2f2f
92018 --- /dev/null
92019 +++ b/tools/gcc/.gitignore
92020 @@ -0,0 +1 @@
92021 +size_overflow_hash.h
92022 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
92023 new file mode 100644
92024 index 0000000..144dbee
92025 --- /dev/null
92026 +++ b/tools/gcc/Makefile
92027 @@ -0,0 +1,45 @@
92028 +#CC := gcc
92029 +#PLUGIN_SOURCE_FILES := pax_plugin.c
92030 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
92031 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
92032 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
92033 +
92034 +ifeq ($(PLUGINCC),$(HOSTCC))
92035 +HOSTLIBS := hostlibs
92036 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
92037 +else
92038 +HOSTLIBS := hostcxxlibs
92039 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
92040 +endif
92041 +
92042 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
92043 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
92044 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
92045 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
92046 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
92047 +$(HOSTLIBS)-y += colorize_plugin.so
92048 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
92049 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
92050 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
92051 +
92052 +always := $($(HOSTLIBS)-y)
92053 +
92054 +constify_plugin-objs := constify_plugin.o
92055 +stackleak_plugin-objs := stackleak_plugin.o
92056 +kallocstat_plugin-objs := kallocstat_plugin.o
92057 +kernexec_plugin-objs := kernexec_plugin.o
92058 +checker_plugin-objs := checker_plugin.o
92059 +colorize_plugin-objs := colorize_plugin.o
92060 +size_overflow_plugin-objs := size_overflow_plugin.o
92061 +latent_entropy_plugin-objs := latent_entropy_plugin.o
92062 +structleak_plugin-objs := structleak_plugin.o
92063 +
92064 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
92065 +
92066 +quiet_cmd_build_size_overflow_hash = GENHASH $@
92067 + cmd_build_size_overflow_hash = \
92068 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
92069 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
92070 + $(call if_changed,build_size_overflow_hash)
92071 +
92072 +targets += size_overflow_hash.h
92073 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
92074 new file mode 100644
92075 index 0000000..d41b5af
92076 --- /dev/null
92077 +++ b/tools/gcc/checker_plugin.c
92078 @@ -0,0 +1,171 @@
92079 +/*
92080 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
92081 + * Licensed under the GPL v2
92082 + *
92083 + * Note: the choice of the license means that the compilation process is
92084 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
92085 + * but for the kernel it doesn't matter since it doesn't link against
92086 + * any of the gcc libraries
92087 + *
92088 + * gcc plugin to implement various sparse (source code checker) features
92089 + *
92090 + * TODO:
92091 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
92092 + *
92093 + * BUGS:
92094 + * - none known
92095 + */
92096 +#include "gcc-plugin.h"
92097 +#include "config.h"
92098 +#include "system.h"
92099 +#include "coretypes.h"
92100 +#include "tree.h"
92101 +#include "tree-pass.h"
92102 +#include "flags.h"
92103 +#include "intl.h"
92104 +#include "toplev.h"
92105 +#include "plugin.h"
92106 +//#include "expr.h" where are you...
92107 +#include "diagnostic.h"
92108 +#include "plugin-version.h"
92109 +#include "tm.h"
92110 +#include "function.h"
92111 +#include "basic-block.h"
92112 +#include "gimple.h"
92113 +#include "rtl.h"
92114 +#include "emit-rtl.h"
92115 +#include "tree-flow.h"
92116 +#include "target.h"
92117 +
92118 +extern void c_register_addr_space (const char *str, addr_space_t as);
92119 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
92120 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
92121 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
92122 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
92123 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
92124 +
92125 +extern void print_gimple_stmt(FILE *, gimple, int, int);
92126 +extern rtx emit_move_insn(rtx x, rtx y);
92127 +
92128 +int plugin_is_GPL_compatible;
92129 +
92130 +static struct plugin_info checker_plugin_info = {
92131 + .version = "201111150100",
92132 +};
92133 +
92134 +#define ADDR_SPACE_KERNEL 0
92135 +#define ADDR_SPACE_FORCE_KERNEL 1
92136 +#define ADDR_SPACE_USER 2
92137 +#define ADDR_SPACE_FORCE_USER 3
92138 +#define ADDR_SPACE_IOMEM 0
92139 +#define ADDR_SPACE_FORCE_IOMEM 0
92140 +#define ADDR_SPACE_PERCPU 0
92141 +#define ADDR_SPACE_FORCE_PERCPU 0
92142 +#define ADDR_SPACE_RCU 0
92143 +#define ADDR_SPACE_FORCE_RCU 0
92144 +
92145 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
92146 +{
92147 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
92148 +}
92149 +
92150 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
92151 +{
92152 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
92153 +}
92154 +
92155 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
92156 +{
92157 + return default_addr_space_valid_pointer_mode(mode, as);
92158 +}
92159 +
92160 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
92161 +{
92162 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
92163 +}
92164 +
92165 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
92166 +{
92167 + return default_addr_space_legitimize_address(x, oldx, mode, as);
92168 +}
92169 +
92170 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
92171 +{
92172 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
92173 + return true;
92174 +
92175 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
92176 + return true;
92177 +
92178 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
92179 + return true;
92180 +
92181 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
92182 + return true;
92183 +
92184 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
92185 + return true;
92186 +
92187 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
92188 + return true;
92189 +
92190 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
92191 + return true;
92192 +
92193 + return subset == superset;
92194 +}
92195 +
92196 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
92197 +{
92198 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
92199 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
92200 +
92201 + return op;
92202 +}
92203 +
92204 +static void register_checker_address_spaces(void *event_data, void *data)
92205 +{
92206 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
92207 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
92208 + c_register_addr_space("__user", ADDR_SPACE_USER);
92209 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
92210 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
92211 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
92212 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
92213 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
92214 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
92215 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
92216 +
92217 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
92218 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
92219 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
92220 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
92221 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
92222 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
92223 + targetm.addr_space.convert = checker_addr_space_convert;
92224 +}
92225 +
92226 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
92227 +{
92228 + const char * const plugin_name = plugin_info->base_name;
92229 + const int argc = plugin_info->argc;
92230 + const struct plugin_argument * const argv = plugin_info->argv;
92231 + int i;
92232 +
92233 + if (!plugin_default_version_check(version, &gcc_version)) {
92234 + error(G_("incompatible gcc/plugin versions"));
92235 + return 1;
92236 + }
92237 +
92238 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
92239 +
92240 + for (i = 0; i < argc; ++i)
92241 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
92242 +
92243 + if (TARGET_64BIT == 0)
92244 + return 0;
92245 +
92246 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
92247 +
92248 + return 0;
92249 +}
92250 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
92251 new file mode 100644
92252 index 0000000..414fe5e
92253 --- /dev/null
92254 +++ b/tools/gcc/colorize_plugin.c
92255 @@ -0,0 +1,151 @@
92256 +/*
92257 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
92258 + * Licensed under the GPL v2
92259 + *
92260 + * Note: the choice of the license means that the compilation process is
92261 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
92262 + * but for the kernel it doesn't matter since it doesn't link against
92263 + * any of the gcc libraries
92264 + *
92265 + * gcc plugin to colorize diagnostic output
92266 + *
92267 + */
92268 +
92269 +#include "gcc-plugin.h"
92270 +#include "config.h"
92271 +#include "system.h"
92272 +#include "coretypes.h"
92273 +#include "tree.h"
92274 +#include "tree-pass.h"
92275 +#include "flags.h"
92276 +#include "intl.h"
92277 +#include "toplev.h"
92278 +#include "plugin.h"
92279 +#include "diagnostic.h"
92280 +#include "plugin-version.h"
92281 +#include "tm.h"
92282 +
92283 +int plugin_is_GPL_compatible;
92284 +
92285 +static struct plugin_info colorize_plugin_info = {
92286 + .version = "201302112000",
92287 + .help = NULL,
92288 +};
92289 +
92290 +#define GREEN "\033[32m\033[2m"
92291 +#define LIGHTGREEN "\033[32m\033[1m"
92292 +#define YELLOW "\033[33m\033[2m"
92293 +#define LIGHTYELLOW "\033[33m\033[1m"
92294 +#define RED "\033[31m\033[2m"
92295 +#define LIGHTRED "\033[31m\033[1m"
92296 +#define BLUE "\033[34m\033[2m"
92297 +#define LIGHTBLUE "\033[34m\033[1m"
92298 +#define BRIGHT "\033[m\033[1m"
92299 +#define NORMAL "\033[m"
92300 +
92301 +static diagnostic_starter_fn old_starter;
92302 +static diagnostic_finalizer_fn old_finalizer;
92303 +
92304 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
92305 +{
92306 + const char *color;
92307 + char *newprefix;
92308 +
92309 + switch (diagnostic->kind) {
92310 + case DK_NOTE:
92311 + color = LIGHTBLUE;
92312 + break;
92313 +
92314 + case DK_PEDWARN:
92315 + case DK_WARNING:
92316 + color = LIGHTYELLOW;
92317 + break;
92318 +
92319 + case DK_ERROR:
92320 + case DK_FATAL:
92321 + case DK_ICE:
92322 + case DK_PERMERROR:
92323 + case DK_SORRY:
92324 + color = LIGHTRED;
92325 + break;
92326 +
92327 + default:
92328 + color = NORMAL;
92329 + }
92330 +
92331 + old_starter(context, diagnostic);
92332 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
92333 + return;
92334 + pp_destroy_prefix(context->printer);
92335 + pp_set_prefix(context->printer, newprefix);
92336 +}
92337 +
92338 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
92339 +{
92340 + old_finalizer(context, diagnostic);
92341 +}
92342 +
92343 +static void colorize_arm(void)
92344 +{
92345 + old_starter = diagnostic_starter(global_dc);
92346 + old_finalizer = diagnostic_finalizer(global_dc);
92347 +
92348 + diagnostic_starter(global_dc) = start_colorize;
92349 + diagnostic_finalizer(global_dc) = finalize_colorize;
92350 +}
92351 +
92352 +static unsigned int execute_colorize_rearm(void)
92353 +{
92354 + if (diagnostic_starter(global_dc) == start_colorize)
92355 + return 0;
92356 +
92357 + colorize_arm();
92358 + return 0;
92359 +}
92360 +
92361 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
92362 + .pass = {
92363 + .type = SIMPLE_IPA_PASS,
92364 + .name = "colorize_rearm",
92365 +#if BUILDING_GCC_VERSION >= 4008
92366 + .optinfo_flags = OPTGROUP_NONE,
92367 +#endif
92368 + .gate = NULL,
92369 + .execute = execute_colorize_rearm,
92370 + .sub = NULL,
92371 + .next = NULL,
92372 + .static_pass_number = 0,
92373 + .tv_id = TV_NONE,
92374 + .properties_required = 0,
92375 + .properties_provided = 0,
92376 + .properties_destroyed = 0,
92377 + .todo_flags_start = 0,
92378 + .todo_flags_finish = 0
92379 + }
92380 +};
92381 +
92382 +static void colorize_start_unit(void *gcc_data, void *user_data)
92383 +{
92384 + colorize_arm();
92385 +}
92386 +
92387 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
92388 +{
92389 + const char * const plugin_name = plugin_info->base_name;
92390 + struct register_pass_info colorize_rearm_pass_info = {
92391 + .pass = &pass_ipa_colorize_rearm.pass,
92392 + .reference_pass_name = "*free_lang_data",
92393 + .ref_pass_instance_number = 1,
92394 + .pos_op = PASS_POS_INSERT_AFTER
92395 + };
92396 +
92397 + if (!plugin_default_version_check(version, &gcc_version)) {
92398 + error(G_("incompatible gcc/plugin versions"));
92399 + return 1;
92400 + }
92401 +
92402 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
92403 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
92404 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
92405 + return 0;
92406 +}
92407 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
92408 new file mode 100644
92409 index 0000000..bee0acb
92410 --- /dev/null
92411 +++ b/tools/gcc/constify_plugin.c
92412 @@ -0,0 +1,518 @@
92413 +/*
92414 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
92415 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
92416 + * Licensed under the GPL v2, or (at your option) v3
92417 + *
92418 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
92419 + *
92420 + * Homepage:
92421 + * http://www.grsecurity.net/~ephox/const_plugin/
92422 + *
92423 + * Usage:
92424 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
92425 + * $ gcc -fplugin=constify_plugin.so test.c -O2
92426 + */
92427 +
92428 +#include "gcc-plugin.h"
92429 +#include "config.h"
92430 +#include "system.h"
92431 +#include "coretypes.h"
92432 +#include "tree.h"
92433 +#include "tree-pass.h"
92434 +#include "flags.h"
92435 +#include "intl.h"
92436 +#include "toplev.h"
92437 +#include "plugin.h"
92438 +#include "diagnostic.h"
92439 +#include "plugin-version.h"
92440 +#include "tm.h"
92441 +#include "function.h"
92442 +#include "basic-block.h"
92443 +#include "gimple.h"
92444 +#include "rtl.h"
92445 +#include "emit-rtl.h"
92446 +#include "tree-flow.h"
92447 +#include "target.h"
92448 +#include "langhooks.h"
92449 +
92450 +// should come from c-tree.h if only it were installed for gcc 4.5...
92451 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
92452 +
92453 +// unused type flag in all versions 4.5-4.8
92454 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
92455 +
92456 +int plugin_is_GPL_compatible;
92457 +
92458 +static struct plugin_info const_plugin_info = {
92459 + .version = "201303270300",
92460 + .help = "no-constify\tturn off constification\n",
92461 +};
92462 +
92463 +typedef struct {
92464 + bool has_fptr_field;
92465 + bool has_writable_field;
92466 + bool has_do_const_field;
92467 + bool has_no_const_field;
92468 +} constify_info;
92469 +
92470 +static const_tree get_field_type(const_tree field)
92471 +{
92472 + return strip_array_types(TREE_TYPE(field));
92473 +}
92474 +
92475 +static bool is_fptr(const_tree field)
92476 +{
92477 + const_tree ptr = get_field_type(field);
92478 +
92479 + if (TREE_CODE(ptr) != POINTER_TYPE)
92480 + return false;
92481 +
92482 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
92483 +}
92484 +
92485 +/*
92486 + * determine whether the given structure type meets the requirements for automatic constification,
92487 + * including the constification attributes on nested structure types
92488 + */
92489 +static void constifiable(const_tree node, constify_info *cinfo)
92490 +{
92491 + const_tree field;
92492 +
92493 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
92494 +
92495 + // e.g., pointer to structure fields while still constructing the structure type
92496 + if (TYPE_FIELDS(node) == NULL_TREE)
92497 + return;
92498 +
92499 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
92500 + const_tree type = get_field_type(field);
92501 + enum tree_code code = TREE_CODE(type);
92502 +
92503 + if (node == type)
92504 + continue;
92505 +
92506 + if (is_fptr(field))
92507 + cinfo->has_fptr_field = true;
92508 + else if (!TREE_READONLY(field))
92509 + cinfo->has_writable_field = true;
92510 +
92511 + if (code == RECORD_TYPE || code == UNION_TYPE) {
92512 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
92513 + cinfo->has_do_const_field = true;
92514 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
92515 + cinfo->has_no_const_field = true;
92516 + else
92517 + constifiable(type, cinfo);
92518 + }
92519 + }
92520 +}
92521 +
92522 +static bool constified(const_tree node)
92523 +{
92524 + constify_info cinfo = {
92525 + .has_fptr_field = false,
92526 + .has_writable_field = false,
92527 + .has_do_const_field = false,
92528 + .has_no_const_field = false
92529 + };
92530 +
92531 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
92532 +
92533 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
92534 + gcc_assert(!TYPE_READONLY(node));
92535 + return false;
92536 + }
92537 +
92538 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
92539 + gcc_assert(TYPE_READONLY(node));
92540 + return true;
92541 + }
92542 +
92543 + constifiable(node, &cinfo);
92544 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
92545 + return false;
92546 +
92547 + return TYPE_READONLY(node);
92548 +}
92549 +
92550 +static void deconstify_tree(tree node);
92551 +
92552 +static void deconstify_type(tree type)
92553 +{
92554 + tree field;
92555 +
92556 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
92557 +
92558 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
92559 + const_tree fieldtype = get_field_type(field);
92560 +
92561 + // special case handling of simple ptr-to-same-array-type members
92562 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
92563 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
92564 +
92565 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
92566 + continue;
92567 + if (TREE_TYPE(TREE_TYPE(field)) == type)
92568 + continue;
92569 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
92570 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
92571 + TREE_TYPE(TREE_TYPE(field)) = type;
92572 + }
92573 + continue;
92574 + }
92575 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
92576 + continue;
92577 + if (!constified(fieldtype))
92578 + continue;
92579 +
92580 + deconstify_tree(field);
92581 + TREE_READONLY(field) = 0;
92582 + }
92583 + TYPE_READONLY(type) = 0;
92584 + C_TYPE_FIELDS_READONLY(type) = 0;
92585 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
92586 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
92587 +}
92588 +
92589 +static void deconstify_tree(tree node)
92590 +{
92591 + tree old_type, new_type, field;
92592 +
92593 + old_type = TREE_TYPE(node);
92594 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
92595 + node = TREE_TYPE(node) = copy_node(old_type);
92596 + old_type = TREE_TYPE(old_type);
92597 + }
92598 +
92599 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
92600 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
92601 +
92602 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
92603 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
92604 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
92605 + DECL_FIELD_CONTEXT(field) = new_type;
92606 +
92607 + deconstify_type(new_type);
92608 +
92609 + TREE_TYPE(node) = new_type;
92610 +}
92611 +
92612 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
92613 +{
92614 + tree type;
92615 + constify_info cinfo = {
92616 + .has_fptr_field = false,
92617 + .has_writable_field = false,
92618 + .has_do_const_field = false,
92619 + .has_no_const_field = false
92620 + };
92621 +
92622 + *no_add_attrs = true;
92623 + if (TREE_CODE(*node) == FUNCTION_DECL) {
92624 + error("%qE attribute does not apply to functions", name);
92625 + return NULL_TREE;
92626 + }
92627 +
92628 + if (TREE_CODE(*node) == PARM_DECL) {
92629 + error("%qE attribute does not apply to function parameters", name);
92630 + return NULL_TREE;
92631 + }
92632 +
92633 + if (TREE_CODE(*node) == VAR_DECL) {
92634 + error("%qE attribute does not apply to variables", name);
92635 + return NULL_TREE;
92636 + }
92637 +
92638 + if (TYPE_P(*node)) {
92639 + *no_add_attrs = false;
92640 + type = *node;
92641 + } else {
92642 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
92643 + type = TREE_TYPE(*node);
92644 + }
92645 +
92646 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
92647 + error("%qE attribute applies to struct and union types only", name);
92648 + return NULL_TREE;
92649 + }
92650 +
92651 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
92652 + error("%qE attribute is already applied to the type", name);
92653 + return NULL_TREE;
92654 + }
92655 +
92656 + if (TYPE_P(*node)) {
92657 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
92658 + error("%qE attribute is incompatible with 'do_const'", name);
92659 + return NULL_TREE;
92660 + }
92661 +
92662 + constifiable(type, &cinfo);
92663 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
92664 + deconstify_tree(*node);
92665 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
92666 + return NULL_TREE;
92667 + }
92668 +
92669 + error("%qE attribute used on type that is not constified", name);
92670 + return NULL_TREE;
92671 +}
92672 +
92673 +static void constify_type(tree type)
92674 +{
92675 + TYPE_READONLY(type) = 1;
92676 + C_TYPE_FIELDS_READONLY(type) = 1;
92677 + TYPE_CONSTIFY_VISITED(type) = 1;
92678 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
92679 +}
92680 +
92681 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
92682 +{
92683 + *no_add_attrs = true;
92684 + if (!TYPE_P(*node)) {
92685 + error("%qE attribute applies to types only", name);
92686 + return NULL_TREE;
92687 + }
92688 +
92689 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
92690 + error("%qE attribute applies to struct and union types only", name);
92691 + return NULL_TREE;
92692 + }
92693 +
92694 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
92695 + error("%qE attribute is already applied to the type", name);
92696 + return NULL_TREE;
92697 + }
92698 +
92699 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
92700 + error("%qE attribute is incompatible with 'no_const'", name);
92701 + return NULL_TREE;
92702 + }
92703 +
92704 + *no_add_attrs = false;
92705 + return NULL_TREE;
92706 +}
92707 +
92708 +static struct attribute_spec no_const_attr = {
92709 + .name = "no_const",
92710 + .min_length = 0,
92711 + .max_length = 0,
92712 + .decl_required = false,
92713 + .type_required = false,
92714 + .function_type_required = false,
92715 + .handler = handle_no_const_attribute,
92716 +#if BUILDING_GCC_VERSION >= 4007
92717 + .affects_type_identity = true
92718 +#endif
92719 +};
92720 +
92721 +static struct attribute_spec do_const_attr = {
92722 + .name = "do_const",
92723 + .min_length = 0,
92724 + .max_length = 0,
92725 + .decl_required = false,
92726 + .type_required = false,
92727 + .function_type_required = false,
92728 + .handler = handle_do_const_attribute,
92729 +#if BUILDING_GCC_VERSION >= 4007
92730 + .affects_type_identity = true
92731 +#endif
92732 +};
92733 +
92734 +static void register_attributes(void *event_data, void *data)
92735 +{
92736 + register_attribute(&no_const_attr);
92737 + register_attribute(&do_const_attr);
92738 +}
92739 +
92740 +static void finish_type(void *event_data, void *data)
92741 +{
92742 + tree type = (tree)event_data;
92743 + constify_info cinfo = {
92744 + .has_fptr_field = false,
92745 + .has_writable_field = false,
92746 + .has_do_const_field = false,
92747 + .has_no_const_field = false
92748 + };
92749 +
92750 + if (type == NULL_TREE || type == error_mark_node)
92751 + return;
92752 +
92753 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
92754 + return;
92755 +
92756 + constifiable(type, &cinfo);
92757 +
92758 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
92759 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
92760 + return;
92761 + if (cinfo.has_writable_field)
92762 + return;
92763 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
92764 + return;
92765 + }
92766 +
92767 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
92768 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
92769 + deconstify_type(type);
92770 + TYPE_CONSTIFY_VISITED(type) = 1;
92771 + } else
92772 + error("'no_const' attribute used on type that is not constified");
92773 + return;
92774 + }
92775 +
92776 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
92777 + constify_type(type);
92778 + return;
92779 + }
92780 +
92781 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
92782 + constify_type(type);
92783 + return;
92784 + }
92785 +
92786 + deconstify_type(type);
92787 + TYPE_CONSTIFY_VISITED(type) = 1;
92788 +}
92789 +
92790 +static unsigned int check_local_variables(void)
92791 +{
92792 + unsigned int ret = 0;
92793 + tree var;
92794 +
92795 +#if BUILDING_GCC_VERSION == 4005
92796 + tree vars;
92797 +#else
92798 + unsigned int i;
92799 +#endif
92800 +
92801 +#if BUILDING_GCC_VERSION == 4005
92802 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
92803 + var = TREE_VALUE(vars);
92804 +#else
92805 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
92806 +#endif
92807 + tree type = TREE_TYPE(var);
92808 +
92809 + gcc_assert(DECL_P(var));
92810 + if (is_global_var(var))
92811 + continue;
92812 +
92813 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
92814 + continue;
92815 +
92816 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
92817 + continue;
92818 +
92819 + if (!TYPE_CONSTIFY_VISITED(type))
92820 + continue;
92821 +
92822 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
92823 + ret = 1;
92824 + }
92825 + return ret;
92826 +}
92827 +
92828 +static struct gimple_opt_pass pass_local_variable = {
92829 + {
92830 + .type = GIMPLE_PASS,
92831 + .name = "check_local_variables",
92832 +#if BUILDING_GCC_VERSION >= 4008
92833 + .optinfo_flags = OPTGROUP_NONE,
92834 +#endif
92835 + .gate = NULL,
92836 + .execute = check_local_variables,
92837 + .sub = NULL,
92838 + .next = NULL,
92839 + .static_pass_number = 0,
92840 + .tv_id = TV_NONE,
92841 + .properties_required = 0,
92842 + .properties_provided = 0,
92843 + .properties_destroyed = 0,
92844 + .todo_flags_start = 0,
92845 + .todo_flags_finish = 0
92846 + }
92847 +};
92848 +
92849 +static struct {
92850 + const char *name;
92851 + const char *asm_op;
92852 +} sections[] = {
92853 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
92854 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
92855 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
92856 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
92857 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
92858 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
92859 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
92860 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
92861 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
92862 +};
92863 +
92864 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
92865 +
92866 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
92867 +{
92868 + size_t i;
92869 +
92870 + for (i = 0; i < ARRAY_SIZE(sections); i++)
92871 + if (!strcmp(sections[i].name, name))
92872 + return 0;
92873 + return old_section_type_flags(decl, name, reloc);
92874 +}
92875 +
92876 +static void constify_start_unit(void *gcc_data, void *user_data)
92877 +{
92878 +// size_t i;
92879 +
92880 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
92881 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
92882 +// sections[i].section = get_section(sections[i].name, 0, NULL);
92883 +
92884 + old_section_type_flags = targetm.section_type_flags;
92885 + targetm.section_type_flags = constify_section_type_flags;
92886 +}
92887 +
92888 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
92889 +{
92890 + const char * const plugin_name = plugin_info->base_name;
92891 + const int argc = plugin_info->argc;
92892 + const struct plugin_argument * const argv = plugin_info->argv;
92893 + int i;
92894 + bool constify = true;
92895 +
92896 + struct register_pass_info local_variable_pass_info = {
92897 + .pass = &pass_local_variable.pass,
92898 + .reference_pass_name = "ssa",
92899 + .ref_pass_instance_number = 1,
92900 + .pos_op = PASS_POS_INSERT_BEFORE
92901 + };
92902 +
92903 + if (!plugin_default_version_check(version, &gcc_version)) {
92904 + error(G_("incompatible gcc/plugin versions"));
92905 + return 1;
92906 + }
92907 +
92908 + for (i = 0; i < argc; ++i) {
92909 + if (!(strcmp(argv[i].key, "no-constify"))) {
92910 + constify = false;
92911 + continue;
92912 + }
92913 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
92914 + }
92915 +
92916 + if (strcmp(lang_hooks.name, "GNU C")) {
92917 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
92918 + constify = false;
92919 + }
92920 +
92921 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
92922 + if (constify) {
92923 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
92924 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
92925 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
92926 + }
92927 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
92928 +
92929 + return 0;
92930 +}
92931 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
92932 new file mode 100644
92933 index 0000000..e518932
92934 --- /dev/null
92935 +++ b/tools/gcc/generate_size_overflow_hash.sh
92936 @@ -0,0 +1,94 @@
92937 +#!/bin/bash
92938 +
92939 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
92940 +
92941 +header1="size_overflow_hash.h"
92942 +database="size_overflow_hash.data"
92943 +n=65536
92944 +
92945 +usage() {
92946 +cat <<EOF
92947 +usage: $0 options
92948 +OPTIONS:
92949 + -h|--help help
92950 + -o header file
92951 + -d database file
92952 + -n hash array size
92953 +EOF
92954 + return 0
92955 +}
92956 +
92957 +while true
92958 +do
92959 + case "$1" in
92960 + -h|--help) usage && exit 0;;
92961 + -n) n=$2; shift 2;;
92962 + -o) header1="$2"; shift 2;;
92963 + -d) database="$2"; shift 2;;
92964 + --) shift 1; break ;;
92965 + *) break ;;
92966 + esac
92967 +done
92968 +
92969 +create_defines() {
92970 + for i in `seq 0 31`
92971 + do
92972 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
92973 + done
92974 + echo >> "$header1"
92975 +}
92976 +
92977 +create_structs() {
92978 + rm -f "$header1"
92979 +
92980 + create_defines
92981 +
92982 + cat "$database" | while read data
92983 + do
92984 + data_array=($data)
92985 + struct_hash_name="${data_array[0]}"
92986 + funcn="${data_array[1]}"
92987 + params="${data_array[2]}"
92988 + next="${data_array[4]}"
92989 +
92990 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
92991 +
92992 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
92993 + echo -en "\t.param\t= " >> "$header1"
92994 + line=
92995 + for param_num in ${params//-/ };
92996 + do
92997 + line="${line}PARAM"$param_num"|"
92998 + done
92999 +
93000 + echo -e "${line%?},\n};\n" >> "$header1"
93001 + done
93002 +}
93003 +
93004 +create_headers() {
93005 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
93006 +}
93007 +
93008 +create_array_elements() {
93009 + index=0
93010 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
93011 + do
93012 + data_array=($data)
93013 + i="${data_array[3]}"
93014 + hash="${data_array[0]}"
93015 + while [[ $index -lt $i ]]
93016 + do
93017 + echo -e "\t["$index"]\t= NULL," >> "$header1"
93018 + index=$(($index + 1))
93019 + done
93020 + index=$(($index + 1))
93021 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
93022 + done
93023 + echo '};' >> $header1
93024 +}
93025 +
93026 +create_structs
93027 +create_headers
93028 +create_array_elements
93029 +
93030 +exit 0
93031 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
93032 new file mode 100644
93033 index 0000000..568b360
93034 --- /dev/null
93035 +++ b/tools/gcc/kallocstat_plugin.c
93036 @@ -0,0 +1,170 @@
93037 +/*
93038 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
93039 + * Licensed under the GPL v2
93040 + *
93041 + * Note: the choice of the license means that the compilation process is
93042 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93043 + * but for the kernel it doesn't matter since it doesn't link against
93044 + * any of the gcc libraries
93045 + *
93046 + * gcc plugin to find the distribution of k*alloc sizes
93047 + *
93048 + * TODO:
93049 + *
93050 + * BUGS:
93051 + * - none known
93052 + */
93053 +#include "gcc-plugin.h"
93054 +#include "config.h"
93055 +#include "system.h"
93056 +#include "coretypes.h"
93057 +#include "tree.h"
93058 +#include "tree-pass.h"
93059 +#include "flags.h"
93060 +#include "intl.h"
93061 +#include "toplev.h"
93062 +#include "plugin.h"
93063 +//#include "expr.h" where are you...
93064 +#include "diagnostic.h"
93065 +#include "plugin-version.h"
93066 +#include "tm.h"
93067 +#include "function.h"
93068 +#include "basic-block.h"
93069 +#include "gimple.h"
93070 +#include "rtl.h"
93071 +#include "emit-rtl.h"
93072 +
93073 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93074 +
93075 +int plugin_is_GPL_compatible;
93076 +
93077 +static const char * const kalloc_functions[] = {
93078 + "__kmalloc",
93079 + "kmalloc",
93080 + "kmalloc_large",
93081 + "kmalloc_node",
93082 + "kmalloc_order",
93083 + "kmalloc_order_trace",
93084 + "kmalloc_slab",
93085 + "kzalloc",
93086 + "kzalloc_node",
93087 +};
93088 +
93089 +static struct plugin_info kallocstat_plugin_info = {
93090 + .version = "201302112000",
93091 +};
93092 +
93093 +static unsigned int execute_kallocstat(void);
93094 +
93095 +static struct gimple_opt_pass kallocstat_pass = {
93096 + .pass = {
93097 + .type = GIMPLE_PASS,
93098 + .name = "kallocstat",
93099 +#if BUILDING_GCC_VERSION >= 4008
93100 + .optinfo_flags = OPTGROUP_NONE,
93101 +#endif
93102 + .gate = NULL,
93103 + .execute = execute_kallocstat,
93104 + .sub = NULL,
93105 + .next = NULL,
93106 + .static_pass_number = 0,
93107 + .tv_id = TV_NONE,
93108 + .properties_required = 0,
93109 + .properties_provided = 0,
93110 + .properties_destroyed = 0,
93111 + .todo_flags_start = 0,
93112 + .todo_flags_finish = 0
93113 + }
93114 +};
93115 +
93116 +static bool is_kalloc(const char *fnname)
93117 +{
93118 + size_t i;
93119 +
93120 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
93121 + if (!strcmp(fnname, kalloc_functions[i]))
93122 + return true;
93123 + return false;
93124 +}
93125 +
93126 +static unsigned int execute_kallocstat(void)
93127 +{
93128 + basic_block bb;
93129 +
93130 + // 1. loop through BBs and GIMPLE statements
93131 + FOR_EACH_BB(bb) {
93132 + gimple_stmt_iterator gsi;
93133 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
93134 + // gimple match:
93135 + tree fndecl, size;
93136 + gimple call_stmt;
93137 + const char *fnname;
93138 +
93139 + // is it a call
93140 + call_stmt = gsi_stmt(gsi);
93141 + if (!is_gimple_call(call_stmt))
93142 + continue;
93143 + fndecl = gimple_call_fndecl(call_stmt);
93144 + if (fndecl == NULL_TREE)
93145 + continue;
93146 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
93147 + continue;
93148 +
93149 + // is it a call to k*alloc
93150 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
93151 + if (!is_kalloc(fnname))
93152 + continue;
93153 +
93154 + // is the size arg the result of a simple const assignment
93155 + size = gimple_call_arg(call_stmt, 0);
93156 + while (true) {
93157 + gimple def_stmt;
93158 + expanded_location xloc;
93159 + size_t size_val;
93160 +
93161 + if (TREE_CODE(size) != SSA_NAME)
93162 + break;
93163 + def_stmt = SSA_NAME_DEF_STMT(size);
93164 + if (!def_stmt || !is_gimple_assign(def_stmt))
93165 + break;
93166 + if (gimple_num_ops(def_stmt) != 2)
93167 + break;
93168 + size = gimple_assign_rhs1(def_stmt);
93169 + if (!TREE_CONSTANT(size))
93170 + continue;
93171 + xloc = expand_location(gimple_location(def_stmt));
93172 + if (!xloc.file)
93173 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
93174 + size_val = TREE_INT_CST_LOW(size);
93175 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
93176 + break;
93177 + }
93178 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
93179 +//debug_tree(gimple_call_fn(call_stmt));
93180 +//print_node(stderr, "pax", fndecl, 4);
93181 + }
93182 + }
93183 +
93184 + return 0;
93185 +}
93186 +
93187 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93188 +{
93189 + const char * const plugin_name = plugin_info->base_name;
93190 + struct register_pass_info kallocstat_pass_info = {
93191 + .pass = &kallocstat_pass.pass,
93192 + .reference_pass_name = "ssa",
93193 + .ref_pass_instance_number = 1,
93194 + .pos_op = PASS_POS_INSERT_AFTER
93195 + };
93196 +
93197 + if (!plugin_default_version_check(version, &gcc_version)) {
93198 + error(G_("incompatible gcc/plugin versions"));
93199 + return 1;
93200 + }
93201 +
93202 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
93203 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
93204 +
93205 + return 0;
93206 +}
93207 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
93208 new file mode 100644
93209 index 0000000..0408e06
93210 --- /dev/null
93211 +++ b/tools/gcc/kernexec_plugin.c
93212 @@ -0,0 +1,465 @@
93213 +/*
93214 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
93215 + * Licensed under the GPL v2
93216 + *
93217 + * Note: the choice of the license means that the compilation process is
93218 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93219 + * but for the kernel it doesn't matter since it doesn't link against
93220 + * any of the gcc libraries
93221 + *
93222 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
93223 + *
93224 + * TODO:
93225 + *
93226 + * BUGS:
93227 + * - none known
93228 + */
93229 +#include "gcc-plugin.h"
93230 +#include "config.h"
93231 +#include "system.h"
93232 +#include "coretypes.h"
93233 +#include "tree.h"
93234 +#include "tree-pass.h"
93235 +#include "flags.h"
93236 +#include "intl.h"
93237 +#include "toplev.h"
93238 +#include "plugin.h"
93239 +//#include "expr.h" where are you...
93240 +#include "diagnostic.h"
93241 +#include "plugin-version.h"
93242 +#include "tm.h"
93243 +#include "function.h"
93244 +#include "basic-block.h"
93245 +#include "gimple.h"
93246 +#include "rtl.h"
93247 +#include "emit-rtl.h"
93248 +#include "tree-flow.h"
93249 +
93250 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93251 +extern rtx emit_move_insn(rtx x, rtx y);
93252 +
93253 +#if BUILDING_GCC_VERSION <= 4006
93254 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
93255 +#endif
93256 +
93257 +#if BUILDING_GCC_VERSION >= 4008
93258 +#define TODO_dump_func 0
93259 +#endif
93260 +
93261 +int plugin_is_GPL_compatible;
93262 +
93263 +static struct plugin_info kernexec_plugin_info = {
93264 + .version = "201302112000",
93265 + .help = "method=[bts|or]\tinstrumentation method\n"
93266 +};
93267 +
93268 +static unsigned int execute_kernexec_reload(void);
93269 +static unsigned int execute_kernexec_fptr(void);
93270 +static unsigned int execute_kernexec_retaddr(void);
93271 +static bool kernexec_cmodel_check(void);
93272 +
93273 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
93274 +static void (*kernexec_instrument_retaddr)(rtx);
93275 +
93276 +static struct gimple_opt_pass kernexec_reload_pass = {
93277 + .pass = {
93278 + .type = GIMPLE_PASS,
93279 + .name = "kernexec_reload",
93280 +#if BUILDING_GCC_VERSION >= 4008
93281 + .optinfo_flags = OPTGROUP_NONE,
93282 +#endif
93283 + .gate = kernexec_cmodel_check,
93284 + .execute = execute_kernexec_reload,
93285 + .sub = NULL,
93286 + .next = NULL,
93287 + .static_pass_number = 0,
93288 + .tv_id = TV_NONE,
93289 + .properties_required = 0,
93290 + .properties_provided = 0,
93291 + .properties_destroyed = 0,
93292 + .todo_flags_start = 0,
93293 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
93294 + }
93295 +};
93296 +
93297 +static struct gimple_opt_pass kernexec_fptr_pass = {
93298 + .pass = {
93299 + .type = GIMPLE_PASS,
93300 + .name = "kernexec_fptr",
93301 +#if BUILDING_GCC_VERSION >= 4008
93302 + .optinfo_flags = OPTGROUP_NONE,
93303 +#endif
93304 + .gate = kernexec_cmodel_check,
93305 + .execute = execute_kernexec_fptr,
93306 + .sub = NULL,
93307 + .next = NULL,
93308 + .static_pass_number = 0,
93309 + .tv_id = TV_NONE,
93310 + .properties_required = 0,
93311 + .properties_provided = 0,
93312 + .properties_destroyed = 0,
93313 + .todo_flags_start = 0,
93314 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
93315 + }
93316 +};
93317 +
93318 +static struct rtl_opt_pass kernexec_retaddr_pass = {
93319 + .pass = {
93320 + .type = RTL_PASS,
93321 + .name = "kernexec_retaddr",
93322 +#if BUILDING_GCC_VERSION >= 4008
93323 + .optinfo_flags = OPTGROUP_NONE,
93324 +#endif
93325 + .gate = kernexec_cmodel_check,
93326 + .execute = execute_kernexec_retaddr,
93327 + .sub = NULL,
93328 + .next = NULL,
93329 + .static_pass_number = 0,
93330 + .tv_id = TV_NONE,
93331 + .properties_required = 0,
93332 + .properties_provided = 0,
93333 + .properties_destroyed = 0,
93334 + .todo_flags_start = 0,
93335 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
93336 + }
93337 +};
93338 +
93339 +static bool kernexec_cmodel_check(void)
93340 +{
93341 + tree section;
93342 +
93343 + if (ix86_cmodel != CM_KERNEL)
93344 + return false;
93345 +
93346 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
93347 + if (!section || !TREE_VALUE(section))
93348 + return true;
93349 +
93350 + section = TREE_VALUE(TREE_VALUE(section));
93351 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
93352 + return true;
93353 +
93354 + return false;
93355 +}
93356 +
93357 +/*
93358 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
93359 + */
93360 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
93361 +{
93362 + gimple asm_movabs_stmt;
93363 +
93364 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
93365 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
93366 + gimple_asm_set_volatile(asm_movabs_stmt, true);
93367 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
93368 + update_stmt(asm_movabs_stmt);
93369 +}
93370 +
93371 +/*
93372 + * find all asm() stmts that clobber r10 and add a reload of r10
93373 + */
93374 +static unsigned int execute_kernexec_reload(void)
93375 +{
93376 + basic_block bb;
93377 +
93378 + // 1. loop through BBs and GIMPLE statements
93379 + FOR_EACH_BB(bb) {
93380 + gimple_stmt_iterator gsi;
93381 +
93382 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
93383 + // gimple match: __asm__ ("" : : : "r10");
93384 + gimple asm_stmt;
93385 + size_t nclobbers;
93386 +
93387 + // is it an asm ...
93388 + asm_stmt = gsi_stmt(gsi);
93389 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
93390 + continue;
93391 +
93392 + // ... clobbering r10
93393 + nclobbers = gimple_asm_nclobbers(asm_stmt);
93394 + while (nclobbers--) {
93395 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
93396 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
93397 + continue;
93398 + kernexec_reload_fptr_mask(&gsi);
93399 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
93400 + break;
93401 + }
93402 + }
93403 + }
93404 +
93405 + return 0;
93406 +}
93407 +
93408 +/*
93409 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
93410 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
93411 + */
93412 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
93413 +{
93414 + gimple assign_intptr, assign_new_fptr, call_stmt;
93415 + tree intptr, old_fptr, new_fptr, kernexec_mask;
93416 +
93417 + call_stmt = gsi_stmt(*gsi);
93418 + old_fptr = gimple_call_fn(call_stmt);
93419 +
93420 + // create temporary unsigned long variable used for bitops and cast fptr to it
93421 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
93422 +#if BUILDING_GCC_VERSION <= 4007
93423 + add_referenced_var(intptr);
93424 + mark_sym_for_renaming(intptr);
93425 +#endif
93426 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
93427 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
93428 + update_stmt(assign_intptr);
93429 +
93430 + // apply logical or to temporary unsigned long and bitmask
93431 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
93432 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
93433 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
93434 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
93435 + update_stmt(assign_intptr);
93436 +
93437 + // cast temporary unsigned long back to a temporary fptr variable
93438 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
93439 +#if BUILDING_GCC_VERSION <= 4007
93440 + add_referenced_var(new_fptr);
93441 + mark_sym_for_renaming(new_fptr);
93442 +#endif
93443 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
93444 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
93445 + update_stmt(assign_new_fptr);
93446 +
93447 + // replace call stmt fn with the new fptr
93448 + gimple_call_set_fn(call_stmt, new_fptr);
93449 + update_stmt(call_stmt);
93450 +}
93451 +
93452 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
93453 +{
93454 + gimple asm_or_stmt, call_stmt;
93455 + tree old_fptr, new_fptr, input, output;
93456 +#if BUILDING_GCC_VERSION <= 4007
93457 + VEC(tree, gc) *inputs = NULL;
93458 + VEC(tree, gc) *outputs = NULL;
93459 +#else
93460 + vec<tree, va_gc> *inputs = NULL;
93461 + vec<tree, va_gc> *outputs = NULL;
93462 +#endif
93463 +
93464 + call_stmt = gsi_stmt(*gsi);
93465 + old_fptr = gimple_call_fn(call_stmt);
93466 +
93467 + // create temporary fptr variable
93468 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
93469 +#if BUILDING_GCC_VERSION <= 4007
93470 + add_referenced_var(new_fptr);
93471 + mark_sym_for_renaming(new_fptr);
93472 +#endif
93473 +
93474 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
93475 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
93476 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
93477 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
93478 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
93479 +#if BUILDING_GCC_VERSION <= 4007
93480 + VEC_safe_push(tree, gc, inputs, input);
93481 + VEC_safe_push(tree, gc, outputs, output);
93482 +#else
93483 + vec_safe_push(inputs, input);
93484 + vec_safe_push(outputs, output);
93485 +#endif
93486 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
93487 + gimple_asm_set_volatile(asm_or_stmt, true);
93488 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
93489 + update_stmt(asm_or_stmt);
93490 +
93491 + // replace call stmt fn with the new fptr
93492 + gimple_call_set_fn(call_stmt, new_fptr);
93493 + update_stmt(call_stmt);
93494 +}
93495 +
93496 +/*
93497 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
93498 + */
93499 +static unsigned int execute_kernexec_fptr(void)
93500 +{
93501 + basic_block bb;
93502 +
93503 + // 1. loop through BBs and GIMPLE statements
93504 + FOR_EACH_BB(bb) {
93505 + gimple_stmt_iterator gsi;
93506 +
93507 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
93508 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
93509 + tree fn;
93510 + gimple call_stmt;
93511 +
93512 + // is it a call ...
93513 + call_stmt = gsi_stmt(gsi);
93514 + if (!is_gimple_call(call_stmt))
93515 + continue;
93516 + fn = gimple_call_fn(call_stmt);
93517 + if (TREE_CODE(fn) == ADDR_EXPR)
93518 + continue;
93519 + if (TREE_CODE(fn) != SSA_NAME)
93520 + gcc_unreachable();
93521 +
93522 + // ... through a function pointer
93523 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
93524 + fn = SSA_NAME_VAR(fn);
93525 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
93526 + debug_tree(fn);
93527 + gcc_unreachable();
93528 + }
93529 + }
93530 + fn = TREE_TYPE(fn);
93531 + if (TREE_CODE(fn) != POINTER_TYPE)
93532 + continue;
93533 + fn = TREE_TYPE(fn);
93534 + if (TREE_CODE(fn) != FUNCTION_TYPE)
93535 + continue;
93536 +
93537 + kernexec_instrument_fptr(&gsi);
93538 +
93539 +//debug_tree(gimple_call_fn(call_stmt));
93540 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
93541 + }
93542 + }
93543 +
93544 + return 0;
93545 +}
93546 +
93547 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
93548 +static void kernexec_instrument_retaddr_bts(rtx insn)
93549 +{
93550 + rtx btsq;
93551 + rtvec argvec, constraintvec, labelvec;
93552 + int line;
93553 +
93554 + // create asm volatile("btsq $63,(%%rsp)":::)
93555 + argvec = rtvec_alloc(0);
93556 + constraintvec = rtvec_alloc(0);
93557 + labelvec = rtvec_alloc(0);
93558 + line = expand_location(RTL_LOCATION(insn)).line;
93559 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
93560 + MEM_VOLATILE_P(btsq) = 1;
93561 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
93562 + emit_insn_before(btsq, insn);
93563 +}
93564 +
93565 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
93566 +static void kernexec_instrument_retaddr_or(rtx insn)
93567 +{
93568 + rtx orq;
93569 + rtvec argvec, constraintvec, labelvec;
93570 + int line;
93571 +
93572 + // create asm volatile("orq %%r10,(%%rsp)":::)
93573 + argvec = rtvec_alloc(0);
93574 + constraintvec = rtvec_alloc(0);
93575 + labelvec = rtvec_alloc(0);
93576 + line = expand_location(RTL_LOCATION(insn)).line;
93577 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
93578 + MEM_VOLATILE_P(orq) = 1;
93579 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
93580 + emit_insn_before(orq, insn);
93581 +}
93582 +
93583 +/*
93584 + * find all asm level function returns and forcibly set the highest bit of the return address
93585 + */
93586 +static unsigned int execute_kernexec_retaddr(void)
93587 +{
93588 + rtx insn;
93589 +
93590 + // 1. find function returns
93591 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
93592 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
93593 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
93594 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
93595 + rtx body;
93596 +
93597 + // is it a retn
93598 + if (!JUMP_P(insn))
93599 + continue;
93600 + body = PATTERN(insn);
93601 + if (GET_CODE(body) == PARALLEL)
93602 + body = XVECEXP(body, 0, 0);
93603 + if (!ANY_RETURN_P(body))
93604 + continue;
93605 + kernexec_instrument_retaddr(insn);
93606 + }
93607 +
93608 +// print_simple_rtl(stderr, get_insns());
93609 +// print_rtl(stderr, get_insns());
93610 +
93611 + return 0;
93612 +}
93613 +
93614 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93615 +{
93616 + const char * const plugin_name = plugin_info->base_name;
93617 + const int argc = plugin_info->argc;
93618 + const struct plugin_argument * const argv = plugin_info->argv;
93619 + int i;
93620 + struct register_pass_info kernexec_reload_pass_info = {
93621 + .pass = &kernexec_reload_pass.pass,
93622 + .reference_pass_name = "ssa",
93623 + .ref_pass_instance_number = 1,
93624 + .pos_op = PASS_POS_INSERT_AFTER
93625 + };
93626 + struct register_pass_info kernexec_fptr_pass_info = {
93627 + .pass = &kernexec_fptr_pass.pass,
93628 + .reference_pass_name = "ssa",
93629 + .ref_pass_instance_number = 1,
93630 + .pos_op = PASS_POS_INSERT_AFTER
93631 + };
93632 + struct register_pass_info kernexec_retaddr_pass_info = {
93633 + .pass = &kernexec_retaddr_pass.pass,
93634 + .reference_pass_name = "pro_and_epilogue",
93635 + .ref_pass_instance_number = 1,
93636 + .pos_op = PASS_POS_INSERT_AFTER
93637 + };
93638 +
93639 + if (!plugin_default_version_check(version, &gcc_version)) {
93640 + error(G_("incompatible gcc/plugin versions"));
93641 + return 1;
93642 + }
93643 +
93644 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
93645 +
93646 + if (TARGET_64BIT == 0)
93647 + return 0;
93648 +
93649 + for (i = 0; i < argc; ++i) {
93650 + if (!strcmp(argv[i].key, "method")) {
93651 + if (!argv[i].value) {
93652 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93653 + continue;
93654 + }
93655 + if (!strcmp(argv[i].value, "bts")) {
93656 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
93657 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
93658 + } else if (!strcmp(argv[i].value, "or")) {
93659 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
93660 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
93661 + fix_register("r10", 1, 1);
93662 + } else
93663 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
93664 + continue;
93665 + }
93666 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93667 + }
93668 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
93669 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
93670 +
93671 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
93672 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
93673 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
93674 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
93675 +
93676 + return 0;
93677 +}
93678 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
93679 new file mode 100644
93680 index 0000000..b5395ba
93681 --- /dev/null
93682 +++ b/tools/gcc/latent_entropy_plugin.c
93683 @@ -0,0 +1,327 @@
93684 +/*
93685 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
93686 + * Licensed under the GPL v2
93687 + *
93688 + * Note: the choice of the license means that the compilation process is
93689 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93690 + * but for the kernel it doesn't matter since it doesn't link against
93691 + * any of the gcc libraries
93692 + *
93693 + * gcc plugin to help generate a little bit of entropy from program state,
93694 + * used during boot in the kernel
93695 + *
93696 + * TODO:
93697 + * - add ipa pass to identify not explicitly marked candidate functions
93698 + * - mix in more program state (function arguments/return values, loop variables, etc)
93699 + * - more instrumentation control via attribute parameters
93700 + *
93701 + * BUGS:
93702 + * - LTO needs -flto-partition=none for now
93703 + */
93704 +#include "gcc-plugin.h"
93705 +#include "config.h"
93706 +#include "system.h"
93707 +#include "coretypes.h"
93708 +#include "tree.h"
93709 +#include "tree-pass.h"
93710 +#include "flags.h"
93711 +#include "intl.h"
93712 +#include "toplev.h"
93713 +#include "plugin.h"
93714 +//#include "expr.h" where are you...
93715 +#include "diagnostic.h"
93716 +#include "plugin-version.h"
93717 +#include "tm.h"
93718 +#include "function.h"
93719 +#include "basic-block.h"
93720 +#include "gimple.h"
93721 +#include "rtl.h"
93722 +#include "emit-rtl.h"
93723 +#include "tree-flow.h"
93724 +#include "langhooks.h"
93725 +
93726 +#if BUILDING_GCC_VERSION >= 4008
93727 +#define TODO_dump_func 0
93728 +#endif
93729 +
93730 +int plugin_is_GPL_compatible;
93731 +
93732 +static tree latent_entropy_decl;
93733 +
93734 +static struct plugin_info latent_entropy_plugin_info = {
93735 + .version = "201303102320",
93736 + .help = NULL
93737 +};
93738 +
93739 +static unsigned int execute_latent_entropy(void);
93740 +static bool gate_latent_entropy(void);
93741 +
93742 +static struct gimple_opt_pass latent_entropy_pass = {
93743 + .pass = {
93744 + .type = GIMPLE_PASS,
93745 + .name = "latent_entropy",
93746 +#if BUILDING_GCC_VERSION >= 4008
93747 + .optinfo_flags = OPTGROUP_NONE,
93748 +#endif
93749 + .gate = gate_latent_entropy,
93750 + .execute = execute_latent_entropy,
93751 + .sub = NULL,
93752 + .next = NULL,
93753 + .static_pass_number = 0,
93754 + .tv_id = TV_NONE,
93755 + .properties_required = PROP_gimple_leh | PROP_cfg,
93756 + .properties_provided = 0,
93757 + .properties_destroyed = 0,
93758 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
93759 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
93760 + }
93761 +};
93762 +
93763 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
93764 +{
93765 + if (TREE_CODE(*node) != FUNCTION_DECL) {
93766 + *no_add_attrs = true;
93767 + error("%qE attribute only applies to functions", name);
93768 + }
93769 + return NULL_TREE;
93770 +}
93771 +
93772 +static struct attribute_spec latent_entropy_attr = {
93773 + .name = "latent_entropy",
93774 + .min_length = 0,
93775 + .max_length = 0,
93776 + .decl_required = true,
93777 + .type_required = false,
93778 + .function_type_required = false,
93779 + .handler = handle_latent_entropy_attribute,
93780 +#if BUILDING_GCC_VERSION >= 4007
93781 + .affects_type_identity = false
93782 +#endif
93783 +};
93784 +
93785 +static void register_attributes(void *event_data, void *data)
93786 +{
93787 + register_attribute(&latent_entropy_attr);
93788 +}
93789 +
93790 +static bool gate_latent_entropy(void)
93791 +{
93792 + tree latent_entropy_attr;
93793 +
93794 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
93795 + return latent_entropy_attr != NULL_TREE;
93796 +}
93797 +
93798 +static unsigned HOST_WIDE_INT seed;
93799 +static unsigned HOST_WIDE_INT get_random_const(void)
93800 +{
93801 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
93802 + return seed;
93803 +}
93804 +
93805 +static enum tree_code get_op(tree *rhs)
93806 +{
93807 + static enum tree_code op;
93808 + unsigned HOST_WIDE_INT random_const;
93809 +
93810 + random_const = get_random_const();
93811 +
93812 + switch (op) {
93813 + case BIT_XOR_EXPR:
93814 + op = PLUS_EXPR;
93815 + break;
93816 +
93817 + case PLUS_EXPR:
93818 + if (rhs) {
93819 + op = LROTATE_EXPR;
93820 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
93821 + break;
93822 + }
93823 +
93824 + case LROTATE_EXPR:
93825 + default:
93826 + op = BIT_XOR_EXPR;
93827 + break;
93828 + }
93829 + if (rhs)
93830 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
93831 + return op;
93832 +}
93833 +
93834 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
93835 +{
93836 + gimple_stmt_iterator gsi;
93837 + gimple assign;
93838 + tree addxorrol, rhs;
93839 + enum tree_code op;
93840 +
93841 + op = get_op(&rhs);
93842 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
93843 + assign = gimple_build_assign(local_entropy, addxorrol);
93844 +#if BUILDING_GCC_VERSION <= 4007
93845 + find_referenced_vars_in(assign);
93846 +#endif
93847 +//debug_bb(bb);
93848 + gsi = gsi_after_labels(bb);
93849 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
93850 + update_stmt(assign);
93851 +}
93852 +
93853 +static void perturb_latent_entropy(basic_block bb, tree rhs)
93854 +{
93855 + gimple_stmt_iterator gsi;
93856 + gimple assign;
93857 + tree addxorrol, temp;
93858 +
93859 + // 1. create temporary copy of latent_entropy
93860 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
93861 +#if BUILDING_GCC_VERSION <= 4007
93862 + add_referenced_var(temp);
93863 + mark_sym_for_renaming(temp);
93864 +#endif
93865 +
93866 + // 2. read...
93867 + assign = gimple_build_assign(temp, latent_entropy_decl);
93868 +#if BUILDING_GCC_VERSION <= 4007
93869 + find_referenced_vars_in(assign);
93870 +#endif
93871 + gsi = gsi_after_labels(bb);
93872 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
93873 + update_stmt(assign);
93874 +
93875 + // 3. ...modify...
93876 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
93877 + assign = gimple_build_assign(temp, addxorrol);
93878 +#if BUILDING_GCC_VERSION <= 4007
93879 + find_referenced_vars_in(assign);
93880 +#endif
93881 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
93882 + update_stmt(assign);
93883 +
93884 + // 4. ...write latent_entropy
93885 + assign = gimple_build_assign(latent_entropy_decl, temp);
93886 +#if BUILDING_GCC_VERSION <= 4007
93887 + find_referenced_vars_in(assign);
93888 +#endif
93889 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
93890 + update_stmt(assign);
93891 +}
93892 +
93893 +static unsigned int execute_latent_entropy(void)
93894 +{
93895 + basic_block bb;
93896 + gimple assign;
93897 + gimple_stmt_iterator gsi;
93898 + tree local_entropy;
93899 +
93900 + if (!latent_entropy_decl) {
93901 + struct varpool_node *node;
93902 +
93903 +#if BUILDING_GCC_VERSION <= 4007
93904 + for (node = varpool_nodes; node; node = node->next) {
93905 + tree var = node->decl;
93906 +#else
93907 + FOR_EACH_VARIABLE(node) {
93908 + tree var = node->symbol.decl;
93909 +#endif
93910 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
93911 + continue;
93912 + latent_entropy_decl = var;
93913 +// debug_tree(var);
93914 + break;
93915 + }
93916 + if (!latent_entropy_decl) {
93917 +// debug_tree(current_function_decl);
93918 + return 0;
93919 + }
93920 + }
93921 +
93922 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
93923 +
93924 + // 1. create local entropy variable
93925 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
93926 +#if BUILDING_GCC_VERSION <= 4007
93927 + add_referenced_var(local_entropy);
93928 + mark_sym_for_renaming(local_entropy);
93929 +#endif
93930 +
93931 + // 2. initialize local entropy variable
93932 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
93933 + if (dom_info_available_p(CDI_DOMINATORS))
93934 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
93935 + gsi = gsi_start_bb(bb);
93936 +
93937 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
93938 +// gimple_set_location(assign, loc);
93939 +#if BUILDING_GCC_VERSION <= 4007
93940 + find_referenced_vars_in(assign);
93941 +#endif
93942 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
93943 + update_stmt(assign);
93944 + bb = bb->next_bb;
93945 +
93946 + // 3. instrument each BB with an operation on the local entropy variable
93947 + while (bb != EXIT_BLOCK_PTR) {
93948 + perturb_local_entropy(bb, local_entropy);
93949 + bb = bb->next_bb;
93950 + };
93951 +
93952 + // 4. mix local entropy into the global entropy variable
93953 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
93954 + return 0;
93955 +}
93956 +
93957 +static void start_unit_callback(void *gcc_data, void *user_data)
93958 +{
93959 + tree latent_entropy_type;
93960 +
93961 +#if BUILDING_GCC_VERSION >= 4007
93962 + seed = get_random_seed(false);
93963 +#else
93964 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
93965 + seed *= seed;
93966 +#endif
93967 +
93968 + if (in_lto_p)
93969 + return;
93970 +
93971 + // extern volatile u64 latent_entropy
93972 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
93973 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
93974 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
93975 +
93976 + TREE_STATIC(latent_entropy_decl) = 1;
93977 + TREE_PUBLIC(latent_entropy_decl) = 1;
93978 + TREE_USED(latent_entropy_decl) = 1;
93979 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
93980 + DECL_EXTERNAL(latent_entropy_decl) = 1;
93981 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
93982 + DECL_INITIAL(latent_entropy_decl) = NULL;
93983 + lang_hooks.decls.pushdecl(latent_entropy_decl);
93984 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
93985 +// varpool_finalize_decl(latent_entropy_decl);
93986 +// varpool_mark_needed_node(latent_entropy_decl);
93987 +}
93988 +
93989 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93990 +{
93991 + const char * const plugin_name = plugin_info->base_name;
93992 + struct register_pass_info latent_entropy_pass_info = {
93993 + .pass = &latent_entropy_pass.pass,
93994 + .reference_pass_name = "optimized",
93995 + .ref_pass_instance_number = 1,
93996 + .pos_op = PASS_POS_INSERT_BEFORE
93997 + };
93998 +
93999 + if (!plugin_default_version_check(version, &gcc_version)) {
94000 + error(G_("incompatible gcc/plugin versions"));
94001 + return 1;
94002 + }
94003 +
94004 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
94005 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
94006 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
94007 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
94008 +
94009 + return 0;
94010 +}
94011 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
94012 new file mode 100644
94013 index 0000000..ddd5b2e
94014 --- /dev/null
94015 +++ b/tools/gcc/size_overflow_hash.data
94016 @@ -0,0 +1,5876 @@
94017 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
94018 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
94019 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
94020 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
94021 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
94022 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
94023 +padzero_55 padzero 1 55 &sel_read_policyvers_55
94024 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
94025 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
94026 +DepcaSignature_80 DepcaSignature 2 80 NULL nohasharray
94027 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 &DepcaSignature_80
94028 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
94029 +load_msg_95 load_msg 2 95 NULL
94030 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
94031 +init_q_132 init_q 4 132 NULL
94032 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
94033 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
94034 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
94035 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
94036 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
94037 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
94038 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
94039 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
94040 +br_port_info_size_268 br_port_info_size 0 268 NULL
94041 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
94042 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
94043 +syslog_print_307 syslog_print 2 307 NULL
94044 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
94045 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
94046 +next_node_allowed_318 next_node_allowed 1 318 NULL
94047 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
94048 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
94049 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
94050 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
94051 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
94052 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
94053 +pidlist_resize_496 pidlist_resize 2 496 NULL
94054 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
94055 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
94056 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
94057 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
94058 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
94059 +dle_count_543 dle_count 0 543 NULL
94060 +devres_alloc_551 devres_alloc 2 551 NULL
94061 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
94062 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
94063 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
94064 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
94065 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
94066 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
94067 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
94068 +isp1760_register_628 isp1760_register 1-2 628 NULL
94069 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
94070 +unlink_queued_645 unlink_queued 3-4 645 NULL
94071 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
94072 +ceph_copy_user_to_page_vector_656 ceph_copy_user_to_page_vector 4-3 656 NULL
94073 +div_u64_rem_672 div_u64_rem 0 672 NULL
94074 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
94075 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
94076 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
94077 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
94078 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
94079 +wm8962_gpio_direction_out_738 wm8962_gpio_direction_out 2 738 NULL
94080 +dvb_video_write_754 dvb_video_write 3 754 NULL
94081 +iwl_read_targ_mem_772 iwl_read_targ_mem 0 772 NULL
94082 +snd_pcm_drain_811 snd_pcm_drain 0 811 NULL
94083 +if_writecmd_815 if_writecmd 2 815 NULL
94084 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
94085 +read_fifo_826 read_fifo 3 826 NULL
94086 +read_tree_block_841 read_tree_block 3 841 NULL
94087 +um_idi_read_850 um_idi_read 3 850 NULL
94088 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
94089 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
94090 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
94091 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
94092 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
94093 +readw_931 readw 0 931 NULL
94094 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
94095 +ieee80211_ie_build_vht_cap_956 ieee80211_ie_build_vht_cap 0 956 NULL nohasharray
94096 +__nodes_weight_956 __nodes_weight 2-0 956 &ieee80211_ie_build_vht_cap_956
94097 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
94098 +hdlcdev_rx_997 hdlcdev_rx 3 997 NULL
94099 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
94100 +lp872x_select_buck_vout_addr_1045 lp872x_select_buck_vout_addr 0 1045 NULL
94101 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
94102 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
94103 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
94104 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
94105 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
94106 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
94107 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
94108 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
94109 +store_risefalltime_1109 store_risefalltime 5 1109 NULL
94110 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
94111 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
94112 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
94113 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
94114 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
94115 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
94116 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
94117 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
94118 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
94119 +thin_status_1239 thin_status 5 1239 NULL
94120 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
94121 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
94122 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
94123 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
94124 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
94125 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
94126 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
94127 +ffs_1322 ffs 0 1322 NULL
94128 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
94129 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
94130 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
94131 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
94132 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
94133 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
94134 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
94135 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
94136 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
94137 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
94138 +zone_page_state_1393 zone_page_state 0 1393 NULL
94139 +file_read_actor_1401 file_read_actor 4 1401 NULL
94140 +lm3533_als_get_threshold_reg_1404 lm3533_als_get_threshold_reg 0-1 1404 NULL
94141 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
94142 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
94143 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
94144 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
94145 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
94146 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
94147 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
94148 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
94149 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
94150 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
94151 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
94152 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
94153 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
94154 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
94155 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
94156 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
94157 +rmap_add_1677 rmap_add 3 1677 NULL
94158 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
94159 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
94160 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
94161 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
94162 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
94163 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
94164 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
94165 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
94166 +cosa_write_1774 cosa_write 3 1774 NULL
94167 +update_macheader_1775 update_macheader 7 1775 NULL
94168 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
94169 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
94170 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
94171 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
94172 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
94173 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
94174 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
94175 +read_swap_header_1957 read_swap_header 0 1957 NULL
94176 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
94177 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
94178 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
94179 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
94180 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
94181 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
94182 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
94183 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
94184 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
94185 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
94186 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
94187 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
94188 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
94189 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
94190 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
94191 +get_unaligned_le32_2092 get_unaligned_le32 0 2092 NULL
94192 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
94193 +audit_expand_2098 audit_expand 2 2098 NULL
94194 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
94195 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
94196 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
94197 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
94198 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
94199 +pcf50633_write_block_2124 pcf50633_write_block 3-2 2124 NULL
94200 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
94201 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL nohasharray
94202 +multipath_status_2151 multipath_status 5 2151 &mlx4_init_icm_table_2151
94203 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
94204 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
94205 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
94206 +u32_array_read_2219 u32_array_read 3 2219 NULL
94207 +vhci_write_2224 vhci_write 3 2224 NULL
94208 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
94209 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
94210 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
94211 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
94212 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
94213 +do_update_counters_2259 do_update_counters 4 2259 NULL
94214 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
94215 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
94216 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4 2308 NULL
94217 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
94218 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
94219 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
94220 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
94221 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
94222 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
94223 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
94224 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
94225 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
94226 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
94227 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
94228 +raid1_size_2419 raid1_size 0-2 2419 NULL
94229 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
94230 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
94231 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
94232 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
94233 +nfs4_alloc_slots_2454 nfs4_alloc_slots 1 2454 NULL nohasharray
94234 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 &nfs4_alloc_slots_2454
94235 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
94236 +update_pmkid_2481 update_pmkid 4 2481 NULL
94237 +wiphy_new_2482 wiphy_new 2 2482 NULL
94238 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
94239 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
94240 +dm_write_2513 dm_write 3 2513 NULL
94241 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
94242 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
94243 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
94244 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
94245 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
94246 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
94247 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
94248 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
94249 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
94250 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
94251 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
94252 +__next_cpu_2782 __next_cpu 1 2782 NULL
94253 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
94254 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL nohasharray
94255 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 &vb2_dc_get_userptr_2829
94256 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
94257 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
94258 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
94259 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
94260 +__swab64p_2875 __swab64p 0 2875 NULL
94261 +nla_padlen_2883 nla_padlen 1 2883 NULL
94262 +cmm_write_2896 cmm_write 3 2896 NULL
94263 +rbd_req_sync_read_2915 rbd_req_sync_read 4-5 2915 NULL
94264 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
94265 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
94266 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
94267 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
94268 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
94269 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
94270 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
94271 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
94272 +depth_write_3021 depth_write 3 3021 NULL
94273 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
94274 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
94275 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
94276 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
94277 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
94278 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
94279 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
94280 +free_coherent_3082 free_coherent 4-2 3082 NULL
94281 +ttusb2_msg_3100 ttusb2_msg 4 3100 NULL
94282 +rb_alloc_3102 rb_alloc 1 3102 NULL
94283 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
94284 +print_time_3132 print_time 0 3132 NULL
94285 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
94286 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
94287 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
94288 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
94289 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
94290 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
94291 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
94292 +alloc_context_3194 alloc_context 1 3194 NULL
94293 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
94294 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
94295 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
94296 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
94297 +key_key_read_3241 key_key_read 3 3241 NULL
94298 +number_3243 number 0 3243 NULL
94299 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
94300 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
94301 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
94302 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
94303 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
94304 +de600_read_byte_3332 de600_read_byte 0 3332 NULL
94305 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
94306 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
94307 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
94308 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
94309 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
94310 +scnprintf_3360 scnprintf 0-2 3360 NULL nohasharray
94311 +tps65090_clr_bits_3360 tps65090_clr_bits 2 3360 &scnprintf_3360
94312 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
94313 +send_stream_3397 send_stream 4 3397 NULL
94314 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
94315 +msix_map_region_3411 msix_map_region 3 3411 NULL
94316 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
94317 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
94318 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
94319 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
94320 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
94321 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
94322 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
94323 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
94324 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
94325 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
94326 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
94327 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
94328 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
94329 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
94330 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
94331 +evtchn_read_3569 evtchn_read 3 3569 NULL
94332 +vc_resize_3585 vc_resize 2-3 3585 NULL
94333 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
94334 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
94335 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
94336 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
94337 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
94338 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
94339 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
94340 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
94341 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
94342 +ntfs_attr_make_non_resident_3694 ntfs_attr_make_non_resident 0 3694 NULL
94343 +create_irq_3703 create_irq 0 3703 NULL nohasharray
94344 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
94345 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
94346 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
94347 +lm3533_als_get_threshold_3725 lm3533_als_get_threshold 2 3725 NULL
94348 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
94349 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
94350 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
94351 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
94352 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
94353 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
94354 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
94355 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
94356 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
94357 +get_fd_set_3866 get_fd_set 1 3866 NULL
94358 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
94359 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
94360 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
94361 +nvram_write_3894 nvram_write 3 3894 NULL
94362 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
94363 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
94364 +vcs_write_3910 vcs_write 3 3910 NULL
94365 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
94366 +do_add_counters_3992 do_add_counters 3 3992 NULL
94367 +userspace_status_4004 userspace_status 4 4004 NULL
94368 +mei_write_4005 mei_write 3 4005 NULL nohasharray
94369 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
94370 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
94371 +blk_end_request_4024 blk_end_request 3 4024 NULL
94372 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
94373 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
94374 +read_file_queues_4078 read_file_queues 3 4078 NULL
94375 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
94376 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
94377 +tm6000_read_4151 tm6000_read 3 4151 NULL
94378 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
94379 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
94380 +get_alua_req_4166 get_alua_req 3 4166 NULL
94381 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
94382 +read_file_bool_4180 read_file_bool 3 4180 NULL
94383 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
94384 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
94385 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
94386 +ext4_new_inode_4247 ext4_new_inode 5 4247 NULL
94387 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
94388 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
94389 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 2-3-5 4303 NULL
94390 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
94391 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
94392 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
94393 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
94394 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
94395 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
94396 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
94397 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
94398 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
94399 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
94400 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
94401 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
94402 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
94403 +set_link_security_4502 set_link_security 4 4502 NULL
94404 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
94405 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
94406 +tty_register_device_4544 tty_register_device 2 4544 NULL
94407 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
94408 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
94409 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
94410 +bch_alloc_4593 bch_alloc 1 4593 NULL
94411 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
94412 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
94413 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
94414 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
94415 +kone_receive_4690 kone_receive 4 4690 NULL
94416 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
94417 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
94418 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
94419 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
94420 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
94421 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
94422 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
94423 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
94424 +__iio_allocate_sw_ring_buffer_4843 __iio_allocate_sw_ring_buffer 3 4843 NULL
94425 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
94426 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
94427 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
94428 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
94429 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
94430 +sys_ipc_4889 sys_ipc 3 4889 NULL
94431 +lp872x_write_byte_4914 lp872x_write_byte 2 4914 NULL
94432 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
94433 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
94434 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
94435 +da9055_reg_write_4942 da9055_reg_write 2 4942 NULL
94436 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
94437 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
94438 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
94439 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
94440 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
94441 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
94442 +lm3533_als_set_target_5010 lm3533_als_set_target 2-3 5010 NULL
94443 +do_mincore_5018 do_mincore 0-1 5018 NULL
94444 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
94445 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
94446 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
94447 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
94448 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
94449 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
94450 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
94451 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
94452 +sound_write_5102 sound_write 3 5102 NULL
94453 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
94454 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
94455 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
94456 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
94457 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
94458 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
94459 +skb_network_header_5203 skb_network_header 0 5203 NULL
94460 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
94461 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
94462 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
94463 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
94464 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
94465 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
94466 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
94467 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
94468 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
94469 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
94470 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
94471 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
94472 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
94473 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
94474 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
94475 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
94476 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
94477 +tty_write_5494 tty_write 3 5494 NULL
94478 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
94479 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
94480 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
94481 +spidev_message_5518 spidev_message 3 5518 NULL
94482 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
94483 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
94484 +le_readq_5557 le_readq 0 5557 NULL
94485 +inw_5558 inw 0 5558 NULL
94486 +__first_dma_cap_5560 __first_dma_cap 0 5560 NULL
94487 +fir16_create_5574 fir16_create 3 5574 NULL
94488 +bioset_create_5580 bioset_create 1 5580 NULL
94489 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
94490 +do_msgrcv_5590 do_msgrcv 4 5590 NULL
94491 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
94492 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
94493 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
94494 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
94495 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
94496 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
94497 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
94498 +get_arg_5694 get_arg 3 5694 NULL
94499 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
94500 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
94501 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
94502 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
94503 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
94504 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
94505 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
94506 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
94507 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
94508 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
94509 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
94510 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
94511 +setup_req_5848 setup_req 3 5848 NULL
94512 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
94513 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
94514 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
94515 +port_show_regs_5904 port_show_regs 3 5904 NULL
94516 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
94517 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
94518 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
94519 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
94520 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
94521 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
94522 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
94523 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
94524 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
94525 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
94526 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
94527 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
94528 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
94529 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
94530 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
94531 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
94532 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
94533 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
94534 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
94535 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
94536 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
94537 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
94538 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
94539 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
94540 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
94541 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
94542 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
94543 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
94544 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 0 6282 NULL nohasharray
94545 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
94546 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
94547 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
94548 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
94549 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
94550 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
94551 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
94552 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
94553 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
94554 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
94555 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 NULL
94556 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
94557 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
94558 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
94559 +mei_read_6507 mei_read 3 6507 NULL
94560 +cpumask_next_and_6516 cpumask_next_and 1 6516 NULL
94561 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
94562 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
94563 +wdm_read_6549 wdm_read 3 6549 NULL
94564 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
94565 +usb_dump_config_descriptor_6572 usb_dump_config_descriptor 0 6572 NULL
94566 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
94567 +usemap_size_6601 usemap_size 0-1 6601 NULL
94568 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
94569 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
94570 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
94571 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
94572 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
94573 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
94574 +ieee80211_build_preq_ies_6691 ieee80211_build_preq_ies 0-4 6691 NULL
94575 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
94576 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
94577 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
94578 +mpeg_read_6708 mpeg_read 3 6708 NULL
94579 +video_proc_write_6724 video_proc_write 3 6724 NULL
94580 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
94581 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
94582 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
94583 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
94584 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
94585 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
94586 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
94587 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
94588 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
94589 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
94590 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
94591 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
94592 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
94593 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
94594 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
94595 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
94596 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
94597 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
94598 +ieee80211_rx_mgmt_probe_resp_6918 ieee80211_rx_mgmt_probe_resp 3 6918 NULL
94599 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
94600 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
94601 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
94602 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
94603 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
94604 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
94605 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
94606 +request_key_async_6990 request_key_async 4 6990 NULL
94607 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
94608 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
94609 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
94610 +wimax_msg_7030 wimax_msg 4 7030 NULL
94611 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
94612 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
94613 +event_enable_read_7074 event_enable_read 3 7074 NULL
94614 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
94615 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
94616 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
94617 +check_header_7108 check_header 0 7108 NULL
94618 +utf16_strsize_7203 utf16_strsize 0 7203 NULL nohasharray
94619 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 &utf16_strsize_7203
94620 +sys32_ipc_7238 sys32_ipc 3-5-6-4 7238 NULL
94621 +get_param_h_7247 get_param_h 0 7247 NULL
94622 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
94623 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
94624 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
94625 +mgmt_control_7349 mgmt_control 3 7349 NULL
94626 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
94627 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
94628 +hweight_long_7388 hweight_long 0-1 7388 NULL
94629 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
94630 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
94631 +readb_7401 readb 0 7401 NULL
94632 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
94633 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
94634 +ms_rw_multi_sector_7459 ms_rw_multi_sector 3-4 7459 NULL
94635 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL nohasharray
94636 +wm8996_gpio_direction_out_7469 wm8996_gpio_direction_out 2 7469 &__mutex_lock_common_7469
94637 +garp_request_join_7471 garp_request_join 4 7471 NULL
94638 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
94639 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
94640 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
94641 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
94642 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
94643 +setup_usemap_7524 setup_usemap 3 7524 NULL
94644 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
94645 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
94646 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
94647 +groups_alloc_7614 groups_alloc 1 7614 NULL
94648 +sg_virt_7616 sg_virt 0 7616 NULL
94649 +cpumask_first_7648 cpumask_first 0 7648 NULL
94650 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
94651 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
94652 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
94653 +dev_write_7708 dev_write 3 7708 NULL
94654 +tps65090_set_bits_7709 tps65090_set_bits 2 7709 NULL
94655 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL nohasharray
94656 +dbg_check_cats_7713 dbg_check_cats 0 7713 &brcmf_sdcard_send_buf_7713
94657 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
94658 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
94659 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
94660 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
94661 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
94662 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
94663 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
94664 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
94665 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
94666 +da9052_reg_update_7858 da9052_reg_update 2 7858 NULL
94667 +tps6586x_clr_bits_7889 tps6586x_clr_bits 2 7889 NULL
94668 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
94669 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
94670 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
94671 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
94672 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
94673 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
94674 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
94675 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
94676 +sys_mbind_7990 sys_mbind 5 7990 NULL
94677 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
94678 +vcs_read_8017 vcs_read 3 8017 NULL
94679 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
94680 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
94681 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
94682 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
94683 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
94684 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
94685 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
94686 +venus_lookup_8121 venus_lookup 4 8121 NULL
94687 +lm3533_als_set_threshold_8125 lm3533_als_set_threshold 2 8125 NULL
94688 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
94689 +ext_sd_execute_write_data_8175 ext_sd_execute_write_data 9 8175 NULL
94690 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
94691 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
94692 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
94693 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
94694 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
94695 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
94696 +play_iframe_8219 play_iframe 3 8219 NULL
94697 +create_log_8225 create_log 2 8225 NULL nohasharray
94698 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
94699 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
94700 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
94701 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
94702 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
94703 +init_cdev_8274 init_cdev 1 8274 NULL
94704 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
94705 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
94706 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
94707 +lm3533_led_get_pattern_8321 lm3533_led_get_pattern 0 8321 NULL nohasharray
94708 +construct_key_and_link_8321 construct_key_and_link 4 8321 &lm3533_led_get_pattern_8321
94709 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
94710 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
94711 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
94712 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
94713 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
94714 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
94715 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
94716 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
94717 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
94718 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
94719 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
94720 +_irq_to_enable_addr_8485 _irq_to_enable_addr 0-1 8485 NULL
94721 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
94722 +dev_config_8506 dev_config 3 8506 NULL
94723 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
94724 +utf16_strnlen_8513 utf16_strnlen 0 8513 NULL
94725 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
94726 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
94727 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
94728 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
94729 +profile_remove_8556 profile_remove 3 8556 NULL
94730 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
94731 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
94732 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
94733 +tower_write_8580 tower_write 3 8580 NULL
94734 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
94735 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
94736 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
94737 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
94738 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
94739 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
94740 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
94741 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
94742 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
94743 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
94744 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
94745 +arcfb_write_8702 arcfb_write 3 8702 NULL
94746 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
94747 +init_header_8703 init_header 0 8703 &i_size_read_8703
94748 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
94749 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL nohasharray
94750 +snapshot_status_8729 snapshot_status 5 8729 &jffs2_acl_count_8729
94751 +f_dupfd_8730 f_dupfd 1 8730 NULL
94752 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
94753 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
94754 +sys_prctl_8766 sys_prctl 4 8766 NULL
94755 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
94756 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
94757 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
94758 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
94759 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
94760 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
94761 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
94762 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
94763 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
94764 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
94765 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
94766 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
94767 +send_pages_8872 send_pages 3 8872 NULL
94768 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
94769 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
94770 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
94771 +layout_commit_8926 layout_commit 3 8926 NULL
94772 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
94773 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
94774 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
94775 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
94776 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
94777 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
94778 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
94779 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
94780 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
94781 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
94782 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
94783 +palmas_ldo_write_9012 palmas_ldo_write 2 9012 NULL
94784 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
94785 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
94786 +nla_put_9042 nla_put 3 9042 NULL
94787 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
94788 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
94789 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
94790 +string_9080 string 0 9080 NULL
94791 +create_queues_9088 create_queues 2-3 9088 NULL
94792 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
94793 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
94794 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
94795 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
94796 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
94797 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
94798 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
94799 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
94800 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
94801 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
94802 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
94803 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
94804 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
94805 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
94806 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
94807 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
94808 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
94809 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
94810 +flakey_status_9274 flakey_status 5 9274 NULL
94811 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
94812 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
94813 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
94814 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
94815 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
94816 +read_9397 read 3 9397 NULL
94817 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
94818 +cfg80211_report_obss_beacon_9422 cfg80211_report_obss_beacon 3 9422 NULL
94819 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
94820 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
94821 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
94822 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
94823 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
94824 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
94825 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
94826 +rbd_coll_end_req_9472 rbd_coll_end_req 3 9472 NULL
94827 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
94828 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
94829 +lp_write_9511 lp_write 3 9511 NULL
94830 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
94831 +lm3533_update_9529 lm3533_update 2 9529 NULL
94832 +read_file_dma_9530 read_file_dma 3 9530 NULL
94833 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
94834 +tps65910_gpio_output_9539 tps65910_gpio_output 2 9539 NULL
94835 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
94836 +readl_9557 readl 0 9557 NULL
94837 +fw_node_create_9559 fw_node_create 2 9559 NULL
94838 +kobj_map_9566 kobj_map 2-3 9566 NULL
94839 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
94840 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
94841 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
94842 +do_sync_9604 do_sync 1 9604 NULL
94843 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
94844 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
94845 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
94846 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
94847 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
94848 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
94849 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
94850 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
94851 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
94852 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
94853 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
94854 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 NULL nohasharray
94855 +is_hole_9694 is_hole 2 9694 &x25_asy_compat_ioctl_9694
94856 +fnb_9703 fnb 2-3 9703 NULL
94857 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 NULL
94858 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
94859 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
94860 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
94861 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
94862 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
94863 +do_sigpending_9766 do_sigpending 2 9766 NULL
94864 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
94865 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
94866 +_regmap_write_9803 _regmap_write 2 9803 NULL
94867 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
94868 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
94869 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
94870 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
94871 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
94872 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
94873 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
94874 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
94875 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
94876 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
94877 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
94878 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
94879 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
94880 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
94881 +receive_DataRequest_9904 receive_DataRequest 3 9904 NULL
94882 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
94883 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
94884 +read_file_misc_9948 read_file_misc 3 9948 NULL
94885 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
94886 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
94887 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
94888 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
94889 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
94890 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
94891 +twl6040_clear_bits_9985 twl6040_clear_bits 2 9985 NULL
94892 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
94893 +handle_request_10024 handle_request 9 10024 NULL
94894 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
94895 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
94896 +rbd_coll_end_req_index_10041 rbd_coll_end_req_index 5 10041 NULL
94897 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
94898 +wm831x_gpio_direction_in_10099 wm831x_gpio_direction_in 2 10099 NULL
94899 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
94900 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
94901 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
94902 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
94903 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
94904 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
94905 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
94906 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
94907 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
94908 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
94909 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
94910 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
94911 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
94912 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
94913 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
94914 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
94915 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
94916 +lm3533_led_delay_set_10291 lm3533_led_delay_set 2 10291 NULL
94917 +read_emulate_10310 read_emulate 2-4 10310 NULL
94918 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
94919 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
94920 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
94921 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
94922 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
94923 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
94924 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
94925 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
94926 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
94927 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
94928 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
94929 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
94930 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
94931 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
94932 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
94933 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
94934 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
94935 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
94936 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
94937 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
94938 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
94939 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
94940 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
94941 +otp_read_10594 otp_read 2-4-5 10594 NULL
94942 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
94943 +mc13783_set_fmt_10616 mc13783_set_fmt 3 10616 NULL
94944 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
94945 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
94946 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
94947 +parport_write_10669 parport_write 0 10669 NULL
94948 +inl_10708 inl 0 10708 NULL nohasharray
94949 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
94950 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
94951 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
94952 +spi_sync_10731 spi_sync 0 10731 NULL
94953 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
94954 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
94955 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
94956 +sys_syslog_10746 sys_syslog 3 10746 NULL
94957 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
94958 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
94959 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4 10765 NULL
94960 +sys_bind_10799 sys_bind 3 10799 NULL
94961 +compat_put_int_10828 compat_put_int 1 10828 NULL
94962 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
94963 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
94964 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
94965 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
94966 +batadv_check_unicast_packet_10866 batadv_check_unicast_packet 2 10866 NULL
94967 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
94968 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
94969 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
94970 +get_scq_10897 get_scq 2 10897 NULL
94971 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
94972 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
94973 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
94974 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
94975 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
94976 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
94977 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
94978 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
94979 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
94980 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
94981 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
94982 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
94983 +nouveau_gpio_create__11048 nouveau_gpio_create_ 4 11048 NULL
94984 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
94985 +carl9170_handle_mpdu_11056 carl9170_handle_mpdu 3 11056 NULL
94986 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
94987 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
94988 +count_argc_11083 count_argc 0 11083 NULL
94989 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
94990 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
94991 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
94992 +page_offset_11120 page_offset 0 11120 NULL
94993 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
94994 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
94995 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
94996 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
94997 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
94998 +__swab16p_11220 __swab16p 0 11220 NULL
94999 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
95000 +of_irq_count_11253 of_irq_count 0 11253 NULL
95001 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
95002 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
95003 +cru_detect_11272 cru_detect 1 11272 NULL
95004 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
95005 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
95006 +construct_key_11329 construct_key 3 11329 NULL nohasharray
95007 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
95008 +next_segment_11330 next_segment 0-2-1 11330 NULL
95009 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
95010 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
95011 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
95012 +sel_write_create_11353 sel_write_create 3 11353 NULL
95013 +handle_unit_11355 handle_unit 0-1 11355 NULL
95014 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
95015 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
95016 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
95017 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
95018 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
95019 +str_to_user_11411 str_to_user 2 11411 NULL
95020 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
95021 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
95022 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
95023 +trace_options_read_11419 trace_options_read 3 11419 NULL
95024 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
95025 +prepare_image_11424 prepare_image 0 11424 NULL
95026 +vring_size_11426 vring_size 0-1-2 11426 NULL
95027 +bttv_read_11432 bttv_read 3 11432 NULL
95028 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
95029 +swp_offset_11475 swp_offset 0 11475 NULL
95030 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
95031 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
95032 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
95033 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
95034 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
95035 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
95036 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
95037 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
95038 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
95039 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
95040 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
95041 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
95042 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
95043 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
95044 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
95045 +da9055_gpio_direction_output_11680 da9055_gpio_direction_output 2 11680 NULL
95046 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
95047 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
95048 +split_11691 split 2 11691 NULL
95049 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
95050 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
95051 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
95052 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
95053 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
95054 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
95055 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
95056 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
95057 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
95058 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
95059 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
95060 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
95061 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
95062 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
95063 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
95064 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
95065 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
95066 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
95067 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
95068 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
95069 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
95070 +kvm_set_msr_common_11953 kvm_set_msr_common 3 11953 NULL
95071 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
95072 +atmel_read16_11981 atmel_read16 0 11981 NULL
95073 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
95074 +mwifiex_cfg80211_mgmt_tx_12022 mwifiex_cfg80211_mgmt_tx 9 12022 NULL
95075 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
95076 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
95077 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
95078 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
95079 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
95080 +da9052_gpio_direction_output_12120 da9052_gpio_direction_output 2 12120 NULL
95081 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
95082 +set_powered_12129 set_powered 4 12129 NULL
95083 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
95084 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
95085 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
95086 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
95087 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
95088 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
95089 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
95090 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
95091 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
95092 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
95093 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
95094 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
95095 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
95096 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
95097 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
95098 +receive_copy_12216 receive_copy 3 12216 NULL
95099 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
95100 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 NULL
95101 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
95102 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
95103 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
95104 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
95105 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
95106 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
95107 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
95108 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
95109 +split_bvec_12312 split_bvec 6 12312 NULL
95110 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
95111 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
95112 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
95113 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
95114 +receive_packet_12367 receive_packet 2 12367 NULL
95115 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
95116 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
95117 +ntfs_get_size_for_mapping_pairs_12413 ntfs_get_size_for_mapping_pairs 0 12413 NULL
95118 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
95119 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
95120 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
95121 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
95122 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
95123 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
95124 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
95125 +arizona_gpio_direction_out_12564 arizona_gpio_direction_out 2 12564 NULL
95126 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
95127 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
95128 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
95129 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
95130 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
95131 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
95132 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
95133 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
95134 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
95135 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
95136 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
95137 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
95138 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
95139 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
95140 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
95141 +ivtv_write_12721 ivtv_write 3 12721 NULL
95142 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
95143 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
95144 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
95145 +listxattr_12769 listxattr 3 12769 NULL
95146 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
95147 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
95148 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
95149 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
95150 +readq_12825 readq 0 12825 NULL
95151 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
95152 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 NULL nohasharray
95153 +spidev_sync_12842 spidev_sync 0 12842 &ath6kl_wmi_add_wow_pattern_cmd_12842
95154 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
95155 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
95156 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
95157 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
95158 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
95159 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
95160 +tps65910_reg_update_bits_12934 tps65910_reg_update_bits 2 12934 NULL
95161 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
95162 +bm_status_write_12964 bm_status_write 3 12964 NULL
95163 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
95164 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
95165 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
95166 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
95167 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
95168 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
95169 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
95170 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
95171 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
95172 +tps6586x_set_bits_13089 tps6586x_set_bits 2 13089 NULL
95173 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
95174 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
95175 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
95176 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
95177 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
95178 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
95179 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
95180 +blk_update_request_13146 blk_update_request 3 13146 NULL
95181 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
95182 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
95183 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
95184 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
95185 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
95186 +comedi_read_13199 comedi_read 3 13199 NULL
95187 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
95188 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
95189 +get_unaligned_le64_13219 get_unaligned_le64 0 13219 NULL
95190 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
95191 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
95192 +fw_download_code_13249 fw_download_code 3 13249 NULL
95193 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
95194 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
95195 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
95196 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
95197 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
95198 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
95199 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
95200 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
95201 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
95202 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5 13337 NULL
95203 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
95204 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
95205 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
95206 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
95207 +sky2_receive_13407 sky2_receive 2 13407 NULL
95208 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
95209 +keyring_read_13438 keyring_read 3 13438 NULL
95210 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
95211 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
95212 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 7-8-9 13443 NULL
95213 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
95214 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
95215 +core_status_13515 core_status 4 13515 NULL
95216 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
95217 +bm_init_13529 bm_init 2 13529 NULL
95218 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL
95219 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
95220 +alloc_tio_13564 alloc_tio 3 13564 NULL
95221 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
95222 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
95223 +pm860x_set_bits_13582 pm860x_set_bits 2 13582 NULL
95224 +cache_write_13589 cache_write 3 13589 NULL
95225 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
95226 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
95227 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
95228 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
95229 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
95230 +wm8994_bulk_write_13615 wm8994_bulk_write 3-2 13615 NULL
95231 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
95232 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
95233 +packet_snd_13634 packet_snd 3 13634 NULL
95234 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
95235 +cache_downcall_13666 cache_downcall 3 13666 NULL
95236 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
95237 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
95238 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
95239 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
95240 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
95241 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
95242 +random_read_13815 random_read 3 13815 NULL
95243 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
95244 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
95245 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
95246 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
95247 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
95248 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
95249 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
95250 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
95251 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
95252 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
95253 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
95254 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
95255 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
95256 +com90xx_found_13974 com90xx_found 3 13974 NULL
95257 +qcam_read_13977 qcam_read 3 13977 NULL
95258 +dsp_read_13980 dsp_read 2 13980 NULL
95259 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
95260 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
95261 +ieee80211_bss_info_update_13991 ieee80211_bss_info_update 4 13991 NULL
95262 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
95263 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
95264 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
95265 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
95266 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
95267 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
95268 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
95269 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
95270 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
95271 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
95272 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
95273 +em_canid_change_14150 em_canid_change 3 14150 NULL
95274 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
95275 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
95276 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
95277 +alloc_async_14208 alloc_async 1 14208 NULL
95278 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
95279 +pool_status_14230 pool_status 5 14230 NULL
95280 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
95281 +inode_to_path_14235 inode_to_path 2 14235 NULL
95282 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
95283 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 4-2 14245 NULL
95284 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
95285 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
95286 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
95287 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
95288 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
95289 +rr_status_14293 rr_status 5 14293 NULL
95290 +lp8788_write_byte_14299 lp8788_write_byte 2 14299 NULL
95291 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
95292 +oo_objects_14319 oo_objects 0 14319 NULL
95293 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
95294 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
95295 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
95296 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
95297 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
95298 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
95299 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
95300 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
95301 +block_size_14443 block_size 0 14443 NULL
95302 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
95303 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
95304 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
95305 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
95306 +stripe_status_14506 stripe_status 5 14506 NULL
95307 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
95308 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
95309 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
95310 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
95311 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
95312 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
95313 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
95314 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
95315 +dbJoin_14644 dbJoin 0 14644 NULL
95316 +profile_replace_14652 profile_replace 3 14652 NULL
95317 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
95318 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
95319 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
95320 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
95321 +vfd_write_14717 vfd_write 3 14717 NULL
95322 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
95323 +raid1_resize_14740 raid1_resize 2 14740 NULL
95324 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
95325 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
95326 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
95327 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
95328 +lm3533_als_get_hysteresis_14776 lm3533_als_get_hysteresis 2 14776 NULL
95329 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
95330 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
95331 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
95332 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
95333 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
95334 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
95335 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
95336 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
95337 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
95338 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
95339 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
95340 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
95341 +unifi_read_14899 unifi_read 3 14899 NULL
95342 +krealloc_14908 krealloc 2 14908 NULL
95343 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
95344 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL
95345 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
95346 +queue_cnt_14951 queue_cnt 0 14951 NULL
95347 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
95348 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
95349 +setkey_14987 setkey 3 14987 NULL nohasharray
95350 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
95351 +vmap_15025 vmap 2 15025 NULL
95352 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
95353 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
95354 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
95355 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
95356 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
95357 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
95358 +__alloc_extent_buffer_15093 __alloc_extent_buffer 3 15093 NULL
95359 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
95360 +start_port_15124 start_port 0 15124 NULL
95361 +memchr_15126 memchr 0 15126 NULL
95362 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
95363 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
95364 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
95365 +reserve_resources_15194 reserve_resources 3 15194 NULL
95366 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
95367 +variax_alloc_sysex_buffer_15237 variax_alloc_sysex_buffer 3 15237 NULL
95368 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
95369 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
95370 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
95371 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
95372 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
95373 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
95374 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
95375 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
95376 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
95377 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
95378 +ioread16_15342 ioread16 0 15342 NULL
95379 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
95380 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
95381 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
95382 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
95383 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
95384 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
95385 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
95386 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
95387 +get_modalias_15406 get_modalias 2 15406 NULL
95388 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
95389 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 0-2 15438 NULL
95390 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
95391 +memweight_15450 memweight 2 15450 NULL
95392 +vmalloc_15464 vmalloc 1 15464 NULL
95393 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
95394 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
95395 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
95396 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
95397 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
95398 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
95399 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
95400 +persistent_status_15574 persistent_status 4 15574 NULL
95401 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
95402 +vme_user_write_15587 vme_user_write 3 15587 NULL
95403 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
95404 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
95405 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
95406 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
95407 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
95408 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
95409 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
95410 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
95411 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
95412 +fs_path_add_15648 fs_path_add 3 15648 NULL
95413 +xsd_read_15653 xsd_read 3 15653 NULL
95414 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
95415 +unix_bind_15668 unix_bind 3 15668 NULL
95416 +dm_read_15674 dm_read 3 15674 NULL
95417 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
95418 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
95419 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
95420 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
95421 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
95422 +do_test_15766 do_test 1 15766 NULL
95423 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
95424 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
95425 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
95426 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
95427 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
95428 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
95429 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
95430 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
95431 +table_size_15851 table_size 0-1-2 15851 NULL
95432 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
95433 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
95434 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
95435 +ERR_PTR_15881 ERR_PTR 0 15881 NULL
95436 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
95437 +native_read_msr_15905 native_read_msr 0 15905 NULL
95438 +wm5100_gpio_direction_in_15934 wm5100_gpio_direction_in 2 15934 NULL
95439 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
95440 +power_read_15939 power_read 3 15939 NULL
95441 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
95442 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
95443 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
95444 +set_spte_15977 set_spte 7-6 15977 NULL
95445 +frame_alloc_15981 frame_alloc 4 15981 NULL
95446 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
95447 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
95448 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
95449 +got_frame_16028 got_frame 2 16028 NULL
95450 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
95451 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
95452 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
95453 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
95454 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
95455 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
95456 +fsm_init_16134 fsm_init 2 16134 NULL
95457 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
95458 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
95459 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
95460 +mapping_level_16188 mapping_level 2 16188 NULL
95461 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
95462 +create_table_16213 create_table 2 16213 NULL
95463 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
95464 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
95465 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 NULL
95466 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
95467 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
95468 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
95469 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
95470 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
95471 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
95472 +account_16283 account 0-2-4 16283 NULL nohasharray
95473 +mirror_status_16283 mirror_status 5 16283 &account_16283
95474 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
95475 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
95476 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
95477 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
95478 +tps80031_update_16360 tps80031_update 3 16360 NULL
95479 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
95480 +rbd_add_16366 rbd_add 3 16366 NULL
95481 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
95482 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
95483 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
95484 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
95485 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
95486 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
95487 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
95488 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
95489 +raid10_resize_16537 raid10_resize 2 16537 NULL
95490 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
95491 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
95492 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
95493 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
95494 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
95495 +da9052_reg_write_16685 da9052_reg_write 2 16685 NULL
95496 +em28xx_v4l2_read_16701 em28xx_v4l2_read 3 16701 NULL
95497 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
95498 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
95499 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
95500 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
95501 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
95502 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
95503 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
95504 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
95505 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
95506 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
95507 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
95508 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
95509 +st_write_16874 st_write 3 16874 NULL
95510 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
95511 +wm8350_set_bits_16911 wm8350_set_bits 2 16911 NULL
95512 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
95513 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
95514 +random32_16937 random32 0 16937 NULL
95515 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
95516 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
95517 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
95518 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
95519 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
95520 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
95521 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
95522 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
95523 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
95524 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
95525 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
95526 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
95527 +mac_address_string_17091 mac_address_string 0 17091 NULL
95528 +entry_length_17093 entry_length 0 17093 NULL
95529 +sys_preadv_17100 sys_preadv 3 17100 NULL
95530 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
95531 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
95532 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
95533 +sep_read_17161 sep_read 3 17161 NULL
95534 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
95535 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
95536 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
95537 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
95538 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
95539 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
95540 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
95541 +ms_rw_17220 ms_rw 3-4 17220 NULL
95542 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
95543 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
95544 +alloc_ep_17269 alloc_ep 1 17269 NULL
95545 +pg_read_17276 pg_read 3 17276 NULL
95546 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
95547 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
95548 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
95549 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
95550 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
95551 +skb_pad_17302 skb_pad 2 17302 NULL
95552 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
95553 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
95554 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
95555 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
95556 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
95557 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
95558 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
95559 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
95560 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
95561 +compat_cmd_17465 compat_cmd 2 17465 NULL
95562 +probe_bios_17467 probe_bios 1 17467 NULL
95563 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
95564 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
95565 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
95566 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
95567 +arizona_apply_fll_17538 arizona_apply_fll 2 17538 NULL
95568 +xlog_do_log_recovery_17550 xlog_do_log_recovery 3 17550 NULL
95569 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
95570 +copy_from_user_17559 copy_from_user 3 17559 NULL
95571 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
95572 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
95573 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
95574 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
95575 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
95576 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
95577 +osst_execute_17607 osst_execute 7-6 17607 NULL
95578 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
95579 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
95580 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
95581 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
95582 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
95583 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
95584 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
95585 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
95586 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
95587 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
95588 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
95589 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
95590 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
95591 +get_unaligned_be64_17794 get_unaligned_be64 0 17794 NULL
95592 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
95593 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
95594 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
95595 +count_leafs_17842 count_leafs 0 17842 NULL
95596 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
95597 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
95598 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
95599 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
95600 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
95601 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
95602 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
95603 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
95604 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
95605 +wm8400_set_bits_17898 wm8400_set_bits 2 17898 NULL
95606 +recover_head_17904 recover_head 3 17904 NULL
95607 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
95608 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
95609 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
95610 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
95611 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
95612 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
95613 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
95614 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
95615 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
95616 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
95617 +prandom32_18007 prandom32 0 18007 NULL
95618 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
95619 +fill_read_18019 fill_read 0 18019 NULL
95620 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
95621 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
95622 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
95623 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
95624 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
95625 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
95626 +packet_came_18072 packet_came 3 18072 NULL
95627 +kvm_read_guest_page_18074 kvm_read_guest_page 5 18074 NULL
95628 +get_vm_area_18080 get_vm_area 1 18080 NULL
95629 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
95630 +tps65910_gpio_input_18110 tps65910_gpio_input 2 18110 NULL
95631 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
95632 +svc_getnl_18120 svc_getnl 0 18120 NULL
95633 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
95634 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
95635 +tps65910_gpio_set_18135 tps65910_gpio_set 2 18135 NULL
95636 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
95637 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
95638 +_has_tag_18169 _has_tag 2 18169 NULL
95639 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
95640 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
95641 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
95642 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
95643 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
95644 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
95645 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
95646 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
95647 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
95648 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
95649 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
95650 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
95651 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
95652 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
95653 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
95654 +um_idi_write_18293 um_idi_write 3 18293 NULL
95655 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
95656 +vga_r_18310 vga_r 0 18310 NULL
95657 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
95658 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
95659 +wm8994_gpio_direction_out_18337 wm8994_gpio_direction_out 2 18337 NULL
95660 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
95661 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
95662 +ep_io_18367 ep_io 0 18367 NULL
95663 +lp872x_update_bits_18368 lp872x_update_bits 2 18368 NULL
95664 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 NULL
95665 +__video_register_device_18399 __video_register_device 3 18399 NULL
95666 +reada_tree_block_flagged_18402 reada_tree_block_flagged 3 18402 NULL nohasharray
95667 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &reada_tree_block_flagged_18402
95668 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
95669 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
95670 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
95671 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
95672 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
95673 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
95674 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
95675 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
95676 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
95677 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
95678 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
95679 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
95680 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
95681 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
95682 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
95683 +debug_output_18575 debug_output 3 18575 NULL
95684 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
95685 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
95686 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
95687 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
95688 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
95689 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
95690 +from_buffer_18625 from_buffer 3 18625 NULL
95691 +f1x_map_sysaddr_to_csrow_18628 f1x_map_sysaddr_to_csrow 2 18628 NULL
95692 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
95693 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
95694 +unmap_page_18665 unmap_page 2-3 18665 NULL
95695 +edge_tty_recv_18667 edge_tty_recv 4 18667 NULL nohasharray
95696 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 &edge_tty_recv_18667
95697 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
95698 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
95699 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
95700 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
95701 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
95702 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
95703 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
95704 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
95705 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
95706 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
95707 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
95708 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
95709 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
95710 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
95711 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
95712 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
95713 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
95714 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
95715 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
95716 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
95717 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
95718 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
95719 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
95720 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
95721 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
95722 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
95723 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
95724 +alc_auto_create_extra_outs_18975 alc_auto_create_extra_outs 2 18975 NULL
95725 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
95726 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
95727 +huge_page_size_19008 huge_page_size 0 19008 NULL
95728 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
95729 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
95730 +revalidate_19043 revalidate 2 19043 NULL
95731 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
95732 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
95733 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
95734 +copy_and_check_19089 copy_and_check 3 19089 NULL
95735 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
95736 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
95737 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
95738 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
95739 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
95740 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
95741 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
95742 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
95743 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
95744 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
95745 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
95746 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
95747 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
95748 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
95749 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
95750 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
95751 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
95752 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
95753 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
95754 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
95755 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
95756 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
95757 +qc_capture_19298 qc_capture 3 19298 NULL
95758 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
95759 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
95760 +debug_read_19322 debug_read 3 19322 NULL
95761 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
95762 +read_zero_19366 read_zero 3 19366 NULL
95763 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
95764 +get_unaligned_be16_19400 get_unaligned_be16 0 19400 NULL
95765 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
95766 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
95767 +__phys_addr_19434 __phys_addr 0 19434 NULL
95768 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
95769 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
95770 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
95771 +sky2_read16_19475 sky2_read16 0 19475 NULL
95772 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
95773 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
95774 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
95775 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
95776 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
95777 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
95778 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
95779 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
95780 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
95781 +nfsd_read_19568 nfsd_read 5 19568 NULL
95782 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
95783 +bm_status_read_19583 bm_status_read 3 19583 NULL
95784 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
95785 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
95786 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
95787 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
95788 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
95789 +read_reg_19723 read_reg 0 19723 NULL
95790 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
95791 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
95792 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
95793 +p9_client_read_19750 p9_client_read 5 19750 NULL
95794 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
95795 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
95796 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
95797 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
95798 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
95799 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
95800 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
95801 +vip_read_19832 vip_read 3 19832 NULL nohasharray
95802 +vfs_getxattr_19832 vfs_getxattr 0 19832 &vip_read_19832
95803 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
95804 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
95805 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
95806 +__nla_put_19857 __nla_put 3 19857 NULL
95807 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
95808 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
95809 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
95810 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
95811 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
95812 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
95813 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
95814 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
95815 +__be32_to_cpup_20056 __be32_to_cpup 0 20056 NULL
95816 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
95817 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
95818 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
95819 +team_options_register_20091 team_options_register 3 20091 NULL
95820 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
95821 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
95822 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
95823 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
95824 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
95825 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
95826 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
95827 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
95828 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
95829 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
95830 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
95831 +resource_size_20256 resource_size 0 20256 NULL
95832 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
95833 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
95834 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
95835 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
95836 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
95837 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
95838 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
95839 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
95840 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
95841 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
95842 +pm860x_write_reg_cache_20448 pm860x_write_reg_cache 2 20448 NULL
95843 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
95844 +ip_vs_icmp_xmit_v6_20464 ip_vs_icmp_xmit_v6 4 20464 NULL
95845 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
95846 +read_buf_20469 read_buf 2 20469 NULL
95847 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
95848 +fast_user_write_20494 fast_user_write 5 20494 NULL
95849 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
95850 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
95851 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
95852 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
95853 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
95854 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
95855 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
95856 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
95857 +venus_create_20555 venus_create 4 20555 NULL
95858 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
95859 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
95860 +rc5t583_set_bits_20573 rc5t583_set_bits 2 20573 NULL
95861 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
95862 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
95863 +lirc_write_20604 lirc_write 3 20604 NULL
95864 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
95865 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
95866 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
95867 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
95868 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
95869 +ceph_osdc_new_request_20654 ceph_osdc_new_request 15-4 20654 NULL
95870 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
95871 +sec_reg_write_20667 sec_reg_write 2 20667 NULL
95872 +tps65910_reg_clear_bits_20672 tps65910_reg_clear_bits 2 20672 NULL
95873 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
95874 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 NULL
95875 +cpumask_size_20683 cpumask_size 0 20683 NULL
95876 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
95877 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
95878 +__maestro_read_20700 __maestro_read 0 20700 NULL
95879 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
95880 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
95881 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
95882 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
95883 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
95884 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
95885 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
95886 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
95887 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
95888 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
95889 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
95890 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
95891 +sys_sendto_20809 sys_sendto 6 20809 NULL
95892 +strndup_user_20819 strndup_user 2 20819 NULL
95893 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
95894 +uvc_alloc_entity_20836 uvc_alloc_entity 4-3 20836 NULL
95895 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
95896 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
95897 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
95898 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
95899 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
95900 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
95901 +htable_bits_20933 htable_bits 0 20933 NULL
95902 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
95903 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
95904 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
95905 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
95906 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
95907 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
95908 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
95909 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
95910 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
95911 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
95912 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
95913 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
95914 +multipath_status_21094 multipath_status 5 21094 NULL
95915 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
95916 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
95917 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
95918 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
95919 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
95920 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
95921 +ath6kl_mgmt_tx_21153 ath6kl_mgmt_tx 9 21153 NULL
95922 +setup_msi_irq_21169 setup_msi_irq 3 21169 NULL
95923 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
95924 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
95925 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
95926 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
95927 +input_ff_create_21240 input_ff_create 2 21240 NULL
95928 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
95929 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
95930 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
95931 +rc5t583_clear_bits_21300 rc5t583_clear_bits 2 21300 NULL
95932 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
95933 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
95934 +add_res_range_21310 add_res_range 4 21310 NULL
95935 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
95936 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
95937 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
95938 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
95939 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
95940 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
95941 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
95942 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
95943 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
95944 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
95945 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
95946 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
95947 +btrfs_iref_to_path_21445 btrfs_iref_to_path 7 21445 NULL
95948 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
95949 +concat_writev_21451 concat_writev 3 21451 NULL
95950 +extend_netdev_table_21453 extend_netdev_table 2 21453 NULL
95951 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
95952 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
95953 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
95954 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
95955 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
95956 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
95957 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
95958 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
95959 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
95960 +xlog_do_recovery_pass_21618 xlog_do_recovery_pass 3 21618 NULL
95961 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
95962 +rbd_req_sync_op_21632 rbd_req_sync_op 7-8 21632 NULL
95963 +validate_nnode_21638 validate_nnode 0 21638 NULL
95964 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
95965 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
95966 +hpet_setup_msi_irq_21662 hpet_setup_msi_irq 1 21662 NULL
95967 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
95968 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
95969 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
95970 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
95971 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
95972 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
95973 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
95974 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
95975 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
95976 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
95977 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
95978 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
95979 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
95980 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
95981 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
95982 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
95983 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
95984 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
95985 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
95986 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
95987 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
95988 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
95989 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
95990 +rbd_req_read_21952 rbd_req_read 4-5 21952 NULL
95991 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
95992 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
95993 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
95994 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
95995 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
95996 +ti_recv_22027 ti_recv 4 22027 NULL
95997 +pcf50633_irq_unmask_22034 pcf50633_irq_unmask 2 22034 NULL
95998 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
95999 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
96000 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
96001 +mem_rw_22085 mem_rw 3 22085 NULL
96002 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
96003 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
96004 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
96005 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
96006 +compat_insn_22142 compat_insn 2 22142 NULL
96007 +pn533_dep_link_up_22154 pn533_dep_link_up 5 22154 NULL
96008 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
96009 +__kfifo_alloc_22173 __kfifo_alloc 2-3 22173 NULL
96010 +fls_22210 fls 0 22210 NULL
96011 +bio_chain_clone_22227 bio_chain_clone 4 22227 NULL
96012 +mem_write_22232 mem_write 3 22232 NULL
96013 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
96014 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
96015 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
96016 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
96017 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
96018 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
96019 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
96020 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
96021 +get_segment_base_22324 get_segment_base 0 22324 NULL
96022 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
96023 +atomic_read_22342 atomic_read 0 22342 NULL
96024 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
96025 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL
96026 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
96027 +wlcore_alloc_hw_22365 wlcore_alloc_hw 1 22365 NULL nohasharray
96028 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 &wlcore_alloc_hw_22365
96029 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
96030 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
96031 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
96032 +zoran_write_22404 zoran_write 3 22404 NULL
96033 +queue_reply_22416 queue_reply 3 22416 NULL
96034 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
96035 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
96036 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
96037 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
96038 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
96039 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
96040 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
96041 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
96042 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
96043 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
96044 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
96045 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
96046 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
96047 +snapshot_read_22601 snapshot_read 3 22601 NULL
96048 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
96049 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
96050 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
96051 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
96052 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
96053 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
96054 +fill_gap_22681 fill_gap 0 22681 NULL
96055 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
96056 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
96057 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
96058 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
96059 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
96060 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
96061 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
96062 +print_frame_22769 print_frame 0 22769 NULL
96063 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
96064 +retu_write_22800 retu_write 2 22800 NULL
96065 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
96066 +can_nocow_odirect_22854 can_nocow_odirect 3 22854 NULL nohasharray
96067 +read_file_rcstat_22854 read_file_rcstat 3 22854 &can_nocow_odirect_22854
96068 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
96069 +nfs4_realloc_slot_table_22859 nfs4_realloc_slot_table 2 22859 NULL
96070 +create_attr_set_22861 create_attr_set 1 22861 NULL
96071 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
96072 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
96073 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
96074 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
96075 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
96076 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
96077 +vme_get_size_22964 vme_get_size 0 22964 NULL
96078 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
96079 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
96080 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
96081 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
96082 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
96083 +st_status_23032 st_status 5 23032 NULL
96084 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
96085 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
96086 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
96087 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
96088 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
96089 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
96090 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
96091 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
96092 +fls_long_23096 fls_long 0 23096 NULL
96093 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
96094 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
96095 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
96096 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
96097 +__clear_user_23118 __clear_user 0 23118 NULL
96098 +dm_write_async_23120 dm_write_async 3 23120 NULL
96099 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
96100 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
96101 +wm831x_set_bits_23158 wm831x_set_bits 2 23158 NULL
96102 +read_file_ani_23161 read_file_ani 3 23161 NULL
96103 +ioremap_23172 ioremap 1-2 23172 NULL
96104 +usblp_write_23178 usblp_write 3 23178 NULL
96105 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
96106 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
96107 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
96108 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
96109 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
96110 +__next_dma_cap_23195 __next_dma_cap 1 23195 NULL
96111 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
96112 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
96113 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
96114 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
96115 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
96116 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
96117 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
96118 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
96119 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
96120 +doc_probe_23285 doc_probe 1 23285 NULL
96121 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
96122 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
96123 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
96124 +page_readlink_23346 page_readlink 3 23346 NULL
96125 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
96126 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
96127 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
96128 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
96129 +__cxio_init_resource_fifo_23447 __cxio_init_resource_fifo 3 23447 NULL nohasharray
96130 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 &__cxio_init_resource_fifo_23447
96131 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
96132 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
96133 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
96134 +event_filter_read_23494 event_filter_read 3 23494 NULL
96135 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
96136 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
96137 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
96138 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
96139 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
96140 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
96141 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
96142 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
96143 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
96144 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
96145 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
96146 +sInW_23663 sInW 0 23663 NULL
96147 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
96148 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
96149 +cx18_read_23699 cx18_read 3 23699 NULL
96150 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
96151 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
96152 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
96153 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
96154 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
96155 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
96156 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
96157 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
96158 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
96159 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
96160 +p54_init_common_23850 p54_init_common 1 23850 NULL
96161 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
96162 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
96163 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
96164 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
96165 +ieee80211_if_read_channel_type_23884 ieee80211_if_read_channel_type 3 23884 NULL
96166 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
96167 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
96168 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
96169 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
96170 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
96171 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
96172 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
96173 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
96174 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
96175 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
96176 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
96177 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
96178 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
96179 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
96180 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
96181 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
96182 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
96183 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
96184 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
96185 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
96186 +ieee80211_send_auth_24121 ieee80211_send_auth 5 24121 NULL
96187 +mpu401_read_24126 mpu401_read 3 24126 NULL
96188 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
96189 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
96190 +adu_read_24177 adu_read 3 24177 NULL
96191 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
96192 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
96193 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
96194 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
96195 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
96196 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
96197 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
96198 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
96199 +thin_status_24278 thin_status 5 24278 NULL
96200 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
96201 +msg_size_24288 msg_size 0 24288 NULL
96202 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
96203 +map_page_24298 map_page 3-4 24298 NULL
96204 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
96205 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
96206 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
96207 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
96208 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
96209 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
96210 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
96211 +igetword_24373 igetword 0 24373 NULL
96212 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
96213 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
96214 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
96215 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
96216 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
96217 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
96218 +smk_user_access_24440 smk_user_access 3 24440 NULL
96219 +page_address_24444 page_address 0 24444 NULL
96220 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
96221 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
96222 +pd_video_read_24510 pd_video_read 3 24510 NULL
96223 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
96224 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
96225 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
96226 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
96227 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
96228 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
96229 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
96230 +palmas_smps_write_24600 palmas_smps_write 2 24600 NULL nohasharray
96231 +count_preds_24600 count_preds 0 24600 &palmas_smps_write_24600
96232 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
96233 +context_alloc_24645 context_alloc 3 24645 NULL
96234 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
96235 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
96236 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
96237 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
96238 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
96239 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
96240 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
96241 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
96242 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
96243 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
96244 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
96245 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
96246 +cache_read_24790 cache_read 3 24790 NULL
96247 +unpack_str_24798 unpack_str 0 24798 NULL
96248 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
96249 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
96250 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
96251 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
96252 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
96253 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
96254 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
96255 +queues_read_24877 queues_read 3 24877 NULL
96256 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
96257 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
96258 +next_token_24929 next_token 0 24929 NULL
96259 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
96260 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
96261 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
96262 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
96263 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
96264 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
96265 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
96266 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
96267 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
96268 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
96269 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
96270 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
96271 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
96272 +gfs2_iter_unstuffed_25099 gfs2_iter_unstuffed 0 25099 NULL
96273 +cxio_hal_init_rhdl_resource_25104 cxio_hal_init_rhdl_resource 1 25104 NULL
96274 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
96275 +fs32_to_cpu_25143 fs32_to_cpu 0 25143 NULL
96276 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
96277 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
96278 +mmu_set_spte_25177 mmu_set_spte 8-9 25177 NULL
96279 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
96280 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
96281 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
96282 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
96283 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
96284 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
96285 +stripe_status_25259 stripe_status 5 25259 NULL
96286 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
96287 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
96288 +vfs_writev_25278 vfs_writev 3 25278 NULL
96289 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
96290 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
96291 +help_25316 help 5 25316 NULL nohasharray
96292 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
96293 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
96294 +i915_gem_execbuffer_relocate_slow_25355 i915_gem_execbuffer_relocate_slow 7 25355 NULL
96295 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
96296 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
96297 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
96298 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
96299 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
96300 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
96301 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
96302 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
96303 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
96304 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
96305 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
96306 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
96307 +sb_permission_25523 sb_permission 0 25523 NULL
96308 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
96309 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
96310 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
96311 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
96312 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
96313 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
96314 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
96315 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
96316 +__get_user_pages_25628 __get_user_pages 0 25628 NULL nohasharray
96317 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
96318 +__direct_map_25647 __direct_map 5-6 25647 NULL
96319 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
96320 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
96321 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
96322 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
96323 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
96324 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
96325 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
96326 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 &sel_write_context_25726
96327 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
96328 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
96329 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
96330 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
96331 +sg_read_25799 sg_read 3 25799 NULL
96332 +sys32_rt_sigpending_25814 sys32_rt_sigpending 2 25814 NULL
96333 +system_enable_read_25815 system_enable_read 3 25815 NULL
96334 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
96335 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
96336 +parport_read_25855 parport_read 0 25855 NULL
96337 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
96338 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
96339 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
96340 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
96341 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
96342 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
96343 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
96344 +utf16_strlen_25913 utf16_strlen 0 25913 NULL
96345 +rcname_read_25919 rcname_read 3 25919 NULL
96346 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
96347 +key_flags_read_25931 key_flags_read 3 25931 NULL
96348 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
96349 +tps80031_clr_bits_25942 tps80031_clr_bits 3 25942 NULL
96350 +flush_25957 flush 2 25957 NULL
96351 +video_register_device_25971 video_register_device 3 25971 NULL
96352 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
96353 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
96354 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
96355 +mirror_status_26010 mirror_status 5 26010 NULL
96356 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
96357 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
96358 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
96359 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
96360 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
96361 +tun_do_read_26047 tun_do_read 5 26047 NULL
96362 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
96363 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
96364 +cpumask_next_26096 cpumask_next 1 26096 NULL
96365 +skb_cow_26138 skb_cow 2 26138 NULL
96366 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
96367 +__fswab64_26155 __fswab64 0 26155 NULL
96368 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
96369 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
96370 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
96371 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
96372 +disk_devt_26180 disk_devt 0 26180 NULL
96373 +get_registers_26187 get_registers 3 26187 NULL
96374 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
96375 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
96376 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
96377 +mce_write_26201 mce_write 3 26201 NULL
96378 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
96379 +cxio_num_stags_26233 cxio_num_stags 0 26233 NULL
96380 +bio_split_26235 bio_split 2 26235 NULL
96381 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
96382 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
96383 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
96384 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
96385 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
96386 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
96387 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
96388 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
96389 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
96390 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
96391 +virtio_has_feature_26467 virtio_has_feature 0 26467 NULL
96392 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
96393 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
96394 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
96395 +read_vmcore_26501 read_vmcore 3 26501 NULL
96396 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
96397 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
96398 +rds_message_inc_copy_to_user_26540 rds_message_inc_copy_to_user 3 26540 NULL
96399 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
96400 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
96401 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
96402 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
96403 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
96404 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
96405 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
96406 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
96407 +mmap_region_26649 mmap_region 0-2 26649 NULL
96408 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
96409 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
96410 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
96411 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
96412 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
96413 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
96414 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
96415 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
96416 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
96417 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
96418 +ntfs_are_rl_mergeable_26777 ntfs_are_rl_mergeable 0 26777 NULL
96419 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
96420 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
96421 +smk_write_load_26829 smk_write_load 3 26829 NULL
96422 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
96423 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
96424 +scnprint_id_26842 scnprint_id 3 26842 NULL
96425 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
96426 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
96427 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
96428 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
96429 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
96430 +wm8994_reg_write_26919 wm8994_reg_write 2 26919 NULL
96431 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
96432 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
96433 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
96434 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
96435 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
96436 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
96437 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
96438 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
96439 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
96440 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
96441 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
96442 +rbd_do_op_27025 rbd_do_op 7-8 27025 NULL
96443 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
96444 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
96445 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
96446 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
96447 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
96448 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
96449 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
96450 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
96451 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
96452 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
96453 +pms_capture_27142 pms_capture 4 27142 NULL
96454 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
96455 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
96456 +mc13xxx_irq_handle_27166 mc13xxx_irq_handle 3 27166 NULL
96457 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
96458 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
96459 +get_unaligned_be32_27184 get_unaligned_be32 0 27184 NULL
96460 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
96461 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
96462 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
96463 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
96464 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
96465 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
96466 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
96467 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
96468 +rbd_req_sync_exec_27320 rbd_req_sync_exec 8 27320 NULL
96469 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
96470 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
96471 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
96472 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
96473 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
96474 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
96475 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
96476 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
96477 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
96478 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
96479 +tps65910_reg_set_bits_27468 tps65910_reg_set_bits 2 27468 NULL
96480 +rtsx_write_cfg_seq_27485 rtsx_write_cfg_seq 5-3 27485 NULL
96481 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
96482 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
96483 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
96484 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
96485 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
96486 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
96487 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
96488 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
96489 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
96490 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
96491 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
96492 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
96493 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
96494 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
96495 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
96496 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
96497 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
96498 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
96499 +qword_get_27670 qword_get 0 27670 NULL
96500 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
96501 +__tty_buffer_request_room_27700 __tty_buffer_request_room 2 27700 NULL
96502 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
96503 +evm_write_key_27715 evm_write_key 3 27715 NULL
96504 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
96505 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
96506 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
96507 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
96508 +kcalloc_27770 kcalloc 1-2 27770 NULL
96509 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
96510 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
96511 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
96512 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
96513 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
96514 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
96515 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
96516 +read_profile_27859 read_profile 3 27859 NULL
96517 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
96518 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
96519 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
96520 +gluebi_write_27905 gluebi_write 3 27905 NULL
96521 +mc13783_set_sysclk_27914 mc13783_set_sysclk 5 27914 NULL
96522 +bm_find_next_27929 bm_find_next 2 27929 NULL
96523 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
96524 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
96525 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
96526 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
96527 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
96528 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
96529 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
96530 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
96531 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
96532 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
96533 +pool_status_28055 pool_status 5 28055 NULL
96534 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
96535 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
96536 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
96537 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
96538 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
96539 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
96540 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
96541 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
96542 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
96543 +video_read_28148 video_read 3 28148 NULL
96544 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
96545 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
96546 +vread_28173 vread 0 28173 NULL
96547 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
96548 +d_path_28198 d_path 0 28198 NULL
96549 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
96550 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
96551 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
96552 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
96553 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
96554 +usemap_size_28281 usemap_size 0 28281 NULL
96555 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
96556 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
96557 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
96558 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
96559 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
96560 +snapshot_write_28351 snapshot_write 3 28351 NULL
96561 +__next_wq_cpu_28352 __next_wq_cpu 1 28352 NULL
96562 +sys_writev_28384 sys_writev 3 28384 NULL
96563 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
96564 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
96565 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
96566 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
96567 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
96568 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
96569 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
96570 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
96571 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
96572 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
96573 +max_response_pages_28492 max_response_pages 0 28492 NULL
96574 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
96575 +__next_node_28521 __next_node 1 28521 NULL
96576 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
96577 +early_init_dt_alloc_memory_arch_28528 early_init_dt_alloc_memory_arch 1 28528 NULL
96578 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
96579 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
96580 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
96581 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
96582 +i2o_msg_post_wait_mem_28558 i2o_msg_post_wait_mem 0 28558 NULL
96583 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
96584 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
96585 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
96586 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
96587 +wm8350_clear_bits_28596 wm8350_clear_bits 2 28596 NULL
96588 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
96589 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
96590 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
96591 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
96592 +_set_range_28627 _set_range 3 28627 NULL
96593 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
96594 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
96595 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
96596 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
96597 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
96598 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
96599 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
96600 +spi_execute_28736 spi_execute 5 28736 NULL
96601 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
96602 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
96603 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
96604 +cxio_init_resource_fifo_28764 cxio_init_resource_fifo 3 28764 NULL
96605 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
96606 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
96607 +sel_write_member_28800 sel_write_member 3 28800 NULL
96608 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
96609 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0-8-3 28809 NULL
96610 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
96611 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
96612 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
96613 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
96614 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
96615 +tps6586x_update_28898 tps6586x_update 2 28898 NULL
96616 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
96617 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
96618 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
96619 +push_rx_28939 push_rx 3 28939 NULL
96620 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
96621 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
96622 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
96623 +bin_uuid_28999 bin_uuid 3 28999 NULL
96624 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
96625 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
96626 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
96627 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
96628 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
96629 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
96630 +ieee80211_probereq_get_29069 ieee80211_probereq_get 4-6 29069 NULL
96631 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
96632 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
96633 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
96634 +snprintf_29125 snprintf 0 29125 NULL
96635 +iov_shorten_29130 iov_shorten 0 29130 NULL
96636 +pm860x_reg_write_29141 pm860x_reg_write 2 29141 NULL
96637 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
96638 +reshape_ring_29147 reshape_ring 2 29147 NULL
96639 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
96640 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
96641 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
96642 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
96643 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
96644 +rds_iw_inc_copy_to_user_29214 rds_iw_inc_copy_to_user 3 29214 NULL
96645 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
96646 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
96647 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
96648 +recover_peb_29238 recover_peb 6-7 29238 NULL
96649 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
96650 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
96651 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
96652 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
96653 +fd_do_writev_29329 fd_do_writev 3 29329 NULL
96654 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
96655 +tun_put_user_29337 tun_put_user 5 29337 NULL
96656 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
96657 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
96658 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
96659 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
96660 +mempool_create_29437 mempool_create 1 29437 NULL
96661 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
96662 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
96663 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
96664 +do_register_entry_29478 do_register_entry 4 29478 NULL
96665 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
96666 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
96667 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
96668 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
96669 +ftrace_write_29551 ftrace_write 3 29551 NULL
96670 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
96671 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
96672 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
96673 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
96674 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
96675 +wm8903_gpio_set_29597 wm8903_gpio_set 2 29597 NULL
96676 +slots_per_page_29601 slots_per_page 0 29601 NULL
96677 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
96678 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
96679 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
96680 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
96681 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
96682 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
96683 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
96684 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
96685 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
96686 +probes_write_29711 probes_write 3 29711 NULL
96687 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
96688 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
96689 +da9055_gpio_direction_input_29742 da9055_gpio_direction_input 2 29742 NULL
96690 +cxio_hal_init_resource_29771 cxio_hal_init_resource 2-6-7 29771 NULL nohasharray
96691 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 &cxio_hal_init_resource_29771
96692 +dbAlloc_29794 dbAlloc 0 29794 NULL
96693 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
96694 +arizona_gpio_set_29823 arizona_gpio_set 2 29823 NULL
96695 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
96696 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
96697 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
96698 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
96699 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
96700 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
96701 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
96702 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
96703 +tps6586x_write_29894 tps6586x_write 2 29894 NULL
96704 +check586_29914 check586 2 29914 NULL
96705 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
96706 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
96707 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
96708 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
96709 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
96710 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
96711 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
96712 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
96713 +drp_wmove_30043 drp_wmove 4 30043 NULL
96714 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
96715 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
96716 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
96717 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
96718 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
96719 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
96720 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
96721 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
96722 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
96723 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
96724 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
96725 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
96726 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
96727 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
96728 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
96729 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
96730 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
96731 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
96732 +compat_readv_30273 compat_readv 3 30273 NULL
96733 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
96734 +__be64_to_cpup_30283 __be64_to_cpup 0 30283 NULL
96735 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
96736 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
96737 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
96738 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
96739 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
96740 +resource_from_user_30341 resource_from_user 3 30341 NULL
96741 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
96742 +sys_get_mempolicy_30379 sys_get_mempolicy 3 30379 NULL
96743 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
96744 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
96745 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
96746 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
96747 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
96748 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
96749 +enable_write_30456 enable_write 3 30456 NULL
96750 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
96751 +urandom_read_30462 urandom_read 3 30462 NULL
96752 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
96753 +write_head_30481 write_head 4 30481 NULL
96754 +adu_write_30487 adu_write 3 30487 NULL
96755 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
96756 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
96757 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
96758 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
96759 +set_le_30581 set_le 4 30581 NULL
96760 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
96761 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
96762 +sgl_map_user_pages_30610 sgl_map_user_pages 2 30610 NULL
96763 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
96764 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
96765 +nfsd_nrpools_30651 nfsd_nrpools 0 30651 NULL
96766 +agp_remap_30665 agp_remap 2 30665 NULL
96767 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
96768 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
96769 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
96770 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
96771 +snapshot_status_30744 snapshot_status 5 30744 NULL
96772 +max77693_update_reg_30747 max77693_update_reg 2 30747 NULL
96773 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
96774 +wm8350_read_auxadc_30780 wm8350_read_auxadc 2 30780 NULL
96775 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
96776 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
96777 +create_subvol_30836 create_subvol 4 30836 NULL
96778 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
96779 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL nohasharray
96780 +twl6040_set_bits_30844 twl6040_set_bits 2 30844 &cfg80211_rx_mgmt_30844
96781 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
96782 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
96783 +f1x_match_to_this_node_30888 f1x_match_to_this_node 3 30888 NULL
96784 +regmap_update_bits_check_30894 regmap_update_bits_check 2 30894 NULL
96785 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
96786 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
96787 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
96788 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
96789 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
96790 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
96791 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
96792 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
96793 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
96794 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
96795 +sys_mincore_31079 sys_mincore 1 31079 NULL
96796 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
96797 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
96798 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3 31109 NULL
96799 +depth_read_31112 depth_read 3 31112 NULL
96800 +ssb_read16_31139 ssb_read16 0 31139 NULL
96801 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
96802 +size_inside_page_31141 size_inside_page 0 31141 NULL
96803 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
96804 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
96805 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
96806 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
96807 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
96808 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
96809 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
96810 +__read_reg_31216 __read_reg 0 31216 NULL
96811 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
96812 +cyy_readb_31240 cyy_readb 0 31240 NULL
96813 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
96814 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
96815 +ceph_copy_page_vector_to_user_31270 ceph_copy_page_vector_to_user 3-4 31270 NULL
96816 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
96817 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
96818 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
96819 +futex_uaddr_31316 futex_uaddr 2 31316 NULL
96820 +command_file_write_31318 command_file_write 3 31318 NULL
96821 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
96822 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
96823 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3 31374 NULL
96824 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
96825 +inb_31388 inb 0 31388 NULL
96826 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
96827 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
96828 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
96829 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
96830 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
96831 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
96832 +_regmap_update_bits_31456 _regmap_update_bits 2 31456 NULL
96833 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
96834 +do_fcntl_31468 do_fcntl 3 31468 NULL
96835 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
96836 +alg_setkey_31485 alg_setkey 3 31485 NULL
96837 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
96838 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
96839 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
96840 +hidraw_write_31536 hidraw_write 3 31536 NULL
96841 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
96842 +usbvision_read_31555 usbvision_read 3 31555 NULL
96843 +normalize_31566 normalize 0-1-2 31566 NULL
96844 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
96845 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
96846 +osst_write_31581 osst_write 3 31581 NULL
96847 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
96848 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
96849 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
96850 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
96851 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
96852 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
96853 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
96854 +__lgread_31668 __lgread 4 31668 NULL
96855 +symbol_string_31670 symbol_string 0 31670 NULL
96856 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
96857 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
96858 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
96859 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
96860 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL
96861 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
96862 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
96863 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
96864 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
96865 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
96866 +lm3533_led_get_pattern_reg_31752 lm3533_led_get_pattern_reg 0-2 31752 NULL
96867 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
96868 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
96869 +get_count_order_31800 get_count_order 0 31800 NULL
96870 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
96871 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
96872 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
96873 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
96874 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
96875 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
96876 +xattr_permission_31907 xattr_permission 0 31907 NULL
96877 +new_dir_31919 new_dir 3 31919 NULL
96878 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
96879 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
96880 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
96881 +vb2_write_31948 vb2_write 3 31948 NULL
96882 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
96883 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
96884 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
96885 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
96886 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
96887 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
96888 +calc_hmac_32010 calc_hmac 3 32010 NULL
96889 +aead_len_32021 aead_len 0 32021 NULL
96890 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
96891 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
96892 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
96893 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
96894 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
96895 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
96896 +bio_alloc_32095 bio_alloc 2 32095 NULL
96897 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
96898 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
96899 +disk_status_32120 disk_status 4 32120 NULL
96900 +rc5t583_write_32124 rc5t583_write 2 32124 NULL
96901 +venus_link_32165 venus_link 5 32165 NULL
96902 +drbd_new_dev_size_32171 drbd_new_dev_size 0 32171 NULL
96903 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
96904 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
96905 +load_header_32183 load_header 0 32183 NULL
96906 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
96907 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
96908 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
96909 +lm3533_write_32236 lm3533_write 2 32236 NULL
96910 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
96911 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
96912 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
96913 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
96914 +hex_string_32310 hex_string 0 32310 NULL
96915 +flakey_status_32315 flakey_status 5 32315 NULL
96916 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
96917 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
96918 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
96919 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
96920 +f1x_translate_sysaddr_to_cs_32359 f1x_translate_sysaddr_to_cs 2 32359 NULL
96921 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
96922 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
96923 +variax_set_raw2_32374 variax_set_raw2 4 32374 NULL
96924 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
96925 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
96926 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
96927 +log_text_32428 log_text 0 32428 NULL
96928 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
96929 +hid_input_report_32458 hid_input_report 4 32458 NULL
96930 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
96931 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
96932 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
96933 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
96934 +disconnect_32521 disconnect 4 32521 NULL
96935 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
96936 +ilo_read_32531 ilo_read 3 32531 NULL
96937 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL nohasharray
96938 +crypt_status_32533 crypt_status 5 32533 &ieee80211_if_read_estab_plinks_32533
96939 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
96940 +__first_node_32558 __first_node 0 32558 NULL
96941 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
96942 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
96943 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
96944 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
96945 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
96946 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
96947 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
96948 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
96949 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
96950 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
96951 +kvmalloc_32646 kvmalloc 1 32646 NULL
96952 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
96953 +generic_readlink_32654 generic_readlink 3 32654 NULL
96954 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
96955 +tps80031_set_bits_32686 tps80031_set_bits 3 32686 NULL
96956 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
96957 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
96958 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
96959 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
96960 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
96961 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
96962 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
96963 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
96964 +vga_rseq_32848 vga_rseq 0 32848 NULL
96965 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
96966 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
96967 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
96968 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
96969 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
96970 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
96971 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
96972 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
96973 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
96974 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
96975 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
96976 +compat_filldir_32999 compat_filldir 3 32999 NULL
96977 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
96978 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
96979 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
96980 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
96981 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
96982 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
96983 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
96984 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
96985 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
96986 +write_node_33121 write_node 4 33121 NULL
96987 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
96988 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
96989 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
96990 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
96991 +pp_read_33210 pp_read 3 33210 NULL
96992 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
96993 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
96994 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
96995 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
96996 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
96997 +pcf50633_irq_mask_33280 pcf50633_irq_mask 2 33280 NULL
96998 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
96999 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
97000 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
97001 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
97002 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
97003 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
97004 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
97005 +ceph_osdc_writepages_33375 ceph_osdc_writepages 5 33375 NULL
97006 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
97007 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
97008 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
97009 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
97010 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
97011 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
97012 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
97013 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
97014 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
97015 +create_entry_33479 create_entry 2 33479 NULL
97016 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
97017 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
97018 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
97019 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
97020 +res_counter_read_33499 res_counter_read 4 33499 NULL
97021 +fb_read_33506 fb_read 3 33506 NULL
97022 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
97023 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
97024 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
97025 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
97026 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
97027 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
97028 +dup_array_33551 dup_array 3 33551 NULL
97029 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
97030 +count_subheaders_33591 count_subheaders 0 33591 NULL
97031 +scsi_execute_33596 scsi_execute 5 33596 NULL
97032 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
97033 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
97034 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
97035 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 NULL
97036 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
97037 +inw_p_33668 inw_p 0 33668 NULL
97038 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
97039 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
97040 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
97041 +rbd_alloc_coll_33678 rbd_alloc_coll 1 33678 NULL
97042 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
97043 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
97044 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
97045 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
97046 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
97047 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
97048 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
97049 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
97050 +Read_hfc_33755 Read_hfc 0 33755 NULL
97051 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
97052 +hashtab_create_33769 hashtab_create 3 33769 NULL
97053 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
97054 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
97055 +find_next_offset_33804 find_next_offset 3 33804 NULL
97056 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
97057 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
97058 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
97059 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
97060 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
97061 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
97062 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
97063 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
97064 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
97065 +config_proc_write_33878 config_proc_write 3 33878 NULL
97066 +get_user_pages_33908 get_user_pages 0 33908 NULL
97067 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
97068 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
97069 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
97070 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
97071 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
97072 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
97073 +ppp_write_34034 ppp_write 3 34034 NULL
97074 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
97075 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
97076 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
97077 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
97078 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
97079 +show_risefalltime_34084 show_risefalltime 4 34084 NULL
97080 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
97081 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
97082 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
97083 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
97084 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
97085 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
97086 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
97087 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
97088 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
97089 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
97090 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
97091 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
97092 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
97093 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
97094 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
97095 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
97096 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
97097 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
97098 +ea_read_34378 ea_read 0 34378 NULL
97099 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
97100 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
97101 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
97102 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 NULL nohasharray
97103 +iwl_calib_set_34400 iwl_calib_set 3 34400 &ivtv_read_pos_34400
97104 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
97105 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
97106 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
97107 +line6_dumpreq_init_34473 line6_dumpreq_init 3 34473 NULL
97108 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
97109 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
97110 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
97111 +alloc_buf_34532 alloc_buf 1 34532 NULL
97112 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
97113 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
97114 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
97115 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
97116 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
97117 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
97118 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
97119 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
97120 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
97121 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
97122 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
97123 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
97124 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
97125 +port_print_34704 port_print 3 34704 NULL
97126 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
97127 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
97128 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
97129 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
97130 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
97131 +ssd1307fb_write_array_34779 ssd1307fb_write_array 4 34779 NULL
97132 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
97133 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
97134 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
97135 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
97136 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
97137 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
97138 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
97139 +lm3533_ctrlbank_get_reg_34886 lm3533_ctrlbank_get_reg 0-2 34886 NULL
97140 +msg_print_text_34889 msg_print_text 0 34889 NULL
97141 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
97142 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
97143 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
97144 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
97145 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
97146 +Realloc_34961 Realloc 2 34961 NULL
97147 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
97148 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
97149 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
97150 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
97151 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
97152 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
97153 +store_ifalias_35088 store_ifalias 4 35088 NULL
97154 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
97155 +capi_write_35104 capi_write 3 35104 NULL nohasharray
97156 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
97157 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
97158 +pointer_35138 pointer 0 35138 NULL
97159 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
97160 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
97161 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
97162 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
97163 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
97164 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
97165 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
97166 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 NULL nohasharray
97167 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 &video_register_device_no_warn_35226
97168 +set_fd_set_35249 set_fd_set 1 35249 NULL
97169 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
97170 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
97171 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
97172 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
97173 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
97174 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
97175 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
97176 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
97177 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
97178 +new_bind_ctl_35324 new_bind_ctl 2 35324 NULL
97179 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
97180 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
97181 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
97182 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
97183 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
97184 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
97185 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
97186 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
97187 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
97188 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
97189 +rdev_get_id_35454 rdev_get_id 0 35454 NULL
97190 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
97191 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
97192 +async_setkey_35521 async_setkey 3 35521 NULL
97193 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
97194 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
97195 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
97196 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
97197 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
97198 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
97199 +ReadZReg_35604 ReadZReg 0 35604 NULL
97200 +kernel_readv_35617 kernel_readv 3 35617 NULL
97201 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
97202 +scrub_stripe_35637 scrub_stripe 4-3 35637 NULL
97203 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
97204 +store_debug_level_35652 store_debug_level 3 35652 NULL
97205 +regmap_update_bits_35668 regmap_update_bits 2 35668 NULL
97206 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
97207 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
97208 +dm_table_create_35687 dm_table_create 3 35687 NULL
97209 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
97210 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
97211 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
97212 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
97213 +read_file_stations_35795 read_file_stations 3 35795 NULL
97214 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
97215 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
97216 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
97217 +fls64_35862 fls64 0 35862 NULL
97218 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
97219 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
97220 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
97221 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
97222 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
97223 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
97224 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
97225 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
97226 +wm8350_reg_write_35967 wm8350_reg_write 2 35967 NULL
97227 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
97228 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
97229 +acl_alloc_35979 acl_alloc 1 35979 NULL
97230 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
97231 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
97232 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
97233 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
97234 +sys_init_module_36047 sys_init_module 2 36047 NULL
97235 +account_shadowed_36048 account_shadowed 2 36048 NULL
97236 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
97237 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
97238 +write_emulate_36065 write_emulate 2-4 36065 NULL
97239 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
97240 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
97241 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
97242 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
97243 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
97244 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
97245 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
97246 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
97247 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
97248 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
97249 +iwl_trans_txq_alloc_36147 iwl_trans_txq_alloc 3 36147 NULL
97250 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
97251 +twl_set_36154 twl_set 2 36154 NULL
97252 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
97253 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
97254 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
97255 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
97256 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
97257 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
97258 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
97259 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
97260 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
97261 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
97262 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
97263 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
97264 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
97265 +readahead_tree_block_36285 readahead_tree_block 3 36285 NULL
97266 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
97267 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
97268 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
97269 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
97270 +lc_create_36332 lc_create 4 36332 NULL
97271 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
97272 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
97273 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
97274 +to_sector_36361 to_sector 0-1 36361 NULL
97275 +tunables_read_36385 tunables_read 3 36385 NULL
97276 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
97277 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
97278 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
97279 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
97280 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
97281 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
97282 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
97283 +get_param_l_36518 get_param_l 0 36518 NULL
97284 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
97285 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
97286 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
97287 +ssd1307fb_write_data_array_36538 ssd1307fb_write_data_array 3 36538 NULL
97288 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
97289 +get_entry_len_36549 get_entry_len 0 36549 NULL
97290 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
97291 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
97292 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
97293 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
97294 +__erst_read_36579 __erst_read 0 36579 NULL
97295 +put_cmsg_36589 put_cmsg 4 36589 NULL
97296 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
97297 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
97298 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
97299 +format_decode_36638 format_decode 0 36638 NULL
97300 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
97301 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
97302 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
97303 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
97304 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
97305 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
97306 +snd_soc_update_bits_36714 snd_soc_update_bits 2 36714 NULL
97307 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
97308 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
97309 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
97310 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
97311 +snd_soc_update_bits_locked_36766 snd_soc_update_bits_locked 2 36766 NULL
97312 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
97313 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
97314 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
97315 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
97316 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
97317 +pcf50633_reg_write_36841 pcf50633_reg_write 2 36841 NULL nohasharray
97318 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 &pcf50633_reg_write_36841
97319 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
97320 +cm_write_36858 cm_write 3 36858 NULL
97321 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
97322 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
97323 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
97324 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
97325 +lm3533_als_get_target_36905 lm3533_als_get_target 2-3 36905 NULL
97326 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
97327 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
97328 +div_u64_36951 div_u64 0 36951 NULL
97329 +write_leb_36957 write_leb 5 36957 NULL
97330 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
97331 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
97332 +mc13xxx_reg_rmw_36997 mc13xxx_reg_rmw 2 36997 NULL
97333 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
97334 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
97335 +setxattr_37006 setxattr 4 37006 NULL
97336 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 NULL
97337 +parse_command_37079 parse_command 2 37079 NULL
97338 +wm8994_gpio_set_37082 wm8994_gpio_set 2 37082 NULL
97339 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
97340 +tun_get_user_37094 tun_get_user 5 37094 NULL
97341 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
97342 +msg_word_37164 msg_word 0 37164 NULL
97343 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
97344 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
97345 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
97346 +__do_replace_37227 __do_replace 5 37227 NULL
97347 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
97348 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
97349 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
97350 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
97351 +c101_run_37279 c101_run 2 37279 NULL
97352 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
97353 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
97354 +send_msg_37323 send_msg 4 37323 NULL
97355 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
97356 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
97357 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
97358 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
97359 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
97360 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
97361 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
97362 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
97363 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
97364 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
97365 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
97366 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
97367 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
97368 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
97369 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
97370 +get_est_timing_37484 get_est_timing 0 37484 NULL
97371 +xfs_trans_read_buf_map_37487 xfs_trans_read_buf_map 5 37487 NULL
97372 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
97373 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
97374 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
97375 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
97376 +hdr_size_37536 hdr_size 0 37536 NULL
97377 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
97378 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
97379 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
97380 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
97381 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6 37611 NULL
97382 +alloc_fd_37637 alloc_fd 1 37637 NULL
97383 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
97384 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
97385 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
97386 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
97387 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
97388 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
97389 +nametbl_header_37698 nametbl_header 2 37698 NULL
97390 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
97391 +soc_widget_update_bits_locked_37715 soc_widget_update_bits_locked 2 37715 NULL
97392 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
97393 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
97394 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
97395 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
97396 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
97397 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
97398 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
97399 +deny_write_access_37813 deny_write_access 0 37813 NULL
97400 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
97401 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
97402 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
97403 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
97404 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
97405 +lm3533_als_get_target_reg_37881 lm3533_als_get_target_reg 0-1-2 37881 NULL
97406 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
97407 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
97408 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
97409 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
97410 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
97411 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
97412 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
97413 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
97414 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
97415 +vfs_readv_38011 vfs_readv 3 38011 NULL
97416 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
97417 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
97418 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
97419 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL
97420 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
97421 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
97422 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
97423 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
97424 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
97425 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
97426 +ep0_read_38095 ep0_read 3 38095 NULL
97427 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
97428 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
97429 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
97430 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
97431 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
97432 +cdev_add_38176 cdev_add 2-3 38176 NULL
97433 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
97434 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
97435 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
97436 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
97437 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
97438 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
97439 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
97440 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
97441 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
97442 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
97443 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
97444 +verity_status_38273 verity_status 5 38273 NULL
97445 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
97446 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
97447 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
97448 +ieee80211_send_probe_req_38307 ieee80211_send_probe_req 6-4 38307 NULL
97449 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
97450 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
97451 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
97452 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
97453 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
97454 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
97455 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
97456 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
97457 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
97458 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
97459 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
97460 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
97461 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
97462 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
97463 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
97464 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
97465 +dev_names_read_38509 dev_names_read 3 38509 NULL
97466 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
97467 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
97468 +set_queue_count_38519 set_queue_count 0 38519 NULL
97469 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
97470 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
97471 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
97472 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
97473 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
97474 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
97475 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
97476 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
97477 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
97478 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
97479 +delay_status_38606 delay_status 5 38606 NULL
97480 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
97481 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
97482 +cma_create_area_38642 cma_create_area 2 38642 NULL
97483 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
97484 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
97485 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
97486 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
97487 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
97488 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
97489 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
97490 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
97491 +udf_readpages_38761 udf_readpages 4 38761 NULL
97492 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
97493 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
97494 +err_decode_38804 err_decode 2 38804 NULL
97495 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
97496 +sys_select_38827 sys_select 1 38827 NULL
97497 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
97498 +direct_entry_38836 direct_entry 3 38836 NULL
97499 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
97500 +interfaces_38859 interfaces 2 38859 NULL
97501 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
97502 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
97503 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
97504 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
97505 +__fswab16_38898 __fswab16 0 38898 NULL
97506 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
97507 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
97508 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
97509 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
97510 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
97511 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
97512 +udf_new_block_38999 udf_new_block 4 38999 NULL
97513 +get_nodes_39012 get_nodes 3 39012 NULL
97514 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
97515 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
97516 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
97517 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
97518 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
97519 +tun_get_user_39099 tun_get_user 4 39099 NULL
97520 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
97521 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
97522 +ea_foreach_39133 ea_foreach 0 39133 NULL
97523 +generic_permission_39150 generic_permission 0 39150 NULL
97524 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
97525 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
97526 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
97527 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
97528 +init_list_set_39188 init_list_set 2-3 39188 NULL
97529 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
97530 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
97531 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
97532 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
97533 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
97534 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
97535 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
97536 +drm_order_39244 drm_order 0 39244 NULL
97537 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
97538 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
97539 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
97540 +__skb_cow_39254 __skb_cow 2 39254 NULL
97541 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
97542 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
97543 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
97544 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
97545 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
97546 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
97547 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
97548 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
97549 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
97550 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
97551 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
97552 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
97553 +__send_to_port_39386 __send_to_port 3 39386 NULL
97554 +user_power_read_39414 user_power_read 3 39414 NULL
97555 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
97556 +sys_semop_39457 sys_semop 3 39457 NULL
97557 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
97558 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
97559 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
97560 +int_proc_write_39542 int_proc_write 3 39542 NULL
97561 +pp_write_39554 pp_write 3 39554 NULL
97562 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
97563 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
97564 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
97565 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
97566 +adau1373_set_pll_39593 adau1373_set_pll 2 39593 NULL
97567 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
97568 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
97569 +ext_depth_39607 ext_depth 0 39607 NULL
97570 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
97571 +sdio_readb_39618 sdio_readb 0 39618 NULL
97572 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
97573 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
97574 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
97575 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
97576 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
97577 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
97578 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
97579 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
97580 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
97581 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
97582 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
97583 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
97584 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
97585 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
97586 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
97587 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
97588 +pkt_add_39897 pkt_add 3 39897 NULL
97589 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
97590 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
97591 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
97592 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
97593 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
97594 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
97595 +__spi_async_39932 __spi_async 0 39932 NULL
97596 +__get_order_39935 __get_order 0 39935 NULL
97597 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
97598 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
97599 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
97600 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
97601 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
97602 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
97603 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
97604 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
97605 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
97606 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
97607 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
97608 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
97609 +add_tty_40055 add_tty 1 40055 NULL nohasharray
97610 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
97611 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
97612 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
97613 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
97614 +rbd_do_op_40128 rbd_do_op 4-5 40128 NULL
97615 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
97616 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
97617 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
97618 +pt_write_40159 pt_write 3 40159 NULL
97619 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
97620 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
97621 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
97622 +allocate_probes_40204 allocate_probes 1 40204 NULL
97623 +acpi_system_write_alarm_40205 acpi_system_write_alarm 3 40205 NULL
97624 +compat_put_long_40214 compat_put_long 1 40214 NULL
97625 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
97626 +xfs_buf_read_map_40226 xfs_buf_read_map 3 40226 NULL
97627 +osst_read_40237 osst_read 3 40237 NULL
97628 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
97629 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
97630 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
97631 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
97632 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
97633 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
97634 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
97635 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
97636 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
97637 +mmio_read_40348 mmio_read 4 40348 NULL
97638 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
97639 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
97640 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
97641 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
97642 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
97643 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
97644 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
97645 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
97646 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
97647 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
97648 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
97649 +tty_write_room_40495 tty_write_room 0 40495 NULL
97650 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
97651 +sg_phys_40507 sg_phys 0 40507 NULL
97652 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
97653 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
97654 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
97655 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
97656 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
97657 +arch_setup_hpet_msi_40584 arch_setup_hpet_msi 1 40584 NULL
97658 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
97659 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
97660 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
97661 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
97662 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
97663 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
97664 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
97665 +fops_read_40672 fops_read 3 40672 NULL
97666 +tps80031_write_40678 tps80031_write 3 40678 NULL
97667 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
97668 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
97669 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
97670 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
97671 +tps65910_irq_map_40748 tps65910_irq_map 2 40748 NULL
97672 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
97673 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
97674 +card_send_command_40757 card_send_command 3 40757 NULL
97675 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
97676 +pg_write_40766 pg_write 3 40766 NULL
97677 +show_list_40775 show_list 3 40775 NULL
97678 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
97679 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
97680 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
97681 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
97682 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
97683 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
97684 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
97685 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
97686 +read_file_queue_40895 read_file_queue 3 40895 NULL
97687 +waiters_read_40902 waiters_read 3 40902 NULL
97688 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
97689 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
97690 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
97691 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
97692 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
97693 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
97694 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
97695 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
97696 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
97697 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
97698 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
97699 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
97700 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
97701 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
97702 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
97703 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
97704 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
97705 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
97706 +dma_attach_41094 dma_attach 5-6 41094 NULL
97707 +provide_user_output_41105 provide_user_output 3 41105 NULL
97708 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
97709 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
97710 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
97711 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
97712 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
97713 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
97714 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
97715 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
97716 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
97717 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
97718 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
97719 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
97720 +erst_read_41260 erst_read 0 41260 NULL
97721 +__fprog_create_41263 __fprog_create 2 41263 NULL
97722 +alloc_context_41283 alloc_context 1 41283 NULL
97723 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
97724 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
97725 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
97726 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
97727 +kmp_init_41373 kmp_init 2 41373 NULL
97728 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
97729 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
97730 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
97731 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
97732 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
97733 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
97734 +ext4_trim_extent_41436 ext4_trim_extent 4 41436 NULL
97735 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
97736 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
97737 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
97738 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
97739 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
97740 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
97741 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
97742 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
97743 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
97744 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
97745 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
97746 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
97747 +gserial_setup_41558 gserial_setup 2 41558 NULL
97748 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
97749 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
97750 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
97751 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
97752 +vga_io_r_41609 vga_io_r 0 41609 NULL
97753 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
97754 +a2mp_send_41615 a2mp_send 4 41615 NULL
97755 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
97756 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
97757 +get_std_timing_41654 get_std_timing 0 41654 NULL
97758 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
97759 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
97760 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
97761 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
97762 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
97763 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
97764 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
97765 +fillonedir_41746 fillonedir 3 41746 NULL
97766 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
97767 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
97768 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
97769 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
97770 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
97771 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
97772 +irq_data_to_status_reg_41854 irq_data_to_status_reg 0 41854 NULL
97773 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
97774 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
97775 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
97776 +ceph_get_direct_page_vector_41917 ceph_get_direct_page_vector 2 41917 NULL
97777 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
97778 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
97779 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
97780 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
97781 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
97782 +portnames_read_41958 portnames_read 3 41958 NULL
97783 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
97784 +dst_mtu_41969 dst_mtu 0 41969 NULL
97785 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
97786 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
97787 +lguest_map_42008 lguest_map 1-2 42008 NULL
97788 +pool_allocate_42012 pool_allocate 3 42012 NULL
97789 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
97790 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
97791 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
97792 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
97793 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
97794 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
97795 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
97796 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
97797 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
97798 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
97799 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
97800 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL
97801 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
97802 +v9fs_alloc_rdir_buf_42150 v9fs_alloc_rdir_buf 2 42150 NULL
97803 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
97804 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
97805 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
97806 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
97807 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
97808 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
97809 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
97810 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
97811 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
97812 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
97813 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
97814 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
97815 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
97816 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
97817 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
97818 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
97819 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
97820 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
97821 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
97822 +krng_get_random_42420 krng_get_random 3 42420 NULL
97823 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
97824 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
97825 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
97826 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
97827 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
97828 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
97829 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
97830 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
97831 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
97832 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
97833 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
97834 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
97835 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
97836 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
97837 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
97838 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
97839 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
97840 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
97841 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
97842 +map_state_42602 map_state 1 42602 NULL nohasharray
97843 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
97844 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
97845 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
97846 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
97847 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
97848 +_regmap_raw_write_42652 _regmap_raw_write 4-2 42652 NULL
97849 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
97850 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
97851 +vb2_read_42703 vb2_read 3 42703 NULL
97852 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
97853 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
97854 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
97855 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
97856 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
97857 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
97858 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
97859 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
97860 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
97861 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
97862 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
97863 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
97864 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
97865 +set_arg_42824 set_arg 3 42824 NULL
97866 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
97867 +xfs_buf_read_uncached_42844 xfs_buf_read_uncached 3 42844 NULL
97868 +prandom_u32_42853 prandom_u32 0 42853 NULL
97869 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
97870 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
97871 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
97872 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
97873 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
97874 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
97875 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
97876 +hd_end_request_42904 hd_end_request 2 42904 NULL
97877 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
97878 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
97879 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
97880 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
97881 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
97882 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
97883 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
97884 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
97885 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
97886 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
97887 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
97888 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
97889 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
97890 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
97891 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
97892 +uuid_string_43154 uuid_string 0 43154 NULL
97893 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
97894 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
97895 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
97896 +process_measurement_43190 process_measurement 0 43190 NULL
97897 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
97898 +uio_write_43202 uio_write 3 43202 NULL
97899 +iso_callback_43208 iso_callback 3 43208 NULL
97900 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
97901 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
97902 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
97903 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
97904 +fixup_leb_43256 fixup_leb 3 43256 NULL
97905 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
97906 +evtchn_write_43278 evtchn_write 3 43278 NULL
97907 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
97908 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
97909 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
97910 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
97911 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
97912 +xenfb_write_43412 xenfb_write 3 43412 NULL
97913 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 NULL nohasharray
97914 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 &gdm_wimax_netif_rx_43423
97915 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
97916 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
97917 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
97918 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
97919 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
97920 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
97921 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
97922 +do_readlink_43518 do_readlink 2 43518 NULL
97923 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
97924 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
97925 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
97926 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
97927 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
97928 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
97929 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
97930 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
97931 +proc_read_43614 proc_read 3 43614 NULL
97932 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
97933 +tps65217_set_bits_43659 tps65217_set_bits 2 43659 NULL nohasharray
97934 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 &tps65217_set_bits_43659
97935 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
97936 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
97937 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
97938 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
97939 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
97940 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
97941 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
97942 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
97943 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
97944 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
97945 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
97946 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
97947 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
97948 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
97949 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
97950 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
97951 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
97952 +read_flush_43851 read_flush 3 43851 NULL
97953 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
97954 +pm860x_bulk_write_43875 pm860x_bulk_write 3-2 43875 NULL
97955 +ec_dbgfs_cmd_write_43895 ec_dbgfs_cmd_write 3 43895 NULL
97956 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
97957 +SendString_43928 SendString 3 43928 NULL
97958 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
97959 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
97960 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
97961 +nla_reserve_43984 nla_reserve 3 43984 NULL
97962 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
97963 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
97964 +emit_flags_44006 emit_flags 4-3 44006 NULL
97965 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
97966 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
97967 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
97968 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
97969 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
97970 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
97971 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
97972 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
97973 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
97974 +__set_free_44211 __set_free 2 44211 NULL
97975 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
97976 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
97977 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
97978 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
97979 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
97980 +enlarge_skb_44248 enlarge_skb 2 44248 NULL nohasharray
97981 +xfs_buf_readahead_map_44248 xfs_buf_readahead_map 3 44248 &enlarge_skb_44248
97982 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
97983 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
97984 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
97985 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
97986 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
97987 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
97988 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
97989 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
97990 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
97991 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
97992 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
97993 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
97994 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
97995 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
97996 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
97997 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
97998 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
97999 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
98000 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
98001 +spidev_write_44510 spidev_write 3 44510 NULL
98002 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
98003 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
98004 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
98005 +dbg_chk_pnode_44555 dbg_chk_pnode 0 44555 NULL
98006 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
98007 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
98008 +wm5100_gpio_set_44602 wm5100_gpio_set 2 44602 NULL
98009 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
98010 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
98011 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
98012 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
98013 +mpi_resize_44674 mpi_resize 2 44674 NULL
98014 +ts_read_44687 ts_read 3 44687 NULL
98015 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
98016 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
98017 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
98018 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
98019 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
98020 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
98021 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
98022 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
98023 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
98024 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
98025 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
98026 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
98027 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
98028 +sisusb_write_44834 sisusb_write 3 44834 NULL
98029 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
98030 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
98031 +skb_availroom_44883 skb_availroom 0 44883 NULL
98032 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
98033 +do_tty_write_44896 do_tty_write 5 44896 NULL
98034 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
98035 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
98036 +max77693_write_reg_45004 max77693_write_reg 2 45004 NULL
98037 +ftdi_process_packet_45005 ftdi_process_packet 5 45005 NULL
98038 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
98039 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
98040 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
98041 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
98042 +sel_write_user_45060 sel_write_user 3 45060 NULL
98043 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
98044 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
98045 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
98046 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
98047 +usbdev_read_45114 usbdev_read 3 45114 NULL
98048 +send_to_tty_45141 send_to_tty 3 45141 NULL
98049 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
98050 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
98051 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
98052 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
98053 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
98054 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
98055 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
98056 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
98057 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
98058 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
98059 +add_child_45201 add_child 4 45201 NULL
98060 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
98061 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
98062 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
98063 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
98064 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
98065 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
98066 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
98067 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
98068 +keymap_store_45406 keymap_store 4 45406 NULL
98069 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 NULL
98070 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
98071 +do_mmap_pgoff_45441 do_mmap_pgoff 0 45441 NULL
98072 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
98073 +__node_remap_45458 __node_remap 4 45458 NULL
98074 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
98075 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
98076 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
98077 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
98078 +arizona_init_fll_45503 arizona_init_fll 4-5 45503 NULL
98079 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
98080 +clone_bio_45516 clone_bio 6 45516 NULL
98081 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
98082 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
98083 +copy_macs_45534 copy_macs 4 45534 NULL
98084 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
98085 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
98086 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
98087 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
98088 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
98089 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
98090 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
98091 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
98092 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
98093 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
98094 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
98095 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
98096 +da9052_gpio_set_45643 da9052_gpio_set 2 45643 NULL
98097 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
98098 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
98099 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
98100 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
98101 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
98102 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
98103 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
98104 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
98105 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
98106 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
98107 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
98108 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
98109 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
98110 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
98111 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
98112 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
98113 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
98114 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
98115 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
98116 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
98117 +amthi_read_45831 amthi_read 4 45831 NULL
98118 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
98119 +isdn_write_45863 isdn_write 3 45863 NULL
98120 +rbd_get_num_segments_45864 rbd_get_num_segments 0-2-3 45864 NULL
98121 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
98122 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
98123 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
98124 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
98125 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
98126 +alloc_mr_45935 alloc_mr 1 45935 NULL
98127 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
98128 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
98129 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
98130 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
98131 +get_free_entries_46030 get_free_entries 1 46030 NULL
98132 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
98133 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
98134 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
98135 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
98136 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
98137 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
98138 +slhc_toss_46066 slhc_toss 0 46066 NULL
98139 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
98140 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
98141 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
98142 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
98143 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
98144 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
98145 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
98146 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
98147 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
98148 +qlcnic_alloc_msix_entries_46160 qlcnic_alloc_msix_entries 2 46160 NULL
98149 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
98150 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
98151 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
98152 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
98153 +dsp_write_46218 dsp_write 2 46218 NULL
98154 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
98155 +__le64_to_cpup_46257 __le64_to_cpup 0 46257 NULL
98156 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
98157 +ReadReg_46277 ReadReg 0 46277 NULL
98158 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
98159 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
98160 +twl6040_write_46351 twl6040_write 2 46351 NULL
98161 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
98162 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
98163 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
98164 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
98165 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
98166 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
98167 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
98168 +filldir64_46469 filldir64 3 46469 NULL
98169 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
98170 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
98171 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
98172 +kmsg_read_46514 kmsg_read 3 46514 NULL
98173 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
98174 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
98175 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
98176 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
98177 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
98178 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
98179 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
98180 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
98181 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
98182 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
98183 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
98184 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
98185 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
98186 +aircable_process_packet_46639 aircable_process_packet 5 46639 NULL
98187 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
98188 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
98189 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
98190 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
98191 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
98192 +prepare_copy_46725 prepare_copy 2 46725 NULL
98193 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
98194 +ext4_count_free_46754 ext4_count_free 2 46754 NULL
98195 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
98196 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
98197 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
98198 +scrub_chunk_46789 scrub_chunk 4 46789 NULL
98199 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
98200 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
98201 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
98202 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
98203 +ieee80211_rx_radiotap_len_46846 ieee80211_rx_radiotap_len 0 46846 NULL
98204 +spi_async_46857 spi_async 0 46857 NULL
98205 +ieee80211_mgmt_tx_46860 ieee80211_mgmt_tx 9 46860 NULL
98206 +vsnprintf_46863 vsnprintf 0 46863 NULL
98207 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
98208 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
98209 +rvmalloc_46873 rvmalloc 1 46873 NULL
98210 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
98211 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
98212 +em28xx_alloc_isoc_46892 em28xx_alloc_isoc 4 46892 NULL
98213 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
98214 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
98215 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
98216 +fb_write_46924 fb_write 3 46924 NULL
98217 +raid_status_46930 raid_status 5 46930 NULL
98218 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
98219 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
98220 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
98221 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
98222 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
98223 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
98224 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
98225 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
98226 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
98227 +__map_single_47020 __map_single 3-4-7 47020 NULL
98228 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
98229 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
98230 +wm8994_set_bits_47052 wm8994_set_bits 2 47052 NULL
98231 +fs_path_len_47060 fs_path_len 0 47060 NULL
98232 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
98233 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
98234 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
98235 +mousedev_read_47123 mousedev_read 3 47123 NULL
98236 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
98237 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
98238 +cxio_init_resource_fifo_random_47151 cxio_init_resource_fifo_random 3 47151 NULL
98239 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
98240 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
98241 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
98242 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
98243 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
98244 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
98245 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
98246 +wm8903_gpio_direction_in_47213 wm8903_gpio_direction_in 2 47213 NULL
98247 +l2headersize_47238 l2headersize 0 47238 NULL
98248 +options_write_47243 options_write 3 47243 NULL
98249 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
98250 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
98251 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
98252 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
98253 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
98254 +vsnprintf_47291 vsnprintf 0 47291 NULL
98255 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
98256 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
98257 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
98258 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
98259 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
98260 +trace_options_core_read_47390 trace_options_core_read 3 47390 NULL
98261 +nametbl_list_47391 nametbl_list 2 47391 NULL
98262 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
98263 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
98264 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
98265 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
98266 +vzalloc_47421 vzalloc 1 47421 NULL
98267 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
98268 +newpart_47485 newpart 6 47485 NULL
98269 +core_sys_select_47494 core_sys_select 1 47494 NULL
98270 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
98271 +unlink_simple_47506 unlink_simple 3 47506 NULL
98272 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
98273 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
98274 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
98275 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
98276 +oz_events_read_47535 oz_events_read 3 47535 NULL
98277 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
98278 +cycx_setup_47562 cycx_setup 4 47562 NULL
98279 +read_ldt_47570 read_ldt 2 47570 NULL
98280 +pci_iomap_47575 pci_iomap 3 47575 NULL
98281 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
98282 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
98283 +wm831x_gpio_direction_out_47607 wm831x_gpio_direction_out 2 47607 NULL
98284 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
98285 +uea_request_47613 uea_request 4 47613 NULL
98286 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
98287 +tps65217_clear_bits_47619 tps65217_clear_bits 2 47619 NULL
98288 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
98289 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
98290 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
98291 +irq_linear_revmap_47682 irq_linear_revmap 0 47682 NULL
98292 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
98293 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
98294 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
98295 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
98296 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
98297 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
98298 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
98299 +irq_domain_legacy_revmap_47765 irq_domain_legacy_revmap 0-2 47765 NULL
98300 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
98301 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
98302 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
98303 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
98304 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
98305 +__pcf50633_irq_mask_set_47847 __pcf50633_irq_mask_set 2 47847 NULL
98306 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
98307 +vhci_read_47878 vhci_read 3 47878 NULL
98308 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
98309 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
98310 +timeout_read_47915 timeout_read 3 47915 NULL
98311 +comedi_write_47926 comedi_write 3 47926 NULL
98312 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
98313 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
98314 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
98315 +pnpacpi_parse_allocated_irqresource_47986 pnpacpi_parse_allocated_irqresource 2 47986 NULL
98316 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
98317 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
98318 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
98319 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
98320 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
98321 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
98322 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
98323 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
98324 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
98325 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
98326 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
98327 +rtsx_read_cfg_seq_48139 rtsx_read_cfg_seq 5-3 48139 NULL
98328 +set_discoverable_48141 set_discoverable 4 48141 NULL
98329 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
98330 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
98331 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
98332 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
98333 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
98334 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
98335 +init_ipath_48187 init_ipath 1 48187 NULL nohasharray
98336 +ieee80211_send_auth_48187 ieee80211_send_auth 6 48187 &init_ipath_48187
98337 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
98338 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
98339 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
98340 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
98341 +read_file_recv_48232 read_file_recv 3 48232 NULL
98342 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL nohasharray
98343 +blk_rq_pos_48233 blk_rq_pos 0 48233 &unaccount_shadowed_48233
98344 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
98345 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
98346 +send_set_info_48288 send_set_info 7 48288 NULL
98347 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
98348 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
98349 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
98350 +hash_setkey_48310 hash_setkey 3 48310 NULL
98351 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
98352 +skb_add_data_48363 skb_add_data 3 48363 NULL
98353 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
98354 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
98355 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
98356 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
98357 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
98358 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
98359 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
98360 +send_control_msg_48498 send_control_msg 6 48498 NULL
98361 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
98362 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
98363 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
98364 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
98365 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
98366 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
98367 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
98368 +named_distribute_48544 named_distribute 4 48544 NULL
98369 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
98370 +ext_sd_execute_read_data_48589 ext_sd_execute_read_data 9 48589 NULL
98371 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
98372 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
98373 +mtd_read_48655 mtd_read 0 48655 NULL
98374 +lc_create_48662 lc_create 3 48662 NULL
98375 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
98376 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
98377 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
98378 +altera_drscan_48698 altera_drscan 2 48698 NULL
98379 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
98380 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
98381 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
98382 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
98383 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
98384 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
98385 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
98386 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
98387 +azx_get_position_48841 azx_get_position 0 48841 NULL
98388 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
98389 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
98390 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
98391 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
98392 +get_num_ops_48886 get_num_ops 0 48886 NULL
98393 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
98394 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
98395 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
98396 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
98397 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL nohasharray
98398 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 &gdth_isa_probe_one_48925
98399 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
98400 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
98401 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
98402 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
98403 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
98404 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
98405 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
98406 +xd_rw_49020 xd_rw 3-4 49020 NULL
98407 +transient_status_49027 transient_status 4 49027 NULL
98408 +ubi_read_49061 ubi_read 0 49061 NULL
98409 +tps65910_reg_write_49066 tps65910_reg_write 2 49066 NULL
98410 +calc_layout_49074 calc_layout 4 49074 NULL
98411 +vmx_set_msr_49090 vmx_set_msr 3 49090 NULL
98412 +scsi_register_49094 scsi_register 2 49094 NULL
98413 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
98414 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
98415 +pt_read_49136 pt_read 3 49136 NULL
98416 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
98417 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
98418 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
98419 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
98420 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
98421 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
98422 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
98423 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
98424 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
98425 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
98426 +pcf50633_gpio_invert_set_49256 pcf50633_gpio_invert_set 2 49256 NULL
98427 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
98428 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
98429 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
98430 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
98431 +uio_read_49300 uio_read 3 49300 NULL
98432 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
98433 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
98434 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
98435 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
98436 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
98437 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
98438 +px_raw_event_49371 px_raw_event 4 49371 NULL
98439 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
98440 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
98441 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
98442 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
98443 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
98444 +md_domain_init_49432 md_domain_init 2 49432 NULL
98445 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
98446 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
98447 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
98448 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
98449 +ieee80211_ie_split_49474 ieee80211_ie_split 0-5 49474 NULL
98450 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
98451 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
98452 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
98453 +wm831x_dcdc_set_mode_int_49546 wm831x_dcdc_set_mode_int 2 49546 NULL
98454 +smk_write_access_49561 smk_write_access 3 49561 NULL
98455 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
98456 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
98457 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
98458 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
98459 +heap_init_49617 heap_init 2 49617 NULL
98460 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
98461 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
98462 +svm_set_msr_49643 svm_set_msr 3 49643 NULL
98463 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
98464 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
98465 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
98466 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
98467 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
98468 +check_frame_49741 check_frame 0 49741 NULL
98469 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
98470 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
98471 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
98472 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
98473 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
98474 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
98475 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
98476 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
98477 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
98478 +add_uuid_49831 add_uuid 4 49831 NULL
98479 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
98480 +__btrfs_map_block_49839 __btrfs_map_block 3 49839 NULL
98481 +twl4030_write_49846 twl4030_write 2 49846 NULL
98482 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
98483 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
98484 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
98485 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
98486 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
98487 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
98488 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
98489 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
98490 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
98491 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
98492 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
98493 +__module_alloc_50004 __module_alloc 1 50004 NULL
98494 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
98495 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
98496 +isdn_read_50021 isdn_read 3 50021 NULL
98497 +rbd_req_write_50041 rbd_req_write 4-5 50041 NULL
98498 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
98499 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
98500 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
98501 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
98502 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
98503 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
98504 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
98505 +read_file_slot_50111 read_file_slot 3 50111 NULL
98506 +copy_items_50140 copy_items 6 50140 NULL
98507 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
98508 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
98509 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
98510 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
98511 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
98512 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
98513 +odev_update_50169 odev_update 2 50169 NULL
98514 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
98515 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
98516 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
98517 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
98518 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
98519 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
98520 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
98521 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
98522 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
98523 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
98524 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
98525 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
98526 +do_launder_page_50329 do_launder_page 0 50329 NULL
98527 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
98528 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
98529 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
98530 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
98531 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
98532 +tpm_read_50344 tpm_read 3 50344 NULL
98533 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
98534 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
98535 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
98536 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
98537 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
98538 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
98539 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
98540 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
98541 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
98542 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
98543 +tps65217_update_bits_50472 tps65217_update_bits 2 50472 NULL
98544 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
98545 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
98546 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
98547 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
98548 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
98549 +pcf50633_reg_set_bit_mask_50544 pcf50633_reg_set_bit_mask 2 50544 NULL
98550 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
98551 +fat_readpages_50582 fat_readpages 4 50582 NULL
98552 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
98553 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
98554 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
98555 +__ffs_50625 __ffs 0 50625 NULL
98556 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
98557 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
98558 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
98559 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
98560 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
98561 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
98562 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
98563 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
98564 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
98565 +skb_padto_50759 skb_padto 2 50759 NULL
98566 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
98567 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
98568 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
98569 +tpm_write_50798 tpm_write 3 50798 NULL
98570 +tun_do_read_50800 tun_do_read 4 50800 NULL
98571 +write_flush_50803 write_flush 3 50803 NULL
98572 +dvb_play_50814 dvb_play 3 50814 NULL
98573 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
98574 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
98575 +pstore_mkfile_50830 pstore_mkfile 5 50830 NULL
98576 +dma_attach_50831 dma_attach 6-7 50831 NULL
98577 +SetArea_50835 SetArea 4 50835 NULL nohasharray
98578 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
98579 +self_check_write_50856 self_check_write 5 50856 NULL
98580 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
98581 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
98582 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
98583 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
98584 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
98585 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
98586 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
98587 +sock_bindtodevice_50942 sock_bindtodevice 3 50942 NULL
98588 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
98589 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
98590 +timeout_write_50991 timeout_write 3 50991 NULL
98591 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL nohasharray
98592 +wm8903_gpio_direction_out_50995 wm8903_gpio_direction_out 2 50995 &wm831x_irq_map_50995
98593 +proc_write_51003 proc_write 3 51003 NULL
98594 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
98595 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
98596 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
98597 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
98598 +dump_midi_51040 dump_midi 3 51040 NULL
98599 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
98600 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
98601 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
98602 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
98603 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
98604 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
98605 +lm3533_als_get_current_51120 lm3533_als_get_current 2 51120 NULL
98606 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
98607 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
98608 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
98609 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
98610 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
98611 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
98612 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
98613 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
98614 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
98615 +tipc_send_51238 tipc_send 4 51238 NULL
98616 +drm_property_create_51239 drm_property_create 4 51239 NULL
98617 +st_read_51251 st_read 3 51251 NULL
98618 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
98619 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
98620 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
98621 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
98622 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
98623 +fd_do_readv_51297 fd_do_readv 3 51297 NULL
98624 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
98625 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
98626 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
98627 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
98628 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
98629 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
98630 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
98631 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
98632 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
98633 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
98634 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
98635 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
98636 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
98637 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
98638 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
98639 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
98640 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
98641 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
98642 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
98643 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
98644 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
98645 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
98646 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
98647 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
98648 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
98649 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
98650 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
98651 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
98652 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
98653 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
98654 +sel_write_access_51704 sel_write_access 3 51704 NULL
98655 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
98656 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
98657 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
98658 +msg_set_51725 msg_set 3 51725 NULL
98659 +dbg_check_lpt_nodes_51727 dbg_check_lpt_nodes 0 51727 NULL
98660 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
98661 +get_user_pages_fast_51751 get_user_pages_fast 0 51751 NULL
98662 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
98663 +if_write_51756 if_write 3 51756 NULL
98664 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
98665 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
98666 +__fswab32_51781 __fswab32 0 51781 NULL
98667 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
98668 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
98669 +wm2000_write_51834 wm2000_write 2 51834 NULL
98670 +ioread32_51847 ioread32 0 51847 NULL nohasharray
98671 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
98672 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
98673 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
98674 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
98675 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
98676 +user_read_51881 user_read 3 51881 NULL
98677 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
98678 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
98679 +iio_read_first_n_sw_rb_51911 iio_read_first_n_sw_rb 2 51911 NULL
98680 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
98681 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
98682 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
98683 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
98684 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
98685 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
98686 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
98687 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
98688 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
98689 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
98690 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
98691 +rdmalt_52022 rdmalt 0 52022 NULL
98692 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
98693 +override_release_52032 override_release 2 52032 NULL
98694 +end_port_52042 end_port 0 52042 NULL
98695 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
98696 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
98697 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
98698 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
98699 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
98700 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
98701 +retry_count_read_52129 retry_count_read 3 52129 NULL
98702 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
98703 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
98704 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
98705 +htable_size_52148 htable_size 0-1 52148 NULL
98706 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
98707 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
98708 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
98709 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
98710 +print_prefix_52176 print_prefix 0 52176 NULL
98711 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
98712 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
98713 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
98714 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
98715 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
98716 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
98717 +mpol_to_str_52293 mpol_to_str 2 52293 NULL
98718 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
98719 +read_file_reset_52310 read_file_reset 3 52310 NULL
98720 +ssd1307fb_write_52315 ssd1307fb_write 3 52315 NULL
98721 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
98722 +hwflags_read_52318 hwflags_read 3 52318 NULL
98723 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
98724 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
98725 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
98726 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
98727 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
98728 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
98729 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
98730 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
98731 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
98732 +pcf50633_reg_clear_bits_52407 pcf50633_reg_clear_bits 2 52407 NULL
98733 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
98734 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
98735 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
98736 +delay_status_52431 delay_status 5 52431 NULL
98737 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
98738 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
98739 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
98740 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
98741 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
98742 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
98743 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
98744 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
98745 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
98746 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
98747 +emit_code_52583 emit_code 0-3 52583 NULL
98748 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
98749 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
98750 +ntfs_get_nr_significant_bytes_52688 ntfs_get_nr_significant_bytes 0 52688 NULL
98751 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
98752 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
98753 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
98754 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
98755 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
98756 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
98757 +alloc_extent_buffer_52824 alloc_extent_buffer 3 52824 NULL
98758 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
98759 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
98760 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
98761 +twlreg_write_52880 twlreg_write 3 52880 NULL
98762 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
98763 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
98764 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
98765 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
98766 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
98767 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
98768 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
98769 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
98770 +send_packet_52960 send_packet 4 52960 NULL
98771 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
98772 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 NULL
98773 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
98774 +num_node_state_52989 num_node_state 0 52989 NULL
98775 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
98776 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
98777 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
98778 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
98779 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
98780 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
98781 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
98782 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
98783 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
98784 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
98785 +verity_status_53120 verity_status 5 53120 NULL
98786 +line6_dumpreq_initbuf_53123 line6_dumpreq_initbuf 3 53123 NULL
98787 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
98788 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
98789 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
98790 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
98791 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
98792 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
98793 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
98794 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
98795 +lirc_buffer_init_53282 lirc_buffer_init 3-2 53282 NULL
98796 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
98797 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
98798 +vm_mmap_53339 vm_mmap 0 53339 NULL
98799 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
98800 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
98801 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
98802 +wm8996_gpio_set_53421 wm8996_gpio_set 2 53421 NULL
98803 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
98804 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
98805 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
98806 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
98807 +n2_run_53459 n2_run 3 53459 NULL
98808 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
98809 +wm831x_write_53469 wm831x_write 2 53469 NULL
98810 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
98811 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
98812 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
98813 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
98814 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
98815 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
98816 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
98817 +check_acl_53512 check_acl 0 53512 NULL
98818 +set_registers_53582 set_registers 3 53582 NULL
98819 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
98820 +__readw_53594 __readw 0 53594 NULL
98821 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
98822 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
98823 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
98824 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
98825 +_preload_range_53676 _preload_range 2-3 53676 NULL
98826 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
98827 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
98828 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 NULL nohasharray
98829 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 &igb_alloc_q_vector_53690
98830 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
98831 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
98832 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
98833 +wdm_write_53735 wdm_write 3 53735 NULL
98834 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
98835 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
98836 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
98837 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
98838 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
98839 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
98840 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
98841 +regmap_raw_write_53803 regmap_raw_write 4-2 53803 NULL
98842 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
98843 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
98844 +cpumask_next_zero_53835 cpumask_next_zero 1 53835 NULL
98845 +pms_read_53873 pms_read 3 53873 NULL
98846 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
98847 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
98848 +proc_file_read_53905 proc_file_read 3 53905 NULL
98849 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
98850 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
98851 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
98852 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
98853 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
98854 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
98855 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
98856 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
98857 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
98858 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
98859 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
98860 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
98861 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
98862 +_malloc_54077 _malloc 1 54077 NULL
98863 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
98864 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
98865 +create_xattr_54106 create_xattr 5 54106 NULL
98866 +strn_len_54122 strn_len 0 54122 NULL
98867 +isku_receive_54130 isku_receive 4 54130 NULL
98868 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
98869 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
98870 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
98871 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
98872 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
98873 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
98874 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
98875 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
98876 +reada_add_block_54247 reada_add_block 2 54247 NULL
98877 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
98878 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
98879 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
98880 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
98881 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
98882 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
98883 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
98884 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
98885 +sprintf_54306 sprintf 0 54306 NULL
98886 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
98887 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
98888 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
98889 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
98890 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
98891 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
98892 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
98893 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
98894 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
98895 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
98896 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
98897 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
98898 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
98899 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
98900 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
98901 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
98902 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
98903 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
98904 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL
98905 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
98906 +viacam_read_54526 viacam_read 3 54526 NULL
98907 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
98908 +setsockopt_54539 setsockopt 5 54539 NULL
98909 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
98910 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
98911 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
98912 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
98913 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
98914 +irq_of_parse_and_map_54646 irq_of_parse_and_map 0 54646 NULL
98915 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
98916 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
98917 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
98918 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
98919 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
98920 +evm_read_key_54674 evm_read_key 3 54674 NULL
98921 +resource_string_54699 resource_string 0 54699 NULL
98922 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
98923 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
98924 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
98925 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
98926 +kzalloc_54740 kzalloc 1 54740 NULL
98927 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
98928 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
98929 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
98930 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
98931 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
98932 +domain_init_54797 domain_init 2 54797 NULL
98933 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
98934 +nfsd_write_54809 nfsd_write 6 54809 NULL
98935 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
98936 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
98937 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
98938 +write_rio_54837 write_rio 3 54837 NULL
98939 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
98940 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
98941 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
98942 +printer_read_54851 printer_read 3 54851 NULL
98943 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
98944 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
98945 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
98946 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
98947 +lm3533_led_get_lv_reg_54900 lm3533_led_get_lv_reg 0-2 54900 NULL
98948 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
98949 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
98950 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
98951 +add_port_54941 add_port 2 54941 NULL
98952 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
98953 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
98954 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
98955 +c4_add_card_54968 c4_add_card 3 54968 NULL
98956 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
98957 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
98958 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
98959 +rds_ib_inc_copy_to_user_55007 rds_ib_inc_copy_to_user 3 55007 NULL
98960 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
98961 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
98962 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
98963 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
98964 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
98965 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL
98966 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
98967 +corrupt_data_55120 corrupt_data 0 55120 NULL
98968 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
98969 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
98970 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
98971 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
98972 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
98973 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
98974 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
98975 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
98976 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL nohasharray
98977 +pcf50633_gpio_set_55209 pcf50633_gpio_set 2 55209 &ht40allow_map_read_55209
98978 +ssd1307fb_write_cmd_array_55211 ssd1307fb_write_cmd_array 3 55211 NULL nohasharray
98979 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 &ssd1307fb_write_cmd_array_55211
98980 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
98981 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
98982 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
98983 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
98984 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
98985 +ptrace_request_55288 ptrace_request 3 55288 NULL
98986 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
98987 +rbd_create_rw_ops_55297 rbd_create_rw_ops 1 55297 NULL
98988 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
98989 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 NULL
98990 +vme_user_read_55338 vme_user_read 3 55338 NULL
98991 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
98992 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
98993 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
98994 +__send_to_port_55383 __send_to_port 3 55383 NULL
98995 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
98996 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
98997 +alloc_skb_55439 alloc_skb 1 55439 NULL
98998 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
98999 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
99000 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
99001 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
99002 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
99003 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
99004 +wm5100_gpio_direction_out_55497 wm5100_gpio_direction_out 2 55497 NULL
99005 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
99006 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
99007 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
99008 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
99009 +ea_get_55522 ea_get 0 55522 NULL
99010 +buffer_size_55534 buffer_size 0 55534 NULL
99011 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
99012 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
99013 +add_partition_55588 add_partition 2 55588 NULL
99014 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
99015 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
99016 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
99017 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
99018 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
99019 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
99020 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
99021 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
99022 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
99023 +read_oldmem_55658 read_oldmem 3 55658 NULL
99024 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
99025 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
99026 +get_info_55681 get_info 3 55681 NULL
99027 +arizona_gpio_direction_in_55690 arizona_gpio_direction_in 2 55690 NULL
99028 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
99029 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
99030 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
99031 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
99032 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 3-2 55738 NULL
99033 +set_local_name_55757 set_local_name 4 55757 NULL
99034 +btrfs_init_new_buffer_55761 btrfs_init_new_buffer 4 55761 NULL
99035 +strlen_55778 strlen 0 55778 NULL nohasharray
99036 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
99037 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
99038 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
99039 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
99040 +btrfs_find_create_tree_block_55812 btrfs_find_create_tree_block 3 55812 NULL
99041 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
99042 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
99043 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
99044 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
99045 +hsc_write_55875 hsc_write 3 55875 NULL
99046 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
99047 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
99048 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
99049 +handle_response_55951 handle_response 5 55951 NULL
99050 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
99051 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
99052 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
99053 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
99054 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
99055 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
99056 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
99057 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
99058 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
99059 +map_addr_56144 map_addr 7 56144 NULL
99060 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
99061 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
99062 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
99063 +skb_headroom_56200 skb_headroom 0 56200 NULL
99064 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
99065 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
99066 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
99067 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
99068 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
99069 +scrub_setup_recheck_block_56245 scrub_setup_recheck_block 4-3 56245 NULL
99070 +fd_copyin_56247 fd_copyin 3 56247 NULL
99071 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
99072 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
99073 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
99074 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
99075 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
99076 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
99077 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
99078 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
99079 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
99080 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
99081 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
99082 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
99083 +tps80031_ext_power_req_config_56353 tps80031_ext_power_req_config 3-4-5 56353 NULL
99084 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
99085 +dev_read_56369 dev_read 3 56369 NULL
99086 +alloc_dummy_extent_buffer_56374 alloc_dummy_extent_buffer 2 56374 NULL
99087 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
99088 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
99089 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
99090 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
99091 +store_msg_56417 store_msg 3 56417 NULL
99092 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
99093 +ec_dbgfs_cmd_read_56431 ec_dbgfs_cmd_read 3 56431 NULL
99094 +fl_create_56435 fl_create 5 56435 NULL
99095 +gnttab_map_56439 gnttab_map 2 56439 NULL
99096 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
99097 +set_connectable_56458 set_connectable 4 56458 NULL
99098 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
99099 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
99100 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
99101 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
99102 +ip_options_get_56538 ip_options_get 4 56538 NULL
99103 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
99104 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
99105 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
99106 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
99107 +event_filter_write_56609 event_filter_write 3 56609 NULL
99108 +gather_array_56641 gather_array 3 56641 NULL
99109 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
99110 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
99111 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
99112 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
99113 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
99114 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
99115 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
99116 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
99117 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
99118 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
99119 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
99120 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
99121 +do_syslog_56807 do_syslog 3 56807 NULL
99122 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
99123 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
99124 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
99125 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
99126 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
99127 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
99128 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
99129 +strcspn_56913 strcspn 0 56913 NULL
99130 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
99131 +check_header_56930 check_header 2 56930 NULL
99132 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
99133 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
99134 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
99135 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
99136 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
99137 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
99138 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
99139 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
99140 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
99141 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
99142 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
99143 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
99144 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
99145 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
99146 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
99147 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
99148 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
99149 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
99150 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
99151 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
99152 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
99153 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
99154 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
99155 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
99156 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
99157 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
99158 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
99159 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
99160 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
99161 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
99162 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
99163 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
99164 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
99165 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
99166 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
99167 +fw_file_size_57307 fw_file_size 0 57307 NULL
99168 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
99169 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
99170 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
99171 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
99172 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
99173 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
99174 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
99175 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
99176 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
99177 +read_file_blob_57406 read_file_blob 3 57406 NULL
99178 +enclosure_register_57412 enclosure_register 3 57412 NULL
99179 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
99180 +wm831x_gpio_set_debounce_57428 wm831x_gpio_set_debounce 2 57428 NULL
99181 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
99182 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
99183 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
99184 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
99185 +ReadReg_57453 ReadReg 0 57453 NULL
99186 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
99187 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
99188 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
99189 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
99190 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
99191 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
99192 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
99193 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
99194 +skb_headlen_57501 skb_headlen 0 57501 NULL
99195 +copy_in_user_57502 copy_in_user 3 57502 NULL
99196 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
99197 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
99198 +init_tag_map_57515 init_tag_map 3 57515 NULL
99199 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
99200 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
99201 +inode_permission_57531 inode_permission 0 57531 NULL
99202 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
99203 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
99204 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
99205 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
99206 +lp8788_update_bits_57600 lp8788_update_bits 2 57600 NULL
99207 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
99208 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
99209 +tps65217_reg_write_57623 tps65217_reg_write 2 57623 NULL nohasharray
99210 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 &tps65217_reg_write_57623
99211 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
99212 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
99213 +mem_read_57631 mem_read 3 57631 NULL
99214 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
99215 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
99216 +r3964_write_57662 r3964_write 4 57662 NULL
99217 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
99218 +__lgwrite_57669 __lgwrite 4 57669 NULL
99219 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
99220 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
99221 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
99222 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
99223 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
99224 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
99225 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
99226 +ld2_57794 ld2 0 57794 NULL
99227 +ivtv_read_57796 ivtv_read 3 57796 NULL
99228 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
99229 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
99230 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
99231 +copy_to_user_57835 copy_to_user 3 57835 NULL
99232 +flash_read_57843 flash_read 3 57843 NULL
99233 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
99234 +ad5380_info_to_reg_57905 ad5380_info_to_reg 0 57905 NULL
99235 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
99236 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
99237 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
99238 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
99239 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
99240 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
99241 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
99242 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
99243 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
99244 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
99245 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
99246 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
99247 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
99248 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
99249 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
99250 +mc13783_write_58033 mc13783_write 2 58033 NULL
99251 +mce_async_out_58056 mce_async_out 3 58056 NULL
99252 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
99253 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
99254 +cm4040_write_58079 cm4040_write 3 58079 NULL
99255 +udi_log_event_58105 udi_log_event 3 58105 NULL
99256 +savemem_58129 savemem 3 58129 NULL
99257 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
99258 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
99259 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
99260 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
99261 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
99262 +btrfs_mksubvol_58240 btrfs_mksubvol 3 58240 NULL
99263 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
99264 +read_file_debug_58256 read_file_debug 3 58256 NULL
99265 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
99266 +profile_load_58267 profile_load 3 58267 NULL
99267 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
99268 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
99269 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
99270 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
99271 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
99272 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
99273 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
99274 +ieee80211_send_probe_req_58337 ieee80211_send_probe_req 4-6 58337 NULL
99275 +next_pidmap_58347 next_pidmap 2 58347 NULL
99276 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
99277 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
99278 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
99279 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
99280 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
99281 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
99282 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
99283 +capabilities_read_58457 capabilities_read 3 58457 NULL
99284 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
99285 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
99286 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
99287 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
99288 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
99289 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
99290 +wm831x_reg_write_58489 wm831x_reg_write 2 58489 NULL
99291 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
99292 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
99293 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
99294 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
99295 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
99296 +xip_file_read_58592 xip_file_read 3 58592 NULL
99297 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
99298 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
99299 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
99300 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
99301 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
99302 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
99303 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
99304 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
99305 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
99306 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
99307 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
99308 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
99309 +acpi_map_58725 acpi_map 1-2 58725 NULL
99310 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
99311 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
99312 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
99313 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
99314 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
99315 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
99316 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
99317 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
99318 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
99319 +ep_read_58813 ep_read 3 58813 NULL
99320 +command_write_58841 command_write 3 58841 NULL
99321 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
99322 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
99323 +hw_write_58881 hw_write 2 58881 NULL
99324 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
99325 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
99326 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
99327 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
99328 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
99329 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
99330 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
99331 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
99332 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
99333 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
99334 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
99335 +ep_write_59008 ep_write 3 59008 NULL
99336 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
99337 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
99338 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
99339 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
99340 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
99341 +da9052_gpio_direction_input_59062 da9052_gpio_direction_input 2 59062 NULL
99342 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
99343 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
99344 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
99345 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
99346 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
99347 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
99348 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
99349 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
99350 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
99351 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
99352 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
99353 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
99354 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
99355 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
99356 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
99357 +dt3155_read_59226 dt3155_read 3 59226 NULL
99358 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
99359 +rbd_do_request_59239 rbd_do_request 6-7 59239 NULL
99360 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
99361 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
99362 +nla_len_59258 nla_len 0 59258 NULL
99363 +da9055_reg_update_59280 da9055_reg_update 2 59280 NULL
99364 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
99365 +fd_copyout_59323 fd_copyout 3 59323 NULL
99366 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
99367 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
99368 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 NULL
99369 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
99370 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
99371 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
99372 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
99373 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
99374 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
99375 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
99376 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
99377 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
99378 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
99379 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
99380 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
99381 +rds_pin_pages_59507 rds_pin_pages 0 59507 NULL
99382 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
99383 +tunables_write_59563 tunables_write 3 59563 NULL
99384 +memdup_user_59590 memdup_user 2 59590 NULL
99385 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
99386 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
99387 +mtrr_write_59622 mtrr_write 3 59622 NULL
99388 +ip_vs_icmp_xmit_59624 ip_vs_icmp_xmit 4 59624 NULL
99389 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
99390 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
99391 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
99392 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
99393 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
99394 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
99395 +wm8400_write_59675 wm8400_write 2 59675 NULL
99396 +sriov_enable_59689 sriov_enable 2 59689 NULL
99397 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
99398 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
99399 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
99400 +wm8996_gpio_direction_in_59739 wm8996_gpio_direction_in 2 59739 NULL
99401 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
99402 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
99403 +strnlen_59746 strnlen 0 59746 NULL
99404 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
99405 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
99406 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
99407 +sec_reg_update_59771 sec_reg_update 2 59771 NULL
99408 +venus_remove_59781 venus_remove 4 59781 NULL
99409 +xlog_do_recover_59789 xlog_do_recover 3 59789 NULL
99410 +ipw_write_59807 ipw_write 3 59807 NULL
99411 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
99412 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
99413 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
99414 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
99415 +fs64_to_cpu_59845 fs64_to_cpu 0 59845 NULL
99416 +tun_put_user_59849 tun_put_user 4 59849 NULL
99417 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
99418 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
99419 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
99420 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
99421 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
99422 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 NULL nohasharray
99423 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 &compat_ipmi_ioctl_59956
99424 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
99425 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
99426 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
99427 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
99428 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
99429 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
99430 +register_device_60015 register_device 2-3 60015 NULL
99431 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
99432 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
99433 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
99434 +ceph_calc_raw_layout_60035 ceph_calc_raw_layout 4 60035 NULL
99435 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
99436 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
99437 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
99438 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
99439 +load_module_60056 load_module 2 60056 NULL nohasharray
99440 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 &load_module_60056
99441 +compat_writev_60063 compat_writev 3 60063 NULL
99442 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 8-6 60064 NULL
99443 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
99444 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
99445 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
99446 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
99447 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
99448 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
99449 +init_state_60165 init_state 2 60165 NULL
99450 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
99451 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
99452 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
99453 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
99454 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
99455 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
99456 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
99457 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
99458 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
99459 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL
99460 +lp8788_select_buck_vout_addr_60241 lp8788_select_buck_vout_addr 0 60241 NULL
99461 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
99462 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
99463 +printer_write_60276 printer_write 3 60276 NULL
99464 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
99465 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
99466 +getDataLength_60301 getDataLength 0 60301 NULL
99467 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
99468 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
99469 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
99470 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
99471 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
99472 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
99473 +driver_names_read_60399 driver_names_read 3 60399 NULL
99474 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
99475 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
99476 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
99477 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
99478 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
99479 +rx_data_60442 rx_data 4 60442 NULL
99480 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
99481 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
99482 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
99483 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
99484 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
99485 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
99486 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
99487 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
99488 +usb_control_msg_60624 usb_control_msg 0 60624 NULL
99489 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
99490 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
99491 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
99492 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
99493 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
99494 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
99495 +init_data_container_60709 init_data_container 1 60709 NULL
99496 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
99497 +raid_status_60755 raid_status 5 60755 NULL
99498 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
99499 +opticon_write_60775 opticon_write 4 60775 NULL
99500 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
99501 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
99502 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
99503 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
99504 +alloc_irq_from_60868 alloc_irq_from 1 60868 NULL
99505 +generic_writepages_60871 generic_writepages 0 60871 NULL
99506 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
99507 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
99508 +wm8962_gpio_set_60894 wm8962_gpio_set 2 60894 NULL
99509 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
99510 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
99511 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
99512 +pti_char_write_60960 pti_char_write 3 60960 NULL
99513 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
99514 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
99515 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
99516 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
99517 +symtab_init_61050 symtab_init 2 61050 NULL
99518 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
99519 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
99520 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
99521 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
99522 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
99523 +get_derived_key_61100 get_derived_key 4 61100 NULL
99524 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
99525 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
99526 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
99527 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
99528 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
99529 +__vmalloc_61168 __vmalloc 1 61168 NULL
99530 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
99531 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
99532 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
99533 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
99534 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
99535 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
99536 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
99537 +sys_add_key_61288 sys_add_key 4 61288 NULL
99538 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
99539 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
99540 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
99541 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
99542 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
99543 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
99544 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
99545 +change_xattr_61390 change_xattr 5 61390 NULL
99546 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
99547 +irq_create_of_mapping_61428 irq_create_of_mapping 0 61428 NULL
99548 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
99549 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
99550 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
99551 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
99552 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
99553 +mc13xxx_reg_write_61490 mc13xxx_reg_write 2 61490 NULL
99554 +erst_errno_61526 erst_errno 0 61526 NULL
99555 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
99556 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
99557 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
99558 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
99559 +seq_open_private_61589 seq_open_private 3 61589 NULL
99560 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
99561 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
99562 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
99563 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
99564 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
99565 +ieee80211_rx_bss_info_61630 ieee80211_rx_bss_info 3 61630 NULL
99566 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
99567 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
99568 +resize_stripes_61650 resize_stripes 2 61650 NULL
99569 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
99570 +insert_one_name_61668 insert_one_name 7 61668 NULL
99571 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
99572 +lock_loop_61681 lock_loop 1 61681 NULL
99573 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
99574 +filter_read_61692 filter_read 3 61692 NULL
99575 +iov_length_61716 iov_length 0 61716 NULL
99576 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
99577 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
99578 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
99579 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
99580 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
99581 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
99582 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
99583 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
99584 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
99585 +get_fw_name_61874 get_fw_name 3 61874 NULL
99586 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
99587 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
99588 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
99589 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
99590 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
99591 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
99592 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
99593 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
99594 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
99595 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
99596 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
99597 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
99598 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
99599 +cow_file_range_61979 cow_file_range 3 61979 NULL
99600 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
99601 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
99602 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
99603 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
99604 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
99605 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
99606 +do_pselect_62061 do_pselect 1 62061 NULL
99607 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
99608 +__next_gcwq_cpu_62078 __next_gcwq_cpu 1 62078 NULL
99609 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
99610 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
99611 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
99612 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
99613 +ql_status_62135 ql_status 5 62135 NULL
99614 +video_usercopy_62151 video_usercopy 2 62151 NULL
99615 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
99616 +_irq_to_addr_62183 _irq_to_addr 0-1 62183 NULL
99617 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
99618 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
99619 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
99620 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
99621 +allocate_partition_62245 allocate_partition 4 62245 NULL
99622 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
99623 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
99624 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
99625 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
99626 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
99627 +subseq_list_62332 subseq_list 3-0 62332 NULL
99628 +flash_write_62354 flash_write 3 62354 NULL
99629 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
99630 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
99631 +altera_irscan_62396 altera_irscan 2 62396 NULL
99632 +set_ssp_62411 set_ssp 4 62411 NULL
99633 +tscadc_writel_62426 tscadc_writel 2 62426 NULL
99634 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
99635 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
99636 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
99637 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
99638 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
99639 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
99640 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
99641 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
99642 +debugfs_read_62535 debugfs_read 3 62535 NULL
99643 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
99644 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
99645 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
99646 +get_subdir_62581 get_subdir 3 62581 NULL
99647 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
99648 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
99649 +get_desc_base_62617 get_desc_base 0 62617 NULL
99650 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
99651 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
99652 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
99653 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
99654 +wm8994_gpio_direction_in_62649 wm8994_gpio_direction_in 2 62649 NULL
99655 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
99656 +write_62671 write 3 62671 NULL
99657 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
99658 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
99659 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
99660 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
99661 +rdm_62719 rdm 0 62719 NULL
99662 +key_replays_read_62746 key_replays_read 3 62746 NULL
99663 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
99664 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
99665 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
99666 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
99667 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
99668 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
99669 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
99670 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
99671 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
99672 +aoechr_write_62883 aoechr_write 3 62883 NULL nohasharray
99673 +em28xx_init_isoc_62883 em28xx_init_isoc 4 62883 &aoechr_write_62883
99674 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
99675 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
99676 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
99677 +getdqbuf_62908 getdqbuf 1 62908 NULL
99678 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
99679 +PTR_ERR_63033 PTR_ERR 0 63033 NULL nohasharray
99680 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 &PTR_ERR_63033
99681 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
99682 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
99683 +unlink1_63059 unlink1 3 63059 NULL
99684 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
99685 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
99686 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
99687 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
99688 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
99689 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
99690 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
99691 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
99692 +vme_master_read_63221 vme_master_read 0 63221 NULL
99693 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
99694 +ptp_read_63251 ptp_read 4 63251 NULL
99695 +ntfs_attr_can_be_non_resident_63267 ntfs_attr_can_be_non_resident 0 63267 NULL
99696 +raid5_resize_63306 raid5_resize 2 63306 NULL
99697 +proc_info_read_63344 proc_info_read 3 63344 NULL
99698 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
99699 +idmouse_read_63374 idmouse_read 3 63374 NULL
99700 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
99701 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
99702 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
99703 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
99704 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
99705 +kone_send_63435 kone_send 4 63435 NULL
99706 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
99707 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
99708 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
99709 +read_kcore_63488 read_kcore 3 63488 NULL
99710 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
99711 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
99712 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
99713 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
99714 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
99715 +kvm_write_guest_page_63555 kvm_write_guest_page 5 63555 &dbg_leb_write_63555
99716 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
99717 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
99718 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
99719 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
99720 +module_alloc_63630 module_alloc 1 63630 NULL
99721 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
99722 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
99723 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
99724 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
99725 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
99726 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
99727 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
99728 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
99729 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
99730 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
99731 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
99732 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
99733 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
99734 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
99735 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
99736 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
99737 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
99738 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
99739 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
99740 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
99741 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
99742 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
99743 +sel_write_load_63830 sel_write_load 3 63830 NULL
99744 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
99745 +ieee80211_if_fmt_channel_type_63855 ieee80211_if_fmt_channel_type 3 63855 NULL
99746 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
99747 +divas_write_63901 divas_write 3 63901 NULL
99748 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
99749 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
99750 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
99751 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
99752 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
99753 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
99754 +__team_options_register_63941 __team_options_register 3 63941 NULL
99755 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
99756 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
99757 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
99758 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
99759 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
99760 +kmemdup_64015 kmemdup 2 64015 NULL
99761 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 NULL
99762 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
99763 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
99764 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
99765 +get_u8_64076 get_u8 0 64076 NULL
99766 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
99767 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
99768 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
99769 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
99770 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
99771 +init_bch_64130 init_bch 1-2 64130 NULL
99772 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
99773 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
99774 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
99775 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
99776 +read_pulse_64227 read_pulse 0-3 64227 NULL
99777 +header_len_64232 header_len 0 64232 NULL
99778 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
99779 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
99780 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
99781 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
99782 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
99783 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
99784 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
99785 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
99786 +ffz_64324 ffz 0 64324 NULL
99787 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
99788 +ts_write_64336 ts_write 3 64336 NULL
99789 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
99790 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
99791 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
99792 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
99793 +ilo_write_64378 ilo_write 3 64378 NULL
99794 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
99795 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
99796 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
99797 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
99798 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
99799 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
99800 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
99801 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
99802 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
99803 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL
99804 +ieee80211_ie_build_ht_cap_64443 ieee80211_ie_build_ht_cap 0 64443 NULL
99805 +cap_capable_64462 cap_capable 0 64462 NULL
99806 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
99807 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
99808 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
99809 +remove_uuid_64505 remove_uuid 4 64505 NULL
99810 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
99811 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
99812 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
99813 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
99814 +__spi_sync_64561 __spi_sync 0 64561 NULL
99815 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
99816 +fanotify_write_64623 fanotify_write 3 64623 NULL
99817 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
99818 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
99819 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
99820 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
99821 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
99822 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
99823 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
99824 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
99825 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
99826 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
99827 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
99828 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
99829 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
99830 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
99831 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
99832 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
99833 +twl6040_reg_write_64790 twl6040_reg_write 2 64790 NULL
99834 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
99835 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
99836 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
99837 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
99838 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
99839 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
99840 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
99841 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
99842 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
99843 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
99844 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
99845 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
99846 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
99847 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
99848 +pskb_pull_65005 pskb_pull 2 65005 NULL
99849 +unifi_write_65012 unifi_write 3 65012 NULL
99850 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
99851 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
99852 +insert_dent_65034 insert_dent 7 65034 NULL
99853 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
99854 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
99855 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
99856 +make_idx_node_65068 make_idx_node 0 65068 NULL
99857 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
99858 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
99859 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
99860 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
99861 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
99862 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
99863 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
99864 +print_endpoint_stat_65232 print_endpoint_stat 0-4-3 65232 NULL
99865 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
99866 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
99867 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
99868 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
99869 +get_unaligned_le16_65293 get_unaligned_le16 0 65293 NULL
99870 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
99871 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
99872 +get_var_len_65304 get_var_len 0 65304 NULL
99873 +unpack_array_65318 unpack_array 0 65318 NULL
99874 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
99875 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
99876 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
99877 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
99878 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
99879 +strchr_65372 strchr 0 65372 NULL
99880 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
99881 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
99882 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
99883 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
99884 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
99885 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
99886 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
99887 +pn533_init_target_frame_65438 pn533_init_target_frame 3 65438 NULL
99888 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
99889 +regmap_write_65478 regmap_write 2 65478 NULL
99890 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
99891 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
99892 +alloc_dr_65495 alloc_dr 2 65495 NULL
99893 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
99894 new file mode 100644
99895 index 0000000..9db0d0e
99896 --- /dev/null
99897 +++ b/tools/gcc/size_overflow_plugin.c
99898 @@ -0,0 +1,2114 @@
99899 +/*
99900 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
99901 + * Licensed under the GPL v2, or (at your option) v3
99902 + *
99903 + * Homepage:
99904 + * http://www.grsecurity.net/~ephox/overflow_plugin/
99905 + *
99906 + * Documentation:
99907 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
99908 + *
99909 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
99910 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
99911 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
99912 + *
99913 + * Usage:
99914 + * $ 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
99915 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
99916 + */
99917 +
99918 +#include "gcc-plugin.h"
99919 +#include "config.h"
99920 +#include "system.h"
99921 +#include "coretypes.h"
99922 +#include "tree.h"
99923 +#include "tree-pass.h"
99924 +#include "intl.h"
99925 +#include "plugin-version.h"
99926 +#include "tm.h"
99927 +#include "toplev.h"
99928 +#include "function.h"
99929 +#include "tree-flow.h"
99930 +#include "plugin.h"
99931 +#include "gimple.h"
99932 +#include "diagnostic.h"
99933 +#include "cfgloop.h"
99934 +
99935 +#if BUILDING_GCC_VERSION >= 4008
99936 +#define TODO_dump_func 0
99937 +#endif
99938 +
99939 +struct size_overflow_hash {
99940 + const struct size_overflow_hash * const next;
99941 + const char * const name;
99942 + const unsigned int param;
99943 +};
99944 +
99945 +#include "size_overflow_hash.h"
99946 +
99947 +enum mark {
99948 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
99949 +};
99950 +
99951 +enum err_code_conditions {
99952 + CAST_ONLY, FROM_CONST
99953 +};
99954 +
99955 +static unsigned int call_count = 0;
99956 +
99957 +#define __unused __attribute__((__unused__))
99958 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
99959 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
99960 +#define BEFORE_STMT true
99961 +#define AFTER_STMT false
99962 +#define CREATE_NEW_VAR NULL_TREE
99963 +#define CODES_LIMIT 32
99964 +#define MAX_PARAM 31
99965 +#define MY_STMT GF_PLF_1
99966 +#define NO_CAST_CHECK GF_PLF_2
99967 +#define FROM_ARG true
99968 +#define FROM_RET false
99969 +
99970 +#if BUILDING_GCC_VERSION == 4005
99971 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
99972 +#endif
99973 +
99974 +int plugin_is_GPL_compatible;
99975 +void debug_gimple_stmt(gimple gs);
99976 +
99977 +static tree expand(struct pointer_set_t *visited, tree lhs);
99978 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
99979 +static tree report_size_overflow_decl;
99980 +static const_tree const_char_ptr_type_node;
99981 +static unsigned int handle_function(void);
99982 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
99983 +static tree get_size_overflow_type(gimple stmt, const_tree node);
99984 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
99985 +static void print_missing_msg(tree func, unsigned int argnum);
99986 +
99987 +static struct plugin_info size_overflow_plugin_info = {
99988 + .version = "20130410beta",
99989 + .help = "no-size-overflow\tturn off size overflow checking\n",
99990 +};
99991 +
99992 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
99993 +{
99994 + unsigned int arg_count;
99995 + enum tree_code code = TREE_CODE(*node);
99996 +
99997 + switch (code) {
99998 + case FUNCTION_DECL:
99999 + arg_count = type_num_arguments(TREE_TYPE(*node));
100000 + break;
100001 + case FUNCTION_TYPE:
100002 + case METHOD_TYPE:
100003 + arg_count = type_num_arguments(*node);
100004 + break;
100005 + default:
100006 + *no_add_attrs = true;
100007 + error("%s: %qE attribute only applies to functions", __func__, name);
100008 + return NULL_TREE;
100009 + }
100010 +
100011 + for (; args; args = TREE_CHAIN(args)) {
100012 + tree position = TREE_VALUE(args);
100013 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
100014 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
100015 + *no_add_attrs = true;
100016 + }
100017 + }
100018 + return NULL_TREE;
100019 +}
100020 +
100021 +static const char* get_asm_name(tree node)
100022 +{
100023 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
100024 +}
100025 +
100026 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
100027 +{
100028 + unsigned int arg_count, arg_num;
100029 + enum tree_code code = TREE_CODE(*node);
100030 +
100031 + switch (code) {
100032 + case FUNCTION_DECL:
100033 + arg_count = type_num_arguments(TREE_TYPE(*node));
100034 + break;
100035 + case FUNCTION_TYPE:
100036 + case METHOD_TYPE:
100037 + arg_count = type_num_arguments(*node);
100038 + break;
100039 + case FIELD_DECL:
100040 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
100041 + if (arg_num != 0) {
100042 + *no_add_attrs = true;
100043 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
100044 + }
100045 + return NULL_TREE;
100046 + default:
100047 + *no_add_attrs = true;
100048 + error("%qE attribute only applies to functions", name);
100049 + return NULL_TREE;
100050 + }
100051 +
100052 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
100053 + return NULL_TREE;
100054 +
100055 + for (; args; args = TREE_CHAIN(args)) {
100056 + tree position = TREE_VALUE(args);
100057 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
100058 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
100059 + *no_add_attrs = true;
100060 + }
100061 + }
100062 + return NULL_TREE;
100063 +}
100064 +
100065 +static struct attribute_spec size_overflow_attr = {
100066 + .name = "size_overflow",
100067 + .min_length = 1,
100068 + .max_length = -1,
100069 + .decl_required = true,
100070 + .type_required = false,
100071 + .function_type_required = false,
100072 + .handler = handle_size_overflow_attribute,
100073 +#if BUILDING_GCC_VERSION >= 4007
100074 + .affects_type_identity = false
100075 +#endif
100076 +};
100077 +
100078 +static struct attribute_spec intentional_overflow_attr = {
100079 + .name = "intentional_overflow",
100080 + .min_length = 1,
100081 + .max_length = -1,
100082 + .decl_required = true,
100083 + .type_required = false,
100084 + .function_type_required = false,
100085 + .handler = handle_intentional_overflow_attribute,
100086 +#if BUILDING_GCC_VERSION >= 4007
100087 + .affects_type_identity = false
100088 +#endif
100089 +};
100090 +
100091 +static void register_attributes(void __unused *event_data, void __unused *data)
100092 +{
100093 + register_attribute(&size_overflow_attr);
100094 + register_attribute(&intentional_overflow_attr);
100095 +}
100096 +
100097 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
100098 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
100099 +{
100100 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
100101 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
100102 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
100103 +
100104 + unsigned int m = 0x57559429;
100105 + unsigned int n = 0x5052acdb;
100106 + const unsigned int *key4 = (const unsigned int *)key;
100107 + unsigned int h = len;
100108 + unsigned int k = len + seed + n;
100109 + unsigned long long p;
100110 +
100111 + while (len >= 8) {
100112 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
100113 + len -= 8;
100114 + }
100115 + if (len >= 4) {
100116 + cwmixb(key4[0]) key4 += 1;
100117 + len -= 4;
100118 + }
100119 + if (len)
100120 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
100121 + cwmixb(h ^ (k + n));
100122 + return k ^ h;
100123 +
100124 +#undef cwfold
100125 +#undef cwmixa
100126 +#undef cwmixb
100127 +}
100128 +
100129 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
100130 +{
100131 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
100132 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
100133 + return fn ^ codes;
100134 +}
100135 +
100136 +static inline tree get_original_function_decl(tree fndecl)
100137 +{
100138 + if (DECL_ABSTRACT_ORIGIN(fndecl))
100139 + return DECL_ABSTRACT_ORIGIN(fndecl);
100140 + return fndecl;
100141 +}
100142 +
100143 +static inline gimple get_def_stmt(const_tree node)
100144 +{
100145 + gcc_assert(node != NULL_TREE);
100146 + if (TREE_CODE(node) != SSA_NAME)
100147 + return NULL;
100148 + return SSA_NAME_DEF_STMT(node);
100149 +}
100150 +
100151 +static unsigned char get_tree_code(const_tree type)
100152 +{
100153 + switch (TREE_CODE(type)) {
100154 + case ARRAY_TYPE:
100155 + return 0;
100156 + case BOOLEAN_TYPE:
100157 + return 1;
100158 + case ENUMERAL_TYPE:
100159 + return 2;
100160 + case FUNCTION_TYPE:
100161 + return 3;
100162 + case INTEGER_TYPE:
100163 + return 4;
100164 + case POINTER_TYPE:
100165 + return 5;
100166 + case RECORD_TYPE:
100167 + return 6;
100168 + case UNION_TYPE:
100169 + return 7;
100170 + case VOID_TYPE:
100171 + return 8;
100172 + case REAL_TYPE:
100173 + return 9;
100174 + case VECTOR_TYPE:
100175 + return 10;
100176 + case REFERENCE_TYPE:
100177 + return 11;
100178 + case OFFSET_TYPE:
100179 + return 12;
100180 + case COMPLEX_TYPE:
100181 + return 13;
100182 + default:
100183 + debug_tree((tree)type);
100184 + gcc_unreachable();
100185 + }
100186 +}
100187 +
100188 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
100189 +{
100190 + gcc_assert(type != NULL_TREE);
100191 +
100192 + while (type && len < CODES_LIMIT) {
100193 + tree_codes[len] = get_tree_code(type);
100194 + len++;
100195 + type = TREE_TYPE(type);
100196 + }
100197 + return len;
100198 +}
100199 +
100200 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
100201 +{
100202 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
100203 + enum tree_code code = TREE_CODE(type);
100204 + size_t len = 0;
100205 +
100206 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
100207 +
100208 + arg = TYPE_ARG_TYPES(type);
100209 + // skip builtins __builtin_constant_p
100210 + if (!arg && DECL_BUILT_IN(fndecl))
100211 + return 0;
100212 +
100213 + if (TREE_CODE_CLASS(code) == tcc_type)
100214 + result = type;
100215 + else
100216 + result = DECL_RESULT(fndecl);
100217 +
100218 + gcc_assert(result != NULL_TREE);
100219 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
100220 +
100221 + if (arg == NULL_TREE) {
100222 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
100223 + arg_field = DECL_ARGUMENT_FLD(fndecl);
100224 + if (arg_field == NULL_TREE)
100225 + return 0;
100226 + arg = TREE_TYPE(arg_field);
100227 + len = add_type_codes(arg, tree_codes, len);
100228 + gcc_assert(len != 0);
100229 + return len;
100230 + }
100231 +
100232 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
100233 + while (arg && len < CODES_LIMIT) {
100234 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
100235 + arg = TREE_CHAIN(arg);
100236 + }
100237 +
100238 + gcc_assert(len != 0);
100239 + return len;
100240 +}
100241 +
100242 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
100243 +{
100244 + unsigned int hash;
100245 + const struct size_overflow_hash *entry;
100246 + unsigned char tree_codes[CODES_LIMIT];
100247 + size_t len;
100248 + const char *func_name;
100249 +
100250 + fndecl = get_original_function_decl(fndecl);
100251 + len = get_function_decl(fndecl, tree_codes);
100252 + if (len == 0)
100253 + return NULL;
100254 +
100255 + func_name = get_asm_name(fndecl);
100256 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
100257 +
100258 + entry = size_overflow_hash[hash];
100259 + while (entry) {
100260 + if (!strcmp(entry->name, func_name))
100261 + return entry;
100262 + entry = entry->next;
100263 + }
100264 +
100265 + return NULL;
100266 +}
100267 +
100268 +static bool is_bool(const_tree node)
100269 +{
100270 + const_tree type;
100271 +
100272 + if (node == NULL_TREE)
100273 + return false;
100274 +
100275 + type = TREE_TYPE(node);
100276 + if (!INTEGRAL_TYPE_P(type))
100277 + return false;
100278 + if (TREE_CODE(type) == BOOLEAN_TYPE)
100279 + return true;
100280 + if (TYPE_PRECISION(type) == 1)
100281 + return true;
100282 + return false;
100283 +}
100284 +
100285 +static bool skip_types(const_tree var)
100286 +{
100287 + tree type;
100288 +
100289 + if (is_gimple_constant(var))
100290 + return true;
100291 +
100292 + switch (TREE_CODE(var)) {
100293 + case ADDR_EXPR:
100294 +#if BUILDING_GCC_VERSION >= 4006
100295 + case MEM_REF:
100296 +#endif
100297 + case ARRAY_REF:
100298 + case BIT_FIELD_REF:
100299 + case INDIRECT_REF:
100300 + case TARGET_MEM_REF:
100301 + return true;
100302 + case PARM_DECL:
100303 + case VAR_DECL:
100304 + case COMPONENT_REF:
100305 + return false;
100306 + default:
100307 + break;
100308 + }
100309 +
100310 + gcc_assert(TREE_CODE(var) == SSA_NAME);
100311 +
100312 + type = TREE_TYPE(var);
100313 + switch (TREE_CODE(type)) {
100314 + case INTEGER_TYPE:
100315 + case ENUMERAL_TYPE:
100316 + return false;
100317 + case BOOLEAN_TYPE:
100318 + return is_bool(var);
100319 + default:
100320 + break;
100321 + }
100322 +
100323 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
100324 +
100325 + type = TREE_TYPE(type);
100326 + gcc_assert(type != NULL_TREE);
100327 + switch (TREE_CODE(type)) {
100328 + case RECORD_TYPE:
100329 + case POINTER_TYPE:
100330 + case ARRAY_TYPE:
100331 + return true;
100332 + case VOID_TYPE:
100333 + case INTEGER_TYPE:
100334 + case UNION_TYPE:
100335 + return false;
100336 + default:
100337 + break;
100338 + }
100339 +
100340 + debug_tree((tree)var);
100341 + gcc_unreachable();
100342 +}
100343 +
100344 +static unsigned int find_arg_number(const_tree arg, tree func)
100345 +{
100346 + tree var;
100347 + unsigned int argnum = 1;
100348 +
100349 + if (TREE_CODE(arg) == SSA_NAME)
100350 + arg = SSA_NAME_VAR(arg);
100351 +
100352 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
100353 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
100354 + continue;
100355 + if (!skip_types(var))
100356 + return argnum;
100357 + }
100358 +
100359 + return 0;
100360 +}
100361 +
100362 +static tree create_new_var(tree type)
100363 +{
100364 + tree new_var = create_tmp_var(type, "cicus");
100365 +
100366 +#if BUILDING_GCC_VERSION <= 4007
100367 + add_referenced_var(new_var);
100368 + mark_sym_for_renaming(new_var);
100369 +#endif
100370 + return new_var;
100371 +}
100372 +
100373 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
100374 +{
100375 + gimple assign;
100376 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
100377 + tree type = TREE_TYPE(rhs1);
100378 + tree lhs = create_new_var(type);
100379 +
100380 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
100381 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
100382 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
100383 +
100384 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
100385 + update_stmt(assign);
100386 + gimple_set_plf(assign, MY_STMT, true);
100387 + return assign;
100388 +}
100389 +
100390 +static tree cast_a_tree(tree type, tree var)
100391 +{
100392 + gcc_assert(type != NULL_TREE);
100393 + gcc_assert(var != NULL_TREE);
100394 + gcc_assert(fold_convertible_p(type, var));
100395 +
100396 + return fold_convert(type, var);
100397 +}
100398 +
100399 +static tree get_lhs(const_gimple stmt)
100400 +{
100401 + switch (gimple_code(stmt)) {
100402 + case GIMPLE_ASSIGN:
100403 + return gimple_get_lhs(stmt);
100404 + case GIMPLE_PHI:
100405 + return gimple_phi_result(stmt);
100406 + case GIMPLE_CALL:
100407 + return gimple_call_lhs(stmt);
100408 + default:
100409 + return NULL_TREE;
100410 + }
100411 +}
100412 +
100413 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
100414 +{
100415 + const_gimple def_stmt = get_def_stmt(rhs);
100416 +
100417 + if (force)
100418 + return false;
100419 +
100420 + if (is_gimple_constant(rhs))
100421 + return false;
100422 +
100423 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
100424 + return false;
100425 +
100426 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
100427 + return false;
100428 +
100429 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
100430 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
100431 + return false;
100432 +
100433 + return true;
100434 +}
100435 +
100436 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
100437 +{
100438 + gimple assign, def_stmt;
100439 +
100440 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
100441 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
100442 + gcc_unreachable();
100443 +
100444 + def_stmt = get_def_stmt(rhs);
100445 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
100446 + return def_stmt;
100447 +
100448 + if (lhs == CREATE_NEW_VAR)
100449 + lhs = create_new_var(dst_type);
100450 +
100451 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
100452 +
100453 + if (!gsi_end_p(*gsi)) {
100454 + location_t loc = gimple_location(gsi_stmt(*gsi));
100455 + gimple_set_location(assign, loc);
100456 + }
100457 +
100458 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
100459 +
100460 + if (before)
100461 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
100462 + else
100463 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
100464 + update_stmt(assign);
100465 + gimple_set_plf(assign, MY_STMT, true);
100466 +
100467 + return assign;
100468 +}
100469 +
100470 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
100471 +{
100472 + gimple_stmt_iterator gsi;
100473 + tree lhs;
100474 + const_gimple new_stmt;
100475 +
100476 + if (rhs == NULL_TREE)
100477 + return NULL_TREE;
100478 +
100479 + gsi = gsi_for_stmt(stmt);
100480 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
100481 +
100482 + lhs = get_lhs(new_stmt);
100483 + gcc_assert(lhs != NULL_TREE);
100484 + return lhs;
100485 +}
100486 +
100487 +static tree cast_to_TI_type(gimple stmt, tree node)
100488 +{
100489 + gimple_stmt_iterator gsi;
100490 + gimple cast_stmt;
100491 + tree type = TREE_TYPE(node);
100492 +
100493 + if (types_compatible_p(type, intTI_type_node))
100494 + return node;
100495 +
100496 + gsi = gsi_for_stmt(stmt);
100497 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
100498 + return gimple_get_lhs(cast_stmt);
100499 +}
100500 +
100501 +static void check_function_hash(const_gimple stmt)
100502 +{
100503 + tree func;
100504 + const struct size_overflow_hash *hash;
100505 +
100506 + if (gimple_code(stmt) != GIMPLE_CALL)
100507 + return;
100508 +
100509 + func = gimple_call_fndecl(stmt);
100510 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
100511 + if (func == NULL_TREE)
100512 + return;
100513 +
100514 + hash = get_function_hash(func);
100515 + if (!hash)
100516 + print_missing_msg(func, 0);
100517 +}
100518 +
100519 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
100520 +{
100521 + tree lhs, new_lhs;
100522 + gimple_stmt_iterator gsi;
100523 +
100524 + if (rhs1 == NULL_TREE) {
100525 + debug_gimple_stmt(oldstmt);
100526 + error("%s: rhs1 is NULL_TREE", __func__);
100527 + gcc_unreachable();
100528 + }
100529 +
100530 + switch (gimple_code(oldstmt)) {
100531 + case GIMPLE_ASM:
100532 + lhs = rhs1;
100533 + break;
100534 + case GIMPLE_CALL:
100535 + lhs = gimple_call_lhs(oldstmt);
100536 + break;
100537 + case GIMPLE_ASSIGN:
100538 + lhs = gimple_get_lhs(oldstmt);
100539 + break;
100540 + default:
100541 + debug_gimple_stmt(oldstmt);
100542 + gcc_unreachable();
100543 + }
100544 +
100545 + gsi = gsi_for_stmt(oldstmt);
100546 + pointer_set_insert(visited, oldstmt);
100547 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
100548 + basic_block next_bb, cur_bb;
100549 + const_edge e;
100550 +
100551 + gcc_assert(before == false);
100552 + gcc_assert(stmt_can_throw_internal(oldstmt));
100553 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
100554 + gcc_assert(!gsi_end_p(gsi));
100555 +
100556 + cur_bb = gimple_bb(oldstmt);
100557 + next_bb = cur_bb->next_bb;
100558 + e = find_edge(cur_bb, next_bb);
100559 + gcc_assert(e != NULL);
100560 + gcc_assert(e->flags & EDGE_FALLTHRU);
100561 +
100562 + gsi = gsi_after_labels(next_bb);
100563 + gcc_assert(!gsi_end_p(gsi));
100564 +
100565 + before = true;
100566 + oldstmt = gsi_stmt(gsi);
100567 + }
100568 +
100569 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
100570 + return new_lhs;
100571 +}
100572 +
100573 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
100574 +{
100575 + gimple stmt;
100576 + gimple_stmt_iterator gsi;
100577 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
100578 +
100579 + if (gimple_plf(oldstmt, MY_STMT))
100580 + return lhs;
100581 +
100582 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
100583 + rhs1 = gimple_assign_rhs1(oldstmt);
100584 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
100585 + }
100586 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
100587 + rhs2 = gimple_assign_rhs2(oldstmt);
100588 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
100589 + }
100590 +
100591 + stmt = gimple_copy(oldstmt);
100592 + gimple_set_location(stmt, gimple_location(oldstmt));
100593 + gimple_set_plf(stmt, MY_STMT, true);
100594 +
100595 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
100596 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
100597 +
100598 + size_overflow_type = get_size_overflow_type(oldstmt, node);
100599 +
100600 + new_var = create_new_var(size_overflow_type);
100601 + new_var = make_ssa_name(new_var, stmt);
100602 + gimple_set_lhs(stmt, new_var);
100603 +
100604 + if (rhs1 != NULL_TREE)
100605 + gimple_assign_set_rhs1(stmt, rhs1);
100606 +
100607 + if (rhs2 != NULL_TREE)
100608 + gimple_assign_set_rhs2(stmt, rhs2);
100609 +#if BUILDING_GCC_VERSION >= 4007
100610 + if (rhs3 != NULL_TREE)
100611 + gimple_assign_set_rhs3(stmt, rhs3);
100612 +#endif
100613 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
100614 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
100615 +
100616 + gsi = gsi_for_stmt(oldstmt);
100617 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
100618 + update_stmt(stmt);
100619 + pointer_set_insert(visited, oldstmt);
100620 + return gimple_get_lhs(stmt);
100621 +}
100622 +
100623 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
100624 +{
100625 + basic_block first_bb;
100626 + gimple assign;
100627 + gimple_stmt_iterator gsi;
100628 +
100629 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
100630 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
100631 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
100632 +
100633 + gsi = gsi_start_bb(first_bb);
100634 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
100635 + return gimple_get_lhs(assign);
100636 +}
100637 +
100638 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
100639 +{
100640 + gimple_stmt_iterator gsi;
100641 + const_gimple assign;
100642 + gimple def_stmt = get_def_stmt(new_arg);
100643 +
100644 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
100645 + gsi = gsi_after_labels(gimple_bb(def_stmt));
100646 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
100647 + } else {
100648 + gsi = gsi_for_stmt(def_stmt);
100649 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
100650 + }
100651 +
100652 + return gimple_get_lhs(assign);
100653 +}
100654 +
100655 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
100656 +{
100657 + basic_block bb;
100658 + gimple_stmt_iterator gsi;
100659 + const_gimple assign, def_stmt;
100660 +
100661 + def_stmt = get_def_stmt(arg);
100662 + bb = gimple_bb(def_stmt);
100663 + gcc_assert(bb->index != 0);
100664 + gsi = gsi_after_labels(bb);
100665 +
100666 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
100667 + return gimple_get_lhs(assign);
100668 +}
100669 +
100670 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
100671 +{
100672 + tree size_overflow_type;
100673 + const_gimple def_stmt = get_def_stmt(arg);
100674 +
100675 + if (phi_ssa_name != NULL_TREE)
100676 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
100677 +
100678 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
100679 +
100680 + if (new_arg != NULL_TREE) {
100681 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
100682 + return use_phi_ssa_name(phi_ssa_name, new_arg);
100683 + }
100684 +
100685 + switch(gimple_code(def_stmt)) {
100686 + case GIMPLE_PHI:
100687 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
100688 + case GIMPLE_NOP:
100689 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
100690 + default:
100691 + debug_gimple_stmt((gimple)def_stmt);
100692 + gcc_unreachable();
100693 + }
100694 +}
100695 +
100696 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
100697 +{
100698 + basic_block bb;
100699 + gimple phi;
100700 + gimple_seq seq;
100701 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
100702 +
100703 + bb = gsi_bb(gsi);
100704 +
100705 + phi = create_phi_node(result, bb);
100706 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
100707 + seq = phi_nodes(bb);
100708 + gsi = gsi_last(seq);
100709 + gsi_remove(&gsi, false);
100710 +
100711 + gsi = gsi_for_stmt(oldstmt);
100712 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
100713 + gimple_set_bb(phi, bb);
100714 + gimple_set_plf(phi, MY_STMT, true);
100715 + return phi;
100716 +}
100717 +
100718 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
100719 +{
100720 + gimple new_phi = NULL;
100721 + gimple oldstmt = get_def_stmt(orig_result);
100722 + tree phi_ssa_name = NULL_TREE;
100723 + unsigned int i;
100724 +
100725 + pointer_set_insert(visited, oldstmt);
100726 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
100727 + tree arg, new_arg;
100728 +
100729 + arg = gimple_phi_arg_def(oldstmt, i);
100730 +
100731 + new_arg = expand(visited, arg);
100732 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
100733 + if (i == 0) {
100734 + phi_ssa_name = new_arg;
100735 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
100736 + }
100737 +
100738 + gcc_assert(new_phi != NULL);
100739 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
100740 + }
100741 +
100742 + gcc_assert(new_phi != NULL);
100743 + update_stmt(new_phi);
100744 + return gimple_phi_result(new_phi);
100745 +}
100746 +
100747 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
100748 +{
100749 + const_gimple assign;
100750 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
100751 + tree origtype = TREE_TYPE(orig_rhs);
100752 +
100753 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
100754 +
100755 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
100756 + return gimple_get_lhs(assign);
100757 +}
100758 +
100759 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
100760 +{
100761 + const_tree rhs1, lhs, rhs1_type, lhs_type;
100762 + enum machine_mode lhs_mode, rhs_mode;
100763 + gimple def_stmt = get_def_stmt(no_const_rhs);
100764 +
100765 + if (!gimple_assign_cast_p(def_stmt))
100766 + return false;
100767 +
100768 + rhs1 = gimple_assign_rhs1(def_stmt);
100769 + lhs = gimple_get_lhs(def_stmt);
100770 + rhs1_type = TREE_TYPE(rhs1);
100771 + lhs_type = TREE_TYPE(lhs);
100772 + rhs_mode = TYPE_MODE(rhs1_type);
100773 + lhs_mode = TYPE_MODE(lhs_type);
100774 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
100775 + return false;
100776 +
100777 + return true;
100778 +}
100779 +
100780 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
100781 +{
100782 + tree rhs1 = gimple_assign_rhs1(stmt);
100783 + tree lhs = gimple_get_lhs(stmt);
100784 + const_tree rhs1_type = TREE_TYPE(rhs1);
100785 + const_tree lhs_type = TREE_TYPE(lhs);
100786 +
100787 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
100788 + return create_assign(visited, stmt, lhs, AFTER_STMT);
100789 +
100790 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
100791 +}
100792 +
100793 +static bool no_uses(tree node)
100794 +{
100795 + imm_use_iterator imm_iter;
100796 + use_operand_p use_p;
100797 +
100798 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
100799 + const_gimple use_stmt = USE_STMT(use_p);
100800 + if (use_stmt == NULL)
100801 + return true;
100802 + if (is_gimple_debug(use_stmt))
100803 + continue;
100804 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
100805 + continue;
100806 + return false;
100807 + }
100808 + return true;
100809 +}
100810 +
100811 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
100812 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
100813 +{
100814 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
100815 + gimple def_stmt = get_def_stmt(lhs);
100816 +
100817 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
100818 + return false;
100819 +
100820 + rhs1 = gimple_assign_rhs1(def_stmt);
100821 + rhs_type = TREE_TYPE(rhs1);
100822 + lhs_type = TREE_TYPE(lhs);
100823 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
100824 + return false;
100825 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
100826 + return false;
100827 +
100828 + def_stmt = get_def_stmt(rhs1);
100829 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
100830 + return false;
100831 +
100832 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
100833 + return false;
100834 +
100835 + rhs1 = gimple_assign_rhs1(def_stmt);
100836 + rhs2 = gimple_assign_rhs2(def_stmt);
100837 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
100838 + return false;
100839 +
100840 + if (is_gimple_constant(rhs2))
100841 + not_const_rhs = rhs1;
100842 + else
100843 + not_const_rhs = rhs2;
100844 +
100845 + return no_uses(not_const_rhs);
100846 +}
100847 +
100848 +static bool skip_lhs_cast_check(const_gimple stmt)
100849 +{
100850 + const_tree rhs = gimple_assign_rhs1(stmt);
100851 + const_gimple def_stmt = get_def_stmt(rhs);
100852 +
100853 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
100854 + if (gimple_code(def_stmt) == GIMPLE_ASM)
100855 + return true;
100856 +
100857 + if (is_const_plus_unsigned_signed_truncation(rhs))
100858 + return true;
100859 +
100860 + return false;
100861 +}
100862 +
100863 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
100864 +{
100865 + bool cast_lhs, cast_rhs;
100866 + tree lhs = gimple_get_lhs(stmt);
100867 + tree rhs = gimple_assign_rhs1(stmt);
100868 + const_tree lhs_type = TREE_TYPE(lhs);
100869 + const_tree rhs_type = TREE_TYPE(rhs);
100870 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
100871 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
100872 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
100873 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
100874 +
100875 + static bool check_lhs[3][4] = {
100876 + // ss su us uu
100877 + { false, true, true, false }, // lhs > rhs
100878 + { false, false, false, false }, // lhs = rhs
100879 + { true, true, true, true }, // lhs < rhs
100880 + };
100881 +
100882 + static bool check_rhs[3][4] = {
100883 + // ss su us uu
100884 + { true, false, true, true }, // lhs > rhs
100885 + { true, false, true, true }, // lhs = rhs
100886 + { true, false, true, true }, // lhs < rhs
100887 + };
100888 +
100889 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
100890 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
100891 + return create_assign(visited, stmt, lhs, AFTER_STMT);
100892 +
100893 + if (lhs_size > rhs_size) {
100894 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
100895 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
100896 + } else if (lhs_size == rhs_size) {
100897 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
100898 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
100899 + } else {
100900 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
100901 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
100902 + }
100903 +
100904 + if (!cast_lhs && !cast_rhs)
100905 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
100906 +
100907 + if (cast_lhs && !skip_lhs_cast_check(stmt))
100908 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
100909 +
100910 + if (cast_rhs)
100911 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
100912 +
100913 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
100914 +}
100915 +
100916 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
100917 +{
100918 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
100919 +
100920 + if (gimple_plf(stmt, MY_STMT))
100921 + return lhs;
100922 +
100923 + rhs1 = gimple_assign_rhs1(stmt);
100924 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
100925 + return create_assign(visited, stmt, lhs, AFTER_STMT);
100926 +
100927 + new_rhs1 = expand(visited, rhs1);
100928 +
100929 + if (new_rhs1 == NULL_TREE)
100930 + return create_cast_assign(visited, stmt);
100931 +
100932 + if (gimple_plf(stmt, NO_CAST_CHECK))
100933 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
100934 +
100935 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
100936 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
100937 +
100938 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
100939 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
100940 + return create_assign(visited, stmt, lhs, AFTER_STMT);
100941 + }
100942 +
100943 + if (!gimple_assign_cast_p(stmt))
100944 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
100945 +
100946 + return create_cast_overflow_check(visited, new_rhs1, stmt);
100947 +}
100948 +
100949 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
100950 +{
100951 + tree rhs1, lhs = gimple_get_lhs(stmt);
100952 + gimple def_stmt = get_def_stmt(lhs);
100953 +
100954 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
100955 + rhs1 = gimple_assign_rhs1(def_stmt);
100956 +
100957 + if (is_gimple_constant(rhs1))
100958 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
100959 +
100960 + switch (TREE_CODE(rhs1)) {
100961 + case SSA_NAME:
100962 + return handle_unary_rhs(visited, def_stmt);
100963 + case ARRAY_REF:
100964 + case BIT_FIELD_REF:
100965 + case ADDR_EXPR:
100966 + case COMPONENT_REF:
100967 + case INDIRECT_REF:
100968 +#if BUILDING_GCC_VERSION >= 4006
100969 + case MEM_REF:
100970 +#endif
100971 + case TARGET_MEM_REF:
100972 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
100973 + case PARM_DECL:
100974 + case VAR_DECL:
100975 + return create_assign(visited, stmt, lhs, AFTER_STMT);
100976 +
100977 + default:
100978 + debug_gimple_stmt(def_stmt);
100979 + debug_tree(rhs1);
100980 + gcc_unreachable();
100981 + }
100982 +}
100983 +
100984 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
100985 +{
100986 + gimple cond_stmt;
100987 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
100988 +
100989 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
100990 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
100991 + update_stmt(cond_stmt);
100992 +}
100993 +
100994 +static tree create_string_param(tree string)
100995 +{
100996 + tree i_type, a_type;
100997 + const int length = TREE_STRING_LENGTH(string);
100998 +
100999 + gcc_assert(length > 0);
101000 +
101001 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
101002 + a_type = build_array_type(char_type_node, i_type);
101003 +
101004 + TREE_TYPE(string) = a_type;
101005 + TREE_CONSTANT(string) = 1;
101006 + TREE_READONLY(string) = 1;
101007 +
101008 + return build1(ADDR_EXPR, ptr_type_node, string);
101009 +}
101010 +
101011 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
101012 +{
101013 + gimple func_stmt;
101014 + const_gimple def_stmt;
101015 + const_tree loc_line;
101016 + tree loc_file, ssa_name, current_func;
101017 + expanded_location xloc;
101018 + char *ssa_name_buf;
101019 + int len;
101020 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
101021 +
101022 + def_stmt = get_def_stmt(arg);
101023 + xloc = expand_location(gimple_location(def_stmt));
101024 +
101025 + if (!gimple_has_location(def_stmt)) {
101026 + xloc = expand_location(gimple_location(stmt));
101027 + if (!gimple_has_location(stmt))
101028 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
101029 + }
101030 +
101031 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
101032 +
101033 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
101034 + loc_file = create_string_param(loc_file);
101035 +
101036 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
101037 + current_func = create_string_param(current_func);
101038 +
101039 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
101040 + call_count++;
101041 + 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);
101042 + gcc_assert(len > 0);
101043 + ssa_name = build_string(len + 1, ssa_name_buf);
101044 + free(ssa_name_buf);
101045 + ssa_name = create_string_param(ssa_name);
101046 +
101047 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
101048 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
101049 +
101050 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
101051 +}
101052 +
101053 +static void __unused print_the_code_insertions(const_gimple stmt)
101054 +{
101055 + location_t loc = gimple_location(stmt);
101056 +
101057 + inform(loc, "Integer size_overflow check applied here.");
101058 +}
101059 +
101060 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
101061 +{
101062 + basic_block cond_bb, join_bb, bb_true;
101063 + edge e;
101064 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101065 +
101066 + cond_bb = gimple_bb(stmt);
101067 + if (before)
101068 + gsi_prev(&gsi);
101069 + if (gsi_end_p(gsi))
101070 + e = split_block_after_labels(cond_bb);
101071 + else
101072 + e = split_block(cond_bb, gsi_stmt(gsi));
101073 + cond_bb = e->src;
101074 + join_bb = e->dest;
101075 + e->flags = EDGE_FALSE_VALUE;
101076 + e->probability = REG_BR_PROB_BASE;
101077 +
101078 + bb_true = create_empty_bb(cond_bb);
101079 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
101080 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
101081 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
101082 +
101083 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
101084 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
101085 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
101086 +
101087 + if (current_loops != NULL) {
101088 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
101089 + add_bb_to_loop(bb_true, cond_bb->loop_father);
101090 + }
101091 +
101092 + insert_cond(cond_bb, arg, cond_code, type_value);
101093 + insert_cond_result(bb_true, stmt, arg, min);
101094 +
101095 +// print_the_code_insertions(stmt);
101096 +}
101097 +
101098 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
101099 +{
101100 + const_tree rhs_type = TREE_TYPE(rhs);
101101 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
101102 +
101103 + gcc_assert(rhs_type != NULL_TREE);
101104 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
101105 + return;
101106 +
101107 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
101108 +
101109 + if (is_const_plus_unsigned_signed_truncation(rhs))
101110 + return;
101111 +
101112 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
101113 + // typemax (-1) < typemin (0)
101114 + if (TREE_OVERFLOW(type_max))
101115 + return;
101116 +
101117 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
101118 +
101119 + cast_rhs_type = TREE_TYPE(cast_rhs);
101120 + type_max_type = TREE_TYPE(type_max);
101121 + type_min_type = TREE_TYPE(type_min);
101122 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
101123 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
101124 +
101125 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
101126 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
101127 +}
101128 +
101129 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
101130 +{
101131 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
101132 + return false;
101133 + if (!is_gimple_constant(rhs))
101134 + return false;
101135 + return true;
101136 +}
101137 +
101138 +static tree get_def_stmt_rhs(const_tree var)
101139 +{
101140 + tree rhs1, def_stmt_rhs1;
101141 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
101142 +
101143 + def_stmt = get_def_stmt(var);
101144 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
101145 +
101146 + rhs1 = gimple_assign_rhs1(def_stmt);
101147 + rhs1_def_stmt = get_def_stmt(rhs1);
101148 + if (!gimple_assign_cast_p(rhs1_def_stmt))
101149 + return rhs1;
101150 +
101151 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
101152 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
101153 +
101154 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
101155 + case GIMPLE_CALL:
101156 + case GIMPLE_NOP:
101157 + case GIMPLE_ASM:
101158 + case GIMPLE_PHI:
101159 + return def_stmt_rhs1;
101160 + case GIMPLE_ASSIGN:
101161 + return rhs1;
101162 + default:
101163 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
101164 + gcc_unreachable();
101165 + }
101166 +}
101167 +
101168 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
101169 +{
101170 + tree new_rhs, orig_rhs;
101171 + void (*gimple_assign_set_rhs)(gimple, tree);
101172 + tree rhs1 = gimple_assign_rhs1(stmt);
101173 + tree rhs2 = gimple_assign_rhs2(stmt);
101174 + tree lhs = gimple_get_lhs(stmt);
101175 +
101176 + if (!check_overflow)
101177 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101178 +
101179 + if (change_rhs == NULL_TREE)
101180 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101181 +
101182 + if (new_rhs2 == NULL_TREE) {
101183 + orig_rhs = rhs1;
101184 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
101185 + } else {
101186 + orig_rhs = rhs2;
101187 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
101188 + }
101189 +
101190 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
101191 +
101192 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
101193 + gimple_assign_set_rhs(stmt, new_rhs);
101194 + update_stmt(stmt);
101195 +
101196 + return create_assign(visited, stmt, lhs, AFTER_STMT);
101197 +}
101198 +
101199 +static bool is_subtraction_special(const_gimple stmt)
101200 +{
101201 + gimple rhs1_def_stmt, rhs2_def_stmt;
101202 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
101203 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
101204 + const_tree rhs1 = gimple_assign_rhs1(stmt);
101205 + const_tree rhs2 = gimple_assign_rhs2(stmt);
101206 +
101207 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
101208 + return false;
101209 +
101210 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
101211 +
101212 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
101213 + return false;
101214 +
101215 + rhs1_def_stmt = get_def_stmt(rhs1);
101216 + rhs2_def_stmt = get_def_stmt(rhs2);
101217 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
101218 + return false;
101219 +
101220 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
101221 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
101222 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
101223 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
101224 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
101225 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
101226 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
101227 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
101228 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
101229 + return false;
101230 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
101231 + return false;
101232 +
101233 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
101234 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
101235 + return true;
101236 +}
101237 +
101238 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
101239 +{
101240 + tree new_rhs1, new_rhs2;
101241 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
101242 + gimple assign, stmt = get_def_stmt(lhs);
101243 + tree rhs1 = gimple_assign_rhs1(stmt);
101244 + tree rhs2 = gimple_assign_rhs2(stmt);
101245 +
101246 + if (!is_subtraction_special(stmt))
101247 + return NULL_TREE;
101248 +
101249 + new_rhs1 = expand(visited, rhs1);
101250 + new_rhs2 = expand(visited, rhs2);
101251 +
101252 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
101253 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
101254 +
101255 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
101256 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
101257 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
101258 + }
101259 +
101260 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
101261 + new_lhs = gimple_get_lhs(assign);
101262 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
101263 +
101264 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
101265 +}
101266 +
101267 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
101268 +{
101269 + const_gimple def_stmt;
101270 +
101271 + if (TREE_CODE(rhs) != SSA_NAME)
101272 + return false;
101273 +
101274 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
101275 + return false;
101276 +
101277 + def_stmt = get_def_stmt(rhs);
101278 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
101279 + return false;
101280 +
101281 + return true;
101282 +}
101283 +
101284 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
101285 +{
101286 + tree rhs1, rhs2, new_lhs;
101287 + gimple def_stmt = get_def_stmt(lhs);
101288 + tree new_rhs1 = NULL_TREE;
101289 + tree new_rhs2 = NULL_TREE;
101290 +
101291 + rhs1 = gimple_assign_rhs1(def_stmt);
101292 + rhs2 = gimple_assign_rhs2(def_stmt);
101293 +
101294 + /* no DImode/TImode division in the 32/64 bit kernel */
101295 + switch (gimple_assign_rhs_code(def_stmt)) {
101296 + case RDIV_EXPR:
101297 + case TRUNC_DIV_EXPR:
101298 + case CEIL_DIV_EXPR:
101299 + case FLOOR_DIV_EXPR:
101300 + case ROUND_DIV_EXPR:
101301 + case TRUNC_MOD_EXPR:
101302 + case CEIL_MOD_EXPR:
101303 + case FLOOR_MOD_EXPR:
101304 + case ROUND_MOD_EXPR:
101305 + case EXACT_DIV_EXPR:
101306 + case POINTER_PLUS_EXPR:
101307 + case BIT_AND_EXPR:
101308 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
101309 + default:
101310 + break;
101311 + }
101312 +
101313 + new_lhs = handle_integer_truncation(visited, lhs);
101314 + if (new_lhs != NULL_TREE)
101315 + return new_lhs;
101316 +
101317 + if (TREE_CODE(rhs1) == SSA_NAME)
101318 + new_rhs1 = expand(visited, rhs1);
101319 + if (TREE_CODE(rhs2) == SSA_NAME)
101320 + new_rhs2 = expand(visited, rhs2);
101321 +
101322 + if (is_a_neg_overflow(def_stmt, rhs2))
101323 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
101324 + if (is_a_neg_overflow(def_stmt, rhs1))
101325 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
101326 +
101327 +
101328 + if (is_a_constant_overflow(def_stmt, rhs2))
101329 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
101330 + if (is_a_constant_overflow(def_stmt, rhs1))
101331 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
101332 +
101333 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
101334 +}
101335 +
101336 +#if BUILDING_GCC_VERSION >= 4007
101337 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
101338 +{
101339 + if (is_gimple_constant(rhs))
101340 + return cast_a_tree(size_overflow_type, rhs);
101341 + if (TREE_CODE(rhs) != SSA_NAME)
101342 + return NULL_TREE;
101343 + return expand(visited, rhs);
101344 +}
101345 +
101346 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
101347 +{
101348 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
101349 + gimple def_stmt = get_def_stmt(lhs);
101350 +
101351 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
101352 +
101353 + rhs1 = gimple_assign_rhs1(def_stmt);
101354 + rhs2 = gimple_assign_rhs2(def_stmt);
101355 + rhs3 = gimple_assign_rhs3(def_stmt);
101356 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
101357 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
101358 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
101359 +
101360 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
101361 +}
101362 +#endif
101363 +
101364 +static tree get_size_overflow_type(gimple stmt, const_tree node)
101365 +{
101366 + const_tree type;
101367 + tree new_type;
101368 +
101369 + gcc_assert(node != NULL_TREE);
101370 +
101371 + type = TREE_TYPE(node);
101372 +
101373 + if (gimple_plf(stmt, MY_STMT))
101374 + return TREE_TYPE(node);
101375 +
101376 + switch (TYPE_MODE(type)) {
101377 + case QImode:
101378 + new_type = intHI_type_node;
101379 + break;
101380 + case HImode:
101381 + new_type = intSI_type_node;
101382 + break;
101383 + case SImode:
101384 + new_type = intDI_type_node;
101385 + break;
101386 + case DImode:
101387 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
101388 + new_type = intDI_type_node;
101389 + else
101390 + new_type = intTI_type_node;
101391 + break;
101392 + default:
101393 + debug_tree((tree)node);
101394 + error("%s: unsupported gcc configuration.", __func__);
101395 + gcc_unreachable();
101396 + }
101397 +
101398 + if (TYPE_QUALS(type) != 0)
101399 + return build_qualified_type(new_type, TYPE_QUALS(type));
101400 + return new_type;
101401 +}
101402 +
101403 +static tree expand_visited(gimple def_stmt)
101404 +{
101405 + const_gimple next_stmt;
101406 + gimple_stmt_iterator gsi;
101407 + enum gimple_code code = gimple_code(def_stmt);
101408 +
101409 + if (code == GIMPLE_ASM)
101410 + return NULL_TREE;
101411 +
101412 + gsi = gsi_for_stmt(def_stmt);
101413 + gsi_next(&gsi);
101414 +
101415 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
101416 + return NULL_TREE;
101417 + gcc_assert(!gsi_end_p(gsi));
101418 + next_stmt = gsi_stmt(gsi);
101419 +
101420 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
101421 + return NULL_TREE;
101422 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
101423 +
101424 + return get_lhs(next_stmt);
101425 +}
101426 +
101427 +static tree expand(struct pointer_set_t *visited, tree lhs)
101428 +{
101429 + gimple def_stmt;
101430 +
101431 + if (skip_types(lhs))
101432 + return NULL_TREE;
101433 +
101434 + def_stmt = get_def_stmt(lhs);
101435 +
101436 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
101437 + return NULL_TREE;
101438 +
101439 + if (gimple_plf(def_stmt, MY_STMT))
101440 + return lhs;
101441 +
101442 + if (pointer_set_contains(visited, def_stmt))
101443 + return expand_visited(def_stmt);
101444 +
101445 + switch (gimple_code(def_stmt)) {
101446 + case GIMPLE_PHI:
101447 + return handle_phi(visited, lhs);
101448 + case GIMPLE_CALL:
101449 + case GIMPLE_ASM:
101450 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
101451 + case GIMPLE_ASSIGN:
101452 + switch (gimple_num_ops(def_stmt)) {
101453 + case 2:
101454 + return handle_unary_ops(visited, def_stmt);
101455 + case 3:
101456 + return handle_binary_ops(visited, lhs);
101457 +#if BUILDING_GCC_VERSION >= 4007
101458 + case 4:
101459 + return handle_ternary_ops(visited, lhs);
101460 +#endif
101461 + }
101462 + default:
101463 + debug_gimple_stmt(def_stmt);
101464 + error("%s: unknown gimple code", __func__);
101465 + gcc_unreachable();
101466 + }
101467 +}
101468 +
101469 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
101470 +{
101471 + const_gimple assign;
101472 + tree orig_type = TREE_TYPE(orig_node);
101473 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101474 +
101475 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101476 + return gimple_get_lhs(assign);
101477 +}
101478 +
101479 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
101480 +{
101481 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
101482 + update_stmt(stmt);
101483 +}
101484 +
101485 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
101486 +{
101487 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
101488 + update_stmt(stmt);
101489 +}
101490 +
101491 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
101492 +{
101493 + tree arg;
101494 + const_tree origarg;
101495 +
101496 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
101497 + return true;
101498 +
101499 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
101500 + while (origarg && *argnum) {
101501 + (*argnum)--;
101502 + origarg = TREE_CHAIN(origarg);
101503 + }
101504 +
101505 + gcc_assert(*argnum == 0);
101506 +
101507 + gcc_assert(origarg != NULL_TREE);
101508 + *argnum = 0;
101509 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
101510 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
101511 + return true;
101512 + return false;
101513 +}
101514 +
101515 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
101516 +{
101517 + gimple phi = get_def_stmt(result);
101518 + unsigned int i, n = gimple_phi_num_args(phi);
101519 +
101520 + if (!phi)
101521 + return MARK_NO;
101522 +
101523 + pointer_set_insert(visited, phi);
101524 + for (i = 0; i < n; i++) {
101525 + enum mark marked;
101526 + const_tree arg = gimple_phi_arg_def(phi, i);
101527 + marked = pre_expand(visited, search_err_code, arg);
101528 + if (marked != MARK_NO)
101529 + return marked;
101530 + }
101531 + return MARK_NO;
101532 +}
101533 +
101534 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
101535 +{
101536 + gimple def_stmt = get_def_stmt(lhs);
101537 + const_tree rhs;
101538 +
101539 + if (!def_stmt)
101540 + return MARK_NO;
101541 +
101542 + rhs = gimple_assign_rhs1(def_stmt);
101543 +
101544 + def_stmt = get_def_stmt(rhs);
101545 + if (is_gimple_constant(rhs))
101546 + search_err_code[FROM_CONST] = true;
101547 +
101548 + return pre_expand(visited, search_err_code, rhs);
101549 +}
101550 +
101551 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
101552 +{
101553 + gimple def_stmt = get_def_stmt(lhs);
101554 + const_tree rhs1, rhs2;
101555 + enum mark marked;
101556 +
101557 + if (!def_stmt)
101558 + return MARK_NO;
101559 +
101560 + search_err_code[CAST_ONLY] = false;
101561 +
101562 + rhs1 = gimple_assign_rhs1(def_stmt);
101563 + rhs2 = gimple_assign_rhs2(def_stmt);
101564 + marked = pre_expand(visited, search_err_code, rhs1);
101565 + if (marked != MARK_NO)
101566 + return marked;
101567 + return pre_expand(visited, search_err_code, rhs2);
101568 +}
101569 +
101570 +static const_tree search_field_decl(const_tree comp_ref)
101571 +{
101572 + const_tree field = NULL_TREE;
101573 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
101574 +
101575 + for (i = 0; i < len; i++) {
101576 + field = TREE_OPERAND(comp_ref, i);
101577 + if (TREE_CODE(field) == FIELD_DECL)
101578 + break;
101579 + }
101580 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
101581 + return field;
101582 +}
101583 +
101584 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
101585 +{
101586 + const_tree attr, p;
101587 +
101588 + // 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);
101589 + if (fndecl == NULL_TREE)
101590 + return MARK_NO;
101591 +
101592 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
101593 + if (!attr || !TREE_VALUE(attr))
101594 + return MARK_NO;
101595 +
101596 + p = TREE_VALUE(attr);
101597 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
101598 + return MARK_TURN_OFF;
101599 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
101600 + return MARK_NOT_INTENTIONAL;
101601 + if (argnum == 0) {
101602 + gcc_assert(current_function_decl == fndecl);
101603 + return MARK_NO;
101604 + }
101605 +
101606 + do {
101607 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
101608 + return MARK_YES;
101609 + p = TREE_CHAIN(p);
101610 + } while (p);
101611 +
101612 + return MARK_NO;
101613 +}
101614 +
101615 +static void print_missing_msg(tree func, unsigned int argnum)
101616 +{
101617 + unsigned int new_hash;
101618 + size_t len;
101619 + unsigned char tree_codes[CODES_LIMIT];
101620 + location_t loc;
101621 + const char *curfunc;
101622 +
101623 + func = get_original_function_decl(func);
101624 + loc = DECL_SOURCE_LOCATION(func);
101625 + curfunc = get_asm_name(func);
101626 +
101627 + len = get_function_decl(func, tree_codes);
101628 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
101629 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
101630 +}
101631 +
101632 +static unsigned int search_missing_attribute(const_tree arg)
101633 +{
101634 + unsigned int argnum;
101635 + const struct size_overflow_hash *hash;
101636 + const_tree type = TREE_TYPE(arg);
101637 + tree func = get_original_function_decl(current_function_decl);
101638 +
101639 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
101640 +
101641 + if (TREE_CODE(type) == POINTER_TYPE)
101642 + return 0;
101643 +
101644 + argnum = find_arg_number(arg, func);
101645 + if (argnum == 0)
101646 + return 0;
101647 +
101648 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
101649 + return argnum;
101650 +
101651 + hash = get_function_hash(func);
101652 + if (!hash || !(hash->param & (1U << argnum))) {
101653 + print_missing_msg(func, argnum);
101654 + return 0;
101655 + }
101656 + return argnum;
101657 +}
101658 +
101659 +static enum mark is_already_marked(const_tree lhs)
101660 +{
101661 + unsigned int argnum;
101662 + const_tree fndecl;
101663 +
101664 + argnum = search_missing_attribute(lhs);
101665 + fndecl = get_original_function_decl(current_function_decl);
101666 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
101667 + return MARK_YES;
101668 + return MARK_NO;
101669 +}
101670 +
101671 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
101672 +{
101673 + const_gimple def_stmt;
101674 +
101675 + if (skip_types(lhs))
101676 + return MARK_NO;
101677 +
101678 + if (TREE_CODE(lhs) == PARM_DECL)
101679 + return is_already_marked(lhs);
101680 +
101681 + if (TREE_CODE(lhs) == COMPONENT_REF) {
101682 + const_tree field, attr;
101683 +
101684 + field = search_field_decl(lhs);
101685 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
101686 + if (!attr || !TREE_VALUE(attr))
101687 + return MARK_NO;
101688 + return MARK_YES;
101689 + }
101690 +
101691 + def_stmt = get_def_stmt(lhs);
101692 +
101693 + if (!def_stmt)
101694 + return MARK_NO;
101695 +
101696 + if (pointer_set_contains(visited, def_stmt))
101697 + return MARK_NO;
101698 +
101699 + switch (gimple_code(def_stmt)) {
101700 + case GIMPLE_NOP:
101701 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
101702 + return is_already_marked(lhs);
101703 + return MARK_NO;
101704 + case GIMPLE_PHI:
101705 + return walk_phi(visited, search_err_code, lhs);
101706 + case GIMPLE_CALL:
101707 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
101708 + return MARK_TURN_OFF;
101709 + check_function_hash(def_stmt);
101710 + return MARK_NO;
101711 + case GIMPLE_ASM:
101712 + search_err_code[CAST_ONLY] = false;
101713 + return MARK_NO;
101714 + case GIMPLE_ASSIGN:
101715 + switch (gimple_num_ops(def_stmt)) {
101716 + case 2:
101717 + return walk_unary_ops(visited, search_err_code, lhs);
101718 + case 3:
101719 + return walk_binary_ops(visited, search_err_code, lhs);
101720 + }
101721 + default:
101722 + debug_gimple_stmt((gimple)def_stmt);
101723 + error("%s: unknown gimple code", __func__);
101724 + gcc_unreachable();
101725 + }
101726 +}
101727 +
101728 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
101729 +static bool skip_asm(const_tree arg)
101730 +{
101731 + gimple def_stmt = get_def_stmt(arg);
101732 +
101733 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
101734 + return false;
101735 +
101736 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
101737 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
101738 +}
101739 +
101740 +/*
101741 +0</MARK_YES: no dup, search attributes (so, int)
101742 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
101743 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
101744 +*/
101745 +
101746 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
101747 +{
101748 + struct pointer_set_t *visited;
101749 + enum mark is_marked, is_found;
101750 + location_t loc;
101751 + bool search_err_code[2] = {true, false};
101752 +
101753 + is_marked = mark_status(current_function_decl, 0);
101754 + if (is_marked == MARK_TURN_OFF)
101755 + return true;
101756 +
101757 + is_marked = mark_status(fndecl, argnum + 1);
101758 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
101759 + return true;
101760 +
101761 + visited = pointer_set_create();
101762 + is_found = pre_expand(visited, search_err_code, arg);
101763 + pointer_set_destroy(visited);
101764 +
101765 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
101766 + return true;
101767 +
101768 + if (where == FROM_ARG && skip_asm(arg))
101769 + return true;
101770 +
101771 + if (is_found == MARK_TURN_OFF)
101772 + return true;
101773 +
101774 + if ((is_found == MARK_YES && is_marked == MARK_YES))
101775 + return true;
101776 +
101777 + if (is_found == MARK_YES) {
101778 + loc = DECL_SOURCE_LOCATION(fndecl);
101779 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
101780 + return true;
101781 + }
101782 + return false;
101783 +}
101784 +
101785 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
101786 +{
101787 + struct pointer_set_t *visited;
101788 + tree arg, new_arg;
101789 + bool match;
101790 +
101791 + if (argnum == 0)
101792 + return;
101793 +
101794 + argnum--;
101795 +
101796 + match = get_function_arg(&argnum, fndecl);
101797 + if (!match)
101798 + return;
101799 + gcc_assert(gimple_call_num_args(stmt) > argnum);
101800 + arg = gimple_call_arg(stmt, argnum);
101801 + if (arg == NULL_TREE)
101802 + return;
101803 +
101804 + if (skip_types(arg))
101805 + return;
101806 +
101807 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
101808 + return;
101809 +
101810 + visited = pointer_set_create();
101811 + new_arg = expand(visited, arg);
101812 + pointer_set_destroy(visited);
101813 +
101814 + if (new_arg == NULL_TREE)
101815 + return;
101816 +
101817 + change_function_arg(stmt, arg, argnum, new_arg);
101818 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
101819 +}
101820 +
101821 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
101822 +{
101823 + tree p = TREE_VALUE(attr);
101824 + do {
101825 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
101826 + p = TREE_CHAIN(p);
101827 + } while (p);
101828 +}
101829 +
101830 +static void handle_function_by_hash(gimple stmt, tree fndecl)
101831 +{
101832 + unsigned int num;
101833 + const struct size_overflow_hash *hash;
101834 +
101835 + hash = get_function_hash(fndecl);
101836 + if (!hash)
101837 + return;
101838 +
101839 + for (num = 0; num <= MAX_PARAM; num++)
101840 + if (hash->param & (1U << num))
101841 + handle_function_arg(stmt, fndecl, num);
101842 +}
101843 +
101844 +static bool check_return_value(void)
101845 +{
101846 + const struct size_overflow_hash *hash;
101847 +
101848 + hash = get_function_hash(current_function_decl);
101849 + if (!hash || !(hash->param & 1U << 0))
101850 + return false;
101851 +
101852 + return true;
101853 +}
101854 +
101855 +static void handle_return_value(gimple ret_stmt)
101856 +{
101857 + struct pointer_set_t *visited;
101858 + tree ret, new_ret;
101859 +
101860 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
101861 + return;
101862 +
101863 + ret = gimple_return_retval(ret_stmt);
101864 +
101865 + if (skip_types(ret))
101866 + return;
101867 +
101868 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
101869 + return;
101870 +
101871 + visited = pointer_set_create();
101872 + new_ret = expand(visited, ret);
101873 + pointer_set_destroy(visited);
101874 +
101875 + change_function_return(ret_stmt, ret, new_ret);
101876 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
101877 +}
101878 +
101879 +static void set_plf_false(void)
101880 +{
101881 + basic_block bb;
101882 +
101883 + FOR_ALL_BB(bb) {
101884 + gimple_stmt_iterator si;
101885 +
101886 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
101887 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
101888 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
101889 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
101890 + }
101891 +}
101892 +
101893 +static unsigned int handle_function(void)
101894 +{
101895 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
101896 + bool check_ret;
101897 +
101898 + set_plf_false();
101899 +
101900 + check_ret = check_return_value();
101901 +
101902 + do {
101903 + gimple_stmt_iterator gsi;
101904 + next = bb->next_bb;
101905 +
101906 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101907 + tree fndecl, attr;
101908 + gimple stmt = gsi_stmt(gsi);
101909 +
101910 + if (check_ret)
101911 + handle_return_value(stmt);
101912 +
101913 + if (!(is_gimple_call(stmt)))
101914 + continue;
101915 + fndecl = gimple_call_fndecl(stmt);
101916 + if (fndecl == NULL_TREE)
101917 + continue;
101918 + if (gimple_call_num_args(stmt) == 0)
101919 + continue;
101920 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
101921 + if (!attr || !TREE_VALUE(attr))
101922 + handle_function_by_hash(stmt, fndecl);
101923 + else
101924 + handle_function_by_attribute(stmt, attr, fndecl);
101925 + gsi = gsi_for_stmt(stmt);
101926 + next = gimple_bb(stmt)->next_bb;
101927 + }
101928 + bb = next;
101929 + } while (bb);
101930 + return 0;
101931 +}
101932 +
101933 +static struct gimple_opt_pass size_overflow_pass = {
101934 + .pass = {
101935 + .type = GIMPLE_PASS,
101936 + .name = "size_overflow",
101937 +#if BUILDING_GCC_VERSION >= 4008
101938 + .optinfo_flags = OPTGROUP_NONE,
101939 +#endif
101940 + .gate = NULL,
101941 + .execute = handle_function,
101942 + .sub = NULL,
101943 + .next = NULL,
101944 + .static_pass_number = 0,
101945 + .tv_id = TV_NONE,
101946 + .properties_required = PROP_cfg,
101947 + .properties_provided = 0,
101948 + .properties_destroyed = 0,
101949 + .todo_flags_start = 0,
101950 + .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
101951 + }
101952 +};
101953 +
101954 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
101955 +{
101956 + tree fntype;
101957 +
101958 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
101959 +
101960 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
101961 + fntype = build_function_type_list(void_type_node,
101962 + const_char_ptr_type_node,
101963 + unsigned_type_node,
101964 + const_char_ptr_type_node,
101965 + const_char_ptr_type_node,
101966 + NULL_TREE);
101967 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
101968 +
101969 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
101970 + TREE_PUBLIC(report_size_overflow_decl) = 1;
101971 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
101972 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
101973 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
101974 +}
101975 +
101976 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101977 +{
101978 + int i;
101979 + const char * const plugin_name = plugin_info->base_name;
101980 + const int argc = plugin_info->argc;
101981 + const struct plugin_argument * const argv = plugin_info->argv;
101982 + bool enable = true;
101983 +
101984 + struct register_pass_info size_overflow_pass_info = {
101985 + .pass = &size_overflow_pass.pass,
101986 + .reference_pass_name = "ssa",
101987 + .ref_pass_instance_number = 1,
101988 + .pos_op = PASS_POS_INSERT_AFTER
101989 + };
101990 +
101991 + if (!plugin_default_version_check(version, &gcc_version)) {
101992 + error(G_("incompatible gcc/plugin versions"));
101993 + return 1;
101994 + }
101995 +
101996 + for (i = 0; i < argc; ++i) {
101997 + if (!strcmp(argv[i].key, "no-size-overflow")) {
101998 + enable = false;
101999 + continue;
102000 + }
102001 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102002 + }
102003 +
102004 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
102005 + if (enable) {
102006 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
102007 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
102008 + }
102009 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
102010 +
102011 + return 0;
102012 +}
102013 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
102014 new file mode 100644
102015 index 0000000..ac2901e
102016 --- /dev/null
102017 +++ b/tools/gcc/stackleak_plugin.c
102018 @@ -0,0 +1,327 @@
102019 +/*
102020 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
102021 + * Licensed under the GPL v2
102022 + *
102023 + * Note: the choice of the license means that the compilation process is
102024 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102025 + * but for the kernel it doesn't matter since it doesn't link against
102026 + * any of the gcc libraries
102027 + *
102028 + * gcc plugin to help implement various PaX features
102029 + *
102030 + * - track lowest stack pointer
102031 + *
102032 + * TODO:
102033 + * - initialize all local variables
102034 + *
102035 + * BUGS:
102036 + * - none known
102037 + */
102038 +#include "gcc-plugin.h"
102039 +#include "config.h"
102040 +#include "system.h"
102041 +#include "coretypes.h"
102042 +#include "tree.h"
102043 +#include "tree-pass.h"
102044 +#include "flags.h"
102045 +#include "intl.h"
102046 +#include "toplev.h"
102047 +#include "plugin.h"
102048 +//#include "expr.h" where are you...
102049 +#include "diagnostic.h"
102050 +#include "plugin-version.h"
102051 +#include "tm.h"
102052 +#include "function.h"
102053 +#include "basic-block.h"
102054 +#include "gimple.h"
102055 +#include "rtl.h"
102056 +#include "emit-rtl.h"
102057 +
102058 +#if BUILDING_GCC_VERSION >= 4008
102059 +#define TODO_dump_func 0
102060 +#endif
102061 +
102062 +extern void print_gimple_stmt(FILE *, gimple, int, int);
102063 +
102064 +int plugin_is_GPL_compatible;
102065 +
102066 +static int track_frame_size = -1;
102067 +static const char track_function[] = "pax_track_stack";
102068 +static const char check_function[] = "pax_check_alloca";
102069 +static bool init_locals;
102070 +
102071 +static struct plugin_info stackleak_plugin_info = {
102072 + .version = "201302112000",
102073 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
102074 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
102075 +};
102076 +
102077 +static bool gate_stackleak_track_stack(void);
102078 +static unsigned int execute_stackleak_tree_instrument(void);
102079 +static unsigned int execute_stackleak_final(void);
102080 +
102081 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
102082 + .pass = {
102083 + .type = GIMPLE_PASS,
102084 + .name = "stackleak_tree_instrument",
102085 +#if BUILDING_GCC_VERSION >= 4008
102086 + .optinfo_flags = OPTGROUP_NONE,
102087 +#endif
102088 + .gate = gate_stackleak_track_stack,
102089 + .execute = execute_stackleak_tree_instrument,
102090 + .sub = NULL,
102091 + .next = NULL,
102092 + .static_pass_number = 0,
102093 + .tv_id = TV_NONE,
102094 + .properties_required = PROP_gimple_leh | PROP_cfg,
102095 + .properties_provided = 0,
102096 + .properties_destroyed = 0,
102097 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
102098 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
102099 + }
102100 +};
102101 +
102102 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
102103 + .pass = {
102104 + .type = RTL_PASS,
102105 + .name = "stackleak_final",
102106 +#if BUILDING_GCC_VERSION >= 4008
102107 + .optinfo_flags = OPTGROUP_NONE,
102108 +#endif
102109 + .gate = gate_stackleak_track_stack,
102110 + .execute = execute_stackleak_final,
102111 + .sub = NULL,
102112 + .next = NULL,
102113 + .static_pass_number = 0,
102114 + .tv_id = TV_NONE,
102115 + .properties_required = 0,
102116 + .properties_provided = 0,
102117 + .properties_destroyed = 0,
102118 + .todo_flags_start = 0,
102119 + .todo_flags_finish = TODO_dump_func
102120 + }
102121 +};
102122 +
102123 +static bool gate_stackleak_track_stack(void)
102124 +{
102125 + return track_frame_size >= 0;
102126 +}
102127 +
102128 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
102129 +{
102130 + gimple check_alloca;
102131 + tree fntype, fndecl, alloca_size;
102132 +
102133 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
102134 + fndecl = build_fn_decl(check_function, fntype);
102135 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
102136 +
102137 + // insert call to void pax_check_alloca(unsigned long size)
102138 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
102139 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
102140 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
102141 +}
102142 +
102143 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
102144 +{
102145 + gimple track_stack;
102146 + tree fntype, fndecl;
102147 +
102148 + fntype = build_function_type_list(void_type_node, NULL_TREE);
102149 + fndecl = build_fn_decl(track_function, fntype);
102150 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
102151 +
102152 + // insert call to void pax_track_stack(void)
102153 + track_stack = gimple_build_call(fndecl, 0);
102154 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
102155 +}
102156 +
102157 +#if BUILDING_GCC_VERSION == 4005
102158 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
102159 +{
102160 + tree fndecl;
102161 +
102162 + if (!is_gimple_call(stmt))
102163 + return false;
102164 + fndecl = gimple_call_fndecl(stmt);
102165 + if (!fndecl)
102166 + return false;
102167 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
102168 + return false;
102169 +// print_node(stderr, "pax", fndecl, 4);
102170 + return DECL_FUNCTION_CODE(fndecl) == code;
102171 +}
102172 +#endif
102173 +
102174 +static bool is_alloca(gimple stmt)
102175 +{
102176 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
102177 + return true;
102178 +
102179 +#if BUILDING_GCC_VERSION >= 4007
102180 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
102181 + return true;
102182 +#endif
102183 +
102184 + return false;
102185 +}
102186 +
102187 +static unsigned int execute_stackleak_tree_instrument(void)
102188 +{
102189 + basic_block bb, entry_bb;
102190 + bool prologue_instrumented = false, is_leaf = true;
102191 +
102192 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
102193 +
102194 + // 1. loop through BBs and GIMPLE statements
102195 + FOR_EACH_BB(bb) {
102196 + gimple_stmt_iterator gsi;
102197 +
102198 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102199 + gimple stmt;
102200 +
102201 + stmt = gsi_stmt(gsi);
102202 +
102203 + if (is_gimple_call(stmt))
102204 + is_leaf = false;
102205 +
102206 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
102207 + if (!is_alloca(stmt))
102208 + continue;
102209 +
102210 + // 2. insert stack overflow check before each __builtin_alloca call
102211 + stackleak_check_alloca(&gsi);
102212 +
102213 + // 3. insert track call after each __builtin_alloca call
102214 + stackleak_add_instrumentation(&gsi);
102215 + if (bb == entry_bb)
102216 + prologue_instrumented = true;
102217 + }
102218 + }
102219 +
102220 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
102221 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
102222 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
102223 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
102224 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
102225 + return 0;
102226 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
102227 + return 0;
102228 +
102229 + // 4. insert track call at the beginning
102230 + if (!prologue_instrumented) {
102231 + gimple_stmt_iterator gsi;
102232 +
102233 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102234 + if (dom_info_available_p(CDI_DOMINATORS))
102235 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
102236 + gsi = gsi_start_bb(bb);
102237 + stackleak_add_instrumentation(&gsi);
102238 + }
102239 +
102240 + return 0;
102241 +}
102242 +
102243 +static unsigned int execute_stackleak_final(void)
102244 +{
102245 + rtx insn, next;
102246 +
102247 + if (cfun->calls_alloca)
102248 + return 0;
102249 +
102250 + // keep calls only if function frame is big enough
102251 + if (get_frame_size() >= track_frame_size)
102252 + return 0;
102253 +
102254 + // 1. find pax_track_stack calls
102255 + for (insn = get_insns(); insn; insn = next) {
102256 + // 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))
102257 + rtx body;
102258 +
102259 + next = NEXT_INSN(insn);
102260 + if (!CALL_P(insn))
102261 + continue;
102262 + body = PATTERN(insn);
102263 + if (GET_CODE(body) != CALL)
102264 + continue;
102265 + body = XEXP(body, 0);
102266 + if (GET_CODE(body) != MEM)
102267 + continue;
102268 + body = XEXP(body, 0);
102269 + if (GET_CODE(body) != SYMBOL_REF)
102270 + continue;
102271 + if (strcmp(XSTR(body, 0), track_function))
102272 + continue;
102273 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
102274 + // 2. delete call
102275 + delete_insn_and_edges(insn);
102276 +#if BUILDING_GCC_VERSION >= 4007
102277 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
102278 + insn = next;
102279 + next = NEXT_INSN(insn);
102280 + delete_insn_and_edges(insn);
102281 + }
102282 +#endif
102283 + }
102284 +
102285 +// print_simple_rtl(stderr, get_insns());
102286 +// print_rtl(stderr, get_insns());
102287 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
102288 +
102289 + return 0;
102290 +}
102291 +
102292 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102293 +{
102294 + const char * const plugin_name = plugin_info->base_name;
102295 + const int argc = plugin_info->argc;
102296 + const struct plugin_argument * const argv = plugin_info->argv;
102297 + int i;
102298 + struct register_pass_info stackleak_tree_instrument_pass_info = {
102299 + .pass = &stackleak_tree_instrument_pass.pass,
102300 +// .reference_pass_name = "tree_profile",
102301 + .reference_pass_name = "optimized",
102302 + .ref_pass_instance_number = 1,
102303 + .pos_op = PASS_POS_INSERT_BEFORE
102304 + };
102305 + struct register_pass_info stackleak_final_pass_info = {
102306 + .pass = &stackleak_final_rtl_opt_pass.pass,
102307 + .reference_pass_name = "final",
102308 + .ref_pass_instance_number = 1,
102309 + .pos_op = PASS_POS_INSERT_BEFORE
102310 + };
102311 +
102312 + if (!plugin_default_version_check(version, &gcc_version)) {
102313 + error(G_("incompatible gcc/plugin versions"));
102314 + return 1;
102315 + }
102316 +
102317 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
102318 +
102319 + for (i = 0; i < argc; ++i) {
102320 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
102321 + if (!argv[i].value) {
102322 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102323 + continue;
102324 + }
102325 + track_frame_size = atoi(argv[i].value);
102326 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
102327 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
102328 + continue;
102329 + }
102330 + if (!strcmp(argv[i].key, "initialize-locals")) {
102331 + if (argv[i].value) {
102332 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
102333 + continue;
102334 + }
102335 + init_locals = true;
102336 + continue;
102337 + }
102338 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102339 + }
102340 +
102341 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
102342 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
102343 +
102344 + return 0;
102345 +}
102346 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
102347 new file mode 100644
102348 index 0000000..b07fe22
102349 --- /dev/null
102350 +++ b/tools/gcc/structleak_plugin.c
102351 @@ -0,0 +1,276 @@
102352 +/*
102353 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
102354 + * Licensed under the GPL v2
102355 + *
102356 + * Note: the choice of the license means that the compilation process is
102357 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102358 + * but for the kernel it doesn't matter since it doesn't link against
102359 + * any of the gcc libraries
102360 + *
102361 + * gcc plugin to forcibly initialize certain local variables that could
102362 + * otherwise leak kernel stack to userland if they aren't properly initialized
102363 + * by later code
102364 + *
102365 + * Homepage: http://pax.grsecurity.net/
102366 + *
102367 + * Usage:
102368 + * $ # for 4.5/4.6/C based 4.7
102369 + * $ 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
102370 + * $ # for C++ based 4.7/4.8+
102371 + * $ 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
102372 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
102373 + *
102374 + * TODO: eliminate redundant initializers
102375 + * increase type coverage
102376 + */
102377 +
102378 +#include "gcc-plugin.h"
102379 +#include "config.h"
102380 +#include "system.h"
102381 +#include "coretypes.h"
102382 +#include "tree.h"
102383 +#include "tree-pass.h"
102384 +#include "intl.h"
102385 +#include "plugin-version.h"
102386 +#include "tm.h"
102387 +#include "toplev.h"
102388 +#include "function.h"
102389 +#include "tree-flow.h"
102390 +#include "plugin.h"
102391 +#include "gimple.h"
102392 +#include "diagnostic.h"
102393 +#include "cfgloop.h"
102394 +#include "langhooks.h"
102395 +
102396 +#if BUILDING_GCC_VERSION >= 4008
102397 +#define TODO_dump_func 0
102398 +#endif
102399 +
102400 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
102401 +
102402 +// unused type flag in all versions 4.5-4.8
102403 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
102404 +
102405 +int plugin_is_GPL_compatible;
102406 +void debug_gimple_stmt(gimple gs);
102407 +
102408 +static struct plugin_info structleak_plugin_info = {
102409 + .version = "201304082245",
102410 + .help = "disable\tdo not activate plugin\n",
102411 +};
102412 +
102413 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
102414 +{
102415 + *no_add_attrs = true;
102416 +
102417 + // check for types? for now accept everything linux has to offer
102418 + if (TREE_CODE(*node) != FIELD_DECL)
102419 + return NULL_TREE;
102420 +
102421 + *no_add_attrs = false;
102422 + return NULL_TREE;
102423 +}
102424 +
102425 +static struct attribute_spec user_attr = {
102426 + .name = "user",
102427 + .min_length = 0,
102428 + .max_length = 0,
102429 + .decl_required = false,
102430 + .type_required = false,
102431 + .function_type_required = false,
102432 + .handler = handle_user_attribute,
102433 +#if BUILDING_GCC_VERSION >= 4007
102434 + .affects_type_identity = true
102435 +#endif
102436 +};
102437 +
102438 +static void register_attributes(void *event_data, void *data)
102439 +{
102440 + register_attribute(&user_attr);
102441 +// register_attribute(&force_attr);
102442 +}
102443 +
102444 +static tree get_field_type(tree field)
102445 +{
102446 + return strip_array_types(TREE_TYPE(field));
102447 +}
102448 +
102449 +static bool is_userspace_type(tree type)
102450 +{
102451 + tree field;
102452 +
102453 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
102454 + tree fieldtype = get_field_type(field);
102455 + enum tree_code code = TREE_CODE(fieldtype);
102456 +
102457 + if (code == RECORD_TYPE || code == UNION_TYPE)
102458 + if (is_userspace_type(fieldtype))
102459 + return true;
102460 +
102461 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
102462 + return true;
102463 + }
102464 + return false;
102465 +}
102466 +
102467 +static void finish_type(void *event_data, void *data)
102468 +{
102469 + tree type = (tree)event_data;
102470 +
102471 + if (TYPE_USERSPACE(type))
102472 + return;
102473 +
102474 + if (is_userspace_type(type))
102475 + TYPE_USERSPACE(type) = 1;
102476 +}
102477 +
102478 +static void initialize(tree var)
102479 +{
102480 + basic_block bb;
102481 + gimple_stmt_iterator gsi;
102482 + tree initializer;
102483 + gimple init_stmt;
102484 +
102485 + // this is the original entry bb before the forced split
102486 + // TODO: check further BBs in case more splits occured before us
102487 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
102488 +
102489 + // first check if the variable is already initialized, warn otherwise
102490 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102491 + gimple stmt = gsi_stmt(gsi);
102492 + tree rhs1 = gimple_assign_rhs1(stmt);
102493 +
102494 + // we're looking for an assignment of a single rhs...
102495 + if (!gimple_assign_single_p(stmt))
102496 + continue;
102497 +#if BUILDING_GCC_VERSION >= 4007
102498 + // ... of a non-clobbering expression...
102499 + if (TREE_CLOBBER_P(rhs1))
102500 + continue;
102501 +#endif
102502 + // ... to our variable...
102503 + if (gimple_get_lhs(stmt) != var)
102504 + continue;
102505 + // if it's an initializer then we're good
102506 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
102507 + return;
102508 + }
102509 +
102510 + // these aren't the 0days you're looking for
102511 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
102512 +
102513 + // build the initializer expression
102514 + initializer = build_constructor(TREE_TYPE(var), NULL);
102515 +
102516 + // build the initializer stmt
102517 + init_stmt = gimple_build_assign(var, initializer);
102518 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
102519 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
102520 + update_stmt(init_stmt);
102521 +}
102522 +
102523 +static unsigned int handle_function(void)
102524 +{
102525 + basic_block bb;
102526 + unsigned int ret = 0;
102527 + tree var;
102528 +
102529 +#if BUILDING_GCC_VERSION == 4005
102530 + tree vars;
102531 +#else
102532 + unsigned int i;
102533 +#endif
102534 +
102535 + // split the first bb where we can put the forced initializers
102536 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102537 + if (dom_info_available_p(CDI_DOMINATORS))
102538 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
102539 +
102540 + // enumarate all local variables and forcibly initialize our targets
102541 +#if BUILDING_GCC_VERSION == 4005
102542 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
102543 + var = TREE_VALUE(vars);
102544 +#else
102545 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
102546 +#endif
102547 + tree type = TREE_TYPE(var);
102548 +
102549 + gcc_assert(DECL_P(var));
102550 + if (!auto_var_in_fn_p(var, current_function_decl))
102551 + continue;
102552 +
102553 + // only care about structure types
102554 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
102555 + continue;
102556 +
102557 + // if the type is of interest, examine the variable
102558 + if (TYPE_USERSPACE(type))
102559 + initialize(var);
102560 + }
102561 +
102562 + return ret;
102563 +}
102564 +
102565 +static struct gimple_opt_pass structleak_pass = {
102566 + .pass = {
102567 + .type = GIMPLE_PASS,
102568 + .name = "structleak",
102569 +#if BUILDING_GCC_VERSION >= 4008
102570 + .optinfo_flags = OPTGROUP_NONE,
102571 +#endif
102572 + .gate = NULL,
102573 + .execute = handle_function,
102574 + .sub = NULL,
102575 + .next = NULL,
102576 + .static_pass_number = 0,
102577 + .tv_id = TV_NONE,
102578 + .properties_required = PROP_cfg,
102579 + .properties_provided = 0,
102580 + .properties_destroyed = 0,
102581 + .todo_flags_start = 0,
102582 + .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
102583 + }
102584 +};
102585 +
102586 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102587 +{
102588 + int i;
102589 + const char * const plugin_name = plugin_info->base_name;
102590 + const int argc = plugin_info->argc;
102591 + const struct plugin_argument * const argv = plugin_info->argv;
102592 + bool enable = true;
102593 +
102594 + struct register_pass_info structleak_pass_info = {
102595 + .pass = &structleak_pass.pass,
102596 + .reference_pass_name = "ssa",
102597 + .ref_pass_instance_number = 1,
102598 + .pos_op = PASS_POS_INSERT_AFTER
102599 + };
102600 +
102601 + if (!plugin_default_version_check(version, &gcc_version)) {
102602 + error(G_("incompatible gcc/plugin versions"));
102603 + return 1;
102604 + }
102605 +
102606 + if (strcmp(lang_hooks.name, "GNU C")) {
102607 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
102608 + enable = false;
102609 + }
102610 +
102611 + for (i = 0; i < argc; ++i) {
102612 + if (!strcmp(argv[i].key, "disable")) {
102613 + enable = false;
102614 + continue;
102615 + }
102616 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102617 + }
102618 +
102619 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
102620 + if (enable) {
102621 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
102622 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
102623 + }
102624 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
102625 +
102626 + return 0;
102627 +}
102628 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
102629 index 6789d78..4afd019e 100644
102630 --- a/tools/perf/util/include/asm/alternative-asm.h
102631 +++ b/tools/perf/util/include/asm/alternative-asm.h
102632 @@ -5,4 +5,7 @@
102633
102634 #define altinstruction_entry #
102635
102636 + .macro pax_force_retaddr rip=0, reload=0
102637 + .endm
102638 +
102639 #endif
102640 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
102641 index 96b919d..c49bb74 100644
102642 --- a/tools/perf/util/include/linux/compiler.h
102643 +++ b/tools/perf/util/include/linux/compiler.h
102644 @@ -18,4 +18,12 @@
102645 #define __force
102646 #endif
102647
102648 +#ifndef __size_overflow
102649 +# define __size_overflow(...)
102650 +#endif
102651 +
102652 +#ifndef __intentional_overflow
102653 +# define __intentional_overflow(...)
102654 +#endif
102655 +
102656 #endif
102657 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
102658 index f18013f..90421df 100644
102659 --- a/virt/kvm/kvm_main.c
102660 +++ b/virt/kvm/kvm_main.c
102661 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
102662
102663 static cpumask_var_t cpus_hardware_enabled;
102664 static int kvm_usage_count = 0;
102665 -static atomic_t hardware_enable_failed;
102666 +static atomic_unchecked_t hardware_enable_failed;
102667
102668 struct kmem_cache *kvm_vcpu_cache;
102669 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
102670
102671 -static __read_mostly struct preempt_ops kvm_preempt_ops;
102672 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
102673 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
102674 +static struct preempt_ops kvm_preempt_ops = {
102675 + .sched_in = kvm_sched_in,
102676 + .sched_out = kvm_sched_out,
102677 +};
102678
102679 struct dentry *kvm_debugfs_dir;
102680
102681 @@ -769,7 +774,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
102682 /* We can read the guest memory with __xxx_user() later on. */
102683 if (user_alloc &&
102684 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
102685 - !access_ok(VERIFY_WRITE,
102686 + !__access_ok(VERIFY_WRITE,
102687 (void __user *)(unsigned long)mem->userspace_addr,
102688 mem->memory_size)))
102689 goto out;
102690 @@ -1881,7 +1886,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
102691 return 0;
102692 }
102693
102694 -static struct file_operations kvm_vcpu_fops = {
102695 +static file_operations_no_const kvm_vcpu_fops __read_only = {
102696 .release = kvm_vcpu_release,
102697 .unlocked_ioctl = kvm_vcpu_ioctl,
102698 #ifdef CONFIG_COMPAT
102699 @@ -2402,7 +2407,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
102700 return 0;
102701 }
102702
102703 -static struct file_operations kvm_vm_fops = {
102704 +static file_operations_no_const kvm_vm_fops __read_only = {
102705 .release = kvm_vm_release,
102706 .unlocked_ioctl = kvm_vm_ioctl,
102707 #ifdef CONFIG_COMPAT
102708 @@ -2500,7 +2505,7 @@ out:
102709 return r;
102710 }
102711
102712 -static struct file_operations kvm_chardev_ops = {
102713 +static file_operations_no_const kvm_chardev_ops __read_only = {
102714 .unlocked_ioctl = kvm_dev_ioctl,
102715 .compat_ioctl = kvm_dev_ioctl,
102716 .llseek = noop_llseek,
102717 @@ -2526,7 +2531,7 @@ static void hardware_enable_nolock(void *junk)
102718
102719 if (r) {
102720 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
102721 - atomic_inc(&hardware_enable_failed);
102722 + atomic_inc_unchecked(&hardware_enable_failed);
102723 printk(KERN_INFO "kvm: enabling virtualization on "
102724 "CPU%d failed\n", cpu);
102725 }
102726 @@ -2580,10 +2585,10 @@ static int hardware_enable_all(void)
102727
102728 kvm_usage_count++;
102729 if (kvm_usage_count == 1) {
102730 - atomic_set(&hardware_enable_failed, 0);
102731 + atomic_set_unchecked(&hardware_enable_failed, 0);
102732 on_each_cpu(hardware_enable_nolock, NULL, 1);
102733
102734 - if (atomic_read(&hardware_enable_failed)) {
102735 + if (atomic_read_unchecked(&hardware_enable_failed)) {
102736 hardware_disable_all_nolock();
102737 r = -EBUSY;
102738 }
102739 @@ -2941,7 +2946,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
102740 kvm_arch_vcpu_put(vcpu);
102741 }
102742
102743 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
102744 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
102745 struct module *module)
102746 {
102747 int r;
102748 @@ -2977,7 +2982,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
102749 if (!vcpu_align)
102750 vcpu_align = __alignof__(struct kvm_vcpu);
102751 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
102752 - 0, NULL);
102753 + SLAB_USERCOPY, NULL);
102754 if (!kvm_vcpu_cache) {
102755 r = -ENOMEM;
102756 goto out_free_3;
102757 @@ -2987,9 +2992,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
102758 if (r)
102759 goto out_free;
102760
102761 + pax_open_kernel();
102762 kvm_chardev_ops.owner = module;
102763 kvm_vm_fops.owner = module;
102764 kvm_vcpu_fops.owner = module;
102765 + pax_close_kernel();
102766
102767 r = misc_register(&kvm_dev);
102768 if (r) {
102769 @@ -2999,9 +3006,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
102770
102771 register_syscore_ops(&kvm_syscore_ops);
102772
102773 - kvm_preempt_ops.sched_in = kvm_sched_in;
102774 - kvm_preempt_ops.sched_out = kvm_sched_out;
102775 -
102776 r = kvm_init_debug();
102777 if (r) {
102778 printk(KERN_ERR "kvm: create debugfs files failed\n");