]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.9.4-201306041949.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.9.4-201306041949.patch
1 diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2 index b89a739..b47493f 100644
3 --- a/Documentation/dontdiff
4 +++ b/Documentation/dontdiff
5 @@ -2,9 +2,11 @@
6 *.aux
7 *.bin
8 *.bz2
9 +*.c.[012]*.*
10 *.cis
11 *.cpio
12 *.csp
13 +*.dbg
14 *.dsp
15 *.dvi
16 *.elf
17 @@ -14,6 +16,7 @@
18 *.gcov
19 *.gen.S
20 *.gif
21 +*.gmo
22 *.grep
23 *.grp
24 *.gz
25 @@ -48,14 +51,17 @@
26 *.tab.h
27 *.tex
28 *.ver
29 +*.vim
30 *.xml
31 *.xz
32 *_MODULES
33 +*_reg_safe.h
34 *_vga16.c
35 *~
36 \#*#
37 *.9
38 -.*
39 +.[^g]*
40 +.gen*
41 .*.d
42 .mm
43 53c700_d.h
44 @@ -69,6 +75,7 @@ Image
45 Module.markers
46 Module.symvers
47 PENDING
48 +PERF*
49 SCCS
50 System.map*
51 TAGS
52 @@ -80,6 +87,7 @@ aic7*seq.h*
53 aicasm
54 aicdb.h*
55 altivec*.c
56 +ashldi3.S
57 asm-offsets.h
58 asm_offsets.h
59 autoconf.h*
60 @@ -92,19 +100,24 @@ bounds.h
61 bsetup
62 btfixupprep
63 build
64 +builtin-policy.h
65 bvmlinux
66 bzImage*
67 capability_names.h
68 capflags.c
69 classlist.h*
70 +clut_vga16.c
71 +common-cmds.h
72 comp*.log
73 compile.h*
74 conf
75 config
76 config-*
77 config_data.h*
78 +config.c
79 config.mak
80 config.mak.autogen
81 +config.tmp
82 conmakehash
83 consolemap_deftbl.c*
84 cpustr.h
85 @@ -115,9 +128,11 @@ devlist.h*
86 dnotify_test
87 docproc
88 dslm
89 +dtc-lexer.lex.c
90 elf2ecoff
91 elfconfig.h*
92 evergreen_reg_safe.h
93 +exception_policy.conf
94 fixdep
95 flask.h
96 fore200e_mkfirm
97 @@ -125,12 +140,15 @@ fore200e_pca_fw.c*
98 gconf
99 gconf.glade.h
100 gen-devlist
101 +gen-kdb_cmds.c
102 gen_crc32table
103 gen_init_cpio
104 generated
105 genheaders
106 genksyms
107 *_gray256.c
108 +hash
109 +hid-example
110 hpet_example
111 hugepage-mmap
112 hugepage-shm
113 @@ -145,14 +163,14 @@ int32.c
114 int4.c
115 int8.c
116 kallsyms
117 -kconfig
118 +kern_constants.h
119 keywords.c
120 ksym.c*
121 ksym.h*
122 kxgettext
123 lex.c
124 lex.*.c
125 -linux
126 +lib1funcs.S
127 logo_*.c
128 logo_*_clut224.c
129 logo_*_mono.c
130 @@ -162,14 +180,15 @@ mach-types.h
131 machtypes.h
132 map
133 map_hugetlb
134 -media
135 mconf
136 +mdp
137 miboot*
138 mk_elfconfig
139 mkboot
140 mkbugboot
141 mkcpustr
142 mkdep
143 +mkpiggy
144 mkprep
145 mkregtable
146 mktables
147 @@ -185,6 +204,8 @@ oui.c*
148 page-types
149 parse.c
150 parse.h
151 +parse-events*
152 +pasyms.h
153 patches*
154 pca200e.bin
155 pca200e_ecd.bin2
156 @@ -194,6 +215,7 @@ perf-archive
157 piggyback
158 piggy.gzip
159 piggy.S
160 +pmu-*
161 pnmtologo
162 ppc_defs.h*
163 pss_boot.h
164 @@ -203,7 +225,10 @@ r200_reg_safe.h
165 r300_reg_safe.h
166 r420_reg_safe.h
167 r600_reg_safe.h
168 +realmode.lds
169 +realmode.relocs
170 recordmcount
171 +regdb.c
172 relocs
173 rlim_names.h
174 rn50_reg_safe.h
175 @@ -213,8 +238,12 @@ series
176 setup
177 setup.bin
178 setup.elf
179 +signing_key*
180 +size_overflow_hash.h
181 sImage
182 +slabinfo
183 sm_tbl*
184 +sortextable
185 split-include
186 syscalltab.h
187 tables.c
188 @@ -224,6 +253,7 @@ tftpboot.img
189 timeconst.h
190 times.h*
191 trix_boot.h
192 +user_constants.h
193 utsrelease.h*
194 vdso-syms.lds
195 vdso.lds
196 @@ -235,13 +265,17 @@ vdso32.lds
197 vdso32.so.dbg
198 vdso64.lds
199 vdso64.so.dbg
200 +vdsox32.lds
201 +vdsox32-syms.lds
202 version.h*
203 vmImage
204 vmlinux
205 vmlinux-*
206 vmlinux.aout
207 vmlinux.bin.all
208 +vmlinux.bin.bz2
209 vmlinux.lds
210 +vmlinux.relocs
211 vmlinuz
212 voffset.h
213 vsyscall.lds
214 @@ -249,9 +283,12 @@ vsyscall_32.lds
215 wanxlfw.inc
216 uImage
217 unifdef
218 +utsrelease.h
219 wakeup.bin
220 wakeup.elf
221 wakeup.lds
222 +x509*
223 zImage*
224 zconf.hash.c
225 +zconf.lex.c
226 zoffset.h
227 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
228 index 8ccbf27..afffeb4 100644
229 --- a/Documentation/kernel-parameters.txt
230 +++ b/Documentation/kernel-parameters.txt
231 @@ -948,6 +948,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
232 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0.
233 Default: 1024
234
235 + grsec_proc_gid= [GRKERNSEC_PROC_USERGROUP] Chooses GID to
236 + ignore grsecurity's /proc restrictions
237 +
238 +
239 hashdist= [KNL,NUMA] Large hashes allocated during boot
240 are distributed across NUMA nodes. Defaults on
241 for 64-bit NUMA, off otherwise.
242 @@ -2147,6 +2151,18 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
243 the specified number of seconds. This is to be used if
244 your oopses keep scrolling off the screen.
245
246 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
247 + virtualization environments that don't cope well with the
248 + expand down segment used by UDEREF on X86-32 or the frequent
249 + page table updates on X86-64.
250 +
251 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
252 +
253 + pax_extra_latent_entropy
254 + Enable a very simple form of latent entropy extraction
255 + from the first 4GB of memory as the bootmem allocator
256 + passes the memory pages to the buddy allocator.
257 +
258 pcbit= [HW,ISDN]
259
260 pcd. [PARIDE]
261 diff --git a/Makefile b/Makefile
262 index bfbfaf9..d0b1bb8 100644
263 --- a/Makefile
264 +++ b/Makefile
265 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
266
267 HOSTCC = gcc
268 HOSTCXX = g++
269 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
270 -HOSTCXXFLAGS = -O2
271 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
272 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
273 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
274
275 # Decide whether to build built-in, modular, or both.
276 # Normally, just do built-in.
277 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
278 # Rules shared between *config targets and build targets
279
280 # Basic helpers built in scripts/
281 -PHONY += scripts_basic
282 -scripts_basic:
283 +PHONY += scripts_basic gcc-plugins
284 +scripts_basic: gcc-plugins
285 $(Q)$(MAKE) $(build)=scripts/basic
286 $(Q)rm -f .tmp_quiet_recordmcount
287
288 @@ -576,6 +577,65 @@ else
289 KBUILD_CFLAGS += -O2
290 endif
291
292 +ifndef DISABLE_PAX_PLUGINS
293 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
294 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
295 +else
296 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
297 +endif
298 +ifneq ($(PLUGINCC),)
299 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
300 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
301 +endif
302 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
303 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
304 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
305 +endif
306 +ifdef CONFIG_KALLOCSTAT_PLUGIN
307 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
308 +endif
309 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
310 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
311 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
312 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
313 +endif
314 +ifdef CONFIG_CHECKER_PLUGIN
315 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
316 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
317 +endif
318 +endif
319 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
320 +ifdef CONFIG_PAX_SIZE_OVERFLOW
321 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
322 +endif
323 +ifdef CONFIG_PAX_LATENT_ENTROPY
324 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
325 +endif
326 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
327 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
328 +endif
329 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
330 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
331 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
332 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
333 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
334 +ifeq ($(KBUILD_EXTMOD),)
335 +gcc-plugins:
336 + $(Q)$(MAKE) $(build)=tools/gcc
337 +else
338 +gcc-plugins: ;
339 +endif
340 +else
341 +gcc-plugins:
342 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
343 + $(error Your gcc installation does not support plugins. If the necessary headers for plugin support are missing, they should be installed. On Debian, apt-get install gcc-<ver>-plugin-dev. If you choose to ignore this error and lessen the improvements provided by this patch, re-run make with the DISABLE_PAX_PLUGINS=y argument.))
344 +else
345 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
346 +endif
347 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
348 +endif
349 +endif
350 +
351 include $(srctree)/arch/$(SRCARCH)/Makefile
352
353 ifdef CONFIG_READABLE_ASM
354 @@ -733,7 +793,7 @@ export mod_sign_cmd
355
356
357 ifeq ($(KBUILD_EXTMOD),)
358 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
359 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
360
361 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
362 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
363 @@ -780,6 +840,8 @@ endif
364
365 # The actual objects are generated when descending,
366 # make sure no implicit rule kicks in
367 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
368 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
369 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
370
371 # Handle descending into subdirectories listed in $(vmlinux-dirs)
372 @@ -789,7 +851,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
373 # Error messages still appears in the original language
374
375 PHONY += $(vmlinux-dirs)
376 -$(vmlinux-dirs): prepare scripts
377 +$(vmlinux-dirs): gcc-plugins prepare scripts
378 $(Q)$(MAKE) $(build)=$@
379
380 # Store (new) KERNELRELASE string in include/config/kernel.release
381 @@ -833,6 +895,7 @@ prepare0: archprepare FORCE
382 $(Q)$(MAKE) $(build)=.
383
384 # All the preparing..
385 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
386 prepare: prepare0
387
388 # Generate some files
389 @@ -940,6 +1003,8 @@ all: modules
390 # using awk while concatenating to the final file.
391
392 PHONY += modules
393 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
394 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
395 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
396 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
397 @$(kecho) ' Building modules, stage 2.';
398 @@ -955,7 +1020,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
399
400 # Target to prepare building external modules
401 PHONY += modules_prepare
402 -modules_prepare: prepare scripts
403 +modules_prepare: gcc-plugins prepare scripts
404
405 # Target to install modules
406 PHONY += modules_install
407 @@ -1021,7 +1086,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
408 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
409 signing_key.priv signing_key.x509 x509.genkey \
410 extra_certificates signing_key.x509.keyid \
411 - signing_key.x509.signer
412 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
413
414 # clean - Delete most, but leave enough to build external modules
415 #
416 @@ -1061,6 +1126,7 @@ distclean: mrproper
417 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
418 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
419 -o -name '.*.rej' \
420 + -o -name '.*.rej' -o -name '*.so' \
421 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
422 -type f -print | xargs rm -f
423
424 @@ -1221,6 +1287,8 @@ PHONY += $(module-dirs) modules
425 $(module-dirs): crmodverdir $(objtree)/Module.symvers
426 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
427
428 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
429 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
430 modules: $(module-dirs)
431 @$(kecho) ' Building modules, stage 2.';
432 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
433 @@ -1357,17 +1425,21 @@ else
434 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
435 endif
436
437 -%.s: %.c prepare scripts FORCE
438 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
439 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
440 +%.s: %.c gcc-plugins prepare scripts FORCE
441 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
442 %.i: %.c prepare scripts FORCE
443 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
444 -%.o: %.c prepare scripts FORCE
445 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
446 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
447 +%.o: %.c gcc-plugins prepare scripts FORCE
448 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
449 %.lst: %.c prepare scripts FORCE
450 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
451 -%.s: %.S prepare scripts FORCE
452 +%.s: %.S gcc-plugins prepare scripts FORCE
453 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
454 -%.o: %.S prepare scripts FORCE
455 +%.o: %.S gcc-plugins prepare scripts FORCE
456 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
457 %.symtypes: %.c prepare scripts FORCE
458 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
459 @@ -1377,11 +1449,15 @@ endif
460 $(cmd_crmodverdir)
461 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
462 $(build)=$(build-dir)
463 -%/: prepare scripts FORCE
464 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
465 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
466 +%/: gcc-plugins prepare scripts FORCE
467 $(cmd_crmodverdir)
468 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
469 $(build)=$(build-dir)
470 -%.ko: prepare scripts FORCE
471 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
472 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
473 +%.ko: gcc-plugins prepare scripts FORCE
474 $(cmd_crmodverdir)
475 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
476 $(build)=$(build-dir) $(@:.ko=.o)
477 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
478 index c2cbe4f..f7264b4 100644
479 --- a/arch/alpha/include/asm/atomic.h
480 +++ b/arch/alpha/include/asm/atomic.h
481 @@ -250,6 +250,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
482 #define atomic_dec(v) atomic_sub(1,(v))
483 #define atomic64_dec(v) atomic64_sub(1,(v))
484
485 +#define atomic64_read_unchecked(v) atomic64_read(v)
486 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
487 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
488 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
489 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
490 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
491 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
492 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
493 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
494 +
495 #define smp_mb__before_atomic_dec() smp_mb()
496 #define smp_mb__after_atomic_dec() smp_mb()
497 #define smp_mb__before_atomic_inc() smp_mb()
498 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
499 index ad368a9..fbe0f25 100644
500 --- a/arch/alpha/include/asm/cache.h
501 +++ b/arch/alpha/include/asm/cache.h
502 @@ -4,19 +4,19 @@
503 #ifndef __ARCH_ALPHA_CACHE_H
504 #define __ARCH_ALPHA_CACHE_H
505
506 +#include <linux/const.h>
507
508 /* Bytes per L1 (data) cache line. */
509 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
510 -# define L1_CACHE_BYTES 64
511 # define L1_CACHE_SHIFT 6
512 #else
513 /* Both EV4 and EV5 are write-through, read-allocate,
514 direct-mapped, physical.
515 */
516 -# define L1_CACHE_BYTES 32
517 # define L1_CACHE_SHIFT 5
518 #endif
519
520 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
521 #define SMP_CACHE_BYTES L1_CACHE_BYTES
522
523 #endif
524 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
525 index 968d999..d36b2df 100644
526 --- a/arch/alpha/include/asm/elf.h
527 +++ b/arch/alpha/include/asm/elf.h
528 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
529
530 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
531
532 +#ifdef CONFIG_PAX_ASLR
533 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
534 +
535 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
536 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
537 +#endif
538 +
539 /* $0 is set by ld.so to a pointer to a function which might be
540 registered using atexit. This provides a mean for the dynamic
541 linker to call DT_FINI functions for shared libraries that have
542 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
543 index bc2a0da..8ad11ee 100644
544 --- a/arch/alpha/include/asm/pgalloc.h
545 +++ b/arch/alpha/include/asm/pgalloc.h
546 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
547 pgd_set(pgd, pmd);
548 }
549
550 +static inline void
551 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
552 +{
553 + pgd_populate(mm, pgd, pmd);
554 +}
555 +
556 extern pgd_t *pgd_alloc(struct mm_struct *mm);
557
558 static inline void
559 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
560 index 81a4342..348b927 100644
561 --- a/arch/alpha/include/asm/pgtable.h
562 +++ b/arch/alpha/include/asm/pgtable.h
563 @@ -102,6 +102,17 @@ struct vm_area_struct;
564 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
565 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
566 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
567 +
568 +#ifdef CONFIG_PAX_PAGEEXEC
569 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
570 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
571 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
572 +#else
573 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
574 +# define PAGE_COPY_NOEXEC PAGE_COPY
575 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
576 +#endif
577 +
578 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
579
580 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
581 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
582 index 2fd00b7..cfd5069 100644
583 --- a/arch/alpha/kernel/module.c
584 +++ b/arch/alpha/kernel/module.c
585 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
586
587 /* The small sections were sorted to the end of the segment.
588 The following should definitely cover them. */
589 - gp = (u64)me->module_core + me->core_size - 0x8000;
590 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
591 got = sechdrs[me->arch.gotsecindex].sh_addr;
592
593 for (i = 0; i < n; i++) {
594 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
595 index b9e37ad..44c24e7 100644
596 --- a/arch/alpha/kernel/osf_sys.c
597 +++ b/arch/alpha/kernel/osf_sys.c
598 @@ -1297,10 +1297,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
599 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
600
601 static unsigned long
602 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
603 - unsigned long limit)
604 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
605 + unsigned long limit, unsigned long flags)
606 {
607 struct vm_unmapped_area_info info;
608 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
609
610 info.flags = 0;
611 info.length = len;
612 @@ -1308,6 +1309,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
613 info.high_limit = limit;
614 info.align_mask = 0;
615 info.align_offset = 0;
616 + info.threadstack_offset = offset;
617 return vm_unmapped_area(&info);
618 }
619
620 @@ -1340,20 +1342,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
621 merely specific addresses, but regions of memory -- perhaps
622 this feature should be incorporated into all ports? */
623
624 +#ifdef CONFIG_PAX_RANDMMAP
625 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
626 +#endif
627 +
628 if (addr) {
629 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
630 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
631 if (addr != (unsigned long) -ENOMEM)
632 return addr;
633 }
634
635 /* Next, try allocating at TASK_UNMAPPED_BASE. */
636 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
637 - len, limit);
638 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
639 +
640 if (addr != (unsigned long) -ENOMEM)
641 return addr;
642
643 /* Finally, try allocating in low memory. */
644 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
645 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
646
647 return addr;
648 }
649 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
650 index 0c4132d..88f0d53 100644
651 --- a/arch/alpha/mm/fault.c
652 +++ b/arch/alpha/mm/fault.c
653 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
654 __reload_thread(pcb);
655 }
656
657 +#ifdef CONFIG_PAX_PAGEEXEC
658 +/*
659 + * PaX: decide what to do with offenders (regs->pc = fault address)
660 + *
661 + * returns 1 when task should be killed
662 + * 2 when patched PLT trampoline was detected
663 + * 3 when unpatched PLT trampoline was detected
664 + */
665 +static int pax_handle_fetch_fault(struct pt_regs *regs)
666 +{
667 +
668 +#ifdef CONFIG_PAX_EMUPLT
669 + int err;
670 +
671 + do { /* PaX: patched PLT emulation #1 */
672 + unsigned int ldah, ldq, jmp;
673 +
674 + err = get_user(ldah, (unsigned int *)regs->pc);
675 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
676 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
677 +
678 + if (err)
679 + break;
680 +
681 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
682 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
683 + jmp == 0x6BFB0000U)
684 + {
685 + unsigned long r27, addr;
686 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
687 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
688 +
689 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
690 + err = get_user(r27, (unsigned long *)addr);
691 + if (err)
692 + break;
693 +
694 + regs->r27 = r27;
695 + regs->pc = r27;
696 + return 2;
697 + }
698 + } while (0);
699 +
700 + do { /* PaX: patched PLT emulation #2 */
701 + unsigned int ldah, lda, br;
702 +
703 + err = get_user(ldah, (unsigned int *)regs->pc);
704 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
705 + err |= get_user(br, (unsigned int *)(regs->pc+8));
706 +
707 + if (err)
708 + break;
709 +
710 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
711 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
712 + (br & 0xFFE00000U) == 0xC3E00000U)
713 + {
714 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
715 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
716 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
717 +
718 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
719 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
720 + return 2;
721 + }
722 + } while (0);
723 +
724 + do { /* PaX: unpatched PLT emulation */
725 + unsigned int br;
726 +
727 + err = get_user(br, (unsigned int *)regs->pc);
728 +
729 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
730 + unsigned int br2, ldq, nop, jmp;
731 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
732 +
733 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
734 + err = get_user(br2, (unsigned int *)addr);
735 + err |= get_user(ldq, (unsigned int *)(addr+4));
736 + err |= get_user(nop, (unsigned int *)(addr+8));
737 + err |= get_user(jmp, (unsigned int *)(addr+12));
738 + err |= get_user(resolver, (unsigned long *)(addr+16));
739 +
740 + if (err)
741 + break;
742 +
743 + if (br2 == 0xC3600000U &&
744 + ldq == 0xA77B000CU &&
745 + nop == 0x47FF041FU &&
746 + jmp == 0x6B7B0000U)
747 + {
748 + regs->r28 = regs->pc+4;
749 + regs->r27 = addr+16;
750 + regs->pc = resolver;
751 + return 3;
752 + }
753 + }
754 + } while (0);
755 +#endif
756 +
757 + return 1;
758 +}
759 +
760 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
761 +{
762 + unsigned long i;
763 +
764 + printk(KERN_ERR "PAX: bytes at PC: ");
765 + for (i = 0; i < 5; i++) {
766 + unsigned int c;
767 + if (get_user(c, (unsigned int *)pc+i))
768 + printk(KERN_CONT "???????? ");
769 + else
770 + printk(KERN_CONT "%08x ", c);
771 + }
772 + printk("\n");
773 +}
774 +#endif
775
776 /*
777 * This routine handles page faults. It determines the address,
778 @@ -133,8 +251,29 @@ retry:
779 good_area:
780 si_code = SEGV_ACCERR;
781 if (cause < 0) {
782 - if (!(vma->vm_flags & VM_EXEC))
783 + if (!(vma->vm_flags & VM_EXEC)) {
784 +
785 +#ifdef CONFIG_PAX_PAGEEXEC
786 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
787 + goto bad_area;
788 +
789 + up_read(&mm->mmap_sem);
790 + switch (pax_handle_fetch_fault(regs)) {
791 +
792 +#ifdef CONFIG_PAX_EMUPLT
793 + case 2:
794 + case 3:
795 + return;
796 +#endif
797 +
798 + }
799 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
800 + do_group_exit(SIGKILL);
801 +#else
802 goto bad_area;
803 +#endif
804 +
805 + }
806 } else if (!cause) {
807 /* Allow reads even for write-only mappings */
808 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
809 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
810 index 1cacda4..2cef624 100644
811 --- a/arch/arm/Kconfig
812 +++ b/arch/arm/Kconfig
813 @@ -1850,7 +1850,7 @@ config ALIGNMENT_TRAP
814
815 config UACCESS_WITH_MEMCPY
816 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
817 - depends on MMU
818 + depends on MMU && !PAX_MEMORY_UDEREF
819 default y if CPU_FEROCEON
820 help
821 Implement faster copy_to_user and clear_user methods for CPU
822 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
823 index c79f61f..9ac0642 100644
824 --- a/arch/arm/include/asm/atomic.h
825 +++ b/arch/arm/include/asm/atomic.h
826 @@ -17,17 +17,35 @@
827 #include <asm/barrier.h>
828 #include <asm/cmpxchg.h>
829
830 +#ifdef CONFIG_GENERIC_ATOMIC64
831 +#include <asm-generic/atomic64.h>
832 +#endif
833 +
834 #define ATOMIC_INIT(i) { (i) }
835
836 #ifdef __KERNEL__
837
838 +#define _ASM_EXTABLE(from, to) \
839 +" .pushsection __ex_table,\"a\"\n"\
840 +" .align 3\n" \
841 +" .long " #from ", " #to"\n" \
842 +" .popsection"
843 +
844 /*
845 * On ARM, ordinary assignment (str instruction) doesn't clear the local
846 * strex/ldrex monitor on some implementations. The reason we can use it for
847 * atomic_set() is the clrex or dummy strex done on every exception return.
848 */
849 #define atomic_read(v) (*(volatile int *)&(v)->counter)
850 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
851 +{
852 + return v->counter;
853 +}
854 #define atomic_set(v,i) (((v)->counter) = (i))
855 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
856 +{
857 + v->counter = i;
858 +}
859
860 #if __LINUX_ARM_ARCH__ >= 6
861
862 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
863 int result;
864
865 __asm__ __volatile__("@ atomic_add\n"
866 +"1: ldrex %1, [%3]\n"
867 +" adds %0, %1, %4\n"
868 +
869 +#ifdef CONFIG_PAX_REFCOUNT
870 +" bvc 3f\n"
871 +"2: bkpt 0xf103\n"
872 +"3:\n"
873 +#endif
874 +
875 +" strex %1, %0, [%3]\n"
876 +" teq %1, #0\n"
877 +" bne 1b"
878 +
879 +#ifdef CONFIG_PAX_REFCOUNT
880 +"\n4:\n"
881 + _ASM_EXTABLE(2b, 4b)
882 +#endif
883 +
884 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
885 + : "r" (&v->counter), "Ir" (i)
886 + : "cc");
887 +}
888 +
889 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
890 +{
891 + unsigned long tmp;
892 + int result;
893 +
894 + __asm__ __volatile__("@ atomic_add_unchecked\n"
895 "1: ldrex %0, [%3]\n"
896 " add %0, %0, %4\n"
897 " strex %1, %0, [%3]\n"
898 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
899 smp_mb();
900
901 __asm__ __volatile__("@ atomic_add_return\n"
902 +"1: ldrex %1, [%3]\n"
903 +" adds %0, %1, %4\n"
904 +
905 +#ifdef CONFIG_PAX_REFCOUNT
906 +" bvc 3f\n"
907 +" mov %0, %1\n"
908 +"2: bkpt 0xf103\n"
909 +"3:\n"
910 +#endif
911 +
912 +" strex %1, %0, [%3]\n"
913 +" teq %1, #0\n"
914 +" bne 1b"
915 +
916 +#ifdef CONFIG_PAX_REFCOUNT
917 +"\n4:\n"
918 + _ASM_EXTABLE(2b, 4b)
919 +#endif
920 +
921 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
922 + : "r" (&v->counter), "Ir" (i)
923 + : "cc");
924 +
925 + smp_mb();
926 +
927 + return result;
928 +}
929 +
930 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
931 +{
932 + unsigned long tmp;
933 + int result;
934 +
935 + smp_mb();
936 +
937 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
938 "1: ldrex %0, [%3]\n"
939 " add %0, %0, %4\n"
940 " strex %1, %0, [%3]\n"
941 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
942 int result;
943
944 __asm__ __volatile__("@ atomic_sub\n"
945 +"1: ldrex %1, [%3]\n"
946 +" subs %0, %1, %4\n"
947 +
948 +#ifdef CONFIG_PAX_REFCOUNT
949 +" bvc 3f\n"
950 +"2: bkpt 0xf103\n"
951 +"3:\n"
952 +#endif
953 +
954 +" strex %1, %0, [%3]\n"
955 +" teq %1, #0\n"
956 +" bne 1b"
957 +
958 +#ifdef CONFIG_PAX_REFCOUNT
959 +"\n4:\n"
960 + _ASM_EXTABLE(2b, 4b)
961 +#endif
962 +
963 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
964 + : "r" (&v->counter), "Ir" (i)
965 + : "cc");
966 +}
967 +
968 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
969 +{
970 + unsigned long tmp;
971 + int result;
972 +
973 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
974 "1: ldrex %0, [%3]\n"
975 " sub %0, %0, %4\n"
976 " strex %1, %0, [%3]\n"
977 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
978 smp_mb();
979
980 __asm__ __volatile__("@ atomic_sub_return\n"
981 -"1: ldrex %0, [%3]\n"
982 -" sub %0, %0, %4\n"
983 +"1: ldrex %1, [%3]\n"
984 +" subs %0, %1, %4\n"
985 +
986 +#ifdef CONFIG_PAX_REFCOUNT
987 +" bvc 3f\n"
988 +" mov %0, %1\n"
989 +"2: bkpt 0xf103\n"
990 +"3:\n"
991 +#endif
992 +
993 " strex %1, %0, [%3]\n"
994 " teq %1, #0\n"
995 " bne 1b"
996 +
997 +#ifdef CONFIG_PAX_REFCOUNT
998 +"\n4:\n"
999 + _ASM_EXTABLE(2b, 4b)
1000 +#endif
1001 +
1002 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1003 : "r" (&v->counter), "Ir" (i)
1004 : "cc");
1005 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1006 return oldval;
1007 }
1008
1009 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1010 +{
1011 + unsigned long oldval, res;
1012 +
1013 + smp_mb();
1014 +
1015 + do {
1016 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1017 + "ldrex %1, [%3]\n"
1018 + "mov %0, #0\n"
1019 + "teq %1, %4\n"
1020 + "strexeq %0, %5, [%3]\n"
1021 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1022 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1023 + : "cc");
1024 + } while (res);
1025 +
1026 + smp_mb();
1027 +
1028 + return oldval;
1029 +}
1030 +
1031 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1032 {
1033 unsigned long tmp, tmp2;
1034 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1035
1036 return val;
1037 }
1038 +
1039 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1040 +{
1041 + return atomic_add_return(i, v);
1042 +}
1043 +
1044 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1045 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1046 +{
1047 + (void) atomic_add_return(i, v);
1048 +}
1049
1050 static inline int atomic_sub_return(int i, atomic_t *v)
1051 {
1052 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1053 return val;
1054 }
1055 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1056 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1057 +{
1058 + (void) atomic_sub_return(i, v);
1059 +}
1060
1061 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1062 {
1063 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1064 return ret;
1065 }
1066
1067 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1068 +{
1069 + return atomic_cmpxchg(v, old, new);
1070 +}
1071 +
1072 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1073 {
1074 unsigned long flags;
1075 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1076 #endif /* __LINUX_ARM_ARCH__ */
1077
1078 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1079 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1080 +{
1081 + return xchg(&v->counter, new);
1082 +}
1083
1084 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1085 {
1086 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1087 }
1088
1089 #define atomic_inc(v) atomic_add(1, v)
1090 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1091 +{
1092 + atomic_add_unchecked(1, v);
1093 +}
1094 #define atomic_dec(v) atomic_sub(1, v)
1095 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1096 +{
1097 + atomic_sub_unchecked(1, v);
1098 +}
1099
1100 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1101 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1102 +{
1103 + return atomic_add_return_unchecked(1, v) == 0;
1104 +}
1105 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1106 #define atomic_inc_return(v) (atomic_add_return(1, v))
1107 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1108 +{
1109 + return atomic_add_return_unchecked(1, v);
1110 +}
1111 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1112 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1113
1114 @@ -241,6 +428,14 @@ typedef struct {
1115 u64 __aligned(8) counter;
1116 } atomic64_t;
1117
1118 +#ifdef CONFIG_PAX_REFCOUNT
1119 +typedef struct {
1120 + u64 __aligned(8) counter;
1121 +} atomic64_unchecked_t;
1122 +#else
1123 +typedef atomic64_t atomic64_unchecked_t;
1124 +#endif
1125 +
1126 #define ATOMIC64_INIT(i) { (i) }
1127
1128 static inline u64 atomic64_read(const atomic64_t *v)
1129 @@ -256,6 +451,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1130 return result;
1131 }
1132
1133 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1134 +{
1135 + u64 result;
1136 +
1137 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1138 +" ldrexd %0, %H0, [%1]"
1139 + : "=&r" (result)
1140 + : "r" (&v->counter), "Qo" (v->counter)
1141 + );
1142 +
1143 + return result;
1144 +}
1145 +
1146 static inline void atomic64_set(atomic64_t *v, u64 i)
1147 {
1148 u64 tmp;
1149 @@ -270,6 +478,20 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1150 : "cc");
1151 }
1152
1153 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1154 +{
1155 + u64 tmp;
1156 +
1157 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1158 +"1: ldrexd %0, %H0, [%2]\n"
1159 +" strexd %0, %3, %H3, [%2]\n"
1160 +" teq %0, #0\n"
1161 +" bne 1b"
1162 + : "=&r" (tmp), "=Qo" (v->counter)
1163 + : "r" (&v->counter), "r" (i)
1164 + : "cc");
1165 +}
1166 +
1167 static inline void atomic64_add(u64 i, atomic64_t *v)
1168 {
1169 u64 result;
1170 @@ -278,6 +500,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1171 __asm__ __volatile__("@ atomic64_add\n"
1172 "1: ldrexd %0, %H0, [%3]\n"
1173 " adds %0, %0, %4\n"
1174 +" adcs %H0, %H0, %H4\n"
1175 +
1176 +#ifdef CONFIG_PAX_REFCOUNT
1177 +" bvc 3f\n"
1178 +"2: bkpt 0xf103\n"
1179 +"3:\n"
1180 +#endif
1181 +
1182 +" strexd %1, %0, %H0, [%3]\n"
1183 +" teq %1, #0\n"
1184 +" bne 1b"
1185 +
1186 +#ifdef CONFIG_PAX_REFCOUNT
1187 +"\n4:\n"
1188 + _ASM_EXTABLE(2b, 4b)
1189 +#endif
1190 +
1191 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1192 + : "r" (&v->counter), "r" (i)
1193 + : "cc");
1194 +}
1195 +
1196 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1197 +{
1198 + u64 result;
1199 + unsigned long tmp;
1200 +
1201 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1202 +"1: ldrexd %0, %H0, [%3]\n"
1203 +" adds %0, %0, %4\n"
1204 " adc %H0, %H0, %H4\n"
1205 " strexd %1, %0, %H0, [%3]\n"
1206 " teq %1, #0\n"
1207 @@ -289,12 +541,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1208
1209 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1210 {
1211 - u64 result;
1212 - unsigned long tmp;
1213 + u64 result, tmp;
1214
1215 smp_mb();
1216
1217 __asm__ __volatile__("@ atomic64_add_return\n"
1218 +"1: ldrexd %1, %H1, [%3]\n"
1219 +" adds %0, %1, %4\n"
1220 +" adcs %H0, %H1, %H4\n"
1221 +
1222 +#ifdef CONFIG_PAX_REFCOUNT
1223 +" bvc 3f\n"
1224 +" mov %0, %1\n"
1225 +" mov %H0, %H1\n"
1226 +"2: bkpt 0xf103\n"
1227 +"3:\n"
1228 +#endif
1229 +
1230 +" strexd %1, %0, %H0, [%3]\n"
1231 +" teq %1, #0\n"
1232 +" bne 1b"
1233 +
1234 +#ifdef CONFIG_PAX_REFCOUNT
1235 +"\n4:\n"
1236 + _ASM_EXTABLE(2b, 4b)
1237 +#endif
1238 +
1239 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1240 + : "r" (&v->counter), "r" (i)
1241 + : "cc");
1242 +
1243 + smp_mb();
1244 +
1245 + return result;
1246 +}
1247 +
1248 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1249 +{
1250 + u64 result;
1251 + unsigned long tmp;
1252 +
1253 + smp_mb();
1254 +
1255 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1256 "1: ldrexd %0, %H0, [%3]\n"
1257 " adds %0, %0, %4\n"
1258 " adc %H0, %H0, %H4\n"
1259 @@ -318,6 +607,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1260 __asm__ __volatile__("@ atomic64_sub\n"
1261 "1: ldrexd %0, %H0, [%3]\n"
1262 " subs %0, %0, %4\n"
1263 +" sbcs %H0, %H0, %H4\n"
1264 +
1265 +#ifdef CONFIG_PAX_REFCOUNT
1266 +" bvc 3f\n"
1267 +"2: bkpt 0xf103\n"
1268 +"3:\n"
1269 +#endif
1270 +
1271 +" strexd %1, %0, %H0, [%3]\n"
1272 +" teq %1, #0\n"
1273 +" bne 1b"
1274 +
1275 +#ifdef CONFIG_PAX_REFCOUNT
1276 +"\n4:\n"
1277 + _ASM_EXTABLE(2b, 4b)
1278 +#endif
1279 +
1280 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1281 + : "r" (&v->counter), "r" (i)
1282 + : "cc");
1283 +}
1284 +
1285 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1286 +{
1287 + u64 result;
1288 + unsigned long tmp;
1289 +
1290 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1291 +"1: ldrexd %0, %H0, [%3]\n"
1292 +" subs %0, %0, %4\n"
1293 " sbc %H0, %H0, %H4\n"
1294 " strexd %1, %0, %H0, [%3]\n"
1295 " teq %1, #0\n"
1296 @@ -329,18 +648,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1297
1298 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1299 {
1300 - u64 result;
1301 - unsigned long tmp;
1302 + u64 result, tmp;
1303
1304 smp_mb();
1305
1306 __asm__ __volatile__("@ atomic64_sub_return\n"
1307 -"1: ldrexd %0, %H0, [%3]\n"
1308 -" subs %0, %0, %4\n"
1309 -" sbc %H0, %H0, %H4\n"
1310 +"1: ldrexd %1, %H1, [%3]\n"
1311 +" subs %0, %1, %4\n"
1312 +" sbcs %H0, %H1, %H4\n"
1313 +
1314 +#ifdef CONFIG_PAX_REFCOUNT
1315 +" bvc 3f\n"
1316 +" mov %0, %1\n"
1317 +" mov %H0, %H1\n"
1318 +"2: bkpt 0xf103\n"
1319 +"3:\n"
1320 +#endif
1321 +
1322 " strexd %1, %0, %H0, [%3]\n"
1323 " teq %1, #0\n"
1324 " bne 1b"
1325 +
1326 +#ifdef CONFIG_PAX_REFCOUNT
1327 +"\n4:\n"
1328 + _ASM_EXTABLE(2b, 4b)
1329 +#endif
1330 +
1331 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1332 : "r" (&v->counter), "r" (i)
1333 : "cc");
1334 @@ -374,6 +707,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1335 return oldval;
1336 }
1337
1338 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1339 +{
1340 + u64 oldval;
1341 + unsigned long res;
1342 +
1343 + smp_mb();
1344 +
1345 + do {
1346 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1347 + "ldrexd %1, %H1, [%3]\n"
1348 + "mov %0, #0\n"
1349 + "teq %1, %4\n"
1350 + "teqeq %H1, %H4\n"
1351 + "strexdeq %0, %5, %H5, [%3]"
1352 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1353 + : "r" (&ptr->counter), "r" (old), "r" (new)
1354 + : "cc");
1355 + } while (res);
1356 +
1357 + smp_mb();
1358 +
1359 + return oldval;
1360 +}
1361 +
1362 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1363 {
1364 u64 result;
1365 @@ -397,21 +754,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1366
1367 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1368 {
1369 - u64 result;
1370 - unsigned long tmp;
1371 + u64 result, tmp;
1372
1373 smp_mb();
1374
1375 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1376 -"1: ldrexd %0, %H0, [%3]\n"
1377 -" subs %0, %0, #1\n"
1378 -" sbc %H0, %H0, #0\n"
1379 +"1: ldrexd %1, %H1, [%3]\n"
1380 +" subs %0, %1, #1\n"
1381 +" sbcs %H0, %H1, #0\n"
1382 +
1383 +#ifdef CONFIG_PAX_REFCOUNT
1384 +" bvc 3f\n"
1385 +" mov %0, %1\n"
1386 +" mov %H0, %H1\n"
1387 +"2: bkpt 0xf103\n"
1388 +"3:\n"
1389 +#endif
1390 +
1391 " teq %H0, #0\n"
1392 -" bmi 2f\n"
1393 +" bmi 4f\n"
1394 " strexd %1, %0, %H0, [%3]\n"
1395 " teq %1, #0\n"
1396 " bne 1b\n"
1397 -"2:"
1398 +"4:\n"
1399 +
1400 +#ifdef CONFIG_PAX_REFCOUNT
1401 + _ASM_EXTABLE(2b, 4b)
1402 +#endif
1403 +
1404 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1405 : "r" (&v->counter)
1406 : "cc");
1407 @@ -434,13 +804,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1408 " teq %0, %5\n"
1409 " teqeq %H0, %H5\n"
1410 " moveq %1, #0\n"
1411 -" beq 2f\n"
1412 +" beq 4f\n"
1413 " adds %0, %0, %6\n"
1414 -" adc %H0, %H0, %H6\n"
1415 +" adcs %H0, %H0, %H6\n"
1416 +
1417 +#ifdef CONFIG_PAX_REFCOUNT
1418 +" bvc 3f\n"
1419 +"2: bkpt 0xf103\n"
1420 +"3:\n"
1421 +#endif
1422 +
1423 " strexd %2, %0, %H0, [%4]\n"
1424 " teq %2, #0\n"
1425 " bne 1b\n"
1426 -"2:"
1427 +"4:\n"
1428 +
1429 +#ifdef CONFIG_PAX_REFCOUNT
1430 + _ASM_EXTABLE(2b, 4b)
1431 +#endif
1432 +
1433 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1434 : "r" (&v->counter), "r" (u), "r" (a)
1435 : "cc");
1436 @@ -453,10 +835,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1437
1438 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1439 #define atomic64_inc(v) atomic64_add(1LL, (v))
1440 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1441 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1442 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1443 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1444 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1445 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1446 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1447 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1448 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1449 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1450 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1451 index 75fe66b..ba3dee4 100644
1452 --- a/arch/arm/include/asm/cache.h
1453 +++ b/arch/arm/include/asm/cache.h
1454 @@ -4,8 +4,10 @@
1455 #ifndef __ASMARM_CACHE_H
1456 #define __ASMARM_CACHE_H
1457
1458 +#include <linux/const.h>
1459 +
1460 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1461 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1462 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1463
1464 /*
1465 * Memory returned by kmalloc() may be used for DMA, so we must make
1466 @@ -24,5 +26,6 @@
1467 #endif
1468
1469 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1470 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1471
1472 #endif
1473 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1474 index e1489c5..d418304 100644
1475 --- a/arch/arm/include/asm/cacheflush.h
1476 +++ b/arch/arm/include/asm/cacheflush.h
1477 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1478 void (*dma_unmap_area)(const void *, size_t, int);
1479
1480 void (*dma_flush_range)(const void *, const void *);
1481 -};
1482 +} __no_const;
1483
1484 /*
1485 * Select the calling method
1486 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1487 index 6dcc164..b14d917 100644
1488 --- a/arch/arm/include/asm/checksum.h
1489 +++ b/arch/arm/include/asm/checksum.h
1490 @@ -37,7 +37,19 @@ __wsum
1491 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1492
1493 __wsum
1494 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1495 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1496 +
1497 +static inline __wsum
1498 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1499 +{
1500 + __wsum ret;
1501 + pax_open_userland();
1502 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1503 + pax_close_userland();
1504 + return ret;
1505 +}
1506 +
1507 +
1508
1509 /*
1510 * Fold a partial checksum without adding pseudo headers
1511 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1512 index 4f009c1..466c59b 100644
1513 --- a/arch/arm/include/asm/cmpxchg.h
1514 +++ b/arch/arm/include/asm/cmpxchg.h
1515 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1516
1517 #define xchg(ptr,x) \
1518 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1519 +#define xchg_unchecked(ptr,x) \
1520 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1521
1522 #include <asm-generic/cmpxchg-local.h>
1523
1524 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1525 index 6ddbe44..b5e38b1 100644
1526 --- a/arch/arm/include/asm/domain.h
1527 +++ b/arch/arm/include/asm/domain.h
1528 @@ -48,18 +48,37 @@
1529 * Domain types
1530 */
1531 #define DOMAIN_NOACCESS 0
1532 -#define DOMAIN_CLIENT 1
1533 #ifdef CONFIG_CPU_USE_DOMAINS
1534 +#define DOMAIN_USERCLIENT 1
1535 +#define DOMAIN_KERNELCLIENT 1
1536 #define DOMAIN_MANAGER 3
1537 +#define DOMAIN_VECTORS DOMAIN_USER
1538 #else
1539 +
1540 +#ifdef CONFIG_PAX_KERNEXEC
1541 #define DOMAIN_MANAGER 1
1542 +#define DOMAIN_KERNEXEC 3
1543 +#else
1544 +#define DOMAIN_MANAGER 1
1545 +#endif
1546 +
1547 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1548 +#define DOMAIN_USERCLIENT 0
1549 +#define DOMAIN_UDEREF 1
1550 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1551 +#else
1552 +#define DOMAIN_USERCLIENT 1
1553 +#define DOMAIN_VECTORS DOMAIN_USER
1554 +#endif
1555 +#define DOMAIN_KERNELCLIENT 1
1556 +
1557 #endif
1558
1559 #define domain_val(dom,type) ((type) << (2*(dom)))
1560
1561 #ifndef __ASSEMBLY__
1562
1563 -#ifdef CONFIG_CPU_USE_DOMAINS
1564 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1565 static inline void set_domain(unsigned val)
1566 {
1567 asm volatile(
1568 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1569 isb();
1570 }
1571
1572 -#define modify_domain(dom,type) \
1573 - do { \
1574 - struct thread_info *thread = current_thread_info(); \
1575 - unsigned int domain = thread->cpu_domain; \
1576 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1577 - thread->cpu_domain = domain | domain_val(dom, type); \
1578 - set_domain(thread->cpu_domain); \
1579 - } while (0)
1580 -
1581 +extern void modify_domain(unsigned int dom, unsigned int type);
1582 #else
1583 static inline void set_domain(unsigned val) { }
1584 static inline void modify_domain(unsigned dom, unsigned type) { }
1585 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1586 index 38050b1..9d90e8b 100644
1587 --- a/arch/arm/include/asm/elf.h
1588 +++ b/arch/arm/include/asm/elf.h
1589 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1590 the loader. We need to make sure that it is out of the way of the program
1591 that it will "exec", and that there is sufficient room for the brk. */
1592
1593 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1594 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1595 +
1596 +#ifdef CONFIG_PAX_ASLR
1597 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1598 +
1599 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1600 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1601 +#endif
1602
1603 /* When the program starts, a1 contains a pointer to a function to be
1604 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1605 @@ -126,8 +133,4 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1606 extern void elf_set_personality(const struct elf32_hdr *);
1607 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1608
1609 -struct mm_struct;
1610 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1611 -#define arch_randomize_brk arch_randomize_brk
1612 -
1613 #endif
1614 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1615 index de53547..52b9a28 100644
1616 --- a/arch/arm/include/asm/fncpy.h
1617 +++ b/arch/arm/include/asm/fncpy.h
1618 @@ -81,7 +81,9 @@
1619 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1620 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1621 \
1622 + pax_open_kernel(); \
1623 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1624 + pax_close_kernel(); \
1625 flush_icache_range((unsigned long)(dest_buf), \
1626 (unsigned long)(dest_buf) + (size)); \
1627 \
1628 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1629 index e42cf59..7b94b8f 100644
1630 --- a/arch/arm/include/asm/futex.h
1631 +++ b/arch/arm/include/asm/futex.h
1632 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1633 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1634 return -EFAULT;
1635
1636 + pax_open_userland();
1637 +
1638 smp_mb();
1639 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1640 "1: ldrex %1, [%4]\n"
1641 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1642 : "cc", "memory");
1643 smp_mb();
1644
1645 + pax_close_userland();
1646 +
1647 *uval = val;
1648 return ret;
1649 }
1650 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1651 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1652 return -EFAULT;
1653
1654 + pax_open_userland();
1655 +
1656 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1657 "1: " TUSER(ldr) " %1, [%4]\n"
1658 " teq %1, %2\n"
1659 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1660 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1661 : "cc", "memory");
1662
1663 + pax_close_userland();
1664 +
1665 *uval = val;
1666 return ret;
1667 }
1668 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1669 return -EFAULT;
1670
1671 pagefault_disable(); /* implies preempt_disable() */
1672 + pax_open_userland();
1673
1674 switch (op) {
1675 case FUTEX_OP_SET:
1676 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1677 ret = -ENOSYS;
1678 }
1679
1680 + pax_close_userland();
1681 pagefault_enable(); /* subsumes preempt_enable() */
1682
1683 if (!ret) {
1684 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1685 index 83eb2f7..ed77159 100644
1686 --- a/arch/arm/include/asm/kmap_types.h
1687 +++ b/arch/arm/include/asm/kmap_types.h
1688 @@ -4,6 +4,6 @@
1689 /*
1690 * This is the "bare minimum". AIO seems to require this.
1691 */
1692 -#define KM_TYPE_NR 16
1693 +#define KM_TYPE_NR 17
1694
1695 #endif
1696 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1697 index 9e614a1..3302cca 100644
1698 --- a/arch/arm/include/asm/mach/dma.h
1699 +++ b/arch/arm/include/asm/mach/dma.h
1700 @@ -22,7 +22,7 @@ struct dma_ops {
1701 int (*residue)(unsigned int, dma_t *); /* optional */
1702 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1703 const char *type;
1704 -};
1705 +} __do_const;
1706
1707 struct dma_struct {
1708 void *addr; /* single DMA address */
1709 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1710 index 2fe141f..192dc01 100644
1711 --- a/arch/arm/include/asm/mach/map.h
1712 +++ b/arch/arm/include/asm/mach/map.h
1713 @@ -27,13 +27,16 @@ struct map_desc {
1714 #define MT_MINICLEAN 6
1715 #define MT_LOW_VECTORS 7
1716 #define MT_HIGH_VECTORS 8
1717 -#define MT_MEMORY 9
1718 +#define MT_MEMORY_RWX 9
1719 #define MT_ROM 10
1720 -#define MT_MEMORY_NONCACHED 11
1721 +#define MT_MEMORY_NONCACHED_RX 11
1722 #define MT_MEMORY_DTCM 12
1723 #define MT_MEMORY_ITCM 13
1724 #define MT_MEMORY_SO 14
1725 #define MT_MEMORY_DMA_READY 15
1726 +#define MT_MEMORY_RW 16
1727 +#define MT_MEMORY_RX 17
1728 +#define MT_MEMORY_NONCACHED_RW 18
1729
1730 #ifdef CONFIG_MMU
1731 extern void iotable_init(struct map_desc *, int);
1732 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1733 index 12f71a1..04e063c 100644
1734 --- a/arch/arm/include/asm/outercache.h
1735 +++ b/arch/arm/include/asm/outercache.h
1736 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1737 #endif
1738 void (*set_debug)(unsigned long);
1739 void (*resume)(void);
1740 -};
1741 +} __no_const;
1742
1743 #ifdef CONFIG_OUTER_CACHE
1744
1745 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1746 index 812a494..71fc0b6 100644
1747 --- a/arch/arm/include/asm/page.h
1748 +++ b/arch/arm/include/asm/page.h
1749 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1750 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1751 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1752 unsigned long vaddr, struct vm_area_struct *vma);
1753 -};
1754 +} __no_const;
1755
1756 #ifdef MULTI_USER
1757 extern struct cpu_user_fns cpu_user;
1758 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1759 index 943504f..c37a730 100644
1760 --- a/arch/arm/include/asm/pgalloc.h
1761 +++ b/arch/arm/include/asm/pgalloc.h
1762 @@ -17,6 +17,7 @@
1763 #include <asm/processor.h>
1764 #include <asm/cacheflush.h>
1765 #include <asm/tlbflush.h>
1766 +#include <asm/system_info.h>
1767
1768 #define check_pgt_cache() do { } while (0)
1769
1770 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1771 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1772 }
1773
1774 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1775 +{
1776 + pud_populate(mm, pud, pmd);
1777 +}
1778 +
1779 #else /* !CONFIG_ARM_LPAE */
1780
1781 /*
1782 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1783 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1784 #define pmd_free(mm, pmd) do { } while (0)
1785 #define pud_populate(mm,pmd,pte) BUG()
1786 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1787
1788 #endif /* CONFIG_ARM_LPAE */
1789
1790 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1791 __free_page(pte);
1792 }
1793
1794 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1795 +{
1796 +#ifdef CONFIG_ARM_LPAE
1797 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1798 +#else
1799 + if (addr & SECTION_SIZE)
1800 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1801 + else
1802 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1803 +#endif
1804 + flush_pmd_entry(pmdp);
1805 +}
1806 +
1807 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1808 pmdval_t prot)
1809 {
1810 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1811 static inline void
1812 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1813 {
1814 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1815 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1816 }
1817 #define pmd_pgtable(pmd) pmd_page(pmd)
1818
1819 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1820 index 5cfba15..f415e1a 100644
1821 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1822 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1823 @@ -20,12 +20,15 @@
1824 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1825 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1826 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1827 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1828 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1829 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1830 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1831 +
1832 /*
1833 * - section
1834 */
1835 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1836 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1837 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1838 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1839 @@ -37,6 +40,7 @@
1840 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1841 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1842 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1843 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1844
1845 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1846 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1847 @@ -66,6 +70,7 @@
1848 * - extended small page/tiny page
1849 */
1850 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1851 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1852 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1853 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1854 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1855 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1856 index f97ee02..07f1be5 100644
1857 --- a/arch/arm/include/asm/pgtable-2level.h
1858 +++ b/arch/arm/include/asm/pgtable-2level.h
1859 @@ -125,6 +125,7 @@
1860 #define L_PTE_XN (_AT(pteval_t, 1) << 9)
1861 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1862 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1863 +#define L_PTE_PXN (_AT(pteval_t, 1) << 12) /* v7*/
1864
1865 /*
1866 * These are the memory types, defined to be compatible with
1867 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1868 index 18f5cef..25b8f43 100644
1869 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1870 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1871 @@ -41,6 +41,7 @@
1872 */
1873 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1874 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1875 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)
1876 #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
1877 #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
1878 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
1879 @@ -71,6 +72,7 @@
1880 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1881 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1882 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1883 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1884 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1885
1886 /*
1887 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1888 index 86b8fe3..e25f975 100644
1889 --- a/arch/arm/include/asm/pgtable-3level.h
1890 +++ b/arch/arm/include/asm/pgtable-3level.h
1891 @@ -74,6 +74,7 @@
1892 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1893 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1894 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1895 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1896 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1897 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1898 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1899 @@ -82,6 +83,7 @@
1900 /*
1901 * To be used in assembly code with the upper page attributes.
1902 */
1903 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1904 #define L_PTE_XN_HIGH (1 << (54 - 32))
1905 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1906
1907 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1908 index 9bcd262..fba731c 100644
1909 --- a/arch/arm/include/asm/pgtable.h
1910 +++ b/arch/arm/include/asm/pgtable.h
1911 @@ -30,6 +30,9 @@
1912 #include <asm/pgtable-2level.h>
1913 #endif
1914
1915 +#define ktla_ktva(addr) (addr)
1916 +#define ktva_ktla(addr) (addr)
1917 +
1918 /*
1919 * Just any arbitrary offset to the start of the vmalloc VM area: the
1920 * current 8MB value just means that there will be a 8MB "hole" after the
1921 @@ -45,6 +48,9 @@
1922 #define LIBRARY_TEXT_START 0x0c000000
1923
1924 #ifndef __ASSEMBLY__
1925 +extern pteval_t __supported_pte_mask;
1926 +extern pmdval_t __supported_pmd_mask;
1927 +
1928 extern void __pte_error(const char *file, int line, pte_t);
1929 extern void __pmd_error(const char *file, int line, pmd_t);
1930 extern void __pgd_error(const char *file, int line, pgd_t);
1931 @@ -53,6 +59,50 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1932 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1933 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1934
1935 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1936 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
1937 +
1938 +#ifdef CONFIG_PAX_KERNEXEC
1939 +#include <asm/domain.h>
1940 +#include <linux/thread_info.h>
1941 +#include <linux/preempt.h>
1942 +#endif
1943 +
1944 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1945 +static inline int test_domain(int domain, int domaintype)
1946 +{
1947 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
1948 +}
1949 +#endif
1950 +
1951 +#ifdef CONFIG_PAX_KERNEXEC
1952 +static inline unsigned long pax_open_kernel(void) {
1953 +#ifdef CONFIG_ARM_LPAE
1954 + /* TODO */
1955 +#else
1956 + preempt_disable();
1957 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
1958 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
1959 +#endif
1960 + return 0;
1961 +}
1962 +
1963 +static inline unsigned long pax_close_kernel(void) {
1964 +#ifdef CONFIG_ARM_LPAE
1965 + /* TODO */
1966 +#else
1967 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
1968 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
1969 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
1970 + preempt_enable_no_resched();
1971 +#endif
1972 + return 0;
1973 +}
1974 +#else
1975 +static inline unsigned long pax_open_kernel(void) { return 0; }
1976 +static inline unsigned long pax_close_kernel(void) { return 0; }
1977 +#endif
1978 +
1979 /*
1980 * This is the lowest virtual address we can permit any user space
1981 * mapping to be mapped at. This is particularly important for
1982 @@ -72,8 +122,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1983 /*
1984 * The pgprot_* and protection_map entries will be fixed up in runtime
1985 * to include the cachable and bufferable bits based on memory policy,
1986 - * as well as any architecture dependent bits like global/ASID and SMP
1987 - * shared mapping bits.
1988 + * as well as any architecture dependent bits like global/ASID, PXN,
1989 + * and SMP shared mapping bits.
1990 */
1991 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
1992
1993 @@ -257,7 +307,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
1994 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
1995 {
1996 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
1997 - L_PTE_NONE | L_PTE_VALID;
1998 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
1999 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2000 return pte;
2001 }
2002 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2003 index f3628fb..a0672dd 100644
2004 --- a/arch/arm/include/asm/proc-fns.h
2005 +++ b/arch/arm/include/asm/proc-fns.h
2006 @@ -75,7 +75,7 @@ extern struct processor {
2007 unsigned int suspend_size;
2008 void (*do_suspend)(void *);
2009 void (*do_resume)(void *);
2010 -} processor;
2011 +} __do_const processor;
2012
2013 #ifndef MULTI_CPU
2014 extern void cpu_proc_init(void);
2015 diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
2016 index 06e7d50..8a8e251 100644
2017 --- a/arch/arm/include/asm/processor.h
2018 +++ b/arch/arm/include/asm/processor.h
2019 @@ -65,9 +65,8 @@ struct thread_struct {
2020 regs->ARM_cpsr |= PSR_ENDSTATE; \
2021 regs->ARM_pc = pc & ~1; /* pc */ \
2022 regs->ARM_sp = sp; /* sp */ \
2023 - regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
2024 - regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
2025 - regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
2026 + /* r2 (envp), r1 (argv), r0 (argc) */ \
2027 + (void)copy_from_user(&regs->ARM_r0, (const char __user *)stack, 3 * sizeof(unsigned long)); \
2028 nommu_start_thread(regs); \
2029 })
2030
2031 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2032 index ce0dbe7..c085b6f 100644
2033 --- a/arch/arm/include/asm/psci.h
2034 +++ b/arch/arm/include/asm/psci.h
2035 @@ -29,7 +29,7 @@ struct psci_operations {
2036 int (*cpu_off)(struct psci_power_state state);
2037 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2038 int (*migrate)(unsigned long cpuid);
2039 -};
2040 +} __no_const;
2041
2042 extern struct psci_operations psci_ops;
2043
2044 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2045 index d3a22be..3a69ad5 100644
2046 --- a/arch/arm/include/asm/smp.h
2047 +++ b/arch/arm/include/asm/smp.h
2048 @@ -107,7 +107,7 @@ struct smp_operations {
2049 int (*cpu_disable)(unsigned int cpu);
2050 #endif
2051 #endif
2052 -};
2053 +} __no_const;
2054
2055 /*
2056 * set platform specific SMP operations
2057 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2058 index cddda1f..ff357f7 100644
2059 --- a/arch/arm/include/asm/thread_info.h
2060 +++ b/arch/arm/include/asm/thread_info.h
2061 @@ -77,9 +77,9 @@ struct thread_info {
2062 .flags = 0, \
2063 .preempt_count = INIT_PREEMPT_COUNT, \
2064 .addr_limit = KERNEL_DS, \
2065 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2066 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2067 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2068 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2069 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2070 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2071 .restart_block = { \
2072 .fn = do_no_restart_syscall, \
2073 }, \
2074 @@ -152,6 +152,12 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2075 #define TIF_SYSCALL_AUDIT 9
2076 #define TIF_SYSCALL_TRACEPOINT 10
2077 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2078 +
2079 +/* within 8 bits of TIF_SYSCALL_TRACE
2080 + * to meet flexible second operand requirements
2081 + */
2082 +#define TIF_GRSEC_SETXID 12
2083 +
2084 #define TIF_USING_IWMMXT 17
2085 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2086 #define TIF_RESTORE_SIGMASK 20
2087 @@ -165,10 +171,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2088 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2089 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2090 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2091 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2092
2093 /* Checks for any syscall work in entry-common.S */
2094 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2095 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2096 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2097
2098 /*
2099 * Change these and you break ASM code in entry-common.S
2100 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2101 index 7e1f760..752fcb7 100644
2102 --- a/arch/arm/include/asm/uaccess.h
2103 +++ b/arch/arm/include/asm/uaccess.h
2104 @@ -18,6 +18,7 @@
2105 #include <asm/domain.h>
2106 #include <asm/unified.h>
2107 #include <asm/compiler.h>
2108 +#include <asm/pgtable.h>
2109
2110 #define VERIFY_READ 0
2111 #define VERIFY_WRITE 1
2112 @@ -60,10 +61,34 @@ extern int __put_user_bad(void);
2113 #define USER_DS TASK_SIZE
2114 #define get_fs() (current_thread_info()->addr_limit)
2115
2116 +static inline void pax_open_userland(void)
2117 +{
2118 +
2119 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2120 + if (get_fs() == USER_DS) {
2121 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2122 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2123 + }
2124 +#endif
2125 +
2126 +}
2127 +
2128 +static inline void pax_close_userland(void)
2129 +{
2130 +
2131 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2132 + if (get_fs() == USER_DS) {
2133 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2134 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2135 + }
2136 +#endif
2137 +
2138 +}
2139 +
2140 static inline void set_fs(mm_segment_t fs)
2141 {
2142 current_thread_info()->addr_limit = fs;
2143 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2144 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2145 }
2146
2147 #define segment_eq(a,b) ((a) == (b))
2148 @@ -143,8 +168,12 @@ extern int __get_user_4(void *);
2149
2150 #define get_user(x,p) \
2151 ({ \
2152 + int __e; \
2153 might_fault(); \
2154 - __get_user_check(x,p); \
2155 + pax_open_userland(); \
2156 + __e = __get_user_check(x,p); \
2157 + pax_close_userland(); \
2158 + __e; \
2159 })
2160
2161 extern int __put_user_1(void *, unsigned int);
2162 @@ -188,8 +217,12 @@ extern int __put_user_8(void *, unsigned long long);
2163
2164 #define put_user(x,p) \
2165 ({ \
2166 + int __e; \
2167 might_fault(); \
2168 - __put_user_check(x,p); \
2169 + pax_open_userland(); \
2170 + __e = __put_user_check(x,p); \
2171 + pax_close_userland(); \
2172 + __e; \
2173 })
2174
2175 #else /* CONFIG_MMU */
2176 @@ -230,13 +263,17 @@ static inline void set_fs(mm_segment_t fs)
2177 #define __get_user(x,ptr) \
2178 ({ \
2179 long __gu_err = 0; \
2180 + pax_open_userland(); \
2181 __get_user_err((x),(ptr),__gu_err); \
2182 + pax_close_userland(); \
2183 __gu_err; \
2184 })
2185
2186 #define __get_user_error(x,ptr,err) \
2187 ({ \
2188 + pax_open_userland(); \
2189 __get_user_err((x),(ptr),err); \
2190 + pax_close_userland(); \
2191 (void) 0; \
2192 })
2193
2194 @@ -312,13 +349,17 @@ do { \
2195 #define __put_user(x,ptr) \
2196 ({ \
2197 long __pu_err = 0; \
2198 + pax_open_userland(); \
2199 __put_user_err((x),(ptr),__pu_err); \
2200 + pax_close_userland(); \
2201 __pu_err; \
2202 })
2203
2204 #define __put_user_error(x,ptr,err) \
2205 ({ \
2206 + pax_open_userland(); \
2207 __put_user_err((x),(ptr),err); \
2208 + pax_close_userland(); \
2209 (void) 0; \
2210 })
2211
2212 @@ -418,11 +459,44 @@ do { \
2213
2214
2215 #ifdef CONFIG_MMU
2216 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2217 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2218 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2219 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2220 +
2221 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2222 +{
2223 + unsigned long ret;
2224 +
2225 + check_object_size(to, n, false);
2226 + pax_open_userland();
2227 + ret = ___copy_from_user(to, from, n);
2228 + pax_close_userland();
2229 + return ret;
2230 +}
2231 +
2232 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2233 +{
2234 + unsigned long ret;
2235 +
2236 + check_object_size(from, n, true);
2237 + pax_open_userland();
2238 + ret = ___copy_to_user(to, from, n);
2239 + pax_close_userland();
2240 + return ret;
2241 +}
2242 +
2243 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2244 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2245 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2246 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2247 +
2248 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2249 +{
2250 + unsigned long ret;
2251 + pax_open_userland();
2252 + ret = ___clear_user(addr, n);
2253 + pax_close_userland();
2254 + return ret;
2255 +}
2256 +
2257 #else
2258 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2259 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2260 @@ -431,6 +505,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2261
2262 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2263 {
2264 + if ((long)n < 0)
2265 + return n;
2266 +
2267 if (access_ok(VERIFY_READ, from, n))
2268 n = __copy_from_user(to, from, n);
2269 else /* security hole - plug it */
2270 @@ -440,6 +517,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2271
2272 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2273 {
2274 + if ((long)n < 0)
2275 + return n;
2276 +
2277 if (access_ok(VERIFY_WRITE, to, n))
2278 n = __copy_to_user(to, from, n);
2279 return n;
2280 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2281 index 96ee092..37f1844 100644
2282 --- a/arch/arm/include/uapi/asm/ptrace.h
2283 +++ b/arch/arm/include/uapi/asm/ptrace.h
2284 @@ -73,7 +73,7 @@
2285 * ARMv7 groups of PSR bits
2286 */
2287 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2288 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2289 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2290 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2291 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2292
2293 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2294 index 60d3b73..d27ee09 100644
2295 --- a/arch/arm/kernel/armksyms.c
2296 +++ b/arch/arm/kernel/armksyms.c
2297 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2298 #ifdef CONFIG_MMU
2299 EXPORT_SYMBOL(copy_page);
2300
2301 -EXPORT_SYMBOL(__copy_from_user);
2302 -EXPORT_SYMBOL(__copy_to_user);
2303 -EXPORT_SYMBOL(__clear_user);
2304 +EXPORT_SYMBOL(___copy_from_user);
2305 +EXPORT_SYMBOL(___copy_to_user);
2306 +EXPORT_SYMBOL(___clear_user);
2307
2308 EXPORT_SYMBOL(__get_user_1);
2309 EXPORT_SYMBOL(__get_user_2);
2310 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2311 index 0f82098..3dbd3ee 100644
2312 --- a/arch/arm/kernel/entry-armv.S
2313 +++ b/arch/arm/kernel/entry-armv.S
2314 @@ -47,6 +47,87 @@
2315 9997:
2316 .endm
2317
2318 + .macro pax_enter_kernel
2319 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2320 + @ make aligned space for saved DACR
2321 + sub sp, sp, #8
2322 + @ save regs
2323 + stmdb sp!, {r1, r2}
2324 + @ read DACR from cpu_domain into r1
2325 + mov r2, sp
2326 + @ assume 8K pages, since we have to split the immediate in two
2327 + bic r2, r2, #(0x1fc0)
2328 + bic r2, r2, #(0x3f)
2329 + ldr r1, [r2, #TI_CPU_DOMAIN]
2330 + @ store old DACR on stack
2331 + str r1, [sp, #8]
2332 +#ifdef CONFIG_PAX_KERNEXEC
2333 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2334 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2335 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2336 +#endif
2337 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2338 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2339 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2340 +#endif
2341 + @ write r1 to current_thread_info()->cpu_domain
2342 + str r1, [r2, #TI_CPU_DOMAIN]
2343 + @ write r1 to DACR
2344 + mcr p15, 0, r1, c3, c0, 0
2345 + @ instruction sync
2346 + instr_sync
2347 + @ restore regs
2348 + ldmia sp!, {r1, r2}
2349 +#endif
2350 + .endm
2351 +
2352 + .macro pax_open_userland
2353 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2354 + @ save regs
2355 + stmdb sp!, {r0, r1}
2356 + @ read DACR from cpu_domain into r1
2357 + mov r0, sp
2358 + @ assume 8K pages, since we have to split the immediate in two
2359 + bic r0, r0, #(0x1fc0)
2360 + bic r0, r0, #(0x3f)
2361 + ldr r1, [r0, #TI_CPU_DOMAIN]
2362 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2363 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2364 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2365 + @ write r1 to current_thread_info()->cpu_domain
2366 + str r1, [r0, #TI_CPU_DOMAIN]
2367 + @ write r1 to DACR
2368 + mcr p15, 0, r1, c3, c0, 0
2369 + @ instruction sync
2370 + instr_sync
2371 + @ restore regs
2372 + ldmia sp!, {r0, r1}
2373 +#endif
2374 + .endm
2375 +
2376 + .macro pax_close_userland
2377 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2378 + @ save regs
2379 + stmdb sp!, {r0, r1}
2380 + @ read DACR from cpu_domain into r1
2381 + mov r0, sp
2382 + @ assume 8K pages, since we have to split the immediate in two
2383 + bic r0, r0, #(0x1fc0)
2384 + bic r0, r0, #(0x3f)
2385 + ldr r1, [r0, #TI_CPU_DOMAIN]
2386 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2387 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2388 + @ write r1 to current_thread_info()->cpu_domain
2389 + str r1, [r0, #TI_CPU_DOMAIN]
2390 + @ write r1 to DACR
2391 + mcr p15, 0, r1, c3, c0, 0
2392 + @ instruction sync
2393 + instr_sync
2394 + @ restore regs
2395 + ldmia sp!, {r0, r1}
2396 +#endif
2397 + .endm
2398 +
2399 .macro pabt_helper
2400 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2401 #ifdef MULTI_PABORT
2402 @@ -89,11 +170,15 @@
2403 * Invalid mode handlers
2404 */
2405 .macro inv_entry, reason
2406 +
2407 + pax_enter_kernel
2408 +
2409 sub sp, sp, #S_FRAME_SIZE
2410 ARM( stmib sp, {r1 - lr} )
2411 THUMB( stmia sp, {r0 - r12} )
2412 THUMB( str sp, [sp, #S_SP] )
2413 THUMB( str lr, [sp, #S_LR] )
2414 +
2415 mov r1, #\reason
2416 .endm
2417
2418 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2419 .macro svc_entry, stack_hole=0
2420 UNWIND(.fnstart )
2421 UNWIND(.save {r0 - pc} )
2422 +
2423 + pax_enter_kernel
2424 +
2425 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2426 +
2427 #ifdef CONFIG_THUMB2_KERNEL
2428 SPFIX( str r0, [sp] ) @ temporarily saved
2429 SPFIX( mov r0, sp )
2430 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2431 ldmia r0, {r3 - r5}
2432 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2433 mov r6, #-1 @ "" "" "" ""
2434 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2435 + @ offset sp by 8 as done in pax_enter_kernel
2436 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2437 +#else
2438 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2439 +#endif
2440 SPFIX( addeq r2, r2, #4 )
2441 str r3, [sp, #-4]! @ save the "real" r0 copied
2442 @ from the exception stack
2443 @@ -359,6 +453,9 @@ ENDPROC(__pabt_svc)
2444 .macro usr_entry
2445 UNWIND(.fnstart )
2446 UNWIND(.cantunwind ) @ don't unwind the user space
2447 +
2448 + pax_enter_kernel_user
2449 +
2450 sub sp, sp, #S_FRAME_SIZE
2451 ARM( stmib sp, {r1 - r12} )
2452 THUMB( stmia sp, {r0 - r12} )
2453 @@ -456,7 +553,9 @@ __und_usr:
2454 tst r3, #PSR_T_BIT @ Thumb mode?
2455 bne __und_usr_thumb
2456 sub r4, r2, #4 @ ARM instr at LR - 4
2457 + pax_open_userland
2458 1: ldrt r0, [r4]
2459 + pax_close_userland
2460 #ifdef CONFIG_CPU_ENDIAN_BE8
2461 rev r0, r0 @ little endian instruction
2462 #endif
2463 @@ -491,10 +590,14 @@ __und_usr_thumb:
2464 */
2465 .arch armv6t2
2466 #endif
2467 + pax_open_userland
2468 2: ldrht r5, [r4]
2469 + pax_close_userland
2470 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2471 blo __und_usr_fault_16 @ 16bit undefined instruction
2472 + pax_open_userland
2473 3: ldrht r0, [r2]
2474 + pax_close_userland
2475 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2476 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2477 orr r0, r0, r5, lsl #16
2478 @@ -733,7 +836,7 @@ ENTRY(__switch_to)
2479 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2480 THUMB( str sp, [ip], #4 )
2481 THUMB( str lr, [ip], #4 )
2482 -#ifdef CONFIG_CPU_USE_DOMAINS
2483 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2484 ldr r6, [r2, #TI_CPU_DOMAIN]
2485 #endif
2486 set_tls r3, r4, r5
2487 @@ -742,7 +845,7 @@ ENTRY(__switch_to)
2488 ldr r8, =__stack_chk_guard
2489 ldr r7, [r7, #TSK_STACK_CANARY]
2490 #endif
2491 -#ifdef CONFIG_CPU_USE_DOMAINS
2492 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2493 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2494 #endif
2495 mov r5, r0
2496 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2497 index fefd7f9..e6f250e 100644
2498 --- a/arch/arm/kernel/entry-common.S
2499 +++ b/arch/arm/kernel/entry-common.S
2500 @@ -10,18 +10,46 @@
2501
2502 #include <asm/unistd.h>
2503 #include <asm/ftrace.h>
2504 +#include <asm/domain.h>
2505 #include <asm/unwind.h>
2506
2507 +#include "entry-header.S"
2508 +
2509 #ifdef CONFIG_NEED_RET_TO_USER
2510 #include <mach/entry-macro.S>
2511 #else
2512 .macro arch_ret_to_user, tmp1, tmp2
2513 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2514 + @ save regs
2515 + stmdb sp!, {r1, r2}
2516 + @ read DACR from cpu_domain into r1
2517 + mov r2, sp
2518 + @ assume 8K pages, since we have to split the immediate in two
2519 + bic r2, r2, #(0x1fc0)
2520 + bic r2, r2, #(0x3f)
2521 + ldr r1, [r2, #TI_CPU_DOMAIN]
2522 +#ifdef CONFIG_PAX_KERNEXEC
2523 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2524 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2525 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2526 +#endif
2527 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2528 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2529 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2530 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2531 +#endif
2532 + @ write r1 to current_thread_info()->cpu_domain
2533 + str r1, [r2, #TI_CPU_DOMAIN]
2534 + @ write r1 to DACR
2535 + mcr p15, 0, r1, c3, c0, 0
2536 + @ instruction sync
2537 + instr_sync
2538 + @ restore regs
2539 + ldmia sp!, {r1, r2}
2540 +#endif
2541 .endm
2542 #endif
2543
2544 -#include "entry-header.S"
2545 -
2546 -
2547 .align 5
2548 /*
2549 * This is the fast syscall return path. We do as little as
2550 @@ -351,6 +379,7 @@ ENDPROC(ftrace_stub)
2551
2552 .align 5
2553 ENTRY(vector_swi)
2554 +
2555 sub sp, sp, #S_FRAME_SIZE
2556 stmia sp, {r0 - r12} @ Calling r0 - r12
2557 ARM( add r8, sp, #S_PC )
2558 @@ -400,6 +429,12 @@ ENTRY(vector_swi)
2559 ldr scno, [lr, #-4] @ get SWI instruction
2560 #endif
2561
2562 + /*
2563 + * do this here to avoid a performance hit of wrapping the code above
2564 + * that directly dereferences userland to parse the SWI instruction
2565 + */
2566 + pax_enter_kernel_user
2567 +
2568 #ifdef CONFIG_ALIGNMENT_TRAP
2569 ldr ip, __cr_alignment
2570 ldr ip, [ip]
2571 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2572 index 9a8531e..812e287 100644
2573 --- a/arch/arm/kernel/entry-header.S
2574 +++ b/arch/arm/kernel/entry-header.S
2575 @@ -73,9 +73,66 @@
2576 msr cpsr_c, \rtemp @ switch back to the SVC mode
2577 .endm
2578
2579 + .macro pax_enter_kernel_user
2580 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2581 + @ save regs
2582 + stmdb sp!, {r0, r1}
2583 + @ read DACR from cpu_domain into r1
2584 + mov r0, sp
2585 + @ assume 8K pages, since we have to split the immediate in two
2586 + bic r0, r0, #(0x1fc0)
2587 + bic r0, r0, #(0x3f)
2588 + ldr r1, [r0, #TI_CPU_DOMAIN]
2589 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2590 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2591 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2592 +#endif
2593 +#ifdef CONFIG_PAX_KERNEXEC
2594 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2595 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2596 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2597 +#endif
2598 + @ write r1 to current_thread_info()->cpu_domain
2599 + str r1, [r0, #TI_CPU_DOMAIN]
2600 + @ write r1 to DACR
2601 + mcr p15, 0, r1, c3, c0, 0
2602 + @ instruction sync
2603 + instr_sync
2604 + @ restore regs
2605 + ldmia sp!, {r0, r1}
2606 +#endif
2607 + .endm
2608 +
2609 + .macro pax_exit_kernel
2610 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2611 + @ save regs
2612 + stmdb sp!, {r0, r1}
2613 + @ read old DACR from stack into r1
2614 + ldr r1, [sp, #(8 + S_SP)]
2615 + sub r1, r1, #8
2616 + ldr r1, [r1]
2617 +
2618 + @ write r1 to current_thread_info()->cpu_domain
2619 + mov r0, sp
2620 + @ assume 8K pages, since we have to split the immediate in two
2621 + bic r0, r0, #(0x1fc0)
2622 + bic r0, r0, #(0x3f)
2623 + str r1, [r0, #TI_CPU_DOMAIN]
2624 + @ write r1 to DACR
2625 + mcr p15, 0, r1, c3, c0, 0
2626 + @ instruction sync
2627 + instr_sync
2628 + @ restore regs
2629 + ldmia sp!, {r0, r1}
2630 +#endif
2631 + .endm
2632 +
2633 #ifndef CONFIG_THUMB2_KERNEL
2634 .macro svc_exit, rpsr
2635 msr spsr_cxsf, \rpsr
2636 +
2637 + pax_exit_kernel
2638 +
2639 #if defined(CONFIG_CPU_V6)
2640 ldr r0, [sp]
2641 strex r1, r2, [sp] @ clear the exclusive monitor
2642 @@ -121,6 +178,9 @@
2643 .endm
2644 #else /* CONFIG_THUMB2_KERNEL */
2645 .macro svc_exit, rpsr
2646 +
2647 + pax_exit_kernel
2648 +
2649 ldr lr, [sp, #S_SP] @ top of the stack
2650 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2651 clrex @ clear the exclusive monitor
2652 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2653 index 2adda11..7fbe958 100644
2654 --- a/arch/arm/kernel/fiq.c
2655 +++ b/arch/arm/kernel/fiq.c
2656 @@ -82,7 +82,9 @@ void set_fiq_handler(void *start, unsigned int length)
2657 #if defined(CONFIG_CPU_USE_DOMAINS)
2658 memcpy((void *)0xffff001c, start, length);
2659 #else
2660 + pax_open_kernel();
2661 memcpy(vectors_page + 0x1c, start, length);
2662 + pax_close_kernel();
2663 #endif
2664 flush_icache_range(0xffff001c, 0xffff001c + length);
2665 if (!vectors_high())
2666 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2667 index 8bac553..caee108 100644
2668 --- a/arch/arm/kernel/head.S
2669 +++ b/arch/arm/kernel/head.S
2670 @@ -52,7 +52,9 @@
2671 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2672
2673 .macro pgtbl, rd, phys
2674 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2675 + mov \rd, #TEXT_OFFSET
2676 + sub \rd, #PG_DIR_SIZE
2677 + add \rd, \rd, \phys
2678 .endm
2679
2680 /*
2681 @@ -434,7 +436,7 @@ __enable_mmu:
2682 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2683 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2684 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2685 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2686 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2687 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2688 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2689 #endif
2690 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2691 index 1fd749e..47adb08 100644
2692 --- a/arch/arm/kernel/hw_breakpoint.c
2693 +++ b/arch/arm/kernel/hw_breakpoint.c
2694 @@ -1029,7 +1029,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2695 return NOTIFY_OK;
2696 }
2697
2698 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2699 +static struct notifier_block dbg_reset_nb = {
2700 .notifier_call = dbg_reset_notify,
2701 };
2702
2703 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2704 index 1e9be5d..03edbc2 100644
2705 --- a/arch/arm/kernel/module.c
2706 +++ b/arch/arm/kernel/module.c
2707 @@ -37,12 +37,37 @@
2708 #endif
2709
2710 #ifdef CONFIG_MMU
2711 -void *module_alloc(unsigned long size)
2712 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2713 {
2714 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2715 + return NULL;
2716 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2717 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2718 + GFP_KERNEL, prot, -1,
2719 __builtin_return_address(0));
2720 }
2721 +
2722 +void *module_alloc(unsigned long size)
2723 +{
2724 +
2725 +#ifdef CONFIG_PAX_KERNEXEC
2726 + return __module_alloc(size, PAGE_KERNEL);
2727 +#else
2728 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2729 +#endif
2730 +
2731 +}
2732 +
2733 +#ifdef CONFIG_PAX_KERNEXEC
2734 +void module_free_exec(struct module *mod, void *module_region)
2735 +{
2736 + module_free(mod, module_region);
2737 +}
2738 +
2739 +void *module_alloc_exec(unsigned long size)
2740 +{
2741 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2742 +}
2743 +#endif
2744 #endif
2745
2746 int
2747 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2748 index 07314af..c46655c 100644
2749 --- a/arch/arm/kernel/patch.c
2750 +++ b/arch/arm/kernel/patch.c
2751 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2752 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2753 int size;
2754
2755 + pax_open_kernel();
2756 if (thumb2 && __opcode_is_thumb16(insn)) {
2757 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2758 size = sizeof(u16);
2759 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2760 *(u32 *)addr = insn;
2761 size = sizeof(u32);
2762 }
2763 + pax_close_kernel();
2764
2765 flush_icache_range((uintptr_t)(addr),
2766 (uintptr_t)(addr) + size);
2767 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2768 index 1f2740e..b36e225 100644
2769 --- a/arch/arm/kernel/perf_event_cpu.c
2770 +++ b/arch/arm/kernel/perf_event_cpu.c
2771 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2772 return NOTIFY_OK;
2773 }
2774
2775 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2776 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2777 .notifier_call = cpu_pmu_notify,
2778 };
2779
2780 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2781 index 047d3e4..7e96107 100644
2782 --- a/arch/arm/kernel/process.c
2783 +++ b/arch/arm/kernel/process.c
2784 @@ -28,7 +28,6 @@
2785 #include <linux/tick.h>
2786 #include <linux/utsname.h>
2787 #include <linux/uaccess.h>
2788 -#include <linux/random.h>
2789 #include <linux/hw_breakpoint.h>
2790 #include <linux/cpuidle.h>
2791 #include <linux/leds.h>
2792 @@ -251,9 +250,10 @@ void machine_power_off(void)
2793 machine_shutdown();
2794 if (pm_power_off)
2795 pm_power_off();
2796 + BUG();
2797 }
2798
2799 -void machine_restart(char *cmd)
2800 +__noreturn void machine_restart(char *cmd)
2801 {
2802 machine_shutdown();
2803
2804 @@ -278,8 +278,8 @@ void __show_regs(struct pt_regs *regs)
2805 init_utsname()->release,
2806 (int)strcspn(init_utsname()->version, " "),
2807 init_utsname()->version);
2808 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2809 - print_symbol("LR is at %s\n", regs->ARM_lr);
2810 + printk("PC is at %pA\n", instruction_pointer(regs));
2811 + printk("LR is at %pA\n", regs->ARM_lr);
2812 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2813 "sp : %08lx ip : %08lx fp : %08lx\n",
2814 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2815 @@ -447,12 +447,6 @@ unsigned long get_wchan(struct task_struct *p)
2816 return 0;
2817 }
2818
2819 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2820 -{
2821 - unsigned long range_end = mm->brk + 0x02000000;
2822 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2823 -}
2824 -
2825 #ifdef CONFIG_MMU
2826 /*
2827 * The vectors page is always readable from user space for the
2828 @@ -465,9 +459,8 @@ static int __init gate_vma_init(void)
2829 {
2830 gate_vma.vm_start = 0xffff0000;
2831 gate_vma.vm_end = 0xffff0000 + PAGE_SIZE;
2832 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2833 - gate_vma.vm_flags = VM_READ | VM_EXEC |
2834 - VM_MAYREAD | VM_MAYEXEC;
2835 + gate_vma.vm_flags = VM_NONE;
2836 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2837 return 0;
2838 }
2839 arch_initcall(gate_vma_init);
2840 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2841 index 3653164..d83e55d 100644
2842 --- a/arch/arm/kernel/psci.c
2843 +++ b/arch/arm/kernel/psci.c
2844 @@ -24,7 +24,7 @@
2845 #include <asm/opcodes-virt.h>
2846 #include <asm/psci.h>
2847
2848 -struct psci_operations psci_ops;
2849 +struct psci_operations psci_ops __read_only;
2850
2851 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2852
2853 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2854 index 03deeff..741ce88 100644
2855 --- a/arch/arm/kernel/ptrace.c
2856 +++ b/arch/arm/kernel/ptrace.c
2857 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2858 return current_thread_info()->syscall;
2859 }
2860
2861 +#ifdef CONFIG_GRKERNSEC_SETXID
2862 +extern void gr_delayed_cred_worker(void);
2863 +#endif
2864 +
2865 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2866 {
2867 current_thread_info()->syscall = scno;
2868
2869 +#ifdef CONFIG_GRKERNSEC_SETXID
2870 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2871 + gr_delayed_cred_worker();
2872 +#endif
2873 +
2874 /* Do the secure computing check first; failures should be fast. */
2875 if (secure_computing(scno) == -1)
2876 return -1;
2877 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2878 index 234e339..81264a1 100644
2879 --- a/arch/arm/kernel/setup.c
2880 +++ b/arch/arm/kernel/setup.c
2881 @@ -96,21 +96,23 @@ EXPORT_SYMBOL(system_serial_high);
2882 unsigned int elf_hwcap __read_mostly;
2883 EXPORT_SYMBOL(elf_hwcap);
2884
2885 +pteval_t __supported_pte_mask __read_only;
2886 +pmdval_t __supported_pmd_mask __read_only;
2887
2888 #ifdef MULTI_CPU
2889 -struct processor processor __read_mostly;
2890 +struct processor processor;
2891 #endif
2892 #ifdef MULTI_TLB
2893 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2894 +struct cpu_tlb_fns cpu_tlb __read_only;
2895 #endif
2896 #ifdef MULTI_USER
2897 -struct cpu_user_fns cpu_user __read_mostly;
2898 +struct cpu_user_fns cpu_user __read_only;
2899 #endif
2900 #ifdef MULTI_CACHE
2901 -struct cpu_cache_fns cpu_cache __read_mostly;
2902 +struct cpu_cache_fns cpu_cache __read_only;
2903 #endif
2904 #ifdef CONFIG_OUTER_CACHE
2905 -struct outer_cache_fns outer_cache __read_mostly;
2906 +struct outer_cache_fns outer_cache __read_only;
2907 EXPORT_SYMBOL(outer_cache);
2908 #endif
2909
2910 @@ -235,9 +237,13 @@ static int __get_cpu_architecture(void)
2911 asm("mrc p15, 0, %0, c0, c1, 4"
2912 : "=r" (mmfr0));
2913 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2914 - (mmfr0 & 0x000000f0) >= 0x00000030)
2915 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2916 cpu_arch = CPU_ARCH_ARMv7;
2917 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2918 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2919 + __supported_pte_mask |= L_PTE_PXN;
2920 + __supported_pmd_mask |= PMD_PXNTABLE;
2921 + }
2922 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2923 (mmfr0 & 0x000000f0) == 0x00000020)
2924 cpu_arch = CPU_ARCH_ARMv6;
2925 else
2926 @@ -478,7 +484,7 @@ static void __init setup_processor(void)
2927 __cpu_architecture = __get_cpu_architecture();
2928
2929 #ifdef MULTI_CPU
2930 - processor = *list->proc;
2931 + memcpy((void *)&processor, list->proc, sizeof processor);
2932 #endif
2933 #ifdef MULTI_TLB
2934 cpu_tlb = *list->tlb;
2935 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
2936 index 296786b..a8d4dd5 100644
2937 --- a/arch/arm/kernel/signal.c
2938 +++ b/arch/arm/kernel/signal.c
2939 @@ -396,22 +396,14 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
2940 __put_user(sigreturn_codes[idx+1], rc+1))
2941 return 1;
2942
2943 - if (cpsr & MODE32_BIT) {
2944 - /*
2945 - * 32-bit code can use the new high-page
2946 - * signal return code support.
2947 - */
2948 - retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
2949 - } else {
2950 - /*
2951 - * Ensure that the instruction cache sees
2952 - * the return code written onto the stack.
2953 - */
2954 - flush_icache_range((unsigned long)rc,
2955 - (unsigned long)(rc + 2));
2956 + /*
2957 + * Ensure that the instruction cache sees
2958 + * the return code written onto the stack.
2959 + */
2960 + flush_icache_range((unsigned long)rc,
2961 + (unsigned long)(rc + 2));
2962
2963 - retcode = ((unsigned long)rc) + thumb;
2964 - }
2965 + retcode = ((unsigned long)rc) + thumb;
2966 }
2967
2968 regs->ARM_r0 = map_sig(ksig->sig);
2969 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
2970 index 1f2cccc..f40c02e 100644
2971 --- a/arch/arm/kernel/smp.c
2972 +++ b/arch/arm/kernel/smp.c
2973 @@ -70,7 +70,7 @@ enum ipi_msg_type {
2974
2975 static DECLARE_COMPLETION(cpu_running);
2976
2977 -static struct smp_operations smp_ops;
2978 +static struct smp_operations smp_ops __read_only;
2979
2980 void __init smp_set_ops(struct smp_operations *ops)
2981 {
2982 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
2983 index 1c08911..264f009 100644
2984 --- a/arch/arm/kernel/traps.c
2985 +++ b/arch/arm/kernel/traps.c
2986 @@ -57,7 +57,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
2987 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
2988 {
2989 #ifdef CONFIG_KALLSYMS
2990 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
2991 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
2992 #else
2993 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
2994 #endif
2995 @@ -266,6 +266,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
2996 static int die_owner = -1;
2997 static unsigned int die_nest_count;
2998
2999 +extern void gr_handle_kernel_exploit(void);
3000 +
3001 static unsigned long oops_begin(void)
3002 {
3003 int cpu;
3004 @@ -308,6 +310,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3005 panic("Fatal exception in interrupt");
3006 if (panic_on_oops)
3007 panic("Fatal exception");
3008 +
3009 + gr_handle_kernel_exploit();
3010 +
3011 if (signr)
3012 do_exit(signr);
3013 }
3014 @@ -601,7 +606,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3015 * The user helper at 0xffff0fe0 must be used instead.
3016 * (see entry-armv.S for details)
3017 */
3018 + pax_open_kernel();
3019 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3020 + pax_close_kernel();
3021 }
3022 return 0;
3023
3024 @@ -841,13 +848,10 @@ void __init early_trap_init(void *vectors_base)
3025 */
3026 kuser_get_tls_init(vectors);
3027
3028 - /*
3029 - * Copy signal return handlers into the vector page, and
3030 - * set sigreturn to be a pointer to these.
3031 - */
3032 - memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
3033 - sigreturn_codes, sizeof(sigreturn_codes));
3034 -
3035 flush_icache_range(vectors, vectors + PAGE_SIZE);
3036 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3037 +
3038 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3039 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3040 +#endif
3041 +
3042 }
3043 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3044 index b571484..4b2fc9b 100644
3045 --- a/arch/arm/kernel/vmlinux.lds.S
3046 +++ b/arch/arm/kernel/vmlinux.lds.S
3047 @@ -8,7 +8,11 @@
3048 #include <asm/thread_info.h>
3049 #include <asm/memory.h>
3050 #include <asm/page.h>
3051 -
3052 +
3053 +#ifdef CONFIG_PAX_KERNEXEC
3054 +#include <asm/pgtable.h>
3055 +#endif
3056 +
3057 #define PROC_INFO \
3058 . = ALIGN(4); \
3059 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3060 @@ -94,6 +98,11 @@ SECTIONS
3061 _text = .;
3062 HEAD_TEXT
3063 }
3064 +
3065 +#ifdef CONFIG_PAX_KERNEXEC
3066 + . = ALIGN(1<<SECTION_SHIFT);
3067 +#endif
3068 +
3069 .text : { /* Real text segment */
3070 _stext = .; /* Text and read-only data */
3071 __exception_text_start = .;
3072 @@ -116,6 +125,8 @@ SECTIONS
3073 ARM_CPU_KEEP(PROC_INFO)
3074 }
3075
3076 + _etext = .; /* End of text section */
3077 +
3078 RO_DATA(PAGE_SIZE)
3079
3080 . = ALIGN(4);
3081 @@ -146,7 +157,9 @@ SECTIONS
3082
3083 NOTES
3084
3085 - _etext = .; /* End of text and rodata section */
3086 +#ifdef CONFIG_PAX_KERNEXEC
3087 + . = ALIGN(1<<SECTION_SHIFT);
3088 +#endif
3089
3090 #ifndef CONFIG_XIP_KERNEL
3091 . = ALIGN(PAGE_SIZE);
3092 @@ -207,6 +220,11 @@ SECTIONS
3093 . = PAGE_OFFSET + TEXT_OFFSET;
3094 #else
3095 __init_end = .;
3096 +
3097 +#ifdef CONFIG_PAX_KERNEXEC
3098 + . = ALIGN(1<<SECTION_SHIFT);
3099 +#endif
3100 +
3101 . = ALIGN(THREAD_SIZE);
3102 __data_loc = .;
3103 #endif
3104 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3105 index 14a0d98..7771a7d 100644
3106 --- a/arch/arm/lib/clear_user.S
3107 +++ b/arch/arm/lib/clear_user.S
3108 @@ -12,14 +12,14 @@
3109
3110 .text
3111
3112 -/* Prototype: int __clear_user(void *addr, size_t sz)
3113 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3114 * Purpose : clear some user memory
3115 * Params : addr - user memory address to clear
3116 * : sz - number of bytes to clear
3117 * Returns : number of bytes NOT cleared
3118 */
3119 ENTRY(__clear_user_std)
3120 -WEAK(__clear_user)
3121 +WEAK(___clear_user)
3122 stmfd sp!, {r1, lr}
3123 mov r2, #0
3124 cmp r1, #4
3125 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3126 USER( strnebt r2, [r0])
3127 mov r0, #0
3128 ldmfd sp!, {r1, pc}
3129 -ENDPROC(__clear_user)
3130 +ENDPROC(___clear_user)
3131 ENDPROC(__clear_user_std)
3132
3133 .pushsection .fixup,"ax"
3134 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3135 index 66a477a..bee61d3 100644
3136 --- a/arch/arm/lib/copy_from_user.S
3137 +++ b/arch/arm/lib/copy_from_user.S
3138 @@ -16,7 +16,7 @@
3139 /*
3140 * Prototype:
3141 *
3142 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3143 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3144 *
3145 * Purpose:
3146 *
3147 @@ -84,11 +84,11 @@
3148
3149 .text
3150
3151 -ENTRY(__copy_from_user)
3152 +ENTRY(___copy_from_user)
3153
3154 #include "copy_template.S"
3155
3156 -ENDPROC(__copy_from_user)
3157 +ENDPROC(___copy_from_user)
3158
3159 .pushsection .fixup,"ax"
3160 .align 0
3161 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3162 index 6ee2f67..d1cce76 100644
3163 --- a/arch/arm/lib/copy_page.S
3164 +++ b/arch/arm/lib/copy_page.S
3165 @@ -10,6 +10,7 @@
3166 * ASM optimised string functions
3167 */
3168 #include <linux/linkage.h>
3169 +#include <linux/const.h>
3170 #include <asm/assembler.h>
3171 #include <asm/asm-offsets.h>
3172 #include <asm/cache.h>
3173 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3174 index d066df6..df28194 100644
3175 --- a/arch/arm/lib/copy_to_user.S
3176 +++ b/arch/arm/lib/copy_to_user.S
3177 @@ -16,7 +16,7 @@
3178 /*
3179 * Prototype:
3180 *
3181 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3182 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3183 *
3184 * Purpose:
3185 *
3186 @@ -88,11 +88,11 @@
3187 .text
3188
3189 ENTRY(__copy_to_user_std)
3190 -WEAK(__copy_to_user)
3191 +WEAK(___copy_to_user)
3192
3193 #include "copy_template.S"
3194
3195 -ENDPROC(__copy_to_user)
3196 +ENDPROC(___copy_to_user)
3197 ENDPROC(__copy_to_user_std)
3198
3199 .pushsection .fixup,"ax"
3200 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3201 index 7d08b43..f7ca7ea 100644
3202 --- a/arch/arm/lib/csumpartialcopyuser.S
3203 +++ b/arch/arm/lib/csumpartialcopyuser.S
3204 @@ -57,8 +57,8 @@
3205 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3206 */
3207
3208 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3209 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3210 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3211 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3212
3213 #include "csumpartialcopygeneric.S"
3214
3215 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3216 index 64dbfa5..84a3fd9 100644
3217 --- a/arch/arm/lib/delay.c
3218 +++ b/arch/arm/lib/delay.c
3219 @@ -28,7 +28,7 @@
3220 /*
3221 * Default to the loop-based delay implementation.
3222 */
3223 -struct arm_delay_ops arm_delay_ops = {
3224 +struct arm_delay_ops arm_delay_ops __read_only = {
3225 .delay = __loop_delay,
3226 .const_udelay = __loop_const_udelay,
3227 .udelay = __loop_udelay,
3228 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3229 index 025f742..8432b08 100644
3230 --- a/arch/arm/lib/uaccess_with_memcpy.c
3231 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3232 @@ -104,7 +104,7 @@ out:
3233 }
3234
3235 unsigned long
3236 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3237 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3238 {
3239 /*
3240 * This test is stubbed out of the main function above to keep
3241 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3242 index 49792a0..f192052 100644
3243 --- a/arch/arm/mach-kirkwood/common.c
3244 +++ b/arch/arm/mach-kirkwood/common.c
3245 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3246 clk_gate_ops.disable(hw);
3247 }
3248
3249 -static struct clk_ops clk_gate_fn_ops;
3250 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3251 +{
3252 + return clk_gate_ops.is_enabled(hw);
3253 +}
3254 +
3255 +static struct clk_ops clk_gate_fn_ops = {
3256 + .enable = clk_gate_fn_enable,
3257 + .disable = clk_gate_fn_disable,
3258 + .is_enabled = clk_gate_fn_is_enabled,
3259 +};
3260
3261 static struct clk __init *clk_register_gate_fn(struct device *dev,
3262 const char *name,
3263 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3264 gate_fn->fn_en = fn_en;
3265 gate_fn->fn_dis = fn_dis;
3266
3267 - /* ops is the gate ops, but with our enable/disable functions */
3268 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3269 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3270 - clk_gate_fn_ops = clk_gate_ops;
3271 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3272 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3273 - }
3274 -
3275 clk = clk_register(dev, &gate_fn->gate.hw);
3276
3277 if (IS_ERR(clk))
3278 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3279 index f6eeb87..cc90868 100644
3280 --- a/arch/arm/mach-omap2/board-n8x0.c
3281 +++ b/arch/arm/mach-omap2/board-n8x0.c
3282 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3283 }
3284 #endif
3285
3286 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3287 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3288 .late_init = n8x0_menelaus_late_init,
3289 };
3290
3291 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3292 index 410e1ba..1d2dd59 100644
3293 --- a/arch/arm/mach-omap2/gpmc.c
3294 +++ b/arch/arm/mach-omap2/gpmc.c
3295 @@ -145,7 +145,6 @@ struct omap3_gpmc_regs {
3296 };
3297
3298 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3299 -static struct irq_chip gpmc_irq_chip;
3300 static unsigned gpmc_irq_start;
3301
3302 static struct resource gpmc_mem_root;
3303 @@ -707,6 +706,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3304
3305 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3306
3307 +static struct irq_chip gpmc_irq_chip = {
3308 + .name = "gpmc",
3309 + .irq_startup = gpmc_irq_noop_ret,
3310 + .irq_enable = gpmc_irq_enable,
3311 + .irq_disable = gpmc_irq_disable,
3312 + .irq_shutdown = gpmc_irq_noop,
3313 + .irq_ack = gpmc_irq_noop,
3314 + .irq_mask = gpmc_irq_noop,
3315 + .irq_unmask = gpmc_irq_noop,
3316 +
3317 +};
3318 +
3319 static int gpmc_setup_irq(void)
3320 {
3321 int i;
3322 @@ -721,15 +732,6 @@ static int gpmc_setup_irq(void)
3323 return gpmc_irq_start;
3324 }
3325
3326 - gpmc_irq_chip.name = "gpmc";
3327 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3328 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3329 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3330 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3331 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3332 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3333 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3334 -
3335 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3336 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3337
3338 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3339 index f8bb3b9..831e7b8 100644
3340 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3341 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3342 @@ -339,7 +339,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3343 return NOTIFY_OK;
3344 }
3345
3346 -static struct notifier_block __refdata irq_hotplug_notifier = {
3347 +static struct notifier_block irq_hotplug_notifier = {
3348 .notifier_call = irq_cpu_hotplug_notify,
3349 };
3350
3351 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3352 index 381be7a..89b9c7e 100644
3353 --- a/arch/arm/mach-omap2/omap_device.c
3354 +++ b/arch/arm/mach-omap2/omap_device.c
3355 @@ -499,7 +499,7 @@ void omap_device_delete(struct omap_device *od)
3356 struct platform_device __init *omap_device_build(const char *pdev_name,
3357 int pdev_id,
3358 struct omap_hwmod *oh,
3359 - void *pdata, int pdata_len)
3360 + const void *pdata, int pdata_len)
3361 {
3362 struct omap_hwmod *ohs[] = { oh };
3363
3364 @@ -527,7 +527,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3365 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3366 int pdev_id,
3367 struct omap_hwmod **ohs,
3368 - int oh_cnt, void *pdata,
3369 + int oh_cnt, const void *pdata,
3370 int pdata_len)
3371 {
3372 int ret = -ENOMEM;
3373 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3374 index 044c31d..2ee0861 100644
3375 --- a/arch/arm/mach-omap2/omap_device.h
3376 +++ b/arch/arm/mach-omap2/omap_device.h
3377 @@ -72,12 +72,12 @@ int omap_device_idle(struct platform_device *pdev);
3378 /* Core code interface */
3379
3380 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3381 - struct omap_hwmod *oh, void *pdata,
3382 + struct omap_hwmod *oh, const void *pdata,
3383 int pdata_len);
3384
3385 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3386 struct omap_hwmod **oh, int oh_cnt,
3387 - void *pdata, int pdata_len);
3388 + const void *pdata, int pdata_len);
3389
3390 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3391 struct omap_hwmod **ohs, int oh_cnt);
3392 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3393 index a202a47..c430564 100644
3394 --- a/arch/arm/mach-omap2/omap_hwmod.c
3395 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3396 @@ -191,10 +191,10 @@ struct omap_hwmod_soc_ops {
3397 int (*init_clkdm)(struct omap_hwmod *oh);
3398 void (*update_context_lost)(struct omap_hwmod *oh);
3399 int (*get_context_lost)(struct omap_hwmod *oh);
3400 -};
3401 +} __no_const;
3402
3403 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3404 -static struct omap_hwmod_soc_ops soc_ops;
3405 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3406
3407 /* omap_hwmod_list contains all registered struct omap_hwmods */
3408 static LIST_HEAD(omap_hwmod_list);
3409 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3410 index d15c7bb..b2d1f0c 100644
3411 --- a/arch/arm/mach-omap2/wd_timer.c
3412 +++ b/arch/arm/mach-omap2/wd_timer.c
3413 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3414 struct omap_hwmod *oh;
3415 char *oh_name = "wd_timer2";
3416 char *dev_name = "omap_wdt";
3417 - struct omap_wd_timer_platform_data pdata;
3418 + static struct omap_wd_timer_platform_data pdata = {
3419 + .read_reset_sources = prm_read_reset_sources
3420 + };
3421
3422 if (!cpu_class_is_omap2() || of_have_populated_dt())
3423 return 0;
3424 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3425 return -EINVAL;
3426 }
3427
3428 - pdata.read_reset_sources = prm_read_reset_sources;
3429 -
3430 pdev = omap_device_build(dev_name, id, oh, &pdata,
3431 sizeof(struct omap_wd_timer_platform_data));
3432 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3433 diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h
3434 index bddce2b..3eb04e2 100644
3435 --- a/arch/arm/mach-ux500/include/mach/setup.h
3436 +++ b/arch/arm/mach-ux500/include/mach/setup.h
3437 @@ -37,13 +37,6 @@ extern void ux500_timer_init(void);
3438 .type = MT_DEVICE, \
3439 }
3440
3441 -#define __MEM_DEV_DESC(x, sz) { \
3442 - .virtual = IO_ADDRESS(x), \
3443 - .pfn = __phys_to_pfn(x), \
3444 - .length = sz, \
3445 - .type = MT_MEMORY, \
3446 -}
3447 -
3448 extern struct smp_operations ux500_smp_ops;
3449 extern void ux500_cpu_die(unsigned int cpu);
3450
3451 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3452 index 4045c49..4e26c79 100644
3453 --- a/arch/arm/mm/Kconfig
3454 +++ b/arch/arm/mm/Kconfig
3455 @@ -425,7 +425,7 @@ config CPU_32v5
3456
3457 config CPU_32v6
3458 bool
3459 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3460 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC
3461 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3462
3463 config CPU_32v6K
3464 @@ -574,6 +574,7 @@ config CPU_CP15_MPU
3465
3466 config CPU_USE_DOMAINS
3467 bool
3468 + depends on !ARM_LPAE && !PAX_KERNEXEC
3469 help
3470 This option enables or disables the use of domain switching
3471 via the set_fs() function.
3472 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3473 index db26e2e..ee44569 100644
3474 --- a/arch/arm/mm/alignment.c
3475 +++ b/arch/arm/mm/alignment.c
3476 @@ -211,10 +211,12 @@ union offset_union {
3477 #define __get16_unaligned_check(ins,val,addr) \
3478 do { \
3479 unsigned int err = 0, v, a = addr; \
3480 + pax_open_userland(); \
3481 __get8_unaligned_check(ins,v,a,err); \
3482 val = v << ((BE) ? 8 : 0); \
3483 __get8_unaligned_check(ins,v,a,err); \
3484 val |= v << ((BE) ? 0 : 8); \
3485 + pax_close_userland(); \
3486 if (err) \
3487 goto fault; \
3488 } while (0)
3489 @@ -228,6 +230,7 @@ union offset_union {
3490 #define __get32_unaligned_check(ins,val,addr) \
3491 do { \
3492 unsigned int err = 0, v, a = addr; \
3493 + pax_open_userland(); \
3494 __get8_unaligned_check(ins,v,a,err); \
3495 val = v << ((BE) ? 24 : 0); \
3496 __get8_unaligned_check(ins,v,a,err); \
3497 @@ -236,6 +239,7 @@ union offset_union {
3498 val |= v << ((BE) ? 8 : 16); \
3499 __get8_unaligned_check(ins,v,a,err); \
3500 val |= v << ((BE) ? 0 : 24); \
3501 + pax_close_userland(); \
3502 if (err) \
3503 goto fault; \
3504 } while (0)
3505 @@ -249,6 +253,7 @@ union offset_union {
3506 #define __put16_unaligned_check(ins,val,addr) \
3507 do { \
3508 unsigned int err = 0, v = val, a = addr; \
3509 + pax_open_userland(); \
3510 __asm__( FIRST_BYTE_16 \
3511 ARM( "1: "ins" %1, [%2], #1\n" ) \
3512 THUMB( "1: "ins" %1, [%2]\n" ) \
3513 @@ -268,6 +273,7 @@ union offset_union {
3514 " .popsection\n" \
3515 : "=r" (err), "=&r" (v), "=&r" (a) \
3516 : "0" (err), "1" (v), "2" (a)); \
3517 + pax_close_userland(); \
3518 if (err) \
3519 goto fault; \
3520 } while (0)
3521 @@ -281,6 +287,7 @@ union offset_union {
3522 #define __put32_unaligned_check(ins,val,addr) \
3523 do { \
3524 unsigned int err = 0, v = val, a = addr; \
3525 + pax_open_userland(); \
3526 __asm__( FIRST_BYTE_32 \
3527 ARM( "1: "ins" %1, [%2], #1\n" ) \
3528 THUMB( "1: "ins" %1, [%2]\n" ) \
3529 @@ -310,6 +317,7 @@ union offset_union {
3530 " .popsection\n" \
3531 : "=r" (err), "=&r" (v), "=&r" (a) \
3532 : "0" (err), "1" (v), "2" (a)); \
3533 + pax_close_userland(); \
3534 if (err) \
3535 goto fault; \
3536 } while (0)
3537 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3538 index 5dbf13f..1a60561 100644
3539 --- a/arch/arm/mm/fault.c
3540 +++ b/arch/arm/mm/fault.c
3541 @@ -25,6 +25,7 @@
3542 #include <asm/system_misc.h>
3543 #include <asm/system_info.h>
3544 #include <asm/tlbflush.h>
3545 +#include <asm/sections.h>
3546
3547 #include "fault.h"
3548
3549 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3550 if (fixup_exception(regs))
3551 return;
3552
3553 +#ifdef CONFIG_PAX_KERNEXEC
3554 + if ((fsr & FSR_WRITE) &&
3555 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3556 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3557 + {
3558 + if (current->signal->curr_ip)
3559 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3560 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3561 + else
3562 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3563 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3564 + }
3565 +#endif
3566 +
3567 /*
3568 * No handler, we'll have to terminate things with extreme prejudice.
3569 */
3570 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3571 }
3572 #endif
3573
3574 +#ifdef CONFIG_PAX_PAGEEXEC
3575 + if (fsr & FSR_LNX_PF) {
3576 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3577 + do_group_exit(SIGKILL);
3578 + }
3579 +#endif
3580 +
3581 tsk->thread.address = addr;
3582 tsk->thread.error_code = fsr;
3583 tsk->thread.trap_no = 14;
3584 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3585 }
3586 #endif /* CONFIG_MMU */
3587
3588 +#ifdef CONFIG_PAX_PAGEEXEC
3589 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3590 +{
3591 + long i;
3592 +
3593 + printk(KERN_ERR "PAX: bytes at PC: ");
3594 + for (i = 0; i < 20; i++) {
3595 + unsigned char c;
3596 + if (get_user(c, (__force unsigned char __user *)pc+i))
3597 + printk(KERN_CONT "?? ");
3598 + else
3599 + printk(KERN_CONT "%02x ", c);
3600 + }
3601 + printk("\n");
3602 +
3603 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3604 + for (i = -1; i < 20; i++) {
3605 + unsigned long c;
3606 + if (get_user(c, (__force unsigned long __user *)sp+i))
3607 + printk(KERN_CONT "???????? ");
3608 + else
3609 + printk(KERN_CONT "%08lx ", c);
3610 + }
3611 + printk("\n");
3612 +}
3613 +#endif
3614 +
3615 /*
3616 * First Level Translation Fault Handler
3617 *
3618 @@ -543,9 +592,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3619 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3620 struct siginfo info;
3621
3622 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3623 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3624 + if (current->signal->curr_ip)
3625 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3626 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3627 + else
3628 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3629 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3630 + goto die;
3631 + }
3632 +#endif
3633 +
3634 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3635 return;
3636
3637 +die:
3638 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3639 inf->name, fsr, addr);
3640
3641 @@ -575,9 +637,49 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3642 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3643 struct siginfo info;
3644
3645 + if (user_mode(regs)) {
3646 + if (addr == 0xffff0fe0UL) {
3647 + /*
3648 + * PaX: __kuser_get_tls emulation
3649 + */
3650 + regs->ARM_r0 = current_thread_info()->tp_value;
3651 + regs->ARM_pc = regs->ARM_lr;
3652 + return;
3653 + }
3654 + }
3655 +
3656 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3657 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3658 + if (current->signal->curr_ip)
3659 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3660 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3661 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3662 + else
3663 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3664 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3665 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3666 + goto die;
3667 + }
3668 +#endif
3669 +
3670 +#ifdef CONFIG_PAX_REFCOUNT
3671 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3672 + unsigned int bkpt;
3673 +
3674 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
3675 + current->thread.error_code = ifsr;
3676 + current->thread.trap_no = 0;
3677 + pax_report_refcount_overflow(regs);
3678 + fixup_exception(regs);
3679 + return;
3680 + }
3681 + }
3682 +#endif
3683 +
3684 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3685 return;
3686
3687 +die:
3688 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3689 inf->name, ifsr, addr);
3690
3691 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3692 index cf08bdf..772656c 100644
3693 --- a/arch/arm/mm/fault.h
3694 +++ b/arch/arm/mm/fault.h
3695 @@ -3,6 +3,7 @@
3696
3697 /*
3698 * Fault status register encodings. We steal bit 31 for our own purposes.
3699 + * Set when the FSR value is from an instruction fault.
3700 */
3701 #define FSR_LNX_PF (1 << 31)
3702 #define FSR_WRITE (1 << 11)
3703 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
3704 }
3705 #endif
3706
3707 +/* valid for LPAE and !LPAE */
3708 +static inline int is_xn_fault(unsigned int fsr)
3709 +{
3710 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
3711 +}
3712 +
3713 +static inline int is_domain_fault(unsigned int fsr)
3714 +{
3715 + return ((fsr_fs(fsr) & 0xD) == 0x9);
3716 +}
3717 +
3718 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
3719 unsigned long search_exception_table(unsigned long addr);
3720
3721 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
3722 index ad722f1..763fdd3 100644
3723 --- a/arch/arm/mm/init.c
3724 +++ b/arch/arm/mm/init.c
3725 @@ -30,6 +30,8 @@
3726 #include <asm/setup.h>
3727 #include <asm/tlb.h>
3728 #include <asm/fixmap.h>
3729 +#include <asm/system_info.h>
3730 +#include <asm/cp15.h>
3731
3732 #include <asm/mach/arch.h>
3733 #include <asm/mach/map.h>
3734 @@ -736,7 +738,46 @@ void free_initmem(void)
3735 {
3736 #ifdef CONFIG_HAVE_TCM
3737 extern char __tcm_start, __tcm_end;
3738 +#endif
3739
3740 +#ifdef CONFIG_PAX_KERNEXEC
3741 + unsigned long addr;
3742 + pgd_t *pgd;
3743 + pud_t *pud;
3744 + pmd_t *pmd;
3745 + int cpu_arch = cpu_architecture();
3746 + unsigned int cr = get_cr();
3747 +
3748 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
3749 + /* make pages tables, etc before .text NX */
3750 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
3751 + pgd = pgd_offset_k(addr);
3752 + pud = pud_offset(pgd, addr);
3753 + pmd = pmd_offset(pud, addr);
3754 + __section_update(pmd, addr, PMD_SECT_XN);
3755 + }
3756 + /* make init NX */
3757 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
3758 + pgd = pgd_offset_k(addr);
3759 + pud = pud_offset(pgd, addr);
3760 + pmd = pmd_offset(pud, addr);
3761 + __section_update(pmd, addr, PMD_SECT_XN);
3762 + }
3763 + /* make kernel code/rodata RX */
3764 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
3765 + pgd = pgd_offset_k(addr);
3766 + pud = pud_offset(pgd, addr);
3767 + pmd = pmd_offset(pud, addr);
3768 +#ifdef CONFIG_ARM_LPAE
3769 + __section_update(pmd, addr, PMD_SECT_RDONLY);
3770 +#else
3771 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
3772 +#endif
3773 + }
3774 + }
3775 +#endif
3776 +
3777 +#ifdef CONFIG_HAVE_TCM
3778 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
3779 totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)),
3780 __phys_to_pfn(__pa(&__tcm_end)),
3781 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
3782 index 04d9006..c547d85 100644
3783 --- a/arch/arm/mm/ioremap.c
3784 +++ b/arch/arm/mm/ioremap.c
3785 @@ -392,9 +392,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
3786 unsigned int mtype;
3787
3788 if (cached)
3789 - mtype = MT_MEMORY;
3790 + mtype = MT_MEMORY_RX;
3791 else
3792 - mtype = MT_MEMORY_NONCACHED;
3793 + mtype = MT_MEMORY_NONCACHED_RX;
3794
3795 return __arm_ioremap_caller(phys_addr, size, mtype,
3796 __builtin_return_address(0));
3797 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
3798 index 10062ce..cd34fb9 100644
3799 --- a/arch/arm/mm/mmap.c
3800 +++ b/arch/arm/mm/mmap.c
3801 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3802 struct vm_area_struct *vma;
3803 int do_align = 0;
3804 int aliasing = cache_is_vipt_aliasing();
3805 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3806 struct vm_unmapped_area_info info;
3807
3808 /*
3809 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3810 if (len > TASK_SIZE)
3811 return -ENOMEM;
3812
3813 +#ifdef CONFIG_PAX_RANDMMAP
3814 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3815 +#endif
3816 +
3817 if (addr) {
3818 if (do_align)
3819 addr = COLOUR_ALIGN(addr, pgoff);
3820 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3821 addr = PAGE_ALIGN(addr);
3822
3823 vma = find_vma(mm, addr);
3824 - if (TASK_SIZE - len >= addr &&
3825 - (!vma || addr + len <= vma->vm_start))
3826 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3827 return addr;
3828 }
3829
3830 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3831 info.high_limit = TASK_SIZE;
3832 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
3833 info.align_offset = pgoff << PAGE_SHIFT;
3834 + info.threadstack_offset = offset;
3835 return vm_unmapped_area(&info);
3836 }
3837
3838 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3839 unsigned long addr = addr0;
3840 int do_align = 0;
3841 int aliasing = cache_is_vipt_aliasing();
3842 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3843 struct vm_unmapped_area_info info;
3844
3845 /*
3846 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3847 return addr;
3848 }
3849
3850 +#ifdef CONFIG_PAX_RANDMMAP
3851 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3852 +#endif
3853 +
3854 /* requesting a specific address */
3855 if (addr) {
3856 if (do_align)
3857 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3858 else
3859 addr = PAGE_ALIGN(addr);
3860 vma = find_vma(mm, addr);
3861 - if (TASK_SIZE - len >= addr &&
3862 - (!vma || addr + len <= vma->vm_start))
3863 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3864 return addr;
3865 }
3866
3867 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3868 info.high_limit = mm->mmap_base;
3869 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
3870 info.align_offset = pgoff << PAGE_SHIFT;
3871 + info.threadstack_offset = offset;
3872 addr = vm_unmapped_area(&info);
3873
3874 /*
3875 @@ -162,6 +172,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3876 VM_BUG_ON(addr != -ENOMEM);
3877 info.flags = 0;
3878 info.low_limit = mm->mmap_base;
3879 +
3880 +#ifdef CONFIG_PAX_RANDMMAP
3881 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3882 + info.low_limit += mm->delta_mmap;
3883 +#endif
3884 +
3885 info.high_limit = TASK_SIZE;
3886 addr = vm_unmapped_area(&info);
3887 }
3888 @@ -173,6 +189,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3889 {
3890 unsigned long random_factor = 0UL;
3891
3892 +#ifdef CONFIG_PAX_RANDMMAP
3893 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3894 +#endif
3895 +
3896 /* 8 bits of randomness in 20 address space bits */
3897 if ((current->flags & PF_RANDOMIZE) &&
3898 !(current->personality & ADDR_NO_RANDOMIZE))
3899 @@ -180,10 +200,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3900
3901 if (mmap_is_legacy()) {
3902 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
3903 +
3904 +#ifdef CONFIG_PAX_RANDMMAP
3905 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3906 + mm->mmap_base += mm->delta_mmap;
3907 +#endif
3908 +
3909 mm->get_unmapped_area = arch_get_unmapped_area;
3910 mm->unmap_area = arch_unmap_area;
3911 } else {
3912 mm->mmap_base = mmap_base(random_factor);
3913 +
3914 +#ifdef CONFIG_PAX_RANDMMAP
3915 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3916 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
3917 +#endif
3918 +
3919 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
3920 mm->unmap_area = arch_unmap_area_topdown;
3921 }
3922 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
3923 index a84ff76..f221c1d 100644
3924 --- a/arch/arm/mm/mmu.c
3925 +++ b/arch/arm/mm/mmu.c
3926 @@ -36,6 +36,22 @@
3927 #include "mm.h"
3928 #include "tcm.h"
3929
3930 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3931 +void modify_domain(unsigned int dom, unsigned int type)
3932 +{
3933 + struct thread_info *thread = current_thread_info();
3934 + unsigned int domain = thread->cpu_domain;
3935 + /*
3936 + * DOMAIN_MANAGER might be defined to some other value,
3937 + * use the arch-defined constant
3938 + */
3939 + domain &= ~domain_val(dom, 3);
3940 + thread->cpu_domain = domain | domain_val(dom, type);
3941 + set_domain(thread->cpu_domain);
3942 +}
3943 +EXPORT_SYMBOL(modify_domain);
3944 +#endif
3945 +
3946 /*
3947 * empty_zero_page is a special page that is used for
3948 * zero-initialized data and COW.
3949 @@ -211,10 +227,18 @@ void adjust_cr(unsigned long mask, unsigned long set)
3950 }
3951 #endif
3952
3953 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
3954 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
3955 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
3956
3957 -static struct mem_type mem_types[] = {
3958 +#ifdef CONFIG_PAX_KERNEXEC
3959 +#define L_PTE_KERNEXEC L_PTE_RDONLY
3960 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
3961 +#else
3962 +#define L_PTE_KERNEXEC L_PTE_DIRTY
3963 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
3964 +#endif
3965 +
3966 +static struct mem_type mem_types[] __read_only = {
3967 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
3968 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
3969 L_PTE_SHARED,
3970 @@ -243,16 +267,16 @@ static struct mem_type mem_types[] = {
3971 [MT_UNCACHED] = {
3972 .prot_pte = PROT_PTE_DEVICE,
3973 .prot_l1 = PMD_TYPE_TABLE,
3974 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
3975 + .prot_sect = PROT_SECT_DEVICE,
3976 .domain = DOMAIN_IO,
3977 },
3978 [MT_CACHECLEAN] = {
3979 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
3980 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
3981 .domain = DOMAIN_KERNEL,
3982 },
3983 #ifndef CONFIG_ARM_LPAE
3984 [MT_MINICLEAN] = {
3985 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
3986 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
3987 .domain = DOMAIN_KERNEL,
3988 },
3989 #endif
3990 @@ -260,36 +284,54 @@ static struct mem_type mem_types[] = {
3991 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
3992 L_PTE_RDONLY,
3993 .prot_l1 = PMD_TYPE_TABLE,
3994 - .domain = DOMAIN_USER,
3995 + .domain = DOMAIN_VECTORS,
3996 },
3997 [MT_HIGH_VECTORS] = {
3998 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
3999 - L_PTE_USER | L_PTE_RDONLY,
4000 + L_PTE_RDONLY,
4001 .prot_l1 = PMD_TYPE_TABLE,
4002 - .domain = DOMAIN_USER,
4003 + .domain = DOMAIN_VECTORS,
4004 },
4005 - [MT_MEMORY] = {
4006 + [MT_MEMORY_RWX] = {
4007 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4008 .prot_l1 = PMD_TYPE_TABLE,
4009 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4010 .domain = DOMAIN_KERNEL,
4011 },
4012 + [MT_MEMORY_RW] = {
4013 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4014 + .prot_l1 = PMD_TYPE_TABLE,
4015 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4016 + .domain = DOMAIN_KERNEL,
4017 + },
4018 + [MT_MEMORY_RX] = {
4019 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4020 + .prot_l1 = PMD_TYPE_TABLE,
4021 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4022 + .domain = DOMAIN_KERNEL,
4023 + },
4024 [MT_ROM] = {
4025 - .prot_sect = PMD_TYPE_SECT,
4026 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4027 .domain = DOMAIN_KERNEL,
4028 },
4029 - [MT_MEMORY_NONCACHED] = {
4030 + [MT_MEMORY_NONCACHED_RW] = {
4031 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4032 L_PTE_MT_BUFFERABLE,
4033 .prot_l1 = PMD_TYPE_TABLE,
4034 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4035 .domain = DOMAIN_KERNEL,
4036 },
4037 + [MT_MEMORY_NONCACHED_RX] = {
4038 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4039 + L_PTE_MT_BUFFERABLE,
4040 + .prot_l1 = PMD_TYPE_TABLE,
4041 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4042 + .domain = DOMAIN_KERNEL,
4043 + },
4044 [MT_MEMORY_DTCM] = {
4045 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4046 - L_PTE_XN,
4047 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4048 .prot_l1 = PMD_TYPE_TABLE,
4049 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4050 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4051 .domain = DOMAIN_KERNEL,
4052 },
4053 [MT_MEMORY_ITCM] = {
4054 @@ -299,10 +341,10 @@ static struct mem_type mem_types[] = {
4055 },
4056 [MT_MEMORY_SO] = {
4057 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4058 - L_PTE_MT_UNCACHED | L_PTE_XN,
4059 + L_PTE_MT_UNCACHED,
4060 .prot_l1 = PMD_TYPE_TABLE,
4061 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4062 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4063 + PMD_SECT_UNCACHED,
4064 .domain = DOMAIN_KERNEL,
4065 },
4066 [MT_MEMORY_DMA_READY] = {
4067 @@ -388,9 +430,35 @@ static void __init build_mem_type_table(void)
4068 * to prevent speculative instruction fetches.
4069 */
4070 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4071 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4072 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4073 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4074 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4075 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4076 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4077 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4078 +
4079 + /* Mark other regions on ARMv6+ as execute-never */
4080 +
4081 +#ifdef CONFIG_PAX_KERNEXEC
4082 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4083 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4084 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4085 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4086 +#ifndef CONFIG_ARM_LPAE
4087 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4088 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4089 +#endif
4090 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4091 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4092 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4093 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4094 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4095 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4096 +#endif
4097 +
4098 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4099 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4100 }
4101 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4102 /*
4103 @@ -451,6 +519,9 @@ static void __init build_mem_type_table(void)
4104 * from SVC mode and no access from userspace.
4105 */
4106 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4107 +#ifdef CONFIG_PAX_KERNEXEC
4108 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4109 +#endif
4110 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4111 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4112 #endif
4113 @@ -468,11 +539,17 @@ static void __init build_mem_type_table(void)
4114 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4115 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4116 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4117 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4118 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4119 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4120 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4121 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4122 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4123 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4124 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4125 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4126 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4127 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4128 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4129 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4130 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4131 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4132 }
4133 }
4134
4135 @@ -483,15 +560,20 @@ static void __init build_mem_type_table(void)
4136 if (cpu_arch >= CPU_ARCH_ARMv6) {
4137 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4138 /* Non-cacheable Normal is XCB = 001 */
4139 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4140 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4141 + PMD_SECT_BUFFERED;
4142 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4143 PMD_SECT_BUFFERED;
4144 } else {
4145 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4146 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4147 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4148 + PMD_SECT_TEX(1);
4149 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4150 PMD_SECT_TEX(1);
4151 }
4152 } else {
4153 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4154 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4155 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4156 }
4157
4158 #ifdef CONFIG_ARM_LPAE
4159 @@ -507,6 +589,8 @@ static void __init build_mem_type_table(void)
4160 vecs_pgprot |= PTE_EXT_AF;
4161 #endif
4162
4163 + user_pgprot |= __supported_pte_mask;
4164 +
4165 for (i = 0; i < 16; i++) {
4166 pteval_t v = pgprot_val(protection_map[i]);
4167 protection_map[i] = __pgprot(v | user_pgprot);
4168 @@ -524,10 +608,15 @@ static void __init build_mem_type_table(void)
4169
4170 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4171 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4172 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4173 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4174 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4175 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4176 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4177 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4178 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4179 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4180 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4181 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4182 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4183 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4184 mem_types[MT_ROM].prot_sect |= cp->pmd;
4185
4186 switch (cp->pmd) {
4187 @@ -1147,18 +1236,15 @@ void __init arm_mm_memblock_reserve(void)
4188 * called function. This means you can't use any function or debugging
4189 * method which may touch any device, otherwise the kernel _will_ crash.
4190 */
4191 +
4192 +static char vectors[PAGE_SIZE] __read_only __aligned(PAGE_SIZE);
4193 +
4194 static void __init devicemaps_init(struct machine_desc *mdesc)
4195 {
4196 struct map_desc map;
4197 unsigned long addr;
4198 - void *vectors;
4199
4200 - /*
4201 - * Allocate the vector page early.
4202 - */
4203 - vectors = early_alloc(PAGE_SIZE);
4204 -
4205 - early_trap_init(vectors);
4206 + early_trap_init(&vectors);
4207
4208 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4209 pmd_clear(pmd_off_k(addr));
4210 @@ -1198,7 +1284,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4211 * location (0xffff0000). If we aren't using high-vectors, also
4212 * create a mapping at the low-vectors virtual address.
4213 */
4214 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4215 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4216 map.virtual = 0xffff0000;
4217 map.length = PAGE_SIZE;
4218 map.type = MT_HIGH_VECTORS;
4219 @@ -1256,8 +1342,39 @@ static void __init map_lowmem(void)
4220 map.pfn = __phys_to_pfn(start);
4221 map.virtual = __phys_to_virt(start);
4222 map.length = end - start;
4223 - map.type = MT_MEMORY;
4224
4225 +#ifdef CONFIG_PAX_KERNEXEC
4226 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4227 + struct map_desc kernel;
4228 + struct map_desc initmap;
4229 +
4230 + /* when freeing initmem we will make this RW */
4231 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4232 + initmap.virtual = (unsigned long)__init_begin;
4233 + initmap.length = _sdata - __init_begin;
4234 + initmap.type = MT_MEMORY_RWX;
4235 + create_mapping(&initmap);
4236 +
4237 + /* when freeing initmem we will make this RX */
4238 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4239 + kernel.virtual = (unsigned long)_stext;
4240 + kernel.length = __init_begin - _stext;
4241 + kernel.type = MT_MEMORY_RWX;
4242 + create_mapping(&kernel);
4243 +
4244 + if (map.virtual < (unsigned long)_stext) {
4245 + map.length = (unsigned long)_stext - map.virtual;
4246 + map.type = MT_MEMORY_RWX;
4247 + create_mapping(&map);
4248 + }
4249 +
4250 + map.pfn = __phys_to_pfn(__pa(_sdata));
4251 + map.virtual = (unsigned long)_sdata;
4252 + map.length = end - __pa(_sdata);
4253 + }
4254 +#endif
4255 +
4256 + map.type = MT_MEMORY_RW;
4257 create_mapping(&map);
4258 }
4259 }
4260 diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
4261 index 78f520b..31f0cb6 100644
4262 --- a/arch/arm/mm/proc-v7-2level.S
4263 +++ b/arch/arm/mm/proc-v7-2level.S
4264 @@ -99,6 +99,9 @@ ENTRY(cpu_v7_set_pte_ext)
4265 tst r1, #L_PTE_XN
4266 orrne r3, r3, #PTE_EXT_XN
4267
4268 + tst r1, #L_PTE_PXN
4269 + orrne r3, r3, #PTE_EXT_PXN
4270 +
4271 tst r1, #L_PTE_YOUNG
4272 tstne r1, #L_PTE_VALID
4273 #ifndef CONFIG_CPU_USE_DOMAINS
4274 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4275 index a5bc92d..0bb4730 100644
4276 --- a/arch/arm/plat-omap/sram.c
4277 +++ b/arch/arm/plat-omap/sram.c
4278 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4279 * Looks like we need to preserve some bootloader code at the
4280 * beginning of SRAM for jumping to flash for reboot to work...
4281 */
4282 + pax_open_kernel();
4283 memset_io(omap_sram_base + omap_sram_skip, 0,
4284 omap_sram_size - omap_sram_skip);
4285 + pax_close_kernel();
4286 }
4287 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4288 index 1141782..0959d64 100644
4289 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4290 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4291 @@ -48,7 +48,7 @@ struct samsung_dma_ops {
4292 int (*started)(unsigned ch);
4293 int (*flush)(unsigned ch);
4294 int (*stop)(unsigned ch);
4295 -};
4296 +} __no_const;
4297
4298 extern void *samsung_dmadev_get_ops(void);
4299 extern void *s3c_dma_get_ops(void);
4300 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4301 index f4726dc..39ed646 100644
4302 --- a/arch/arm64/kernel/debug-monitors.c
4303 +++ b/arch/arm64/kernel/debug-monitors.c
4304 @@ -149,7 +149,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4305 return NOTIFY_OK;
4306 }
4307
4308 -static struct notifier_block __cpuinitdata os_lock_nb = {
4309 +static struct notifier_block os_lock_nb = {
4310 .notifier_call = os_lock_notify,
4311 };
4312
4313 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4314 index 5ab825c..96aaec8 100644
4315 --- a/arch/arm64/kernel/hw_breakpoint.c
4316 +++ b/arch/arm64/kernel/hw_breakpoint.c
4317 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4318 return NOTIFY_OK;
4319 }
4320
4321 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4322 +static struct notifier_block hw_breakpoint_reset_nb = {
4323 .notifier_call = hw_breakpoint_reset_notify,
4324 };
4325
4326 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4327 index c3a58a1..78fbf54 100644
4328 --- a/arch/avr32/include/asm/cache.h
4329 +++ b/arch/avr32/include/asm/cache.h
4330 @@ -1,8 +1,10 @@
4331 #ifndef __ASM_AVR32_CACHE_H
4332 #define __ASM_AVR32_CACHE_H
4333
4334 +#include <linux/const.h>
4335 +
4336 #define L1_CACHE_SHIFT 5
4337 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4338 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4339
4340 /*
4341 * Memory returned by kmalloc() may be used for DMA, so we must make
4342 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4343 index d232888..87c8df1 100644
4344 --- a/arch/avr32/include/asm/elf.h
4345 +++ b/arch/avr32/include/asm/elf.h
4346 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4347 the loader. We need to make sure that it is out of the way of the program
4348 that it will "exec", and that there is sufficient room for the brk. */
4349
4350 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4351 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4352
4353 +#ifdef CONFIG_PAX_ASLR
4354 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4355 +
4356 +#define PAX_DELTA_MMAP_LEN 15
4357 +#define PAX_DELTA_STACK_LEN 15
4358 +#endif
4359
4360 /* This yields a mask that user programs can use to figure out what
4361 instruction set this CPU supports. This could be done in user space,
4362 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4363 index 479330b..53717a8 100644
4364 --- a/arch/avr32/include/asm/kmap_types.h
4365 +++ b/arch/avr32/include/asm/kmap_types.h
4366 @@ -2,9 +2,9 @@
4367 #define __ASM_AVR32_KMAP_TYPES_H
4368
4369 #ifdef CONFIG_DEBUG_HIGHMEM
4370 -# define KM_TYPE_NR 29
4371 +# define KM_TYPE_NR 30
4372 #else
4373 -# define KM_TYPE_NR 14
4374 +# define KM_TYPE_NR 15
4375 #endif
4376
4377 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4378 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4379 index b2f2d2d..d1c85cb 100644
4380 --- a/arch/avr32/mm/fault.c
4381 +++ b/arch/avr32/mm/fault.c
4382 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4383
4384 int exception_trace = 1;
4385
4386 +#ifdef CONFIG_PAX_PAGEEXEC
4387 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4388 +{
4389 + unsigned long i;
4390 +
4391 + printk(KERN_ERR "PAX: bytes at PC: ");
4392 + for (i = 0; i < 20; i++) {
4393 + unsigned char c;
4394 + if (get_user(c, (unsigned char *)pc+i))
4395 + printk(KERN_CONT "???????? ");
4396 + else
4397 + printk(KERN_CONT "%02x ", c);
4398 + }
4399 + printk("\n");
4400 +}
4401 +#endif
4402 +
4403 /*
4404 * This routine handles page faults. It determines the address and the
4405 * problem, and then passes it off to one of the appropriate routines.
4406 @@ -174,6 +191,16 @@ bad_area:
4407 up_read(&mm->mmap_sem);
4408
4409 if (user_mode(regs)) {
4410 +
4411 +#ifdef CONFIG_PAX_PAGEEXEC
4412 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4413 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4414 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4415 + do_group_exit(SIGKILL);
4416 + }
4417 + }
4418 +#endif
4419 +
4420 if (exception_trace && printk_ratelimit())
4421 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4422 "sp %08lx ecr %lu\n",
4423 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4424 index 568885a..f8008df 100644
4425 --- a/arch/blackfin/include/asm/cache.h
4426 +++ b/arch/blackfin/include/asm/cache.h
4427 @@ -7,6 +7,7 @@
4428 #ifndef __ARCH_BLACKFIN_CACHE_H
4429 #define __ARCH_BLACKFIN_CACHE_H
4430
4431 +#include <linux/const.h>
4432 #include <linux/linkage.h> /* for asmlinkage */
4433
4434 /*
4435 @@ -14,7 +15,7 @@
4436 * Blackfin loads 32 bytes for cache
4437 */
4438 #define L1_CACHE_SHIFT 5
4439 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4440 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4441 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4442
4443 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4444 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4445 index aea2718..3639a60 100644
4446 --- a/arch/cris/include/arch-v10/arch/cache.h
4447 +++ b/arch/cris/include/arch-v10/arch/cache.h
4448 @@ -1,8 +1,9 @@
4449 #ifndef _ASM_ARCH_CACHE_H
4450 #define _ASM_ARCH_CACHE_H
4451
4452 +#include <linux/const.h>
4453 /* Etrax 100LX have 32-byte cache-lines. */
4454 -#define L1_CACHE_BYTES 32
4455 #define L1_CACHE_SHIFT 5
4456 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4457
4458 #endif /* _ASM_ARCH_CACHE_H */
4459 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4460 index 7caf25d..ee65ac5 100644
4461 --- a/arch/cris/include/arch-v32/arch/cache.h
4462 +++ b/arch/cris/include/arch-v32/arch/cache.h
4463 @@ -1,11 +1,12 @@
4464 #ifndef _ASM_CRIS_ARCH_CACHE_H
4465 #define _ASM_CRIS_ARCH_CACHE_H
4466
4467 +#include <linux/const.h>
4468 #include <arch/hwregs/dma.h>
4469
4470 /* A cache-line is 32 bytes. */
4471 -#define L1_CACHE_BYTES 32
4472 #define L1_CACHE_SHIFT 5
4473 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4474
4475 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4476
4477 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4478 index b86329d..6709906 100644
4479 --- a/arch/frv/include/asm/atomic.h
4480 +++ b/arch/frv/include/asm/atomic.h
4481 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4482 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4483 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4484
4485 +#define atomic64_read_unchecked(v) atomic64_read(v)
4486 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4487 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4488 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4489 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4490 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4491 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4492 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4493 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4494 +
4495 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4496 {
4497 int c, old;
4498 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4499 index 2797163..c2a401d 100644
4500 --- a/arch/frv/include/asm/cache.h
4501 +++ b/arch/frv/include/asm/cache.h
4502 @@ -12,10 +12,11 @@
4503 #ifndef __ASM_CACHE_H
4504 #define __ASM_CACHE_H
4505
4506 +#include <linux/const.h>
4507
4508 /* bytes per L1 cache line */
4509 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4510 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4511 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4512
4513 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4514 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4515 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4516 index 43901f2..0d8b865 100644
4517 --- a/arch/frv/include/asm/kmap_types.h
4518 +++ b/arch/frv/include/asm/kmap_types.h
4519 @@ -2,6 +2,6 @@
4520 #ifndef _ASM_KMAP_TYPES_H
4521 #define _ASM_KMAP_TYPES_H
4522
4523 -#define KM_TYPE_NR 17
4524 +#define KM_TYPE_NR 18
4525
4526 #endif
4527 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4528 index 836f147..4cf23f5 100644
4529 --- a/arch/frv/mm/elf-fdpic.c
4530 +++ b/arch/frv/mm/elf-fdpic.c
4531 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4532 {
4533 struct vm_area_struct *vma;
4534 struct vm_unmapped_area_info info;
4535 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4536
4537 if (len > TASK_SIZE)
4538 return -ENOMEM;
4539 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4540 if (addr) {
4541 addr = PAGE_ALIGN(addr);
4542 vma = find_vma(current->mm, addr);
4543 - if (TASK_SIZE - len >= addr &&
4544 - (!vma || addr + len <= vma->vm_start))
4545 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4546 goto success;
4547 }
4548
4549 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4550 info.high_limit = (current->mm->start_stack - 0x00200000);
4551 info.align_mask = 0;
4552 info.align_offset = 0;
4553 + info.threadstack_offset = offset;
4554 addr = vm_unmapped_area(&info);
4555 if (!(addr & ~PAGE_MASK))
4556 goto success;
4557 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4558 index f4ca594..adc72fd6 100644
4559 --- a/arch/hexagon/include/asm/cache.h
4560 +++ b/arch/hexagon/include/asm/cache.h
4561 @@ -21,9 +21,11 @@
4562 #ifndef __ASM_CACHE_H
4563 #define __ASM_CACHE_H
4564
4565 +#include <linux/const.h>
4566 +
4567 /* Bytes per L1 cache line */
4568 -#define L1_CACHE_SHIFT (5)
4569 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4570 +#define L1_CACHE_SHIFT 5
4571 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4572
4573 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4574 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4575 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4576 index 6e6fe18..a6ae668 100644
4577 --- a/arch/ia64/include/asm/atomic.h
4578 +++ b/arch/ia64/include/asm/atomic.h
4579 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4580 #define atomic64_inc(v) atomic64_add(1, (v))
4581 #define atomic64_dec(v) atomic64_sub(1, (v))
4582
4583 +#define atomic64_read_unchecked(v) atomic64_read(v)
4584 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4585 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4586 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4587 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4588 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4589 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4590 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4591 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4592 +
4593 /* Atomic operations are already serializing */
4594 #define smp_mb__before_atomic_dec() barrier()
4595 #define smp_mb__after_atomic_dec() barrier()
4596 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4597 index 988254a..e1ee885 100644
4598 --- a/arch/ia64/include/asm/cache.h
4599 +++ b/arch/ia64/include/asm/cache.h
4600 @@ -1,6 +1,7 @@
4601 #ifndef _ASM_IA64_CACHE_H
4602 #define _ASM_IA64_CACHE_H
4603
4604 +#include <linux/const.h>
4605
4606 /*
4607 * Copyright (C) 1998-2000 Hewlett-Packard Co
4608 @@ -9,7 +10,7 @@
4609
4610 /* Bytes per L1 (data) cache line. */
4611 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4612 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4613 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4614
4615 #ifdef CONFIG_SMP
4616 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4617 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4618 index 5a83c5c..4d7f553 100644
4619 --- a/arch/ia64/include/asm/elf.h
4620 +++ b/arch/ia64/include/asm/elf.h
4621 @@ -42,6 +42,13 @@
4622 */
4623 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4624
4625 +#ifdef CONFIG_PAX_ASLR
4626 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4627 +
4628 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4629 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4630 +#endif
4631 +
4632 #define PT_IA_64_UNWIND 0x70000001
4633
4634 /* IA-64 relocations: */
4635 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4636 index 96a8d92..617a1cf 100644
4637 --- a/arch/ia64/include/asm/pgalloc.h
4638 +++ b/arch/ia64/include/asm/pgalloc.h
4639 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4640 pgd_val(*pgd_entry) = __pa(pud);
4641 }
4642
4643 +static inline void
4644 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4645 +{
4646 + pgd_populate(mm, pgd_entry, pud);
4647 +}
4648 +
4649 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4650 {
4651 return quicklist_alloc(0, GFP_KERNEL, NULL);
4652 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4653 pud_val(*pud_entry) = __pa(pmd);
4654 }
4655
4656 +static inline void
4657 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4658 +{
4659 + pud_populate(mm, pud_entry, pmd);
4660 +}
4661 +
4662 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4663 {
4664 return quicklist_alloc(0, GFP_KERNEL, NULL);
4665 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4666 index 815810c..d60bd4c 100644
4667 --- a/arch/ia64/include/asm/pgtable.h
4668 +++ b/arch/ia64/include/asm/pgtable.h
4669 @@ -12,7 +12,7 @@
4670 * David Mosberger-Tang <davidm@hpl.hp.com>
4671 */
4672
4673 -
4674 +#include <linux/const.h>
4675 #include <asm/mman.h>
4676 #include <asm/page.h>
4677 #include <asm/processor.h>
4678 @@ -142,6 +142,17 @@
4679 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4680 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4681 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4682 +
4683 +#ifdef CONFIG_PAX_PAGEEXEC
4684 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4685 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4686 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4687 +#else
4688 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4689 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4690 +# define PAGE_COPY_NOEXEC PAGE_COPY
4691 +#endif
4692 +
4693 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4694 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4695 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4696 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4697 index 54ff557..70c88b7 100644
4698 --- a/arch/ia64/include/asm/spinlock.h
4699 +++ b/arch/ia64/include/asm/spinlock.h
4700 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4701 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4702
4703 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4704 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4705 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4706 }
4707
4708 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4709 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4710 index 449c8c0..18965fb 100644
4711 --- a/arch/ia64/include/asm/uaccess.h
4712 +++ b/arch/ia64/include/asm/uaccess.h
4713 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4714 static inline unsigned long
4715 __copy_to_user (void __user *to, const void *from, unsigned long count)
4716 {
4717 + if (count > INT_MAX)
4718 + return count;
4719 +
4720 + if (!__builtin_constant_p(count))
4721 + check_object_size(from, count, true);
4722 +
4723 return __copy_user(to, (__force void __user *) from, count);
4724 }
4725
4726 static inline unsigned long
4727 __copy_from_user (void *to, const void __user *from, unsigned long count)
4728 {
4729 + if (count > INT_MAX)
4730 + return count;
4731 +
4732 + if (!__builtin_constant_p(count))
4733 + check_object_size(to, count, false);
4734 +
4735 return __copy_user((__force void __user *) to, from, count);
4736 }
4737
4738 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4739 ({ \
4740 void __user *__cu_to = (to); \
4741 const void *__cu_from = (from); \
4742 - long __cu_len = (n); \
4743 + unsigned long __cu_len = (n); \
4744 \
4745 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4746 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4747 + if (!__builtin_constant_p(n)) \
4748 + check_object_size(__cu_from, __cu_len, true); \
4749 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
4750 + } \
4751 __cu_len; \
4752 })
4753
4754 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4755 ({ \
4756 void *__cu_to = (to); \
4757 const void __user *__cu_from = (from); \
4758 - long __cu_len = (n); \
4759 + unsigned long __cu_len = (n); \
4760 \
4761 __chk_user_ptr(__cu_from); \
4762 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
4763 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
4764 + if (!__builtin_constant_p(n)) \
4765 + check_object_size(__cu_to, __cu_len, false); \
4766 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
4767 + } \
4768 __cu_len; \
4769 })
4770
4771 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
4772 index 2d67317..07d8bfa 100644
4773 --- a/arch/ia64/kernel/err_inject.c
4774 +++ b/arch/ia64/kernel/err_inject.c
4775 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
4776 return NOTIFY_OK;
4777 }
4778
4779 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
4780 +static struct notifier_block err_inject_cpu_notifier =
4781 {
4782 .notifier_call = err_inject_cpu_callback,
4783 };
4784 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
4785 index d7396db..b33e873 100644
4786 --- a/arch/ia64/kernel/mca.c
4787 +++ b/arch/ia64/kernel/mca.c
4788 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
4789 return NOTIFY_OK;
4790 }
4791
4792 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
4793 +static struct notifier_block mca_cpu_notifier = {
4794 .notifier_call = mca_cpu_callback
4795 };
4796
4797 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
4798 index 24603be..948052d 100644
4799 --- a/arch/ia64/kernel/module.c
4800 +++ b/arch/ia64/kernel/module.c
4801 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
4802 void
4803 module_free (struct module *mod, void *module_region)
4804 {
4805 - if (mod && mod->arch.init_unw_table &&
4806 - module_region == mod->module_init) {
4807 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
4808 unw_remove_unwind_table(mod->arch.init_unw_table);
4809 mod->arch.init_unw_table = NULL;
4810 }
4811 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
4812 }
4813
4814 static inline int
4815 +in_init_rx (const struct module *mod, uint64_t addr)
4816 +{
4817 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
4818 +}
4819 +
4820 +static inline int
4821 +in_init_rw (const struct module *mod, uint64_t addr)
4822 +{
4823 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
4824 +}
4825 +
4826 +static inline int
4827 in_init (const struct module *mod, uint64_t addr)
4828 {
4829 - return addr - (uint64_t) mod->module_init < mod->init_size;
4830 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
4831 +}
4832 +
4833 +static inline int
4834 +in_core_rx (const struct module *mod, uint64_t addr)
4835 +{
4836 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
4837 +}
4838 +
4839 +static inline int
4840 +in_core_rw (const struct module *mod, uint64_t addr)
4841 +{
4842 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
4843 }
4844
4845 static inline int
4846 in_core (const struct module *mod, uint64_t addr)
4847 {
4848 - return addr - (uint64_t) mod->module_core < mod->core_size;
4849 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
4850 }
4851
4852 static inline int
4853 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
4854 break;
4855
4856 case RV_BDREL:
4857 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
4858 + if (in_init_rx(mod, val))
4859 + val -= (uint64_t) mod->module_init_rx;
4860 + else if (in_init_rw(mod, val))
4861 + val -= (uint64_t) mod->module_init_rw;
4862 + else if (in_core_rx(mod, val))
4863 + val -= (uint64_t) mod->module_core_rx;
4864 + else if (in_core_rw(mod, val))
4865 + val -= (uint64_t) mod->module_core_rw;
4866 break;
4867
4868 case RV_LTV:
4869 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
4870 * addresses have been selected...
4871 */
4872 uint64_t gp;
4873 - if (mod->core_size > MAX_LTOFF)
4874 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
4875 /*
4876 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
4877 * at the end of the module.
4878 */
4879 - gp = mod->core_size - MAX_LTOFF / 2;
4880 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
4881 else
4882 - gp = mod->core_size / 2;
4883 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
4884 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
4885 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
4886 mod->arch.gp = gp;
4887 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
4888 }
4889 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
4890 index 79521d5..43dddff 100644
4891 --- a/arch/ia64/kernel/palinfo.c
4892 +++ b/arch/ia64/kernel/palinfo.c
4893 @@ -1006,7 +1006,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
4894 return NOTIFY_OK;
4895 }
4896
4897 -static struct notifier_block __refdata palinfo_cpu_notifier =
4898 +static struct notifier_block palinfo_cpu_notifier =
4899 {
4900 .notifier_call = palinfo_cpu_callback,
4901 .priority = 0,
4902 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
4903 index aa527d7..f237752 100644
4904 --- a/arch/ia64/kernel/salinfo.c
4905 +++ b/arch/ia64/kernel/salinfo.c
4906 @@ -616,7 +616,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
4907 return NOTIFY_OK;
4908 }
4909
4910 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
4911 +static struct notifier_block salinfo_cpu_notifier =
4912 {
4913 .notifier_call = salinfo_cpu_callback,
4914 .priority = 0,
4915 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
4916 index 41e33f8..65180b2 100644
4917 --- a/arch/ia64/kernel/sys_ia64.c
4918 +++ b/arch/ia64/kernel/sys_ia64.c
4919 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
4920 unsigned long align_mask = 0;
4921 struct mm_struct *mm = current->mm;
4922 struct vm_unmapped_area_info info;
4923 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4924
4925 if (len > RGN_MAP_LIMIT)
4926 return -ENOMEM;
4927 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
4928 if (REGION_NUMBER(addr) == RGN_HPAGE)
4929 addr = 0;
4930 #endif
4931 +
4932 +#ifdef CONFIG_PAX_RANDMMAP
4933 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4934 + addr = mm->free_area_cache;
4935 + else
4936 +#endif
4937 +
4938 if (!addr)
4939 addr = TASK_UNMAPPED_BASE;
4940
4941 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
4942 info.high_limit = TASK_SIZE;
4943 info.align_mask = align_mask;
4944 info.align_offset = 0;
4945 + info.threadstack_offset = offset;
4946 return vm_unmapped_area(&info);
4947 }
4948
4949 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
4950 index dc00b2c..cce53c2 100644
4951 --- a/arch/ia64/kernel/topology.c
4952 +++ b/arch/ia64/kernel/topology.c
4953 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
4954 return NOTIFY_OK;
4955 }
4956
4957 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
4958 +static struct notifier_block cache_cpu_notifier =
4959 {
4960 .notifier_call = cache_cpu_callback
4961 };
4962 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
4963 index 0ccb28f..8992469 100644
4964 --- a/arch/ia64/kernel/vmlinux.lds.S
4965 +++ b/arch/ia64/kernel/vmlinux.lds.S
4966 @@ -198,7 +198,7 @@ SECTIONS {
4967 /* Per-cpu data: */
4968 . = ALIGN(PERCPU_PAGE_SIZE);
4969 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
4970 - __phys_per_cpu_start = __per_cpu_load;
4971 + __phys_per_cpu_start = per_cpu_load;
4972 /*
4973 * ensure percpu data fits
4974 * into percpu page size
4975 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
4976 index 6cf0341..d352594 100644
4977 --- a/arch/ia64/mm/fault.c
4978 +++ b/arch/ia64/mm/fault.c
4979 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
4980 return pte_present(pte);
4981 }
4982
4983 +#ifdef CONFIG_PAX_PAGEEXEC
4984 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4985 +{
4986 + unsigned long i;
4987 +
4988 + printk(KERN_ERR "PAX: bytes at PC: ");
4989 + for (i = 0; i < 8; i++) {
4990 + unsigned int c;
4991 + if (get_user(c, (unsigned int *)pc+i))
4992 + printk(KERN_CONT "???????? ");
4993 + else
4994 + printk(KERN_CONT "%08x ", c);
4995 + }
4996 + printk("\n");
4997 +}
4998 +#endif
4999 +
5000 # define VM_READ_BIT 0
5001 # define VM_WRITE_BIT 1
5002 # define VM_EXEC_BIT 2
5003 @@ -149,8 +166,21 @@ retry:
5004 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5005 goto bad_area;
5006
5007 - if ((vma->vm_flags & mask) != mask)
5008 + if ((vma->vm_flags & mask) != mask) {
5009 +
5010 +#ifdef CONFIG_PAX_PAGEEXEC
5011 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5012 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5013 + goto bad_area;
5014 +
5015 + up_read(&mm->mmap_sem);
5016 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5017 + do_group_exit(SIGKILL);
5018 + }
5019 +#endif
5020 +
5021 goto bad_area;
5022 + }
5023
5024 /*
5025 * If for any reason at all we couldn't handle the fault, make
5026 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5027 index 76069c1..c2aa816 100644
5028 --- a/arch/ia64/mm/hugetlbpage.c
5029 +++ b/arch/ia64/mm/hugetlbpage.c
5030 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5031 unsigned long pgoff, unsigned long flags)
5032 {
5033 struct vm_unmapped_area_info info;
5034 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5035
5036 if (len > RGN_MAP_LIMIT)
5037 return -ENOMEM;
5038 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5039 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5040 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5041 info.align_offset = 0;
5042 + info.threadstack_offset = offset;
5043 return vm_unmapped_area(&info);
5044 }
5045
5046 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5047 index 20bc967..a26993e 100644
5048 --- a/arch/ia64/mm/init.c
5049 +++ b/arch/ia64/mm/init.c
5050 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5051 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5052 vma->vm_end = vma->vm_start + PAGE_SIZE;
5053 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5054 +
5055 +#ifdef CONFIG_PAX_PAGEEXEC
5056 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5057 + vma->vm_flags &= ~VM_EXEC;
5058 +
5059 +#ifdef CONFIG_PAX_MPROTECT
5060 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5061 + vma->vm_flags &= ~VM_MAYEXEC;
5062 +#endif
5063 +
5064 + }
5065 +#endif
5066 +
5067 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5068 down_write(&current->mm->mmap_sem);
5069 if (insert_vm_struct(current->mm, vma)) {
5070 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5071 index 40b3ee9..8c2c112 100644
5072 --- a/arch/m32r/include/asm/cache.h
5073 +++ b/arch/m32r/include/asm/cache.h
5074 @@ -1,8 +1,10 @@
5075 #ifndef _ASM_M32R_CACHE_H
5076 #define _ASM_M32R_CACHE_H
5077
5078 +#include <linux/const.h>
5079 +
5080 /* L1 cache line size */
5081 #define L1_CACHE_SHIFT 4
5082 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5083 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5084
5085 #endif /* _ASM_M32R_CACHE_H */
5086 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5087 index 82abd15..d95ae5d 100644
5088 --- a/arch/m32r/lib/usercopy.c
5089 +++ b/arch/m32r/lib/usercopy.c
5090 @@ -14,6 +14,9 @@
5091 unsigned long
5092 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5093 {
5094 + if ((long)n < 0)
5095 + return n;
5096 +
5097 prefetch(from);
5098 if (access_ok(VERIFY_WRITE, to, n))
5099 __copy_user(to,from,n);
5100 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5101 unsigned long
5102 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5103 {
5104 + if ((long)n < 0)
5105 + return n;
5106 +
5107 prefetchw(to);
5108 if (access_ok(VERIFY_READ, from, n))
5109 __copy_user_zeroing(to,from,n);
5110 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5111 index 0395c51..5f26031 100644
5112 --- a/arch/m68k/include/asm/cache.h
5113 +++ b/arch/m68k/include/asm/cache.h
5114 @@ -4,9 +4,11 @@
5115 #ifndef __ARCH_M68K_CACHE_H
5116 #define __ARCH_M68K_CACHE_H
5117
5118 +#include <linux/const.h>
5119 +
5120 /* bytes per L1 cache line */
5121 #define L1_CACHE_SHIFT 4
5122 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5123 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5124
5125 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5126
5127 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5128 index 3c52fa6..11b2ad8 100644
5129 --- a/arch/metag/mm/hugetlbpage.c
5130 +++ b/arch/metag/mm/hugetlbpage.c
5131 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5132 info.high_limit = TASK_SIZE;
5133 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5134 info.align_offset = 0;
5135 + info.threadstack_offset = 0;
5136 return vm_unmapped_area(&info);
5137 }
5138
5139 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5140 index 4efe96a..60e8699 100644
5141 --- a/arch/microblaze/include/asm/cache.h
5142 +++ b/arch/microblaze/include/asm/cache.h
5143 @@ -13,11 +13,12 @@
5144 #ifndef _ASM_MICROBLAZE_CACHE_H
5145 #define _ASM_MICROBLAZE_CACHE_H
5146
5147 +#include <linux/const.h>
5148 #include <asm/registers.h>
5149
5150 #define L1_CACHE_SHIFT 5
5151 /* word-granular cache in microblaze */
5152 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5153 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5154
5155 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5156
5157 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5158 index 08b6079..eb272cf 100644
5159 --- a/arch/mips/include/asm/atomic.h
5160 +++ b/arch/mips/include/asm/atomic.h
5161 @@ -21,6 +21,10 @@
5162 #include <asm/cmpxchg.h>
5163 #include <asm/war.h>
5164
5165 +#ifdef CONFIG_GENERIC_ATOMIC64
5166 +#include <asm-generic/atomic64.h>
5167 +#endif
5168 +
5169 #define ATOMIC_INIT(i) { (i) }
5170
5171 /*
5172 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5173 */
5174 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5175
5176 +#define atomic64_read_unchecked(v) atomic64_read(v)
5177 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5178 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5179 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5180 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5181 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5182 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5183 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5184 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5185 +
5186 #endif /* CONFIG_64BIT */
5187
5188 /*
5189 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5190 index b4db69f..8f3b093 100644
5191 --- a/arch/mips/include/asm/cache.h
5192 +++ b/arch/mips/include/asm/cache.h
5193 @@ -9,10 +9,11 @@
5194 #ifndef _ASM_CACHE_H
5195 #define _ASM_CACHE_H
5196
5197 +#include <linux/const.h>
5198 #include <kmalloc.h>
5199
5200 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5201 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5202 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5203
5204 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5205 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5206 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5207 index cf3ae24..238d22f 100644
5208 --- a/arch/mips/include/asm/elf.h
5209 +++ b/arch/mips/include/asm/elf.h
5210 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5211 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5212 #endif
5213
5214 +#ifdef CONFIG_PAX_ASLR
5215 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5216 +
5217 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5218 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5219 +#endif
5220 +
5221 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5222 struct linux_binprm;
5223 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5224 int uses_interp);
5225
5226 -struct mm_struct;
5227 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5228 -#define arch_randomize_brk arch_randomize_brk
5229 -
5230 #endif /* _ASM_ELF_H */
5231 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5232 index c1f6afa..38cc6e9 100644
5233 --- a/arch/mips/include/asm/exec.h
5234 +++ b/arch/mips/include/asm/exec.h
5235 @@ -12,6 +12,6 @@
5236 #ifndef _ASM_EXEC_H
5237 #define _ASM_EXEC_H
5238
5239 -extern unsigned long arch_align_stack(unsigned long sp);
5240 +#define arch_align_stack(x) ((x) & ~0xfUL)
5241
5242 #endif /* _ASM_EXEC_H */
5243 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5244 index eab99e5..607c98e 100644
5245 --- a/arch/mips/include/asm/page.h
5246 +++ b/arch/mips/include/asm/page.h
5247 @@ -96,7 +96,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5248 #ifdef CONFIG_CPU_MIPS32
5249 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5250 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5251 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5252 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5253 #else
5254 typedef struct { unsigned long long pte; } pte_t;
5255 #define pte_val(x) ((x).pte)
5256 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5257 index 881d18b..cea38bc 100644
5258 --- a/arch/mips/include/asm/pgalloc.h
5259 +++ b/arch/mips/include/asm/pgalloc.h
5260 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5261 {
5262 set_pud(pud, __pud((unsigned long)pmd));
5263 }
5264 +
5265 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5266 +{
5267 + pud_populate(mm, pud, pmd);
5268 +}
5269 #endif
5270
5271 /*
5272 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5273 index 178f792..8ebc510 100644
5274 --- a/arch/mips/include/asm/thread_info.h
5275 +++ b/arch/mips/include/asm/thread_info.h
5276 @@ -111,6 +111,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
5277 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5278 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5279 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5280 +/* li takes a 32bit immediate */
5281 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5282 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5283
5284 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5285 @@ -126,15 +128,18 @@ register struct thread_info *__current_thread_info __asm__("$28");
5286 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5287 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5288 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5289 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5290 +
5291 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5292
5293 /* work to do in syscall_trace_leave() */
5294 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5295 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5296
5297 /* work to do on interrupt/exception return */
5298 #define _TIF_WORK_MASK \
5299 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5300 /* work to do on any return to u-space */
5301 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5302 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5303
5304 #endif /* __KERNEL__ */
5305
5306 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5307 index e06f777..3244284 100644
5308 --- a/arch/mips/kernel/binfmt_elfn32.c
5309 +++ b/arch/mips/kernel/binfmt_elfn32.c
5310 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5311 #undef ELF_ET_DYN_BASE
5312 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5313
5314 +#ifdef CONFIG_PAX_ASLR
5315 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5316 +
5317 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5318 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5319 +#endif
5320 +
5321 #include <asm/processor.h>
5322 #include <linux/module.h>
5323 #include <linux/elfcore.h>
5324 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5325 index 556a435..b4fd2e3 100644
5326 --- a/arch/mips/kernel/binfmt_elfo32.c
5327 +++ b/arch/mips/kernel/binfmt_elfo32.c
5328 @@ -52,6 +52,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5329 #undef ELF_ET_DYN_BASE
5330 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5331
5332 +#ifdef CONFIG_PAX_ASLR
5333 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5334 +
5335 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5336 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5337 +#endif
5338 +
5339 #include <asm/processor.h>
5340
5341 /*
5342 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5343 index 3be4405..a799827 100644
5344 --- a/arch/mips/kernel/process.c
5345 +++ b/arch/mips/kernel/process.c
5346 @@ -461,15 +461,3 @@ unsigned long get_wchan(struct task_struct *task)
5347 out:
5348 return pc;
5349 }
5350 -
5351 -/*
5352 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5353 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5354 - */
5355 -unsigned long arch_align_stack(unsigned long sp)
5356 -{
5357 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5358 - sp -= get_random_int() & ~PAGE_MASK;
5359 -
5360 - return sp & ALMASK;
5361 -}
5362 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5363 index 9c6299c..2fb4c22 100644
5364 --- a/arch/mips/kernel/ptrace.c
5365 +++ b/arch/mips/kernel/ptrace.c
5366 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5367 return arch;
5368 }
5369
5370 +#ifdef CONFIG_GRKERNSEC_SETXID
5371 +extern void gr_delayed_cred_worker(void);
5372 +#endif
5373 +
5374 /*
5375 * Notification of system call entry/exit
5376 * - triggered by current->work.syscall_trace
5377 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5378 /* do the secure computing check first */
5379 secure_computing_strict(regs->regs[2]);
5380
5381 +#ifdef CONFIG_GRKERNSEC_SETXID
5382 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5383 + gr_delayed_cred_worker();
5384 +#endif
5385 +
5386 if (!(current->ptrace & PT_PTRACED))
5387 goto out;
5388
5389 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5390 index 9ea2964..c4329c3 100644
5391 --- a/arch/mips/kernel/scall32-o32.S
5392 +++ b/arch/mips/kernel/scall32-o32.S
5393 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5394
5395 stack_done:
5396 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5397 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5398 + li t1, _TIF_SYSCALL_WORK
5399 and t0, t1
5400 bnez t0, syscall_trace_entry # -> yes
5401
5402 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5403 index 36cfd40..b1436e0 100644
5404 --- a/arch/mips/kernel/scall64-64.S
5405 +++ b/arch/mips/kernel/scall64-64.S
5406 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5407
5408 sd a3, PT_R26(sp) # save a3 for syscall restarting
5409
5410 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5411 + li t1, _TIF_SYSCALL_WORK
5412 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5413 and t0, t1, t0
5414 bnez t0, syscall_trace_entry
5415 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5416 index 693d60b..ae0ba75 100644
5417 --- a/arch/mips/kernel/scall64-n32.S
5418 +++ b/arch/mips/kernel/scall64-n32.S
5419 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5420
5421 sd a3, PT_R26(sp) # save a3 for syscall restarting
5422
5423 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5424 + li t1, _TIF_SYSCALL_WORK
5425 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5426 and t0, t1, t0
5427 bnez t0, n32_syscall_trace_entry
5428 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5429 index af8887f..611ccb6 100644
5430 --- a/arch/mips/kernel/scall64-o32.S
5431 +++ b/arch/mips/kernel/scall64-o32.S
5432 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5433 PTR 4b, bad_stack
5434 .previous
5435
5436 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5437 + li t1, _TIF_SYSCALL_WORK
5438 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5439 and t0, t1, t0
5440 bnez t0, trace_a_syscall
5441 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5442 index 0fead53..a2c0fb5 100644
5443 --- a/arch/mips/mm/fault.c
5444 +++ b/arch/mips/mm/fault.c
5445 @@ -27,6 +27,23 @@
5446 #include <asm/highmem.h> /* For VMALLOC_END */
5447 #include <linux/kdebug.h>
5448
5449 +#ifdef CONFIG_PAX_PAGEEXEC
5450 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5451 +{
5452 + unsigned long i;
5453 +
5454 + printk(KERN_ERR "PAX: bytes at PC: ");
5455 + for (i = 0; i < 5; i++) {
5456 + unsigned int c;
5457 + if (get_user(c, (unsigned int *)pc+i))
5458 + printk(KERN_CONT "???????? ");
5459 + else
5460 + printk(KERN_CONT "%08x ", c);
5461 + }
5462 + printk("\n");
5463 +}
5464 +#endif
5465 +
5466 /*
5467 * This routine handles page faults. It determines the address,
5468 * and the problem, and then passes it off to one of the appropriate
5469 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5470 index 7e5fe27..9656513 100644
5471 --- a/arch/mips/mm/mmap.c
5472 +++ b/arch/mips/mm/mmap.c
5473 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5474 struct vm_area_struct *vma;
5475 unsigned long addr = addr0;
5476 int do_color_align;
5477 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5478 struct vm_unmapped_area_info info;
5479
5480 if (unlikely(len > TASK_SIZE))
5481 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5482 do_color_align = 1;
5483
5484 /* requesting a specific address */
5485 +
5486 +#ifdef CONFIG_PAX_RANDMMAP
5487 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5488 +#endif
5489 +
5490 if (addr) {
5491 if (do_color_align)
5492 addr = COLOUR_ALIGN(addr, pgoff);
5493 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5494 addr = PAGE_ALIGN(addr);
5495
5496 vma = find_vma(mm, addr);
5497 - if (TASK_SIZE - len >= addr &&
5498 - (!vma || addr + len <= vma->vm_start))
5499 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5500 return addr;
5501 }
5502
5503 info.length = len;
5504 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
5505 info.align_offset = pgoff << PAGE_SHIFT;
5506 + info.threadstack_offset = offset;
5507
5508 if (dir == DOWN) {
5509 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
5510 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5511 {
5512 unsigned long random_factor = 0UL;
5513
5514 +#ifdef CONFIG_PAX_RANDMMAP
5515 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5516 +#endif
5517 +
5518 if (current->flags & PF_RANDOMIZE) {
5519 random_factor = get_random_int();
5520 random_factor = random_factor << PAGE_SHIFT;
5521 @@ -157,42 +167,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5522
5523 if (mmap_is_legacy()) {
5524 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5525 +
5526 +#ifdef CONFIG_PAX_RANDMMAP
5527 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5528 + mm->mmap_base += mm->delta_mmap;
5529 +#endif
5530 +
5531 mm->get_unmapped_area = arch_get_unmapped_area;
5532 mm->unmap_area = arch_unmap_area;
5533 } else {
5534 mm->mmap_base = mmap_base(random_factor);
5535 +
5536 +#ifdef CONFIG_PAX_RANDMMAP
5537 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5538 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5539 +#endif
5540 +
5541 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5542 mm->unmap_area = arch_unmap_area_topdown;
5543 }
5544 }
5545
5546 -static inline unsigned long brk_rnd(void)
5547 -{
5548 - unsigned long rnd = get_random_int();
5549 -
5550 - rnd = rnd << PAGE_SHIFT;
5551 - /* 8MB for 32bit, 256MB for 64bit */
5552 - if (TASK_IS_32BIT_ADDR)
5553 - rnd = rnd & 0x7ffffful;
5554 - else
5555 - rnd = rnd & 0xffffffful;
5556 -
5557 - return rnd;
5558 -}
5559 -
5560 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5561 -{
5562 - unsigned long base = mm->brk;
5563 - unsigned long ret;
5564 -
5565 - ret = PAGE_ALIGN(base + brk_rnd());
5566 -
5567 - if (ret < mm->brk)
5568 - return mm->brk;
5569 -
5570 - return ret;
5571 -}
5572 -
5573 int __virt_addr_valid(const volatile void *kaddr)
5574 {
5575 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5576 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5577 index 967d144..db12197 100644
5578 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5579 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5580 @@ -11,12 +11,14 @@
5581 #ifndef _ASM_PROC_CACHE_H
5582 #define _ASM_PROC_CACHE_H
5583
5584 +#include <linux/const.h>
5585 +
5586 /* L1 cache */
5587
5588 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5589 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5590 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5591 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5592 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5593 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5594
5595 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5596 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5597 index bcb5df2..84fabd2 100644
5598 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5599 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5600 @@ -16,13 +16,15 @@
5601 #ifndef _ASM_PROC_CACHE_H
5602 #define _ASM_PROC_CACHE_H
5603
5604 +#include <linux/const.h>
5605 +
5606 /*
5607 * L1 cache
5608 */
5609 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5610 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5611 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5612 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5613 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5614 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5615
5616 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5617 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5618 index 4ce7a01..449202a 100644
5619 --- a/arch/openrisc/include/asm/cache.h
5620 +++ b/arch/openrisc/include/asm/cache.h
5621 @@ -19,11 +19,13 @@
5622 #ifndef __ASM_OPENRISC_CACHE_H
5623 #define __ASM_OPENRISC_CACHE_H
5624
5625 +#include <linux/const.h>
5626 +
5627 /* FIXME: How can we replace these with values from the CPU...
5628 * they shouldn't be hard-coded!
5629 */
5630
5631 -#define L1_CACHE_BYTES 16
5632 #define L1_CACHE_SHIFT 4
5633 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5634
5635 #endif /* __ASM_OPENRISC_CACHE_H */
5636 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5637 index f38e198..4179e38 100644
5638 --- a/arch/parisc/include/asm/atomic.h
5639 +++ b/arch/parisc/include/asm/atomic.h
5640 @@ -229,6 +229,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5641
5642 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
5643
5644 +#define atomic64_read_unchecked(v) atomic64_read(v)
5645 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5646 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5647 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5648 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5649 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5650 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5651 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5652 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5653 +
5654 #endif /* !CONFIG_64BIT */
5655
5656
5657 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5658 index 47f11c7..3420df2 100644
5659 --- a/arch/parisc/include/asm/cache.h
5660 +++ b/arch/parisc/include/asm/cache.h
5661 @@ -5,6 +5,7 @@
5662 #ifndef __ARCH_PARISC_CACHE_H
5663 #define __ARCH_PARISC_CACHE_H
5664
5665 +#include <linux/const.h>
5666
5667 /*
5668 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5669 @@ -15,13 +16,13 @@
5670 * just ruin performance.
5671 */
5672 #ifdef CONFIG_PA20
5673 -#define L1_CACHE_BYTES 64
5674 #define L1_CACHE_SHIFT 6
5675 #else
5676 -#define L1_CACHE_BYTES 32
5677 #define L1_CACHE_SHIFT 5
5678 #endif
5679
5680 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5681 +
5682 #ifndef __ASSEMBLY__
5683
5684 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5685 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
5686 index ad2b503..bdf1651 100644
5687 --- a/arch/parisc/include/asm/elf.h
5688 +++ b/arch/parisc/include/asm/elf.h
5689 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
5690
5691 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
5692
5693 +#ifdef CONFIG_PAX_ASLR
5694 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
5695 +
5696 +#define PAX_DELTA_MMAP_LEN 16
5697 +#define PAX_DELTA_STACK_LEN 16
5698 +#endif
5699 +
5700 /* This yields a mask that user programs can use to figure out what
5701 instruction set this CPU supports. This could be done in user space,
5702 but it's not easy, and we've already done it here. */
5703 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
5704 index fc987a1..6e068ef 100644
5705 --- a/arch/parisc/include/asm/pgalloc.h
5706 +++ b/arch/parisc/include/asm/pgalloc.h
5707 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5708 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
5709 }
5710
5711 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5712 +{
5713 + pgd_populate(mm, pgd, pmd);
5714 +}
5715 +
5716 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
5717 {
5718 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
5719 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
5720 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
5721 #define pmd_free(mm, x) do { } while (0)
5722 #define pgd_populate(mm, pmd, pte) BUG()
5723 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
5724
5725 #endif
5726
5727 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
5728 index 1e40d7f..a3eb445 100644
5729 --- a/arch/parisc/include/asm/pgtable.h
5730 +++ b/arch/parisc/include/asm/pgtable.h
5731 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
5732 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
5733 #define PAGE_COPY PAGE_EXECREAD
5734 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
5735 +
5736 +#ifdef CONFIG_PAX_PAGEEXEC
5737 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
5738 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5739 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5740 +#else
5741 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5742 +# define PAGE_COPY_NOEXEC PAGE_COPY
5743 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5744 +#endif
5745 +
5746 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
5747 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
5748 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
5749 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
5750 index e0a8235..ce2f1e1 100644
5751 --- a/arch/parisc/include/asm/uaccess.h
5752 +++ b/arch/parisc/include/asm/uaccess.h
5753 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
5754 const void __user *from,
5755 unsigned long n)
5756 {
5757 - int sz = __compiletime_object_size(to);
5758 + size_t sz = __compiletime_object_size(to);
5759 int ret = -EFAULT;
5760
5761 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
5762 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
5763 ret = __copy_from_user(to, from, n);
5764 else
5765 copy_from_user_overflow();
5766 diff --git a/arch/parisc/kernel/drivers.c b/arch/parisc/kernel/drivers.c
5767 index 5709c5e..14285ca 100644
5768 --- a/arch/parisc/kernel/drivers.c
5769 +++ b/arch/parisc/kernel/drivers.c
5770 @@ -394,7 +394,7 @@ EXPORT_SYMBOL(print_pci_hwpath);
5771 static void setup_bus_id(struct parisc_device *padev)
5772 {
5773 struct hardware_path path;
5774 - char name[20];
5775 + char name[28];
5776 char *output = name;
5777 int i;
5778
5779 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
5780 index 2a625fb..9908930 100644
5781 --- a/arch/parisc/kernel/module.c
5782 +++ b/arch/parisc/kernel/module.c
5783 @@ -98,16 +98,38 @@
5784
5785 /* three functions to determine where in the module core
5786 * or init pieces the location is */
5787 +static inline int in_init_rx(struct module *me, void *loc)
5788 +{
5789 + return (loc >= me->module_init_rx &&
5790 + loc < (me->module_init_rx + me->init_size_rx));
5791 +}
5792 +
5793 +static inline int in_init_rw(struct module *me, void *loc)
5794 +{
5795 + return (loc >= me->module_init_rw &&
5796 + loc < (me->module_init_rw + me->init_size_rw));
5797 +}
5798 +
5799 static inline int in_init(struct module *me, void *loc)
5800 {
5801 - return (loc >= me->module_init &&
5802 - loc <= (me->module_init + me->init_size));
5803 + return in_init_rx(me, loc) || in_init_rw(me, loc);
5804 +}
5805 +
5806 +static inline int in_core_rx(struct module *me, void *loc)
5807 +{
5808 + return (loc >= me->module_core_rx &&
5809 + loc < (me->module_core_rx + me->core_size_rx));
5810 +}
5811 +
5812 +static inline int in_core_rw(struct module *me, void *loc)
5813 +{
5814 + return (loc >= me->module_core_rw &&
5815 + loc < (me->module_core_rw + me->core_size_rw));
5816 }
5817
5818 static inline int in_core(struct module *me, void *loc)
5819 {
5820 - return (loc >= me->module_core &&
5821 - loc <= (me->module_core + me->core_size));
5822 + return in_core_rx(me, loc) || in_core_rw(me, loc);
5823 }
5824
5825 static inline int in_local(struct module *me, void *loc)
5826 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
5827 }
5828
5829 /* align things a bit */
5830 - me->core_size = ALIGN(me->core_size, 16);
5831 - me->arch.got_offset = me->core_size;
5832 - me->core_size += gots * sizeof(struct got_entry);
5833 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5834 + me->arch.got_offset = me->core_size_rw;
5835 + me->core_size_rw += gots * sizeof(struct got_entry);
5836
5837 - me->core_size = ALIGN(me->core_size, 16);
5838 - me->arch.fdesc_offset = me->core_size;
5839 - me->core_size += fdescs * sizeof(Elf_Fdesc);
5840 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5841 + me->arch.fdesc_offset = me->core_size_rw;
5842 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
5843
5844 me->arch.got_max = gots;
5845 me->arch.fdesc_max = fdescs;
5846 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5847
5848 BUG_ON(value == 0);
5849
5850 - got = me->module_core + me->arch.got_offset;
5851 + got = me->module_core_rw + me->arch.got_offset;
5852 for (i = 0; got[i].addr; i++)
5853 if (got[i].addr == value)
5854 goto out;
5855 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5856 #ifdef CONFIG_64BIT
5857 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5858 {
5859 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
5860 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
5861
5862 if (!value) {
5863 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
5864 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5865
5866 /* Create new one */
5867 fdesc->addr = value;
5868 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5869 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5870 return (Elf_Addr)fdesc;
5871 }
5872 #endif /* CONFIG_64BIT */
5873 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
5874
5875 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
5876 end = table + sechdrs[me->arch.unwind_section].sh_size;
5877 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5878 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5879
5880 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
5881 me->arch.unwind_section, table, end, gp);
5882 diff --git a/arch/parisc/kernel/setup.c b/arch/parisc/kernel/setup.c
5883 index a3328c2..3b812eb 100644
5884 --- a/arch/parisc/kernel/setup.c
5885 +++ b/arch/parisc/kernel/setup.c
5886 @@ -69,7 +69,8 @@ void __init setup_cmdline(char **cmdline_p)
5887 /* called from hpux boot loader */
5888 boot_command_line[0] = '\0';
5889 } else {
5890 - strcpy(boot_command_line, (char *)__va(boot_args[1]));
5891 + strlcpy(boot_command_line, (char *)__va(boot_args[1]),
5892 + COMMAND_LINE_SIZE);
5893
5894 #ifdef CONFIG_BLK_DEV_INITRD
5895 if (boot_args[2] != 0) /* did palo pass us a ramdisk? */
5896 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
5897 index 5dfd248..64914ac 100644
5898 --- a/arch/parisc/kernel/sys_parisc.c
5899 +++ b/arch/parisc/kernel/sys_parisc.c
5900 @@ -33,9 +33,11 @@
5901 #include <linux/utsname.h>
5902 #include <linux/personality.h>
5903
5904 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5905 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
5906 + unsigned long flags)
5907 {
5908 struct vm_unmapped_area_info info;
5909 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5910
5911 info.flags = 0;
5912 info.length = len;
5913 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5914 info.high_limit = TASK_SIZE;
5915 info.align_mask = 0;
5916 info.align_offset = 0;
5917 + info.threadstack_offset = offset;
5918 return vm_unmapped_area(&info);
5919 }
5920
5921 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
5922 return (unsigned long) mapping >> 8;
5923 }
5924
5925 -static unsigned long get_shared_area(struct address_space *mapping,
5926 - unsigned long addr, unsigned long len, unsigned long pgoff)
5927 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
5928 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
5929 {
5930 struct vm_unmapped_area_info info;
5931 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5932
5933 info.flags = 0;
5934 info.length = len;
5935 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
5936 info.high_limit = TASK_SIZE;
5937 info.align_mask = PAGE_MASK & (SHMLBA - 1);
5938 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
5939 + info.threadstack_offset = offset;
5940 return vm_unmapped_area(&info);
5941 }
5942
5943 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
5944 return -EINVAL;
5945 return addr;
5946 }
5947 - if (!addr)
5948 + if (!addr) {
5949 addr = TASK_UNMAPPED_BASE;
5950
5951 +#ifdef CONFIG_PAX_RANDMMAP
5952 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
5953 + addr += current->mm->delta_mmap;
5954 +#endif
5955 +
5956 + }
5957 +
5958 if (filp) {
5959 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
5960 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
5961 } else if(flags & MAP_SHARED) {
5962 - addr = get_shared_area(NULL, addr, len, pgoff);
5963 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
5964 } else {
5965 - addr = get_unshared_area(addr, len);
5966 + addr = get_unshared_area(filp, addr, len, flags);
5967 }
5968 return addr;
5969 }
5970 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
5971 index aeb8f8f..27a6c2f 100644
5972 --- a/arch/parisc/kernel/traps.c
5973 +++ b/arch/parisc/kernel/traps.c
5974 @@ -732,9 +732,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
5975
5976 down_read(&current->mm->mmap_sem);
5977 vma = find_vma(current->mm,regs->iaoq[0]);
5978 - if (vma && (regs->iaoq[0] >= vma->vm_start)
5979 - && (vma->vm_flags & VM_EXEC)) {
5980 -
5981 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
5982 fault_address = regs->iaoq[0];
5983 fault_space = regs->iasq[0];
5984
5985 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
5986 index f247a34..dc0f219 100644
5987 --- a/arch/parisc/mm/fault.c
5988 +++ b/arch/parisc/mm/fault.c
5989 @@ -15,6 +15,7 @@
5990 #include <linux/sched.h>
5991 #include <linux/interrupt.h>
5992 #include <linux/module.h>
5993 +#include <linux/unistd.h>
5994
5995 #include <asm/uaccess.h>
5996 #include <asm/traps.h>
5997 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
5998 static unsigned long
5999 parisc_acctyp(unsigned long code, unsigned int inst)
6000 {
6001 - if (code == 6 || code == 16)
6002 + if (code == 6 || code == 7 || code == 16)
6003 return VM_EXEC;
6004
6005 switch (inst & 0xf0000000) {
6006 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
6007 }
6008 #endif
6009
6010 +#ifdef CONFIG_PAX_PAGEEXEC
6011 +/*
6012 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
6013 + *
6014 + * returns 1 when task should be killed
6015 + * 2 when rt_sigreturn trampoline was detected
6016 + * 3 when unpatched PLT trampoline was detected
6017 + */
6018 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6019 +{
6020 +
6021 +#ifdef CONFIG_PAX_EMUPLT
6022 + int err;
6023 +
6024 + do { /* PaX: unpatched PLT emulation */
6025 + unsigned int bl, depwi;
6026 +
6027 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6028 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6029 +
6030 + if (err)
6031 + break;
6032 +
6033 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6034 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6035 +
6036 + err = get_user(ldw, (unsigned int *)addr);
6037 + err |= get_user(bv, (unsigned int *)(addr+4));
6038 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6039 +
6040 + if (err)
6041 + break;
6042 +
6043 + if (ldw == 0x0E801096U &&
6044 + bv == 0xEAC0C000U &&
6045 + ldw2 == 0x0E881095U)
6046 + {
6047 + unsigned int resolver, map;
6048 +
6049 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6050 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6051 + if (err)
6052 + break;
6053 +
6054 + regs->gr[20] = instruction_pointer(regs)+8;
6055 + regs->gr[21] = map;
6056 + regs->gr[22] = resolver;
6057 + regs->iaoq[0] = resolver | 3UL;
6058 + regs->iaoq[1] = regs->iaoq[0] + 4;
6059 + return 3;
6060 + }
6061 + }
6062 + } while (0);
6063 +#endif
6064 +
6065 +#ifdef CONFIG_PAX_EMUTRAMP
6066 +
6067 +#ifndef CONFIG_PAX_EMUSIGRT
6068 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6069 + return 1;
6070 +#endif
6071 +
6072 + do { /* PaX: rt_sigreturn emulation */
6073 + unsigned int ldi1, ldi2, bel, nop;
6074 +
6075 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6076 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6077 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6078 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6079 +
6080 + if (err)
6081 + break;
6082 +
6083 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6084 + ldi2 == 0x3414015AU &&
6085 + bel == 0xE4008200U &&
6086 + nop == 0x08000240U)
6087 + {
6088 + regs->gr[25] = (ldi1 & 2) >> 1;
6089 + regs->gr[20] = __NR_rt_sigreturn;
6090 + regs->gr[31] = regs->iaoq[1] + 16;
6091 + regs->sr[0] = regs->iasq[1];
6092 + regs->iaoq[0] = 0x100UL;
6093 + regs->iaoq[1] = regs->iaoq[0] + 4;
6094 + regs->iasq[0] = regs->sr[2];
6095 + regs->iasq[1] = regs->sr[2];
6096 + return 2;
6097 + }
6098 + } while (0);
6099 +#endif
6100 +
6101 + return 1;
6102 +}
6103 +
6104 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6105 +{
6106 + unsigned long i;
6107 +
6108 + printk(KERN_ERR "PAX: bytes at PC: ");
6109 + for (i = 0; i < 5; i++) {
6110 + unsigned int c;
6111 + if (get_user(c, (unsigned int *)pc+i))
6112 + printk(KERN_CONT "???????? ");
6113 + else
6114 + printk(KERN_CONT "%08x ", c);
6115 + }
6116 + printk("\n");
6117 +}
6118 +#endif
6119 +
6120 int fixup_exception(struct pt_regs *regs)
6121 {
6122 const struct exception_table_entry *fix;
6123 @@ -194,8 +305,33 @@ good_area:
6124
6125 acc_type = parisc_acctyp(code,regs->iir);
6126
6127 - if ((vma->vm_flags & acc_type) != acc_type)
6128 + if ((vma->vm_flags & acc_type) != acc_type) {
6129 +
6130 +#ifdef CONFIG_PAX_PAGEEXEC
6131 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6132 + (address & ~3UL) == instruction_pointer(regs))
6133 + {
6134 + up_read(&mm->mmap_sem);
6135 + switch (pax_handle_fetch_fault(regs)) {
6136 +
6137 +#ifdef CONFIG_PAX_EMUPLT
6138 + case 3:
6139 + return;
6140 +#endif
6141 +
6142 +#ifdef CONFIG_PAX_EMUTRAMP
6143 + case 2:
6144 + return;
6145 +#endif
6146 +
6147 + }
6148 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6149 + do_group_exit(SIGKILL);
6150 + }
6151 +#endif
6152 +
6153 goto bad_area;
6154 + }
6155
6156 /*
6157 * If for any reason at all we couldn't handle the fault, make
6158 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6159 index e3b1d41..8e81edf 100644
6160 --- a/arch/powerpc/include/asm/atomic.h
6161 +++ b/arch/powerpc/include/asm/atomic.h
6162 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6163 return t1;
6164 }
6165
6166 +#define atomic64_read_unchecked(v) atomic64_read(v)
6167 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6168 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6169 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6170 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6171 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6172 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6173 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6174 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6175 +
6176 #endif /* __powerpc64__ */
6177
6178 #endif /* __KERNEL__ */
6179 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6180 index 9e495c9..b6878e5 100644
6181 --- a/arch/powerpc/include/asm/cache.h
6182 +++ b/arch/powerpc/include/asm/cache.h
6183 @@ -3,6 +3,7 @@
6184
6185 #ifdef __KERNEL__
6186
6187 +#include <linux/const.h>
6188
6189 /* bytes per L1 cache line */
6190 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6191 @@ -22,7 +23,7 @@
6192 #define L1_CACHE_SHIFT 7
6193 #endif
6194
6195 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6196 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6197
6198 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6199
6200 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6201 index ac9790f..6d30741 100644
6202 --- a/arch/powerpc/include/asm/elf.h
6203 +++ b/arch/powerpc/include/asm/elf.h
6204 @@ -28,8 +28,19 @@
6205 the loader. We need to make sure that it is out of the way of the program
6206 that it will "exec", and that there is sufficient room for the brk. */
6207
6208 -extern unsigned long randomize_et_dyn(unsigned long base);
6209 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6210 +#define ELF_ET_DYN_BASE (0x20000000)
6211 +
6212 +#ifdef CONFIG_PAX_ASLR
6213 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6214 +
6215 +#ifdef __powerpc64__
6216 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6217 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6218 +#else
6219 +#define PAX_DELTA_MMAP_LEN 15
6220 +#define PAX_DELTA_STACK_LEN 15
6221 +#endif
6222 +#endif
6223
6224 /*
6225 * Our registers are always unsigned longs, whether we're a 32 bit
6226 @@ -122,10 +133,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6227 (0x7ff >> (PAGE_SHIFT - 12)) : \
6228 (0x3ffff >> (PAGE_SHIFT - 12)))
6229
6230 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6231 -#define arch_randomize_brk arch_randomize_brk
6232 -
6233 -
6234 #ifdef CONFIG_SPU_BASE
6235 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6236 #define NT_SPU 1
6237 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6238 index 8196e9c..d83a9f3 100644
6239 --- a/arch/powerpc/include/asm/exec.h
6240 +++ b/arch/powerpc/include/asm/exec.h
6241 @@ -4,6 +4,6 @@
6242 #ifndef _ASM_POWERPC_EXEC_H
6243 #define _ASM_POWERPC_EXEC_H
6244
6245 -extern unsigned long arch_align_stack(unsigned long sp);
6246 +#define arch_align_stack(x) ((x) & ~0xfUL)
6247
6248 #endif /* _ASM_POWERPC_EXEC_H */
6249 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6250 index 5acabbd..7ea14fa 100644
6251 --- a/arch/powerpc/include/asm/kmap_types.h
6252 +++ b/arch/powerpc/include/asm/kmap_types.h
6253 @@ -10,7 +10,7 @@
6254 * 2 of the License, or (at your option) any later version.
6255 */
6256
6257 -#define KM_TYPE_NR 16
6258 +#define KM_TYPE_NR 17
6259
6260 #endif /* __KERNEL__ */
6261 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6262 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6263 index 8565c25..2865190 100644
6264 --- a/arch/powerpc/include/asm/mman.h
6265 +++ b/arch/powerpc/include/asm/mman.h
6266 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6267 }
6268 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6269
6270 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6271 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6272 {
6273 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6274 }
6275 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6276 index f072e97..b436dee 100644
6277 --- a/arch/powerpc/include/asm/page.h
6278 +++ b/arch/powerpc/include/asm/page.h
6279 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6280 * and needs to be executable. This means the whole heap ends
6281 * up being executable.
6282 */
6283 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6284 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6285 +#define VM_DATA_DEFAULT_FLAGS32 \
6286 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6287 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6288
6289 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6290 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6291 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6292 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6293 #endif
6294
6295 +#define ktla_ktva(addr) (addr)
6296 +#define ktva_ktla(addr) (addr)
6297 +
6298 /*
6299 * Use the top bit of the higher-level page table entries to indicate whether
6300 * the entries we point to contain hugepages. This works because we know that
6301 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6302 index cd915d6..c10cee8 100644
6303 --- a/arch/powerpc/include/asm/page_64.h
6304 +++ b/arch/powerpc/include/asm/page_64.h
6305 @@ -154,15 +154,18 @@ do { \
6306 * stack by default, so in the absence of a PT_GNU_STACK program header
6307 * we turn execute permission off.
6308 */
6309 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6310 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6311 +#define VM_STACK_DEFAULT_FLAGS32 \
6312 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6313 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6314
6315 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6316 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6317
6318 +#ifndef CONFIG_PAX_PAGEEXEC
6319 #define VM_STACK_DEFAULT_FLAGS \
6320 (is_32bit_task() ? \
6321 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6322 +#endif
6323
6324 #include <asm-generic/getorder.h>
6325
6326 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6327 index 292725c..f87ae14 100644
6328 --- a/arch/powerpc/include/asm/pgalloc-64.h
6329 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6330 @@ -50,6 +50,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6331 #ifndef CONFIG_PPC_64K_PAGES
6332
6333 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6334 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6335
6336 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6337 {
6338 @@ -67,6 +68,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6339 pud_set(pud, (unsigned long)pmd);
6340 }
6341
6342 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6343 +{
6344 + pud_populate(mm, pud, pmd);
6345 +}
6346 +
6347 #define pmd_populate(mm, pmd, pte_page) \
6348 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6349 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6350 @@ -76,6 +82,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6351 #else /* CONFIG_PPC_64K_PAGES */
6352
6353 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6354 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6355
6356 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6357 pte_t *pte)
6358 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6359 index a9cbd3b..3b67efa 100644
6360 --- a/arch/powerpc/include/asm/pgtable.h
6361 +++ b/arch/powerpc/include/asm/pgtable.h
6362 @@ -2,6 +2,7 @@
6363 #define _ASM_POWERPC_PGTABLE_H
6364 #ifdef __KERNEL__
6365
6366 +#include <linux/const.h>
6367 #ifndef __ASSEMBLY__
6368 #include <asm/processor.h> /* For TASK_SIZE */
6369 #include <asm/mmu.h>
6370 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6371 index 4aad413..85d86bf 100644
6372 --- a/arch/powerpc/include/asm/pte-hash32.h
6373 +++ b/arch/powerpc/include/asm/pte-hash32.h
6374 @@ -21,6 +21,7 @@
6375 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6376 #define _PAGE_USER 0x004 /* usermode access allowed */
6377 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6378 +#define _PAGE_EXEC _PAGE_GUARDED
6379 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6380 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6381 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6382 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6383 index c9c67fc..e10c012 100644
6384 --- a/arch/powerpc/include/asm/reg.h
6385 +++ b/arch/powerpc/include/asm/reg.h
6386 @@ -245,6 +245,7 @@
6387 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6388 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6389 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6390 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6391 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6392 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6393 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6394 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
6395 index 195ce2a..ab5c614 100644
6396 --- a/arch/powerpc/include/asm/smp.h
6397 +++ b/arch/powerpc/include/asm/smp.h
6398 @@ -50,7 +50,7 @@ struct smp_ops_t {
6399 int (*cpu_disable)(void);
6400 void (*cpu_die)(unsigned int nr);
6401 int (*cpu_bootable)(unsigned int nr);
6402 -};
6403 +} __no_const;
6404
6405 extern void smp_send_debugger_break(void);
6406 extern void start_secondary_resume(void);
6407 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6408 index 406b7b9..af63426 100644
6409 --- a/arch/powerpc/include/asm/thread_info.h
6410 +++ b/arch/powerpc/include/asm/thread_info.h
6411 @@ -97,7 +97,6 @@ static inline struct thread_info *current_thread_info(void)
6412 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6413 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6414 #define TIF_SINGLESTEP 8 /* singlestepping active */
6415 -#define TIF_MEMDIE 9 /* is terminating due to OOM killer */
6416 #define TIF_SECCOMP 10 /* secure computing */
6417 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
6418 #define TIF_NOERROR 12 /* Force successful syscall return */
6419 @@ -106,6 +105,9 @@ static inline struct thread_info *current_thread_info(void)
6420 #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
6421 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6422 for stack store? */
6423 +#define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6424 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6425 +#define TIF_GRSEC_SETXID 9 /* update credentials on syscall entry/exit */
6426
6427 /* as above, but as bit values */
6428 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6429 @@ -124,8 +126,10 @@ static inline struct thread_info *current_thread_info(void)
6430 #define _TIF_UPROBE (1<<TIF_UPROBE)
6431 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6432 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6433 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6434 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6435 - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
6436 + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6437 + _TIF_GRSEC_SETXID)
6438
6439 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6440 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6441 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6442 index 4db4959..aba5c41 100644
6443 --- a/arch/powerpc/include/asm/uaccess.h
6444 +++ b/arch/powerpc/include/asm/uaccess.h
6445 @@ -318,52 +318,6 @@ do { \
6446 extern unsigned long __copy_tofrom_user(void __user *to,
6447 const void __user *from, unsigned long size);
6448
6449 -#ifndef __powerpc64__
6450 -
6451 -static inline unsigned long copy_from_user(void *to,
6452 - const void __user *from, unsigned long n)
6453 -{
6454 - unsigned long over;
6455 -
6456 - if (access_ok(VERIFY_READ, from, n))
6457 - return __copy_tofrom_user((__force void __user *)to, from, n);
6458 - if ((unsigned long)from < TASK_SIZE) {
6459 - over = (unsigned long)from + n - TASK_SIZE;
6460 - return __copy_tofrom_user((__force void __user *)to, from,
6461 - n - over) + over;
6462 - }
6463 - return n;
6464 -}
6465 -
6466 -static inline unsigned long copy_to_user(void __user *to,
6467 - const void *from, unsigned long n)
6468 -{
6469 - unsigned long over;
6470 -
6471 - if (access_ok(VERIFY_WRITE, to, n))
6472 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6473 - if ((unsigned long)to < TASK_SIZE) {
6474 - over = (unsigned long)to + n - TASK_SIZE;
6475 - return __copy_tofrom_user(to, (__force void __user *)from,
6476 - n - over) + over;
6477 - }
6478 - return n;
6479 -}
6480 -
6481 -#else /* __powerpc64__ */
6482 -
6483 -#define __copy_in_user(to, from, size) \
6484 - __copy_tofrom_user((to), (from), (size))
6485 -
6486 -extern unsigned long copy_from_user(void *to, const void __user *from,
6487 - unsigned long n);
6488 -extern unsigned long copy_to_user(void __user *to, const void *from,
6489 - unsigned long n);
6490 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6491 - unsigned long n);
6492 -
6493 -#endif /* __powerpc64__ */
6494 -
6495 static inline unsigned long __copy_from_user_inatomic(void *to,
6496 const void __user *from, unsigned long n)
6497 {
6498 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6499 if (ret == 0)
6500 return 0;
6501 }
6502 +
6503 + if (!__builtin_constant_p(n))
6504 + check_object_size(to, n, false);
6505 +
6506 return __copy_tofrom_user((__force void __user *)to, from, n);
6507 }
6508
6509 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6510 if (ret == 0)
6511 return 0;
6512 }
6513 +
6514 + if (!__builtin_constant_p(n))
6515 + check_object_size(from, n, true);
6516 +
6517 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6518 }
6519
6520 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6521 return __copy_to_user_inatomic(to, from, size);
6522 }
6523
6524 +#ifndef __powerpc64__
6525 +
6526 +static inline unsigned long __must_check copy_from_user(void *to,
6527 + const void __user *from, unsigned long n)
6528 +{
6529 + unsigned long over;
6530 +
6531 + if ((long)n < 0)
6532 + return n;
6533 +
6534 + if (access_ok(VERIFY_READ, from, n)) {
6535 + if (!__builtin_constant_p(n))
6536 + check_object_size(to, n, false);
6537 + return __copy_tofrom_user((__force void __user *)to, from, n);
6538 + }
6539 + if ((unsigned long)from < TASK_SIZE) {
6540 + over = (unsigned long)from + n - TASK_SIZE;
6541 + if (!__builtin_constant_p(n - over))
6542 + check_object_size(to, n - over, false);
6543 + return __copy_tofrom_user((__force void __user *)to, from,
6544 + n - over) + over;
6545 + }
6546 + return n;
6547 +}
6548 +
6549 +static inline unsigned long __must_check copy_to_user(void __user *to,
6550 + const void *from, unsigned long n)
6551 +{
6552 + unsigned long over;
6553 +
6554 + if ((long)n < 0)
6555 + return n;
6556 +
6557 + if (access_ok(VERIFY_WRITE, to, n)) {
6558 + if (!__builtin_constant_p(n))
6559 + check_object_size(from, n, true);
6560 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6561 + }
6562 + if ((unsigned long)to < TASK_SIZE) {
6563 + over = (unsigned long)to + n - TASK_SIZE;
6564 + if (!__builtin_constant_p(n))
6565 + check_object_size(from, n - over, true);
6566 + return __copy_tofrom_user(to, (__force void __user *)from,
6567 + n - over) + over;
6568 + }
6569 + return n;
6570 +}
6571 +
6572 +#else /* __powerpc64__ */
6573 +
6574 +#define __copy_in_user(to, from, size) \
6575 + __copy_tofrom_user((to), (from), (size))
6576 +
6577 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6578 +{
6579 + if ((long)n < 0 || n > INT_MAX)
6580 + return n;
6581 +
6582 + if (!__builtin_constant_p(n))
6583 + check_object_size(to, n, false);
6584 +
6585 + if (likely(access_ok(VERIFY_READ, from, n)))
6586 + n = __copy_from_user(to, from, n);
6587 + else
6588 + memset(to, 0, n);
6589 + return n;
6590 +}
6591 +
6592 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6593 +{
6594 + if ((long)n < 0 || n > INT_MAX)
6595 + return n;
6596 +
6597 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6598 + if (!__builtin_constant_p(n))
6599 + check_object_size(from, n, true);
6600 + n = __copy_to_user(to, from, n);
6601 + }
6602 + return n;
6603 +}
6604 +
6605 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6606 + unsigned long n);
6607 +
6608 +#endif /* __powerpc64__ */
6609 +
6610 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6611
6612 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6613 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6614 index ae54553..cf2184d 100644
6615 --- a/arch/powerpc/kernel/exceptions-64e.S
6616 +++ b/arch/powerpc/kernel/exceptions-64e.S
6617 @@ -716,6 +716,7 @@ storage_fault_common:
6618 std r14,_DAR(r1)
6619 std r15,_DSISR(r1)
6620 addi r3,r1,STACK_FRAME_OVERHEAD
6621 + bl .save_nvgprs
6622 mr r4,r14
6623 mr r5,r15
6624 ld r14,PACA_EXGEN+EX_R14(r13)
6625 @@ -724,8 +725,7 @@ storage_fault_common:
6626 cmpdi r3,0
6627 bne- 1f
6628 b .ret_from_except_lite
6629 -1: bl .save_nvgprs
6630 - mr r5,r3
6631 +1: mr r5,r3
6632 addi r3,r1,STACK_FRAME_OVERHEAD
6633 ld r4,_DAR(r1)
6634 bl .bad_page_fault
6635 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6636 index 3bbe7ed..14ec3eb 100644
6637 --- a/arch/powerpc/kernel/exceptions-64s.S
6638 +++ b/arch/powerpc/kernel/exceptions-64s.S
6639 @@ -1390,10 +1390,10 @@ handle_page_fault:
6640 11: ld r4,_DAR(r1)
6641 ld r5,_DSISR(r1)
6642 addi r3,r1,STACK_FRAME_OVERHEAD
6643 + bl .save_nvgprs
6644 bl .do_page_fault
6645 cmpdi r3,0
6646 beq+ 12f
6647 - bl .save_nvgprs
6648 mr r5,r3
6649 addi r3,r1,STACK_FRAME_OVERHEAD
6650 lwz r4,_DAR(r1)
6651 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6652 index 2e3200c..72095ce 100644
6653 --- a/arch/powerpc/kernel/module_32.c
6654 +++ b/arch/powerpc/kernel/module_32.c
6655 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6656 me->arch.core_plt_section = i;
6657 }
6658 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6659 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6660 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
6661 return -ENOEXEC;
6662 }
6663
6664 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
6665
6666 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
6667 /* Init, or core PLT? */
6668 - if (location >= mod->module_core
6669 - && location < mod->module_core + mod->core_size)
6670 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
6671 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
6672 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
6673 - else
6674 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
6675 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
6676 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
6677 + else {
6678 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
6679 + return ~0UL;
6680 + }
6681
6682 /* Find this entry, or if that fails, the next avail. entry */
6683 while (entry->jump[0]) {
6684 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
6685 index 16e77a8..4501b41 100644
6686 --- a/arch/powerpc/kernel/process.c
6687 +++ b/arch/powerpc/kernel/process.c
6688 @@ -870,8 +870,8 @@ void show_regs(struct pt_regs * regs)
6689 * Lookup NIP late so we have the best change of getting the
6690 * above info out without failing
6691 */
6692 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
6693 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
6694 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
6695 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
6696 #endif
6697 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
6698 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
6699 @@ -1330,10 +1330,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6700 newsp = stack[0];
6701 ip = stack[STACK_FRAME_LR_SAVE];
6702 if (!firstframe || ip != lr) {
6703 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
6704 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
6705 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6706 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
6707 - printk(" (%pS)",
6708 + printk(" (%pA)",
6709 (void *)current->ret_stack[curr_frame].ret);
6710 curr_frame--;
6711 }
6712 @@ -1353,7 +1353,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6713 struct pt_regs *regs = (struct pt_regs *)
6714 (sp + STACK_FRAME_OVERHEAD);
6715 lr = regs->link;
6716 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
6717 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
6718 regs->trap, (void *)regs->nip, (void *)lr);
6719 firstframe = 1;
6720 }
6721 @@ -1395,58 +1395,3 @@ void __ppc64_runlatch_off(void)
6722 mtspr(SPRN_CTRLT, ctrl);
6723 }
6724 #endif /* CONFIG_PPC64 */
6725 -
6726 -unsigned long arch_align_stack(unsigned long sp)
6727 -{
6728 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6729 - sp -= get_random_int() & ~PAGE_MASK;
6730 - return sp & ~0xf;
6731 -}
6732 -
6733 -static inline unsigned long brk_rnd(void)
6734 -{
6735 - unsigned long rnd = 0;
6736 -
6737 - /* 8MB for 32bit, 1GB for 64bit */
6738 - if (is_32bit_task())
6739 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
6740 - else
6741 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
6742 -
6743 - return rnd << PAGE_SHIFT;
6744 -}
6745 -
6746 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6747 -{
6748 - unsigned long base = mm->brk;
6749 - unsigned long ret;
6750 -
6751 -#ifdef CONFIG_PPC_STD_MMU_64
6752 - /*
6753 - * If we are using 1TB segments and we are allowed to randomise
6754 - * the heap, we can put it above 1TB so it is backed by a 1TB
6755 - * segment. Otherwise the heap will be in the bottom 1TB
6756 - * which always uses 256MB segments and this may result in a
6757 - * performance penalty.
6758 - */
6759 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
6760 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
6761 -#endif
6762 -
6763 - ret = PAGE_ALIGN(base + brk_rnd());
6764 -
6765 - if (ret < mm->brk)
6766 - return mm->brk;
6767 -
6768 - return ret;
6769 -}
6770 -
6771 -unsigned long randomize_et_dyn(unsigned long base)
6772 -{
6773 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
6774 -
6775 - if (ret < base)
6776 - return base;
6777 -
6778 - return ret;
6779 -}
6780 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
6781 index f9b30c6..d72e7a3 100644
6782 --- a/arch/powerpc/kernel/ptrace.c
6783 +++ b/arch/powerpc/kernel/ptrace.c
6784 @@ -1771,6 +1771,10 @@ long arch_ptrace(struct task_struct *child, long request,
6785 return ret;
6786 }
6787
6788 +#ifdef CONFIG_GRKERNSEC_SETXID
6789 +extern void gr_delayed_cred_worker(void);
6790 +#endif
6791 +
6792 /*
6793 * We must return the syscall number to actually look up in the table.
6794 * This can be -1L to skip running any syscall at all.
6795 @@ -1781,6 +1785,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
6796
6797 secure_computing_strict(regs->gpr[0]);
6798
6799 +#ifdef CONFIG_GRKERNSEC_SETXID
6800 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6801 + gr_delayed_cred_worker();
6802 +#endif
6803 +
6804 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
6805 tracehook_report_syscall_entry(regs))
6806 /*
6807 @@ -1815,6 +1824,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
6808 {
6809 int step;
6810
6811 +#ifdef CONFIG_GRKERNSEC_SETXID
6812 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6813 + gr_delayed_cred_worker();
6814 +#endif
6815 +
6816 audit_syscall_exit(regs);
6817
6818 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
6819 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
6820 index 95068bf..9ba1814 100644
6821 --- a/arch/powerpc/kernel/signal_32.c
6822 +++ b/arch/powerpc/kernel/signal_32.c
6823 @@ -982,7 +982,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
6824 /* Save user registers on the stack */
6825 frame = &rt_sf->uc.uc_mcontext;
6826 addr = frame;
6827 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
6828 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6829 sigret = 0;
6830 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
6831 } else {
6832 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
6833 index c179428..58acdaa 100644
6834 --- a/arch/powerpc/kernel/signal_64.c
6835 +++ b/arch/powerpc/kernel/signal_64.c
6836 @@ -758,7 +758,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
6837 #endif
6838
6839 /* Set up to return from userspace. */
6840 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
6841 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6842 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
6843 } else {
6844 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
6845 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
6846 index 3ce1f86..c30e629 100644
6847 --- a/arch/powerpc/kernel/sysfs.c
6848 +++ b/arch/powerpc/kernel/sysfs.c
6849 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
6850 return NOTIFY_OK;
6851 }
6852
6853 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
6854 +static struct notifier_block sysfs_cpu_nb = {
6855 .notifier_call = sysfs_cpu_notify,
6856 };
6857
6858 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
6859 index 83efa2f..6bb5839 100644
6860 --- a/arch/powerpc/kernel/traps.c
6861 +++ b/arch/powerpc/kernel/traps.c
6862 @@ -141,6 +141,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
6863 return flags;
6864 }
6865
6866 +extern void gr_handle_kernel_exploit(void);
6867 +
6868 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6869 int signr)
6870 {
6871 @@ -190,6 +192,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6872 panic("Fatal exception in interrupt");
6873 if (panic_on_oops)
6874 panic("Fatal exception");
6875 +
6876 + gr_handle_kernel_exploit();
6877 +
6878 do_exit(signr);
6879 }
6880
6881 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
6882 index 1b2076f..835e4be 100644
6883 --- a/arch/powerpc/kernel/vdso.c
6884 +++ b/arch/powerpc/kernel/vdso.c
6885 @@ -34,6 +34,7 @@
6886 #include <asm/firmware.h>
6887 #include <asm/vdso.h>
6888 #include <asm/vdso_datapage.h>
6889 +#include <asm/mman.h>
6890
6891 #include "setup.h"
6892
6893 @@ -218,7 +219,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6894 vdso_base = VDSO32_MBASE;
6895 #endif
6896
6897 - current->mm->context.vdso_base = 0;
6898 + current->mm->context.vdso_base = ~0UL;
6899
6900 /* vDSO has a problem and was disabled, just don't "enable" it for the
6901 * process
6902 @@ -238,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6903 vdso_base = get_unmapped_area(NULL, vdso_base,
6904 (vdso_pages << PAGE_SHIFT) +
6905 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
6906 - 0, 0);
6907 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
6908 if (IS_ERR_VALUE(vdso_base)) {
6909 rc = vdso_base;
6910 goto fail_mmapsem;
6911 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
6912 index 5eea6f3..5d10396 100644
6913 --- a/arch/powerpc/lib/usercopy_64.c
6914 +++ b/arch/powerpc/lib/usercopy_64.c
6915 @@ -9,22 +9,6 @@
6916 #include <linux/module.h>
6917 #include <asm/uaccess.h>
6918
6919 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
6920 -{
6921 - if (likely(access_ok(VERIFY_READ, from, n)))
6922 - n = __copy_from_user(to, from, n);
6923 - else
6924 - memset(to, 0, n);
6925 - return n;
6926 -}
6927 -
6928 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
6929 -{
6930 - if (likely(access_ok(VERIFY_WRITE, to, n)))
6931 - n = __copy_to_user(to, from, n);
6932 - return n;
6933 -}
6934 -
6935 unsigned long copy_in_user(void __user *to, const void __user *from,
6936 unsigned long n)
6937 {
6938 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
6939 return n;
6940 }
6941
6942 -EXPORT_SYMBOL(copy_from_user);
6943 -EXPORT_SYMBOL(copy_to_user);
6944 EXPORT_SYMBOL(copy_in_user);
6945
6946 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
6947 index 229951f..cdeca42 100644
6948 --- a/arch/powerpc/mm/fault.c
6949 +++ b/arch/powerpc/mm/fault.c
6950 @@ -32,6 +32,10 @@
6951 #include <linux/perf_event.h>
6952 #include <linux/magic.h>
6953 #include <linux/ratelimit.h>
6954 +#include <linux/slab.h>
6955 +#include <linux/pagemap.h>
6956 +#include <linux/compiler.h>
6957 +#include <linux/unistd.h>
6958
6959 #include <asm/firmware.h>
6960 #include <asm/page.h>
6961 @@ -68,6 +72,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
6962 }
6963 #endif
6964
6965 +#ifdef CONFIG_PAX_PAGEEXEC
6966 +/*
6967 + * PaX: decide what to do with offenders (regs->nip = fault address)
6968 + *
6969 + * returns 1 when task should be killed
6970 + */
6971 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6972 +{
6973 + return 1;
6974 +}
6975 +
6976 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6977 +{
6978 + unsigned long i;
6979 +
6980 + printk(KERN_ERR "PAX: bytes at PC: ");
6981 + for (i = 0; i < 5; i++) {
6982 + unsigned int c;
6983 + if (get_user(c, (unsigned int __user *)pc+i))
6984 + printk(KERN_CONT "???????? ");
6985 + else
6986 + printk(KERN_CONT "%08x ", c);
6987 + }
6988 + printk("\n");
6989 +}
6990 +#endif
6991 +
6992 /*
6993 * Check whether the instruction at regs->nip is a store using
6994 * an update addressing form which will update r1.
6995 @@ -213,7 +244,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
6996 * indicate errors in DSISR but can validly be set in SRR1.
6997 */
6998 if (trap == 0x400)
6999 - error_code &= 0x48200000;
7000 + error_code &= 0x58200000;
7001 else
7002 is_write = error_code & DSISR_ISSTORE;
7003 #else
7004 @@ -364,7 +395,7 @@ good_area:
7005 * "undefined". Of those that can be set, this is the only
7006 * one which seems bad.
7007 */
7008 - if (error_code & 0x10000000)
7009 + if (error_code & DSISR_GUARDED)
7010 /* Guarded storage error. */
7011 goto bad_area;
7012 #endif /* CONFIG_8xx */
7013 @@ -379,7 +410,7 @@ good_area:
7014 * processors use the same I/D cache coherency mechanism
7015 * as embedded.
7016 */
7017 - if (error_code & DSISR_PROTFAULT)
7018 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
7019 goto bad_area;
7020 #endif /* CONFIG_PPC_STD_MMU */
7021
7022 @@ -462,6 +493,23 @@ bad_area:
7023 bad_area_nosemaphore:
7024 /* User mode accesses cause a SIGSEGV */
7025 if (user_mode(regs)) {
7026 +
7027 +#ifdef CONFIG_PAX_PAGEEXEC
7028 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7029 +#ifdef CONFIG_PPC_STD_MMU
7030 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7031 +#else
7032 + if (is_exec && regs->nip == address) {
7033 +#endif
7034 + switch (pax_handle_fetch_fault(regs)) {
7035 + }
7036 +
7037 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7038 + do_group_exit(SIGKILL);
7039 + }
7040 + }
7041 +#endif
7042 +
7043 _exception(SIGSEGV, regs, code, address);
7044 return 0;
7045 }
7046 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7047 index 67a42ed..cd463e0 100644
7048 --- a/arch/powerpc/mm/mmap_64.c
7049 +++ b/arch/powerpc/mm/mmap_64.c
7050 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7051 {
7052 unsigned long rnd = 0;
7053
7054 +#ifdef CONFIG_PAX_RANDMMAP
7055 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7056 +#endif
7057 +
7058 if (current->flags & PF_RANDOMIZE) {
7059 /* 8MB for 32bit, 1GB for 64bit */
7060 if (is_32bit_task())
7061 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7062 */
7063 if (mmap_is_legacy()) {
7064 mm->mmap_base = TASK_UNMAPPED_BASE;
7065 +
7066 +#ifdef CONFIG_PAX_RANDMMAP
7067 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7068 + mm->mmap_base += mm->delta_mmap;
7069 +#endif
7070 +
7071 mm->get_unmapped_area = arch_get_unmapped_area;
7072 mm->unmap_area = arch_unmap_area;
7073 } else {
7074 mm->mmap_base = mmap_base();
7075 +
7076 +#ifdef CONFIG_PAX_RANDMMAP
7077 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7078 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7079 +#endif
7080 +
7081 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7082 mm->unmap_area = arch_unmap_area_topdown;
7083 }
7084 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7085 index e779642..e5bb889 100644
7086 --- a/arch/powerpc/mm/mmu_context_nohash.c
7087 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7088 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7089 return NOTIFY_OK;
7090 }
7091
7092 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7093 +static struct notifier_block mmu_context_cpu_nb = {
7094 .notifier_call = mmu_context_cpu_notify,
7095 };
7096
7097 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7098 index 6a252c4..3024d81 100644
7099 --- a/arch/powerpc/mm/numa.c
7100 +++ b/arch/powerpc/mm/numa.c
7101 @@ -932,7 +932,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7102 return ret;
7103 }
7104
7105 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7106 +static struct notifier_block ppc64_numa_nb = {
7107 .notifier_call = cpu_numa_callback,
7108 .priority = 1 /* Must run before sched domains notifier. */
7109 };
7110 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7111 index cf9dada..241529f 100644
7112 --- a/arch/powerpc/mm/slice.c
7113 +++ b/arch/powerpc/mm/slice.c
7114 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7115 if ((mm->task_size - len) < addr)
7116 return 0;
7117 vma = find_vma(mm, addr);
7118 - return (!vma || (addr + len) <= vma->vm_start);
7119 + return check_heap_stack_gap(vma, addr, len, 0);
7120 }
7121
7122 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7123 @@ -272,7 +272,7 @@ full_search:
7124 addr = _ALIGN_UP(addr + 1, 1ul << SLICE_HIGH_SHIFT);
7125 continue;
7126 }
7127 - if (!vma || addr + len <= vma->vm_start) {
7128 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7129 /*
7130 * Remember the place where we stopped the search:
7131 */
7132 @@ -329,10 +329,14 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7133 }
7134 }
7135
7136 - addr = mm->mmap_base;
7137 - while (addr > len) {
7138 + if (mm->mmap_base < len)
7139 + addr = -ENOMEM;
7140 + else
7141 + addr = mm->mmap_base - len;
7142 +
7143 + while (!IS_ERR_VALUE(addr)) {
7144 /* Go down by chunk size */
7145 - addr = _ALIGN_DOWN(addr - len, 1ul << pshift);
7146 + addr = _ALIGN_DOWN(addr, 1ul << pshift);
7147
7148 /* Check for hit with different page size */
7149 mask = slice_range_to_mask(addr, len);
7150 @@ -352,7 +356,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7151 * return with success:
7152 */
7153 vma = find_vma(mm, addr);
7154 - if (!vma || (addr + len) <= vma->vm_start) {
7155 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7156 /* remember the address as a hint for next time */
7157 if (use_cache)
7158 mm->free_area_cache = addr;
7159 @@ -364,7 +368,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7160 mm->cached_hole_size = vma->vm_start - addr;
7161
7162 /* try just below the current vma->vm_start */
7163 - addr = vma->vm_start;
7164 + addr = skip_heap_stack_gap(vma, len, 0);
7165 }
7166
7167 /*
7168 @@ -442,6 +446,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7169 if (fixed && addr > (mm->task_size - len))
7170 return -EINVAL;
7171
7172 +#ifdef CONFIG_PAX_RANDMMAP
7173 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7174 + addr = 0;
7175 +#endif
7176 +
7177 /* If hint, make sure it matches our alignment restrictions */
7178 if (!fixed && addr) {
7179 addr = _ALIGN_UP(addr, 1ul << pshift);
7180 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7181 index 68c57d3..1fdcfb2 100644
7182 --- a/arch/powerpc/platforms/cell/spufs/file.c
7183 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7184 @@ -281,9 +281,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7185 return VM_FAULT_NOPAGE;
7186 }
7187
7188 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7189 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7190 unsigned long address,
7191 - void *buf, int len, int write)
7192 + void *buf, size_t len, int write)
7193 {
7194 struct spu_context *ctx = vma->vm_file->private_data;
7195 unsigned long offset = address - vma->vm_start;
7196 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7197 index bdb738a..49c9f95 100644
7198 --- a/arch/powerpc/platforms/powermac/smp.c
7199 +++ b/arch/powerpc/platforms/powermac/smp.c
7200 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7201 return NOTIFY_OK;
7202 }
7203
7204 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7205 +static struct notifier_block smp_core99_cpu_nb = {
7206 .notifier_call = smp_core99_cpu_notify,
7207 };
7208 #endif /* CONFIG_HOTPLUG_CPU */
7209 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7210 index c797832..ce575c8 100644
7211 --- a/arch/s390/include/asm/atomic.h
7212 +++ b/arch/s390/include/asm/atomic.h
7213 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7214 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7215 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7216
7217 +#define atomic64_read_unchecked(v) atomic64_read(v)
7218 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7219 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7220 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7221 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7222 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7223 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7224 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7225 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7226 +
7227 #define smp_mb__before_atomic_dec() smp_mb()
7228 #define smp_mb__after_atomic_dec() smp_mb()
7229 #define smp_mb__before_atomic_inc() smp_mb()
7230 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7231 index 4d7ccac..d03d0ad 100644
7232 --- a/arch/s390/include/asm/cache.h
7233 +++ b/arch/s390/include/asm/cache.h
7234 @@ -9,8 +9,10 @@
7235 #ifndef __ARCH_S390_CACHE_H
7236 #define __ARCH_S390_CACHE_H
7237
7238 -#define L1_CACHE_BYTES 256
7239 +#include <linux/const.h>
7240 +
7241 #define L1_CACHE_SHIFT 8
7242 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7243 #define NET_SKB_PAD 32
7244
7245 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7246 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7247 index 1bfdf24..9c9ab2e 100644
7248 --- a/arch/s390/include/asm/elf.h
7249 +++ b/arch/s390/include/asm/elf.h
7250 @@ -160,8 +160,14 @@ extern unsigned int vdso_enabled;
7251 the loader. We need to make sure that it is out of the way of the program
7252 that it will "exec", and that there is sufficient room for the brk. */
7253
7254 -extern unsigned long randomize_et_dyn(unsigned long base);
7255 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7256 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7257 +
7258 +#ifdef CONFIG_PAX_ASLR
7259 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7260 +
7261 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7262 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7263 +#endif
7264
7265 /* This yields a mask that user programs can use to figure out what
7266 instruction set this CPU supports. */
7267 @@ -207,9 +213,6 @@ struct linux_binprm;
7268 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7269 int arch_setup_additional_pages(struct linux_binprm *, int);
7270
7271 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7272 -#define arch_randomize_brk arch_randomize_brk
7273 -
7274 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7275
7276 #endif
7277 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7278 index c4a93d6..4d2a9b4 100644
7279 --- a/arch/s390/include/asm/exec.h
7280 +++ b/arch/s390/include/asm/exec.h
7281 @@ -7,6 +7,6 @@
7282 #ifndef __ASM_EXEC_H
7283 #define __ASM_EXEC_H
7284
7285 -extern unsigned long arch_align_stack(unsigned long sp);
7286 +#define arch_align_stack(x) ((x) & ~0xfUL)
7287
7288 #endif /* __ASM_EXEC_H */
7289 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7290 index 9c33ed4..e40cbef 100644
7291 --- a/arch/s390/include/asm/uaccess.h
7292 +++ b/arch/s390/include/asm/uaccess.h
7293 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7294 copy_to_user(void __user *to, const void *from, unsigned long n)
7295 {
7296 might_fault();
7297 +
7298 + if ((long)n < 0)
7299 + return n;
7300 +
7301 return __copy_to_user(to, from, n);
7302 }
7303
7304 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7305 static inline unsigned long __must_check
7306 __copy_from_user(void *to, const void __user *from, unsigned long n)
7307 {
7308 + if ((long)n < 0)
7309 + return n;
7310 +
7311 if (__builtin_constant_p(n) && (n <= 256))
7312 return uaccess.copy_from_user_small(n, from, to);
7313 else
7314 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7315 static inline unsigned long __must_check
7316 copy_from_user(void *to, const void __user *from, unsigned long n)
7317 {
7318 - unsigned int sz = __compiletime_object_size(to);
7319 + size_t sz = __compiletime_object_size(to);
7320
7321 might_fault();
7322 - if (unlikely(sz != -1 && sz < n)) {
7323 +
7324 + if ((long)n < 0)
7325 + return n;
7326 +
7327 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7328 copy_from_user_overflow();
7329 return n;
7330 }
7331 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7332 index 7845e15..59c4353 100644
7333 --- a/arch/s390/kernel/module.c
7334 +++ b/arch/s390/kernel/module.c
7335 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7336
7337 /* Increase core size by size of got & plt and set start
7338 offsets for got and plt. */
7339 - me->core_size = ALIGN(me->core_size, 4);
7340 - me->arch.got_offset = me->core_size;
7341 - me->core_size += me->arch.got_size;
7342 - me->arch.plt_offset = me->core_size;
7343 - me->core_size += me->arch.plt_size;
7344 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7345 + me->arch.got_offset = me->core_size_rw;
7346 + me->core_size_rw += me->arch.got_size;
7347 + me->arch.plt_offset = me->core_size_rx;
7348 + me->core_size_rx += me->arch.plt_size;
7349 return 0;
7350 }
7351
7352 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7353 if (info->got_initialized == 0) {
7354 Elf_Addr *gotent;
7355
7356 - gotent = me->module_core + me->arch.got_offset +
7357 + gotent = me->module_core_rw + me->arch.got_offset +
7358 info->got_offset;
7359 *gotent = val;
7360 info->got_initialized = 1;
7361 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7362 rc = apply_rela_bits(loc, val, 0, 64, 0);
7363 else if (r_type == R_390_GOTENT ||
7364 r_type == R_390_GOTPLTENT) {
7365 - val += (Elf_Addr) me->module_core - loc;
7366 + val += (Elf_Addr) me->module_core_rw - loc;
7367 rc = apply_rela_bits(loc, val, 1, 32, 1);
7368 }
7369 break;
7370 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7371 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7372 if (info->plt_initialized == 0) {
7373 unsigned int *ip;
7374 - ip = me->module_core + me->arch.plt_offset +
7375 + ip = me->module_core_rx + me->arch.plt_offset +
7376 info->plt_offset;
7377 #ifndef CONFIG_64BIT
7378 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7379 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7380 val - loc + 0xffffUL < 0x1ffffeUL) ||
7381 (r_type == R_390_PLT32DBL &&
7382 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7383 - val = (Elf_Addr) me->module_core +
7384 + val = (Elf_Addr) me->module_core_rx +
7385 me->arch.plt_offset +
7386 info->plt_offset;
7387 val += rela->r_addend - loc;
7388 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7389 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7390 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7391 val = val + rela->r_addend -
7392 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7393 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7394 if (r_type == R_390_GOTOFF16)
7395 rc = apply_rela_bits(loc, val, 0, 16, 0);
7396 else if (r_type == R_390_GOTOFF32)
7397 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7398 break;
7399 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7400 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7401 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7402 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7403 rela->r_addend - loc;
7404 if (r_type == R_390_GOTPC)
7405 rc = apply_rela_bits(loc, val, 1, 32, 0);
7406 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7407 index 536d645..4a5bd9e 100644
7408 --- a/arch/s390/kernel/process.c
7409 +++ b/arch/s390/kernel/process.c
7410 @@ -250,39 +250,3 @@ unsigned long get_wchan(struct task_struct *p)
7411 }
7412 return 0;
7413 }
7414 -
7415 -unsigned long arch_align_stack(unsigned long sp)
7416 -{
7417 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7418 - sp -= get_random_int() & ~PAGE_MASK;
7419 - return sp & ~0xf;
7420 -}
7421 -
7422 -static inline unsigned long brk_rnd(void)
7423 -{
7424 - /* 8MB for 32bit, 1GB for 64bit */
7425 - if (is_32bit_task())
7426 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7427 - else
7428 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7429 -}
7430 -
7431 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7432 -{
7433 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7434 -
7435 - if (ret < mm->brk)
7436 - return mm->brk;
7437 - return ret;
7438 -}
7439 -
7440 -unsigned long randomize_et_dyn(unsigned long base)
7441 -{
7442 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7443 -
7444 - if (!(current->flags & PF_RANDOMIZE))
7445 - return base;
7446 - if (ret < base)
7447 - return base;
7448 - return ret;
7449 -}
7450 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7451 index 06bafec..2bca531 100644
7452 --- a/arch/s390/mm/mmap.c
7453 +++ b/arch/s390/mm/mmap.c
7454 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7455 */
7456 if (mmap_is_legacy()) {
7457 mm->mmap_base = TASK_UNMAPPED_BASE;
7458 +
7459 +#ifdef CONFIG_PAX_RANDMMAP
7460 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7461 + mm->mmap_base += mm->delta_mmap;
7462 +#endif
7463 +
7464 mm->get_unmapped_area = arch_get_unmapped_area;
7465 mm->unmap_area = arch_unmap_area;
7466 } else {
7467 mm->mmap_base = mmap_base();
7468 +
7469 +#ifdef CONFIG_PAX_RANDMMAP
7470 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7471 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7472 +#endif
7473 +
7474 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7475 mm->unmap_area = arch_unmap_area_topdown;
7476 }
7477 @@ -175,10 +187,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7478 */
7479 if (mmap_is_legacy()) {
7480 mm->mmap_base = TASK_UNMAPPED_BASE;
7481 +
7482 +#ifdef CONFIG_PAX_RANDMMAP
7483 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7484 + mm->mmap_base += mm->delta_mmap;
7485 +#endif
7486 +
7487 mm->get_unmapped_area = s390_get_unmapped_area;
7488 mm->unmap_area = arch_unmap_area;
7489 } else {
7490 mm->mmap_base = mmap_base();
7491 +
7492 +#ifdef CONFIG_PAX_RANDMMAP
7493 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7494 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7495 +#endif
7496 +
7497 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7498 mm->unmap_area = arch_unmap_area_topdown;
7499 }
7500 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7501 index ae3d59f..f65f075 100644
7502 --- a/arch/score/include/asm/cache.h
7503 +++ b/arch/score/include/asm/cache.h
7504 @@ -1,7 +1,9 @@
7505 #ifndef _ASM_SCORE_CACHE_H
7506 #define _ASM_SCORE_CACHE_H
7507
7508 +#include <linux/const.h>
7509 +
7510 #define L1_CACHE_SHIFT 4
7511 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7512 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7513
7514 #endif /* _ASM_SCORE_CACHE_H */
7515 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7516 index f9f3cd5..58ff438 100644
7517 --- a/arch/score/include/asm/exec.h
7518 +++ b/arch/score/include/asm/exec.h
7519 @@ -1,6 +1,6 @@
7520 #ifndef _ASM_SCORE_EXEC_H
7521 #define _ASM_SCORE_EXEC_H
7522
7523 -extern unsigned long arch_align_stack(unsigned long sp);
7524 +#define arch_align_stack(x) (x)
7525
7526 #endif /* _ASM_SCORE_EXEC_H */
7527 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7528 index 7956846..5f37677 100644
7529 --- a/arch/score/kernel/process.c
7530 +++ b/arch/score/kernel/process.c
7531 @@ -134,8 +134,3 @@ unsigned long get_wchan(struct task_struct *task)
7532
7533 return task_pt_regs(task)->cp0_epc;
7534 }
7535 -
7536 -unsigned long arch_align_stack(unsigned long sp)
7537 -{
7538 - return sp;
7539 -}
7540 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7541 index ef9e555..331bd29 100644
7542 --- a/arch/sh/include/asm/cache.h
7543 +++ b/arch/sh/include/asm/cache.h
7544 @@ -9,10 +9,11 @@
7545 #define __ASM_SH_CACHE_H
7546 #ifdef __KERNEL__
7547
7548 +#include <linux/const.h>
7549 #include <linux/init.h>
7550 #include <cpu/cache.h>
7551
7552 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7553 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7554
7555 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7556
7557 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7558 index 03f2b55..b0270327 100644
7559 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7560 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7561 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7562 return NOTIFY_OK;
7563 }
7564
7565 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7566 +static struct notifier_block shx3_cpu_notifier = {
7567 .notifier_call = shx3_cpu_callback,
7568 };
7569
7570 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7571 index 6777177..cb5e44f 100644
7572 --- a/arch/sh/mm/mmap.c
7573 +++ b/arch/sh/mm/mmap.c
7574 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7575 struct mm_struct *mm = current->mm;
7576 struct vm_area_struct *vma;
7577 int do_colour_align;
7578 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7579 struct vm_unmapped_area_info info;
7580
7581 if (flags & MAP_FIXED) {
7582 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7583 if (filp || (flags & MAP_SHARED))
7584 do_colour_align = 1;
7585
7586 +#ifdef CONFIG_PAX_RANDMMAP
7587 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7588 +#endif
7589 +
7590 if (addr) {
7591 if (do_colour_align)
7592 addr = COLOUR_ALIGN(addr, pgoff);
7593 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7594 addr = PAGE_ALIGN(addr);
7595
7596 vma = find_vma(mm, addr);
7597 - if (TASK_SIZE - len >= addr &&
7598 - (!vma || addr + len <= vma->vm_start))
7599 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7600 return addr;
7601 }
7602
7603 info.flags = 0;
7604 info.length = len;
7605 - info.low_limit = TASK_UNMAPPED_BASE;
7606 + info.low_limit = mm->mmap_base;
7607 info.high_limit = TASK_SIZE;
7608 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7609 info.align_offset = pgoff << PAGE_SHIFT;
7610 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7611 struct mm_struct *mm = current->mm;
7612 unsigned long addr = addr0;
7613 int do_colour_align;
7614 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7615 struct vm_unmapped_area_info info;
7616
7617 if (flags & MAP_FIXED) {
7618 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7619 if (filp || (flags & MAP_SHARED))
7620 do_colour_align = 1;
7621
7622 +#ifdef CONFIG_PAX_RANDMMAP
7623 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7624 +#endif
7625 +
7626 /* requesting a specific address */
7627 if (addr) {
7628 if (do_colour_align)
7629 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7630 addr = PAGE_ALIGN(addr);
7631
7632 vma = find_vma(mm, addr);
7633 - if (TASK_SIZE - len >= addr &&
7634 - (!vma || addr + len <= vma->vm_start))
7635 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7636 return addr;
7637 }
7638
7639 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7640 VM_BUG_ON(addr != -ENOMEM);
7641 info.flags = 0;
7642 info.low_limit = TASK_UNMAPPED_BASE;
7643 +
7644 +#ifdef CONFIG_PAX_RANDMMAP
7645 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7646 + info.low_limit += mm->delta_mmap;
7647 +#endif
7648 +
7649 info.high_limit = TASK_SIZE;
7650 addr = vm_unmapped_area(&info);
7651 }
7652 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7653 index be56a24..443328f 100644
7654 --- a/arch/sparc/include/asm/atomic_64.h
7655 +++ b/arch/sparc/include/asm/atomic_64.h
7656 @@ -14,18 +14,40 @@
7657 #define ATOMIC64_INIT(i) { (i) }
7658
7659 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7660 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
7661 +{
7662 + return v->counter;
7663 +}
7664 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
7665 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
7666 +{
7667 + return v->counter;
7668 +}
7669
7670 #define atomic_set(v, i) (((v)->counter) = i)
7671 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7672 +{
7673 + v->counter = i;
7674 +}
7675 #define atomic64_set(v, i) (((v)->counter) = i)
7676 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
7677 +{
7678 + v->counter = i;
7679 +}
7680
7681 extern void atomic_add(int, atomic_t *);
7682 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
7683 extern void atomic64_add(long, atomic64_t *);
7684 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
7685 extern void atomic_sub(int, atomic_t *);
7686 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
7687 extern void atomic64_sub(long, atomic64_t *);
7688 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
7689
7690 extern int atomic_add_ret(int, atomic_t *);
7691 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
7692 extern long atomic64_add_ret(long, atomic64_t *);
7693 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
7694 extern int atomic_sub_ret(int, atomic_t *);
7695 extern long atomic64_sub_ret(long, atomic64_t *);
7696
7697 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7698 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
7699
7700 #define atomic_inc_return(v) atomic_add_ret(1, v)
7701 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
7702 +{
7703 + return atomic_add_ret_unchecked(1, v);
7704 +}
7705 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
7706 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
7707 +{
7708 + return atomic64_add_ret_unchecked(1, v);
7709 +}
7710
7711 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
7712 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
7713
7714 #define atomic_add_return(i, v) atomic_add_ret(i, v)
7715 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
7716 +{
7717 + return atomic_add_ret_unchecked(i, v);
7718 +}
7719 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
7720 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
7721 +{
7722 + return atomic64_add_ret_unchecked(i, v);
7723 +}
7724
7725 /*
7726 * atomic_inc_and_test - increment and test
7727 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7728 * other cases.
7729 */
7730 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
7731 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
7732 +{
7733 + return atomic_inc_return_unchecked(v) == 0;
7734 +}
7735 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
7736
7737 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
7738 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7739 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
7740
7741 #define atomic_inc(v) atomic_add(1, v)
7742 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
7743 +{
7744 + atomic_add_unchecked(1, v);
7745 +}
7746 #define atomic64_inc(v) atomic64_add(1, v)
7747 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
7748 +{
7749 + atomic64_add_unchecked(1, v);
7750 +}
7751
7752 #define atomic_dec(v) atomic_sub(1, v)
7753 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
7754 +{
7755 + atomic_sub_unchecked(1, v);
7756 +}
7757 #define atomic64_dec(v) atomic64_sub(1, v)
7758 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
7759 +{
7760 + atomic64_sub_unchecked(1, v);
7761 +}
7762
7763 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
7764 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
7765
7766 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
7767 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
7768 +{
7769 + return cmpxchg(&v->counter, old, new);
7770 +}
7771 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
7772 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
7773 +{
7774 + return xchg(&v->counter, new);
7775 +}
7776
7777 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7778 {
7779 - int c, old;
7780 + int c, old, new;
7781 c = atomic_read(v);
7782 for (;;) {
7783 - if (unlikely(c == (u)))
7784 + if (unlikely(c == u))
7785 break;
7786 - old = atomic_cmpxchg((v), c, c + (a));
7787 +
7788 + asm volatile("addcc %2, %0, %0\n"
7789 +
7790 +#ifdef CONFIG_PAX_REFCOUNT
7791 + "tvs %%icc, 6\n"
7792 +#endif
7793 +
7794 + : "=r" (new)
7795 + : "0" (c), "ir" (a)
7796 + : "cc");
7797 +
7798 + old = atomic_cmpxchg(v, c, new);
7799 if (likely(old == c))
7800 break;
7801 c = old;
7802 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7803 #define atomic64_cmpxchg(v, o, n) \
7804 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
7805 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
7806 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
7807 +{
7808 + return xchg(&v->counter, new);
7809 +}
7810
7811 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
7812 {
7813 - long c, old;
7814 + long c, old, new;
7815 c = atomic64_read(v);
7816 for (;;) {
7817 - if (unlikely(c == (u)))
7818 + if (unlikely(c == u))
7819 break;
7820 - old = atomic64_cmpxchg((v), c, c + (a));
7821 +
7822 + asm volatile("addcc %2, %0, %0\n"
7823 +
7824 +#ifdef CONFIG_PAX_REFCOUNT
7825 + "tvs %%xcc, 6\n"
7826 +#endif
7827 +
7828 + : "=r" (new)
7829 + : "0" (c), "ir" (a)
7830 + : "cc");
7831 +
7832 + old = atomic64_cmpxchg(v, c, new);
7833 if (likely(old == c))
7834 break;
7835 c = old;
7836 }
7837 - return c != (u);
7838 + return c != u;
7839 }
7840
7841 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7842 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
7843 index 5bb6991..5c2132e 100644
7844 --- a/arch/sparc/include/asm/cache.h
7845 +++ b/arch/sparc/include/asm/cache.h
7846 @@ -7,10 +7,12 @@
7847 #ifndef _SPARC_CACHE_H
7848 #define _SPARC_CACHE_H
7849
7850 +#include <linux/const.h>
7851 +
7852 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
7853
7854 #define L1_CACHE_SHIFT 5
7855 -#define L1_CACHE_BYTES 32
7856 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7857
7858 #ifdef CONFIG_SPARC32
7859 #define SMP_CACHE_BYTES_SHIFT 5
7860 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
7861 index a24e41f..47677ff 100644
7862 --- a/arch/sparc/include/asm/elf_32.h
7863 +++ b/arch/sparc/include/asm/elf_32.h
7864 @@ -114,6 +114,13 @@ typedef struct {
7865
7866 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
7867
7868 +#ifdef CONFIG_PAX_ASLR
7869 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7870 +
7871 +#define PAX_DELTA_MMAP_LEN 16
7872 +#define PAX_DELTA_STACK_LEN 16
7873 +#endif
7874 +
7875 /* This yields a mask that user programs can use to figure out what
7876 instruction set this cpu supports. This can NOT be done in userspace
7877 on Sparc. */
7878 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
7879 index 370ca1e..d4f4a98 100644
7880 --- a/arch/sparc/include/asm/elf_64.h
7881 +++ b/arch/sparc/include/asm/elf_64.h
7882 @@ -189,6 +189,13 @@ typedef struct {
7883 #define ELF_ET_DYN_BASE 0x0000010000000000UL
7884 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
7885
7886 +#ifdef CONFIG_PAX_ASLR
7887 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
7888 +
7889 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
7890 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
7891 +#endif
7892 +
7893 extern unsigned long sparc64_elf_hwcap;
7894 #define ELF_HWCAP sparc64_elf_hwcap
7895
7896 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
7897 index 9b1c36d..209298b 100644
7898 --- a/arch/sparc/include/asm/pgalloc_32.h
7899 +++ b/arch/sparc/include/asm/pgalloc_32.h
7900 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
7901 }
7902
7903 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
7904 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
7905
7906 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
7907 unsigned long address)
7908 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
7909 index bcfe063..b333142 100644
7910 --- a/arch/sparc/include/asm/pgalloc_64.h
7911 +++ b/arch/sparc/include/asm/pgalloc_64.h
7912 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7913 }
7914
7915 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
7916 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
7917
7918 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
7919 {
7920 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
7921 index 6fc1348..390c50a 100644
7922 --- a/arch/sparc/include/asm/pgtable_32.h
7923 +++ b/arch/sparc/include/asm/pgtable_32.h
7924 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
7925 #define PAGE_SHARED SRMMU_PAGE_SHARED
7926 #define PAGE_COPY SRMMU_PAGE_COPY
7927 #define PAGE_READONLY SRMMU_PAGE_RDONLY
7928 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
7929 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
7930 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
7931 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
7932
7933 /* Top-level page directory - dummy used by init-mm.
7934 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
7935
7936 /* xwr */
7937 #define __P000 PAGE_NONE
7938 -#define __P001 PAGE_READONLY
7939 -#define __P010 PAGE_COPY
7940 -#define __P011 PAGE_COPY
7941 +#define __P001 PAGE_READONLY_NOEXEC
7942 +#define __P010 PAGE_COPY_NOEXEC
7943 +#define __P011 PAGE_COPY_NOEXEC
7944 #define __P100 PAGE_READONLY
7945 #define __P101 PAGE_READONLY
7946 #define __P110 PAGE_COPY
7947 #define __P111 PAGE_COPY
7948
7949 #define __S000 PAGE_NONE
7950 -#define __S001 PAGE_READONLY
7951 -#define __S010 PAGE_SHARED
7952 -#define __S011 PAGE_SHARED
7953 +#define __S001 PAGE_READONLY_NOEXEC
7954 +#define __S010 PAGE_SHARED_NOEXEC
7955 +#define __S011 PAGE_SHARED_NOEXEC
7956 #define __S100 PAGE_READONLY
7957 #define __S101 PAGE_READONLY
7958 #define __S110 PAGE_SHARED
7959 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
7960 index 79da178..c2eede8 100644
7961 --- a/arch/sparc/include/asm/pgtsrmmu.h
7962 +++ b/arch/sparc/include/asm/pgtsrmmu.h
7963 @@ -115,6 +115,11 @@
7964 SRMMU_EXEC | SRMMU_REF)
7965 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
7966 SRMMU_EXEC | SRMMU_REF)
7967 +
7968 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
7969 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7970 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7971 +
7972 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
7973 SRMMU_DIRTY | SRMMU_REF)
7974
7975 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
7976 index 9689176..63c18ea 100644
7977 --- a/arch/sparc/include/asm/spinlock_64.h
7978 +++ b/arch/sparc/include/asm/spinlock_64.h
7979 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
7980
7981 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
7982
7983 -static void inline arch_read_lock(arch_rwlock_t *lock)
7984 +static inline void arch_read_lock(arch_rwlock_t *lock)
7985 {
7986 unsigned long tmp1, tmp2;
7987
7988 __asm__ __volatile__ (
7989 "1: ldsw [%2], %0\n"
7990 " brlz,pn %0, 2f\n"
7991 -"4: add %0, 1, %1\n"
7992 +"4: addcc %0, 1, %1\n"
7993 +
7994 +#ifdef CONFIG_PAX_REFCOUNT
7995 +" tvs %%icc, 6\n"
7996 +#endif
7997 +
7998 " cas [%2], %0, %1\n"
7999 " cmp %0, %1\n"
8000 " bne,pn %%icc, 1b\n"
8001 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
8002 " .previous"
8003 : "=&r" (tmp1), "=&r" (tmp2)
8004 : "r" (lock)
8005 - : "memory");
8006 + : "memory", "cc");
8007 }
8008
8009 -static int inline arch_read_trylock(arch_rwlock_t *lock)
8010 +static inline int arch_read_trylock(arch_rwlock_t *lock)
8011 {
8012 int tmp1, tmp2;
8013
8014 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8015 "1: ldsw [%2], %0\n"
8016 " brlz,a,pn %0, 2f\n"
8017 " mov 0, %0\n"
8018 -" add %0, 1, %1\n"
8019 +" addcc %0, 1, %1\n"
8020 +
8021 +#ifdef CONFIG_PAX_REFCOUNT
8022 +" tvs %%icc, 6\n"
8023 +#endif
8024 +
8025 " cas [%2], %0, %1\n"
8026 " cmp %0, %1\n"
8027 " bne,pn %%icc, 1b\n"
8028 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8029 return tmp1;
8030 }
8031
8032 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8033 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8034 {
8035 unsigned long tmp1, tmp2;
8036
8037 __asm__ __volatile__(
8038 "1: lduw [%2], %0\n"
8039 -" sub %0, 1, %1\n"
8040 +" subcc %0, 1, %1\n"
8041 +
8042 +#ifdef CONFIG_PAX_REFCOUNT
8043 +" tvs %%icc, 6\n"
8044 +#endif
8045 +
8046 " cas [%2], %0, %1\n"
8047 " cmp %0, %1\n"
8048 " bne,pn %%xcc, 1b\n"
8049 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8050 : "memory");
8051 }
8052
8053 -static void inline arch_write_lock(arch_rwlock_t *lock)
8054 +static inline void arch_write_lock(arch_rwlock_t *lock)
8055 {
8056 unsigned long mask, tmp1, tmp2;
8057
8058 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8059 : "memory");
8060 }
8061
8062 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8063 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8064 {
8065 __asm__ __volatile__(
8066 " stw %%g0, [%0]"
8067 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8068 : "memory");
8069 }
8070
8071 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8072 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8073 {
8074 unsigned long mask, tmp1, tmp2, result;
8075
8076 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8077 index 25849ae..924c54b 100644
8078 --- a/arch/sparc/include/asm/thread_info_32.h
8079 +++ b/arch/sparc/include/asm/thread_info_32.h
8080 @@ -49,6 +49,8 @@ struct thread_info {
8081 unsigned long w_saved;
8082
8083 struct restart_block restart_block;
8084 +
8085 + unsigned long lowest_stack;
8086 };
8087
8088 /*
8089 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8090 index 269bd92..e46a9b8 100644
8091 --- a/arch/sparc/include/asm/thread_info_64.h
8092 +++ b/arch/sparc/include/asm/thread_info_64.h
8093 @@ -63,6 +63,8 @@ struct thread_info {
8094 struct pt_regs *kern_una_regs;
8095 unsigned int kern_una_insn;
8096
8097 + unsigned long lowest_stack;
8098 +
8099 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8100 };
8101
8102 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8103 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8104 /* flag bit 6 is available */
8105 #define TIF_32BIT 7 /* 32-bit binary */
8106 -/* flag bit 8 is available */
8107 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8108 #define TIF_SECCOMP 9 /* secure computing */
8109 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8110 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8111 +
8112 /* NOTE: Thread flags >= 12 should be ones we have no interest
8113 * in using in assembly, else we can't use the mask as
8114 * an immediate value in instructions such as andcc.
8115 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8116 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8117 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8118 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8119 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8120
8121 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8122 _TIF_DO_NOTIFY_RESUME_MASK | \
8123 _TIF_NEED_RESCHED)
8124 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8125
8126 +#define _TIF_WORK_SYSCALL \
8127 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8128 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8129 +
8130 +
8131 /*
8132 * Thread-synchronous status.
8133 *
8134 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8135 index 0167d26..767bb0c 100644
8136 --- a/arch/sparc/include/asm/uaccess.h
8137 +++ b/arch/sparc/include/asm/uaccess.h
8138 @@ -1,5 +1,6 @@
8139 #ifndef ___ASM_SPARC_UACCESS_H
8140 #define ___ASM_SPARC_UACCESS_H
8141 +
8142 #if defined(__sparc__) && defined(__arch64__)
8143 #include <asm/uaccess_64.h>
8144 #else
8145 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8146 index 53a28dd..50c38c3 100644
8147 --- a/arch/sparc/include/asm/uaccess_32.h
8148 +++ b/arch/sparc/include/asm/uaccess_32.h
8149 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8150
8151 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8152 {
8153 - if (n && __access_ok((unsigned long) to, n))
8154 + if ((long)n < 0)
8155 + return n;
8156 +
8157 + if (n && __access_ok((unsigned long) to, n)) {
8158 + if (!__builtin_constant_p(n))
8159 + check_object_size(from, n, true);
8160 return __copy_user(to, (__force void __user *) from, n);
8161 - else
8162 + } else
8163 return n;
8164 }
8165
8166 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8167 {
8168 + if ((long)n < 0)
8169 + return n;
8170 +
8171 + if (!__builtin_constant_p(n))
8172 + check_object_size(from, n, true);
8173 +
8174 return __copy_user(to, (__force void __user *) from, n);
8175 }
8176
8177 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8178 {
8179 - if (n && __access_ok((unsigned long) from, n))
8180 + if ((long)n < 0)
8181 + return n;
8182 +
8183 + if (n && __access_ok((unsigned long) from, n)) {
8184 + if (!__builtin_constant_p(n))
8185 + check_object_size(to, n, false);
8186 return __copy_user((__force void __user *) to, from, n);
8187 - else
8188 + } else
8189 return n;
8190 }
8191
8192 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8193 {
8194 + if ((long)n < 0)
8195 + return n;
8196 +
8197 return __copy_user((__force void __user *) to, from, n);
8198 }
8199
8200 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8201 index e562d3c..191f176 100644
8202 --- a/arch/sparc/include/asm/uaccess_64.h
8203 +++ b/arch/sparc/include/asm/uaccess_64.h
8204 @@ -10,6 +10,7 @@
8205 #include <linux/compiler.h>
8206 #include <linux/string.h>
8207 #include <linux/thread_info.h>
8208 +#include <linux/kernel.h>
8209 #include <asm/asi.h>
8210 #include <asm/spitfire.h>
8211 #include <asm-generic/uaccess-unaligned.h>
8212 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8213 static inline unsigned long __must_check
8214 copy_from_user(void *to, const void __user *from, unsigned long size)
8215 {
8216 - unsigned long ret = ___copy_from_user(to, from, size);
8217 + unsigned long ret;
8218
8219 + if ((long)size < 0 || size > INT_MAX)
8220 + return size;
8221 +
8222 + if (!__builtin_constant_p(size))
8223 + check_object_size(to, size, false);
8224 +
8225 + ret = ___copy_from_user(to, from, size);
8226 if (unlikely(ret))
8227 ret = copy_from_user_fixup(to, from, size);
8228
8229 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8230 static inline unsigned long __must_check
8231 copy_to_user(void __user *to, const void *from, unsigned long size)
8232 {
8233 - unsigned long ret = ___copy_to_user(to, from, size);
8234 + unsigned long ret;
8235
8236 + if ((long)size < 0 || size > INT_MAX)
8237 + return size;
8238 +
8239 + if (!__builtin_constant_p(size))
8240 + check_object_size(from, size, true);
8241 +
8242 + ret = ___copy_to_user(to, from, size);
8243 if (unlikely(ret))
8244 ret = copy_to_user_fixup(to, from, size);
8245 return ret;
8246 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8247 index 6cf591b..b49e65a 100644
8248 --- a/arch/sparc/kernel/Makefile
8249 +++ b/arch/sparc/kernel/Makefile
8250 @@ -3,7 +3,7 @@
8251 #
8252
8253 asflags-y := -ansi
8254 -ccflags-y := -Werror
8255 +#ccflags-y := -Werror
8256
8257 extra-y := head_$(BITS).o
8258
8259 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8260 index 62eede1..9c5b904 100644
8261 --- a/arch/sparc/kernel/process_32.c
8262 +++ b/arch/sparc/kernel/process_32.c
8263 @@ -125,14 +125,14 @@ void show_regs(struct pt_regs *r)
8264
8265 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8266 r->psr, r->pc, r->npc, r->y, print_tainted());
8267 - printk("PC: <%pS>\n", (void *) r->pc);
8268 + printk("PC: <%pA>\n", (void *) r->pc);
8269 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8270 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8271 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8272 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8273 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8274 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8275 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8276 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8277
8278 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8279 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8280 @@ -167,7 +167,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8281 rw = (struct reg_window32 *) fp;
8282 pc = rw->ins[7];
8283 printk("[%08lx : ", pc);
8284 - printk("%pS ] ", (void *) pc);
8285 + printk("%pA ] ", (void *) pc);
8286 fp = rw->ins[6];
8287 } while (++count < 16);
8288 printk("\n");
8289 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8290 index cdb80b2..5ca141d 100644
8291 --- a/arch/sparc/kernel/process_64.c
8292 +++ b/arch/sparc/kernel/process_64.c
8293 @@ -181,14 +181,14 @@ static void show_regwindow(struct pt_regs *regs)
8294 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8295 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8296 if (regs->tstate & TSTATE_PRIV)
8297 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8298 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8299 }
8300
8301 void show_regs(struct pt_regs *regs)
8302 {
8303 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8304 regs->tpc, regs->tnpc, regs->y, print_tainted());
8305 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8306 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8307 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8308 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8309 regs->u_regs[3]);
8310 @@ -201,7 +201,7 @@ void show_regs(struct pt_regs *regs)
8311 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8312 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8313 regs->u_regs[15]);
8314 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8315 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8316 show_regwindow(regs);
8317 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8318 }
8319 @@ -290,7 +290,7 @@ void arch_trigger_all_cpu_backtrace(void)
8320 ((tp && tp->task) ? tp->task->pid : -1));
8321
8322 if (gp->tstate & TSTATE_PRIV) {
8323 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8324 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8325 (void *) gp->tpc,
8326 (void *) gp->o7,
8327 (void *) gp->i7,
8328 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
8329 index 9f20566..67eb41b 100644
8330 --- a/arch/sparc/kernel/prom_common.c
8331 +++ b/arch/sparc/kernel/prom_common.c
8332 @@ -143,7 +143,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
8333
8334 unsigned int prom_early_allocated __initdata;
8335
8336 -static struct of_pdt_ops prom_sparc_ops __initdata = {
8337 +static struct of_pdt_ops prom_sparc_ops __initconst = {
8338 .nextprop = prom_common_nextprop,
8339 .getproplen = prom_getproplen,
8340 .getproperty = prom_getproperty,
8341 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8342 index 7ff45e4..a58f271 100644
8343 --- a/arch/sparc/kernel/ptrace_64.c
8344 +++ b/arch/sparc/kernel/ptrace_64.c
8345 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8346 return ret;
8347 }
8348
8349 +#ifdef CONFIG_GRKERNSEC_SETXID
8350 +extern void gr_delayed_cred_worker(void);
8351 +#endif
8352 +
8353 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8354 {
8355 int ret = 0;
8356 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8357 /* do the secure computing check first */
8358 secure_computing_strict(regs->u_regs[UREG_G1]);
8359
8360 +#ifdef CONFIG_GRKERNSEC_SETXID
8361 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8362 + gr_delayed_cred_worker();
8363 +#endif
8364 +
8365 if (test_thread_flag(TIF_SYSCALL_TRACE))
8366 ret = tracehook_report_syscall_entry(regs);
8367
8368 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8369
8370 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8371 {
8372 +#ifdef CONFIG_GRKERNSEC_SETXID
8373 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8374 + gr_delayed_cred_worker();
8375 +#endif
8376 +
8377 audit_syscall_exit(regs);
8378
8379 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8380 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8381 index 3a8d184..49498a8 100644
8382 --- a/arch/sparc/kernel/sys_sparc_32.c
8383 +++ b/arch/sparc/kernel/sys_sparc_32.c
8384 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8385 if (len > TASK_SIZE - PAGE_SIZE)
8386 return -ENOMEM;
8387 if (!addr)
8388 - addr = TASK_UNMAPPED_BASE;
8389 + addr = current->mm->mmap_base;
8390
8391 info.flags = 0;
8392 info.length = len;
8393 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8394 index 708bc29..6bfdfad 100644
8395 --- a/arch/sparc/kernel/sys_sparc_64.c
8396 +++ b/arch/sparc/kernel/sys_sparc_64.c
8397 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8398 struct vm_area_struct * vma;
8399 unsigned long task_size = TASK_SIZE;
8400 int do_color_align;
8401 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8402 struct vm_unmapped_area_info info;
8403
8404 if (flags & MAP_FIXED) {
8405 /* We do not accept a shared mapping if it would violate
8406 * cache aliasing constraints.
8407 */
8408 - if ((flags & MAP_SHARED) &&
8409 + if ((filp || (flags & MAP_SHARED)) &&
8410 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8411 return -EINVAL;
8412 return addr;
8413 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8414 if (filp || (flags & MAP_SHARED))
8415 do_color_align = 1;
8416
8417 +#ifdef CONFIG_PAX_RANDMMAP
8418 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8419 +#endif
8420 +
8421 if (addr) {
8422 if (do_color_align)
8423 addr = COLOR_ALIGN(addr, pgoff);
8424 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8425 addr = PAGE_ALIGN(addr);
8426
8427 vma = find_vma(mm, addr);
8428 - if (task_size - len >= addr &&
8429 - (!vma || addr + len <= vma->vm_start))
8430 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8431 return addr;
8432 }
8433
8434 info.flags = 0;
8435 info.length = len;
8436 - info.low_limit = TASK_UNMAPPED_BASE;
8437 + info.low_limit = mm->mmap_base;
8438 info.high_limit = min(task_size, VA_EXCLUDE_START);
8439 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8440 info.align_offset = pgoff << PAGE_SHIFT;
8441 + info.threadstack_offset = offset;
8442 addr = vm_unmapped_area(&info);
8443
8444 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8445 VM_BUG_ON(addr != -ENOMEM);
8446 info.low_limit = VA_EXCLUDE_END;
8447 +
8448 +#ifdef CONFIG_PAX_RANDMMAP
8449 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8450 + info.low_limit += mm->delta_mmap;
8451 +#endif
8452 +
8453 info.high_limit = task_size;
8454 addr = vm_unmapped_area(&info);
8455 }
8456 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8457 unsigned long task_size = STACK_TOP32;
8458 unsigned long addr = addr0;
8459 int do_color_align;
8460 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8461 struct vm_unmapped_area_info info;
8462
8463 /* This should only ever run for 32-bit processes. */
8464 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8465 /* We do not accept a shared mapping if it would violate
8466 * cache aliasing constraints.
8467 */
8468 - if ((flags & MAP_SHARED) &&
8469 + if ((filp || (flags & MAP_SHARED)) &&
8470 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8471 return -EINVAL;
8472 return addr;
8473 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8474 if (filp || (flags & MAP_SHARED))
8475 do_color_align = 1;
8476
8477 +#ifdef CONFIG_PAX_RANDMMAP
8478 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8479 +#endif
8480 +
8481 /* requesting a specific address */
8482 if (addr) {
8483 if (do_color_align)
8484 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8485 addr = PAGE_ALIGN(addr);
8486
8487 vma = find_vma(mm, addr);
8488 - if (task_size - len >= addr &&
8489 - (!vma || addr + len <= vma->vm_start))
8490 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8491 return addr;
8492 }
8493
8494 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8495 info.high_limit = mm->mmap_base;
8496 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8497 info.align_offset = pgoff << PAGE_SHIFT;
8498 + info.threadstack_offset = offset;
8499 addr = vm_unmapped_area(&info);
8500
8501 /*
8502 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8503 VM_BUG_ON(addr != -ENOMEM);
8504 info.flags = 0;
8505 info.low_limit = TASK_UNMAPPED_BASE;
8506 +
8507 +#ifdef CONFIG_PAX_RANDMMAP
8508 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8509 + info.low_limit += mm->delta_mmap;
8510 +#endif
8511 +
8512 info.high_limit = STACK_TOP32;
8513 addr = vm_unmapped_area(&info);
8514 }
8515 @@ -264,6 +286,10 @@ static unsigned long mmap_rnd(void)
8516 {
8517 unsigned long rnd = 0UL;
8518
8519 +#ifdef CONFIG_PAX_RANDMMAP
8520 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8521 +#endif
8522 +
8523 if (current->flags & PF_RANDOMIZE) {
8524 unsigned long val = get_random_int();
8525 if (test_thread_flag(TIF_32BIT))
8526 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8527 gap == RLIM_INFINITY ||
8528 sysctl_legacy_va_layout) {
8529 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8530 +
8531 +#ifdef CONFIG_PAX_RANDMMAP
8532 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8533 + mm->mmap_base += mm->delta_mmap;
8534 +#endif
8535 +
8536 mm->get_unmapped_area = arch_get_unmapped_area;
8537 mm->unmap_area = arch_unmap_area;
8538 } else {
8539 @@ -301,6 +333,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8540 gap = (task_size / 6 * 5);
8541
8542 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8543 +
8544 +#ifdef CONFIG_PAX_RANDMMAP
8545 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8546 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8547 +#endif
8548 +
8549 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8550 mm->unmap_area = arch_unmap_area_topdown;
8551 }
8552 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8553 index 22a1098..6255eb9 100644
8554 --- a/arch/sparc/kernel/syscalls.S
8555 +++ b/arch/sparc/kernel/syscalls.S
8556 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
8557 #endif
8558 .align 32
8559 1: ldx [%g6 + TI_FLAGS], %l5
8560 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8561 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8562 be,pt %icc, rtrap
8563 nop
8564 call syscall_trace_leave
8565 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
8566
8567 srl %i5, 0, %o5 ! IEU1
8568 srl %i2, 0, %o2 ! IEU0 Group
8569 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8570 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8571 bne,pn %icc, linux_syscall_trace32 ! CTI
8572 mov %i0, %l5 ! IEU1
8573 call %l7 ! CTI Group brk forced
8574 @@ -207,7 +207,7 @@ linux_sparc_syscall:
8575
8576 mov %i3, %o3 ! IEU1
8577 mov %i4, %o4 ! IEU0 Group
8578 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8579 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8580 bne,pn %icc, linux_syscall_trace ! CTI Group
8581 mov %i0, %l5 ! IEU0
8582 2: call %l7 ! CTI Group brk forced
8583 @@ -223,7 +223,7 @@ ret_sys_call:
8584
8585 cmp %o0, -ERESTART_RESTARTBLOCK
8586 bgeu,pn %xcc, 1f
8587 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8588 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8589 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8590
8591 2:
8592 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8593 index 654e8aa..45f431b 100644
8594 --- a/arch/sparc/kernel/sysfs.c
8595 +++ b/arch/sparc/kernel/sysfs.c
8596 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8597 return NOTIFY_OK;
8598 }
8599
8600 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8601 +static struct notifier_block sysfs_cpu_nb = {
8602 .notifier_call = sysfs_cpu_notify,
8603 };
8604
8605 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8606 index 6629829..036032d 100644
8607 --- a/arch/sparc/kernel/traps_32.c
8608 +++ b/arch/sparc/kernel/traps_32.c
8609 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8610 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8611 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8612
8613 +extern void gr_handle_kernel_exploit(void);
8614 +
8615 void die_if_kernel(char *str, struct pt_regs *regs)
8616 {
8617 static int die_counter;
8618 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8619 count++ < 30 &&
8620 (((unsigned long) rw) >= PAGE_OFFSET) &&
8621 !(((unsigned long) rw) & 0x7)) {
8622 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8623 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8624 (void *) rw->ins[7]);
8625 rw = (struct reg_window32 *)rw->ins[6];
8626 }
8627 }
8628 printk("Instruction DUMP:");
8629 instruction_dump ((unsigned long *) regs->pc);
8630 - if(regs->psr & PSR_PS)
8631 + if(regs->psr & PSR_PS) {
8632 + gr_handle_kernel_exploit();
8633 do_exit(SIGKILL);
8634 + }
8635 do_exit(SIGSEGV);
8636 }
8637
8638 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8639 index 8d38ca9..845b1d6 100644
8640 --- a/arch/sparc/kernel/traps_64.c
8641 +++ b/arch/sparc/kernel/traps_64.c
8642 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8643 i + 1,
8644 p->trapstack[i].tstate, p->trapstack[i].tpc,
8645 p->trapstack[i].tnpc, p->trapstack[i].tt);
8646 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8647 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8648 }
8649 }
8650
8651 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8652
8653 lvl -= 0x100;
8654 if (regs->tstate & TSTATE_PRIV) {
8655 +
8656 +#ifdef CONFIG_PAX_REFCOUNT
8657 + if (lvl == 6)
8658 + pax_report_refcount_overflow(regs);
8659 +#endif
8660 +
8661 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8662 die_if_kernel(buffer, regs);
8663 }
8664 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8665 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8666 {
8667 char buffer[32];
8668 -
8669 +
8670 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
8671 0, lvl, SIGTRAP) == NOTIFY_STOP)
8672 return;
8673
8674 +#ifdef CONFIG_PAX_REFCOUNT
8675 + if (lvl == 6)
8676 + pax_report_refcount_overflow(regs);
8677 +#endif
8678 +
8679 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
8680
8681 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
8682 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
8683 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
8684 printk("%s" "ERROR(%d): ",
8685 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
8686 - printk("TPC<%pS>\n", (void *) regs->tpc);
8687 + printk("TPC<%pA>\n", (void *) regs->tpc);
8688 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
8689 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
8690 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
8691 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8692 smp_processor_id(),
8693 (type & 0x1) ? 'I' : 'D',
8694 regs->tpc);
8695 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
8696 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
8697 panic("Irrecoverable Cheetah+ parity error.");
8698 }
8699
8700 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8701 smp_processor_id(),
8702 (type & 0x1) ? 'I' : 'D',
8703 regs->tpc);
8704 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
8705 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
8706 }
8707
8708 struct sun4v_error_entry {
8709 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
8710
8711 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
8712 regs->tpc, tl);
8713 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
8714 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
8715 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8716 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
8717 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
8718 (void *) regs->u_regs[UREG_I7]);
8719 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
8720 "pte[%lx] error[%lx]\n",
8721 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
8722
8723 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
8724 regs->tpc, tl);
8725 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
8726 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
8727 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8728 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
8729 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
8730 (void *) regs->u_regs[UREG_I7]);
8731 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
8732 "pte[%lx] error[%lx]\n",
8733 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8734 fp = (unsigned long)sf->fp + STACK_BIAS;
8735 }
8736
8737 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8738 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8739 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8740 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
8741 int index = tsk->curr_ret_stack;
8742 if (tsk->ret_stack && index >= graph) {
8743 pc = tsk->ret_stack[index - graph].ret;
8744 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8745 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8746 graph++;
8747 }
8748 }
8749 @@ -2367,6 +2378,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
8750 return (struct reg_window *) (fp + STACK_BIAS);
8751 }
8752
8753 +extern void gr_handle_kernel_exploit(void);
8754 +
8755 void die_if_kernel(char *str, struct pt_regs *regs)
8756 {
8757 static int die_counter;
8758 @@ -2395,7 +2408,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8759 while (rw &&
8760 count++ < 30 &&
8761 kstack_valid(tp, (unsigned long) rw)) {
8762 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
8763 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
8764 (void *) rw->ins[7]);
8765
8766 rw = kernel_stack_up(rw);
8767 @@ -2408,8 +2421,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8768 }
8769 user_instruction_dump ((unsigned int __user *) regs->tpc);
8770 }
8771 - if (regs->tstate & TSTATE_PRIV)
8772 + if (regs->tstate & TSTATE_PRIV) {
8773 + gr_handle_kernel_exploit();
8774 do_exit(SIGKILL);
8775 + }
8776 do_exit(SIGSEGV);
8777 }
8778 EXPORT_SYMBOL(die_if_kernel);
8779 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
8780 index 8201c25e..072a2a7 100644
8781 --- a/arch/sparc/kernel/unaligned_64.c
8782 +++ b/arch/sparc/kernel/unaligned_64.c
8783 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
8784 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
8785
8786 if (__ratelimit(&ratelimit)) {
8787 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
8788 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
8789 regs->tpc, (void *) regs->tpc);
8790 }
8791 }
8792 diff --git a/arch/sparc/kernel/us3_cpufreq.c b/arch/sparc/kernel/us3_cpufreq.c
8793 index eb1624b..55100de 100644
8794 --- a/arch/sparc/kernel/us3_cpufreq.c
8795 +++ b/arch/sparc/kernel/us3_cpufreq.c
8796 @@ -18,14 +18,12 @@
8797 #include <asm/head.h>
8798 #include <asm/timer.h>
8799
8800 -static struct cpufreq_driver *cpufreq_us3_driver;
8801 -
8802 struct us3_freq_percpu_info {
8803 struct cpufreq_frequency_table table[4];
8804 };
8805
8806 /* Indexed by cpu number. */
8807 -static struct us3_freq_percpu_info *us3_freq_table;
8808 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
8809
8810 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
8811 * in the Safari config register.
8812 @@ -191,12 +189,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
8813
8814 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
8815 {
8816 - if (cpufreq_us3_driver)
8817 - us3_set_cpu_divider_index(policy->cpu, 0);
8818 + us3_set_cpu_divider_index(policy->cpu, 0);
8819
8820 return 0;
8821 }
8822
8823 +static int __init us3_freq_init(void);
8824 +static void __exit us3_freq_exit(void);
8825 +
8826 +static struct cpufreq_driver cpufreq_us3_driver = {
8827 + .init = us3_freq_cpu_init,
8828 + .verify = us3_freq_verify,
8829 + .target = us3_freq_target,
8830 + .get = us3_freq_get,
8831 + .exit = us3_freq_cpu_exit,
8832 + .owner = THIS_MODULE,
8833 + .name = "UltraSPARC-III",
8834 +
8835 +};
8836 +
8837 static int __init us3_freq_init(void)
8838 {
8839 unsigned long manuf, impl, ver;
8840 @@ -213,57 +224,15 @@ static int __init us3_freq_init(void)
8841 (impl == CHEETAH_IMPL ||
8842 impl == CHEETAH_PLUS_IMPL ||
8843 impl == JAGUAR_IMPL ||
8844 - impl == PANTHER_IMPL)) {
8845 - struct cpufreq_driver *driver;
8846 -
8847 - ret = -ENOMEM;
8848 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
8849 - if (!driver)
8850 - goto err_out;
8851 -
8852 - us3_freq_table = kzalloc(
8853 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
8854 - GFP_KERNEL);
8855 - if (!us3_freq_table)
8856 - goto err_out;
8857 -
8858 - driver->init = us3_freq_cpu_init;
8859 - driver->verify = us3_freq_verify;
8860 - driver->target = us3_freq_target;
8861 - driver->get = us3_freq_get;
8862 - driver->exit = us3_freq_cpu_exit;
8863 - driver->owner = THIS_MODULE,
8864 - strcpy(driver->name, "UltraSPARC-III");
8865 -
8866 - cpufreq_us3_driver = driver;
8867 - ret = cpufreq_register_driver(driver);
8868 - if (ret)
8869 - goto err_out;
8870 -
8871 - return 0;
8872 -
8873 -err_out:
8874 - if (driver) {
8875 - kfree(driver);
8876 - cpufreq_us3_driver = NULL;
8877 - }
8878 - kfree(us3_freq_table);
8879 - us3_freq_table = NULL;
8880 - return ret;
8881 - }
8882 + impl == PANTHER_IMPL))
8883 + return cpufreq_register_driver(&cpufreq_us3_driver);
8884
8885 return -ENODEV;
8886 }
8887
8888 static void __exit us3_freq_exit(void)
8889 {
8890 - if (cpufreq_us3_driver) {
8891 - cpufreq_unregister_driver(cpufreq_us3_driver);
8892 - kfree(cpufreq_us3_driver);
8893 - cpufreq_us3_driver = NULL;
8894 - kfree(us3_freq_table);
8895 - us3_freq_table = NULL;
8896 - }
8897 + cpufreq_unregister_driver(&cpufreq_us3_driver);
8898 }
8899
8900 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
8901 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
8902 index 8410065f2..4fd4ca22 100644
8903 --- a/arch/sparc/lib/Makefile
8904 +++ b/arch/sparc/lib/Makefile
8905 @@ -2,7 +2,7 @@
8906 #
8907
8908 asflags-y := -ansi -DST_DIV0=0x02
8909 -ccflags-y := -Werror
8910 +#ccflags-y := -Werror
8911
8912 lib-$(CONFIG_SPARC32) += ashrdi3.o
8913 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
8914 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
8915 index 85c233d..68500e0 100644
8916 --- a/arch/sparc/lib/atomic_64.S
8917 +++ b/arch/sparc/lib/atomic_64.S
8918 @@ -17,7 +17,12 @@
8919 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8920 BACKOFF_SETUP(%o2)
8921 1: lduw [%o1], %g1
8922 - add %g1, %o0, %g7
8923 + addcc %g1, %o0, %g7
8924 +
8925 +#ifdef CONFIG_PAX_REFCOUNT
8926 + tvs %icc, 6
8927 +#endif
8928 +
8929 cas [%o1], %g1, %g7
8930 cmp %g1, %g7
8931 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8932 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8933 2: BACKOFF_SPIN(%o2, %o3, 1b)
8934 ENDPROC(atomic_add)
8935
8936 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8937 + BACKOFF_SETUP(%o2)
8938 +1: lduw [%o1], %g1
8939 + add %g1, %o0, %g7
8940 + cas [%o1], %g1, %g7
8941 + cmp %g1, %g7
8942 + bne,pn %icc, 2f
8943 + nop
8944 + retl
8945 + nop
8946 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8947 +ENDPROC(atomic_add_unchecked)
8948 +
8949 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8950 BACKOFF_SETUP(%o2)
8951 1: lduw [%o1], %g1
8952 - sub %g1, %o0, %g7
8953 + subcc %g1, %o0, %g7
8954 +
8955 +#ifdef CONFIG_PAX_REFCOUNT
8956 + tvs %icc, 6
8957 +#endif
8958 +
8959 cas [%o1], %g1, %g7
8960 cmp %g1, %g7
8961 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8962 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8963 2: BACKOFF_SPIN(%o2, %o3, 1b)
8964 ENDPROC(atomic_sub)
8965
8966 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
8967 + BACKOFF_SETUP(%o2)
8968 +1: lduw [%o1], %g1
8969 + sub %g1, %o0, %g7
8970 + cas [%o1], %g1, %g7
8971 + cmp %g1, %g7
8972 + bne,pn %icc, 2f
8973 + nop
8974 + retl
8975 + nop
8976 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8977 +ENDPROC(atomic_sub_unchecked)
8978 +
8979 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8980 BACKOFF_SETUP(%o2)
8981 1: lduw [%o1], %g1
8982 - add %g1, %o0, %g7
8983 + addcc %g1, %o0, %g7
8984 +
8985 +#ifdef CONFIG_PAX_REFCOUNT
8986 + tvs %icc, 6
8987 +#endif
8988 +
8989 cas [%o1], %g1, %g7
8990 cmp %g1, %g7
8991 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8992 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8993 2: BACKOFF_SPIN(%o2, %o3, 1b)
8994 ENDPROC(atomic_add_ret)
8995
8996 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8997 + BACKOFF_SETUP(%o2)
8998 +1: lduw [%o1], %g1
8999 + addcc %g1, %o0, %g7
9000 + cas [%o1], %g1, %g7
9001 + cmp %g1, %g7
9002 + bne,pn %icc, 2f
9003 + add %g7, %o0, %g7
9004 + sra %g7, 0, %o0
9005 + retl
9006 + nop
9007 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9008 +ENDPROC(atomic_add_ret_unchecked)
9009 +
9010 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9011 BACKOFF_SETUP(%o2)
9012 1: lduw [%o1], %g1
9013 - sub %g1, %o0, %g7
9014 + subcc %g1, %o0, %g7
9015 +
9016 +#ifdef CONFIG_PAX_REFCOUNT
9017 + tvs %icc, 6
9018 +#endif
9019 +
9020 cas [%o1], %g1, %g7
9021 cmp %g1, %g7
9022 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9023 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
9024 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9025 BACKOFF_SETUP(%o2)
9026 1: ldx [%o1], %g1
9027 - add %g1, %o0, %g7
9028 + addcc %g1, %o0, %g7
9029 +
9030 +#ifdef CONFIG_PAX_REFCOUNT
9031 + tvs %xcc, 6
9032 +#endif
9033 +
9034 casx [%o1], %g1, %g7
9035 cmp %g1, %g7
9036 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9037 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9038 2: BACKOFF_SPIN(%o2, %o3, 1b)
9039 ENDPROC(atomic64_add)
9040
9041 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9042 + BACKOFF_SETUP(%o2)
9043 +1: ldx [%o1], %g1
9044 + addcc %g1, %o0, %g7
9045 + casx [%o1], %g1, %g7
9046 + cmp %g1, %g7
9047 + bne,pn %xcc, 2f
9048 + nop
9049 + retl
9050 + nop
9051 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9052 +ENDPROC(atomic64_add_unchecked)
9053 +
9054 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9055 BACKOFF_SETUP(%o2)
9056 1: ldx [%o1], %g1
9057 - sub %g1, %o0, %g7
9058 + subcc %g1, %o0, %g7
9059 +
9060 +#ifdef CONFIG_PAX_REFCOUNT
9061 + tvs %xcc, 6
9062 +#endif
9063 +
9064 casx [%o1], %g1, %g7
9065 cmp %g1, %g7
9066 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9067 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9068 2: BACKOFF_SPIN(%o2, %o3, 1b)
9069 ENDPROC(atomic64_sub)
9070
9071 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9072 + BACKOFF_SETUP(%o2)
9073 +1: ldx [%o1], %g1
9074 + subcc %g1, %o0, %g7
9075 + casx [%o1], %g1, %g7
9076 + cmp %g1, %g7
9077 + bne,pn %xcc, 2f
9078 + nop
9079 + retl
9080 + nop
9081 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9082 +ENDPROC(atomic64_sub_unchecked)
9083 +
9084 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9085 BACKOFF_SETUP(%o2)
9086 1: ldx [%o1], %g1
9087 - add %g1, %o0, %g7
9088 + addcc %g1, %o0, %g7
9089 +
9090 +#ifdef CONFIG_PAX_REFCOUNT
9091 + tvs %xcc, 6
9092 +#endif
9093 +
9094 casx [%o1], %g1, %g7
9095 cmp %g1, %g7
9096 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9097 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9098 2: BACKOFF_SPIN(%o2, %o3, 1b)
9099 ENDPROC(atomic64_add_ret)
9100
9101 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9102 + BACKOFF_SETUP(%o2)
9103 +1: ldx [%o1], %g1
9104 + addcc %g1, %o0, %g7
9105 + casx [%o1], %g1, %g7
9106 + cmp %g1, %g7
9107 + bne,pn %xcc, 2f
9108 + add %g7, %o0, %g7
9109 + mov %g7, %o0
9110 + retl
9111 + nop
9112 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9113 +ENDPROC(atomic64_add_ret_unchecked)
9114 +
9115 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9116 BACKOFF_SETUP(%o2)
9117 1: ldx [%o1], %g1
9118 - sub %g1, %o0, %g7
9119 + subcc %g1, %o0, %g7
9120 +
9121 +#ifdef CONFIG_PAX_REFCOUNT
9122 + tvs %xcc, 6
9123 +#endif
9124 +
9125 casx [%o1], %g1, %g7
9126 cmp %g1, %g7
9127 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9128 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9129 index 0c4e35e..745d3e4 100644
9130 --- a/arch/sparc/lib/ksyms.c
9131 +++ b/arch/sparc/lib/ksyms.c
9132 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9133
9134 /* Atomic counter implementation. */
9135 EXPORT_SYMBOL(atomic_add);
9136 +EXPORT_SYMBOL(atomic_add_unchecked);
9137 EXPORT_SYMBOL(atomic_add_ret);
9138 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9139 EXPORT_SYMBOL(atomic_sub);
9140 +EXPORT_SYMBOL(atomic_sub_unchecked);
9141 EXPORT_SYMBOL(atomic_sub_ret);
9142 EXPORT_SYMBOL(atomic64_add);
9143 +EXPORT_SYMBOL(atomic64_add_unchecked);
9144 EXPORT_SYMBOL(atomic64_add_ret);
9145 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9146 EXPORT_SYMBOL(atomic64_sub);
9147 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9148 EXPORT_SYMBOL(atomic64_sub_ret);
9149 EXPORT_SYMBOL(atomic64_dec_if_positive);
9150
9151 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9152 index 30c3ecc..736f015 100644
9153 --- a/arch/sparc/mm/Makefile
9154 +++ b/arch/sparc/mm/Makefile
9155 @@ -2,7 +2,7 @@
9156 #
9157
9158 asflags-y := -ansi
9159 -ccflags-y := -Werror
9160 +#ccflags-y := -Werror
9161
9162 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9163 obj-y += fault_$(BITS).o
9164 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9165 index e98bfda..ea8d221 100644
9166 --- a/arch/sparc/mm/fault_32.c
9167 +++ b/arch/sparc/mm/fault_32.c
9168 @@ -21,6 +21,9 @@
9169 #include <linux/perf_event.h>
9170 #include <linux/interrupt.h>
9171 #include <linux/kdebug.h>
9172 +#include <linux/slab.h>
9173 +#include <linux/pagemap.h>
9174 +#include <linux/compiler.h>
9175
9176 #include <asm/page.h>
9177 #include <asm/pgtable.h>
9178 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9179 return safe_compute_effective_address(regs, insn);
9180 }
9181
9182 +#ifdef CONFIG_PAX_PAGEEXEC
9183 +#ifdef CONFIG_PAX_DLRESOLVE
9184 +static void pax_emuplt_close(struct vm_area_struct *vma)
9185 +{
9186 + vma->vm_mm->call_dl_resolve = 0UL;
9187 +}
9188 +
9189 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9190 +{
9191 + unsigned int *kaddr;
9192 +
9193 + vmf->page = alloc_page(GFP_HIGHUSER);
9194 + if (!vmf->page)
9195 + return VM_FAULT_OOM;
9196 +
9197 + kaddr = kmap(vmf->page);
9198 + memset(kaddr, 0, PAGE_SIZE);
9199 + kaddr[0] = 0x9DE3BFA8U; /* save */
9200 + flush_dcache_page(vmf->page);
9201 + kunmap(vmf->page);
9202 + return VM_FAULT_MAJOR;
9203 +}
9204 +
9205 +static const struct vm_operations_struct pax_vm_ops = {
9206 + .close = pax_emuplt_close,
9207 + .fault = pax_emuplt_fault
9208 +};
9209 +
9210 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9211 +{
9212 + int ret;
9213 +
9214 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9215 + vma->vm_mm = current->mm;
9216 + vma->vm_start = addr;
9217 + vma->vm_end = addr + PAGE_SIZE;
9218 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9219 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9220 + vma->vm_ops = &pax_vm_ops;
9221 +
9222 + ret = insert_vm_struct(current->mm, vma);
9223 + if (ret)
9224 + return ret;
9225 +
9226 + ++current->mm->total_vm;
9227 + return 0;
9228 +}
9229 +#endif
9230 +
9231 +/*
9232 + * PaX: decide what to do with offenders (regs->pc = fault address)
9233 + *
9234 + * returns 1 when task should be killed
9235 + * 2 when patched PLT trampoline was detected
9236 + * 3 when unpatched PLT trampoline was detected
9237 + */
9238 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9239 +{
9240 +
9241 +#ifdef CONFIG_PAX_EMUPLT
9242 + int err;
9243 +
9244 + do { /* PaX: patched PLT emulation #1 */
9245 + unsigned int sethi1, sethi2, jmpl;
9246 +
9247 + err = get_user(sethi1, (unsigned int *)regs->pc);
9248 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9249 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9250 +
9251 + if (err)
9252 + break;
9253 +
9254 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9255 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9256 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9257 + {
9258 + unsigned int addr;
9259 +
9260 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9261 + addr = regs->u_regs[UREG_G1];
9262 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9263 + regs->pc = addr;
9264 + regs->npc = addr+4;
9265 + return 2;
9266 + }
9267 + } while (0);
9268 +
9269 + do { /* PaX: patched PLT emulation #2 */
9270 + unsigned int ba;
9271 +
9272 + err = get_user(ba, (unsigned int *)regs->pc);
9273 +
9274 + if (err)
9275 + break;
9276 +
9277 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9278 + unsigned int addr;
9279 +
9280 + if ((ba & 0xFFC00000U) == 0x30800000U)
9281 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9282 + else
9283 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9284 + regs->pc = addr;
9285 + regs->npc = addr+4;
9286 + return 2;
9287 + }
9288 + } while (0);
9289 +
9290 + do { /* PaX: patched PLT emulation #3 */
9291 + unsigned int sethi, bajmpl, nop;
9292 +
9293 + err = get_user(sethi, (unsigned int *)regs->pc);
9294 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9295 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9296 +
9297 + if (err)
9298 + break;
9299 +
9300 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9301 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9302 + nop == 0x01000000U)
9303 + {
9304 + unsigned int addr;
9305 +
9306 + addr = (sethi & 0x003FFFFFU) << 10;
9307 + regs->u_regs[UREG_G1] = addr;
9308 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9309 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9310 + else
9311 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9312 + regs->pc = addr;
9313 + regs->npc = addr+4;
9314 + return 2;
9315 + }
9316 + } while (0);
9317 +
9318 + do { /* PaX: unpatched PLT emulation step 1 */
9319 + unsigned int sethi, ba, nop;
9320 +
9321 + err = get_user(sethi, (unsigned int *)regs->pc);
9322 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9323 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9324 +
9325 + if (err)
9326 + break;
9327 +
9328 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9329 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9330 + nop == 0x01000000U)
9331 + {
9332 + unsigned int addr, save, call;
9333 +
9334 + if ((ba & 0xFFC00000U) == 0x30800000U)
9335 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9336 + else
9337 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9338 +
9339 + err = get_user(save, (unsigned int *)addr);
9340 + err |= get_user(call, (unsigned int *)(addr+4));
9341 + err |= get_user(nop, (unsigned int *)(addr+8));
9342 + if (err)
9343 + break;
9344 +
9345 +#ifdef CONFIG_PAX_DLRESOLVE
9346 + if (save == 0x9DE3BFA8U &&
9347 + (call & 0xC0000000U) == 0x40000000U &&
9348 + nop == 0x01000000U)
9349 + {
9350 + struct vm_area_struct *vma;
9351 + unsigned long call_dl_resolve;
9352 +
9353 + down_read(&current->mm->mmap_sem);
9354 + call_dl_resolve = current->mm->call_dl_resolve;
9355 + up_read(&current->mm->mmap_sem);
9356 + if (likely(call_dl_resolve))
9357 + goto emulate;
9358 +
9359 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9360 +
9361 + down_write(&current->mm->mmap_sem);
9362 + if (current->mm->call_dl_resolve) {
9363 + call_dl_resolve = current->mm->call_dl_resolve;
9364 + up_write(&current->mm->mmap_sem);
9365 + if (vma)
9366 + kmem_cache_free(vm_area_cachep, vma);
9367 + goto emulate;
9368 + }
9369 +
9370 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9371 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9372 + up_write(&current->mm->mmap_sem);
9373 + if (vma)
9374 + kmem_cache_free(vm_area_cachep, vma);
9375 + return 1;
9376 + }
9377 +
9378 + if (pax_insert_vma(vma, call_dl_resolve)) {
9379 + up_write(&current->mm->mmap_sem);
9380 + kmem_cache_free(vm_area_cachep, vma);
9381 + return 1;
9382 + }
9383 +
9384 + current->mm->call_dl_resolve = call_dl_resolve;
9385 + up_write(&current->mm->mmap_sem);
9386 +
9387 +emulate:
9388 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9389 + regs->pc = call_dl_resolve;
9390 + regs->npc = addr+4;
9391 + return 3;
9392 + }
9393 +#endif
9394 +
9395 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9396 + if ((save & 0xFFC00000U) == 0x05000000U &&
9397 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9398 + nop == 0x01000000U)
9399 + {
9400 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9401 + regs->u_regs[UREG_G2] = addr + 4;
9402 + addr = (save & 0x003FFFFFU) << 10;
9403 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9404 + regs->pc = addr;
9405 + regs->npc = addr+4;
9406 + return 3;
9407 + }
9408 + }
9409 + } while (0);
9410 +
9411 + do { /* PaX: unpatched PLT emulation step 2 */
9412 + unsigned int save, call, nop;
9413 +
9414 + err = get_user(save, (unsigned int *)(regs->pc-4));
9415 + err |= get_user(call, (unsigned int *)regs->pc);
9416 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9417 + if (err)
9418 + break;
9419 +
9420 + if (save == 0x9DE3BFA8U &&
9421 + (call & 0xC0000000U) == 0x40000000U &&
9422 + nop == 0x01000000U)
9423 + {
9424 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9425 +
9426 + regs->u_regs[UREG_RETPC] = regs->pc;
9427 + regs->pc = dl_resolve;
9428 + regs->npc = dl_resolve+4;
9429 + return 3;
9430 + }
9431 + } while (0);
9432 +#endif
9433 +
9434 + return 1;
9435 +}
9436 +
9437 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9438 +{
9439 + unsigned long i;
9440 +
9441 + printk(KERN_ERR "PAX: bytes at PC: ");
9442 + for (i = 0; i < 8; i++) {
9443 + unsigned int c;
9444 + if (get_user(c, (unsigned int *)pc+i))
9445 + printk(KERN_CONT "???????? ");
9446 + else
9447 + printk(KERN_CONT "%08x ", c);
9448 + }
9449 + printk("\n");
9450 +}
9451 +#endif
9452 +
9453 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9454 int text_fault)
9455 {
9456 @@ -230,6 +504,24 @@ good_area:
9457 if (!(vma->vm_flags & VM_WRITE))
9458 goto bad_area;
9459 } else {
9460 +
9461 +#ifdef CONFIG_PAX_PAGEEXEC
9462 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9463 + up_read(&mm->mmap_sem);
9464 + switch (pax_handle_fetch_fault(regs)) {
9465 +
9466 +#ifdef CONFIG_PAX_EMUPLT
9467 + case 2:
9468 + case 3:
9469 + return;
9470 +#endif
9471 +
9472 + }
9473 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9474 + do_group_exit(SIGKILL);
9475 + }
9476 +#endif
9477 +
9478 /* Allow reads even for write-only mappings */
9479 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9480 goto bad_area;
9481 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9482 index 5062ff3..e0b75f3 100644
9483 --- a/arch/sparc/mm/fault_64.c
9484 +++ b/arch/sparc/mm/fault_64.c
9485 @@ -21,6 +21,9 @@
9486 #include <linux/kprobes.h>
9487 #include <linux/kdebug.h>
9488 #include <linux/percpu.h>
9489 +#include <linux/slab.h>
9490 +#include <linux/pagemap.h>
9491 +#include <linux/compiler.h>
9492
9493 #include <asm/page.h>
9494 #include <asm/pgtable.h>
9495 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9496 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9497 regs->tpc);
9498 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9499 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9500 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9501 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9502 dump_stack();
9503 unhandled_fault(regs->tpc, current, regs);
9504 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9505 show_regs(regs);
9506 }
9507
9508 +#ifdef CONFIG_PAX_PAGEEXEC
9509 +#ifdef CONFIG_PAX_DLRESOLVE
9510 +static void pax_emuplt_close(struct vm_area_struct *vma)
9511 +{
9512 + vma->vm_mm->call_dl_resolve = 0UL;
9513 +}
9514 +
9515 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9516 +{
9517 + unsigned int *kaddr;
9518 +
9519 + vmf->page = alloc_page(GFP_HIGHUSER);
9520 + if (!vmf->page)
9521 + return VM_FAULT_OOM;
9522 +
9523 + kaddr = kmap(vmf->page);
9524 + memset(kaddr, 0, PAGE_SIZE);
9525 + kaddr[0] = 0x9DE3BFA8U; /* save */
9526 + flush_dcache_page(vmf->page);
9527 + kunmap(vmf->page);
9528 + return VM_FAULT_MAJOR;
9529 +}
9530 +
9531 +static const struct vm_operations_struct pax_vm_ops = {
9532 + .close = pax_emuplt_close,
9533 + .fault = pax_emuplt_fault
9534 +};
9535 +
9536 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9537 +{
9538 + int ret;
9539 +
9540 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9541 + vma->vm_mm = current->mm;
9542 + vma->vm_start = addr;
9543 + vma->vm_end = addr + PAGE_SIZE;
9544 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9545 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9546 + vma->vm_ops = &pax_vm_ops;
9547 +
9548 + ret = insert_vm_struct(current->mm, vma);
9549 + if (ret)
9550 + return ret;
9551 +
9552 + ++current->mm->total_vm;
9553 + return 0;
9554 +}
9555 +#endif
9556 +
9557 +/*
9558 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9559 + *
9560 + * returns 1 when task should be killed
9561 + * 2 when patched PLT trampoline was detected
9562 + * 3 when unpatched PLT trampoline was detected
9563 + */
9564 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9565 +{
9566 +
9567 +#ifdef CONFIG_PAX_EMUPLT
9568 + int err;
9569 +
9570 + do { /* PaX: patched PLT emulation #1 */
9571 + unsigned int sethi1, sethi2, jmpl;
9572 +
9573 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9574 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9575 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9576 +
9577 + if (err)
9578 + break;
9579 +
9580 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9581 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9582 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9583 + {
9584 + unsigned long addr;
9585 +
9586 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9587 + addr = regs->u_regs[UREG_G1];
9588 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9589 +
9590 + if (test_thread_flag(TIF_32BIT))
9591 + addr &= 0xFFFFFFFFUL;
9592 +
9593 + regs->tpc = addr;
9594 + regs->tnpc = addr+4;
9595 + return 2;
9596 + }
9597 + } while (0);
9598 +
9599 + do { /* PaX: patched PLT emulation #2 */
9600 + unsigned int ba;
9601 +
9602 + err = get_user(ba, (unsigned int *)regs->tpc);
9603 +
9604 + if (err)
9605 + break;
9606 +
9607 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9608 + unsigned long addr;
9609 +
9610 + if ((ba & 0xFFC00000U) == 0x30800000U)
9611 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9612 + else
9613 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9614 +
9615 + if (test_thread_flag(TIF_32BIT))
9616 + addr &= 0xFFFFFFFFUL;
9617 +
9618 + regs->tpc = addr;
9619 + regs->tnpc = addr+4;
9620 + return 2;
9621 + }
9622 + } while (0);
9623 +
9624 + do { /* PaX: patched PLT emulation #3 */
9625 + unsigned int sethi, bajmpl, nop;
9626 +
9627 + err = get_user(sethi, (unsigned int *)regs->tpc);
9628 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9629 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9630 +
9631 + if (err)
9632 + break;
9633 +
9634 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9635 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9636 + nop == 0x01000000U)
9637 + {
9638 + unsigned long addr;
9639 +
9640 + addr = (sethi & 0x003FFFFFU) << 10;
9641 + regs->u_regs[UREG_G1] = addr;
9642 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9643 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9644 + else
9645 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9646 +
9647 + if (test_thread_flag(TIF_32BIT))
9648 + addr &= 0xFFFFFFFFUL;
9649 +
9650 + regs->tpc = addr;
9651 + regs->tnpc = addr+4;
9652 + return 2;
9653 + }
9654 + } while (0);
9655 +
9656 + do { /* PaX: patched PLT emulation #4 */
9657 + unsigned int sethi, mov1, call, mov2;
9658 +
9659 + err = get_user(sethi, (unsigned int *)regs->tpc);
9660 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9661 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9662 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9663 +
9664 + if (err)
9665 + break;
9666 +
9667 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9668 + mov1 == 0x8210000FU &&
9669 + (call & 0xC0000000U) == 0x40000000U &&
9670 + mov2 == 0x9E100001U)
9671 + {
9672 + unsigned long addr;
9673 +
9674 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
9675 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9676 +
9677 + if (test_thread_flag(TIF_32BIT))
9678 + addr &= 0xFFFFFFFFUL;
9679 +
9680 + regs->tpc = addr;
9681 + regs->tnpc = addr+4;
9682 + return 2;
9683 + }
9684 + } while (0);
9685 +
9686 + do { /* PaX: patched PLT emulation #5 */
9687 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
9688 +
9689 + err = get_user(sethi, (unsigned int *)regs->tpc);
9690 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9691 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9692 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
9693 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
9694 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
9695 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
9696 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
9697 +
9698 + if (err)
9699 + break;
9700 +
9701 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9702 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9703 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9704 + (or1 & 0xFFFFE000U) == 0x82106000U &&
9705 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9706 + sllx == 0x83287020U &&
9707 + jmpl == 0x81C04005U &&
9708 + nop == 0x01000000U)
9709 + {
9710 + unsigned long addr;
9711 +
9712 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9713 + regs->u_regs[UREG_G1] <<= 32;
9714 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9715 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9716 + regs->tpc = addr;
9717 + regs->tnpc = addr+4;
9718 + return 2;
9719 + }
9720 + } while (0);
9721 +
9722 + do { /* PaX: patched PLT emulation #6 */
9723 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
9724 +
9725 + err = get_user(sethi, (unsigned int *)regs->tpc);
9726 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9727 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9728 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
9729 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
9730 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
9731 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
9732 +
9733 + if (err)
9734 + break;
9735 +
9736 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9737 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9738 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9739 + sllx == 0x83287020U &&
9740 + (or & 0xFFFFE000U) == 0x8A116000U &&
9741 + jmpl == 0x81C04005U &&
9742 + nop == 0x01000000U)
9743 + {
9744 + unsigned long addr;
9745 +
9746 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
9747 + regs->u_regs[UREG_G1] <<= 32;
9748 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
9749 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9750 + regs->tpc = addr;
9751 + regs->tnpc = addr+4;
9752 + return 2;
9753 + }
9754 + } while (0);
9755 +
9756 + do { /* PaX: unpatched PLT emulation step 1 */
9757 + unsigned int sethi, ba, nop;
9758 +
9759 + err = get_user(sethi, (unsigned int *)regs->tpc);
9760 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9761 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9762 +
9763 + if (err)
9764 + break;
9765 +
9766 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9767 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9768 + nop == 0x01000000U)
9769 + {
9770 + unsigned long addr;
9771 + unsigned int save, call;
9772 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
9773 +
9774 + if ((ba & 0xFFC00000U) == 0x30800000U)
9775 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9776 + else
9777 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9778 +
9779 + if (test_thread_flag(TIF_32BIT))
9780 + addr &= 0xFFFFFFFFUL;
9781 +
9782 + err = get_user(save, (unsigned int *)addr);
9783 + err |= get_user(call, (unsigned int *)(addr+4));
9784 + err |= get_user(nop, (unsigned int *)(addr+8));
9785 + if (err)
9786 + break;
9787 +
9788 +#ifdef CONFIG_PAX_DLRESOLVE
9789 + if (save == 0x9DE3BFA8U &&
9790 + (call & 0xC0000000U) == 0x40000000U &&
9791 + nop == 0x01000000U)
9792 + {
9793 + struct vm_area_struct *vma;
9794 + unsigned long call_dl_resolve;
9795 +
9796 + down_read(&current->mm->mmap_sem);
9797 + call_dl_resolve = current->mm->call_dl_resolve;
9798 + up_read(&current->mm->mmap_sem);
9799 + if (likely(call_dl_resolve))
9800 + goto emulate;
9801 +
9802 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9803 +
9804 + down_write(&current->mm->mmap_sem);
9805 + if (current->mm->call_dl_resolve) {
9806 + call_dl_resolve = current->mm->call_dl_resolve;
9807 + up_write(&current->mm->mmap_sem);
9808 + if (vma)
9809 + kmem_cache_free(vm_area_cachep, vma);
9810 + goto emulate;
9811 + }
9812 +
9813 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9814 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9815 + up_write(&current->mm->mmap_sem);
9816 + if (vma)
9817 + kmem_cache_free(vm_area_cachep, vma);
9818 + return 1;
9819 + }
9820 +
9821 + if (pax_insert_vma(vma, call_dl_resolve)) {
9822 + up_write(&current->mm->mmap_sem);
9823 + kmem_cache_free(vm_area_cachep, vma);
9824 + return 1;
9825 + }
9826 +
9827 + current->mm->call_dl_resolve = call_dl_resolve;
9828 + up_write(&current->mm->mmap_sem);
9829 +
9830 +emulate:
9831 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9832 + regs->tpc = call_dl_resolve;
9833 + regs->tnpc = addr+4;
9834 + return 3;
9835 + }
9836 +#endif
9837 +
9838 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9839 + if ((save & 0xFFC00000U) == 0x05000000U &&
9840 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9841 + nop == 0x01000000U)
9842 + {
9843 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9844 + regs->u_regs[UREG_G2] = addr + 4;
9845 + addr = (save & 0x003FFFFFU) << 10;
9846 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9847 +
9848 + if (test_thread_flag(TIF_32BIT))
9849 + addr &= 0xFFFFFFFFUL;
9850 +
9851 + regs->tpc = addr;
9852 + regs->tnpc = addr+4;
9853 + return 3;
9854 + }
9855 +
9856 + /* PaX: 64-bit PLT stub */
9857 + err = get_user(sethi1, (unsigned int *)addr);
9858 + err |= get_user(sethi2, (unsigned int *)(addr+4));
9859 + err |= get_user(or1, (unsigned int *)(addr+8));
9860 + err |= get_user(or2, (unsigned int *)(addr+12));
9861 + err |= get_user(sllx, (unsigned int *)(addr+16));
9862 + err |= get_user(add, (unsigned int *)(addr+20));
9863 + err |= get_user(jmpl, (unsigned int *)(addr+24));
9864 + err |= get_user(nop, (unsigned int *)(addr+28));
9865 + if (err)
9866 + break;
9867 +
9868 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
9869 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9870 + (or1 & 0xFFFFE000U) == 0x88112000U &&
9871 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9872 + sllx == 0x89293020U &&
9873 + add == 0x8A010005U &&
9874 + jmpl == 0x89C14000U &&
9875 + nop == 0x01000000U)
9876 + {
9877 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9878 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9879 + regs->u_regs[UREG_G4] <<= 32;
9880 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9881 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
9882 + regs->u_regs[UREG_G4] = addr + 24;
9883 + addr = regs->u_regs[UREG_G5];
9884 + regs->tpc = addr;
9885 + regs->tnpc = addr+4;
9886 + return 3;
9887 + }
9888 + }
9889 + } while (0);
9890 +
9891 +#ifdef CONFIG_PAX_DLRESOLVE
9892 + do { /* PaX: unpatched PLT emulation step 2 */
9893 + unsigned int save, call, nop;
9894 +
9895 + err = get_user(save, (unsigned int *)(regs->tpc-4));
9896 + err |= get_user(call, (unsigned int *)regs->tpc);
9897 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
9898 + if (err)
9899 + break;
9900 +
9901 + if (save == 0x9DE3BFA8U &&
9902 + (call & 0xC0000000U) == 0x40000000U &&
9903 + nop == 0x01000000U)
9904 + {
9905 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9906 +
9907 + if (test_thread_flag(TIF_32BIT))
9908 + dl_resolve &= 0xFFFFFFFFUL;
9909 +
9910 + regs->u_regs[UREG_RETPC] = regs->tpc;
9911 + regs->tpc = dl_resolve;
9912 + regs->tnpc = dl_resolve+4;
9913 + return 3;
9914 + }
9915 + } while (0);
9916 +#endif
9917 +
9918 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
9919 + unsigned int sethi, ba, nop;
9920 +
9921 + err = get_user(sethi, (unsigned int *)regs->tpc);
9922 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9923 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9924 +
9925 + if (err)
9926 + break;
9927 +
9928 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9929 + (ba & 0xFFF00000U) == 0x30600000U &&
9930 + nop == 0x01000000U)
9931 + {
9932 + unsigned long addr;
9933 +
9934 + addr = (sethi & 0x003FFFFFU) << 10;
9935 + regs->u_regs[UREG_G1] = addr;
9936 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9937 +
9938 + if (test_thread_flag(TIF_32BIT))
9939 + addr &= 0xFFFFFFFFUL;
9940 +
9941 + regs->tpc = addr;
9942 + regs->tnpc = addr+4;
9943 + return 2;
9944 + }
9945 + } while (0);
9946 +
9947 +#endif
9948 +
9949 + return 1;
9950 +}
9951 +
9952 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9953 +{
9954 + unsigned long i;
9955 +
9956 + printk(KERN_ERR "PAX: bytes at PC: ");
9957 + for (i = 0; i < 8; i++) {
9958 + unsigned int c;
9959 + if (get_user(c, (unsigned int *)pc+i))
9960 + printk(KERN_CONT "???????? ");
9961 + else
9962 + printk(KERN_CONT "%08x ", c);
9963 + }
9964 + printk("\n");
9965 +}
9966 +#endif
9967 +
9968 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
9969 {
9970 struct mm_struct *mm = current->mm;
9971 @@ -341,6 +804,29 @@ retry:
9972 if (!vma)
9973 goto bad_area;
9974
9975 +#ifdef CONFIG_PAX_PAGEEXEC
9976 + /* PaX: detect ITLB misses on non-exec pages */
9977 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
9978 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
9979 + {
9980 + if (address != regs->tpc)
9981 + goto good_area;
9982 +
9983 + up_read(&mm->mmap_sem);
9984 + switch (pax_handle_fetch_fault(regs)) {
9985 +
9986 +#ifdef CONFIG_PAX_EMUPLT
9987 + case 2:
9988 + case 3:
9989 + return;
9990 +#endif
9991 +
9992 + }
9993 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
9994 + do_group_exit(SIGKILL);
9995 + }
9996 +#endif
9997 +
9998 /* Pure DTLB misses do not tell us whether the fault causing
9999 * load/store/atomic was a write or not, it only says that there
10000 * was no match. So in such a case we (carefully) read the
10001 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
10002 index d2b5944..bd813f2 100644
10003 --- a/arch/sparc/mm/hugetlbpage.c
10004 +++ b/arch/sparc/mm/hugetlbpage.c
10005 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10006
10007 info.flags = 0;
10008 info.length = len;
10009 - info.low_limit = TASK_UNMAPPED_BASE;
10010 + info.low_limit = mm->mmap_base;
10011 info.high_limit = min(task_size, VA_EXCLUDE_START);
10012 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
10013 info.align_offset = 0;
10014 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10015 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
10016 VM_BUG_ON(addr != -ENOMEM);
10017 info.low_limit = VA_EXCLUDE_END;
10018 +
10019 +#ifdef CONFIG_PAX_RANDMMAP
10020 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10021 + info.low_limit += mm->delta_mmap;
10022 +#endif
10023 +
10024 info.high_limit = task_size;
10025 addr = vm_unmapped_area(&info);
10026 }
10027 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10028 VM_BUG_ON(addr != -ENOMEM);
10029 info.flags = 0;
10030 info.low_limit = TASK_UNMAPPED_BASE;
10031 +
10032 +#ifdef CONFIG_PAX_RANDMMAP
10033 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10034 + info.low_limit += mm->delta_mmap;
10035 +#endif
10036 +
10037 info.high_limit = STACK_TOP32;
10038 addr = vm_unmapped_area(&info);
10039 }
10040 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10041 struct mm_struct *mm = current->mm;
10042 struct vm_area_struct *vma;
10043 unsigned long task_size = TASK_SIZE;
10044 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
10045
10046 if (test_thread_flag(TIF_32BIT))
10047 task_size = STACK_TOP32;
10048 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10049 return addr;
10050 }
10051
10052 +#ifdef CONFIG_PAX_RANDMMAP
10053 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10054 +#endif
10055 +
10056 if (addr) {
10057 addr = ALIGN(addr, HPAGE_SIZE);
10058 vma = find_vma(mm, addr);
10059 - if (task_size - len >= addr &&
10060 - (!vma || addr + len <= vma->vm_start))
10061 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10062 return addr;
10063 }
10064 if (mm->get_unmapped_area == arch_get_unmapped_area)
10065 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
10066 index f4500c6..889656c 100644
10067 --- a/arch/tile/include/asm/atomic_64.h
10068 +++ b/arch/tile/include/asm/atomic_64.h
10069 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10070
10071 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10072
10073 +#define atomic64_read_unchecked(v) atomic64_read(v)
10074 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
10075 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
10076 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
10077 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
10078 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
10079 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
10080 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
10081 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
10082 +
10083 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
10084 #define smp_mb__before_atomic_dec() smp_mb()
10085 #define smp_mb__after_atomic_dec() smp_mb()
10086 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
10087 index a9a5299..0fce79e 100644
10088 --- a/arch/tile/include/asm/cache.h
10089 +++ b/arch/tile/include/asm/cache.h
10090 @@ -15,11 +15,12 @@
10091 #ifndef _ASM_TILE_CACHE_H
10092 #define _ASM_TILE_CACHE_H
10093
10094 +#include <linux/const.h>
10095 #include <arch/chip.h>
10096
10097 /* bytes per L1 data cache line */
10098 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
10099 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10100 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10101
10102 /* bytes per L2 cache line */
10103 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10104 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10105 index 9ab078a..d6635c2 100644
10106 --- a/arch/tile/include/asm/uaccess.h
10107 +++ b/arch/tile/include/asm/uaccess.h
10108 @@ -403,9 +403,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10109 const void __user *from,
10110 unsigned long n)
10111 {
10112 - int sz = __compiletime_object_size(to);
10113 + size_t sz = __compiletime_object_size(to);
10114
10115 - if (likely(sz == -1 || sz >= n))
10116 + if (likely(sz == (size_t)-1 || sz >= n))
10117 n = _copy_from_user(to, from, n);
10118 else
10119 copy_from_user_overflow();
10120 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
10121 index 650ccff..45fe2d6 100644
10122 --- a/arch/tile/mm/hugetlbpage.c
10123 +++ b/arch/tile/mm/hugetlbpage.c
10124 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
10125 info.high_limit = TASK_SIZE;
10126 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10127 info.align_offset = 0;
10128 + info.threadstack_offset = 0;
10129 return vm_unmapped_area(&info);
10130 }
10131
10132 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
10133 info.high_limit = current->mm->mmap_base;
10134 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10135 info.align_offset = 0;
10136 + info.threadstack_offset = 0;
10137 addr = vm_unmapped_area(&info);
10138
10139 /*
10140 diff --git a/arch/um/Makefile b/arch/um/Makefile
10141 index 133f7de..1d6f2f1 100644
10142 --- a/arch/um/Makefile
10143 +++ b/arch/um/Makefile
10144 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10145 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10146 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10147
10148 +ifdef CONSTIFY_PLUGIN
10149 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10150 +endif
10151 +
10152 #This will adjust *FLAGS accordingly to the platform.
10153 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10154
10155 diff --git a/arch/um/defconfig b/arch/um/defconfig
10156 index 08107a7..ab22afe 100644
10157 --- a/arch/um/defconfig
10158 +++ b/arch/um/defconfig
10159 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
10160 CONFIG_X86_L1_CACHE_SHIFT=5
10161 CONFIG_X86_XADD=y
10162 CONFIG_X86_PPRO_FENCE=y
10163 -CONFIG_X86_WP_WORKS_OK=y
10164 CONFIG_X86_INVLPG=y
10165 CONFIG_X86_BSWAP=y
10166 CONFIG_X86_POPAD_OK=y
10167 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10168 index 19e1bdd..3665b77 100644
10169 --- a/arch/um/include/asm/cache.h
10170 +++ b/arch/um/include/asm/cache.h
10171 @@ -1,6 +1,7 @@
10172 #ifndef __UM_CACHE_H
10173 #define __UM_CACHE_H
10174
10175 +#include <linux/const.h>
10176
10177 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10178 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10179 @@ -12,6 +13,6 @@
10180 # define L1_CACHE_SHIFT 5
10181 #endif
10182
10183 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10184 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10185
10186 #endif
10187 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10188 index 2e0a6b1..a64d0f5 100644
10189 --- a/arch/um/include/asm/kmap_types.h
10190 +++ b/arch/um/include/asm/kmap_types.h
10191 @@ -8,6 +8,6 @@
10192
10193 /* No more #include "asm/arch/kmap_types.h" ! */
10194
10195 -#define KM_TYPE_NR 14
10196 +#define KM_TYPE_NR 15
10197
10198 #endif
10199 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10200 index 5ff53d9..5850cdf 100644
10201 --- a/arch/um/include/asm/page.h
10202 +++ b/arch/um/include/asm/page.h
10203 @@ -14,6 +14,9 @@
10204 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10205 #define PAGE_MASK (~(PAGE_SIZE-1))
10206
10207 +#define ktla_ktva(addr) (addr)
10208 +#define ktva_ktla(addr) (addr)
10209 +
10210 #ifndef __ASSEMBLY__
10211
10212 struct page;
10213 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10214 index 0032f92..cd151e0 100644
10215 --- a/arch/um/include/asm/pgtable-3level.h
10216 +++ b/arch/um/include/asm/pgtable-3level.h
10217 @@ -58,6 +58,7 @@
10218 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10219 #define pud_populate(mm, pud, pmd) \
10220 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10221 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10222
10223 #ifdef CONFIG_64BIT
10224 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10225 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10226 index b462b13..e7a19aa 100644
10227 --- a/arch/um/kernel/process.c
10228 +++ b/arch/um/kernel/process.c
10229 @@ -386,22 +386,6 @@ int singlestepping(void * t)
10230 return 2;
10231 }
10232
10233 -/*
10234 - * Only x86 and x86_64 have an arch_align_stack().
10235 - * All other arches have "#define arch_align_stack(x) (x)"
10236 - * in their asm/system.h
10237 - * As this is included in UML from asm-um/system-generic.h,
10238 - * we can use it to behave as the subarch does.
10239 - */
10240 -#ifndef arch_align_stack
10241 -unsigned long arch_align_stack(unsigned long sp)
10242 -{
10243 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10244 - sp -= get_random_int() % 8192;
10245 - return sp & ~0xf;
10246 -}
10247 -#endif
10248 -
10249 unsigned long get_wchan(struct task_struct *p)
10250 {
10251 unsigned long stack_page, sp, ip;
10252 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10253 index ad8f795..2c7eec6 100644
10254 --- a/arch/unicore32/include/asm/cache.h
10255 +++ b/arch/unicore32/include/asm/cache.h
10256 @@ -12,8 +12,10 @@
10257 #ifndef __UNICORE_CACHE_H__
10258 #define __UNICORE_CACHE_H__
10259
10260 -#define L1_CACHE_SHIFT (5)
10261 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10262 +#include <linux/const.h>
10263 +
10264 +#define L1_CACHE_SHIFT 5
10265 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10266
10267 /*
10268 * Memory returned by kmalloc() may be used for DMA, so we must make
10269 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10270 index 6ef2a37..74ad6ad 100644
10271 --- a/arch/x86/Kconfig
10272 +++ b/arch/x86/Kconfig
10273 @@ -243,7 +243,7 @@ config X86_HT
10274
10275 config X86_32_LAZY_GS
10276 def_bool y
10277 - depends on X86_32 && !CC_STACKPROTECTOR
10278 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10279
10280 config ARCH_HWEIGHT_CFLAGS
10281 string
10282 @@ -1076,6 +1076,7 @@ config MICROCODE_EARLY
10283
10284 config X86_MSR
10285 tristate "/dev/cpu/*/msr - Model-specific register support"
10286 + depends on !GRKERNSEC_KMEM
10287 ---help---
10288 This device gives privileged processes access to the x86
10289 Model-Specific Registers (MSRs). It is a character device with
10290 @@ -1099,7 +1100,7 @@ choice
10291
10292 config NOHIGHMEM
10293 bool "off"
10294 - depends on !X86_NUMAQ
10295 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10296 ---help---
10297 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10298 However, the address space of 32-bit x86 processors is only 4
10299 @@ -1136,7 +1137,7 @@ config NOHIGHMEM
10300
10301 config HIGHMEM4G
10302 bool "4GB"
10303 - depends on !X86_NUMAQ
10304 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10305 ---help---
10306 Select this if you have a 32-bit processor and between 1 and 4
10307 gigabytes of physical RAM.
10308 @@ -1189,7 +1190,7 @@ config PAGE_OFFSET
10309 hex
10310 default 0xB0000000 if VMSPLIT_3G_OPT
10311 default 0x80000000 if VMSPLIT_2G
10312 - default 0x78000000 if VMSPLIT_2G_OPT
10313 + default 0x70000000 if VMSPLIT_2G_OPT
10314 default 0x40000000 if VMSPLIT_1G
10315 default 0xC0000000
10316 depends on X86_32
10317 @@ -1587,6 +1588,7 @@ config SECCOMP
10318
10319 config CC_STACKPROTECTOR
10320 bool "Enable -fstack-protector buffer overflow detection"
10321 + depends on X86_64 || !PAX_MEMORY_UDEREF
10322 ---help---
10323 This option turns on the -fstack-protector GCC feature. This
10324 feature puts, at the beginning of functions, a canary value on
10325 @@ -1706,6 +1708,8 @@ config X86_NEED_RELOCS
10326 config PHYSICAL_ALIGN
10327 hex "Alignment value to which kernel should be aligned" if X86_32
10328 default "0x1000000"
10329 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
10330 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
10331 range 0x2000 0x1000000
10332 ---help---
10333 This value puts the alignment restrictions on physical address
10334 @@ -1781,9 +1785,10 @@ config DEBUG_HOTPLUG_CPU0
10335 If unsure, say N.
10336
10337 config COMPAT_VDSO
10338 - def_bool y
10339 + def_bool n
10340 prompt "Compat VDSO support"
10341 depends on X86_32 || IA32_EMULATION
10342 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10343 ---help---
10344 Map the 32-bit VDSO to the predictable old-style address too.
10345
10346 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10347 index c026cca..14657ae 100644
10348 --- a/arch/x86/Kconfig.cpu
10349 +++ b/arch/x86/Kconfig.cpu
10350 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10351
10352 config X86_F00F_BUG
10353 def_bool y
10354 - depends on M586MMX || M586TSC || M586 || M486
10355 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10356
10357 config X86_INVD_BUG
10358 def_bool y
10359 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10360
10361 config X86_ALIGNMENT_16
10362 def_bool y
10363 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10364 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10365
10366 config X86_INTEL_USERCOPY
10367 def_bool y
10368 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10369 # generates cmov.
10370 config X86_CMOV
10371 def_bool y
10372 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10373 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10374
10375 config X86_MINIMUM_CPU_FAMILY
10376 int
10377 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10378 index b322f12..652d0d9 100644
10379 --- a/arch/x86/Kconfig.debug
10380 +++ b/arch/x86/Kconfig.debug
10381 @@ -84,7 +84,7 @@ config X86_PTDUMP
10382 config DEBUG_RODATA
10383 bool "Write protect kernel read-only data structures"
10384 default y
10385 - depends on DEBUG_KERNEL
10386 + depends on DEBUG_KERNEL && BROKEN
10387 ---help---
10388 Mark the kernel read-only data as write-protected in the pagetables,
10389 in order to catch accidental (and incorrect) writes to such const
10390 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10391
10392 config DEBUG_SET_MODULE_RONX
10393 bool "Set loadable kernel module data as NX and text as RO"
10394 - depends on MODULES
10395 + depends on MODULES && BROKEN
10396 ---help---
10397 This option helps catch unintended modifications to loadable
10398 kernel module's text and read-only data. It also prevents execution
10399 @@ -294,7 +294,7 @@ config OPTIMIZE_INLINING
10400
10401 config DEBUG_STRICT_USER_COPY_CHECKS
10402 bool "Strict copy size checks"
10403 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
10404 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
10405 ---help---
10406 Enabling this option turns a certain set of sanity checks for user
10407 copy operations into compile time failures.
10408 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10409 index 5c47726..8c4fa67 100644
10410 --- a/arch/x86/Makefile
10411 +++ b/arch/x86/Makefile
10412 @@ -54,6 +54,7 @@ else
10413 UTS_MACHINE := x86_64
10414 CHECKFLAGS += -D__x86_64__ -m64
10415
10416 + biarch := $(call cc-option,-m64)
10417 KBUILD_AFLAGS += -m64
10418 KBUILD_CFLAGS += -m64
10419
10420 @@ -234,3 +235,12 @@ define archhelp
10421 echo ' FDARGS="..." arguments for the booted kernel'
10422 echo ' FDINITRD=file initrd for the booted kernel'
10423 endef
10424 +
10425 +define OLD_LD
10426 +
10427 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10428 +*** Please upgrade your binutils to 2.18 or newer
10429 +endef
10430 +
10431 +archprepare:
10432 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10433 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10434 index 379814b..add62ce 100644
10435 --- a/arch/x86/boot/Makefile
10436 +++ b/arch/x86/boot/Makefile
10437 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10438 $(call cc-option, -fno-stack-protector) \
10439 $(call cc-option, -mpreferred-stack-boundary=2)
10440 KBUILD_CFLAGS += $(call cc-option, -m32)
10441 +ifdef CONSTIFY_PLUGIN
10442 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10443 +endif
10444 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10445 GCOV_PROFILE := n
10446
10447 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10448 index 878e4b9..20537ab 100644
10449 --- a/arch/x86/boot/bitops.h
10450 +++ b/arch/x86/boot/bitops.h
10451 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10452 u8 v;
10453 const u32 *p = (const u32 *)addr;
10454
10455 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10456 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10457 return v;
10458 }
10459
10460 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10461
10462 static inline void set_bit(int nr, void *addr)
10463 {
10464 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10465 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10466 }
10467
10468 #endif /* BOOT_BITOPS_H */
10469 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10470 index 5b75319..331a4ca 100644
10471 --- a/arch/x86/boot/boot.h
10472 +++ b/arch/x86/boot/boot.h
10473 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10474 static inline u16 ds(void)
10475 {
10476 u16 seg;
10477 - asm("movw %%ds,%0" : "=rm" (seg));
10478 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10479 return seg;
10480 }
10481
10482 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10483 static inline int memcmp(const void *s1, const void *s2, size_t len)
10484 {
10485 u8 diff;
10486 - asm("repe; cmpsb; setnz %0"
10487 + asm volatile("repe; cmpsb; setnz %0"
10488 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10489 return diff;
10490 }
10491 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10492 index 5ef205c..342191d 100644
10493 --- a/arch/x86/boot/compressed/Makefile
10494 +++ b/arch/x86/boot/compressed/Makefile
10495 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10496 KBUILD_CFLAGS += $(cflags-y)
10497 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10498 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10499 +ifdef CONSTIFY_PLUGIN
10500 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10501 +endif
10502
10503 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10504 GCOV_PROFILE := n
10505 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10506 index 35ee62f..b6609b6 100644
10507 --- a/arch/x86/boot/compressed/eboot.c
10508 +++ b/arch/x86/boot/compressed/eboot.c
10509 @@ -150,7 +150,6 @@ again:
10510 *addr = max_addr;
10511 }
10512
10513 -free_pool:
10514 efi_call_phys1(sys_table->boottime->free_pool, map);
10515
10516 fail:
10517 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10518 if (i == map_size / desc_size)
10519 status = EFI_NOT_FOUND;
10520
10521 -free_pool:
10522 efi_call_phys1(sys_table->boottime->free_pool, map);
10523 fail:
10524 return status;
10525 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10526 index 1e3184f..0d11e2e 100644
10527 --- a/arch/x86/boot/compressed/head_32.S
10528 +++ b/arch/x86/boot/compressed/head_32.S
10529 @@ -118,7 +118,7 @@ preferred_addr:
10530 notl %eax
10531 andl %eax, %ebx
10532 #else
10533 - movl $LOAD_PHYSICAL_ADDR, %ebx
10534 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10535 #endif
10536
10537 /* Target address to relocate to for decompression */
10538 @@ -204,7 +204,7 @@ relocated:
10539 * and where it was actually loaded.
10540 */
10541 movl %ebp, %ebx
10542 - subl $LOAD_PHYSICAL_ADDR, %ebx
10543 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10544 jz 2f /* Nothing to be done if loaded at compiled addr. */
10545 /*
10546 * Process relocations.
10547 @@ -212,8 +212,7 @@ relocated:
10548
10549 1: subl $4, %edi
10550 movl (%edi), %ecx
10551 - testl %ecx, %ecx
10552 - jz 2f
10553 + jecxz 2f
10554 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10555 jmp 1b
10556 2:
10557 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10558 index c1d383d..57ab51c 100644
10559 --- a/arch/x86/boot/compressed/head_64.S
10560 +++ b/arch/x86/boot/compressed/head_64.S
10561 @@ -97,7 +97,7 @@ ENTRY(startup_32)
10562 notl %eax
10563 andl %eax, %ebx
10564 #else
10565 - movl $LOAD_PHYSICAL_ADDR, %ebx
10566 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10567 #endif
10568
10569 /* Target address to relocate to for decompression */
10570 @@ -272,7 +272,7 @@ preferred_addr:
10571 notq %rax
10572 andq %rax, %rbp
10573 #else
10574 - movq $LOAD_PHYSICAL_ADDR, %rbp
10575 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10576 #endif
10577
10578 /* Target address to relocate to for decompression */
10579 @@ -363,8 +363,8 @@ gdt:
10580 .long gdt
10581 .word 0
10582 .quad 0x0000000000000000 /* NULL descriptor */
10583 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
10584 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
10585 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
10586 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
10587 .quad 0x0080890000000000 /* TS descriptor */
10588 .quad 0x0000000000000000 /* TS continued */
10589 gdt_end:
10590 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10591 index 7cb56c6..d382d84 100644
10592 --- a/arch/x86/boot/compressed/misc.c
10593 +++ b/arch/x86/boot/compressed/misc.c
10594 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10595 case PT_LOAD:
10596 #ifdef CONFIG_RELOCATABLE
10597 dest = output;
10598 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10599 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10600 #else
10601 dest = (void *)(phdr->p_paddr);
10602 #endif
10603 @@ -354,7 +354,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10604 error("Destination address too large");
10605 #endif
10606 #ifndef CONFIG_RELOCATABLE
10607 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10608 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10609 error("Wrong destination address");
10610 #endif
10611
10612 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10613 index 4d3ff03..e4972ff 100644
10614 --- a/arch/x86/boot/cpucheck.c
10615 +++ b/arch/x86/boot/cpucheck.c
10616 @@ -74,7 +74,7 @@ static int has_fpu(void)
10617 u16 fcw = -1, fsw = -1;
10618 u32 cr0;
10619
10620 - asm("movl %%cr0,%0" : "=r" (cr0));
10621 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10622 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10623 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10624 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10625 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10626 {
10627 u32 f0, f1;
10628
10629 - asm("pushfl ; "
10630 + asm volatile("pushfl ; "
10631 "pushfl ; "
10632 "popl %0 ; "
10633 "movl %0,%1 ; "
10634 @@ -115,7 +115,7 @@ static void get_flags(void)
10635 set_bit(X86_FEATURE_FPU, cpu.flags);
10636
10637 if (has_eflag(X86_EFLAGS_ID)) {
10638 - asm("cpuid"
10639 + asm volatile("cpuid"
10640 : "=a" (max_intel_level),
10641 "=b" (cpu_vendor[0]),
10642 "=d" (cpu_vendor[1]),
10643 @@ -124,7 +124,7 @@ static void get_flags(void)
10644
10645 if (max_intel_level >= 0x00000001 &&
10646 max_intel_level <= 0x0000ffff) {
10647 - asm("cpuid"
10648 + asm volatile("cpuid"
10649 : "=a" (tfms),
10650 "=c" (cpu.flags[4]),
10651 "=d" (cpu.flags[0])
10652 @@ -136,7 +136,7 @@ static void get_flags(void)
10653 cpu.model += ((tfms >> 16) & 0xf) << 4;
10654 }
10655
10656 - asm("cpuid"
10657 + asm volatile("cpuid"
10658 : "=a" (max_amd_level)
10659 : "a" (0x80000000)
10660 : "ebx", "ecx", "edx");
10661 @@ -144,7 +144,7 @@ static void get_flags(void)
10662 if (max_amd_level >= 0x80000001 &&
10663 max_amd_level <= 0x8000ffff) {
10664 u32 eax = 0x80000001;
10665 - asm("cpuid"
10666 + asm volatile("cpuid"
10667 : "+a" (eax),
10668 "=c" (cpu.flags[6]),
10669 "=d" (cpu.flags[1])
10670 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10671 u32 ecx = MSR_K7_HWCR;
10672 u32 eax, edx;
10673
10674 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10675 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10676 eax &= ~(1 << 15);
10677 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10678 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10679
10680 get_flags(); /* Make sure it really did something */
10681 err = check_flags();
10682 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10683 u32 ecx = MSR_VIA_FCR;
10684 u32 eax, edx;
10685
10686 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10687 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10688 eax |= (1<<1)|(1<<7);
10689 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10690 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10691
10692 set_bit(X86_FEATURE_CX8, cpu.flags);
10693 err = check_flags();
10694 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10695 u32 eax, edx;
10696 u32 level = 1;
10697
10698 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10699 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10700 - asm("cpuid"
10701 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10702 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10703 + asm volatile("cpuid"
10704 : "+a" (level), "=d" (cpu.flags[0])
10705 : : "ecx", "ebx");
10706 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10707 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10708
10709 err = check_flags();
10710 }
10711 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
10712 index 9ec06a1..2c25e79 100644
10713 --- a/arch/x86/boot/header.S
10714 +++ b/arch/x86/boot/header.S
10715 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
10716 # single linked list of
10717 # struct setup_data
10718
10719 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
10720 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
10721
10722 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
10723 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
10724 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
10725 +#else
10726 #define VO_INIT_SIZE (VO__end - VO__text)
10727 +#endif
10728 #if ZO_INIT_SIZE > VO_INIT_SIZE
10729 #define INIT_SIZE ZO_INIT_SIZE
10730 #else
10731 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
10732 index db75d07..8e6d0af 100644
10733 --- a/arch/x86/boot/memory.c
10734 +++ b/arch/x86/boot/memory.c
10735 @@ -19,7 +19,7 @@
10736
10737 static int detect_memory_e820(void)
10738 {
10739 - int count = 0;
10740 + unsigned int count = 0;
10741 struct biosregs ireg, oreg;
10742 struct e820entry *desc = boot_params.e820_map;
10743 static struct e820entry buf; /* static so it is zeroed */
10744 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
10745 index 11e8c6e..fdbb1ed 100644
10746 --- a/arch/x86/boot/video-vesa.c
10747 +++ b/arch/x86/boot/video-vesa.c
10748 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
10749
10750 boot_params.screen_info.vesapm_seg = oreg.es;
10751 boot_params.screen_info.vesapm_off = oreg.di;
10752 + boot_params.screen_info.vesapm_size = oreg.cx;
10753 }
10754
10755 /*
10756 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
10757 index 43eda28..5ab5fdb 100644
10758 --- a/arch/x86/boot/video.c
10759 +++ b/arch/x86/boot/video.c
10760 @@ -96,7 +96,7 @@ static void store_mode_params(void)
10761 static unsigned int get_entry(void)
10762 {
10763 char entry_buf[4];
10764 - int i, len = 0;
10765 + unsigned int i, len = 0;
10766 int key;
10767 unsigned int v;
10768
10769 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
10770 index 9105655..5e37f27 100644
10771 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
10772 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
10773 @@ -8,6 +8,8 @@
10774 * including this sentence is retained in full.
10775 */
10776
10777 +#include <asm/alternative-asm.h>
10778 +
10779 .extern crypto_ft_tab
10780 .extern crypto_it_tab
10781 .extern crypto_fl_tab
10782 @@ -70,6 +72,8 @@
10783 je B192; \
10784 leaq 32(r9),r9;
10785
10786 +#define ret pax_force_retaddr 0, 1; ret
10787 +
10788 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
10789 movq r1,r2; \
10790 movq r3,r4; \
10791 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
10792 index 04b7977..402f223 100644
10793 --- a/arch/x86/crypto/aesni-intel_asm.S
10794 +++ b/arch/x86/crypto/aesni-intel_asm.S
10795 @@ -31,6 +31,7 @@
10796
10797 #include <linux/linkage.h>
10798 #include <asm/inst.h>
10799 +#include <asm/alternative-asm.h>
10800
10801 #ifdef __x86_64__
10802 .data
10803 @@ -1435,6 +1436,7 @@ _return_T_done_decrypt:
10804 pop %r14
10805 pop %r13
10806 pop %r12
10807 + pax_force_retaddr 0, 1
10808 ret
10809 ENDPROC(aesni_gcm_dec)
10810
10811 @@ -1699,6 +1701,7 @@ _return_T_done_encrypt:
10812 pop %r14
10813 pop %r13
10814 pop %r12
10815 + pax_force_retaddr 0, 1
10816 ret
10817 ENDPROC(aesni_gcm_enc)
10818
10819 @@ -1716,6 +1719,7 @@ _key_expansion_256a:
10820 pxor %xmm1, %xmm0
10821 movaps %xmm0, (TKEYP)
10822 add $0x10, TKEYP
10823 + pax_force_retaddr_bts
10824 ret
10825 ENDPROC(_key_expansion_128)
10826 ENDPROC(_key_expansion_256a)
10827 @@ -1742,6 +1746,7 @@ _key_expansion_192a:
10828 shufps $0b01001110, %xmm2, %xmm1
10829 movaps %xmm1, 0x10(TKEYP)
10830 add $0x20, TKEYP
10831 + pax_force_retaddr_bts
10832 ret
10833 ENDPROC(_key_expansion_192a)
10834
10835 @@ -1762,6 +1767,7 @@ _key_expansion_192b:
10836
10837 movaps %xmm0, (TKEYP)
10838 add $0x10, TKEYP
10839 + pax_force_retaddr_bts
10840 ret
10841 ENDPROC(_key_expansion_192b)
10842
10843 @@ -1775,6 +1781,7 @@ _key_expansion_256b:
10844 pxor %xmm1, %xmm2
10845 movaps %xmm2, (TKEYP)
10846 add $0x10, TKEYP
10847 + pax_force_retaddr_bts
10848 ret
10849 ENDPROC(_key_expansion_256b)
10850
10851 @@ -1888,6 +1895,7 @@ ENTRY(aesni_set_key)
10852 #ifndef __x86_64__
10853 popl KEYP
10854 #endif
10855 + pax_force_retaddr 0, 1
10856 ret
10857 ENDPROC(aesni_set_key)
10858
10859 @@ -1910,6 +1918,7 @@ ENTRY(aesni_enc)
10860 popl KLEN
10861 popl KEYP
10862 #endif
10863 + pax_force_retaddr 0, 1
10864 ret
10865 ENDPROC(aesni_enc)
10866
10867 @@ -1968,6 +1977,7 @@ _aesni_enc1:
10868 AESENC KEY STATE
10869 movaps 0x70(TKEYP), KEY
10870 AESENCLAST KEY STATE
10871 + pax_force_retaddr_bts
10872 ret
10873 ENDPROC(_aesni_enc1)
10874
10875 @@ -2077,6 +2087,7 @@ _aesni_enc4:
10876 AESENCLAST KEY STATE2
10877 AESENCLAST KEY STATE3
10878 AESENCLAST KEY STATE4
10879 + pax_force_retaddr_bts
10880 ret
10881 ENDPROC(_aesni_enc4)
10882
10883 @@ -2100,6 +2111,7 @@ ENTRY(aesni_dec)
10884 popl KLEN
10885 popl KEYP
10886 #endif
10887 + pax_force_retaddr 0, 1
10888 ret
10889 ENDPROC(aesni_dec)
10890
10891 @@ -2158,6 +2170,7 @@ _aesni_dec1:
10892 AESDEC KEY STATE
10893 movaps 0x70(TKEYP), KEY
10894 AESDECLAST KEY STATE
10895 + pax_force_retaddr_bts
10896 ret
10897 ENDPROC(_aesni_dec1)
10898
10899 @@ -2267,6 +2280,7 @@ _aesni_dec4:
10900 AESDECLAST KEY STATE2
10901 AESDECLAST KEY STATE3
10902 AESDECLAST KEY STATE4
10903 + pax_force_retaddr_bts
10904 ret
10905 ENDPROC(_aesni_dec4)
10906
10907 @@ -2325,6 +2339,7 @@ ENTRY(aesni_ecb_enc)
10908 popl KEYP
10909 popl LEN
10910 #endif
10911 + pax_force_retaddr 0, 1
10912 ret
10913 ENDPROC(aesni_ecb_enc)
10914
10915 @@ -2384,6 +2399,7 @@ ENTRY(aesni_ecb_dec)
10916 popl KEYP
10917 popl LEN
10918 #endif
10919 + pax_force_retaddr 0, 1
10920 ret
10921 ENDPROC(aesni_ecb_dec)
10922
10923 @@ -2426,6 +2442,7 @@ ENTRY(aesni_cbc_enc)
10924 popl LEN
10925 popl IVP
10926 #endif
10927 + pax_force_retaddr 0, 1
10928 ret
10929 ENDPROC(aesni_cbc_enc)
10930
10931 @@ -2517,6 +2534,7 @@ ENTRY(aesni_cbc_dec)
10932 popl LEN
10933 popl IVP
10934 #endif
10935 + pax_force_retaddr 0, 1
10936 ret
10937 ENDPROC(aesni_cbc_dec)
10938
10939 @@ -2544,6 +2562,7 @@ _aesni_inc_init:
10940 mov $1, TCTR_LOW
10941 MOVQ_R64_XMM TCTR_LOW INC
10942 MOVQ_R64_XMM CTR TCTR_LOW
10943 + pax_force_retaddr_bts
10944 ret
10945 ENDPROC(_aesni_inc_init)
10946
10947 @@ -2573,6 +2592,7 @@ _aesni_inc:
10948 .Linc_low:
10949 movaps CTR, IV
10950 PSHUFB_XMM BSWAP_MASK IV
10951 + pax_force_retaddr_bts
10952 ret
10953 ENDPROC(_aesni_inc)
10954
10955 @@ -2634,6 +2654,7 @@ ENTRY(aesni_ctr_enc)
10956 .Lctr_enc_ret:
10957 movups IV, (IVP)
10958 .Lctr_enc_just_ret:
10959 + pax_force_retaddr 0, 1
10960 ret
10961 ENDPROC(aesni_ctr_enc)
10962 #endif
10963 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10964 index 246c670..4d1ed00 100644
10965 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
10966 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10967 @@ -21,6 +21,7 @@
10968 */
10969
10970 #include <linux/linkage.h>
10971 +#include <asm/alternative-asm.h>
10972
10973 .file "blowfish-x86_64-asm.S"
10974 .text
10975 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
10976 jnz .L__enc_xor;
10977
10978 write_block();
10979 + pax_force_retaddr 0, 1
10980 ret;
10981 .L__enc_xor:
10982 xor_block();
10983 + pax_force_retaddr 0, 1
10984 ret;
10985 ENDPROC(__blowfish_enc_blk)
10986
10987 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
10988
10989 movq %r11, %rbp;
10990
10991 + pax_force_retaddr 0, 1
10992 ret;
10993 ENDPROC(blowfish_dec_blk)
10994
10995 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
10996
10997 popq %rbx;
10998 popq %rbp;
10999 + pax_force_retaddr 0, 1
11000 ret;
11001
11002 .L__enc_xor4:
11003 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
11004
11005 popq %rbx;
11006 popq %rbp;
11007 + pax_force_retaddr 0, 1
11008 ret;
11009 ENDPROC(__blowfish_enc_blk_4way)
11010
11011 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
11012 popq %rbx;
11013 popq %rbp;
11014
11015 + pax_force_retaddr 0, 1
11016 ret;
11017 ENDPROC(blowfish_dec_blk_4way)
11018 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
11019 index 310319c..ce174a4 100644
11020 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
11021 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
11022 @@ -21,6 +21,7 @@
11023 */
11024
11025 #include <linux/linkage.h>
11026 +#include <asm/alternative-asm.h>
11027
11028 .file "camellia-x86_64-asm_64.S"
11029 .text
11030 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
11031 enc_outunpack(mov, RT1);
11032
11033 movq RRBP, %rbp;
11034 + pax_force_retaddr 0, 1
11035 ret;
11036
11037 .L__enc_xor:
11038 enc_outunpack(xor, RT1);
11039
11040 movq RRBP, %rbp;
11041 + pax_force_retaddr 0, 1
11042 ret;
11043 ENDPROC(__camellia_enc_blk)
11044
11045 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
11046 dec_outunpack();
11047
11048 movq RRBP, %rbp;
11049 + pax_force_retaddr 0, 1
11050 ret;
11051 ENDPROC(camellia_dec_blk)
11052
11053 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
11054
11055 movq RRBP, %rbp;
11056 popq %rbx;
11057 + pax_force_retaddr 0, 1
11058 ret;
11059
11060 .L__enc2_xor:
11061 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
11062
11063 movq RRBP, %rbp;
11064 popq %rbx;
11065 + pax_force_retaddr 0, 1
11066 ret;
11067 ENDPROC(__camellia_enc_blk_2way)
11068
11069 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
11070
11071 movq RRBP, %rbp;
11072 movq RXOR, %rbx;
11073 + pax_force_retaddr 0, 1
11074 ret;
11075 ENDPROC(camellia_dec_blk_2way)
11076 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11077 index c35fd5d..c1ee236 100644
11078 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11079 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11080 @@ -24,6 +24,7 @@
11081 */
11082
11083 #include <linux/linkage.h>
11084 +#include <asm/alternative-asm.h>
11085
11086 .file "cast5-avx-x86_64-asm_64.S"
11087
11088 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
11089 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11090 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11091
11092 + pax_force_retaddr 0, 1
11093 ret;
11094 ENDPROC(__cast5_enc_blk16)
11095
11096 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
11097 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11098 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11099
11100 + pax_force_retaddr 0, 1
11101 ret;
11102
11103 .L__skip_dec:
11104 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
11105 vmovdqu RR4, (6*4*4)(%r11);
11106 vmovdqu RL4, (7*4*4)(%r11);
11107
11108 + pax_force_retaddr
11109 ret;
11110 ENDPROC(cast5_ecb_enc_16way)
11111
11112 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
11113 vmovdqu RR4, (6*4*4)(%r11);
11114 vmovdqu RL4, (7*4*4)(%r11);
11115
11116 + pax_force_retaddr
11117 ret;
11118 ENDPROC(cast5_ecb_dec_16way)
11119
11120 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
11121
11122 popq %r12;
11123
11124 + pax_force_retaddr
11125 ret;
11126 ENDPROC(cast5_cbc_dec_16way)
11127
11128 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
11129
11130 popq %r12;
11131
11132 + pax_force_retaddr
11133 ret;
11134 ENDPROC(cast5_ctr_16way)
11135 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11136 index f93b610..c09bf40 100644
11137 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11138 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11139 @@ -24,6 +24,7 @@
11140 */
11141
11142 #include <linux/linkage.h>
11143 +#include <asm/alternative-asm.h>
11144 #include "glue_helper-asm-avx.S"
11145
11146 .file "cast6-avx-x86_64-asm_64.S"
11147 @@ -293,6 +294,7 @@ __cast6_enc_blk8:
11148 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11149 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11150
11151 + pax_force_retaddr 0, 1
11152 ret;
11153 ENDPROC(__cast6_enc_blk8)
11154
11155 @@ -338,6 +340,7 @@ __cast6_dec_blk8:
11156 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11157 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11158
11159 + pax_force_retaddr 0, 1
11160 ret;
11161 ENDPROC(__cast6_dec_blk8)
11162
11163 @@ -356,6 +359,7 @@ ENTRY(cast6_ecb_enc_8way)
11164
11165 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11166
11167 + pax_force_retaddr
11168 ret;
11169 ENDPROC(cast6_ecb_enc_8way)
11170
11171 @@ -374,6 +378,7 @@ ENTRY(cast6_ecb_dec_8way)
11172
11173 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11174
11175 + pax_force_retaddr
11176 ret;
11177 ENDPROC(cast6_ecb_dec_8way)
11178
11179 @@ -397,6 +402,7 @@ ENTRY(cast6_cbc_dec_8way)
11180
11181 popq %r12;
11182
11183 + pax_force_retaddr
11184 ret;
11185 ENDPROC(cast6_cbc_dec_8way)
11186
11187 @@ -422,5 +428,6 @@ ENTRY(cast6_ctr_8way)
11188
11189 popq %r12;
11190
11191 + pax_force_retaddr
11192 ret;
11193 ENDPROC(cast6_ctr_8way)
11194 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11195 index 9279e0b..9270820 100644
11196 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11197 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11198 @@ -1,4 +1,5 @@
11199 #include <linux/linkage.h>
11200 +#include <asm/alternative-asm.h>
11201
11202 # enter salsa20_encrypt_bytes
11203 ENTRY(salsa20_encrypt_bytes)
11204 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
11205 add %r11,%rsp
11206 mov %rdi,%rax
11207 mov %rsi,%rdx
11208 + pax_force_retaddr 0, 1
11209 ret
11210 # bytesatleast65:
11211 ._bytesatleast65:
11212 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
11213 add %r11,%rsp
11214 mov %rdi,%rax
11215 mov %rsi,%rdx
11216 + pax_force_retaddr
11217 ret
11218 ENDPROC(salsa20_keysetup)
11219
11220 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
11221 add %r11,%rsp
11222 mov %rdi,%rax
11223 mov %rsi,%rdx
11224 + pax_force_retaddr
11225 ret
11226 ENDPROC(salsa20_ivsetup)
11227 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11228 index 43c9386..a0e2d60 100644
11229 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11230 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11231 @@ -25,6 +25,7 @@
11232 */
11233
11234 #include <linux/linkage.h>
11235 +#include <asm/alternative-asm.h>
11236 #include "glue_helper-asm-avx.S"
11237
11238 .file "serpent-avx-x86_64-asm_64.S"
11239 @@ -617,6 +618,7 @@ __serpent_enc_blk8_avx:
11240 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11241 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11242
11243 + pax_force_retaddr
11244 ret;
11245 ENDPROC(__serpent_enc_blk8_avx)
11246
11247 @@ -671,6 +673,7 @@ __serpent_dec_blk8_avx:
11248 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11249 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11250
11251 + pax_force_retaddr
11252 ret;
11253 ENDPROC(__serpent_dec_blk8_avx)
11254
11255 @@ -687,6 +690,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
11256
11257 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11258
11259 + pax_force_retaddr
11260 ret;
11261 ENDPROC(serpent_ecb_enc_8way_avx)
11262
11263 @@ -703,6 +707,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
11264
11265 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11266
11267 + pax_force_retaddr
11268 ret;
11269 ENDPROC(serpent_ecb_dec_8way_avx)
11270
11271 @@ -719,6 +724,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
11272
11273 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11274
11275 + pax_force_retaddr
11276 ret;
11277 ENDPROC(serpent_cbc_dec_8way_avx)
11278
11279 @@ -737,5 +743,6 @@ ENTRY(serpent_ctr_8way_avx)
11280
11281 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11282
11283 + pax_force_retaddr
11284 ret;
11285 ENDPROC(serpent_ctr_8way_avx)
11286 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11287 index acc066c..1559cc4 100644
11288 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11289 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11290 @@ -25,6 +25,7 @@
11291 */
11292
11293 #include <linux/linkage.h>
11294 +#include <asm/alternative-asm.h>
11295
11296 .file "serpent-sse2-x86_64-asm_64.S"
11297 .text
11298 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
11299 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11300 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11301
11302 + pax_force_retaddr
11303 ret;
11304
11305 .L__enc_xor8:
11306 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11307 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11308
11309 + pax_force_retaddr
11310 ret;
11311 ENDPROC(__serpent_enc_blk_8way)
11312
11313 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
11314 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11315 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11316
11317 + pax_force_retaddr
11318 ret;
11319 ENDPROC(serpent_dec_blk_8way)
11320 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11321 index a410950..3356d42 100644
11322 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11323 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11324 @@ -29,6 +29,7 @@
11325 */
11326
11327 #include <linux/linkage.h>
11328 +#include <asm/alternative-asm.h>
11329
11330 #define CTX %rdi // arg1
11331 #define BUF %rsi // arg2
11332 @@ -104,6 +105,7 @@
11333 pop %r12
11334 pop %rbp
11335 pop %rbx
11336 + pax_force_retaddr 0, 1
11337 ret
11338
11339 ENDPROC(\name)
11340 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11341 index 8d3e113..898b161 100644
11342 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11343 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11344 @@ -24,6 +24,7 @@
11345 */
11346
11347 #include <linux/linkage.h>
11348 +#include <asm/alternative-asm.h>
11349 #include "glue_helper-asm-avx.S"
11350
11351 .file "twofish-avx-x86_64-asm_64.S"
11352 @@ -282,6 +283,7 @@ __twofish_enc_blk8:
11353 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11354 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11355
11356 + pax_force_retaddr 0, 1
11357 ret;
11358 ENDPROC(__twofish_enc_blk8)
11359
11360 @@ -322,6 +324,7 @@ __twofish_dec_blk8:
11361 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11362 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11363
11364 + pax_force_retaddr 0, 1
11365 ret;
11366 ENDPROC(__twofish_dec_blk8)
11367
11368 @@ -340,6 +343,7 @@ ENTRY(twofish_ecb_enc_8way)
11369
11370 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11371
11372 + pax_force_retaddr 0, 1
11373 ret;
11374 ENDPROC(twofish_ecb_enc_8way)
11375
11376 @@ -358,6 +362,7 @@ ENTRY(twofish_ecb_dec_8way)
11377
11378 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11379
11380 + pax_force_retaddr 0, 1
11381 ret;
11382 ENDPROC(twofish_ecb_dec_8way)
11383
11384 @@ -381,6 +386,7 @@ ENTRY(twofish_cbc_dec_8way)
11385
11386 popq %r12;
11387
11388 + pax_force_retaddr 0, 1
11389 ret;
11390 ENDPROC(twofish_cbc_dec_8way)
11391
11392 @@ -406,5 +412,6 @@ ENTRY(twofish_ctr_8way)
11393
11394 popq %r12;
11395
11396 + pax_force_retaddr 0, 1
11397 ret;
11398 ENDPROC(twofish_ctr_8way)
11399 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11400 index 1c3b7ce..b365c5e 100644
11401 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11402 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11403 @@ -21,6 +21,7 @@
11404 */
11405
11406 #include <linux/linkage.h>
11407 +#include <asm/alternative-asm.h>
11408
11409 .file "twofish-x86_64-asm-3way.S"
11410 .text
11411 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
11412 popq %r13;
11413 popq %r14;
11414 popq %r15;
11415 + pax_force_retaddr 0, 1
11416 ret;
11417
11418 .L__enc_xor3:
11419 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
11420 popq %r13;
11421 popq %r14;
11422 popq %r15;
11423 + pax_force_retaddr 0, 1
11424 ret;
11425 ENDPROC(__twofish_enc_blk_3way)
11426
11427 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
11428 popq %r13;
11429 popq %r14;
11430 popq %r15;
11431 + pax_force_retaddr 0, 1
11432 ret;
11433 ENDPROC(twofish_dec_blk_3way)
11434 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11435 index a039d21..29e7615 100644
11436 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11437 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11438 @@ -22,6 +22,7 @@
11439
11440 #include <linux/linkage.h>
11441 #include <asm/asm-offsets.h>
11442 +#include <asm/alternative-asm.h>
11443
11444 #define a_offset 0
11445 #define b_offset 4
11446 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
11447
11448 popq R1
11449 movq $1,%rax
11450 + pax_force_retaddr 0, 1
11451 ret
11452 ENDPROC(twofish_enc_blk)
11453
11454 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
11455
11456 popq R1
11457 movq $1,%rax
11458 + pax_force_retaddr 0, 1
11459 ret
11460 ENDPROC(twofish_dec_blk)
11461 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11462 index 03abf9b..a42ba29 100644
11463 --- a/arch/x86/ia32/ia32_aout.c
11464 +++ b/arch/x86/ia32/ia32_aout.c
11465 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11466 unsigned long dump_start, dump_size;
11467 struct user32 dump;
11468
11469 + memset(&dump, 0, sizeof(dump));
11470 +
11471 fs = get_fs();
11472 set_fs(KERNEL_DS);
11473 has_dumped = 1;
11474 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11475 index cf1a471..3bc4cf8 100644
11476 --- a/arch/x86/ia32/ia32_signal.c
11477 +++ b/arch/x86/ia32/ia32_signal.c
11478 @@ -340,7 +340,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
11479 sp -= frame_size;
11480 /* Align the stack pointer according to the i386 ABI,
11481 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11482 - sp = ((sp + 4) & -16ul) - 4;
11483 + sp = ((sp - 12) & -16ul) - 4;
11484 return (void __user *) sp;
11485 }
11486
11487 @@ -398,7 +398,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
11488 * These are actually not used anymore, but left because some
11489 * gdb versions depend on them as a marker.
11490 */
11491 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11492 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11493 } put_user_catch(err);
11494
11495 if (err)
11496 @@ -440,7 +440,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11497 0xb8,
11498 __NR_ia32_rt_sigreturn,
11499 0x80cd,
11500 - 0,
11501 + 0
11502 };
11503
11504 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
11505 @@ -463,16 +463,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11506
11507 if (ksig->ka.sa.sa_flags & SA_RESTORER)
11508 restorer = ksig->ka.sa.sa_restorer;
11509 + else if (current->mm->context.vdso)
11510 + /* Return stub is in 32bit vsyscall page */
11511 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11512 else
11513 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11514 - rt_sigreturn);
11515 + restorer = &frame->retcode;
11516 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11517
11518 /*
11519 * Not actually used anymore, but left because some gdb
11520 * versions need it.
11521 */
11522 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11523 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11524 } put_user_catch(err);
11525
11526 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
11527 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11528 index 474dc1b..be7bff5 100644
11529 --- a/arch/x86/ia32/ia32entry.S
11530 +++ b/arch/x86/ia32/ia32entry.S
11531 @@ -15,8 +15,10 @@
11532 #include <asm/irqflags.h>
11533 #include <asm/asm.h>
11534 #include <asm/smap.h>
11535 +#include <asm/pgtable.h>
11536 #include <linux/linkage.h>
11537 #include <linux/err.h>
11538 +#include <asm/alternative-asm.h>
11539
11540 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11541 #include <linux/elf-em.h>
11542 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11543 ENDPROC(native_irq_enable_sysexit)
11544 #endif
11545
11546 + .macro pax_enter_kernel_user
11547 + pax_set_fptr_mask
11548 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11549 + call pax_enter_kernel_user
11550 +#endif
11551 + .endm
11552 +
11553 + .macro pax_exit_kernel_user
11554 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11555 + call pax_exit_kernel_user
11556 +#endif
11557 +#ifdef CONFIG_PAX_RANDKSTACK
11558 + pushq %rax
11559 + pushq %r11
11560 + call pax_randomize_kstack
11561 + popq %r11
11562 + popq %rax
11563 +#endif
11564 + .endm
11565 +
11566 +.macro pax_erase_kstack
11567 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11568 + call pax_erase_kstack
11569 +#endif
11570 +.endm
11571 +
11572 /*
11573 * 32bit SYSENTER instruction entry.
11574 *
11575 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11576 CFI_REGISTER rsp,rbp
11577 SWAPGS_UNSAFE_STACK
11578 movq PER_CPU_VAR(kernel_stack), %rsp
11579 - addq $(KERNEL_STACK_OFFSET),%rsp
11580 - /*
11581 - * No need to follow this irqs on/off section: the syscall
11582 - * disabled irqs, here we enable it straight after entry:
11583 - */
11584 - ENABLE_INTERRUPTS(CLBR_NONE)
11585 movl %ebp,%ebp /* zero extension */
11586 pushq_cfi $__USER32_DS
11587 /*CFI_REL_OFFSET ss,0*/
11588 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11589 CFI_REL_OFFSET rsp,0
11590 pushfq_cfi
11591 /*CFI_REL_OFFSET rflags,0*/
11592 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11593 - CFI_REGISTER rip,r10
11594 + orl $X86_EFLAGS_IF,(%rsp)
11595 + GET_THREAD_INFO(%r11)
11596 + movl TI_sysenter_return(%r11), %r11d
11597 + CFI_REGISTER rip,r11
11598 pushq_cfi $__USER32_CS
11599 /*CFI_REL_OFFSET cs,0*/
11600 movl %eax, %eax
11601 - pushq_cfi %r10
11602 + pushq_cfi %r11
11603 CFI_REL_OFFSET rip,0
11604 pushq_cfi %rax
11605 cld
11606 SAVE_ARGS 0,1,0
11607 + pax_enter_kernel_user
11608 +
11609 +#ifdef CONFIG_PAX_RANDKSTACK
11610 + pax_erase_kstack
11611 +#endif
11612 +
11613 + /*
11614 + * No need to follow this irqs on/off section: the syscall
11615 + * disabled irqs, here we enable it straight after entry:
11616 + */
11617 + ENABLE_INTERRUPTS(CLBR_NONE)
11618 /* no need to do an access_ok check here because rbp has been
11619 32bit zero extended */
11620 +
11621 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11622 + mov pax_user_shadow_base,%r11
11623 + add %r11,%rbp
11624 +#endif
11625 +
11626 ASM_STAC
11627 1: movl (%rbp),%ebp
11628 _ASM_EXTABLE(1b,ia32_badarg)
11629 ASM_CLAC
11630 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11631 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11632 + GET_THREAD_INFO(%r11)
11633 + orl $TS_COMPAT,TI_status(%r11)
11634 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11635 CFI_REMEMBER_STATE
11636 jnz sysenter_tracesys
11637 cmpq $(IA32_NR_syscalls-1),%rax
11638 @@ -162,12 +204,15 @@ sysenter_do_call:
11639 sysenter_dispatch:
11640 call *ia32_sys_call_table(,%rax,8)
11641 movq %rax,RAX-ARGOFFSET(%rsp)
11642 + GET_THREAD_INFO(%r11)
11643 DISABLE_INTERRUPTS(CLBR_NONE)
11644 TRACE_IRQS_OFF
11645 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11646 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11647 jnz sysexit_audit
11648 sysexit_from_sys_call:
11649 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11650 + pax_exit_kernel_user
11651 + pax_erase_kstack
11652 + andl $~TS_COMPAT,TI_status(%r11)
11653 /* clear IF, that popfq doesn't enable interrupts early */
11654 andl $~0x200,EFLAGS-R11(%rsp)
11655 movl RIP-R11(%rsp),%edx /* User %eip */
11656 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11657 movl %eax,%esi /* 2nd arg: syscall number */
11658 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11659 call __audit_syscall_entry
11660 +
11661 + pax_erase_kstack
11662 +
11663 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11664 cmpq $(IA32_NR_syscalls-1),%rax
11665 ja ia32_badsys
11666 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11667 .endm
11668
11669 .macro auditsys_exit exit
11670 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11671 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11672 jnz ia32_ret_from_sys_call
11673 TRACE_IRQS_ON
11674 ENABLE_INTERRUPTS(CLBR_NONE)
11675 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11676 1: setbe %al /* 1 if error, 0 if not */
11677 movzbl %al,%edi /* zero-extend that into %edi */
11678 call __audit_syscall_exit
11679 + GET_THREAD_INFO(%r11)
11680 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11681 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11682 DISABLE_INTERRUPTS(CLBR_NONE)
11683 TRACE_IRQS_OFF
11684 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11685 + testl %edi,TI_flags(%r11)
11686 jz \exit
11687 CLEAR_RREGS -ARGOFFSET
11688 jmp int_with_check
11689 @@ -237,7 +286,7 @@ sysexit_audit:
11690
11691 sysenter_tracesys:
11692 #ifdef CONFIG_AUDITSYSCALL
11693 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11694 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11695 jz sysenter_auditsys
11696 #endif
11697 SAVE_REST
11698 @@ -249,6 +298,9 @@ sysenter_tracesys:
11699 RESTORE_REST
11700 cmpq $(IA32_NR_syscalls-1),%rax
11701 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
11702 +
11703 + pax_erase_kstack
11704 +
11705 jmp sysenter_do_call
11706 CFI_ENDPROC
11707 ENDPROC(ia32_sysenter_target)
11708 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
11709 ENTRY(ia32_cstar_target)
11710 CFI_STARTPROC32 simple
11711 CFI_SIGNAL_FRAME
11712 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
11713 + CFI_DEF_CFA rsp,0
11714 CFI_REGISTER rip,rcx
11715 /*CFI_REGISTER rflags,r11*/
11716 SWAPGS_UNSAFE_STACK
11717 movl %esp,%r8d
11718 CFI_REGISTER rsp,r8
11719 movq PER_CPU_VAR(kernel_stack),%rsp
11720 + SAVE_ARGS 8*6,0,0
11721 + pax_enter_kernel_user
11722 +
11723 +#ifdef CONFIG_PAX_RANDKSTACK
11724 + pax_erase_kstack
11725 +#endif
11726 +
11727 /*
11728 * No need to follow this irqs on/off section: the syscall
11729 * disabled irqs and here we enable it straight after entry:
11730 */
11731 ENABLE_INTERRUPTS(CLBR_NONE)
11732 - SAVE_ARGS 8,0,0
11733 movl %eax,%eax /* zero extension */
11734 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
11735 movq %rcx,RIP-ARGOFFSET(%rsp)
11736 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
11737 /* no need to do an access_ok check here because r8 has been
11738 32bit zero extended */
11739 /* hardware stack frame is complete now */
11740 +
11741 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11742 + mov pax_user_shadow_base,%r11
11743 + add %r11,%r8
11744 +#endif
11745 +
11746 ASM_STAC
11747 1: movl (%r8),%r9d
11748 _ASM_EXTABLE(1b,ia32_badarg)
11749 ASM_CLAC
11750 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11751 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11752 + GET_THREAD_INFO(%r11)
11753 + orl $TS_COMPAT,TI_status(%r11)
11754 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11755 CFI_REMEMBER_STATE
11756 jnz cstar_tracesys
11757 cmpq $IA32_NR_syscalls-1,%rax
11758 @@ -319,12 +384,15 @@ cstar_do_call:
11759 cstar_dispatch:
11760 call *ia32_sys_call_table(,%rax,8)
11761 movq %rax,RAX-ARGOFFSET(%rsp)
11762 + GET_THREAD_INFO(%r11)
11763 DISABLE_INTERRUPTS(CLBR_NONE)
11764 TRACE_IRQS_OFF
11765 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11766 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11767 jnz sysretl_audit
11768 sysretl_from_sys_call:
11769 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11770 + pax_exit_kernel_user
11771 + pax_erase_kstack
11772 + andl $~TS_COMPAT,TI_status(%r11)
11773 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
11774 movl RIP-ARGOFFSET(%rsp),%ecx
11775 CFI_REGISTER rip,rcx
11776 @@ -352,7 +420,7 @@ sysretl_audit:
11777
11778 cstar_tracesys:
11779 #ifdef CONFIG_AUDITSYSCALL
11780 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11781 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11782 jz cstar_auditsys
11783 #endif
11784 xchgl %r9d,%ebp
11785 @@ -366,6 +434,9 @@ cstar_tracesys:
11786 xchgl %ebp,%r9d
11787 cmpq $(IA32_NR_syscalls-1),%rax
11788 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
11789 +
11790 + pax_erase_kstack
11791 +
11792 jmp cstar_do_call
11793 END(ia32_cstar_target)
11794
11795 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
11796 CFI_REL_OFFSET rip,RIP-RIP
11797 PARAVIRT_ADJUST_EXCEPTION_FRAME
11798 SWAPGS
11799 - /*
11800 - * No need to follow this irqs on/off section: the syscall
11801 - * disabled irqs and here we enable it straight after entry:
11802 - */
11803 - ENABLE_INTERRUPTS(CLBR_NONE)
11804 movl %eax,%eax
11805 pushq_cfi %rax
11806 cld
11807 /* note the registers are not zero extended to the sf.
11808 this could be a problem. */
11809 SAVE_ARGS 0,1,0
11810 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11811 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11812 + pax_enter_kernel_user
11813 +
11814 +#ifdef CONFIG_PAX_RANDKSTACK
11815 + pax_erase_kstack
11816 +#endif
11817 +
11818 + /*
11819 + * No need to follow this irqs on/off section: the syscall
11820 + * disabled irqs and here we enable it straight after entry:
11821 + */
11822 + ENABLE_INTERRUPTS(CLBR_NONE)
11823 + GET_THREAD_INFO(%r11)
11824 + orl $TS_COMPAT,TI_status(%r11)
11825 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11826 jnz ia32_tracesys
11827 cmpq $(IA32_NR_syscalls-1),%rax
11828 ja ia32_badsys
11829 @@ -442,6 +520,9 @@ ia32_tracesys:
11830 RESTORE_REST
11831 cmpq $(IA32_NR_syscalls-1),%rax
11832 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
11833 +
11834 + pax_erase_kstack
11835 +
11836 jmp ia32_do_call
11837 END(ia32_syscall)
11838
11839 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
11840 index ad7a20c..1ffa3c1 100644
11841 --- a/arch/x86/ia32/sys_ia32.c
11842 +++ b/arch/x86/ia32/sys_ia32.c
11843 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
11844 */
11845 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
11846 {
11847 - typeof(ubuf->st_uid) uid = 0;
11848 - typeof(ubuf->st_gid) gid = 0;
11849 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
11850 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
11851 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
11852 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
11853 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
11854 @@ -205,7 +205,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
11855 return -EFAULT;
11856
11857 set_fs(KERNEL_DS);
11858 - ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
11859 + ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __force_user *)&of : NULL,
11860 count);
11861 set_fs(old_fs);
11862
11863 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
11864 index 372231c..a5aa1a1 100644
11865 --- a/arch/x86/include/asm/alternative-asm.h
11866 +++ b/arch/x86/include/asm/alternative-asm.h
11867 @@ -18,6 +18,45 @@
11868 .endm
11869 #endif
11870
11871 +#ifdef KERNEXEC_PLUGIN
11872 + .macro pax_force_retaddr_bts rip=0
11873 + btsq $63,\rip(%rsp)
11874 + .endm
11875 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
11876 + .macro pax_force_retaddr rip=0, reload=0
11877 + btsq $63,\rip(%rsp)
11878 + .endm
11879 + .macro pax_force_fptr ptr
11880 + btsq $63,\ptr
11881 + .endm
11882 + .macro pax_set_fptr_mask
11883 + .endm
11884 +#endif
11885 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
11886 + .macro pax_force_retaddr rip=0, reload=0
11887 + .if \reload
11888 + pax_set_fptr_mask
11889 + .endif
11890 + orq %r10,\rip(%rsp)
11891 + .endm
11892 + .macro pax_force_fptr ptr
11893 + orq %r10,\ptr
11894 + .endm
11895 + .macro pax_set_fptr_mask
11896 + movabs $0x8000000000000000,%r10
11897 + .endm
11898 +#endif
11899 +#else
11900 + .macro pax_force_retaddr rip=0, reload=0
11901 + .endm
11902 + .macro pax_force_fptr ptr
11903 + .endm
11904 + .macro pax_force_retaddr_bts rip=0
11905 + .endm
11906 + .macro pax_set_fptr_mask
11907 + .endm
11908 +#endif
11909 +
11910 .macro altinstruction_entry orig alt feature orig_len alt_len
11911 .long \orig - .
11912 .long \alt - .
11913 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
11914 index 58ed6d9..f1cbe58 100644
11915 --- a/arch/x86/include/asm/alternative.h
11916 +++ b/arch/x86/include/asm/alternative.h
11917 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11918 ".pushsection .discard,\"aw\",@progbits\n" \
11919 DISCARD_ENTRY(1) \
11920 ".popsection\n" \
11921 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11922 + ".pushsection .altinstr_replacement, \"a\"\n" \
11923 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
11924 ".popsection"
11925
11926 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11927 DISCARD_ENTRY(1) \
11928 DISCARD_ENTRY(2) \
11929 ".popsection\n" \
11930 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11931 + ".pushsection .altinstr_replacement, \"a\"\n" \
11932 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
11933 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
11934 ".popsection"
11935 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
11936 index 3388034..050f0b9 100644
11937 --- a/arch/x86/include/asm/apic.h
11938 +++ b/arch/x86/include/asm/apic.h
11939 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
11940
11941 #ifdef CONFIG_X86_LOCAL_APIC
11942
11943 -extern unsigned int apic_verbosity;
11944 +extern int apic_verbosity;
11945 extern int local_apic_timer_c2_ok;
11946
11947 extern int disable_apic;
11948 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
11949 index 20370c6..a2eb9b0 100644
11950 --- a/arch/x86/include/asm/apm.h
11951 +++ b/arch/x86/include/asm/apm.h
11952 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
11953 __asm__ __volatile__(APM_DO_ZERO_SEGS
11954 "pushl %%edi\n\t"
11955 "pushl %%ebp\n\t"
11956 - "lcall *%%cs:apm_bios_entry\n\t"
11957 + "lcall *%%ss:apm_bios_entry\n\t"
11958 "setc %%al\n\t"
11959 "popl %%ebp\n\t"
11960 "popl %%edi\n\t"
11961 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
11962 __asm__ __volatile__(APM_DO_ZERO_SEGS
11963 "pushl %%edi\n\t"
11964 "pushl %%ebp\n\t"
11965 - "lcall *%%cs:apm_bios_entry\n\t"
11966 + "lcall *%%ss:apm_bios_entry\n\t"
11967 "setc %%bl\n\t"
11968 "popl %%ebp\n\t"
11969 "popl %%edi\n\t"
11970 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
11971 index 722aa3b..3a0bb27 100644
11972 --- a/arch/x86/include/asm/atomic.h
11973 +++ b/arch/x86/include/asm/atomic.h
11974 @@ -22,7 +22,18 @@
11975 */
11976 static inline int atomic_read(const atomic_t *v)
11977 {
11978 - return (*(volatile int *)&(v)->counter);
11979 + return (*(volatile const int *)&(v)->counter);
11980 +}
11981 +
11982 +/**
11983 + * atomic_read_unchecked - read atomic variable
11984 + * @v: pointer of type atomic_unchecked_t
11985 + *
11986 + * Atomically reads the value of @v.
11987 + */
11988 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
11989 +{
11990 + return (*(volatile const int *)&(v)->counter);
11991 }
11992
11993 /**
11994 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
11995 }
11996
11997 /**
11998 + * atomic_set_unchecked - set atomic variable
11999 + * @v: pointer of type atomic_unchecked_t
12000 + * @i: required value
12001 + *
12002 + * Atomically sets the value of @v to @i.
12003 + */
12004 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
12005 +{
12006 + v->counter = i;
12007 +}
12008 +
12009 +/**
12010 * atomic_add - add integer to atomic variable
12011 * @i: integer value to add
12012 * @v: pointer of type atomic_t
12013 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
12014 */
12015 static inline void atomic_add(int i, atomic_t *v)
12016 {
12017 - asm volatile(LOCK_PREFIX "addl %1,%0"
12018 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12019 +
12020 +#ifdef CONFIG_PAX_REFCOUNT
12021 + "jno 0f\n"
12022 + LOCK_PREFIX "subl %1,%0\n"
12023 + "int $4\n0:\n"
12024 + _ASM_EXTABLE(0b, 0b)
12025 +#endif
12026 +
12027 + : "+m" (v->counter)
12028 + : "ir" (i));
12029 +}
12030 +
12031 +/**
12032 + * atomic_add_unchecked - add integer to atomic variable
12033 + * @i: integer value to add
12034 + * @v: pointer of type atomic_unchecked_t
12035 + *
12036 + * Atomically adds @i to @v.
12037 + */
12038 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
12039 +{
12040 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12041 : "+m" (v->counter)
12042 : "ir" (i));
12043 }
12044 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
12045 */
12046 static inline void atomic_sub(int i, atomic_t *v)
12047 {
12048 - asm volatile(LOCK_PREFIX "subl %1,%0"
12049 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12050 +
12051 +#ifdef CONFIG_PAX_REFCOUNT
12052 + "jno 0f\n"
12053 + LOCK_PREFIX "addl %1,%0\n"
12054 + "int $4\n0:\n"
12055 + _ASM_EXTABLE(0b, 0b)
12056 +#endif
12057 +
12058 + : "+m" (v->counter)
12059 + : "ir" (i));
12060 +}
12061 +
12062 +/**
12063 + * atomic_sub_unchecked - subtract integer from atomic variable
12064 + * @i: integer value to subtract
12065 + * @v: pointer of type atomic_unchecked_t
12066 + *
12067 + * Atomically subtracts @i from @v.
12068 + */
12069 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
12070 +{
12071 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12072 : "+m" (v->counter)
12073 : "ir" (i));
12074 }
12075 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12076 {
12077 unsigned char c;
12078
12079 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
12080 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
12081 +
12082 +#ifdef CONFIG_PAX_REFCOUNT
12083 + "jno 0f\n"
12084 + LOCK_PREFIX "addl %2,%0\n"
12085 + "int $4\n0:\n"
12086 + _ASM_EXTABLE(0b, 0b)
12087 +#endif
12088 +
12089 + "sete %1\n"
12090 : "+m" (v->counter), "=qm" (c)
12091 : "ir" (i) : "memory");
12092 return c;
12093 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12094 */
12095 static inline void atomic_inc(atomic_t *v)
12096 {
12097 - asm volatile(LOCK_PREFIX "incl %0"
12098 + asm volatile(LOCK_PREFIX "incl %0\n"
12099 +
12100 +#ifdef CONFIG_PAX_REFCOUNT
12101 + "jno 0f\n"
12102 + LOCK_PREFIX "decl %0\n"
12103 + "int $4\n0:\n"
12104 + _ASM_EXTABLE(0b, 0b)
12105 +#endif
12106 +
12107 + : "+m" (v->counter));
12108 +}
12109 +
12110 +/**
12111 + * atomic_inc_unchecked - increment atomic variable
12112 + * @v: pointer of type atomic_unchecked_t
12113 + *
12114 + * Atomically increments @v by 1.
12115 + */
12116 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12117 +{
12118 + asm volatile(LOCK_PREFIX "incl %0\n"
12119 : "+m" (v->counter));
12120 }
12121
12122 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12123 */
12124 static inline void atomic_dec(atomic_t *v)
12125 {
12126 - asm volatile(LOCK_PREFIX "decl %0"
12127 + asm volatile(LOCK_PREFIX "decl %0\n"
12128 +
12129 +#ifdef CONFIG_PAX_REFCOUNT
12130 + "jno 0f\n"
12131 + LOCK_PREFIX "incl %0\n"
12132 + "int $4\n0:\n"
12133 + _ASM_EXTABLE(0b, 0b)
12134 +#endif
12135 +
12136 + : "+m" (v->counter));
12137 +}
12138 +
12139 +/**
12140 + * atomic_dec_unchecked - decrement atomic variable
12141 + * @v: pointer of type atomic_unchecked_t
12142 + *
12143 + * Atomically decrements @v by 1.
12144 + */
12145 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12146 +{
12147 + asm volatile(LOCK_PREFIX "decl %0\n"
12148 : "+m" (v->counter));
12149 }
12150
12151 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12152 {
12153 unsigned char c;
12154
12155 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12156 + asm volatile(LOCK_PREFIX "decl %0\n"
12157 +
12158 +#ifdef CONFIG_PAX_REFCOUNT
12159 + "jno 0f\n"
12160 + LOCK_PREFIX "incl %0\n"
12161 + "int $4\n0:\n"
12162 + _ASM_EXTABLE(0b, 0b)
12163 +#endif
12164 +
12165 + "sete %1\n"
12166 : "+m" (v->counter), "=qm" (c)
12167 : : "memory");
12168 return c != 0;
12169 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12170 {
12171 unsigned char c;
12172
12173 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
12174 + asm volatile(LOCK_PREFIX "incl %0\n"
12175 +
12176 +#ifdef CONFIG_PAX_REFCOUNT
12177 + "jno 0f\n"
12178 + LOCK_PREFIX "decl %0\n"
12179 + "int $4\n0:\n"
12180 + _ASM_EXTABLE(0b, 0b)
12181 +#endif
12182 +
12183 + "sete %1\n"
12184 + : "+m" (v->counter), "=qm" (c)
12185 + : : "memory");
12186 + return c != 0;
12187 +}
12188 +
12189 +/**
12190 + * atomic_inc_and_test_unchecked - increment and test
12191 + * @v: pointer of type atomic_unchecked_t
12192 + *
12193 + * Atomically increments @v by 1
12194 + * and returns true if the result is zero, or false for all
12195 + * other cases.
12196 + */
12197 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12198 +{
12199 + unsigned char c;
12200 +
12201 + asm volatile(LOCK_PREFIX "incl %0\n"
12202 + "sete %1\n"
12203 : "+m" (v->counter), "=qm" (c)
12204 : : "memory");
12205 return c != 0;
12206 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12207 {
12208 unsigned char c;
12209
12210 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12211 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12212 +
12213 +#ifdef CONFIG_PAX_REFCOUNT
12214 + "jno 0f\n"
12215 + LOCK_PREFIX "subl %2,%0\n"
12216 + "int $4\n0:\n"
12217 + _ASM_EXTABLE(0b, 0b)
12218 +#endif
12219 +
12220 + "sets %1\n"
12221 : "+m" (v->counter), "=qm" (c)
12222 : "ir" (i) : "memory");
12223 return c;
12224 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12225 */
12226 static inline int atomic_add_return(int i, atomic_t *v)
12227 {
12228 + return i + xadd_check_overflow(&v->counter, i);
12229 +}
12230 +
12231 +/**
12232 + * atomic_add_return_unchecked - add integer and return
12233 + * @i: integer value to add
12234 + * @v: pointer of type atomic_unchecked_t
12235 + *
12236 + * Atomically adds @i to @v and returns @i + @v
12237 + */
12238 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12239 +{
12240 return i + xadd(&v->counter, i);
12241 }
12242
12243 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12244 }
12245
12246 #define atomic_inc_return(v) (atomic_add_return(1, v))
12247 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12248 +{
12249 + return atomic_add_return_unchecked(1, v);
12250 +}
12251 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12252
12253 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12254 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12255 return cmpxchg(&v->counter, old, new);
12256 }
12257
12258 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12259 +{
12260 + return cmpxchg(&v->counter, old, new);
12261 +}
12262 +
12263 static inline int atomic_xchg(atomic_t *v, int new)
12264 {
12265 return xchg(&v->counter, new);
12266 }
12267
12268 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12269 +{
12270 + return xchg(&v->counter, new);
12271 +}
12272 +
12273 /**
12274 * __atomic_add_unless - add unless the number is already a given value
12275 * @v: pointer of type atomic_t
12276 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12277 */
12278 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12279 {
12280 - int c, old;
12281 + int c, old, new;
12282 c = atomic_read(v);
12283 for (;;) {
12284 - if (unlikely(c == (u)))
12285 + if (unlikely(c == u))
12286 break;
12287 - old = atomic_cmpxchg((v), c, c + (a));
12288 +
12289 + asm volatile("addl %2,%0\n"
12290 +
12291 +#ifdef CONFIG_PAX_REFCOUNT
12292 + "jno 0f\n"
12293 + "subl %2,%0\n"
12294 + "int $4\n0:\n"
12295 + _ASM_EXTABLE(0b, 0b)
12296 +#endif
12297 +
12298 + : "=r" (new)
12299 + : "0" (c), "ir" (a));
12300 +
12301 + old = atomic_cmpxchg(v, c, new);
12302 if (likely(old == c))
12303 break;
12304 c = old;
12305 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12306 }
12307
12308 /**
12309 + * atomic_inc_not_zero_hint - increment if not null
12310 + * @v: pointer of type atomic_t
12311 + * @hint: probable value of the atomic before the increment
12312 + *
12313 + * This version of atomic_inc_not_zero() gives a hint of probable
12314 + * value of the atomic. This helps processor to not read the memory
12315 + * before doing the atomic read/modify/write cycle, lowering
12316 + * number of bus transactions on some arches.
12317 + *
12318 + * Returns: 0 if increment was not done, 1 otherwise.
12319 + */
12320 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12321 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12322 +{
12323 + int val, c = hint, new;
12324 +
12325 + /* sanity test, should be removed by compiler if hint is a constant */
12326 + if (!hint)
12327 + return __atomic_add_unless(v, 1, 0);
12328 +
12329 + do {
12330 + asm volatile("incl %0\n"
12331 +
12332 +#ifdef CONFIG_PAX_REFCOUNT
12333 + "jno 0f\n"
12334 + "decl %0\n"
12335 + "int $4\n0:\n"
12336 + _ASM_EXTABLE(0b, 0b)
12337 +#endif
12338 +
12339 + : "=r" (new)
12340 + : "0" (c));
12341 +
12342 + val = atomic_cmpxchg(v, c, new);
12343 + if (val == c)
12344 + return 1;
12345 + c = val;
12346 + } while (c);
12347 +
12348 + return 0;
12349 +}
12350 +
12351 +/**
12352 * atomic_inc_short - increment of a short integer
12353 * @v: pointer to type int
12354 *
12355 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12356 #endif
12357
12358 /* These are x86-specific, used by some header files */
12359 -#define atomic_clear_mask(mask, addr) \
12360 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12361 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12362 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12363 +{
12364 + asm volatile(LOCK_PREFIX "andl %1,%0"
12365 + : "+m" (v->counter)
12366 + : "r" (~(mask))
12367 + : "memory");
12368 +}
12369
12370 -#define atomic_set_mask(mask, addr) \
12371 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12372 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12373 - : "memory")
12374 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12375 +{
12376 + asm volatile(LOCK_PREFIX "andl %1,%0"
12377 + : "+m" (v->counter)
12378 + : "r" (~(mask))
12379 + : "memory");
12380 +}
12381 +
12382 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12383 +{
12384 + asm volatile(LOCK_PREFIX "orl %1,%0"
12385 + : "+m" (v->counter)
12386 + : "r" (mask)
12387 + : "memory");
12388 +}
12389 +
12390 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12391 +{
12392 + asm volatile(LOCK_PREFIX "orl %1,%0"
12393 + : "+m" (v->counter)
12394 + : "r" (mask)
12395 + : "memory");
12396 +}
12397
12398 /* Atomic operations are already serializing on x86 */
12399 #define smp_mb__before_atomic_dec() barrier()
12400 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12401 index b154de7..aadebd8 100644
12402 --- a/arch/x86/include/asm/atomic64_32.h
12403 +++ b/arch/x86/include/asm/atomic64_32.h
12404 @@ -12,6 +12,14 @@ typedef struct {
12405 u64 __aligned(8) counter;
12406 } atomic64_t;
12407
12408 +#ifdef CONFIG_PAX_REFCOUNT
12409 +typedef struct {
12410 + u64 __aligned(8) counter;
12411 +} atomic64_unchecked_t;
12412 +#else
12413 +typedef atomic64_t atomic64_unchecked_t;
12414 +#endif
12415 +
12416 #define ATOMIC64_INIT(val) { (val) }
12417
12418 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12419 @@ -37,21 +45,31 @@ typedef struct {
12420 ATOMIC64_DECL_ONE(sym##_386)
12421
12422 ATOMIC64_DECL_ONE(add_386);
12423 +ATOMIC64_DECL_ONE(add_unchecked_386);
12424 ATOMIC64_DECL_ONE(sub_386);
12425 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12426 ATOMIC64_DECL_ONE(inc_386);
12427 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12428 ATOMIC64_DECL_ONE(dec_386);
12429 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12430 #endif
12431
12432 #define alternative_atomic64(f, out, in...) \
12433 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12434
12435 ATOMIC64_DECL(read);
12436 +ATOMIC64_DECL(read_unchecked);
12437 ATOMIC64_DECL(set);
12438 +ATOMIC64_DECL(set_unchecked);
12439 ATOMIC64_DECL(xchg);
12440 ATOMIC64_DECL(add_return);
12441 +ATOMIC64_DECL(add_return_unchecked);
12442 ATOMIC64_DECL(sub_return);
12443 +ATOMIC64_DECL(sub_return_unchecked);
12444 ATOMIC64_DECL(inc_return);
12445 +ATOMIC64_DECL(inc_return_unchecked);
12446 ATOMIC64_DECL(dec_return);
12447 +ATOMIC64_DECL(dec_return_unchecked);
12448 ATOMIC64_DECL(dec_if_positive);
12449 ATOMIC64_DECL(inc_not_zero);
12450 ATOMIC64_DECL(add_unless);
12451 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12452 }
12453
12454 /**
12455 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12456 + * @p: pointer to type atomic64_unchecked_t
12457 + * @o: expected value
12458 + * @n: new value
12459 + *
12460 + * Atomically sets @v to @n if it was equal to @o and returns
12461 + * the old value.
12462 + */
12463 +
12464 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12465 +{
12466 + return cmpxchg64(&v->counter, o, n);
12467 +}
12468 +
12469 +/**
12470 * atomic64_xchg - xchg atomic64 variable
12471 * @v: pointer to type atomic64_t
12472 * @n: value to assign
12473 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12474 }
12475
12476 /**
12477 + * atomic64_set_unchecked - set atomic64 variable
12478 + * @v: pointer to type atomic64_unchecked_t
12479 + * @n: value to assign
12480 + *
12481 + * Atomically sets the value of @v to @n.
12482 + */
12483 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12484 +{
12485 + unsigned high = (unsigned)(i >> 32);
12486 + unsigned low = (unsigned)i;
12487 + alternative_atomic64(set, /* no output */,
12488 + "S" (v), "b" (low), "c" (high)
12489 + : "eax", "edx", "memory");
12490 +}
12491 +
12492 +/**
12493 * atomic64_read - read atomic64 variable
12494 * @v: pointer to type atomic64_t
12495 *
12496 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12497 }
12498
12499 /**
12500 + * atomic64_read_unchecked - read atomic64 variable
12501 + * @v: pointer to type atomic64_unchecked_t
12502 + *
12503 + * Atomically reads the value of @v and returns it.
12504 + */
12505 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12506 +{
12507 + long long r;
12508 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12509 + return r;
12510 + }
12511 +
12512 +/**
12513 * atomic64_add_return - add and return
12514 * @i: integer value to add
12515 * @v: pointer to type atomic64_t
12516 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12517 return i;
12518 }
12519
12520 +/**
12521 + * atomic64_add_return_unchecked - add and return
12522 + * @i: integer value to add
12523 + * @v: pointer to type atomic64_unchecked_t
12524 + *
12525 + * Atomically adds @i to @v and returns @i + *@v
12526 + */
12527 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12528 +{
12529 + alternative_atomic64(add_return_unchecked,
12530 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12531 + ASM_NO_INPUT_CLOBBER("memory"));
12532 + return i;
12533 +}
12534 +
12535 /*
12536 * Other variants with different arithmetic operators:
12537 */
12538 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12539 return a;
12540 }
12541
12542 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12543 +{
12544 + long long a;
12545 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12546 + "S" (v) : "memory", "ecx");
12547 + return a;
12548 +}
12549 +
12550 static inline long long atomic64_dec_return(atomic64_t *v)
12551 {
12552 long long a;
12553 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12554 }
12555
12556 /**
12557 + * atomic64_add_unchecked - add integer to atomic64 variable
12558 + * @i: integer value to add
12559 + * @v: pointer to type atomic64_unchecked_t
12560 + *
12561 + * Atomically adds @i to @v.
12562 + */
12563 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12564 +{
12565 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12566 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12567 + ASM_NO_INPUT_CLOBBER("memory"));
12568 + return i;
12569 +}
12570 +
12571 +/**
12572 * atomic64_sub - subtract the atomic64 variable
12573 * @i: integer value to subtract
12574 * @v: pointer to type atomic64_t
12575 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12576 index 0e1cbfc..5623683 100644
12577 --- a/arch/x86/include/asm/atomic64_64.h
12578 +++ b/arch/x86/include/asm/atomic64_64.h
12579 @@ -18,7 +18,19 @@
12580 */
12581 static inline long atomic64_read(const atomic64_t *v)
12582 {
12583 - return (*(volatile long *)&(v)->counter);
12584 + return (*(volatile const long *)&(v)->counter);
12585 +}
12586 +
12587 +/**
12588 + * atomic64_read_unchecked - read atomic64 variable
12589 + * @v: pointer of type atomic64_unchecked_t
12590 + *
12591 + * Atomically reads the value of @v.
12592 + * Doesn't imply a read memory barrier.
12593 + */
12594 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12595 +{
12596 + return (*(volatile const long *)&(v)->counter);
12597 }
12598
12599 /**
12600 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12601 }
12602
12603 /**
12604 + * atomic64_set_unchecked - set atomic64 variable
12605 + * @v: pointer to type atomic64_unchecked_t
12606 + * @i: required value
12607 + *
12608 + * Atomically sets the value of @v to @i.
12609 + */
12610 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12611 +{
12612 + v->counter = i;
12613 +}
12614 +
12615 +/**
12616 * atomic64_add - add integer to atomic64 variable
12617 * @i: integer value to add
12618 * @v: pointer to type atomic64_t
12619 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12620 */
12621 static inline void atomic64_add(long i, atomic64_t *v)
12622 {
12623 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12624 +
12625 +#ifdef CONFIG_PAX_REFCOUNT
12626 + "jno 0f\n"
12627 + LOCK_PREFIX "subq %1,%0\n"
12628 + "int $4\n0:\n"
12629 + _ASM_EXTABLE(0b, 0b)
12630 +#endif
12631 +
12632 + : "=m" (v->counter)
12633 + : "er" (i), "m" (v->counter));
12634 +}
12635 +
12636 +/**
12637 + * atomic64_add_unchecked - add integer to atomic64 variable
12638 + * @i: integer value to add
12639 + * @v: pointer to type atomic64_unchecked_t
12640 + *
12641 + * Atomically adds @i to @v.
12642 + */
12643 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12644 +{
12645 asm volatile(LOCK_PREFIX "addq %1,%0"
12646 : "=m" (v->counter)
12647 : "er" (i), "m" (v->counter));
12648 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
12649 */
12650 static inline void atomic64_sub(long i, atomic64_t *v)
12651 {
12652 - asm volatile(LOCK_PREFIX "subq %1,%0"
12653 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12654 +
12655 +#ifdef CONFIG_PAX_REFCOUNT
12656 + "jno 0f\n"
12657 + LOCK_PREFIX "addq %1,%0\n"
12658 + "int $4\n0:\n"
12659 + _ASM_EXTABLE(0b, 0b)
12660 +#endif
12661 +
12662 + : "=m" (v->counter)
12663 + : "er" (i), "m" (v->counter));
12664 +}
12665 +
12666 +/**
12667 + * atomic64_sub_unchecked - subtract the atomic64 variable
12668 + * @i: integer value to subtract
12669 + * @v: pointer to type atomic64_unchecked_t
12670 + *
12671 + * Atomically subtracts @i from @v.
12672 + */
12673 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
12674 +{
12675 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12676 : "=m" (v->counter)
12677 : "er" (i), "m" (v->counter));
12678 }
12679 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12680 {
12681 unsigned char c;
12682
12683 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
12684 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
12685 +
12686 +#ifdef CONFIG_PAX_REFCOUNT
12687 + "jno 0f\n"
12688 + LOCK_PREFIX "addq %2,%0\n"
12689 + "int $4\n0:\n"
12690 + _ASM_EXTABLE(0b, 0b)
12691 +#endif
12692 +
12693 + "sete %1\n"
12694 : "=m" (v->counter), "=qm" (c)
12695 : "er" (i), "m" (v->counter) : "memory");
12696 return c;
12697 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12698 */
12699 static inline void atomic64_inc(atomic64_t *v)
12700 {
12701 + asm volatile(LOCK_PREFIX "incq %0\n"
12702 +
12703 +#ifdef CONFIG_PAX_REFCOUNT
12704 + "jno 0f\n"
12705 + LOCK_PREFIX "decq %0\n"
12706 + "int $4\n0:\n"
12707 + _ASM_EXTABLE(0b, 0b)
12708 +#endif
12709 +
12710 + : "=m" (v->counter)
12711 + : "m" (v->counter));
12712 +}
12713 +
12714 +/**
12715 + * atomic64_inc_unchecked - increment atomic64 variable
12716 + * @v: pointer to type atomic64_unchecked_t
12717 + *
12718 + * Atomically increments @v by 1.
12719 + */
12720 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
12721 +{
12722 asm volatile(LOCK_PREFIX "incq %0"
12723 : "=m" (v->counter)
12724 : "m" (v->counter));
12725 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
12726 */
12727 static inline void atomic64_dec(atomic64_t *v)
12728 {
12729 - asm volatile(LOCK_PREFIX "decq %0"
12730 + asm volatile(LOCK_PREFIX "decq %0\n"
12731 +
12732 +#ifdef CONFIG_PAX_REFCOUNT
12733 + "jno 0f\n"
12734 + LOCK_PREFIX "incq %0\n"
12735 + "int $4\n0:\n"
12736 + _ASM_EXTABLE(0b, 0b)
12737 +#endif
12738 +
12739 + : "=m" (v->counter)
12740 + : "m" (v->counter));
12741 +}
12742 +
12743 +/**
12744 + * atomic64_dec_unchecked - decrement atomic64 variable
12745 + * @v: pointer to type atomic64_t
12746 + *
12747 + * Atomically decrements @v by 1.
12748 + */
12749 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
12750 +{
12751 + asm volatile(LOCK_PREFIX "decq %0\n"
12752 : "=m" (v->counter)
12753 : "m" (v->counter));
12754 }
12755 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
12756 {
12757 unsigned char c;
12758
12759 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
12760 + asm volatile(LOCK_PREFIX "decq %0\n"
12761 +
12762 +#ifdef CONFIG_PAX_REFCOUNT
12763 + "jno 0f\n"
12764 + LOCK_PREFIX "incq %0\n"
12765 + "int $4\n0:\n"
12766 + _ASM_EXTABLE(0b, 0b)
12767 +#endif
12768 +
12769 + "sete %1\n"
12770 : "=m" (v->counter), "=qm" (c)
12771 : "m" (v->counter) : "memory");
12772 return c != 0;
12773 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
12774 {
12775 unsigned char c;
12776
12777 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
12778 + asm volatile(LOCK_PREFIX "incq %0\n"
12779 +
12780 +#ifdef CONFIG_PAX_REFCOUNT
12781 + "jno 0f\n"
12782 + LOCK_PREFIX "decq %0\n"
12783 + "int $4\n0:\n"
12784 + _ASM_EXTABLE(0b, 0b)
12785 +#endif
12786 +
12787 + "sete %1\n"
12788 : "=m" (v->counter), "=qm" (c)
12789 : "m" (v->counter) : "memory");
12790 return c != 0;
12791 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12792 {
12793 unsigned char c;
12794
12795 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
12796 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
12797 +
12798 +#ifdef CONFIG_PAX_REFCOUNT
12799 + "jno 0f\n"
12800 + LOCK_PREFIX "subq %2,%0\n"
12801 + "int $4\n0:\n"
12802 + _ASM_EXTABLE(0b, 0b)
12803 +#endif
12804 +
12805 + "sets %1\n"
12806 : "=m" (v->counter), "=qm" (c)
12807 : "er" (i), "m" (v->counter) : "memory");
12808 return c;
12809 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12810 */
12811 static inline long atomic64_add_return(long i, atomic64_t *v)
12812 {
12813 + return i + xadd_check_overflow(&v->counter, i);
12814 +}
12815 +
12816 +/**
12817 + * atomic64_add_return_unchecked - add and return
12818 + * @i: integer value to add
12819 + * @v: pointer to type atomic64_unchecked_t
12820 + *
12821 + * Atomically adds @i to @v and returns @i + @v
12822 + */
12823 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
12824 +{
12825 return i + xadd(&v->counter, i);
12826 }
12827
12828 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
12829 }
12830
12831 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
12832 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12833 +{
12834 + return atomic64_add_return_unchecked(1, v);
12835 +}
12836 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
12837
12838 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12839 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12840 return cmpxchg(&v->counter, old, new);
12841 }
12842
12843 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
12844 +{
12845 + return cmpxchg(&v->counter, old, new);
12846 +}
12847 +
12848 static inline long atomic64_xchg(atomic64_t *v, long new)
12849 {
12850 return xchg(&v->counter, new);
12851 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
12852 */
12853 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
12854 {
12855 - long c, old;
12856 + long c, old, new;
12857 c = atomic64_read(v);
12858 for (;;) {
12859 - if (unlikely(c == (u)))
12860 + if (unlikely(c == u))
12861 break;
12862 - old = atomic64_cmpxchg((v), c, c + (a));
12863 +
12864 + asm volatile("add %2,%0\n"
12865 +
12866 +#ifdef CONFIG_PAX_REFCOUNT
12867 + "jno 0f\n"
12868 + "sub %2,%0\n"
12869 + "int $4\n0:\n"
12870 + _ASM_EXTABLE(0b, 0b)
12871 +#endif
12872 +
12873 + : "=r" (new)
12874 + : "0" (c), "ir" (a));
12875 +
12876 + old = atomic64_cmpxchg(v, c, new);
12877 if (likely(old == c))
12878 break;
12879 c = old;
12880 }
12881 - return c != (u);
12882 + return c != u;
12883 }
12884
12885 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
12886 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
12887 index 6dfd019..28e188d 100644
12888 --- a/arch/x86/include/asm/bitops.h
12889 +++ b/arch/x86/include/asm/bitops.h
12890 @@ -40,7 +40,7 @@
12891 * a mask operation on a byte.
12892 */
12893 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
12894 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
12895 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
12896 #define CONST_MASK(nr) (1 << ((nr) & 7))
12897
12898 /**
12899 @@ -486,7 +486,7 @@ static inline int fls(int x)
12900 * at position 64.
12901 */
12902 #ifdef CONFIG_X86_64
12903 -static __always_inline int fls64(__u64 x)
12904 +static __always_inline long fls64(__u64 x)
12905 {
12906 int bitpos = -1;
12907 /*
12908 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
12909 index 4fa687a..60f2d39 100644
12910 --- a/arch/x86/include/asm/boot.h
12911 +++ b/arch/x86/include/asm/boot.h
12912 @@ -6,10 +6,15 @@
12913 #include <uapi/asm/boot.h>
12914
12915 /* Physical address where kernel should be loaded. */
12916 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12917 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12918 + (CONFIG_PHYSICAL_ALIGN - 1)) \
12919 & ~(CONFIG_PHYSICAL_ALIGN - 1))
12920
12921 +#ifndef __ASSEMBLY__
12922 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
12923 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
12924 +#endif
12925 +
12926 /* Minimum kernel alignment, as a power of two */
12927 #ifdef CONFIG_X86_64
12928 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
12929 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
12930 index 48f99f1..d78ebf9 100644
12931 --- a/arch/x86/include/asm/cache.h
12932 +++ b/arch/x86/include/asm/cache.h
12933 @@ -5,12 +5,13 @@
12934
12935 /* L1 cache line size */
12936 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
12937 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12938 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12939
12940 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
12941 +#define __read_only __attribute__((__section__(".data..read_only")))
12942
12943 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
12944 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
12945 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
12946
12947 #ifdef CONFIG_X86_VSMP
12948 #ifdef CONFIG_SMP
12949 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
12950 index 9863ee3..4a1f8e1 100644
12951 --- a/arch/x86/include/asm/cacheflush.h
12952 +++ b/arch/x86/include/asm/cacheflush.h
12953 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
12954 unsigned long pg_flags = pg->flags & _PGMT_MASK;
12955
12956 if (pg_flags == _PGMT_DEFAULT)
12957 - return -1;
12958 + return ~0UL;
12959 else if (pg_flags == _PGMT_WC)
12960 return _PAGE_CACHE_WC;
12961 else if (pg_flags == _PGMT_UC_MINUS)
12962 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
12963 index 46fc474..b02b0f9 100644
12964 --- a/arch/x86/include/asm/checksum_32.h
12965 +++ b/arch/x86/include/asm/checksum_32.h
12966 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
12967 int len, __wsum sum,
12968 int *src_err_ptr, int *dst_err_ptr);
12969
12970 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
12971 + int len, __wsum sum,
12972 + int *src_err_ptr, int *dst_err_ptr);
12973 +
12974 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
12975 + int len, __wsum sum,
12976 + int *src_err_ptr, int *dst_err_ptr);
12977 +
12978 /*
12979 * Note: when you get a NULL pointer exception here this means someone
12980 * passed in an incorrect kernel address to one of these functions.
12981 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
12982 int *err_ptr)
12983 {
12984 might_sleep();
12985 - return csum_partial_copy_generic((__force void *)src, dst,
12986 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
12987 len, sum, err_ptr, NULL);
12988 }
12989
12990 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
12991 {
12992 might_sleep();
12993 if (access_ok(VERIFY_WRITE, dst, len))
12994 - return csum_partial_copy_generic(src, (__force void *)dst,
12995 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
12996 len, sum, NULL, err_ptr);
12997
12998 if (len)
12999 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
13000 index 8d871ea..c1a0dc9 100644
13001 --- a/arch/x86/include/asm/cmpxchg.h
13002 +++ b/arch/x86/include/asm/cmpxchg.h
13003 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
13004 __compiletime_error("Bad argument size for cmpxchg");
13005 extern void __xadd_wrong_size(void)
13006 __compiletime_error("Bad argument size for xadd");
13007 +extern void __xadd_check_overflow_wrong_size(void)
13008 + __compiletime_error("Bad argument size for xadd_check_overflow");
13009 extern void __add_wrong_size(void)
13010 __compiletime_error("Bad argument size for add");
13011 +extern void __add_check_overflow_wrong_size(void)
13012 + __compiletime_error("Bad argument size for add_check_overflow");
13013
13014 /*
13015 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
13016 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
13017 __ret; \
13018 })
13019
13020 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
13021 + ({ \
13022 + __typeof__ (*(ptr)) __ret = (arg); \
13023 + switch (sizeof(*(ptr))) { \
13024 + case __X86_CASE_L: \
13025 + asm volatile (lock #op "l %0, %1\n" \
13026 + "jno 0f\n" \
13027 + "mov %0,%1\n" \
13028 + "int $4\n0:\n" \
13029 + _ASM_EXTABLE(0b, 0b) \
13030 + : "+r" (__ret), "+m" (*(ptr)) \
13031 + : : "memory", "cc"); \
13032 + break; \
13033 + case __X86_CASE_Q: \
13034 + asm volatile (lock #op "q %q0, %1\n" \
13035 + "jno 0f\n" \
13036 + "mov %0,%1\n" \
13037 + "int $4\n0:\n" \
13038 + _ASM_EXTABLE(0b, 0b) \
13039 + : "+r" (__ret), "+m" (*(ptr)) \
13040 + : : "memory", "cc"); \
13041 + break; \
13042 + default: \
13043 + __ ## op ## _check_overflow_wrong_size(); \
13044 + } \
13045 + __ret; \
13046 + })
13047 +
13048 /*
13049 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
13050 * Since this is generally used to protect other memory information, we
13051 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
13052 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
13053 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
13054
13055 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
13056 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
13057 +
13058 #define __add(ptr, inc, lock) \
13059 ({ \
13060 __typeof__ (*(ptr)) __ret = (inc); \
13061 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
13062 index 59c6c40..5e0b22c 100644
13063 --- a/arch/x86/include/asm/compat.h
13064 +++ b/arch/x86/include/asm/compat.h
13065 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
13066 typedef u32 compat_uint_t;
13067 typedef u32 compat_ulong_t;
13068 typedef u64 __attribute__((aligned(4))) compat_u64;
13069 -typedef u32 compat_uptr_t;
13070 +typedef u32 __user compat_uptr_t;
13071
13072 struct compat_timespec {
13073 compat_time_t tv_sec;
13074 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
13075 index 93fe929..90858b7 100644
13076 --- a/arch/x86/include/asm/cpufeature.h
13077 +++ b/arch/x86/include/asm/cpufeature.h
13078 @@ -207,7 +207,7 @@
13079 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
13080 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
13081 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
13082 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
13083 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
13084 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
13085 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
13086 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
13087 @@ -377,7 +377,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
13088 ".section .discard,\"aw\",@progbits\n"
13089 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
13090 ".previous\n"
13091 - ".section .altinstr_replacement,\"ax\"\n"
13092 + ".section .altinstr_replacement,\"a\"\n"
13093 "3: movb $1,%0\n"
13094 "4:\n"
13095 ".previous\n"
13096 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
13097 index 8bf1c06..b6ae785 100644
13098 --- a/arch/x86/include/asm/desc.h
13099 +++ b/arch/x86/include/asm/desc.h
13100 @@ -4,6 +4,7 @@
13101 #include <asm/desc_defs.h>
13102 #include <asm/ldt.h>
13103 #include <asm/mmu.h>
13104 +#include <asm/pgtable.h>
13105
13106 #include <linux/smp.h>
13107 #include <linux/percpu.h>
13108 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13109
13110 desc->type = (info->read_exec_only ^ 1) << 1;
13111 desc->type |= info->contents << 2;
13112 + desc->type |= info->seg_not_present ^ 1;
13113
13114 desc->s = 1;
13115 desc->dpl = 0x3;
13116 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13117 }
13118
13119 extern struct desc_ptr idt_descr;
13120 -extern gate_desc idt_table[];
13121 extern struct desc_ptr nmi_idt_descr;
13122 -extern gate_desc nmi_idt_table[];
13123 -
13124 -struct gdt_page {
13125 - struct desc_struct gdt[GDT_ENTRIES];
13126 -} __attribute__((aligned(PAGE_SIZE)));
13127 -
13128 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13129 +extern gate_desc idt_table[256];
13130 +extern gate_desc nmi_idt_table[256];
13131
13132 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13133 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13134 {
13135 - return per_cpu(gdt_page, cpu).gdt;
13136 + return cpu_gdt_table[cpu];
13137 }
13138
13139 #ifdef CONFIG_X86_64
13140 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13141 unsigned long base, unsigned dpl, unsigned flags,
13142 unsigned short seg)
13143 {
13144 - gate->a = (seg << 16) | (base & 0xffff);
13145 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13146 + gate->gate.offset_low = base;
13147 + gate->gate.seg = seg;
13148 + gate->gate.reserved = 0;
13149 + gate->gate.type = type;
13150 + gate->gate.s = 0;
13151 + gate->gate.dpl = dpl;
13152 + gate->gate.p = 1;
13153 + gate->gate.offset_high = base >> 16;
13154 }
13155
13156 #endif
13157 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13158
13159 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13160 {
13161 + pax_open_kernel();
13162 memcpy(&idt[entry], gate, sizeof(*gate));
13163 + pax_close_kernel();
13164 }
13165
13166 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13167 {
13168 + pax_open_kernel();
13169 memcpy(&ldt[entry], desc, 8);
13170 + pax_close_kernel();
13171 }
13172
13173 static inline void
13174 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13175 default: size = sizeof(*gdt); break;
13176 }
13177
13178 + pax_open_kernel();
13179 memcpy(&gdt[entry], desc, size);
13180 + pax_close_kernel();
13181 }
13182
13183 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13184 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13185
13186 static inline void native_load_tr_desc(void)
13187 {
13188 + pax_open_kernel();
13189 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13190 + pax_close_kernel();
13191 }
13192
13193 static inline void native_load_gdt(const struct desc_ptr *dtr)
13194 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13195 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13196 unsigned int i;
13197
13198 + pax_open_kernel();
13199 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13200 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13201 + pax_close_kernel();
13202 }
13203
13204 #define _LDT_empty(info) \
13205 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13206 preempt_enable();
13207 }
13208
13209 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13210 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13211 {
13212 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13213 }
13214 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13215 }
13216
13217 #ifdef CONFIG_X86_64
13218 -static inline void set_nmi_gate(int gate, void *addr)
13219 +static inline void set_nmi_gate(int gate, const void *addr)
13220 {
13221 gate_desc s;
13222
13223 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13224 }
13225 #endif
13226
13227 -static inline void _set_gate(int gate, unsigned type, void *addr,
13228 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13229 unsigned dpl, unsigned ist, unsigned seg)
13230 {
13231 gate_desc s;
13232 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13233 * Pentium F0 0F bugfix can have resulted in the mapped
13234 * IDT being write-protected.
13235 */
13236 -static inline void set_intr_gate(unsigned int n, void *addr)
13237 +static inline void set_intr_gate(unsigned int n, const void *addr)
13238 {
13239 BUG_ON((unsigned)n > 0xFF);
13240 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13241 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13242 /*
13243 * This routine sets up an interrupt gate at directory privilege level 3.
13244 */
13245 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13246 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13247 {
13248 BUG_ON((unsigned)n > 0xFF);
13249 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13250 }
13251
13252 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13253 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13254 {
13255 BUG_ON((unsigned)n > 0xFF);
13256 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13257 }
13258
13259 -static inline void set_trap_gate(unsigned int n, void *addr)
13260 +static inline void set_trap_gate(unsigned int n, const void *addr)
13261 {
13262 BUG_ON((unsigned)n > 0xFF);
13263 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13264 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13265 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13266 {
13267 BUG_ON((unsigned)n > 0xFF);
13268 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13269 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13270 }
13271
13272 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13273 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13274 {
13275 BUG_ON((unsigned)n > 0xFF);
13276 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13277 }
13278
13279 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13280 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13281 {
13282 BUG_ON((unsigned)n > 0xFF);
13283 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13284 }
13285
13286 +#ifdef CONFIG_X86_32
13287 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13288 +{
13289 + struct desc_struct d;
13290 +
13291 + if (likely(limit))
13292 + limit = (limit - 1UL) >> PAGE_SHIFT;
13293 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13294 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13295 +}
13296 +#endif
13297 +
13298 #endif /* _ASM_X86_DESC_H */
13299 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13300 index 278441f..b95a174 100644
13301 --- a/arch/x86/include/asm/desc_defs.h
13302 +++ b/arch/x86/include/asm/desc_defs.h
13303 @@ -31,6 +31,12 @@ struct desc_struct {
13304 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13305 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13306 };
13307 + struct {
13308 + u16 offset_low;
13309 + u16 seg;
13310 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13311 + unsigned offset_high: 16;
13312 + } gate;
13313 };
13314 } __attribute__((packed));
13315
13316 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13317 index ced283a..ffe04cc 100644
13318 --- a/arch/x86/include/asm/div64.h
13319 +++ b/arch/x86/include/asm/div64.h
13320 @@ -39,7 +39,7 @@
13321 __mod; \
13322 })
13323
13324 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13325 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13326 {
13327 union {
13328 u64 v64;
13329 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13330 index 9c999c1..3860cb8 100644
13331 --- a/arch/x86/include/asm/elf.h
13332 +++ b/arch/x86/include/asm/elf.h
13333 @@ -243,7 +243,25 @@ extern int force_personality32;
13334 the loader. We need to make sure that it is out of the way of the program
13335 that it will "exec", and that there is sufficient room for the brk. */
13336
13337 +#ifdef CONFIG_PAX_SEGMEXEC
13338 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13339 +#else
13340 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13341 +#endif
13342 +
13343 +#ifdef CONFIG_PAX_ASLR
13344 +#ifdef CONFIG_X86_32
13345 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13346 +
13347 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13348 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13349 +#else
13350 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13351 +
13352 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13353 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13354 +#endif
13355 +#endif
13356
13357 /* This yields a mask that user programs can use to figure out what
13358 instruction set this CPU supports. This could be done in user space,
13359 @@ -296,16 +314,12 @@ do { \
13360
13361 #define ARCH_DLINFO \
13362 do { \
13363 - if (vdso_enabled) \
13364 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13365 - (unsigned long)current->mm->context.vdso); \
13366 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13367 } while (0)
13368
13369 #define ARCH_DLINFO_X32 \
13370 do { \
13371 - if (vdso_enabled) \
13372 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13373 - (unsigned long)current->mm->context.vdso); \
13374 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13375 } while (0)
13376
13377 #define AT_SYSINFO 32
13378 @@ -320,7 +334,7 @@ else \
13379
13380 #endif /* !CONFIG_X86_32 */
13381
13382 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13383 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13384
13385 #define VDSO_ENTRY \
13386 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13387 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13388 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13389 #define compat_arch_setup_additional_pages syscall32_setup_pages
13390
13391 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13392 -#define arch_randomize_brk arch_randomize_brk
13393 -
13394 /*
13395 * True on X86_32 or when emulating IA32 on X86_64
13396 */
13397 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13398 index 75ce3f4..882e801 100644
13399 --- a/arch/x86/include/asm/emergency-restart.h
13400 +++ b/arch/x86/include/asm/emergency-restart.h
13401 @@ -13,6 +13,6 @@ enum reboot_type {
13402
13403 extern enum reboot_type reboot_type;
13404
13405 -extern void machine_emergency_restart(void);
13406 +extern void machine_emergency_restart(void) __noreturn;
13407
13408 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13409 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13410 index e25cc33..425d099 100644
13411 --- a/arch/x86/include/asm/fpu-internal.h
13412 +++ b/arch/x86/include/asm/fpu-internal.h
13413 @@ -127,7 +127,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13414 ({ \
13415 int err; \
13416 asm volatile(ASM_STAC "\n" \
13417 - "1:" #insn "\n\t" \
13418 + "1:" \
13419 + __copyuser_seg \
13420 + #insn "\n\t" \
13421 "2: " ASM_CLAC "\n" \
13422 ".section .fixup,\"ax\"\n" \
13423 "3: movl $-1,%[err]\n" \
13424 @@ -300,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13425 "emms\n\t" /* clear stack tags */
13426 "fildl %P[addr]", /* set F?P to defined value */
13427 X86_FEATURE_FXSAVE_LEAK,
13428 - [addr] "m" (tsk->thread.fpu.has_fpu));
13429 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13430
13431 return fpu_restore_checking(&tsk->thread.fpu);
13432 }
13433 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13434 index be27ba1..8f13ff9 100644
13435 --- a/arch/x86/include/asm/futex.h
13436 +++ b/arch/x86/include/asm/futex.h
13437 @@ -12,6 +12,7 @@
13438 #include <asm/smap.h>
13439
13440 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13441 + typecheck(u32 __user *, uaddr); \
13442 asm volatile("\t" ASM_STAC "\n" \
13443 "1:\t" insn "\n" \
13444 "2:\t" ASM_CLAC "\n" \
13445 @@ -20,15 +21,16 @@
13446 "\tjmp\t2b\n" \
13447 "\t.previous\n" \
13448 _ASM_EXTABLE(1b, 3b) \
13449 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13450 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13451 : "i" (-EFAULT), "0" (oparg), "1" (0))
13452
13453 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13454 + typecheck(u32 __user *, uaddr); \
13455 asm volatile("\t" ASM_STAC "\n" \
13456 "1:\tmovl %2, %0\n" \
13457 "\tmovl\t%0, %3\n" \
13458 "\t" insn "\n" \
13459 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13460 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13461 "\tjnz\t1b\n" \
13462 "3:\t" ASM_CLAC "\n" \
13463 "\t.section .fixup,\"ax\"\n" \
13464 @@ -38,7 +40,7 @@
13465 _ASM_EXTABLE(1b, 4b) \
13466 _ASM_EXTABLE(2b, 4b) \
13467 : "=&a" (oldval), "=&r" (ret), \
13468 - "+m" (*uaddr), "=&r" (tem) \
13469 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13470 : "r" (oparg), "i" (-EFAULT), "1" (0))
13471
13472 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13473 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13474
13475 switch (op) {
13476 case FUTEX_OP_SET:
13477 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13478 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13479 break;
13480 case FUTEX_OP_ADD:
13481 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13482 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13483 uaddr, oparg);
13484 break;
13485 case FUTEX_OP_OR:
13486 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13487 return -EFAULT;
13488
13489 asm volatile("\t" ASM_STAC "\n"
13490 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13491 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13492 "2:\t" ASM_CLAC "\n"
13493 "\t.section .fixup, \"ax\"\n"
13494 "3:\tmov %3, %0\n"
13495 "\tjmp 2b\n"
13496 "\t.previous\n"
13497 _ASM_EXTABLE(1b, 3b)
13498 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13499 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13500 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13501 : "memory"
13502 );
13503 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13504 index 10a78c3..cc77143 100644
13505 --- a/arch/x86/include/asm/hw_irq.h
13506 +++ b/arch/x86/include/asm/hw_irq.h
13507 @@ -147,8 +147,8 @@ extern void setup_ioapic_dest(void);
13508 extern void enable_IO_APIC(void);
13509
13510 /* Statistics */
13511 -extern atomic_t irq_err_count;
13512 -extern atomic_t irq_mis_count;
13513 +extern atomic_unchecked_t irq_err_count;
13514 +extern atomic_unchecked_t irq_mis_count;
13515
13516 /* EISA */
13517 extern void eisa_set_level_irq(unsigned int irq);
13518 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13519 index a203659..9889f1c 100644
13520 --- a/arch/x86/include/asm/i8259.h
13521 +++ b/arch/x86/include/asm/i8259.h
13522 @@ -62,7 +62,7 @@ struct legacy_pic {
13523 void (*init)(int auto_eoi);
13524 int (*irq_pending)(unsigned int irq);
13525 void (*make_irq)(unsigned int irq);
13526 -};
13527 +} __do_const;
13528
13529 extern struct legacy_pic *legacy_pic;
13530 extern struct legacy_pic null_legacy_pic;
13531 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13532 index d8e8eef..1765f78 100644
13533 --- a/arch/x86/include/asm/io.h
13534 +++ b/arch/x86/include/asm/io.h
13535 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13536 "m" (*(volatile type __force *)addr) barrier); }
13537
13538 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13539 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13540 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13541 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13542 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13543
13544 build_mmio_read(__readb, "b", unsigned char, "=q", )
13545 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13546 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13547 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13548 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13549
13550 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13551 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13552 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13553 return ioremap_nocache(offset, size);
13554 }
13555
13556 -extern void iounmap(volatile void __iomem *addr);
13557 +extern void iounmap(const volatile void __iomem *addr);
13558
13559 extern void set_iounmap_nonlazy(void);
13560
13561 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13562
13563 #include <linux/vmalloc.h>
13564
13565 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13566 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13567 +{
13568 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13569 +}
13570 +
13571 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13572 +{
13573 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13574 +}
13575 +
13576 /*
13577 * Convert a virtual cached pointer to an uncached pointer
13578 */
13579 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13580 index bba3cf8..06bc8da 100644
13581 --- a/arch/x86/include/asm/irqflags.h
13582 +++ b/arch/x86/include/asm/irqflags.h
13583 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13584 sti; \
13585 sysexit
13586
13587 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13588 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13589 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13590 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13591 +
13592 #else
13593 #define INTERRUPT_RETURN iret
13594 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13595 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13596 index 5a6d287..f815789 100644
13597 --- a/arch/x86/include/asm/kprobes.h
13598 +++ b/arch/x86/include/asm/kprobes.h
13599 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13600 #define RELATIVEJUMP_SIZE 5
13601 #define RELATIVECALL_OPCODE 0xe8
13602 #define RELATIVE_ADDR_SIZE 4
13603 -#define MAX_STACK_SIZE 64
13604 -#define MIN_STACK_SIZE(ADDR) \
13605 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13606 - THREAD_SIZE - (unsigned long)(ADDR))) \
13607 - ? (MAX_STACK_SIZE) \
13608 - : (((unsigned long)current_thread_info()) + \
13609 - THREAD_SIZE - (unsigned long)(ADDR)))
13610 +#define MAX_STACK_SIZE 64UL
13611 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13612
13613 #define flush_insn_slot(p) do { } while (0)
13614
13615 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13616 index 2d89e39..baee879 100644
13617 --- a/arch/x86/include/asm/local.h
13618 +++ b/arch/x86/include/asm/local.h
13619 @@ -10,33 +10,97 @@ typedef struct {
13620 atomic_long_t a;
13621 } local_t;
13622
13623 +typedef struct {
13624 + atomic_long_unchecked_t a;
13625 +} local_unchecked_t;
13626 +
13627 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13628
13629 #define local_read(l) atomic_long_read(&(l)->a)
13630 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13631 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13632 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13633
13634 static inline void local_inc(local_t *l)
13635 {
13636 - asm volatile(_ASM_INC "%0"
13637 + asm volatile(_ASM_INC "%0\n"
13638 +
13639 +#ifdef CONFIG_PAX_REFCOUNT
13640 + "jno 0f\n"
13641 + _ASM_DEC "%0\n"
13642 + "int $4\n0:\n"
13643 + _ASM_EXTABLE(0b, 0b)
13644 +#endif
13645 +
13646 + : "+m" (l->a.counter));
13647 +}
13648 +
13649 +static inline void local_inc_unchecked(local_unchecked_t *l)
13650 +{
13651 + asm volatile(_ASM_INC "%0\n"
13652 : "+m" (l->a.counter));
13653 }
13654
13655 static inline void local_dec(local_t *l)
13656 {
13657 - asm volatile(_ASM_DEC "%0"
13658 + asm volatile(_ASM_DEC "%0\n"
13659 +
13660 +#ifdef CONFIG_PAX_REFCOUNT
13661 + "jno 0f\n"
13662 + _ASM_INC "%0\n"
13663 + "int $4\n0:\n"
13664 + _ASM_EXTABLE(0b, 0b)
13665 +#endif
13666 +
13667 + : "+m" (l->a.counter));
13668 +}
13669 +
13670 +static inline void local_dec_unchecked(local_unchecked_t *l)
13671 +{
13672 + asm volatile(_ASM_DEC "%0\n"
13673 : "+m" (l->a.counter));
13674 }
13675
13676 static inline void local_add(long i, local_t *l)
13677 {
13678 - asm volatile(_ASM_ADD "%1,%0"
13679 + asm volatile(_ASM_ADD "%1,%0\n"
13680 +
13681 +#ifdef CONFIG_PAX_REFCOUNT
13682 + "jno 0f\n"
13683 + _ASM_SUB "%1,%0\n"
13684 + "int $4\n0:\n"
13685 + _ASM_EXTABLE(0b, 0b)
13686 +#endif
13687 +
13688 + : "+m" (l->a.counter)
13689 + : "ir" (i));
13690 +}
13691 +
13692 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
13693 +{
13694 + asm volatile(_ASM_ADD "%1,%0\n"
13695 : "+m" (l->a.counter)
13696 : "ir" (i));
13697 }
13698
13699 static inline void local_sub(long i, local_t *l)
13700 {
13701 - asm volatile(_ASM_SUB "%1,%0"
13702 + asm volatile(_ASM_SUB "%1,%0\n"
13703 +
13704 +#ifdef CONFIG_PAX_REFCOUNT
13705 + "jno 0f\n"
13706 + _ASM_ADD "%1,%0\n"
13707 + "int $4\n0:\n"
13708 + _ASM_EXTABLE(0b, 0b)
13709 +#endif
13710 +
13711 + : "+m" (l->a.counter)
13712 + : "ir" (i));
13713 +}
13714 +
13715 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
13716 +{
13717 + asm volatile(_ASM_SUB "%1,%0\n"
13718 : "+m" (l->a.counter)
13719 : "ir" (i));
13720 }
13721 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
13722 {
13723 unsigned char c;
13724
13725 - asm volatile(_ASM_SUB "%2,%0; sete %1"
13726 + asm volatile(_ASM_SUB "%2,%0\n"
13727 +
13728 +#ifdef CONFIG_PAX_REFCOUNT
13729 + "jno 0f\n"
13730 + _ASM_ADD "%2,%0\n"
13731 + "int $4\n0:\n"
13732 + _ASM_EXTABLE(0b, 0b)
13733 +#endif
13734 +
13735 + "sete %1\n"
13736 : "+m" (l->a.counter), "=qm" (c)
13737 : "ir" (i) : "memory");
13738 return c;
13739 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
13740 {
13741 unsigned char c;
13742
13743 - asm volatile(_ASM_DEC "%0; sete %1"
13744 + asm volatile(_ASM_DEC "%0\n"
13745 +
13746 +#ifdef CONFIG_PAX_REFCOUNT
13747 + "jno 0f\n"
13748 + _ASM_INC "%0\n"
13749 + "int $4\n0:\n"
13750 + _ASM_EXTABLE(0b, 0b)
13751 +#endif
13752 +
13753 + "sete %1\n"
13754 : "+m" (l->a.counter), "=qm" (c)
13755 : : "memory");
13756 return c != 0;
13757 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
13758 {
13759 unsigned char c;
13760
13761 - asm volatile(_ASM_INC "%0; sete %1"
13762 + asm volatile(_ASM_INC "%0\n"
13763 +
13764 +#ifdef CONFIG_PAX_REFCOUNT
13765 + "jno 0f\n"
13766 + _ASM_DEC "%0\n"
13767 + "int $4\n0:\n"
13768 + _ASM_EXTABLE(0b, 0b)
13769 +#endif
13770 +
13771 + "sete %1\n"
13772 : "+m" (l->a.counter), "=qm" (c)
13773 : : "memory");
13774 return c != 0;
13775 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
13776 {
13777 unsigned char c;
13778
13779 - asm volatile(_ASM_ADD "%2,%0; sets %1"
13780 + asm volatile(_ASM_ADD "%2,%0\n"
13781 +
13782 +#ifdef CONFIG_PAX_REFCOUNT
13783 + "jno 0f\n"
13784 + _ASM_SUB "%2,%0\n"
13785 + "int $4\n0:\n"
13786 + _ASM_EXTABLE(0b, 0b)
13787 +#endif
13788 +
13789 + "sets %1\n"
13790 : "+m" (l->a.counter), "=qm" (c)
13791 : "ir" (i) : "memory");
13792 return c;
13793 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
13794 static inline long local_add_return(long i, local_t *l)
13795 {
13796 long __i = i;
13797 + asm volatile(_ASM_XADD "%0, %1\n"
13798 +
13799 +#ifdef CONFIG_PAX_REFCOUNT
13800 + "jno 0f\n"
13801 + _ASM_MOV "%0,%1\n"
13802 + "int $4\n0:\n"
13803 + _ASM_EXTABLE(0b, 0b)
13804 +#endif
13805 +
13806 + : "+r" (i), "+m" (l->a.counter)
13807 + : : "memory");
13808 + return i + __i;
13809 +}
13810 +
13811 +/**
13812 + * local_add_return_unchecked - add and return
13813 + * @i: integer value to add
13814 + * @l: pointer to type local_unchecked_t
13815 + *
13816 + * Atomically adds @i to @l and returns @i + @l
13817 + */
13818 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
13819 +{
13820 + long __i = i;
13821 asm volatile(_ASM_XADD "%0, %1;"
13822 : "+r" (i), "+m" (l->a.counter)
13823 : : "memory");
13824 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
13825
13826 #define local_cmpxchg(l, o, n) \
13827 (cmpxchg_local(&((l)->a.counter), (o), (n)))
13828 +#define local_cmpxchg_unchecked(l, o, n) \
13829 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
13830 /* Always has a lock prefix */
13831 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
13832
13833 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
13834 new file mode 100644
13835 index 0000000..2bfd3ba
13836 --- /dev/null
13837 +++ b/arch/x86/include/asm/mman.h
13838 @@ -0,0 +1,15 @@
13839 +#ifndef _X86_MMAN_H
13840 +#define _X86_MMAN_H
13841 +
13842 +#include <uapi/asm/mman.h>
13843 +
13844 +#ifdef __KERNEL__
13845 +#ifndef __ASSEMBLY__
13846 +#ifdef CONFIG_X86_32
13847 +#define arch_mmap_check i386_mmap_check
13848 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
13849 +#endif
13850 +#endif
13851 +#endif
13852 +
13853 +#endif /* X86_MMAN_H */
13854 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
13855 index 5f55e69..e20bfb1 100644
13856 --- a/arch/x86/include/asm/mmu.h
13857 +++ b/arch/x86/include/asm/mmu.h
13858 @@ -9,7 +9,7 @@
13859 * we put the segment information here.
13860 */
13861 typedef struct {
13862 - void *ldt;
13863 + struct desc_struct *ldt;
13864 int size;
13865
13866 #ifdef CONFIG_X86_64
13867 @@ -18,7 +18,19 @@ typedef struct {
13868 #endif
13869
13870 struct mutex lock;
13871 - void *vdso;
13872 + unsigned long vdso;
13873 +
13874 +#ifdef CONFIG_X86_32
13875 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
13876 + unsigned long user_cs_base;
13877 + unsigned long user_cs_limit;
13878 +
13879 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13880 + cpumask_t cpu_user_cs_mask;
13881 +#endif
13882 +
13883 +#endif
13884 +#endif
13885 } mm_context_t;
13886
13887 #ifdef CONFIG_SMP
13888 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
13889 index cdbf367..adb37ac 100644
13890 --- a/arch/x86/include/asm/mmu_context.h
13891 +++ b/arch/x86/include/asm/mmu_context.h
13892 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
13893
13894 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
13895 {
13896 +
13897 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
13898 + unsigned int i;
13899 + pgd_t *pgd;
13900 +
13901 + pax_open_kernel();
13902 + pgd = get_cpu_pgd(smp_processor_id());
13903 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
13904 + set_pgd_batched(pgd+i, native_make_pgd(0));
13905 + pax_close_kernel();
13906 +#endif
13907 +
13908 #ifdef CONFIG_SMP
13909 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
13910 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
13911 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13912 struct task_struct *tsk)
13913 {
13914 unsigned cpu = smp_processor_id();
13915 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13916 + int tlbstate = TLBSTATE_OK;
13917 +#endif
13918
13919 if (likely(prev != next)) {
13920 #ifdef CONFIG_SMP
13921 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13922 + tlbstate = this_cpu_read(cpu_tlbstate.state);
13923 +#endif
13924 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13925 this_cpu_write(cpu_tlbstate.active_mm, next);
13926 #endif
13927 cpumask_set_cpu(cpu, mm_cpumask(next));
13928
13929 /* Re-load page tables */
13930 +#ifdef CONFIG_PAX_PER_CPU_PGD
13931 + pax_open_kernel();
13932 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13933 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13934 + pax_close_kernel();
13935 + load_cr3(get_cpu_pgd(cpu));
13936 +#else
13937 load_cr3(next->pgd);
13938 +#endif
13939
13940 /* stop flush ipis for the previous mm */
13941 cpumask_clear_cpu(cpu, mm_cpumask(prev));
13942 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13943 */
13944 if (unlikely(prev->context.ldt != next->context.ldt))
13945 load_LDT_nolock(&next->context);
13946 - }
13947 +
13948 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13949 + if (!(__supported_pte_mask & _PAGE_NX)) {
13950 + smp_mb__before_clear_bit();
13951 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
13952 + smp_mb__after_clear_bit();
13953 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13954 + }
13955 +#endif
13956 +
13957 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13958 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
13959 + prev->context.user_cs_limit != next->context.user_cs_limit))
13960 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13961 #ifdef CONFIG_SMP
13962 + else if (unlikely(tlbstate != TLBSTATE_OK))
13963 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13964 +#endif
13965 +#endif
13966 +
13967 + }
13968 else {
13969 +
13970 +#ifdef CONFIG_PAX_PER_CPU_PGD
13971 + pax_open_kernel();
13972 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13973 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13974 + pax_close_kernel();
13975 + load_cr3(get_cpu_pgd(cpu));
13976 +#endif
13977 +
13978 +#ifdef CONFIG_SMP
13979 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13980 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
13981
13982 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13983 * tlb flush IPI delivery. We must reload CR3
13984 * to make sure to use no freed page tables.
13985 */
13986 +
13987 +#ifndef CONFIG_PAX_PER_CPU_PGD
13988 load_cr3(next->pgd);
13989 +#endif
13990 +
13991 load_LDT_nolock(&next->context);
13992 +
13993 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
13994 + if (!(__supported_pte_mask & _PAGE_NX))
13995 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13996 +#endif
13997 +
13998 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13999 +#ifdef CONFIG_PAX_PAGEEXEC
14000 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
14001 +#endif
14002 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14003 +#endif
14004 +
14005 }
14006 +#endif
14007 }
14008 -#endif
14009 }
14010
14011 #define activate_mm(prev, next) \
14012 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
14013 index e3b7819..b257c64 100644
14014 --- a/arch/x86/include/asm/module.h
14015 +++ b/arch/x86/include/asm/module.h
14016 @@ -5,6 +5,7 @@
14017
14018 #ifdef CONFIG_X86_64
14019 /* X86_64 does not define MODULE_PROC_FAMILY */
14020 +#define MODULE_PROC_FAMILY ""
14021 #elif defined CONFIG_M486
14022 #define MODULE_PROC_FAMILY "486 "
14023 #elif defined CONFIG_M586
14024 @@ -57,8 +58,20 @@
14025 #error unknown processor family
14026 #endif
14027
14028 -#ifdef CONFIG_X86_32
14029 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
14030 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14031 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
14032 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
14033 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
14034 +#else
14035 +#define MODULE_PAX_KERNEXEC ""
14036 #endif
14037
14038 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14039 +#define MODULE_PAX_UDEREF "UDEREF "
14040 +#else
14041 +#define MODULE_PAX_UDEREF ""
14042 +#endif
14043 +
14044 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
14045 +
14046 #endif /* _ASM_X86_MODULE_H */
14047 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
14048 index c0fa356..07a498a 100644
14049 --- a/arch/x86/include/asm/nmi.h
14050 +++ b/arch/x86/include/asm/nmi.h
14051 @@ -42,11 +42,11 @@ struct nmiaction {
14052 nmi_handler_t handler;
14053 unsigned long flags;
14054 const char *name;
14055 -};
14056 +} __do_const;
14057
14058 #define register_nmi_handler(t, fn, fg, n, init...) \
14059 ({ \
14060 - static struct nmiaction init fn##_na = { \
14061 + static const struct nmiaction init fn##_na = { \
14062 .handler = (fn), \
14063 .name = (n), \
14064 .flags = (fg), \
14065 @@ -54,7 +54,7 @@ struct nmiaction {
14066 __register_nmi_handler((t), &fn##_na); \
14067 })
14068
14069 -int __register_nmi_handler(unsigned int, struct nmiaction *);
14070 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
14071
14072 void unregister_nmi_handler(unsigned int, const char *);
14073
14074 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
14075 index 0f1ddee..e2fc3d1 100644
14076 --- a/arch/x86/include/asm/page_64.h
14077 +++ b/arch/x86/include/asm/page_64.h
14078 @@ -7,9 +7,9 @@
14079
14080 /* duplicated to the one in bootmem.h */
14081 extern unsigned long max_pfn;
14082 -extern unsigned long phys_base;
14083 +extern const unsigned long phys_base;
14084
14085 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
14086 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
14087 {
14088 unsigned long y = x - __START_KERNEL_map;
14089
14090 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
14091 index 7361e47..16dc226 100644
14092 --- a/arch/x86/include/asm/paravirt.h
14093 +++ b/arch/x86/include/asm/paravirt.h
14094 @@ -564,7 +564,7 @@ static inline pmd_t __pmd(pmdval_t val)
14095 return (pmd_t) { ret };
14096 }
14097
14098 -static inline pmdval_t pmd_val(pmd_t pmd)
14099 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
14100 {
14101 pmdval_t ret;
14102
14103 @@ -630,6 +630,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
14104 val);
14105 }
14106
14107 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14108 +{
14109 + pgdval_t val = native_pgd_val(pgd);
14110 +
14111 + if (sizeof(pgdval_t) > sizeof(long))
14112 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14113 + val, (u64)val >> 32);
14114 + else
14115 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14116 + val);
14117 +}
14118 +
14119 static inline void pgd_clear(pgd_t *pgdp)
14120 {
14121 set_pgd(pgdp, __pgd(0));
14122 @@ -714,6 +726,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14123 pv_mmu_ops.set_fixmap(idx, phys, flags);
14124 }
14125
14126 +#ifdef CONFIG_PAX_KERNEXEC
14127 +static inline unsigned long pax_open_kernel(void)
14128 +{
14129 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14130 +}
14131 +
14132 +static inline unsigned long pax_close_kernel(void)
14133 +{
14134 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14135 +}
14136 +#else
14137 +static inline unsigned long pax_open_kernel(void) { return 0; }
14138 +static inline unsigned long pax_close_kernel(void) { return 0; }
14139 +#endif
14140 +
14141 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14142
14143 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14144 @@ -930,7 +957,7 @@ extern void default_banner(void);
14145
14146 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14147 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14148 -#define PARA_INDIRECT(addr) *%cs:addr
14149 +#define PARA_INDIRECT(addr) *%ss:addr
14150 #endif
14151
14152 #define INTERRUPT_RETURN \
14153 @@ -1005,6 +1032,21 @@ extern void default_banner(void);
14154 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14155 CLBR_NONE, \
14156 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14157 +
14158 +#define GET_CR0_INTO_RDI \
14159 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14160 + mov %rax,%rdi
14161 +
14162 +#define SET_RDI_INTO_CR0 \
14163 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14164 +
14165 +#define GET_CR3_INTO_RDI \
14166 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14167 + mov %rax,%rdi
14168 +
14169 +#define SET_RDI_INTO_CR3 \
14170 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14171 +
14172 #endif /* CONFIG_X86_32 */
14173
14174 #endif /* __ASSEMBLY__ */
14175 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14176 index b3b0ec1..b1cd3eb 100644
14177 --- a/arch/x86/include/asm/paravirt_types.h
14178 +++ b/arch/x86/include/asm/paravirt_types.h
14179 @@ -84,7 +84,7 @@ struct pv_init_ops {
14180 */
14181 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14182 unsigned long addr, unsigned len);
14183 -};
14184 +} __no_const;
14185
14186
14187 struct pv_lazy_ops {
14188 @@ -98,7 +98,7 @@ struct pv_time_ops {
14189 unsigned long long (*sched_clock)(void);
14190 unsigned long long (*steal_clock)(int cpu);
14191 unsigned long (*get_tsc_khz)(void);
14192 -};
14193 +} __no_const;
14194
14195 struct pv_cpu_ops {
14196 /* hooks for various privileged instructions */
14197 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
14198
14199 void (*start_context_switch)(struct task_struct *prev);
14200 void (*end_context_switch)(struct task_struct *next);
14201 -};
14202 +} __no_const;
14203
14204 struct pv_irq_ops {
14205 /*
14206 @@ -223,7 +223,7 @@ struct pv_apic_ops {
14207 unsigned long start_eip,
14208 unsigned long start_esp);
14209 #endif
14210 -};
14211 +} __no_const;
14212
14213 struct pv_mmu_ops {
14214 unsigned long (*read_cr2)(void);
14215 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
14216 struct paravirt_callee_save make_pud;
14217
14218 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14219 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14220 #endif /* PAGETABLE_LEVELS == 4 */
14221 #endif /* PAGETABLE_LEVELS >= 3 */
14222
14223 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
14224 an mfn. We can tell which is which from the index. */
14225 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14226 phys_addr_t phys, pgprot_t flags);
14227 +
14228 +#ifdef CONFIG_PAX_KERNEXEC
14229 + unsigned long (*pax_open_kernel)(void);
14230 + unsigned long (*pax_close_kernel)(void);
14231 +#endif
14232 +
14233 };
14234
14235 struct arch_spinlock;
14236 @@ -334,7 +341,7 @@ struct pv_lock_ops {
14237 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14238 int (*spin_trylock)(struct arch_spinlock *lock);
14239 void (*spin_unlock)(struct arch_spinlock *lock);
14240 -};
14241 +} __no_const;
14242
14243 /* This contains all the paravirt structures: we get a convenient
14244 * number for each function using the offset which we use to indicate
14245 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14246 index b4389a4..7024269 100644
14247 --- a/arch/x86/include/asm/pgalloc.h
14248 +++ b/arch/x86/include/asm/pgalloc.h
14249 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14250 pmd_t *pmd, pte_t *pte)
14251 {
14252 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14253 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14254 +}
14255 +
14256 +static inline void pmd_populate_user(struct mm_struct *mm,
14257 + pmd_t *pmd, pte_t *pte)
14258 +{
14259 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14260 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14261 }
14262
14263 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14264
14265 #ifdef CONFIG_X86_PAE
14266 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14267 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14268 +{
14269 + pud_populate(mm, pudp, pmd);
14270 +}
14271 #else /* !CONFIG_X86_PAE */
14272 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14273 {
14274 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14275 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14276 }
14277 +
14278 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14279 +{
14280 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14281 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
14282 +}
14283 #endif /* CONFIG_X86_PAE */
14284
14285 #if PAGETABLE_LEVELS > 3
14286 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14287 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14288 }
14289
14290 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14291 +{
14292 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14293 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14294 +}
14295 +
14296 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14297 {
14298 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14299 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14300 index f2b489c..4f7e2e5 100644
14301 --- a/arch/x86/include/asm/pgtable-2level.h
14302 +++ b/arch/x86/include/asm/pgtable-2level.h
14303 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14304
14305 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14306 {
14307 + pax_open_kernel();
14308 *pmdp = pmd;
14309 + pax_close_kernel();
14310 }
14311
14312 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14313 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14314 index 4cc9f2b..5fd9226 100644
14315 --- a/arch/x86/include/asm/pgtable-3level.h
14316 +++ b/arch/x86/include/asm/pgtable-3level.h
14317 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14318
14319 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14320 {
14321 + pax_open_kernel();
14322 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14323 + pax_close_kernel();
14324 }
14325
14326 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14327 {
14328 + pax_open_kernel();
14329 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14330 + pax_close_kernel();
14331 }
14332
14333 /*
14334 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14335 index 1e67223..dd6e7ea 100644
14336 --- a/arch/x86/include/asm/pgtable.h
14337 +++ b/arch/x86/include/asm/pgtable.h
14338 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14339
14340 #ifndef __PAGETABLE_PUD_FOLDED
14341 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14342 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14343 #define pgd_clear(pgd) native_pgd_clear(pgd)
14344 #endif
14345
14346 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14347
14348 #define arch_end_context_switch(prev) do {} while(0)
14349
14350 +#define pax_open_kernel() native_pax_open_kernel()
14351 +#define pax_close_kernel() native_pax_close_kernel()
14352 #endif /* CONFIG_PARAVIRT */
14353
14354 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14355 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14356 +
14357 +#ifdef CONFIG_PAX_KERNEXEC
14358 +static inline unsigned long native_pax_open_kernel(void)
14359 +{
14360 + unsigned long cr0;
14361 +
14362 + preempt_disable();
14363 + barrier();
14364 + cr0 = read_cr0() ^ X86_CR0_WP;
14365 + BUG_ON(cr0 & X86_CR0_WP);
14366 + write_cr0(cr0);
14367 + return cr0 ^ X86_CR0_WP;
14368 +}
14369 +
14370 +static inline unsigned long native_pax_close_kernel(void)
14371 +{
14372 + unsigned long cr0;
14373 +
14374 + cr0 = read_cr0() ^ X86_CR0_WP;
14375 + BUG_ON(!(cr0 & X86_CR0_WP));
14376 + write_cr0(cr0);
14377 + barrier();
14378 + preempt_enable_no_resched();
14379 + return cr0 ^ X86_CR0_WP;
14380 +}
14381 +#else
14382 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14383 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14384 +#endif
14385 +
14386 /*
14387 * The following only work if pte_present() is true.
14388 * Undefined behaviour if not..
14389 */
14390 +static inline int pte_user(pte_t pte)
14391 +{
14392 + return pte_val(pte) & _PAGE_USER;
14393 +}
14394 +
14395 static inline int pte_dirty(pte_t pte)
14396 {
14397 return pte_flags(pte) & _PAGE_DIRTY;
14398 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
14399 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
14400 }
14401
14402 +static inline unsigned long pgd_pfn(pgd_t pgd)
14403 +{
14404 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
14405 +}
14406 +
14407 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
14408
14409 static inline int pmd_large(pmd_t pte)
14410 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14411 return pte_clear_flags(pte, _PAGE_RW);
14412 }
14413
14414 +static inline pte_t pte_mkread(pte_t pte)
14415 +{
14416 + return __pte(pte_val(pte) | _PAGE_USER);
14417 +}
14418 +
14419 static inline pte_t pte_mkexec(pte_t pte)
14420 {
14421 - return pte_clear_flags(pte, _PAGE_NX);
14422 +#ifdef CONFIG_X86_PAE
14423 + if (__supported_pte_mask & _PAGE_NX)
14424 + return pte_clear_flags(pte, _PAGE_NX);
14425 + else
14426 +#endif
14427 + return pte_set_flags(pte, _PAGE_USER);
14428 +}
14429 +
14430 +static inline pte_t pte_exprotect(pte_t pte)
14431 +{
14432 +#ifdef CONFIG_X86_PAE
14433 + if (__supported_pte_mask & _PAGE_NX)
14434 + return pte_set_flags(pte, _PAGE_NX);
14435 + else
14436 +#endif
14437 + return pte_clear_flags(pte, _PAGE_USER);
14438 }
14439
14440 static inline pte_t pte_mkdirty(pte_t pte)
14441 @@ -394,6 +459,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14442 #endif
14443
14444 #ifndef __ASSEMBLY__
14445 +
14446 +#ifdef CONFIG_PAX_PER_CPU_PGD
14447 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14448 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14449 +{
14450 + return cpu_pgd[cpu];
14451 +}
14452 +#endif
14453 +
14454 #include <linux/mm_types.h>
14455 #include <linux/log2.h>
14456
14457 @@ -529,7 +603,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
14458 * Currently stuck as a macro due to indirect forward reference to
14459 * linux/mmzone.h's __section_mem_map_addr() definition:
14460 */
14461 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
14462 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
14463
14464 /* Find an entry in the second-level page table.. */
14465 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
14466 @@ -569,7 +643,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
14467 * Currently stuck as a macro due to indirect forward reference to
14468 * linux/mmzone.h's __section_mem_map_addr() definition:
14469 */
14470 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
14471 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
14472
14473 /* to find an entry in a page-table-directory. */
14474 static inline unsigned long pud_index(unsigned long address)
14475 @@ -584,7 +658,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14476
14477 static inline int pgd_bad(pgd_t pgd)
14478 {
14479 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14480 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14481 }
14482
14483 static inline int pgd_none(pgd_t pgd)
14484 @@ -607,7 +681,12 @@ static inline int pgd_none(pgd_t pgd)
14485 * pgd_offset() returns a (pgd_t *)
14486 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14487 */
14488 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14489 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14490 +
14491 +#ifdef CONFIG_PAX_PER_CPU_PGD
14492 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14493 +#endif
14494 +
14495 /*
14496 * a shortcut which implies the use of the kernel's pgd, instead
14497 * of a process's
14498 @@ -618,6 +697,22 @@ static inline int pgd_none(pgd_t pgd)
14499 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14500 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14501
14502 +#ifdef CONFIG_X86_32
14503 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14504 +#else
14505 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14506 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14507 +
14508 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14509 +#ifdef __ASSEMBLY__
14510 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
14511 +#else
14512 +extern unsigned long pax_user_shadow_base;
14513 +#endif
14514 +#endif
14515 +
14516 +#endif
14517 +
14518 #ifndef __ASSEMBLY__
14519
14520 extern int direct_gbpages;
14521 @@ -784,11 +879,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14522 * dst and src can be on the same page, but the range must not overlap,
14523 * and must not cross a page boundary.
14524 */
14525 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14526 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14527 {
14528 - memcpy(dst, src, count * sizeof(pgd_t));
14529 + pax_open_kernel();
14530 + while (count--)
14531 + *dst++ = *src++;
14532 + pax_close_kernel();
14533 }
14534
14535 +#ifdef CONFIG_PAX_PER_CPU_PGD
14536 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14537 +#endif
14538 +
14539 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14540 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14541 +#else
14542 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14543 +#endif
14544 +
14545 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
14546 static inline int page_level_shift(enum pg_level level)
14547 {
14548 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14549 index 9ee3221..b979c6b 100644
14550 --- a/arch/x86/include/asm/pgtable_32.h
14551 +++ b/arch/x86/include/asm/pgtable_32.h
14552 @@ -25,9 +25,6 @@
14553 struct mm_struct;
14554 struct vm_area_struct;
14555
14556 -extern pgd_t swapper_pg_dir[1024];
14557 -extern pgd_t initial_page_table[1024];
14558 -
14559 static inline void pgtable_cache_init(void) { }
14560 static inline void check_pgt_cache(void) { }
14561 void paging_init(void);
14562 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14563 # include <asm/pgtable-2level.h>
14564 #endif
14565
14566 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14567 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14568 +#ifdef CONFIG_X86_PAE
14569 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14570 +#endif
14571 +
14572 #if defined(CONFIG_HIGHPTE)
14573 #define pte_offset_map(dir, address) \
14574 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14575 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14576 /* Clear a kernel PTE and flush it from the TLB */
14577 #define kpte_clear_flush(ptep, vaddr) \
14578 do { \
14579 + pax_open_kernel(); \
14580 pte_clear(&init_mm, (vaddr), (ptep)); \
14581 + pax_close_kernel(); \
14582 __flush_tlb_one((vaddr)); \
14583 } while (0)
14584
14585 #endif /* !__ASSEMBLY__ */
14586
14587 +#define HAVE_ARCH_UNMAPPED_AREA
14588 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14589 +
14590 /*
14591 * kern_addr_valid() is (1) for FLATMEM and (0) for
14592 * SPARSEMEM and DISCONTIGMEM
14593 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14594 index ed5903b..c7fe163 100644
14595 --- a/arch/x86/include/asm/pgtable_32_types.h
14596 +++ b/arch/x86/include/asm/pgtable_32_types.h
14597 @@ -8,7 +8,7 @@
14598 */
14599 #ifdef CONFIG_X86_PAE
14600 # include <asm/pgtable-3level_types.h>
14601 -# define PMD_SIZE (1UL << PMD_SHIFT)
14602 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14603 # define PMD_MASK (~(PMD_SIZE - 1))
14604 #else
14605 # include <asm/pgtable-2level_types.h>
14606 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14607 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14608 #endif
14609
14610 +#ifdef CONFIG_PAX_KERNEXEC
14611 +#ifndef __ASSEMBLY__
14612 +extern unsigned char MODULES_EXEC_VADDR[];
14613 +extern unsigned char MODULES_EXEC_END[];
14614 +#endif
14615 +#include <asm/boot.h>
14616 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14617 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14618 +#else
14619 +#define ktla_ktva(addr) (addr)
14620 +#define ktva_ktla(addr) (addr)
14621 +#endif
14622 +
14623 #define MODULES_VADDR VMALLOC_START
14624 #define MODULES_END VMALLOC_END
14625 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14626 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14627 index e22c1db..23a625a 100644
14628 --- a/arch/x86/include/asm/pgtable_64.h
14629 +++ b/arch/x86/include/asm/pgtable_64.h
14630 @@ -16,10 +16,14 @@
14631
14632 extern pud_t level3_kernel_pgt[512];
14633 extern pud_t level3_ident_pgt[512];
14634 +extern pud_t level3_vmalloc_start_pgt[512];
14635 +extern pud_t level3_vmalloc_end_pgt[512];
14636 +extern pud_t level3_vmemmap_pgt[512];
14637 +extern pud_t level2_vmemmap_pgt[512];
14638 extern pmd_t level2_kernel_pgt[512];
14639 extern pmd_t level2_fixmap_pgt[512];
14640 -extern pmd_t level2_ident_pgt[512];
14641 -extern pgd_t init_level4_pgt[];
14642 +extern pmd_t level2_ident_pgt[512*2];
14643 +extern pgd_t init_level4_pgt[512];
14644
14645 #define swapper_pg_dir init_level4_pgt
14646
14647 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14648
14649 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14650 {
14651 + pax_open_kernel();
14652 *pmdp = pmd;
14653 + pax_close_kernel();
14654 }
14655
14656 static inline void native_pmd_clear(pmd_t *pmd)
14657 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14658
14659 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14660 {
14661 + pax_open_kernel();
14662 *pudp = pud;
14663 + pax_close_kernel();
14664 }
14665
14666 static inline void native_pud_clear(pud_t *pud)
14667 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14668
14669 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14670 {
14671 + pax_open_kernel();
14672 + *pgdp = pgd;
14673 + pax_close_kernel();
14674 +}
14675 +
14676 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14677 +{
14678 *pgdp = pgd;
14679 }
14680
14681 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14682 index 2d88344..4679fc3 100644
14683 --- a/arch/x86/include/asm/pgtable_64_types.h
14684 +++ b/arch/x86/include/asm/pgtable_64_types.h
14685 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
14686 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
14687 #define MODULES_END _AC(0xffffffffff000000, UL)
14688 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
14689 +#define MODULES_EXEC_VADDR MODULES_VADDR
14690 +#define MODULES_EXEC_END MODULES_END
14691 +
14692 +#define ktla_ktva(addr) (addr)
14693 +#define ktva_ktla(addr) (addr)
14694
14695 #define EARLY_DYNAMIC_PAGE_TABLES 64
14696
14697 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
14698 index 567b5d0..bd91d64 100644
14699 --- a/arch/x86/include/asm/pgtable_types.h
14700 +++ b/arch/x86/include/asm/pgtable_types.h
14701 @@ -16,13 +16,12 @@
14702 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
14703 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
14704 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
14705 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
14706 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
14707 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
14708 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
14709 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
14710 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
14711 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
14712 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
14713 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
14714 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
14715 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
14716
14717 /* If _PAGE_BIT_PRESENT is clear, we use these: */
14718 @@ -40,7 +39,6 @@
14719 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
14720 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
14721 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
14722 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
14723 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
14724 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
14725 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
14726 @@ -57,8 +55,10 @@
14727
14728 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
14729 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
14730 -#else
14731 +#elif defined(CONFIG_KMEMCHECK)
14732 #define _PAGE_NX (_AT(pteval_t, 0))
14733 +#else
14734 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
14735 #endif
14736
14737 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
14738 @@ -116,6 +116,9 @@
14739 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
14740 _PAGE_ACCESSED)
14741
14742 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
14743 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
14744 +
14745 #define __PAGE_KERNEL_EXEC \
14746 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
14747 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
14748 @@ -126,7 +129,7 @@
14749 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
14750 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
14751 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
14752 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
14753 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
14754 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
14755 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
14756 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
14757 @@ -188,8 +191,8 @@
14758 * bits are combined, this will alow user to access the high address mapped
14759 * VDSO in the presence of CONFIG_COMPAT_VDSO
14760 */
14761 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
14762 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
14763 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14764 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14765 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
14766 #endif
14767
14768 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
14769 {
14770 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
14771 }
14772 +#endif
14773
14774 +#if PAGETABLE_LEVELS == 3
14775 +#include <asm-generic/pgtable-nopud.h>
14776 +#endif
14777 +
14778 +#if PAGETABLE_LEVELS == 2
14779 +#include <asm-generic/pgtable-nopmd.h>
14780 +#endif
14781 +
14782 +#ifndef __ASSEMBLY__
14783 #if PAGETABLE_LEVELS > 3
14784 typedef struct { pudval_t pud; } pud_t;
14785
14786 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
14787 return pud.pud;
14788 }
14789 #else
14790 -#include <asm-generic/pgtable-nopud.h>
14791 -
14792 static inline pudval_t native_pud_val(pud_t pud)
14793 {
14794 return native_pgd_val(pud.pgd);
14795 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
14796 return pmd.pmd;
14797 }
14798 #else
14799 -#include <asm-generic/pgtable-nopmd.h>
14800 -
14801 static inline pmdval_t native_pmd_val(pmd_t pmd)
14802 {
14803 return native_pgd_val(pmd.pud.pgd);
14804 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
14805
14806 extern pteval_t __supported_pte_mask;
14807 extern void set_nx(void);
14808 -extern int nx_enabled;
14809
14810 #define pgprot_writecombine pgprot_writecombine
14811 extern pgprot_t pgprot_writecombine(pgprot_t prot);
14812 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
14813 index 3270116..8d99d82 100644
14814 --- a/arch/x86/include/asm/processor.h
14815 +++ b/arch/x86/include/asm/processor.h
14816 @@ -285,7 +285,7 @@ struct tss_struct {
14817
14818 } ____cacheline_aligned;
14819
14820 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
14821 +extern struct tss_struct init_tss[NR_CPUS];
14822
14823 /*
14824 * Save the original ist values for checking stack pointers during debugging
14825 @@ -826,11 +826,18 @@ static inline void spin_lock_prefetch(const void *x)
14826 */
14827 #define TASK_SIZE PAGE_OFFSET
14828 #define TASK_SIZE_MAX TASK_SIZE
14829 +
14830 +#ifdef CONFIG_PAX_SEGMEXEC
14831 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
14832 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
14833 +#else
14834 #define STACK_TOP TASK_SIZE
14835 -#define STACK_TOP_MAX STACK_TOP
14836 +#endif
14837 +
14838 +#define STACK_TOP_MAX TASK_SIZE
14839
14840 #define INIT_THREAD { \
14841 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14842 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14843 .vm86_info = NULL, \
14844 .sysenter_cs = __KERNEL_CS, \
14845 .io_bitmap_ptr = NULL, \
14846 @@ -844,7 +851,7 @@ static inline void spin_lock_prefetch(const void *x)
14847 */
14848 #define INIT_TSS { \
14849 .x86_tss = { \
14850 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14851 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14852 .ss0 = __KERNEL_DS, \
14853 .ss1 = __KERNEL_CS, \
14854 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
14855 @@ -855,11 +862,7 @@ static inline void spin_lock_prefetch(const void *x)
14856 extern unsigned long thread_saved_pc(struct task_struct *tsk);
14857
14858 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
14859 -#define KSTK_TOP(info) \
14860 -({ \
14861 - unsigned long *__ptr = (unsigned long *)(info); \
14862 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
14863 -})
14864 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
14865
14866 /*
14867 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
14868 @@ -874,7 +877,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14869 #define task_pt_regs(task) \
14870 ({ \
14871 struct pt_regs *__regs__; \
14872 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
14873 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
14874 __regs__ - 1; \
14875 })
14876
14877 @@ -884,13 +887,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14878 /*
14879 * User space process size. 47bits minus one guard page.
14880 */
14881 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
14882 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
14883
14884 /* This decides where the kernel will search for a free chunk of vm
14885 * space during mmap's.
14886 */
14887 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
14888 - 0xc0000000 : 0xFFFFe000)
14889 + 0xc0000000 : 0xFFFFf000)
14890
14891 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
14892 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
14893 @@ -901,11 +904,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14894 #define STACK_TOP_MAX TASK_SIZE_MAX
14895
14896 #define INIT_THREAD { \
14897 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14898 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14899 }
14900
14901 #define INIT_TSS { \
14902 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14903 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14904 }
14905
14906 /*
14907 @@ -933,6 +936,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
14908 */
14909 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
14910
14911 +#ifdef CONFIG_PAX_SEGMEXEC
14912 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
14913 +#endif
14914 +
14915 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
14916
14917 /* Get/set a process' ability to use the timestamp counter instruction */
14918 @@ -993,7 +1000,7 @@ extern bool cpu_has_amd_erratum(const int *);
14919 #define cpu_has_amd_erratum(x) (false)
14920 #endif /* CONFIG_CPU_SUP_AMD */
14921
14922 -extern unsigned long arch_align_stack(unsigned long sp);
14923 +#define arch_align_stack(x) ((x) & ~0xfUL)
14924 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
14925
14926 void default_idle(void);
14927 @@ -1003,6 +1010,6 @@ bool xen_set_default_idle(void);
14928 #define xen_set_default_idle 0
14929 #endif
14930
14931 -void stop_this_cpu(void *dummy);
14932 +void stop_this_cpu(void *dummy) __noreturn;
14933
14934 #endif /* _ASM_X86_PROCESSOR_H */
14935 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
14936 index 942a086..6c26446 100644
14937 --- a/arch/x86/include/asm/ptrace.h
14938 +++ b/arch/x86/include/asm/ptrace.h
14939 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
14940 }
14941
14942 /*
14943 - * user_mode_vm(regs) determines whether a register set came from user mode.
14944 + * user_mode(regs) determines whether a register set came from user mode.
14945 * This is true if V8086 mode was enabled OR if the register set was from
14946 * protected mode with RPL-3 CS value. This tricky test checks that with
14947 * one comparison. Many places in the kernel can bypass this full check
14948 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
14949 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
14950 + * be used.
14951 */
14952 -static inline int user_mode(struct pt_regs *regs)
14953 +static inline int user_mode_novm(struct pt_regs *regs)
14954 {
14955 #ifdef CONFIG_X86_32
14956 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
14957 #else
14958 - return !!(regs->cs & 3);
14959 + return !!(regs->cs & SEGMENT_RPL_MASK);
14960 #endif
14961 }
14962
14963 -static inline int user_mode_vm(struct pt_regs *regs)
14964 +static inline int user_mode(struct pt_regs *regs)
14965 {
14966 #ifdef CONFIG_X86_32
14967 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
14968 USER_RPL;
14969 #else
14970 - return user_mode(regs);
14971 + return user_mode_novm(regs);
14972 #endif
14973 }
14974
14975 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
14976 #ifdef CONFIG_X86_64
14977 static inline bool user_64bit_mode(struct pt_regs *regs)
14978 {
14979 + unsigned long cs = regs->cs & 0xffff;
14980 #ifndef CONFIG_PARAVIRT
14981 /*
14982 * On non-paravirt systems, this is the only long mode CPL 3
14983 * selector. We do not allow long mode selectors in the LDT.
14984 */
14985 - return regs->cs == __USER_CS;
14986 + return cs == __USER_CS;
14987 #else
14988 /* Headers are too twisted for this to go in paravirt.h. */
14989 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
14990 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
14991 #endif
14992 }
14993
14994 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
14995 * Traps from the kernel do not save sp and ss.
14996 * Use the helper function to retrieve sp.
14997 */
14998 - if (offset == offsetof(struct pt_regs, sp) &&
14999 - regs->cs == __KERNEL_CS)
15000 - return kernel_stack_pointer(regs);
15001 + if (offset == offsetof(struct pt_regs, sp)) {
15002 + unsigned long cs = regs->cs & 0xffff;
15003 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
15004 + return kernel_stack_pointer(regs);
15005 + }
15006 #endif
15007 return *(unsigned long *)((unsigned long)regs + offset);
15008 }
15009 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
15010 index 9c6b890..5305f53 100644
15011 --- a/arch/x86/include/asm/realmode.h
15012 +++ b/arch/x86/include/asm/realmode.h
15013 @@ -22,16 +22,14 @@ struct real_mode_header {
15014 #endif
15015 /* APM/BIOS reboot */
15016 u32 machine_real_restart_asm;
15017 -#ifdef CONFIG_X86_64
15018 u32 machine_real_restart_seg;
15019 -#endif
15020 };
15021
15022 /* This must match data at trampoline_32/64.S */
15023 struct trampoline_header {
15024 #ifdef CONFIG_X86_32
15025 u32 start;
15026 - u16 gdt_pad;
15027 + u16 boot_cs;
15028 u16 gdt_limit;
15029 u32 gdt_base;
15030 #else
15031 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
15032 index a82c4f1..ac45053 100644
15033 --- a/arch/x86/include/asm/reboot.h
15034 +++ b/arch/x86/include/asm/reboot.h
15035 @@ -6,13 +6,13 @@
15036 struct pt_regs;
15037
15038 struct machine_ops {
15039 - void (*restart)(char *cmd);
15040 - void (*halt)(void);
15041 - void (*power_off)(void);
15042 + void (* __noreturn restart)(char *cmd);
15043 + void (* __noreturn halt)(void);
15044 + void (* __noreturn power_off)(void);
15045 void (*shutdown)(void);
15046 void (*crash_shutdown)(struct pt_regs *);
15047 - void (*emergency_restart)(void);
15048 -};
15049 + void (* __noreturn emergency_restart)(void);
15050 +} __no_const;
15051
15052 extern struct machine_ops machine_ops;
15053
15054 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
15055 index 2dbe4a7..ce1db00 100644
15056 --- a/arch/x86/include/asm/rwsem.h
15057 +++ b/arch/x86/include/asm/rwsem.h
15058 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
15059 {
15060 asm volatile("# beginning down_read\n\t"
15061 LOCK_PREFIX _ASM_INC "(%1)\n\t"
15062 +
15063 +#ifdef CONFIG_PAX_REFCOUNT
15064 + "jno 0f\n"
15065 + LOCK_PREFIX _ASM_DEC "(%1)\n"
15066 + "int $4\n0:\n"
15067 + _ASM_EXTABLE(0b, 0b)
15068 +#endif
15069 +
15070 /* adds 0x00000001 */
15071 " jns 1f\n"
15072 " call call_rwsem_down_read_failed\n"
15073 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
15074 "1:\n\t"
15075 " mov %1,%2\n\t"
15076 " add %3,%2\n\t"
15077 +
15078 +#ifdef CONFIG_PAX_REFCOUNT
15079 + "jno 0f\n"
15080 + "sub %3,%2\n"
15081 + "int $4\n0:\n"
15082 + _ASM_EXTABLE(0b, 0b)
15083 +#endif
15084 +
15085 " jle 2f\n\t"
15086 LOCK_PREFIX " cmpxchg %2,%0\n\t"
15087 " jnz 1b\n\t"
15088 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
15089 long tmp;
15090 asm volatile("# beginning down_write\n\t"
15091 LOCK_PREFIX " xadd %1,(%2)\n\t"
15092 +
15093 +#ifdef CONFIG_PAX_REFCOUNT
15094 + "jno 0f\n"
15095 + "mov %1,(%2)\n"
15096 + "int $4\n0:\n"
15097 + _ASM_EXTABLE(0b, 0b)
15098 +#endif
15099 +
15100 /* adds 0xffff0001, returns the old value */
15101 " test %1,%1\n\t"
15102 /* was the count 0 before? */
15103 @@ -141,6 +165,14 @@ static inline void __up_read(struct rw_semaphore *sem)
15104 long tmp;
15105 asm volatile("# beginning __up_read\n\t"
15106 LOCK_PREFIX " xadd %1,(%2)\n\t"
15107 +
15108 +#ifdef CONFIG_PAX_REFCOUNT
15109 + "jno 0f\n"
15110 + "mov %1,(%2)\n"
15111 + "int $4\n0:\n"
15112 + _ASM_EXTABLE(0b, 0b)
15113 +#endif
15114 +
15115 /* subtracts 1, returns the old value */
15116 " jns 1f\n\t"
15117 " call call_rwsem_wake\n" /* expects old value in %edx */
15118 @@ -159,6 +191,14 @@ static inline void __up_write(struct rw_semaphore *sem)
15119 long tmp;
15120 asm volatile("# beginning __up_write\n\t"
15121 LOCK_PREFIX " xadd %1,(%2)\n\t"
15122 +
15123 +#ifdef CONFIG_PAX_REFCOUNT
15124 + "jno 0f\n"
15125 + "mov %1,(%2)\n"
15126 + "int $4\n0:\n"
15127 + _ASM_EXTABLE(0b, 0b)
15128 +#endif
15129 +
15130 /* subtracts 0xffff0001, returns the old value */
15131 " jns 1f\n\t"
15132 " call call_rwsem_wake\n" /* expects old value in %edx */
15133 @@ -176,6 +216,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15134 {
15135 asm volatile("# beginning __downgrade_write\n\t"
15136 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
15137 +
15138 +#ifdef CONFIG_PAX_REFCOUNT
15139 + "jno 0f\n"
15140 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15141 + "int $4\n0:\n"
15142 + _ASM_EXTABLE(0b, 0b)
15143 +#endif
15144 +
15145 /*
15146 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15147 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15148 @@ -194,7 +242,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15149 */
15150 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15151 {
15152 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15153 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15154 +
15155 +#ifdef CONFIG_PAX_REFCOUNT
15156 + "jno 0f\n"
15157 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15158 + "int $4\n0:\n"
15159 + _ASM_EXTABLE(0b, 0b)
15160 +#endif
15161 +
15162 : "+m" (sem->count)
15163 : "er" (delta));
15164 }
15165 @@ -204,7 +260,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15166 */
15167 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15168 {
15169 - return delta + xadd(&sem->count, delta);
15170 + return delta + xadd_check_overflow(&sem->count, delta);
15171 }
15172
15173 #endif /* __KERNEL__ */
15174 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15175 index c48a950..c6d7468 100644
15176 --- a/arch/x86/include/asm/segment.h
15177 +++ b/arch/x86/include/asm/segment.h
15178 @@ -64,10 +64,15 @@
15179 * 26 - ESPFIX small SS
15180 * 27 - per-cpu [ offset to per-cpu data area ]
15181 * 28 - stack_canary-20 [ for stack protector ]
15182 - * 29 - unused
15183 - * 30 - unused
15184 + * 29 - PCI BIOS CS
15185 + * 30 - PCI BIOS DS
15186 * 31 - TSS for double fault handler
15187 */
15188 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15189 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15190 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15191 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15192 +
15193 #define GDT_ENTRY_TLS_MIN 6
15194 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15195
15196 @@ -79,6 +84,8 @@
15197
15198 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15199
15200 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15201 +
15202 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15203
15204 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15205 @@ -104,6 +111,12 @@
15206 #define __KERNEL_STACK_CANARY 0
15207 #endif
15208
15209 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15210 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15211 +
15212 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15213 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15214 +
15215 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15216
15217 /*
15218 @@ -141,7 +154,7 @@
15219 */
15220
15221 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15222 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15223 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15224
15225
15226 #else
15227 @@ -165,6 +178,8 @@
15228 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15229 #define __USER32_DS __USER_DS
15230
15231 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15232 +
15233 #define GDT_ENTRY_TSS 8 /* needs two entries */
15234 #define GDT_ENTRY_LDT 10 /* needs two entries */
15235 #define GDT_ENTRY_TLS_MIN 12
15236 @@ -185,6 +200,7 @@
15237 #endif
15238
15239 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15240 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15241 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15242 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15243 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15244 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15245 {
15246 unsigned long __limit;
15247 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15248 - return __limit + 1;
15249 + return __limit;
15250 }
15251
15252 #endif /* !__ASSEMBLY__ */
15253 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15254 index b073aae..39f9bdd 100644
15255 --- a/arch/x86/include/asm/smp.h
15256 +++ b/arch/x86/include/asm/smp.h
15257 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15258 /* cpus sharing the last level cache: */
15259 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15260 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15261 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15262 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15263
15264 static inline struct cpumask *cpu_sibling_mask(int cpu)
15265 {
15266 @@ -79,7 +79,7 @@ struct smp_ops {
15267
15268 void (*send_call_func_ipi)(const struct cpumask *mask);
15269 void (*send_call_func_single_ipi)(int cpu);
15270 -};
15271 +} __no_const;
15272
15273 /* Globals due to paravirt */
15274 extern void set_cpu_sibling_map(int cpu);
15275 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15276 extern int safe_smp_processor_id(void);
15277
15278 #elif defined(CONFIG_X86_64_SMP)
15279 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15280 -
15281 -#define stack_smp_processor_id() \
15282 -({ \
15283 - struct thread_info *ti; \
15284 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15285 - ti->cpu; \
15286 -})
15287 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15288 +#define stack_smp_processor_id() raw_smp_processor_id()
15289 #define safe_smp_processor_id() smp_processor_id()
15290
15291 #endif
15292 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15293 index 33692ea..350a534 100644
15294 --- a/arch/x86/include/asm/spinlock.h
15295 +++ b/arch/x86/include/asm/spinlock.h
15296 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15297 static inline void arch_read_lock(arch_rwlock_t *rw)
15298 {
15299 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15300 +
15301 +#ifdef CONFIG_PAX_REFCOUNT
15302 + "jno 0f\n"
15303 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15304 + "int $4\n0:\n"
15305 + _ASM_EXTABLE(0b, 0b)
15306 +#endif
15307 +
15308 "jns 1f\n"
15309 "call __read_lock_failed\n\t"
15310 "1:\n"
15311 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15312 static inline void arch_write_lock(arch_rwlock_t *rw)
15313 {
15314 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15315 +
15316 +#ifdef CONFIG_PAX_REFCOUNT
15317 + "jno 0f\n"
15318 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15319 + "int $4\n0:\n"
15320 + _ASM_EXTABLE(0b, 0b)
15321 +#endif
15322 +
15323 "jz 1f\n"
15324 "call __write_lock_failed\n\t"
15325 "1:\n"
15326 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15327
15328 static inline void arch_read_unlock(arch_rwlock_t *rw)
15329 {
15330 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15331 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15332 +
15333 +#ifdef CONFIG_PAX_REFCOUNT
15334 + "jno 0f\n"
15335 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15336 + "int $4\n0:\n"
15337 + _ASM_EXTABLE(0b, 0b)
15338 +#endif
15339 +
15340 :"+m" (rw->lock) : : "memory");
15341 }
15342
15343 static inline void arch_write_unlock(arch_rwlock_t *rw)
15344 {
15345 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15346 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15347 +
15348 +#ifdef CONFIG_PAX_REFCOUNT
15349 + "jno 0f\n"
15350 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15351 + "int $4\n0:\n"
15352 + _ASM_EXTABLE(0b, 0b)
15353 +#endif
15354 +
15355 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15356 }
15357
15358 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15359 index 6a99859..03cb807 100644
15360 --- a/arch/x86/include/asm/stackprotector.h
15361 +++ b/arch/x86/include/asm/stackprotector.h
15362 @@ -47,7 +47,7 @@
15363 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15364 */
15365 #define GDT_STACK_CANARY_INIT \
15366 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15367 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15368
15369 /*
15370 * Initialize the stackprotector canary value.
15371 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15372
15373 static inline void load_stack_canary_segment(void)
15374 {
15375 -#ifdef CONFIG_X86_32
15376 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15377 asm volatile ("mov %0, %%gs" : : "r" (0));
15378 #endif
15379 }
15380 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15381 index 70bbe39..4ae2bd4 100644
15382 --- a/arch/x86/include/asm/stacktrace.h
15383 +++ b/arch/x86/include/asm/stacktrace.h
15384 @@ -11,28 +11,20 @@
15385
15386 extern int kstack_depth_to_print;
15387
15388 -struct thread_info;
15389 +struct task_struct;
15390 struct stacktrace_ops;
15391
15392 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15393 - unsigned long *stack,
15394 - unsigned long bp,
15395 - const struct stacktrace_ops *ops,
15396 - void *data,
15397 - unsigned long *end,
15398 - int *graph);
15399 +typedef unsigned long walk_stack_t(struct task_struct *task,
15400 + void *stack_start,
15401 + unsigned long *stack,
15402 + unsigned long bp,
15403 + const struct stacktrace_ops *ops,
15404 + void *data,
15405 + unsigned long *end,
15406 + int *graph);
15407
15408 -extern unsigned long
15409 -print_context_stack(struct thread_info *tinfo,
15410 - unsigned long *stack, unsigned long bp,
15411 - const struct stacktrace_ops *ops, void *data,
15412 - unsigned long *end, int *graph);
15413 -
15414 -extern unsigned long
15415 -print_context_stack_bp(struct thread_info *tinfo,
15416 - unsigned long *stack, unsigned long bp,
15417 - const struct stacktrace_ops *ops, void *data,
15418 - unsigned long *end, int *graph);
15419 +extern walk_stack_t print_context_stack;
15420 +extern walk_stack_t print_context_stack_bp;
15421
15422 /* Generic stack tracer with callbacks */
15423
15424 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15425 void (*address)(void *data, unsigned long address, int reliable);
15426 /* On negative return stop dumping */
15427 int (*stack)(void *data, char *name);
15428 - walk_stack_t walk_stack;
15429 + walk_stack_t *walk_stack;
15430 };
15431
15432 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15433 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15434 index 4ec45b3..a4f0a8a 100644
15435 --- a/arch/x86/include/asm/switch_to.h
15436 +++ b/arch/x86/include/asm/switch_to.h
15437 @@ -108,7 +108,7 @@ do { \
15438 "call __switch_to\n\t" \
15439 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15440 __switch_canary \
15441 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15442 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15443 "movq %%rax,%%rdi\n\t" \
15444 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15445 "jnz ret_from_fork\n\t" \
15446 @@ -119,7 +119,7 @@ do { \
15447 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15448 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15449 [_tif_fork] "i" (_TIF_FORK), \
15450 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15451 + [thread_info] "m" (current_tinfo), \
15452 [current_task] "m" (current_task) \
15453 __switch_canary_iparam \
15454 : "memory", "cc" __EXTRA_CLOBBER)
15455 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15456 index 2cd056e..0224df8 100644
15457 --- a/arch/x86/include/asm/thread_info.h
15458 +++ b/arch/x86/include/asm/thread_info.h
15459 @@ -10,6 +10,7 @@
15460 #include <linux/compiler.h>
15461 #include <asm/page.h>
15462 #include <asm/types.h>
15463 +#include <asm/percpu.h>
15464
15465 /*
15466 * low level task data that entry.S needs immediate access to
15467 @@ -23,7 +24,6 @@ struct exec_domain;
15468 #include <linux/atomic.h>
15469
15470 struct thread_info {
15471 - struct task_struct *task; /* main task structure */
15472 struct exec_domain *exec_domain; /* execution domain */
15473 __u32 flags; /* low level flags */
15474 __u32 status; /* thread synchronous flags */
15475 @@ -33,19 +33,13 @@ struct thread_info {
15476 mm_segment_t addr_limit;
15477 struct restart_block restart_block;
15478 void __user *sysenter_return;
15479 -#ifdef CONFIG_X86_32
15480 - unsigned long previous_esp; /* ESP of the previous stack in
15481 - case of nested (IRQ) stacks
15482 - */
15483 - __u8 supervisor_stack[0];
15484 -#endif
15485 + unsigned long lowest_stack;
15486 unsigned int sig_on_uaccess_error:1;
15487 unsigned int uaccess_err:1; /* uaccess failed */
15488 };
15489
15490 -#define INIT_THREAD_INFO(tsk) \
15491 +#define INIT_THREAD_INFO \
15492 { \
15493 - .task = &tsk, \
15494 .exec_domain = &default_exec_domain, \
15495 .flags = 0, \
15496 .cpu = 0, \
15497 @@ -56,7 +50,7 @@ struct thread_info {
15498 }, \
15499 }
15500
15501 -#define init_thread_info (init_thread_union.thread_info)
15502 +#define init_thread_info (init_thread_union.stack)
15503 #define init_stack (init_thread_union.stack)
15504
15505 #else /* !__ASSEMBLY__ */
15506 @@ -97,6 +91,7 @@ struct thread_info {
15507 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15508 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15509 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15510 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15511
15512 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15513 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15514 @@ -121,17 +116,18 @@ struct thread_info {
15515 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15516 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15517 #define _TIF_X32 (1 << TIF_X32)
15518 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15519
15520 /* work to do in syscall_trace_enter() */
15521 #define _TIF_WORK_SYSCALL_ENTRY \
15522 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15523 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15524 - _TIF_NOHZ)
15525 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15526
15527 /* work to do in syscall_trace_leave() */
15528 #define _TIF_WORK_SYSCALL_EXIT \
15529 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15530 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15531 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15532
15533 /* work to do on interrupt/exception return */
15534 #define _TIF_WORK_MASK \
15535 @@ -142,7 +138,7 @@ struct thread_info {
15536 /* work to do on any return to user space */
15537 #define _TIF_ALLWORK_MASK \
15538 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15539 - _TIF_NOHZ)
15540 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15541
15542 /* Only used for 64 bit */
15543 #define _TIF_DO_NOTIFY_MASK \
15544 @@ -158,45 +154,40 @@ struct thread_info {
15545
15546 #define PREEMPT_ACTIVE 0x10000000
15547
15548 -#ifdef CONFIG_X86_32
15549 -
15550 -#define STACK_WARN (THREAD_SIZE/8)
15551 -/*
15552 - * macros/functions for gaining access to the thread information structure
15553 - *
15554 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15555 - */
15556 -#ifndef __ASSEMBLY__
15557 -
15558 -
15559 -/* how to get the current stack pointer from C */
15560 -register unsigned long current_stack_pointer asm("esp") __used;
15561 -
15562 -/* how to get the thread information struct from C */
15563 -static inline struct thread_info *current_thread_info(void)
15564 -{
15565 - return (struct thread_info *)
15566 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15567 -}
15568 -
15569 -#else /* !__ASSEMBLY__ */
15570 -
15571 +#ifdef __ASSEMBLY__
15572 /* how to get the thread information struct from ASM */
15573 #define GET_THREAD_INFO(reg) \
15574 - movl $-THREAD_SIZE, reg; \
15575 - andl %esp, reg
15576 + mov PER_CPU_VAR(current_tinfo), reg
15577
15578 /* use this one if reg already contains %esp */
15579 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15580 - andl $-THREAD_SIZE, reg
15581 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15582 +#else
15583 +/* how to get the thread information struct from C */
15584 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15585 +
15586 +static __always_inline struct thread_info *current_thread_info(void)
15587 +{
15588 + return this_cpu_read_stable(current_tinfo);
15589 +}
15590 +#endif
15591 +
15592 +#ifdef CONFIG_X86_32
15593 +
15594 +#define STACK_WARN (THREAD_SIZE/8)
15595 +/*
15596 + * macros/functions for gaining access to the thread information structure
15597 + *
15598 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15599 + */
15600 +#ifndef __ASSEMBLY__
15601 +
15602 +/* how to get the current stack pointer from C */
15603 +register unsigned long current_stack_pointer asm("esp") __used;
15604
15605 #endif
15606
15607 #else /* X86_32 */
15608
15609 -#include <asm/percpu.h>
15610 -#define KERNEL_STACK_OFFSET (5*8)
15611 -
15612 /*
15613 * macros/functions for gaining access to the thread information structure
15614 * preempt_count needs to be 1 initially, until the scheduler is functional.
15615 @@ -204,27 +195,8 @@ static inline struct thread_info *current_thread_info(void)
15616 #ifndef __ASSEMBLY__
15617 DECLARE_PER_CPU(unsigned long, kernel_stack);
15618
15619 -static inline struct thread_info *current_thread_info(void)
15620 -{
15621 - struct thread_info *ti;
15622 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15623 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15624 - return ti;
15625 -}
15626 -
15627 -#else /* !__ASSEMBLY__ */
15628 -
15629 -/* how to get the thread information struct from ASM */
15630 -#define GET_THREAD_INFO(reg) \
15631 - movq PER_CPU_VAR(kernel_stack),reg ; \
15632 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15633 -
15634 -/*
15635 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15636 - * a certain register (to be used in assembler memory operands).
15637 - */
15638 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15639 -
15640 +/* how to get the current stack pointer from C */
15641 +register unsigned long current_stack_pointer asm("rsp") __used;
15642 #endif
15643
15644 #endif /* !X86_32 */
15645 @@ -285,5 +257,12 @@ static inline bool is_ia32_task(void)
15646 extern void arch_task_cache_init(void);
15647 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15648 extern void arch_release_task_struct(struct task_struct *tsk);
15649 +
15650 +#define __HAVE_THREAD_FUNCTIONS
15651 +#define task_thread_info(task) (&(task)->tinfo)
15652 +#define task_stack_page(task) ((task)->stack)
15653 +#define setup_thread_stack(p, org) do {} while (0)
15654 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15655 +
15656 #endif
15657 #endif /* _ASM_X86_THREAD_INFO_H */
15658 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15659 index 5ee2687..70d5895 100644
15660 --- a/arch/x86/include/asm/uaccess.h
15661 +++ b/arch/x86/include/asm/uaccess.h
15662 @@ -7,6 +7,7 @@
15663 #include <linux/compiler.h>
15664 #include <linux/thread_info.h>
15665 #include <linux/string.h>
15666 +#include <linux/sched.h>
15667 #include <asm/asm.h>
15668 #include <asm/page.h>
15669 #include <asm/smap.h>
15670 @@ -29,7 +30,12 @@
15671
15672 #define get_ds() (KERNEL_DS)
15673 #define get_fs() (current_thread_info()->addr_limit)
15674 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15675 +void __set_fs(mm_segment_t x);
15676 +void set_fs(mm_segment_t x);
15677 +#else
15678 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15679 +#endif
15680
15681 #define segment_eq(a, b) ((a).seg == (b).seg)
15682
15683 @@ -77,8 +83,33 @@
15684 * checks that the pointer is in the user space range - after calling
15685 * this function, memory access functions may still return -EFAULT.
15686 */
15687 -#define access_ok(type, addr, size) \
15688 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15689 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15690 +#define access_ok(type, addr, size) \
15691 +({ \
15692 + long __size = size; \
15693 + unsigned long __addr = (unsigned long)addr; \
15694 + unsigned long __addr_ao = __addr & PAGE_MASK; \
15695 + unsigned long __end_ao = __addr + __size - 1; \
15696 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
15697 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
15698 + while(__addr_ao <= __end_ao) { \
15699 + char __c_ao; \
15700 + __addr_ao += PAGE_SIZE; \
15701 + if (__size > PAGE_SIZE) \
15702 + cond_resched(); \
15703 + if (__get_user(__c_ao, (char __user *)__addr)) \
15704 + break; \
15705 + if (type != VERIFY_WRITE) { \
15706 + __addr = __addr_ao; \
15707 + continue; \
15708 + } \
15709 + if (__put_user(__c_ao, (char __user *)__addr)) \
15710 + break; \
15711 + __addr = __addr_ao; \
15712 + } \
15713 + } \
15714 + __ret_ao; \
15715 +})
15716
15717 /*
15718 * The exception table consists of pairs of addresses relative to the
15719 @@ -176,13 +207,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15720 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
15721 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
15722
15723 -
15724 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15725 +#define __copyuser_seg "gs;"
15726 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
15727 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
15728 +#else
15729 +#define __copyuser_seg
15730 +#define __COPYUSER_SET_ES
15731 +#define __COPYUSER_RESTORE_ES
15732 +#endif
15733
15734 #ifdef CONFIG_X86_32
15735 #define __put_user_asm_u64(x, addr, err, errret) \
15736 asm volatile(ASM_STAC "\n" \
15737 - "1: movl %%eax,0(%2)\n" \
15738 - "2: movl %%edx,4(%2)\n" \
15739 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
15740 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
15741 "3: " ASM_CLAC "\n" \
15742 ".section .fixup,\"ax\"\n" \
15743 "4: movl %3,%0\n" \
15744 @@ -195,8 +234,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15745
15746 #define __put_user_asm_ex_u64(x, addr) \
15747 asm volatile(ASM_STAC "\n" \
15748 - "1: movl %%eax,0(%1)\n" \
15749 - "2: movl %%edx,4(%1)\n" \
15750 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
15751 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
15752 "3: " ASM_CLAC "\n" \
15753 _ASM_EXTABLE_EX(1b, 2b) \
15754 _ASM_EXTABLE_EX(2b, 3b) \
15755 @@ -246,7 +285,7 @@ extern void __put_user_8(void);
15756 __typeof__(*(ptr)) __pu_val; \
15757 __chk_user_ptr(ptr); \
15758 might_fault(); \
15759 - __pu_val = x; \
15760 + __pu_val = (x); \
15761 switch (sizeof(*(ptr))) { \
15762 case 1: \
15763 __put_user_x(1, __pu_val, ptr, __ret_pu); \
15764 @@ -345,7 +384,7 @@ do { \
15765
15766 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15767 asm volatile(ASM_STAC "\n" \
15768 - "1: mov"itype" %2,%"rtype"1\n" \
15769 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
15770 "2: " ASM_CLAC "\n" \
15771 ".section .fixup,\"ax\"\n" \
15772 "3: mov %3,%0\n" \
15773 @@ -353,7 +392,7 @@ do { \
15774 " jmp 2b\n" \
15775 ".previous\n" \
15776 _ASM_EXTABLE(1b, 3b) \
15777 - : "=r" (err), ltype(x) \
15778 + : "=r" (err), ltype (x) \
15779 : "m" (__m(addr)), "i" (errret), "0" (err))
15780
15781 #define __get_user_size_ex(x, ptr, size) \
15782 @@ -378,7 +417,7 @@ do { \
15783 } while (0)
15784
15785 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
15786 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
15787 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
15788 "2:\n" \
15789 _ASM_EXTABLE_EX(1b, 2b) \
15790 : ltype(x) : "m" (__m(addr)))
15791 @@ -395,13 +434,24 @@ do { \
15792 int __gu_err; \
15793 unsigned long __gu_val; \
15794 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
15795 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
15796 + (x) = (__typeof__(*(ptr)))__gu_val; \
15797 __gu_err; \
15798 })
15799
15800 /* FIXME: this hack is definitely wrong -AK */
15801 struct __large_struct { unsigned long buf[100]; };
15802 -#define __m(x) (*(struct __large_struct __user *)(x))
15803 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15804 +#define ____m(x) \
15805 +({ \
15806 + unsigned long ____x = (unsigned long)(x); \
15807 + if (____x < pax_user_shadow_base) \
15808 + ____x += pax_user_shadow_base; \
15809 + (typeof(x))____x; \
15810 +})
15811 +#else
15812 +#define ____m(x) (x)
15813 +#endif
15814 +#define __m(x) (*(struct __large_struct __user *)____m(x))
15815
15816 /*
15817 * Tell gcc we read from memory instead of writing: this is because
15818 @@ -410,7 +460,7 @@ struct __large_struct { unsigned long buf[100]; };
15819 */
15820 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15821 asm volatile(ASM_STAC "\n" \
15822 - "1: mov"itype" %"rtype"1,%2\n" \
15823 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
15824 "2: " ASM_CLAC "\n" \
15825 ".section .fixup,\"ax\"\n" \
15826 "3: mov %3,%0\n" \
15827 @@ -418,10 +468,10 @@ struct __large_struct { unsigned long buf[100]; };
15828 ".previous\n" \
15829 _ASM_EXTABLE(1b, 3b) \
15830 : "=r"(err) \
15831 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
15832 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
15833
15834 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
15835 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
15836 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
15837 "2:\n" \
15838 _ASM_EXTABLE_EX(1b, 2b) \
15839 : : ltype(x), "m" (__m(addr)))
15840 @@ -460,8 +510,12 @@ struct __large_struct { unsigned long buf[100]; };
15841 * On error, the variable @x is set to zero.
15842 */
15843
15844 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15845 +#define __get_user(x, ptr) get_user((x), (ptr))
15846 +#else
15847 #define __get_user(x, ptr) \
15848 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
15849 +#endif
15850
15851 /**
15852 * __put_user: - Write a simple value into user space, with less checking.
15853 @@ -483,8 +537,12 @@ struct __large_struct { unsigned long buf[100]; };
15854 * Returns zero on success, or -EFAULT on error.
15855 */
15856
15857 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15858 +#define __put_user(x, ptr) put_user((x), (ptr))
15859 +#else
15860 #define __put_user(x, ptr) \
15861 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
15862 +#endif
15863
15864 #define __get_user_unaligned __get_user
15865 #define __put_user_unaligned __put_user
15866 @@ -502,7 +560,7 @@ struct __large_struct { unsigned long buf[100]; };
15867 #define get_user_ex(x, ptr) do { \
15868 unsigned long __gue_val; \
15869 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
15870 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
15871 + (x) = (__typeof__(*(ptr)))__gue_val; \
15872 } while (0)
15873
15874 #define put_user_try uaccess_try
15875 @@ -519,8 +577,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
15876 extern __must_check long strlen_user(const char __user *str);
15877 extern __must_check long strnlen_user(const char __user *str, long n);
15878
15879 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
15880 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
15881 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15882 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15883
15884 /*
15885 * movsl can be slow when source and dest are not both 8-byte aligned
15886 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
15887 index 7f760a9..04b1c65 100644
15888 --- a/arch/x86/include/asm/uaccess_32.h
15889 +++ b/arch/x86/include/asm/uaccess_32.h
15890 @@ -11,15 +11,15 @@
15891 #include <asm/page.h>
15892
15893 unsigned long __must_check __copy_to_user_ll
15894 - (void __user *to, const void *from, unsigned long n);
15895 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
15896 unsigned long __must_check __copy_from_user_ll
15897 - (void *to, const void __user *from, unsigned long n);
15898 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15899 unsigned long __must_check __copy_from_user_ll_nozero
15900 - (void *to, const void __user *from, unsigned long n);
15901 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15902 unsigned long __must_check __copy_from_user_ll_nocache
15903 - (void *to, const void __user *from, unsigned long n);
15904 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15905 unsigned long __must_check __copy_from_user_ll_nocache_nozero
15906 - (void *to, const void __user *from, unsigned long n);
15907 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15908
15909 /**
15910 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
15911 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
15912 static __always_inline unsigned long __must_check
15913 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
15914 {
15915 + if ((long)n < 0)
15916 + return n;
15917 +
15918 + check_object_size(from, n, true);
15919 +
15920 if (__builtin_constant_p(n)) {
15921 unsigned long ret;
15922
15923 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
15924 __copy_to_user(void __user *to, const void *from, unsigned long n)
15925 {
15926 might_fault();
15927 +
15928 return __copy_to_user_inatomic(to, from, n);
15929 }
15930
15931 static __always_inline unsigned long
15932 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
15933 {
15934 + if ((long)n < 0)
15935 + return n;
15936 +
15937 /* Avoid zeroing the tail if the copy fails..
15938 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
15939 * but as the zeroing behaviour is only significant when n is not
15940 @@ -137,6 +146,12 @@ static __always_inline unsigned long
15941 __copy_from_user(void *to, const void __user *from, unsigned long n)
15942 {
15943 might_fault();
15944 +
15945 + if ((long)n < 0)
15946 + return n;
15947 +
15948 + check_object_size(to, n, false);
15949 +
15950 if (__builtin_constant_p(n)) {
15951 unsigned long ret;
15952
15953 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
15954 const void __user *from, unsigned long n)
15955 {
15956 might_fault();
15957 +
15958 + if ((long)n < 0)
15959 + return n;
15960 +
15961 if (__builtin_constant_p(n)) {
15962 unsigned long ret;
15963
15964 @@ -181,15 +200,19 @@ static __always_inline unsigned long
15965 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
15966 unsigned long n)
15967 {
15968 - return __copy_from_user_ll_nocache_nozero(to, from, n);
15969 + if ((long)n < 0)
15970 + return n;
15971 +
15972 + return __copy_from_user_ll_nocache_nozero(to, from, n);
15973 }
15974
15975 -unsigned long __must_check copy_to_user(void __user *to,
15976 - const void *from, unsigned long n);
15977 -unsigned long __must_check _copy_from_user(void *to,
15978 - const void __user *from,
15979 - unsigned long n);
15980 -
15981 +extern void copy_to_user_overflow(void)
15982 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15983 + __compiletime_error("copy_to_user() buffer size is not provably correct")
15984 +#else
15985 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
15986 +#endif
15987 +;
15988
15989 extern void copy_from_user_overflow(void)
15990 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15991 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
15992 #endif
15993 ;
15994
15995 -static inline unsigned long __must_check copy_from_user(void *to,
15996 - const void __user *from,
15997 - unsigned long n)
15998 +/**
15999 + * copy_to_user: - Copy a block of data into user space.
16000 + * @to: Destination address, in user space.
16001 + * @from: Source address, in kernel space.
16002 + * @n: Number of bytes to copy.
16003 + *
16004 + * Context: User context only. This function may sleep.
16005 + *
16006 + * Copy data from kernel space to user space.
16007 + *
16008 + * Returns number of bytes that could not be copied.
16009 + * On success, this will be zero.
16010 + */
16011 +static inline unsigned long __must_check
16012 +copy_to_user(void __user *to, const void *from, unsigned long n)
16013 {
16014 - int sz = __compiletime_object_size(to);
16015 + size_t sz = __compiletime_object_size(from);
16016
16017 - if (likely(sz == -1 || sz >= n))
16018 - n = _copy_from_user(to, from, n);
16019 - else
16020 + if (unlikely(sz != (size_t)-1 && sz < n))
16021 + copy_to_user_overflow();
16022 + else if (access_ok(VERIFY_WRITE, to, n))
16023 + n = __copy_to_user(to, from, n);
16024 + return n;
16025 +}
16026 +
16027 +/**
16028 + * copy_from_user: - Copy a block of data from user space.
16029 + * @to: Destination address, in kernel space.
16030 + * @from: Source address, in user space.
16031 + * @n: Number of bytes to copy.
16032 + *
16033 + * Context: User context only. This function may sleep.
16034 + *
16035 + * Copy data from user space to kernel space.
16036 + *
16037 + * Returns number of bytes that could not be copied.
16038 + * On success, this will be zero.
16039 + *
16040 + * If some data could not be copied, this function will pad the copied
16041 + * data to the requested size using zero bytes.
16042 + */
16043 +static inline unsigned long __must_check
16044 +copy_from_user(void *to, const void __user *from, unsigned long n)
16045 +{
16046 + size_t sz = __compiletime_object_size(to);
16047 +
16048 + check_object_size(to, n, false);
16049 +
16050 + if (unlikely(sz != (size_t)-1 && sz < n))
16051 copy_from_user_overflow();
16052 -
16053 + else if (access_ok(VERIFY_READ, from, n))
16054 + n = __copy_from_user(to, from, n);
16055 + else if ((long)n > 0)
16056 + memset(to, 0, n);
16057 return n;
16058 }
16059
16060 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
16061 index 142810c..1f2a0a7 100644
16062 --- a/arch/x86/include/asm/uaccess_64.h
16063 +++ b/arch/x86/include/asm/uaccess_64.h
16064 @@ -10,6 +10,9 @@
16065 #include <asm/alternative.h>
16066 #include <asm/cpufeature.h>
16067 #include <asm/page.h>
16068 +#include <asm/pgtable.h>
16069 +
16070 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
16071
16072 /*
16073 * Copy To/From Userspace
16074 @@ -17,13 +20,13 @@
16075
16076 /* Handles exceptions in both to and from, but doesn't do access_ok */
16077 __must_check unsigned long
16078 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
16079 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
16080 __must_check unsigned long
16081 -copy_user_generic_string(void *to, const void *from, unsigned len);
16082 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
16083 __must_check unsigned long
16084 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
16085 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
16086
16087 -static __always_inline __must_check unsigned long
16088 +static __always_inline __must_check __size_overflow(3) unsigned long
16089 copy_user_generic(void *to, const void *from, unsigned len)
16090 {
16091 unsigned ret;
16092 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
16093 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
16094 "=d" (len)),
16095 "1" (to), "2" (from), "3" (len)
16096 - : "memory", "rcx", "r8", "r9", "r10", "r11");
16097 + : "memory", "rcx", "r8", "r9", "r11");
16098 return ret;
16099 }
16100
16101 +static __always_inline __must_check unsigned long
16102 +__copy_to_user(void __user *to, const void *from, unsigned long len);
16103 +static __always_inline __must_check unsigned long
16104 +__copy_from_user(void *to, const void __user *from, unsigned long len);
16105 __must_check unsigned long
16106 -_copy_to_user(void __user *to, const void *from, unsigned len);
16107 -__must_check unsigned long
16108 -_copy_from_user(void *to, const void __user *from, unsigned len);
16109 -__must_check unsigned long
16110 -copy_in_user(void __user *to, const void __user *from, unsigned len);
16111 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
16112 +
16113 +extern void copy_to_user_overflow(void)
16114 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16115 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16116 +#else
16117 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16118 +#endif
16119 +;
16120 +
16121 +extern void copy_from_user_overflow(void)
16122 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16123 + __compiletime_error("copy_from_user() buffer size is not provably correct")
16124 +#else
16125 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
16126 +#endif
16127 +;
16128
16129 static inline unsigned long __must_check copy_from_user(void *to,
16130 const void __user *from,
16131 unsigned long n)
16132 {
16133 - int sz = __compiletime_object_size(to);
16134 -
16135 might_fault();
16136 - if (likely(sz == -1 || sz >= n))
16137 - n = _copy_from_user(to, from, n);
16138 -#ifdef CONFIG_DEBUG_VM
16139 - else
16140 - WARN(1, "Buffer overflow detected!\n");
16141 -#endif
16142 +
16143 + check_object_size(to, n, false);
16144 +
16145 + if (access_ok(VERIFY_READ, from, n))
16146 + n = __copy_from_user(to, from, n);
16147 + else if (n < INT_MAX)
16148 + memset(to, 0, n);
16149 return n;
16150 }
16151
16152 static __always_inline __must_check
16153 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16154 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16155 {
16156 might_fault();
16157
16158 - return _copy_to_user(dst, src, size);
16159 + if (access_ok(VERIFY_WRITE, dst, size))
16160 + size = __copy_to_user(dst, src, size);
16161 + return size;
16162 }
16163
16164 static __always_inline __must_check
16165 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16166 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16167 {
16168 - int ret = 0;
16169 + size_t sz = __compiletime_object_size(dst);
16170 + unsigned ret = 0;
16171
16172 might_fault();
16173 +
16174 + if (size > INT_MAX)
16175 + return size;
16176 +
16177 + check_object_size(dst, size, false);
16178 +
16179 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16180 + if (!__access_ok(VERIFY_READ, src, size))
16181 + return size;
16182 +#endif
16183 +
16184 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16185 + copy_from_user_overflow();
16186 + return size;
16187 + }
16188 +
16189 if (!__builtin_constant_p(size))
16190 - return copy_user_generic(dst, (__force void *)src, size);
16191 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16192 switch (size) {
16193 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16194 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16195 ret, "b", "b", "=q", 1);
16196 return ret;
16197 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16198 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16199 ret, "w", "w", "=r", 2);
16200 return ret;
16201 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16202 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16203 ret, "l", "k", "=r", 4);
16204 return ret;
16205 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16206 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16207 ret, "q", "", "=r", 8);
16208 return ret;
16209 case 10:
16210 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16211 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16212 ret, "q", "", "=r", 10);
16213 if (unlikely(ret))
16214 return ret;
16215 __get_user_asm(*(u16 *)(8 + (char *)dst),
16216 - (u16 __user *)(8 + (char __user *)src),
16217 + (const u16 __user *)(8 + (const char __user *)src),
16218 ret, "w", "w", "=r", 2);
16219 return ret;
16220 case 16:
16221 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16222 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16223 ret, "q", "", "=r", 16);
16224 if (unlikely(ret))
16225 return ret;
16226 __get_user_asm(*(u64 *)(8 + (char *)dst),
16227 - (u64 __user *)(8 + (char __user *)src),
16228 + (const u64 __user *)(8 + (const char __user *)src),
16229 ret, "q", "", "=r", 8);
16230 return ret;
16231 default:
16232 - return copy_user_generic(dst, (__force void *)src, size);
16233 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16234 }
16235 }
16236
16237 static __always_inline __must_check
16238 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16239 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16240 {
16241 - int ret = 0;
16242 + size_t sz = __compiletime_object_size(src);
16243 + unsigned ret = 0;
16244
16245 might_fault();
16246 +
16247 + if (size > INT_MAX)
16248 + return size;
16249 +
16250 + check_object_size(src, size, true);
16251 +
16252 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16253 + if (!__access_ok(VERIFY_WRITE, dst, size))
16254 + return size;
16255 +#endif
16256 +
16257 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16258 + copy_to_user_overflow();
16259 + return size;
16260 + }
16261 +
16262 if (!__builtin_constant_p(size))
16263 - return copy_user_generic((__force void *)dst, src, size);
16264 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16265 switch (size) {
16266 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16267 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16268 ret, "b", "b", "iq", 1);
16269 return ret;
16270 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16271 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16272 ret, "w", "w", "ir", 2);
16273 return ret;
16274 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16275 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16276 ret, "l", "k", "ir", 4);
16277 return ret;
16278 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16279 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16280 ret, "q", "", "er", 8);
16281 return ret;
16282 case 10:
16283 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16284 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16285 ret, "q", "", "er", 10);
16286 if (unlikely(ret))
16287 return ret;
16288 asm("":::"memory");
16289 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16290 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16291 ret, "w", "w", "ir", 2);
16292 return ret;
16293 case 16:
16294 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16295 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16296 ret, "q", "", "er", 16);
16297 if (unlikely(ret))
16298 return ret;
16299 asm("":::"memory");
16300 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16301 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16302 ret, "q", "", "er", 8);
16303 return ret;
16304 default:
16305 - return copy_user_generic((__force void *)dst, src, size);
16306 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16307 }
16308 }
16309
16310 static __always_inline __must_check
16311 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16312 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16313 {
16314 - int ret = 0;
16315 + unsigned ret = 0;
16316
16317 might_fault();
16318 +
16319 + if (size > INT_MAX)
16320 + return size;
16321 +
16322 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16323 + if (!__access_ok(VERIFY_READ, src, size))
16324 + return size;
16325 + if (!__access_ok(VERIFY_WRITE, dst, size))
16326 + return size;
16327 +#endif
16328 +
16329 if (!__builtin_constant_p(size))
16330 - return copy_user_generic((__force void *)dst,
16331 - (__force void *)src, size);
16332 + return copy_user_generic((__force_kernel void *)____m(dst),
16333 + (__force_kernel const void *)____m(src), size);
16334 switch (size) {
16335 case 1: {
16336 u8 tmp;
16337 - __get_user_asm(tmp, (u8 __user *)src,
16338 + __get_user_asm(tmp, (const u8 __user *)src,
16339 ret, "b", "b", "=q", 1);
16340 if (likely(!ret))
16341 __put_user_asm(tmp, (u8 __user *)dst,
16342 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16343 }
16344 case 2: {
16345 u16 tmp;
16346 - __get_user_asm(tmp, (u16 __user *)src,
16347 + __get_user_asm(tmp, (const u16 __user *)src,
16348 ret, "w", "w", "=r", 2);
16349 if (likely(!ret))
16350 __put_user_asm(tmp, (u16 __user *)dst,
16351 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16352
16353 case 4: {
16354 u32 tmp;
16355 - __get_user_asm(tmp, (u32 __user *)src,
16356 + __get_user_asm(tmp, (const u32 __user *)src,
16357 ret, "l", "k", "=r", 4);
16358 if (likely(!ret))
16359 __put_user_asm(tmp, (u32 __user *)dst,
16360 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16361 }
16362 case 8: {
16363 u64 tmp;
16364 - __get_user_asm(tmp, (u64 __user *)src,
16365 + __get_user_asm(tmp, (const u64 __user *)src,
16366 ret, "q", "", "=r", 8);
16367 if (likely(!ret))
16368 __put_user_asm(tmp, (u64 __user *)dst,
16369 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16370 return ret;
16371 }
16372 default:
16373 - return copy_user_generic((__force void *)dst,
16374 - (__force void *)src, size);
16375 + return copy_user_generic((__force_kernel void *)____m(dst),
16376 + (__force_kernel const void *)____m(src), size);
16377 }
16378 }
16379
16380 static __must_check __always_inline int
16381 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16382 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16383 {
16384 - return copy_user_generic(dst, (__force const void *)src, size);
16385 + if (size > INT_MAX)
16386 + return size;
16387 +
16388 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16389 + if (!__access_ok(VERIFY_READ, src, size))
16390 + return size;
16391 +#endif
16392 +
16393 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16394 }
16395
16396 -static __must_check __always_inline int
16397 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16398 +static __must_check __always_inline unsigned long
16399 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16400 {
16401 - return copy_user_generic((__force void *)dst, src, size);
16402 + if (size > INT_MAX)
16403 + return size;
16404 +
16405 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16406 + if (!__access_ok(VERIFY_WRITE, dst, size))
16407 + return size;
16408 +#endif
16409 +
16410 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16411 }
16412
16413 -extern long __copy_user_nocache(void *dst, const void __user *src,
16414 - unsigned size, int zerorest);
16415 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16416 + unsigned long size, int zerorest) __size_overflow(3);
16417
16418 -static inline int
16419 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16420 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16421 {
16422 might_sleep();
16423 +
16424 + if (size > INT_MAX)
16425 + return size;
16426 +
16427 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16428 + if (!__access_ok(VERIFY_READ, src, size))
16429 + return size;
16430 +#endif
16431 +
16432 return __copy_user_nocache(dst, src, size, 1);
16433 }
16434
16435 -static inline int
16436 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16437 - unsigned size)
16438 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16439 + unsigned long size)
16440 {
16441 + if (size > INT_MAX)
16442 + return size;
16443 +
16444 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16445 + if (!__access_ok(VERIFY_READ, src, size))
16446 + return size;
16447 +#endif
16448 +
16449 return __copy_user_nocache(dst, src, size, 0);
16450 }
16451
16452 -unsigned long
16453 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16454 +extern unsigned long
16455 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16456
16457 #endif /* _ASM_X86_UACCESS_64_H */
16458 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16459 index 5b238981..77fdd78 100644
16460 --- a/arch/x86/include/asm/word-at-a-time.h
16461 +++ b/arch/x86/include/asm/word-at-a-time.h
16462 @@ -11,7 +11,7 @@
16463 * and shift, for example.
16464 */
16465 struct word_at_a_time {
16466 - const unsigned long one_bits, high_bits;
16467 + unsigned long one_bits, high_bits;
16468 };
16469
16470 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16471 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16472 index d8d9922..bf6cecb 100644
16473 --- a/arch/x86/include/asm/x86_init.h
16474 +++ b/arch/x86/include/asm/x86_init.h
16475 @@ -129,7 +129,7 @@ struct x86_init_ops {
16476 struct x86_init_timers timers;
16477 struct x86_init_iommu iommu;
16478 struct x86_init_pci pci;
16479 -};
16480 +} __no_const;
16481
16482 /**
16483 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16484 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
16485 void (*setup_percpu_clockev)(void);
16486 void (*early_percpu_clock_init)(void);
16487 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16488 -};
16489 +} __no_const;
16490
16491 /**
16492 * struct x86_platform_ops - platform specific runtime functions
16493 @@ -166,7 +166,7 @@ struct x86_platform_ops {
16494 void (*save_sched_clock_state)(void);
16495 void (*restore_sched_clock_state)(void);
16496 void (*apic_post_init)(void);
16497 -};
16498 +} __no_const;
16499
16500 struct pci_dev;
16501 struct msi_msg;
16502 @@ -180,7 +180,7 @@ struct x86_msi_ops {
16503 void (*teardown_msi_irqs)(struct pci_dev *dev);
16504 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16505 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
16506 -};
16507 +} __no_const;
16508
16509 struct IO_APIC_route_entry;
16510 struct io_apic_irq_attr;
16511 @@ -201,7 +201,7 @@ struct x86_io_apic_ops {
16512 unsigned int destination, int vector,
16513 struct io_apic_irq_attr *attr);
16514 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
16515 -};
16516 +} __no_const;
16517
16518 extern struct x86_init_ops x86_init;
16519 extern struct x86_cpuinit_ops x86_cpuinit;
16520 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16521 index 0415cda..b43d877 100644
16522 --- a/arch/x86/include/asm/xsave.h
16523 +++ b/arch/x86/include/asm/xsave.h
16524 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16525 return -EFAULT;
16526
16527 __asm__ __volatile__(ASM_STAC "\n"
16528 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16529 + "1:"
16530 + __copyuser_seg
16531 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16532 "2: " ASM_CLAC "\n"
16533 ".section .fixup,\"ax\"\n"
16534 "3: movl $-1,%[err]\n"
16535 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16536 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16537 {
16538 int err;
16539 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16540 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16541 u32 lmask = mask;
16542 u32 hmask = mask >> 32;
16543
16544 __asm__ __volatile__(ASM_STAC "\n"
16545 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16546 + "1:"
16547 + __copyuser_seg
16548 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16549 "2: " ASM_CLAC "\n"
16550 ".section .fixup,\"ax\"\n"
16551 "3: movl $-1,%[err]\n"
16552 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16553 index bbae024..e1528f9 100644
16554 --- a/arch/x86/include/uapi/asm/e820.h
16555 +++ b/arch/x86/include/uapi/asm/e820.h
16556 @@ -63,7 +63,7 @@ struct e820map {
16557 #define ISA_START_ADDRESS 0xa0000
16558 #define ISA_END_ADDRESS 0x100000
16559
16560 -#define BIOS_BEGIN 0x000a0000
16561 +#define BIOS_BEGIN 0x000c0000
16562 #define BIOS_END 0x00100000
16563
16564 #define BIOS_ROM_BASE 0xffe00000
16565 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16566 index 7bd3bd3..5dac791 100644
16567 --- a/arch/x86/kernel/Makefile
16568 +++ b/arch/x86/kernel/Makefile
16569 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16570 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16571 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16572 obj-y += probe_roms.o
16573 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16574 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16575 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16576 obj-y += syscall_$(BITS).o
16577 obj-$(CONFIG_X86_64) += vsyscall_64.o
16578 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16579 index 230c8ea..f915130 100644
16580 --- a/arch/x86/kernel/acpi/boot.c
16581 +++ b/arch/x86/kernel/acpi/boot.c
16582 @@ -1361,7 +1361,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16583 * If your system is blacklisted here, but you find that acpi=force
16584 * works for you, please contact linux-acpi@vger.kernel.org
16585 */
16586 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16587 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16588 /*
16589 * Boxes that need ACPI disabled
16590 */
16591 @@ -1436,7 +1436,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16592 };
16593
16594 /* second table for DMI checks that should run after early-quirks */
16595 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16596 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16597 /*
16598 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16599 * which includes some code which overrides all temperature
16600 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16601 index 0532f5d..36afc0a 100644
16602 --- a/arch/x86/kernel/acpi/sleep.c
16603 +++ b/arch/x86/kernel/acpi/sleep.c
16604 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16605 #else /* CONFIG_64BIT */
16606 #ifdef CONFIG_SMP
16607 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16608 +
16609 + pax_open_kernel();
16610 early_gdt_descr.address =
16611 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16612 + pax_close_kernel();
16613 +
16614 initial_gs = per_cpu_offset(smp_processor_id());
16615 #endif
16616 initial_code = (unsigned long)wakeup_long64;
16617 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16618 index 13ab720..95d5442 100644
16619 --- a/arch/x86/kernel/acpi/wakeup_32.S
16620 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16621 @@ -30,13 +30,11 @@ wakeup_pmode_return:
16622 # and restore the stack ... but you need gdt for this to work
16623 movl saved_context_esp, %esp
16624
16625 - movl %cs:saved_magic, %eax
16626 - cmpl $0x12345678, %eax
16627 + cmpl $0x12345678, saved_magic
16628 jne bogus_magic
16629
16630 # jump to place where we left off
16631 - movl saved_eip, %eax
16632 - jmp *%eax
16633 + jmp *(saved_eip)
16634
16635 bogus_magic:
16636 jmp bogus_magic
16637 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16638 index ef5ccca..bd83949 100644
16639 --- a/arch/x86/kernel/alternative.c
16640 +++ b/arch/x86/kernel/alternative.c
16641 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16642 */
16643 for (a = start; a < end; a++) {
16644 instr = (u8 *)&a->instr_offset + a->instr_offset;
16645 +
16646 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16647 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16648 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16649 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16650 +#endif
16651 +
16652 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16653 BUG_ON(a->replacementlen > a->instrlen);
16654 BUG_ON(a->instrlen > sizeof(insnbuf));
16655 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16656 for (poff = start; poff < end; poff++) {
16657 u8 *ptr = (u8 *)poff + *poff;
16658
16659 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16660 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16661 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16662 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16663 +#endif
16664 +
16665 if (!*poff || ptr < text || ptr >= text_end)
16666 continue;
16667 /* turn DS segment override prefix into lock prefix */
16668 - if (*ptr == 0x3e)
16669 + if (*ktla_ktva(ptr) == 0x3e)
16670 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16671 }
16672 mutex_unlock(&text_mutex);
16673 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16674 for (poff = start; poff < end; poff++) {
16675 u8 *ptr = (u8 *)poff + *poff;
16676
16677 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16678 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16679 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16680 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16681 +#endif
16682 +
16683 if (!*poff || ptr < text || ptr >= text_end)
16684 continue;
16685 /* turn lock prefix into DS segment override prefix */
16686 - if (*ptr == 0xf0)
16687 + if (*ktla_ktva(ptr) == 0xf0)
16688 text_poke(ptr, ((unsigned char []){0x3E}), 1);
16689 }
16690 mutex_unlock(&text_mutex);
16691 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
16692
16693 BUG_ON(p->len > MAX_PATCH_LEN);
16694 /* prep the buffer with the original instructions */
16695 - memcpy(insnbuf, p->instr, p->len);
16696 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
16697 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
16698 (unsigned long)p->instr, p->len);
16699
16700 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
16701 if (!uniproc_patched || num_possible_cpus() == 1)
16702 free_init_pages("SMP alternatives",
16703 (unsigned long)__smp_locks,
16704 - (unsigned long)__smp_locks_end);
16705 + PAGE_ALIGN((unsigned long)__smp_locks_end));
16706 #endif
16707
16708 apply_paravirt(__parainstructions, __parainstructions_end);
16709 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
16710 * instructions. And on the local CPU you need to be protected again NMI or MCE
16711 * handlers seeing an inconsistent instruction while you patch.
16712 */
16713 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
16714 +void *__kprobes text_poke_early(void *addr, const void *opcode,
16715 size_t len)
16716 {
16717 unsigned long flags;
16718 local_irq_save(flags);
16719 - memcpy(addr, opcode, len);
16720 +
16721 + pax_open_kernel();
16722 + memcpy(ktla_ktva(addr), opcode, len);
16723 sync_core();
16724 + pax_close_kernel();
16725 +
16726 local_irq_restore(flags);
16727 /* Could also do a CLFLUSH here to speed up CPU recovery; but
16728 that causes hangs on some VIA CPUs. */
16729 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
16730 */
16731 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
16732 {
16733 - unsigned long flags;
16734 - char *vaddr;
16735 + unsigned char *vaddr = ktla_ktva(addr);
16736 struct page *pages[2];
16737 - int i;
16738 + size_t i;
16739
16740 if (!core_kernel_text((unsigned long)addr)) {
16741 - pages[0] = vmalloc_to_page(addr);
16742 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
16743 + pages[0] = vmalloc_to_page(vaddr);
16744 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
16745 } else {
16746 - pages[0] = virt_to_page(addr);
16747 + pages[0] = virt_to_page(vaddr);
16748 WARN_ON(!PageReserved(pages[0]));
16749 - pages[1] = virt_to_page(addr + PAGE_SIZE);
16750 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
16751 }
16752 BUG_ON(!pages[0]);
16753 - local_irq_save(flags);
16754 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
16755 - if (pages[1])
16756 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
16757 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
16758 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
16759 - clear_fixmap(FIX_TEXT_POKE0);
16760 - if (pages[1])
16761 - clear_fixmap(FIX_TEXT_POKE1);
16762 - local_flush_tlb();
16763 - sync_core();
16764 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
16765 - that causes hangs on some VIA CPUs. */
16766 + text_poke_early(addr, opcode, len);
16767 for (i = 0; i < len; i++)
16768 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
16769 - local_irq_restore(flags);
16770 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
16771 return addr;
16772 }
16773
16774 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
16775 index 904611b..004dde6 100644
16776 --- a/arch/x86/kernel/apic/apic.c
16777 +++ b/arch/x86/kernel/apic/apic.c
16778 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
16779 /*
16780 * Debug level, exported for io_apic.c
16781 */
16782 -unsigned int apic_verbosity;
16783 +int apic_verbosity;
16784
16785 int pic_mode;
16786
16787 @@ -1955,7 +1955,7 @@ void smp_error_interrupt(struct pt_regs *regs)
16788 apic_write(APIC_ESR, 0);
16789 v1 = apic_read(APIC_ESR);
16790 ack_APIC_irq();
16791 - atomic_inc(&irq_err_count);
16792 + atomic_inc_unchecked(&irq_err_count);
16793
16794 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
16795 smp_processor_id(), v0 , v1);
16796 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
16797 index 00c77cf..2dc6a2d 100644
16798 --- a/arch/x86/kernel/apic/apic_flat_64.c
16799 +++ b/arch/x86/kernel/apic/apic_flat_64.c
16800 @@ -157,7 +157,7 @@ static int flat_probe(void)
16801 return 1;
16802 }
16803
16804 -static struct apic apic_flat = {
16805 +static struct apic apic_flat __read_only = {
16806 .name = "flat",
16807 .probe = flat_probe,
16808 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
16809 @@ -271,7 +271,7 @@ static int physflat_probe(void)
16810 return 0;
16811 }
16812
16813 -static struct apic apic_physflat = {
16814 +static struct apic apic_physflat __read_only = {
16815
16816 .name = "physical flat",
16817 .probe = physflat_probe,
16818 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
16819 index e145f28..2752888 100644
16820 --- a/arch/x86/kernel/apic/apic_noop.c
16821 +++ b/arch/x86/kernel/apic/apic_noop.c
16822 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
16823 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
16824 }
16825
16826 -struct apic apic_noop = {
16827 +struct apic apic_noop __read_only = {
16828 .name = "noop",
16829 .probe = noop_probe,
16830 .acpi_madt_oem_check = NULL,
16831 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
16832 index d50e364..543bee3 100644
16833 --- a/arch/x86/kernel/apic/bigsmp_32.c
16834 +++ b/arch/x86/kernel/apic/bigsmp_32.c
16835 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
16836 return dmi_bigsmp;
16837 }
16838
16839 -static struct apic apic_bigsmp = {
16840 +static struct apic apic_bigsmp __read_only = {
16841
16842 .name = "bigsmp",
16843 .probe = probe_bigsmp,
16844 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
16845 index 0874799..a7a7892 100644
16846 --- a/arch/x86/kernel/apic/es7000_32.c
16847 +++ b/arch/x86/kernel/apic/es7000_32.c
16848 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
16849 return ret && es7000_apic_is_cluster();
16850 }
16851
16852 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
16853 -static struct apic __refdata apic_es7000_cluster = {
16854 +static struct apic apic_es7000_cluster __read_only = {
16855
16856 .name = "es7000",
16857 .probe = probe_es7000,
16858 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
16859 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
16860 };
16861
16862 -static struct apic __refdata apic_es7000 = {
16863 +static struct apic apic_es7000 __read_only = {
16864
16865 .name = "es7000",
16866 .probe = probe_es7000,
16867 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
16868 index 9ed796c..e930fe4 100644
16869 --- a/arch/x86/kernel/apic/io_apic.c
16870 +++ b/arch/x86/kernel/apic/io_apic.c
16871 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
16872 }
16873 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
16874
16875 -void lock_vector_lock(void)
16876 +void lock_vector_lock(void) __acquires(vector_lock)
16877 {
16878 /* Used to the online set of cpus does not change
16879 * during assign_irq_vector.
16880 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
16881 raw_spin_lock(&vector_lock);
16882 }
16883
16884 -void unlock_vector_lock(void)
16885 +void unlock_vector_lock(void) __releases(vector_lock)
16886 {
16887 raw_spin_unlock(&vector_lock);
16888 }
16889 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
16890 ack_APIC_irq();
16891 }
16892
16893 -atomic_t irq_mis_count;
16894 +atomic_unchecked_t irq_mis_count;
16895
16896 #ifdef CONFIG_GENERIC_PENDING_IRQ
16897 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
16898 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
16899 * at the cpu.
16900 */
16901 if (!(v & (1 << (i & 0x1f)))) {
16902 - atomic_inc(&irq_mis_count);
16903 + atomic_inc_unchecked(&irq_mis_count);
16904
16905 eoi_ioapic_irq(irq, cfg);
16906 }
16907 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
16908 index d661ee9..791fd33 100644
16909 --- a/arch/x86/kernel/apic/numaq_32.c
16910 +++ b/arch/x86/kernel/apic/numaq_32.c
16911 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
16912 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
16913 }
16914
16915 -/* Use __refdata to keep false positive warning calm. */
16916 -static struct apic __refdata apic_numaq = {
16917 +static struct apic apic_numaq __read_only = {
16918
16919 .name = "NUMAQ",
16920 .probe = probe_numaq,
16921 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
16922 index eb35ef9..f184a21 100644
16923 --- a/arch/x86/kernel/apic/probe_32.c
16924 +++ b/arch/x86/kernel/apic/probe_32.c
16925 @@ -72,7 +72,7 @@ static int probe_default(void)
16926 return 1;
16927 }
16928
16929 -static struct apic apic_default = {
16930 +static struct apic apic_default __read_only = {
16931
16932 .name = "default",
16933 .probe = probe_default,
16934 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
16935 index 77c95c0..434f8a4 100644
16936 --- a/arch/x86/kernel/apic/summit_32.c
16937 +++ b/arch/x86/kernel/apic/summit_32.c
16938 @@ -486,7 +486,7 @@ void setup_summit(void)
16939 }
16940 #endif
16941
16942 -static struct apic apic_summit = {
16943 +static struct apic apic_summit __read_only = {
16944
16945 .name = "summit",
16946 .probe = probe_summit,
16947 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
16948 index c88baa4..757aee1 100644
16949 --- a/arch/x86/kernel/apic/x2apic_cluster.c
16950 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
16951 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
16952 return notifier_from_errno(err);
16953 }
16954
16955 -static struct notifier_block __refdata x2apic_cpu_notifier = {
16956 +static struct notifier_block x2apic_cpu_notifier = {
16957 .notifier_call = update_clusterinfo,
16958 };
16959
16960 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
16961 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
16962 }
16963
16964 -static struct apic apic_x2apic_cluster = {
16965 +static struct apic apic_x2apic_cluster __read_only = {
16966
16967 .name = "cluster x2apic",
16968 .probe = x2apic_cluster_probe,
16969 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
16970 index 562a76d..a003c0f 100644
16971 --- a/arch/x86/kernel/apic/x2apic_phys.c
16972 +++ b/arch/x86/kernel/apic/x2apic_phys.c
16973 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
16974 return apic == &apic_x2apic_phys;
16975 }
16976
16977 -static struct apic apic_x2apic_phys = {
16978 +static struct apic apic_x2apic_phys __read_only = {
16979
16980 .name = "physical x2apic",
16981 .probe = x2apic_phys_probe,
16982 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
16983 index 794f6eb..67e1db2 100644
16984 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
16985 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
16986 @@ -342,7 +342,7 @@ static int uv_probe(void)
16987 return apic == &apic_x2apic_uv_x;
16988 }
16989
16990 -static struct apic __refdata apic_x2apic_uv_x = {
16991 +static struct apic apic_x2apic_uv_x __read_only = {
16992
16993 .name = "UV large system",
16994 .probe = uv_probe,
16995 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
16996 index 66b5faf..3442423 100644
16997 --- a/arch/x86/kernel/apm_32.c
16998 +++ b/arch/x86/kernel/apm_32.c
16999 @@ -434,7 +434,7 @@ static DEFINE_MUTEX(apm_mutex);
17000 * This is for buggy BIOS's that refer to (real mode) segment 0x40
17001 * even though they are called in protected mode.
17002 */
17003 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
17004 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
17005 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
17006
17007 static const char driver_version[] = "1.16ac"; /* no spaces */
17008 @@ -612,7 +612,10 @@ static long __apm_bios_call(void *_call)
17009 BUG_ON(cpu != 0);
17010 gdt = get_cpu_gdt_table(cpu);
17011 save_desc_40 = gdt[0x40 / 8];
17012 +
17013 + pax_open_kernel();
17014 gdt[0x40 / 8] = bad_bios_desc;
17015 + pax_close_kernel();
17016
17017 apm_irq_save(flags);
17018 APM_DO_SAVE_SEGS;
17019 @@ -621,7 +624,11 @@ static long __apm_bios_call(void *_call)
17020 &call->esi);
17021 APM_DO_RESTORE_SEGS;
17022 apm_irq_restore(flags);
17023 +
17024 + pax_open_kernel();
17025 gdt[0x40 / 8] = save_desc_40;
17026 + pax_close_kernel();
17027 +
17028 put_cpu();
17029
17030 return call->eax & 0xff;
17031 @@ -688,7 +695,10 @@ static long __apm_bios_call_simple(void *_call)
17032 BUG_ON(cpu != 0);
17033 gdt = get_cpu_gdt_table(cpu);
17034 save_desc_40 = gdt[0x40 / 8];
17035 +
17036 + pax_open_kernel();
17037 gdt[0x40 / 8] = bad_bios_desc;
17038 + pax_close_kernel();
17039
17040 apm_irq_save(flags);
17041 APM_DO_SAVE_SEGS;
17042 @@ -696,7 +706,11 @@ static long __apm_bios_call_simple(void *_call)
17043 &call->eax);
17044 APM_DO_RESTORE_SEGS;
17045 apm_irq_restore(flags);
17046 +
17047 + pax_open_kernel();
17048 gdt[0x40 / 8] = save_desc_40;
17049 + pax_close_kernel();
17050 +
17051 put_cpu();
17052 return error;
17053 }
17054 @@ -2363,12 +2377,15 @@ static int __init apm_init(void)
17055 * code to that CPU.
17056 */
17057 gdt = get_cpu_gdt_table(0);
17058 +
17059 + pax_open_kernel();
17060 set_desc_base(&gdt[APM_CS >> 3],
17061 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
17062 set_desc_base(&gdt[APM_CS_16 >> 3],
17063 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
17064 set_desc_base(&gdt[APM_DS >> 3],
17065 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
17066 + pax_close_kernel();
17067
17068 proc_create("apm", 0, NULL, &apm_file_ops);
17069
17070 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
17071 index 2861082..6d4718e 100644
17072 --- a/arch/x86/kernel/asm-offsets.c
17073 +++ b/arch/x86/kernel/asm-offsets.c
17074 @@ -33,6 +33,8 @@ void common(void) {
17075 OFFSET(TI_status, thread_info, status);
17076 OFFSET(TI_addr_limit, thread_info, addr_limit);
17077 OFFSET(TI_preempt_count, thread_info, preempt_count);
17078 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
17079 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
17080
17081 BLANK();
17082 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
17083 @@ -53,8 +55,26 @@ void common(void) {
17084 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
17085 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
17086 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
17087 +
17088 +#ifdef CONFIG_PAX_KERNEXEC
17089 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
17090 #endif
17091
17092 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17093 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
17094 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
17095 +#ifdef CONFIG_X86_64
17096 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
17097 +#endif
17098 +#endif
17099 +
17100 +#endif
17101 +
17102 + BLANK();
17103 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
17104 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
17105 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
17106 +
17107 #ifdef CONFIG_XEN
17108 BLANK();
17109 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
17110 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
17111 index 1b4754f..fbb4227 100644
17112 --- a/arch/x86/kernel/asm-offsets_64.c
17113 +++ b/arch/x86/kernel/asm-offsets_64.c
17114 @@ -76,6 +76,7 @@ int main(void)
17115 BLANK();
17116 #undef ENTRY
17117
17118 + DEFINE(TSS_size, sizeof(struct tss_struct));
17119 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17120 BLANK();
17121
17122 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17123 index a0e067d..9c7db16 100644
17124 --- a/arch/x86/kernel/cpu/Makefile
17125 +++ b/arch/x86/kernel/cpu/Makefile
17126 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17127 CFLAGS_REMOVE_perf_event.o = -pg
17128 endif
17129
17130 -# Make sure load_percpu_segment has no stackprotector
17131 -nostackp := $(call cc-option, -fno-stack-protector)
17132 -CFLAGS_common.o := $(nostackp)
17133 -
17134 obj-y := intel_cacheinfo.o scattered.o topology.o
17135 obj-y += proc.o capflags.o powerflags.o common.o
17136 obj-y += vmware.o hypervisor.o mshyperv.o
17137 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17138 index fa96eb0..03efe73 100644
17139 --- a/arch/x86/kernel/cpu/amd.c
17140 +++ b/arch/x86/kernel/cpu/amd.c
17141 @@ -737,7 +737,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17142 unsigned int size)
17143 {
17144 /* AMD errata T13 (order #21922) */
17145 - if ((c->x86 == 6)) {
17146 + if (c->x86 == 6) {
17147 /* Duron Rev A0 */
17148 if (c->x86_model == 3 && c->x86_mask == 0)
17149 size = 64;
17150 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17151 index d814772..c615653 100644
17152 --- a/arch/x86/kernel/cpu/common.c
17153 +++ b/arch/x86/kernel/cpu/common.c
17154 @@ -88,60 +88,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17155
17156 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17157
17158 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17159 -#ifdef CONFIG_X86_64
17160 - /*
17161 - * We need valid kernel segments for data and code in long mode too
17162 - * IRET will check the segment types kkeil 2000/10/28
17163 - * Also sysret mandates a special GDT layout
17164 - *
17165 - * TLS descriptors are currently at a different place compared to i386.
17166 - * Hopefully nobody expects them at a fixed place (Wine?)
17167 - */
17168 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17169 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17170 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17171 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17172 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17173 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17174 -#else
17175 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17176 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17177 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17178 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17179 - /*
17180 - * Segments used for calling PnP BIOS have byte granularity.
17181 - * They code segments and data segments have fixed 64k limits,
17182 - * the transfer segment sizes are set at run time.
17183 - */
17184 - /* 32-bit code */
17185 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17186 - /* 16-bit code */
17187 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17188 - /* 16-bit data */
17189 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17190 - /* 16-bit data */
17191 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17192 - /* 16-bit data */
17193 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17194 - /*
17195 - * The APM segments have byte granularity and their bases
17196 - * are set at run time. All have 64k limits.
17197 - */
17198 - /* 32-bit code */
17199 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17200 - /* 16-bit code */
17201 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17202 - /* data */
17203 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17204 -
17205 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17206 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17207 - GDT_STACK_CANARY_INIT
17208 -#endif
17209 -} };
17210 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17211 -
17212 static int __init x86_xsave_setup(char *s)
17213 {
17214 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17215 @@ -386,7 +332,7 @@ void switch_to_new_gdt(int cpu)
17216 {
17217 struct desc_ptr gdt_descr;
17218
17219 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17220 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17221 gdt_descr.size = GDT_SIZE - 1;
17222 load_gdt(&gdt_descr);
17223 /* Reload the per-cpu base */
17224 @@ -882,6 +828,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17225 /* Filter out anything that depends on CPUID levels we don't have */
17226 filter_cpuid_features(c, true);
17227
17228 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17229 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17230 +#endif
17231 +
17232 /* If the model name is still unset, do table lookup. */
17233 if (!c->x86_model_id[0]) {
17234 const char *p;
17235 @@ -1065,10 +1015,12 @@ static __init int setup_disablecpuid(char *arg)
17236 }
17237 __setup("clearcpuid=", setup_disablecpuid);
17238
17239 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17240 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17241 +
17242 #ifdef CONFIG_X86_64
17243 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17244 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17245 - (unsigned long) nmi_idt_table };
17246 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17247
17248 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17249 irq_stack_union) __aligned(PAGE_SIZE);
17250 @@ -1082,7 +1034,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17251 EXPORT_PER_CPU_SYMBOL(current_task);
17252
17253 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17254 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17255 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17256 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17257
17258 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17259 @@ -1227,7 +1179,7 @@ void __cpuinit cpu_init(void)
17260 load_ucode_ap();
17261
17262 cpu = stack_smp_processor_id();
17263 - t = &per_cpu(init_tss, cpu);
17264 + t = init_tss + cpu;
17265 oist = &per_cpu(orig_ist, cpu);
17266
17267 #ifdef CONFIG_NUMA
17268 @@ -1253,7 +1205,7 @@ void __cpuinit cpu_init(void)
17269 switch_to_new_gdt(cpu);
17270 loadsegment(fs, 0);
17271
17272 - load_idt((const struct desc_ptr *)&idt_descr);
17273 + load_idt(&idt_descr);
17274
17275 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17276 syscall_init();
17277 @@ -1262,7 +1214,6 @@ void __cpuinit cpu_init(void)
17278 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17279 barrier();
17280
17281 - x86_configure_nx();
17282 enable_x2apic();
17283
17284 /*
17285 @@ -1314,7 +1265,7 @@ void __cpuinit cpu_init(void)
17286 {
17287 int cpu = smp_processor_id();
17288 struct task_struct *curr = current;
17289 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17290 + struct tss_struct *t = init_tss + cpu;
17291 struct thread_struct *thread = &curr->thread;
17292
17293 show_ucode_info_early();
17294 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
17295 index 1905ce9..a7ac587 100644
17296 --- a/arch/x86/kernel/cpu/intel.c
17297 +++ b/arch/x86/kernel/cpu/intel.c
17298 @@ -173,7 +173,7 @@ static void __cpuinit trap_init_f00f_bug(void)
17299 * Update the IDT descriptor and reload the IDT so that
17300 * it uses the read-only mapped virtual address.
17301 */
17302 - idt_descr.address = fix_to_virt(FIX_F00F_IDT);
17303 + idt_descr.address = (struct desc_struct *)fix_to_virt(FIX_F00F_IDT);
17304 load_idt(&idt_descr);
17305 }
17306 #endif
17307 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17308 index 7c6f7d5..8cac382 100644
17309 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17310 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17311 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17312 };
17313
17314 #ifdef CONFIG_AMD_NB
17315 +static struct attribute *default_attrs_amd_nb[] = {
17316 + &type.attr,
17317 + &level.attr,
17318 + &coherency_line_size.attr,
17319 + &physical_line_partition.attr,
17320 + &ways_of_associativity.attr,
17321 + &number_of_sets.attr,
17322 + &size.attr,
17323 + &shared_cpu_map.attr,
17324 + &shared_cpu_list.attr,
17325 + NULL,
17326 + NULL,
17327 + NULL,
17328 + NULL
17329 +};
17330 +
17331 static struct attribute ** __cpuinit amd_l3_attrs(void)
17332 {
17333 static struct attribute **attrs;
17334 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17335
17336 n = ARRAY_SIZE(default_attrs);
17337
17338 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17339 - n += 2;
17340 -
17341 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17342 - n += 1;
17343 -
17344 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17345 - if (attrs == NULL)
17346 - return attrs = default_attrs;
17347 -
17348 - for (n = 0; default_attrs[n]; n++)
17349 - attrs[n] = default_attrs[n];
17350 + attrs = default_attrs_amd_nb;
17351
17352 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17353 attrs[n++] = &cache_disable_0.attr;
17354 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17355 .default_attrs = default_attrs,
17356 };
17357
17358 +#ifdef CONFIG_AMD_NB
17359 +static struct kobj_type ktype_cache_amd_nb = {
17360 + .sysfs_ops = &sysfs_ops,
17361 + .default_attrs = default_attrs_amd_nb,
17362 +};
17363 +#endif
17364 +
17365 static struct kobj_type ktype_percpu_entry = {
17366 .sysfs_ops = &sysfs_ops,
17367 };
17368 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17369 return retval;
17370 }
17371
17372 +#ifdef CONFIG_AMD_NB
17373 + amd_l3_attrs();
17374 +#endif
17375 +
17376 for (i = 0; i < num_cache_leaves; i++) {
17377 + struct kobj_type *ktype;
17378 +
17379 this_object = INDEX_KOBJECT_PTR(cpu, i);
17380 this_object->cpu = cpu;
17381 this_object->index = i;
17382
17383 this_leaf = CPUID4_INFO_IDX(cpu, i);
17384
17385 - ktype_cache.default_attrs = default_attrs;
17386 + ktype = &ktype_cache;
17387 #ifdef CONFIG_AMD_NB
17388 if (this_leaf->base.nb)
17389 - ktype_cache.default_attrs = amd_l3_attrs();
17390 + ktype = &ktype_cache_amd_nb;
17391 #endif
17392 retval = kobject_init_and_add(&(this_object->kobj),
17393 - &ktype_cache,
17394 + ktype,
17395 per_cpu(ici_cache_kobject, cpu),
17396 "index%1lu", i);
17397 if (unlikely(retval)) {
17398 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17399 return NOTIFY_OK;
17400 }
17401
17402 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17403 +static struct notifier_block cacheinfo_cpu_notifier = {
17404 .notifier_call = cacheinfo_cpu_callback,
17405 };
17406
17407 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17408 index 7bc1263..ce2cbfb 100644
17409 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17410 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17411 @@ -45,6 +45,7 @@
17412 #include <asm/processor.h>
17413 #include <asm/mce.h>
17414 #include <asm/msr.h>
17415 +#include <asm/local.h>
17416
17417 #include "mce-internal.h"
17418
17419 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17420 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17421 m->cs, m->ip);
17422
17423 - if (m->cs == __KERNEL_CS)
17424 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17425 print_symbol("{%s}", m->ip);
17426 pr_cont("\n");
17427 }
17428 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17429
17430 #define PANIC_TIMEOUT 5 /* 5 seconds */
17431
17432 -static atomic_t mce_paniced;
17433 +static atomic_unchecked_t mce_paniced;
17434
17435 static int fake_panic;
17436 -static atomic_t mce_fake_paniced;
17437 +static atomic_unchecked_t mce_fake_paniced;
17438
17439 /* Panic in progress. Enable interrupts and wait for final IPI */
17440 static void wait_for_panic(void)
17441 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17442 /*
17443 * Make sure only one CPU runs in machine check panic
17444 */
17445 - if (atomic_inc_return(&mce_paniced) > 1)
17446 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17447 wait_for_panic();
17448 barrier();
17449
17450 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17451 console_verbose();
17452 } else {
17453 /* Don't log too much for fake panic */
17454 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17455 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17456 return;
17457 }
17458 /* First print corrected ones that are still unlogged */
17459 @@ -683,7 +684,7 @@ static int mce_timed_out(u64 *t)
17460 * might have been modified by someone else.
17461 */
17462 rmb();
17463 - if (atomic_read(&mce_paniced))
17464 + if (atomic_read_unchecked(&mce_paniced))
17465 wait_for_panic();
17466 if (!mca_cfg.monarch_timeout)
17467 goto out;
17468 @@ -1654,7 +1655,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17469 }
17470
17471 /* Call the installed machine check handler for this CPU setup. */
17472 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17473 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17474 unexpected_machine_check;
17475
17476 /*
17477 @@ -1677,7 +1678,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17478 return;
17479 }
17480
17481 + pax_open_kernel();
17482 machine_check_vector = do_machine_check;
17483 + pax_close_kernel();
17484
17485 __mcheck_cpu_init_generic();
17486 __mcheck_cpu_init_vendor(c);
17487 @@ -1691,7 +1694,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17488 */
17489
17490 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17491 -static int mce_chrdev_open_count; /* #times opened */
17492 +static local_t mce_chrdev_open_count; /* #times opened */
17493 static int mce_chrdev_open_exclu; /* already open exclusive? */
17494
17495 static int mce_chrdev_open(struct inode *inode, struct file *file)
17496 @@ -1699,7 +1702,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17497 spin_lock(&mce_chrdev_state_lock);
17498
17499 if (mce_chrdev_open_exclu ||
17500 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17501 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17502 spin_unlock(&mce_chrdev_state_lock);
17503
17504 return -EBUSY;
17505 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17506
17507 if (file->f_flags & O_EXCL)
17508 mce_chrdev_open_exclu = 1;
17509 - mce_chrdev_open_count++;
17510 + local_inc(&mce_chrdev_open_count);
17511
17512 spin_unlock(&mce_chrdev_state_lock);
17513
17514 @@ -1718,7 +1721,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17515 {
17516 spin_lock(&mce_chrdev_state_lock);
17517
17518 - mce_chrdev_open_count--;
17519 + local_dec(&mce_chrdev_open_count);
17520 mce_chrdev_open_exclu = 0;
17521
17522 spin_unlock(&mce_chrdev_state_lock);
17523 @@ -2364,7 +2367,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17524 return NOTIFY_OK;
17525 }
17526
17527 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17528 +static struct notifier_block mce_cpu_notifier = {
17529 .notifier_call = mce_cpu_callback,
17530 };
17531
17532 @@ -2374,7 +2377,7 @@ static __init void mce_init_banks(void)
17533
17534 for (i = 0; i < mca_cfg.banks; i++) {
17535 struct mce_bank *b = &mce_banks[i];
17536 - struct device_attribute *a = &b->attr;
17537 + device_attribute_no_const *a = &b->attr;
17538
17539 sysfs_attr_init(&a->attr);
17540 a->attr.name = b->attrname;
17541 @@ -2442,7 +2445,7 @@ struct dentry *mce_get_debugfs_dir(void)
17542 static void mce_reset(void)
17543 {
17544 cpu_missing = 0;
17545 - atomic_set(&mce_fake_paniced, 0);
17546 + atomic_set_unchecked(&mce_fake_paniced, 0);
17547 atomic_set(&mce_executing, 0);
17548 atomic_set(&mce_callin, 0);
17549 atomic_set(&global_nwo, 0);
17550 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17551 index 1c044b1..37a2a43 100644
17552 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17553 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17554 @@ -11,6 +11,7 @@
17555 #include <asm/processor.h>
17556 #include <asm/mce.h>
17557 #include <asm/msr.h>
17558 +#include <asm/pgtable.h>
17559
17560 /* By default disabled */
17561 int mce_p5_enabled __read_mostly;
17562 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17563 if (!cpu_has(c, X86_FEATURE_MCE))
17564 return;
17565
17566 + pax_open_kernel();
17567 machine_check_vector = pentium_machine_check;
17568 + pax_close_kernel();
17569 /* Make sure the vector pointer is visible before we enable MCEs: */
17570 wmb();
17571
17572 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17573 index 47a1870..8c019a7 100644
17574 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17575 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17576 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17577 return notifier_from_errno(err);
17578 }
17579
17580 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17581 +static struct notifier_block thermal_throttle_cpu_notifier =
17582 {
17583 .notifier_call = thermal_throttle_cpu_callback,
17584 };
17585 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17586 index e9a701a..35317d6 100644
17587 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17588 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17589 @@ -10,6 +10,7 @@
17590 #include <asm/processor.h>
17591 #include <asm/mce.h>
17592 #include <asm/msr.h>
17593 +#include <asm/pgtable.h>
17594
17595 /* Machine check handler for WinChip C6: */
17596 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17597 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17598 {
17599 u32 lo, hi;
17600
17601 + pax_open_kernel();
17602 machine_check_vector = winchip_machine_check;
17603 + pax_close_kernel();
17604 /* Make sure the vector pointer is visible before we enable MCEs: */
17605 wmb();
17606
17607 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17608 index 726bf96..81f0526 100644
17609 --- a/arch/x86/kernel/cpu/mtrr/main.c
17610 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17611 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17612 u64 size_or_mask, size_and_mask;
17613 static bool mtrr_aps_delayed_init;
17614
17615 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17616 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17617
17618 const struct mtrr_ops *mtrr_if;
17619
17620 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17621 index df5e41f..816c719 100644
17622 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17623 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17624 @@ -25,7 +25,7 @@ struct mtrr_ops {
17625 int (*validate_add_page)(unsigned long base, unsigned long size,
17626 unsigned int type);
17627 int (*have_wrcomb)(void);
17628 -};
17629 +} __do_const;
17630
17631 extern int generic_get_free_region(unsigned long base, unsigned long size,
17632 int replace_reg);
17633 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17634 index bf0f01a..9adfee1 100644
17635 --- a/arch/x86/kernel/cpu/perf_event.c
17636 +++ b/arch/x86/kernel/cpu/perf_event.c
17637 @@ -1305,7 +1305,7 @@ static void __init pmu_check_apic(void)
17638 pr_info("no hardware sampling interrupt available.\n");
17639 }
17640
17641 -static struct attribute_group x86_pmu_format_group = {
17642 +static attribute_group_no_const x86_pmu_format_group = {
17643 .name = "format",
17644 .attrs = NULL,
17645 };
17646 @@ -1374,7 +1374,7 @@ static struct attribute *events_attr[] = {
17647 NULL,
17648 };
17649
17650 -static struct attribute_group x86_pmu_events_group = {
17651 +static attribute_group_no_const x86_pmu_events_group = {
17652 .name = "events",
17653 .attrs = events_attr,
17654 };
17655 @@ -1873,7 +1873,7 @@ static unsigned long get_segment_base(unsigned int segment)
17656 if (idx > GDT_ENTRIES)
17657 return 0;
17658
17659 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
17660 + desc = get_cpu_gdt_table(smp_processor_id());
17661 }
17662
17663 return get_desc_base(desc + idx);
17664 @@ -1963,7 +1963,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
17665 break;
17666
17667 perf_callchain_store(entry, frame.return_address);
17668 - fp = frame.next_frame;
17669 + fp = (const void __force_user *)frame.next_frame;
17670 }
17671 }
17672
17673 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
17674 index 4a0a462..be3b204 100644
17675 --- a/arch/x86/kernel/cpu/perf_event_intel.c
17676 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
17677 @@ -1994,10 +1994,10 @@ __init int intel_pmu_init(void)
17678 * v2 and above have a perf capabilities MSR
17679 */
17680 if (version > 1) {
17681 - u64 capabilities;
17682 + u64 capabilities = x86_pmu.intel_cap.capabilities;
17683
17684 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
17685 - x86_pmu.intel_cap.capabilities = capabilities;
17686 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
17687 + x86_pmu.intel_cap.capabilities = capabilities;
17688 }
17689
17690 intel_ds_init();
17691 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17692 index 3e091f0..d2dc8d6 100644
17693 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17694 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17695 @@ -2428,7 +2428,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
17696 static int __init uncore_type_init(struct intel_uncore_type *type)
17697 {
17698 struct intel_uncore_pmu *pmus;
17699 - struct attribute_group *attr_group;
17700 + attribute_group_no_const *attr_group;
17701 struct attribute **attrs;
17702 int i, j;
17703
17704 @@ -2826,7 +2826,7 @@ static int
17705 return NOTIFY_OK;
17706 }
17707
17708 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
17709 +static struct notifier_block uncore_cpu_nb = {
17710 .notifier_call = uncore_cpu_notifier,
17711 /*
17712 * to migrate uncore events, our notifier should be executed
17713 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17714 index e68a455..975a932 100644
17715 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17716 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17717 @@ -428,7 +428,7 @@ struct intel_uncore_box {
17718 struct uncore_event_desc {
17719 struct kobj_attribute attr;
17720 const char *config;
17721 -};
17722 +} __do_const;
17723
17724 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
17725 { \
17726 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
17727 index 1e4dbcf..b9a34c2 100644
17728 --- a/arch/x86/kernel/cpuid.c
17729 +++ b/arch/x86/kernel/cpuid.c
17730 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
17731 return notifier_from_errno(err);
17732 }
17733
17734 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
17735 +static struct notifier_block cpuid_class_cpu_notifier =
17736 {
17737 .notifier_call = cpuid_class_cpu_callback,
17738 };
17739 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
17740 index 74467fe..18793d5 100644
17741 --- a/arch/x86/kernel/crash.c
17742 +++ b/arch/x86/kernel/crash.c
17743 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
17744 {
17745 #ifdef CONFIG_X86_32
17746 struct pt_regs fixed_regs;
17747 -#endif
17748
17749 -#ifdef CONFIG_X86_32
17750 - if (!user_mode_vm(regs)) {
17751 + if (!user_mode(regs)) {
17752 crash_fixup_ss_esp(&fixed_regs, regs);
17753 regs = &fixed_regs;
17754 }
17755 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
17756 index afa64ad..dce67dd 100644
17757 --- a/arch/x86/kernel/crash_dump_64.c
17758 +++ b/arch/x86/kernel/crash_dump_64.c
17759 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
17760 return -ENOMEM;
17761
17762 if (userbuf) {
17763 - if (copy_to_user(buf, vaddr + offset, csize)) {
17764 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
17765 iounmap(vaddr);
17766 return -EFAULT;
17767 }
17768 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
17769 index 37250fe..bf2ec74 100644
17770 --- a/arch/x86/kernel/doublefault_32.c
17771 +++ b/arch/x86/kernel/doublefault_32.c
17772 @@ -11,7 +11,7 @@
17773
17774 #define DOUBLEFAULT_STACKSIZE (1024)
17775 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
17776 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
17777 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
17778
17779 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
17780
17781 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
17782 unsigned long gdt, tss;
17783
17784 store_gdt(&gdt_desc);
17785 - gdt = gdt_desc.address;
17786 + gdt = (unsigned long)gdt_desc.address;
17787
17788 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
17789
17790 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
17791 /* 0x2 bit is always set */
17792 .flags = X86_EFLAGS_SF | 0x2,
17793 .sp = STACK_START,
17794 - .es = __USER_DS,
17795 + .es = __KERNEL_DS,
17796 .cs = __KERNEL_CS,
17797 .ss = __KERNEL_DS,
17798 - .ds = __USER_DS,
17799 + .ds = __KERNEL_DS,
17800 .fs = __KERNEL_PERCPU,
17801
17802 .__cr3 = __pa_nodebug(swapper_pg_dir),
17803 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
17804 index c8797d5..c605e53 100644
17805 --- a/arch/x86/kernel/dumpstack.c
17806 +++ b/arch/x86/kernel/dumpstack.c
17807 @@ -2,6 +2,9 @@
17808 * Copyright (C) 1991, 1992 Linus Torvalds
17809 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
17810 */
17811 +#ifdef CONFIG_GRKERNSEC_HIDESYM
17812 +#define __INCLUDED_BY_HIDESYM 1
17813 +#endif
17814 #include <linux/kallsyms.h>
17815 #include <linux/kprobes.h>
17816 #include <linux/uaccess.h>
17817 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
17818 static void
17819 print_ftrace_graph_addr(unsigned long addr, void *data,
17820 const struct stacktrace_ops *ops,
17821 - struct thread_info *tinfo, int *graph)
17822 + struct task_struct *task, int *graph)
17823 {
17824 - struct task_struct *task;
17825 unsigned long ret_addr;
17826 int index;
17827
17828 if (addr != (unsigned long)return_to_handler)
17829 return;
17830
17831 - task = tinfo->task;
17832 index = task->curr_ret_stack;
17833
17834 if (!task->ret_stack || index < *graph)
17835 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17836 static inline void
17837 print_ftrace_graph_addr(unsigned long addr, void *data,
17838 const struct stacktrace_ops *ops,
17839 - struct thread_info *tinfo, int *graph)
17840 + struct task_struct *task, int *graph)
17841 { }
17842 #endif
17843
17844 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17845 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
17846 */
17847
17848 -static inline int valid_stack_ptr(struct thread_info *tinfo,
17849 - void *p, unsigned int size, void *end)
17850 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
17851 {
17852 - void *t = tinfo;
17853 if (end) {
17854 if (p < end && p >= (end-THREAD_SIZE))
17855 return 1;
17856 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
17857 }
17858
17859 unsigned long
17860 -print_context_stack(struct thread_info *tinfo,
17861 +print_context_stack(struct task_struct *task, void *stack_start,
17862 unsigned long *stack, unsigned long bp,
17863 const struct stacktrace_ops *ops, void *data,
17864 unsigned long *end, int *graph)
17865 {
17866 struct stack_frame *frame = (struct stack_frame *)bp;
17867
17868 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
17869 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
17870 unsigned long addr;
17871
17872 addr = *stack;
17873 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
17874 } else {
17875 ops->address(data, addr, 0);
17876 }
17877 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17878 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17879 }
17880 stack++;
17881 }
17882 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
17883 EXPORT_SYMBOL_GPL(print_context_stack);
17884
17885 unsigned long
17886 -print_context_stack_bp(struct thread_info *tinfo,
17887 +print_context_stack_bp(struct task_struct *task, void *stack_start,
17888 unsigned long *stack, unsigned long bp,
17889 const struct stacktrace_ops *ops, void *data,
17890 unsigned long *end, int *graph)
17891 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17892 struct stack_frame *frame = (struct stack_frame *)bp;
17893 unsigned long *ret_addr = &frame->return_address;
17894
17895 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
17896 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
17897 unsigned long addr = *ret_addr;
17898
17899 if (!__kernel_text_address(addr))
17900 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17901 ops->address(data, addr, 1);
17902 frame = frame->next_frame;
17903 ret_addr = &frame->return_address;
17904 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17905 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17906 }
17907
17908 return (unsigned long)frame;
17909 @@ -189,7 +188,7 @@ void dump_stack(void)
17910
17911 bp = stack_frame(current, NULL);
17912 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
17913 - current->pid, current->comm, print_tainted(),
17914 + task_pid_nr(current), current->comm, print_tainted(),
17915 init_utsname()->release,
17916 (int)strcspn(init_utsname()->version, " "),
17917 init_utsname()->version);
17918 @@ -225,6 +224,8 @@ unsigned __kprobes long oops_begin(void)
17919 }
17920 EXPORT_SYMBOL_GPL(oops_begin);
17921
17922 +extern void gr_handle_kernel_exploit(void);
17923 +
17924 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17925 {
17926 if (regs && kexec_should_crash(current))
17927 @@ -246,7 +247,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17928 panic("Fatal exception in interrupt");
17929 if (panic_on_oops)
17930 panic("Fatal exception");
17931 - do_exit(signr);
17932 +
17933 + gr_handle_kernel_exploit();
17934 +
17935 + do_group_exit(signr);
17936 }
17937
17938 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17939 @@ -274,7 +278,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17940 print_modules();
17941 show_regs(regs);
17942 #ifdef CONFIG_X86_32
17943 - if (user_mode_vm(regs)) {
17944 + if (user_mode(regs)) {
17945 sp = regs->sp;
17946 ss = regs->ss & 0xffff;
17947 } else {
17948 @@ -302,7 +306,7 @@ void die(const char *str, struct pt_regs *regs, long err)
17949 unsigned long flags = oops_begin();
17950 int sig = SIGSEGV;
17951
17952 - if (!user_mode_vm(regs))
17953 + if (!user_mode(regs))
17954 report_bug(regs->ip, regs);
17955
17956 if (__die(str, regs, err))
17957 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
17958 index 1038a41..db2c12b 100644
17959 --- a/arch/x86/kernel/dumpstack_32.c
17960 +++ b/arch/x86/kernel/dumpstack_32.c
17961 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17962 bp = stack_frame(task, regs);
17963
17964 for (;;) {
17965 - struct thread_info *context;
17966 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
17967
17968 - context = (struct thread_info *)
17969 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
17970 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
17971 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
17972
17973 - stack = (unsigned long *)context->previous_esp;
17974 - if (!stack)
17975 + if (stack_start == task_stack_page(task))
17976 break;
17977 + stack = *(unsigned long **)stack_start;
17978 if (ops->stack(data, "IRQ") < 0)
17979 break;
17980 touch_nmi_watchdog();
17981 @@ -86,7 +84,7 @@ void show_regs(struct pt_regs *regs)
17982 {
17983 int i;
17984
17985 - __show_regs(regs, !user_mode_vm(regs));
17986 + __show_regs(regs, !user_mode(regs));
17987
17988 pr_emerg("Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
17989 TASK_COMM_LEN, current->comm, task_pid_nr(current),
17990 @@ -95,21 +93,22 @@ void show_regs(struct pt_regs *regs)
17991 * When in-kernel, we also print out the stack and code at the
17992 * time of the fault..
17993 */
17994 - if (!user_mode_vm(regs)) {
17995 + if (!user_mode(regs)) {
17996 unsigned int code_prologue = code_bytes * 43 / 64;
17997 unsigned int code_len = code_bytes;
17998 unsigned char c;
17999 u8 *ip;
18000 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
18001
18002 pr_emerg("Stack:\n");
18003 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
18004
18005 pr_emerg("Code:");
18006
18007 - ip = (u8 *)regs->ip - code_prologue;
18008 + ip = (u8 *)regs->ip - code_prologue + cs_base;
18009 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
18010 /* try starting at IP */
18011 - ip = (u8 *)regs->ip;
18012 + ip = (u8 *)regs->ip + cs_base;
18013 code_len = code_len - code_prologue + 1;
18014 }
18015 for (i = 0; i < code_len; i++, ip++) {
18016 @@ -118,7 +117,7 @@ void show_regs(struct pt_regs *regs)
18017 pr_cont(" Bad EIP value.");
18018 break;
18019 }
18020 - if (ip == (u8 *)regs->ip)
18021 + if (ip == (u8 *)regs->ip + cs_base)
18022 pr_cont(" <%02x>", c);
18023 else
18024 pr_cont(" %02x", c);
18025 @@ -131,6 +130,7 @@ int is_valid_bugaddr(unsigned long ip)
18026 {
18027 unsigned short ud2;
18028
18029 + ip = ktla_ktva(ip);
18030 if (ip < PAGE_OFFSET)
18031 return 0;
18032 if (probe_kernel_address((unsigned short *)ip, ud2))
18033 @@ -138,3 +138,15 @@ int is_valid_bugaddr(unsigned long ip)
18034
18035 return ud2 == 0x0b0f;
18036 }
18037 +
18038 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18039 +void pax_check_alloca(unsigned long size)
18040 +{
18041 + unsigned long sp = (unsigned long)&sp, stack_left;
18042 +
18043 + /* all kernel stacks are of the same size */
18044 + stack_left = sp & (THREAD_SIZE - 1);
18045 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18046 +}
18047 +EXPORT_SYMBOL(pax_check_alloca);
18048 +#endif
18049 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
18050 index b653675..51cc8c0 100644
18051 --- a/arch/x86/kernel/dumpstack_64.c
18052 +++ b/arch/x86/kernel/dumpstack_64.c
18053 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18054 unsigned long *irq_stack_end =
18055 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
18056 unsigned used = 0;
18057 - struct thread_info *tinfo;
18058 int graph = 0;
18059 unsigned long dummy;
18060 + void *stack_start;
18061
18062 if (!task)
18063 task = current;
18064 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18065 * current stack address. If the stacks consist of nested
18066 * exceptions
18067 */
18068 - tinfo = task_thread_info(task);
18069 for (;;) {
18070 char *id;
18071 unsigned long *estack_end;
18072 +
18073 estack_end = in_exception_stack(cpu, (unsigned long)stack,
18074 &used, &id);
18075
18076 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18077 if (ops->stack(data, id) < 0)
18078 break;
18079
18080 - bp = ops->walk_stack(tinfo, stack, bp, ops,
18081 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
18082 data, estack_end, &graph);
18083 ops->stack(data, "<EOE>");
18084 /*
18085 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18086 * second-to-last pointer (index -2 to end) in the
18087 * exception stack:
18088 */
18089 + if ((u16)estack_end[-1] != __KERNEL_DS)
18090 + goto out;
18091 stack = (unsigned long *) estack_end[-2];
18092 continue;
18093 }
18094 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18095 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18096 if (ops->stack(data, "IRQ") < 0)
18097 break;
18098 - bp = ops->walk_stack(tinfo, stack, bp,
18099 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18100 ops, data, irq_stack_end, &graph);
18101 /*
18102 * We link to the next stack (which would be
18103 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18104 /*
18105 * This handles the process stack:
18106 */
18107 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18108 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18109 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18110 +out:
18111 put_cpu();
18112 }
18113 EXPORT_SYMBOL(dump_trace);
18114 @@ -249,7 +253,7 @@ void show_regs(struct pt_regs *regs)
18115 {
18116 int i;
18117 unsigned long sp;
18118 - const int cpu = smp_processor_id();
18119 + const int cpu = raw_smp_processor_id();
18120 struct task_struct *cur = current;
18121
18122 sp = regs->sp;
18123 @@ -304,3 +308,50 @@ int is_valid_bugaddr(unsigned long ip)
18124
18125 return ud2 == 0x0b0f;
18126 }
18127 +
18128 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18129 +void pax_check_alloca(unsigned long size)
18130 +{
18131 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18132 + unsigned cpu, used;
18133 + char *id;
18134 +
18135 + /* check the process stack first */
18136 + stack_start = (unsigned long)task_stack_page(current);
18137 + stack_end = stack_start + THREAD_SIZE;
18138 + if (likely(stack_start <= sp && sp < stack_end)) {
18139 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18140 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18141 + return;
18142 + }
18143 +
18144 + cpu = get_cpu();
18145 +
18146 + /* check the irq stacks */
18147 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18148 + stack_start = stack_end - IRQ_STACK_SIZE;
18149 + if (stack_start <= sp && sp < stack_end) {
18150 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18151 + put_cpu();
18152 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18153 + return;
18154 + }
18155 +
18156 + /* check the exception stacks */
18157 + used = 0;
18158 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18159 + stack_start = stack_end - EXCEPTION_STKSZ;
18160 + if (stack_end && stack_start <= sp && sp < stack_end) {
18161 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18162 + put_cpu();
18163 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18164 + return;
18165 + }
18166 +
18167 + put_cpu();
18168 +
18169 + /* unknown stack */
18170 + BUG();
18171 +}
18172 +EXPORT_SYMBOL(pax_check_alloca);
18173 +#endif
18174 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18175 index 9b9f18b..9fcaa04 100644
18176 --- a/arch/x86/kernel/early_printk.c
18177 +++ b/arch/x86/kernel/early_printk.c
18178 @@ -7,6 +7,7 @@
18179 #include <linux/pci_regs.h>
18180 #include <linux/pci_ids.h>
18181 #include <linux/errno.h>
18182 +#include <linux/sched.h>
18183 #include <asm/io.h>
18184 #include <asm/processor.h>
18185 #include <asm/fcntl.h>
18186 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18187 index 8f3e2de..934870f 100644
18188 --- a/arch/x86/kernel/entry_32.S
18189 +++ b/arch/x86/kernel/entry_32.S
18190 @@ -177,13 +177,153 @@
18191 /*CFI_REL_OFFSET gs, PT_GS*/
18192 .endm
18193 .macro SET_KERNEL_GS reg
18194 +
18195 +#ifdef CONFIG_CC_STACKPROTECTOR
18196 movl $(__KERNEL_STACK_CANARY), \reg
18197 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18198 + movl $(__USER_DS), \reg
18199 +#else
18200 + xorl \reg, \reg
18201 +#endif
18202 +
18203 movl \reg, %gs
18204 .endm
18205
18206 #endif /* CONFIG_X86_32_LAZY_GS */
18207
18208 -.macro SAVE_ALL
18209 +.macro pax_enter_kernel
18210 +#ifdef CONFIG_PAX_KERNEXEC
18211 + call pax_enter_kernel
18212 +#endif
18213 +.endm
18214 +
18215 +.macro pax_exit_kernel
18216 +#ifdef CONFIG_PAX_KERNEXEC
18217 + call pax_exit_kernel
18218 +#endif
18219 +.endm
18220 +
18221 +#ifdef CONFIG_PAX_KERNEXEC
18222 +ENTRY(pax_enter_kernel)
18223 +#ifdef CONFIG_PARAVIRT
18224 + pushl %eax
18225 + pushl %ecx
18226 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18227 + mov %eax, %esi
18228 +#else
18229 + mov %cr0, %esi
18230 +#endif
18231 + bts $16, %esi
18232 + jnc 1f
18233 + mov %cs, %esi
18234 + cmp $__KERNEL_CS, %esi
18235 + jz 3f
18236 + ljmp $__KERNEL_CS, $3f
18237 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18238 +2:
18239 +#ifdef CONFIG_PARAVIRT
18240 + mov %esi, %eax
18241 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18242 +#else
18243 + mov %esi, %cr0
18244 +#endif
18245 +3:
18246 +#ifdef CONFIG_PARAVIRT
18247 + popl %ecx
18248 + popl %eax
18249 +#endif
18250 + ret
18251 +ENDPROC(pax_enter_kernel)
18252 +
18253 +ENTRY(pax_exit_kernel)
18254 +#ifdef CONFIG_PARAVIRT
18255 + pushl %eax
18256 + pushl %ecx
18257 +#endif
18258 + mov %cs, %esi
18259 + cmp $__KERNEXEC_KERNEL_CS, %esi
18260 + jnz 2f
18261 +#ifdef CONFIG_PARAVIRT
18262 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18263 + mov %eax, %esi
18264 +#else
18265 + mov %cr0, %esi
18266 +#endif
18267 + btr $16, %esi
18268 + ljmp $__KERNEL_CS, $1f
18269 +1:
18270 +#ifdef CONFIG_PARAVIRT
18271 + mov %esi, %eax
18272 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18273 +#else
18274 + mov %esi, %cr0
18275 +#endif
18276 +2:
18277 +#ifdef CONFIG_PARAVIRT
18278 + popl %ecx
18279 + popl %eax
18280 +#endif
18281 + ret
18282 +ENDPROC(pax_exit_kernel)
18283 +#endif
18284 +
18285 +.macro pax_erase_kstack
18286 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18287 + call pax_erase_kstack
18288 +#endif
18289 +.endm
18290 +
18291 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18292 +/*
18293 + * ebp: thread_info
18294 + */
18295 +ENTRY(pax_erase_kstack)
18296 + pushl %edi
18297 + pushl %ecx
18298 + pushl %eax
18299 +
18300 + mov TI_lowest_stack(%ebp), %edi
18301 + mov $-0xBEEF, %eax
18302 + std
18303 +
18304 +1: mov %edi, %ecx
18305 + and $THREAD_SIZE_asm - 1, %ecx
18306 + shr $2, %ecx
18307 + repne scasl
18308 + jecxz 2f
18309 +
18310 + cmp $2*16, %ecx
18311 + jc 2f
18312 +
18313 + mov $2*16, %ecx
18314 + repe scasl
18315 + jecxz 2f
18316 + jne 1b
18317 +
18318 +2: cld
18319 + mov %esp, %ecx
18320 + sub %edi, %ecx
18321 +
18322 + cmp $THREAD_SIZE_asm, %ecx
18323 + jb 3f
18324 + ud2
18325 +3:
18326 +
18327 + shr $2, %ecx
18328 + rep stosl
18329 +
18330 + mov TI_task_thread_sp0(%ebp), %edi
18331 + sub $128, %edi
18332 + mov %edi, TI_lowest_stack(%ebp)
18333 +
18334 + popl %eax
18335 + popl %ecx
18336 + popl %edi
18337 + ret
18338 +ENDPROC(pax_erase_kstack)
18339 +#endif
18340 +
18341 +.macro __SAVE_ALL _DS
18342 cld
18343 PUSH_GS
18344 pushl_cfi %fs
18345 @@ -206,7 +346,7 @@
18346 CFI_REL_OFFSET ecx, 0
18347 pushl_cfi %ebx
18348 CFI_REL_OFFSET ebx, 0
18349 - movl $(__USER_DS), %edx
18350 + movl $\_DS, %edx
18351 movl %edx, %ds
18352 movl %edx, %es
18353 movl $(__KERNEL_PERCPU), %edx
18354 @@ -214,6 +354,15 @@
18355 SET_KERNEL_GS %edx
18356 .endm
18357
18358 +.macro SAVE_ALL
18359 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18360 + __SAVE_ALL __KERNEL_DS
18361 + pax_enter_kernel
18362 +#else
18363 + __SAVE_ALL __USER_DS
18364 +#endif
18365 +.endm
18366 +
18367 .macro RESTORE_INT_REGS
18368 popl_cfi %ebx
18369 CFI_RESTORE ebx
18370 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18371 popfl_cfi
18372 jmp syscall_exit
18373 CFI_ENDPROC
18374 -END(ret_from_fork)
18375 +ENDPROC(ret_from_fork)
18376
18377 ENTRY(ret_from_kernel_thread)
18378 CFI_STARTPROC
18379 @@ -344,7 +493,15 @@ ret_from_intr:
18380 andl $SEGMENT_RPL_MASK, %eax
18381 #endif
18382 cmpl $USER_RPL, %eax
18383 +
18384 +#ifdef CONFIG_PAX_KERNEXEC
18385 + jae resume_userspace
18386 +
18387 + pax_exit_kernel
18388 + jmp resume_kernel
18389 +#else
18390 jb resume_kernel # not returning to v8086 or userspace
18391 +#endif
18392
18393 ENTRY(resume_userspace)
18394 LOCKDEP_SYS_EXIT
18395 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18396 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18397 # int/exception return?
18398 jne work_pending
18399 - jmp restore_all
18400 -END(ret_from_exception)
18401 + jmp restore_all_pax
18402 +ENDPROC(ret_from_exception)
18403
18404 #ifdef CONFIG_PREEMPT
18405 ENTRY(resume_kernel)
18406 @@ -372,7 +529,7 @@ need_resched:
18407 jz restore_all
18408 call preempt_schedule_irq
18409 jmp need_resched
18410 -END(resume_kernel)
18411 +ENDPROC(resume_kernel)
18412 #endif
18413 CFI_ENDPROC
18414 /*
18415 @@ -406,30 +563,45 @@ sysenter_past_esp:
18416 /*CFI_REL_OFFSET cs, 0*/
18417 /*
18418 * Push current_thread_info()->sysenter_return to the stack.
18419 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18420 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18421 */
18422 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18423 + pushl_cfi $0
18424 CFI_REL_OFFSET eip, 0
18425
18426 pushl_cfi %eax
18427 SAVE_ALL
18428 + GET_THREAD_INFO(%ebp)
18429 + movl TI_sysenter_return(%ebp),%ebp
18430 + movl %ebp,PT_EIP(%esp)
18431 ENABLE_INTERRUPTS(CLBR_NONE)
18432
18433 /*
18434 * Load the potential sixth argument from user stack.
18435 * Careful about security.
18436 */
18437 + movl PT_OLDESP(%esp),%ebp
18438 +
18439 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18440 + mov PT_OLDSS(%esp),%ds
18441 +1: movl %ds:(%ebp),%ebp
18442 + push %ss
18443 + pop %ds
18444 +#else
18445 cmpl $__PAGE_OFFSET-3,%ebp
18446 jae syscall_fault
18447 ASM_STAC
18448 1: movl (%ebp),%ebp
18449 ASM_CLAC
18450 +#endif
18451 +
18452 movl %ebp,PT_EBP(%esp)
18453 _ASM_EXTABLE(1b,syscall_fault)
18454
18455 GET_THREAD_INFO(%ebp)
18456
18457 +#ifdef CONFIG_PAX_RANDKSTACK
18458 + pax_erase_kstack
18459 +#endif
18460 +
18461 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18462 jnz sysenter_audit
18463 sysenter_do_call:
18464 @@ -444,12 +616,24 @@ sysenter_do_call:
18465 testl $_TIF_ALLWORK_MASK, %ecx
18466 jne sysexit_audit
18467 sysenter_exit:
18468 +
18469 +#ifdef CONFIG_PAX_RANDKSTACK
18470 + pushl_cfi %eax
18471 + movl %esp, %eax
18472 + call pax_randomize_kstack
18473 + popl_cfi %eax
18474 +#endif
18475 +
18476 + pax_erase_kstack
18477 +
18478 /* if something modifies registers it must also disable sysexit */
18479 movl PT_EIP(%esp), %edx
18480 movl PT_OLDESP(%esp), %ecx
18481 xorl %ebp,%ebp
18482 TRACE_IRQS_ON
18483 1: mov PT_FS(%esp), %fs
18484 +2: mov PT_DS(%esp), %ds
18485 +3: mov PT_ES(%esp), %es
18486 PTGS_TO_GS
18487 ENABLE_INTERRUPTS_SYSEXIT
18488
18489 @@ -466,6 +650,9 @@ sysenter_audit:
18490 movl %eax,%edx /* 2nd arg: syscall number */
18491 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18492 call __audit_syscall_entry
18493 +
18494 + pax_erase_kstack
18495 +
18496 pushl_cfi %ebx
18497 movl PT_EAX(%esp),%eax /* reload syscall number */
18498 jmp sysenter_do_call
18499 @@ -491,10 +678,16 @@ sysexit_audit:
18500
18501 CFI_ENDPROC
18502 .pushsection .fixup,"ax"
18503 -2: movl $0,PT_FS(%esp)
18504 +4: movl $0,PT_FS(%esp)
18505 + jmp 1b
18506 +5: movl $0,PT_DS(%esp)
18507 + jmp 1b
18508 +6: movl $0,PT_ES(%esp)
18509 jmp 1b
18510 .popsection
18511 - _ASM_EXTABLE(1b,2b)
18512 + _ASM_EXTABLE(1b,4b)
18513 + _ASM_EXTABLE(2b,5b)
18514 + _ASM_EXTABLE(3b,6b)
18515 PTGS_TO_GS_EX
18516 ENDPROC(ia32_sysenter_target)
18517
18518 @@ -509,6 +702,11 @@ ENTRY(system_call)
18519 pushl_cfi %eax # save orig_eax
18520 SAVE_ALL
18521 GET_THREAD_INFO(%ebp)
18522 +
18523 +#ifdef CONFIG_PAX_RANDKSTACK
18524 + pax_erase_kstack
18525 +#endif
18526 +
18527 # system call tracing in operation / emulation
18528 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18529 jnz syscall_trace_entry
18530 @@ -527,6 +725,15 @@ syscall_exit:
18531 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18532 jne syscall_exit_work
18533
18534 +restore_all_pax:
18535 +
18536 +#ifdef CONFIG_PAX_RANDKSTACK
18537 + movl %esp, %eax
18538 + call pax_randomize_kstack
18539 +#endif
18540 +
18541 + pax_erase_kstack
18542 +
18543 restore_all:
18544 TRACE_IRQS_IRET
18545 restore_all_notrace:
18546 @@ -583,14 +790,34 @@ ldt_ss:
18547 * compensating for the offset by changing to the ESPFIX segment with
18548 * a base address that matches for the difference.
18549 */
18550 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18551 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18552 mov %esp, %edx /* load kernel esp */
18553 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18554 mov %dx, %ax /* eax: new kernel esp */
18555 sub %eax, %edx /* offset (low word is 0) */
18556 +#ifdef CONFIG_SMP
18557 + movl PER_CPU_VAR(cpu_number), %ebx
18558 + shll $PAGE_SHIFT_asm, %ebx
18559 + addl $cpu_gdt_table, %ebx
18560 +#else
18561 + movl $cpu_gdt_table, %ebx
18562 +#endif
18563 shr $16, %edx
18564 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18565 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18566 +
18567 +#ifdef CONFIG_PAX_KERNEXEC
18568 + mov %cr0, %esi
18569 + btr $16, %esi
18570 + mov %esi, %cr0
18571 +#endif
18572 +
18573 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18574 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18575 +
18576 +#ifdef CONFIG_PAX_KERNEXEC
18577 + bts $16, %esi
18578 + mov %esi, %cr0
18579 +#endif
18580 +
18581 pushl_cfi $__ESPFIX_SS
18582 pushl_cfi %eax /* new kernel esp */
18583 /* Disable interrupts, but do not irqtrace this section: we
18584 @@ -619,20 +846,18 @@ work_resched:
18585 movl TI_flags(%ebp), %ecx
18586 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18587 # than syscall tracing?
18588 - jz restore_all
18589 + jz restore_all_pax
18590 testb $_TIF_NEED_RESCHED, %cl
18591 jnz work_resched
18592
18593 work_notifysig: # deal with pending signals and
18594 # notify-resume requests
18595 + movl %esp, %eax
18596 #ifdef CONFIG_VM86
18597 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18598 - movl %esp, %eax
18599 jne work_notifysig_v86 # returning to kernel-space or
18600 # vm86-space
18601 1:
18602 -#else
18603 - movl %esp, %eax
18604 #endif
18605 TRACE_IRQS_ON
18606 ENABLE_INTERRUPTS(CLBR_NONE)
18607 @@ -653,7 +878,7 @@ work_notifysig_v86:
18608 movl %eax, %esp
18609 jmp 1b
18610 #endif
18611 -END(work_pending)
18612 +ENDPROC(work_pending)
18613
18614 # perform syscall exit tracing
18615 ALIGN
18616 @@ -661,11 +886,14 @@ syscall_trace_entry:
18617 movl $-ENOSYS,PT_EAX(%esp)
18618 movl %esp, %eax
18619 call syscall_trace_enter
18620 +
18621 + pax_erase_kstack
18622 +
18623 /* What it returned is what we'll actually use. */
18624 cmpl $(NR_syscalls), %eax
18625 jnae syscall_call
18626 jmp syscall_exit
18627 -END(syscall_trace_entry)
18628 +ENDPROC(syscall_trace_entry)
18629
18630 # perform syscall exit tracing
18631 ALIGN
18632 @@ -678,21 +906,25 @@ syscall_exit_work:
18633 movl %esp, %eax
18634 call syscall_trace_leave
18635 jmp resume_userspace
18636 -END(syscall_exit_work)
18637 +ENDPROC(syscall_exit_work)
18638 CFI_ENDPROC
18639
18640 RING0_INT_FRAME # can't unwind into user space anyway
18641 syscall_fault:
18642 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18643 + push %ss
18644 + pop %ds
18645 +#endif
18646 ASM_CLAC
18647 GET_THREAD_INFO(%ebp)
18648 movl $-EFAULT,PT_EAX(%esp)
18649 jmp resume_userspace
18650 -END(syscall_fault)
18651 +ENDPROC(syscall_fault)
18652
18653 syscall_badsys:
18654 movl $-ENOSYS,PT_EAX(%esp)
18655 jmp resume_userspace
18656 -END(syscall_badsys)
18657 +ENDPROC(syscall_badsys)
18658 CFI_ENDPROC
18659 /*
18660 * End of kprobes section
18661 @@ -708,8 +940,15 @@ END(syscall_badsys)
18662 * normal stack and adjusts ESP with the matching offset.
18663 */
18664 /* fixup the stack */
18665 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
18666 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
18667 +#ifdef CONFIG_SMP
18668 + movl PER_CPU_VAR(cpu_number), %ebx
18669 + shll $PAGE_SHIFT_asm, %ebx
18670 + addl $cpu_gdt_table, %ebx
18671 +#else
18672 + movl $cpu_gdt_table, %ebx
18673 +#endif
18674 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
18675 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
18676 shl $16, %eax
18677 addl %esp, %eax /* the adjusted stack pointer */
18678 pushl_cfi $__KERNEL_DS
18679 @@ -762,7 +1001,7 @@ vector=vector+1
18680 .endr
18681 2: jmp common_interrupt
18682 .endr
18683 -END(irq_entries_start)
18684 +ENDPROC(irq_entries_start)
18685
18686 .previous
18687 END(interrupt)
18688 @@ -813,7 +1052,7 @@ ENTRY(coprocessor_error)
18689 pushl_cfi $do_coprocessor_error
18690 jmp error_code
18691 CFI_ENDPROC
18692 -END(coprocessor_error)
18693 +ENDPROC(coprocessor_error)
18694
18695 ENTRY(simd_coprocessor_error)
18696 RING0_INT_FRAME
18697 @@ -835,7 +1074,7 @@ ENTRY(simd_coprocessor_error)
18698 #endif
18699 jmp error_code
18700 CFI_ENDPROC
18701 -END(simd_coprocessor_error)
18702 +ENDPROC(simd_coprocessor_error)
18703
18704 ENTRY(device_not_available)
18705 RING0_INT_FRAME
18706 @@ -844,18 +1083,18 @@ ENTRY(device_not_available)
18707 pushl_cfi $do_device_not_available
18708 jmp error_code
18709 CFI_ENDPROC
18710 -END(device_not_available)
18711 +ENDPROC(device_not_available)
18712
18713 #ifdef CONFIG_PARAVIRT
18714 ENTRY(native_iret)
18715 iret
18716 _ASM_EXTABLE(native_iret, iret_exc)
18717 -END(native_iret)
18718 +ENDPROC(native_iret)
18719
18720 ENTRY(native_irq_enable_sysexit)
18721 sti
18722 sysexit
18723 -END(native_irq_enable_sysexit)
18724 +ENDPROC(native_irq_enable_sysexit)
18725 #endif
18726
18727 ENTRY(overflow)
18728 @@ -865,7 +1104,7 @@ ENTRY(overflow)
18729 pushl_cfi $do_overflow
18730 jmp error_code
18731 CFI_ENDPROC
18732 -END(overflow)
18733 +ENDPROC(overflow)
18734
18735 ENTRY(bounds)
18736 RING0_INT_FRAME
18737 @@ -874,7 +1113,7 @@ ENTRY(bounds)
18738 pushl_cfi $do_bounds
18739 jmp error_code
18740 CFI_ENDPROC
18741 -END(bounds)
18742 +ENDPROC(bounds)
18743
18744 ENTRY(invalid_op)
18745 RING0_INT_FRAME
18746 @@ -883,7 +1122,7 @@ ENTRY(invalid_op)
18747 pushl_cfi $do_invalid_op
18748 jmp error_code
18749 CFI_ENDPROC
18750 -END(invalid_op)
18751 +ENDPROC(invalid_op)
18752
18753 ENTRY(coprocessor_segment_overrun)
18754 RING0_INT_FRAME
18755 @@ -892,7 +1131,7 @@ ENTRY(coprocessor_segment_overrun)
18756 pushl_cfi $do_coprocessor_segment_overrun
18757 jmp error_code
18758 CFI_ENDPROC
18759 -END(coprocessor_segment_overrun)
18760 +ENDPROC(coprocessor_segment_overrun)
18761
18762 ENTRY(invalid_TSS)
18763 RING0_EC_FRAME
18764 @@ -900,7 +1139,7 @@ ENTRY(invalid_TSS)
18765 pushl_cfi $do_invalid_TSS
18766 jmp error_code
18767 CFI_ENDPROC
18768 -END(invalid_TSS)
18769 +ENDPROC(invalid_TSS)
18770
18771 ENTRY(segment_not_present)
18772 RING0_EC_FRAME
18773 @@ -908,7 +1147,7 @@ ENTRY(segment_not_present)
18774 pushl_cfi $do_segment_not_present
18775 jmp error_code
18776 CFI_ENDPROC
18777 -END(segment_not_present)
18778 +ENDPROC(segment_not_present)
18779
18780 ENTRY(stack_segment)
18781 RING0_EC_FRAME
18782 @@ -916,7 +1155,7 @@ ENTRY(stack_segment)
18783 pushl_cfi $do_stack_segment
18784 jmp error_code
18785 CFI_ENDPROC
18786 -END(stack_segment)
18787 +ENDPROC(stack_segment)
18788
18789 ENTRY(alignment_check)
18790 RING0_EC_FRAME
18791 @@ -924,7 +1163,7 @@ ENTRY(alignment_check)
18792 pushl_cfi $do_alignment_check
18793 jmp error_code
18794 CFI_ENDPROC
18795 -END(alignment_check)
18796 +ENDPROC(alignment_check)
18797
18798 ENTRY(divide_error)
18799 RING0_INT_FRAME
18800 @@ -933,7 +1172,7 @@ ENTRY(divide_error)
18801 pushl_cfi $do_divide_error
18802 jmp error_code
18803 CFI_ENDPROC
18804 -END(divide_error)
18805 +ENDPROC(divide_error)
18806
18807 #ifdef CONFIG_X86_MCE
18808 ENTRY(machine_check)
18809 @@ -943,7 +1182,7 @@ ENTRY(machine_check)
18810 pushl_cfi machine_check_vector
18811 jmp error_code
18812 CFI_ENDPROC
18813 -END(machine_check)
18814 +ENDPROC(machine_check)
18815 #endif
18816
18817 ENTRY(spurious_interrupt_bug)
18818 @@ -953,7 +1192,7 @@ ENTRY(spurious_interrupt_bug)
18819 pushl_cfi $do_spurious_interrupt_bug
18820 jmp error_code
18821 CFI_ENDPROC
18822 -END(spurious_interrupt_bug)
18823 +ENDPROC(spurious_interrupt_bug)
18824 /*
18825 * End of kprobes section
18826 */
18827 @@ -1063,7 +1302,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
18828
18829 ENTRY(mcount)
18830 ret
18831 -END(mcount)
18832 +ENDPROC(mcount)
18833
18834 ENTRY(ftrace_caller)
18835 cmpl $0, function_trace_stop
18836 @@ -1096,7 +1335,7 @@ ftrace_graph_call:
18837 .globl ftrace_stub
18838 ftrace_stub:
18839 ret
18840 -END(ftrace_caller)
18841 +ENDPROC(ftrace_caller)
18842
18843 ENTRY(ftrace_regs_caller)
18844 pushf /* push flags before compare (in cs location) */
18845 @@ -1197,7 +1436,7 @@ trace:
18846 popl %ecx
18847 popl %eax
18848 jmp ftrace_stub
18849 -END(mcount)
18850 +ENDPROC(mcount)
18851 #endif /* CONFIG_DYNAMIC_FTRACE */
18852 #endif /* CONFIG_FUNCTION_TRACER */
18853
18854 @@ -1215,7 +1454,7 @@ ENTRY(ftrace_graph_caller)
18855 popl %ecx
18856 popl %eax
18857 ret
18858 -END(ftrace_graph_caller)
18859 +ENDPROC(ftrace_graph_caller)
18860
18861 .globl return_to_handler
18862 return_to_handler:
18863 @@ -1271,15 +1510,18 @@ error_code:
18864 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
18865 REG_TO_PTGS %ecx
18866 SET_KERNEL_GS %ecx
18867 - movl $(__USER_DS), %ecx
18868 + movl $(__KERNEL_DS), %ecx
18869 movl %ecx, %ds
18870 movl %ecx, %es
18871 +
18872 + pax_enter_kernel
18873 +
18874 TRACE_IRQS_OFF
18875 movl %esp,%eax # pt_regs pointer
18876 call *%edi
18877 jmp ret_from_exception
18878 CFI_ENDPROC
18879 -END(page_fault)
18880 +ENDPROC(page_fault)
18881
18882 /*
18883 * Debug traps and NMI can happen at the one SYSENTER instruction
18884 @@ -1322,7 +1564,7 @@ debug_stack_correct:
18885 call do_debug
18886 jmp ret_from_exception
18887 CFI_ENDPROC
18888 -END(debug)
18889 +ENDPROC(debug)
18890
18891 /*
18892 * NMI is doubly nasty. It can happen _while_ we're handling
18893 @@ -1360,6 +1602,9 @@ nmi_stack_correct:
18894 xorl %edx,%edx # zero error code
18895 movl %esp,%eax # pt_regs pointer
18896 call do_nmi
18897 +
18898 + pax_exit_kernel
18899 +
18900 jmp restore_all_notrace
18901 CFI_ENDPROC
18902
18903 @@ -1396,12 +1641,15 @@ nmi_espfix_stack:
18904 FIXUP_ESPFIX_STACK # %eax == %esp
18905 xorl %edx,%edx # zero error code
18906 call do_nmi
18907 +
18908 + pax_exit_kernel
18909 +
18910 RESTORE_REGS
18911 lss 12+4(%esp), %esp # back to espfix stack
18912 CFI_ADJUST_CFA_OFFSET -24
18913 jmp irq_return
18914 CFI_ENDPROC
18915 -END(nmi)
18916 +ENDPROC(nmi)
18917
18918 ENTRY(int3)
18919 RING0_INT_FRAME
18920 @@ -1414,14 +1662,14 @@ ENTRY(int3)
18921 call do_int3
18922 jmp ret_from_exception
18923 CFI_ENDPROC
18924 -END(int3)
18925 +ENDPROC(int3)
18926
18927 ENTRY(general_protection)
18928 RING0_EC_FRAME
18929 pushl_cfi $do_general_protection
18930 jmp error_code
18931 CFI_ENDPROC
18932 -END(general_protection)
18933 +ENDPROC(general_protection)
18934
18935 #ifdef CONFIG_KVM_GUEST
18936 ENTRY(async_page_fault)
18937 @@ -1430,7 +1678,7 @@ ENTRY(async_page_fault)
18938 pushl_cfi $do_async_page_fault
18939 jmp error_code
18940 CFI_ENDPROC
18941 -END(async_page_fault)
18942 +ENDPROC(async_page_fault)
18943 #endif
18944
18945 /*
18946 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
18947 index c1d01e6..5625dce 100644
18948 --- a/arch/x86/kernel/entry_64.S
18949 +++ b/arch/x86/kernel/entry_64.S
18950 @@ -59,6 +59,8 @@
18951 #include <asm/context_tracking.h>
18952 #include <asm/smap.h>
18953 #include <linux/err.h>
18954 +#include <asm/pgtable.h>
18955 +#include <asm/alternative-asm.h>
18956
18957 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
18958 #include <linux/elf-em.h>
18959 @@ -80,8 +82,9 @@
18960 #ifdef CONFIG_DYNAMIC_FTRACE
18961
18962 ENTRY(function_hook)
18963 + pax_force_retaddr
18964 retq
18965 -END(function_hook)
18966 +ENDPROC(function_hook)
18967
18968 /* skip is set if stack has been adjusted */
18969 .macro ftrace_caller_setup skip=0
18970 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
18971 #endif
18972
18973 GLOBAL(ftrace_stub)
18974 + pax_force_retaddr
18975 retq
18976 -END(ftrace_caller)
18977 +ENDPROC(ftrace_caller)
18978
18979 ENTRY(ftrace_regs_caller)
18980 /* Save the current flags before compare (in SS location)*/
18981 @@ -191,7 +195,7 @@ ftrace_restore_flags:
18982 popfq
18983 jmp ftrace_stub
18984
18985 -END(ftrace_regs_caller)
18986 +ENDPROC(ftrace_regs_caller)
18987
18988
18989 #else /* ! CONFIG_DYNAMIC_FTRACE */
18990 @@ -212,6 +216,7 @@ ENTRY(function_hook)
18991 #endif
18992
18993 GLOBAL(ftrace_stub)
18994 + pax_force_retaddr
18995 retq
18996
18997 trace:
18998 @@ -225,12 +230,13 @@ trace:
18999 #endif
19000 subq $MCOUNT_INSN_SIZE, %rdi
19001
19002 + pax_force_fptr ftrace_trace_function
19003 call *ftrace_trace_function
19004
19005 MCOUNT_RESTORE_FRAME
19006
19007 jmp ftrace_stub
19008 -END(function_hook)
19009 +ENDPROC(function_hook)
19010 #endif /* CONFIG_DYNAMIC_FTRACE */
19011 #endif /* CONFIG_FUNCTION_TRACER */
19012
19013 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
19014
19015 MCOUNT_RESTORE_FRAME
19016
19017 + pax_force_retaddr
19018 retq
19019 -END(ftrace_graph_caller)
19020 +ENDPROC(ftrace_graph_caller)
19021
19022 GLOBAL(return_to_handler)
19023 subq $24, %rsp
19024 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
19025 movq 8(%rsp), %rdx
19026 movq (%rsp), %rax
19027 addq $24, %rsp
19028 + pax_force_fptr %rdi
19029 jmp *%rdi
19030 +ENDPROC(return_to_handler)
19031 #endif
19032
19033
19034 @@ -284,6 +293,282 @@ ENTRY(native_usergs_sysret64)
19035 ENDPROC(native_usergs_sysret64)
19036 #endif /* CONFIG_PARAVIRT */
19037
19038 + .macro ljmpq sel, off
19039 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
19040 + .byte 0x48; ljmp *1234f(%rip)
19041 + .pushsection .rodata
19042 + .align 16
19043 + 1234: .quad \off; .word \sel
19044 + .popsection
19045 +#else
19046 + pushq $\sel
19047 + pushq $\off
19048 + lretq
19049 +#endif
19050 + .endm
19051 +
19052 + .macro pax_enter_kernel
19053 + pax_set_fptr_mask
19054 +#ifdef CONFIG_PAX_KERNEXEC
19055 + call pax_enter_kernel
19056 +#endif
19057 + .endm
19058 +
19059 + .macro pax_exit_kernel
19060 +#ifdef CONFIG_PAX_KERNEXEC
19061 + call pax_exit_kernel
19062 +#endif
19063 + .endm
19064 +
19065 +#ifdef CONFIG_PAX_KERNEXEC
19066 +ENTRY(pax_enter_kernel)
19067 + pushq %rdi
19068 +
19069 +#ifdef CONFIG_PARAVIRT
19070 + PV_SAVE_REGS(CLBR_RDI)
19071 +#endif
19072 +
19073 + GET_CR0_INTO_RDI
19074 + bts $16,%rdi
19075 + jnc 3f
19076 + mov %cs,%edi
19077 + cmp $__KERNEL_CS,%edi
19078 + jnz 2f
19079 +1:
19080 +
19081 +#ifdef CONFIG_PARAVIRT
19082 + PV_RESTORE_REGS(CLBR_RDI)
19083 +#endif
19084 +
19085 + popq %rdi
19086 + pax_force_retaddr
19087 + retq
19088 +
19089 +2: ljmpq __KERNEL_CS,1b
19090 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
19091 +4: SET_RDI_INTO_CR0
19092 + jmp 1b
19093 +ENDPROC(pax_enter_kernel)
19094 +
19095 +ENTRY(pax_exit_kernel)
19096 + pushq %rdi
19097 +
19098 +#ifdef CONFIG_PARAVIRT
19099 + PV_SAVE_REGS(CLBR_RDI)
19100 +#endif
19101 +
19102 + mov %cs,%rdi
19103 + cmp $__KERNEXEC_KERNEL_CS,%edi
19104 + jz 2f
19105 + GET_CR0_INTO_RDI
19106 + bts $16,%rdi
19107 + jnc 4f
19108 +1:
19109 +
19110 +#ifdef CONFIG_PARAVIRT
19111 + PV_RESTORE_REGS(CLBR_RDI);
19112 +#endif
19113 +
19114 + popq %rdi
19115 + pax_force_retaddr
19116 + retq
19117 +
19118 +2: GET_CR0_INTO_RDI
19119 + btr $16,%rdi
19120 + jnc 4f
19121 + ljmpq __KERNEL_CS,3f
19122 +3: SET_RDI_INTO_CR0
19123 + jmp 1b
19124 +4: ud2
19125 + jmp 4b
19126 +ENDPROC(pax_exit_kernel)
19127 +#endif
19128 +
19129 + .macro pax_enter_kernel_user
19130 + pax_set_fptr_mask
19131 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19132 + call pax_enter_kernel_user
19133 +#endif
19134 + .endm
19135 +
19136 + .macro pax_exit_kernel_user
19137 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19138 + call pax_exit_kernel_user
19139 +#endif
19140 +#ifdef CONFIG_PAX_RANDKSTACK
19141 + pushq %rax
19142 + call pax_randomize_kstack
19143 + popq %rax
19144 +#endif
19145 + .endm
19146 +
19147 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19148 +ENTRY(pax_enter_kernel_user)
19149 + pushq %rdi
19150 + pushq %rbx
19151 +
19152 +#ifdef CONFIG_PARAVIRT
19153 + PV_SAVE_REGS(CLBR_RDI)
19154 +#endif
19155 +
19156 + GET_CR3_INTO_RDI
19157 + mov %rdi,%rbx
19158 + add $__START_KERNEL_map,%rbx
19159 + sub phys_base(%rip),%rbx
19160 +
19161 +#ifdef CONFIG_PARAVIRT
19162 + pushq %rdi
19163 + cmpl $0, pv_info+PARAVIRT_enabled
19164 + jz 1f
19165 + i = 0
19166 + .rept USER_PGD_PTRS
19167 + mov i*8(%rbx),%rsi
19168 + mov $0,%sil
19169 + lea i*8(%rbx),%rdi
19170 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19171 + i = i + 1
19172 + .endr
19173 + jmp 2f
19174 +1:
19175 +#endif
19176 +
19177 + i = 0
19178 + .rept USER_PGD_PTRS
19179 + movb $0,i*8(%rbx)
19180 + i = i + 1
19181 + .endr
19182 +
19183 +#ifdef CONFIG_PARAVIRT
19184 +2: popq %rdi
19185 +#endif
19186 + SET_RDI_INTO_CR3
19187 +
19188 +#ifdef CONFIG_PAX_KERNEXEC
19189 + GET_CR0_INTO_RDI
19190 + bts $16,%rdi
19191 + SET_RDI_INTO_CR0
19192 +#endif
19193 +
19194 +#ifdef CONFIG_PARAVIRT
19195 + PV_RESTORE_REGS(CLBR_RDI)
19196 +#endif
19197 +
19198 + popq %rbx
19199 + popq %rdi
19200 + pax_force_retaddr
19201 + retq
19202 +ENDPROC(pax_enter_kernel_user)
19203 +
19204 +ENTRY(pax_exit_kernel_user)
19205 + push %rdi
19206 +
19207 +#ifdef CONFIG_PARAVIRT
19208 + pushq %rbx
19209 + PV_SAVE_REGS(CLBR_RDI)
19210 +#endif
19211 +
19212 +#ifdef CONFIG_PAX_KERNEXEC
19213 + GET_CR0_INTO_RDI
19214 + btr $16,%rdi
19215 + jnc 3f
19216 + SET_RDI_INTO_CR0
19217 +#endif
19218 +
19219 + GET_CR3_INTO_RDI
19220 + add $__START_KERNEL_map,%rdi
19221 + sub phys_base(%rip),%rdi
19222 +
19223 +#ifdef CONFIG_PARAVIRT
19224 + cmpl $0, pv_info+PARAVIRT_enabled
19225 + jz 1f
19226 + mov %rdi,%rbx
19227 + i = 0
19228 + .rept USER_PGD_PTRS
19229 + mov i*8(%rbx),%rsi
19230 + mov $0x67,%sil
19231 + lea i*8(%rbx),%rdi
19232 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19233 + i = i + 1
19234 + .endr
19235 + jmp 2f
19236 +1:
19237 +#endif
19238 +
19239 + i = 0
19240 + .rept USER_PGD_PTRS
19241 + movb $0x67,i*8(%rdi)
19242 + i = i + 1
19243 + .endr
19244 +
19245 +#ifdef CONFIG_PARAVIRT
19246 +2: PV_RESTORE_REGS(CLBR_RDI)
19247 + popq %rbx
19248 +#endif
19249 +
19250 + popq %rdi
19251 + pax_force_retaddr
19252 + retq
19253 +3: ud2
19254 + jmp 3b
19255 +ENDPROC(pax_exit_kernel_user)
19256 +#endif
19257 +
19258 +.macro pax_erase_kstack
19259 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19260 + call pax_erase_kstack
19261 +#endif
19262 +.endm
19263 +
19264 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19265 +ENTRY(pax_erase_kstack)
19266 + pushq %rdi
19267 + pushq %rcx
19268 + pushq %rax
19269 + pushq %r11
19270 +
19271 + GET_THREAD_INFO(%r11)
19272 + mov TI_lowest_stack(%r11), %rdi
19273 + mov $-0xBEEF, %rax
19274 + std
19275 +
19276 +1: mov %edi, %ecx
19277 + and $THREAD_SIZE_asm - 1, %ecx
19278 + shr $3, %ecx
19279 + repne scasq
19280 + jecxz 2f
19281 +
19282 + cmp $2*8, %ecx
19283 + jc 2f
19284 +
19285 + mov $2*8, %ecx
19286 + repe scasq
19287 + jecxz 2f
19288 + jne 1b
19289 +
19290 +2: cld
19291 + mov %esp, %ecx
19292 + sub %edi, %ecx
19293 +
19294 + cmp $THREAD_SIZE_asm, %rcx
19295 + jb 3f
19296 + ud2
19297 +3:
19298 +
19299 + shr $3, %ecx
19300 + rep stosq
19301 +
19302 + mov TI_task_thread_sp0(%r11), %rdi
19303 + sub $256, %rdi
19304 + mov %rdi, TI_lowest_stack(%r11)
19305 +
19306 + popq %r11
19307 + popq %rax
19308 + popq %rcx
19309 + popq %rdi
19310 + pax_force_retaddr
19311 + ret
19312 +ENDPROC(pax_erase_kstack)
19313 +#endif
19314
19315 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19316 #ifdef CONFIG_TRACE_IRQFLAGS
19317 @@ -375,8 +660,8 @@ ENDPROC(native_usergs_sysret64)
19318 .endm
19319
19320 .macro UNFAKE_STACK_FRAME
19321 - addq $8*6, %rsp
19322 - CFI_ADJUST_CFA_OFFSET -(6*8)
19323 + addq $8*6 + ARG_SKIP, %rsp
19324 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19325 .endm
19326
19327 /*
19328 @@ -463,7 +748,7 @@ ENDPROC(native_usergs_sysret64)
19329 movq %rsp, %rsi
19330
19331 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19332 - testl $3, CS-RBP(%rsi)
19333 + testb $3, CS-RBP(%rsi)
19334 je 1f
19335 SWAPGS
19336 /*
19337 @@ -498,9 +783,10 @@ ENTRY(save_rest)
19338 movq_cfi r15, R15+16
19339 movq %r11, 8(%rsp) /* return address */
19340 FIXUP_TOP_OF_STACK %r11, 16
19341 + pax_force_retaddr
19342 ret
19343 CFI_ENDPROC
19344 -END(save_rest)
19345 +ENDPROC(save_rest)
19346
19347 /* save complete stack frame */
19348 .pushsection .kprobes.text, "ax"
19349 @@ -529,9 +815,10 @@ ENTRY(save_paranoid)
19350 js 1f /* negative -> in kernel */
19351 SWAPGS
19352 xorl %ebx,%ebx
19353 -1: ret
19354 +1: pax_force_retaddr_bts
19355 + ret
19356 CFI_ENDPROC
19357 -END(save_paranoid)
19358 +ENDPROC(save_paranoid)
19359 .popsection
19360
19361 /*
19362 @@ -553,7 +840,7 @@ ENTRY(ret_from_fork)
19363
19364 RESTORE_REST
19365
19366 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19367 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19368 jz 1f
19369
19370 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19371 @@ -571,7 +858,7 @@ ENTRY(ret_from_fork)
19372 RESTORE_REST
19373 jmp int_ret_from_sys_call
19374 CFI_ENDPROC
19375 -END(ret_from_fork)
19376 +ENDPROC(ret_from_fork)
19377
19378 /*
19379 * System call entry. Up to 6 arguments in registers are supported.
19380 @@ -608,7 +895,7 @@ END(ret_from_fork)
19381 ENTRY(system_call)
19382 CFI_STARTPROC simple
19383 CFI_SIGNAL_FRAME
19384 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19385 + CFI_DEF_CFA rsp,0
19386 CFI_REGISTER rip,rcx
19387 /*CFI_REGISTER rflags,r11*/
19388 SWAPGS_UNSAFE_STACK
19389 @@ -621,16 +908,23 @@ GLOBAL(system_call_after_swapgs)
19390
19391 movq %rsp,PER_CPU_VAR(old_rsp)
19392 movq PER_CPU_VAR(kernel_stack),%rsp
19393 + SAVE_ARGS 8*6,0
19394 + pax_enter_kernel_user
19395 +
19396 +#ifdef CONFIG_PAX_RANDKSTACK
19397 + pax_erase_kstack
19398 +#endif
19399 +
19400 /*
19401 * No need to follow this irqs off/on section - it's straight
19402 * and short:
19403 */
19404 ENABLE_INTERRUPTS(CLBR_NONE)
19405 - SAVE_ARGS 8,0
19406 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19407 movq %rcx,RIP-ARGOFFSET(%rsp)
19408 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19409 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19410 + GET_THREAD_INFO(%rcx)
19411 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19412 jnz tracesys
19413 system_call_fastpath:
19414 #if __SYSCALL_MASK == ~0
19415 @@ -640,7 +934,7 @@ system_call_fastpath:
19416 cmpl $__NR_syscall_max,%eax
19417 #endif
19418 ja badsys
19419 - movq %r10,%rcx
19420 + movq R10-ARGOFFSET(%rsp),%rcx
19421 call *sys_call_table(,%rax,8) # XXX: rip relative
19422 movq %rax,RAX-ARGOFFSET(%rsp)
19423 /*
19424 @@ -654,10 +948,13 @@ sysret_check:
19425 LOCKDEP_SYS_EXIT
19426 DISABLE_INTERRUPTS(CLBR_NONE)
19427 TRACE_IRQS_OFF
19428 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19429 + GET_THREAD_INFO(%rcx)
19430 + movl TI_flags(%rcx),%edx
19431 andl %edi,%edx
19432 jnz sysret_careful
19433 CFI_REMEMBER_STATE
19434 + pax_exit_kernel_user
19435 + pax_erase_kstack
19436 /*
19437 * sysretq will re-enable interrupts:
19438 */
19439 @@ -709,14 +1006,18 @@ badsys:
19440 * jump back to the normal fast path.
19441 */
19442 auditsys:
19443 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19444 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19445 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19446 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19447 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19448 movq %rax,%rsi /* 2nd arg: syscall number */
19449 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19450 call __audit_syscall_entry
19451 +
19452 + pax_erase_kstack
19453 +
19454 LOAD_ARGS 0 /* reload call-clobbered registers */
19455 + pax_set_fptr_mask
19456 jmp system_call_fastpath
19457
19458 /*
19459 @@ -737,7 +1038,7 @@ sysret_audit:
19460 /* Do syscall tracing */
19461 tracesys:
19462 #ifdef CONFIG_AUDITSYSCALL
19463 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19464 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19465 jz auditsys
19466 #endif
19467 SAVE_REST
19468 @@ -745,12 +1046,16 @@ tracesys:
19469 FIXUP_TOP_OF_STACK %rdi
19470 movq %rsp,%rdi
19471 call syscall_trace_enter
19472 +
19473 + pax_erase_kstack
19474 +
19475 /*
19476 * Reload arg registers from stack in case ptrace changed them.
19477 * We don't reload %rax because syscall_trace_enter() returned
19478 * the value it wants us to use in the table lookup.
19479 */
19480 LOAD_ARGS ARGOFFSET, 1
19481 + pax_set_fptr_mask
19482 RESTORE_REST
19483 #if __SYSCALL_MASK == ~0
19484 cmpq $__NR_syscall_max,%rax
19485 @@ -759,7 +1064,7 @@ tracesys:
19486 cmpl $__NR_syscall_max,%eax
19487 #endif
19488 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19489 - movq %r10,%rcx /* fixup for C */
19490 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19491 call *sys_call_table(,%rax,8)
19492 movq %rax,RAX-ARGOFFSET(%rsp)
19493 /* Use IRET because user could have changed frame */
19494 @@ -780,7 +1085,9 @@ GLOBAL(int_with_check)
19495 andl %edi,%edx
19496 jnz int_careful
19497 andl $~TS_COMPAT,TI_status(%rcx)
19498 - jmp retint_swapgs
19499 + pax_exit_kernel_user
19500 + pax_erase_kstack
19501 + jmp retint_swapgs_pax
19502
19503 /* Either reschedule or signal or syscall exit tracking needed. */
19504 /* First do a reschedule test. */
19505 @@ -826,7 +1133,7 @@ int_restore_rest:
19506 TRACE_IRQS_OFF
19507 jmp int_with_check
19508 CFI_ENDPROC
19509 -END(system_call)
19510 +ENDPROC(system_call)
19511
19512 .macro FORK_LIKE func
19513 ENTRY(stub_\func)
19514 @@ -839,9 +1146,10 @@ ENTRY(stub_\func)
19515 DEFAULT_FRAME 0 8 /* offset 8: return address */
19516 call sys_\func
19517 RESTORE_TOP_OF_STACK %r11, 8
19518 + pax_force_retaddr
19519 ret $REST_SKIP /* pop extended registers */
19520 CFI_ENDPROC
19521 -END(stub_\func)
19522 +ENDPROC(stub_\func)
19523 .endm
19524
19525 .macro FIXED_FRAME label,func
19526 @@ -851,9 +1159,10 @@ ENTRY(\label)
19527 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
19528 call \func
19529 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
19530 + pax_force_retaddr
19531 ret
19532 CFI_ENDPROC
19533 -END(\label)
19534 +ENDPROC(\label)
19535 .endm
19536
19537 FORK_LIKE clone
19538 @@ -870,9 +1179,10 @@ ENTRY(ptregscall_common)
19539 movq_cfi_restore R12+8, r12
19540 movq_cfi_restore RBP+8, rbp
19541 movq_cfi_restore RBX+8, rbx
19542 + pax_force_retaddr
19543 ret $REST_SKIP /* pop extended registers */
19544 CFI_ENDPROC
19545 -END(ptregscall_common)
19546 +ENDPROC(ptregscall_common)
19547
19548 ENTRY(stub_execve)
19549 CFI_STARTPROC
19550 @@ -885,7 +1195,7 @@ ENTRY(stub_execve)
19551 RESTORE_REST
19552 jmp int_ret_from_sys_call
19553 CFI_ENDPROC
19554 -END(stub_execve)
19555 +ENDPROC(stub_execve)
19556
19557 /*
19558 * sigreturn is special because it needs to restore all registers on return.
19559 @@ -902,7 +1212,7 @@ ENTRY(stub_rt_sigreturn)
19560 RESTORE_REST
19561 jmp int_ret_from_sys_call
19562 CFI_ENDPROC
19563 -END(stub_rt_sigreturn)
19564 +ENDPROC(stub_rt_sigreturn)
19565
19566 #ifdef CONFIG_X86_X32_ABI
19567 ENTRY(stub_x32_rt_sigreturn)
19568 @@ -916,7 +1226,7 @@ ENTRY(stub_x32_rt_sigreturn)
19569 RESTORE_REST
19570 jmp int_ret_from_sys_call
19571 CFI_ENDPROC
19572 -END(stub_x32_rt_sigreturn)
19573 +ENDPROC(stub_x32_rt_sigreturn)
19574
19575 ENTRY(stub_x32_execve)
19576 CFI_STARTPROC
19577 @@ -930,7 +1240,7 @@ ENTRY(stub_x32_execve)
19578 RESTORE_REST
19579 jmp int_ret_from_sys_call
19580 CFI_ENDPROC
19581 -END(stub_x32_execve)
19582 +ENDPROC(stub_x32_execve)
19583
19584 #endif
19585
19586 @@ -967,7 +1277,7 @@ vector=vector+1
19587 2: jmp common_interrupt
19588 .endr
19589 CFI_ENDPROC
19590 -END(irq_entries_start)
19591 +ENDPROC(irq_entries_start)
19592
19593 .previous
19594 END(interrupt)
19595 @@ -987,6 +1297,16 @@ END(interrupt)
19596 subq $ORIG_RAX-RBP, %rsp
19597 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19598 SAVE_ARGS_IRQ
19599 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19600 + testb $3, CS(%rdi)
19601 + jnz 1f
19602 + pax_enter_kernel
19603 + jmp 2f
19604 +1: pax_enter_kernel_user
19605 +2:
19606 +#else
19607 + pax_enter_kernel
19608 +#endif
19609 call \func
19610 .endm
19611
19612 @@ -1019,7 +1339,7 @@ ret_from_intr:
19613
19614 exit_intr:
19615 GET_THREAD_INFO(%rcx)
19616 - testl $3,CS-ARGOFFSET(%rsp)
19617 + testb $3,CS-ARGOFFSET(%rsp)
19618 je retint_kernel
19619
19620 /* Interrupt came from user space */
19621 @@ -1041,12 +1361,16 @@ retint_swapgs: /* return to user-space */
19622 * The iretq could re-enable interrupts:
19623 */
19624 DISABLE_INTERRUPTS(CLBR_ANY)
19625 + pax_exit_kernel_user
19626 +retint_swapgs_pax:
19627 TRACE_IRQS_IRETQ
19628 SWAPGS
19629 jmp restore_args
19630
19631 retint_restore_args: /* return to kernel space */
19632 DISABLE_INTERRUPTS(CLBR_ANY)
19633 + pax_exit_kernel
19634 + pax_force_retaddr (RIP-ARGOFFSET)
19635 /*
19636 * The iretq could re-enable interrupts:
19637 */
19638 @@ -1129,7 +1453,7 @@ ENTRY(retint_kernel)
19639 #endif
19640
19641 CFI_ENDPROC
19642 -END(common_interrupt)
19643 +ENDPROC(common_interrupt)
19644 /*
19645 * End of kprobes section
19646 */
19647 @@ -1147,7 +1471,7 @@ ENTRY(\sym)
19648 interrupt \do_sym
19649 jmp ret_from_intr
19650 CFI_ENDPROC
19651 -END(\sym)
19652 +ENDPROC(\sym)
19653 .endm
19654
19655 #ifdef CONFIG_SMP
19656 @@ -1203,12 +1527,22 @@ ENTRY(\sym)
19657 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19658 call error_entry
19659 DEFAULT_FRAME 0
19660 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19661 + testb $3, CS(%rsp)
19662 + jnz 1f
19663 + pax_enter_kernel
19664 + jmp 2f
19665 +1: pax_enter_kernel_user
19666 +2:
19667 +#else
19668 + pax_enter_kernel
19669 +#endif
19670 movq %rsp,%rdi /* pt_regs pointer */
19671 xorl %esi,%esi /* no error code */
19672 call \do_sym
19673 jmp error_exit /* %ebx: no swapgs flag */
19674 CFI_ENDPROC
19675 -END(\sym)
19676 +ENDPROC(\sym)
19677 .endm
19678
19679 .macro paranoidzeroentry sym do_sym
19680 @@ -1221,15 +1555,25 @@ ENTRY(\sym)
19681 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19682 call save_paranoid
19683 TRACE_IRQS_OFF
19684 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19685 + testb $3, CS(%rsp)
19686 + jnz 1f
19687 + pax_enter_kernel
19688 + jmp 2f
19689 +1: pax_enter_kernel_user
19690 +2:
19691 +#else
19692 + pax_enter_kernel
19693 +#endif
19694 movq %rsp,%rdi /* pt_regs pointer */
19695 xorl %esi,%esi /* no error code */
19696 call \do_sym
19697 jmp paranoid_exit /* %ebx: no swapgs flag */
19698 CFI_ENDPROC
19699 -END(\sym)
19700 +ENDPROC(\sym)
19701 .endm
19702
19703 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
19704 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
19705 .macro paranoidzeroentry_ist sym do_sym ist
19706 ENTRY(\sym)
19707 INTR_FRAME
19708 @@ -1240,14 +1584,30 @@ ENTRY(\sym)
19709 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19710 call save_paranoid
19711 TRACE_IRQS_OFF_DEBUG
19712 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19713 + testb $3, CS(%rsp)
19714 + jnz 1f
19715 + pax_enter_kernel
19716 + jmp 2f
19717 +1: pax_enter_kernel_user
19718 +2:
19719 +#else
19720 + pax_enter_kernel
19721 +#endif
19722 movq %rsp,%rdi /* pt_regs pointer */
19723 xorl %esi,%esi /* no error code */
19724 +#ifdef CONFIG_SMP
19725 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
19726 + lea init_tss(%r12), %r12
19727 +#else
19728 + lea init_tss(%rip), %r12
19729 +#endif
19730 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19731 call \do_sym
19732 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19733 jmp paranoid_exit /* %ebx: no swapgs flag */
19734 CFI_ENDPROC
19735 -END(\sym)
19736 +ENDPROC(\sym)
19737 .endm
19738
19739 .macro errorentry sym do_sym
19740 @@ -1259,13 +1619,23 @@ ENTRY(\sym)
19741 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19742 call error_entry
19743 DEFAULT_FRAME 0
19744 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19745 + testb $3, CS(%rsp)
19746 + jnz 1f
19747 + pax_enter_kernel
19748 + jmp 2f
19749 +1: pax_enter_kernel_user
19750 +2:
19751 +#else
19752 + pax_enter_kernel
19753 +#endif
19754 movq %rsp,%rdi /* pt_regs pointer */
19755 movq ORIG_RAX(%rsp),%rsi /* get error code */
19756 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19757 call \do_sym
19758 jmp error_exit /* %ebx: no swapgs flag */
19759 CFI_ENDPROC
19760 -END(\sym)
19761 +ENDPROC(\sym)
19762 .endm
19763
19764 /* error code is on the stack already */
19765 @@ -1279,13 +1649,23 @@ ENTRY(\sym)
19766 call save_paranoid
19767 DEFAULT_FRAME 0
19768 TRACE_IRQS_OFF
19769 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19770 + testb $3, CS(%rsp)
19771 + jnz 1f
19772 + pax_enter_kernel
19773 + jmp 2f
19774 +1: pax_enter_kernel_user
19775 +2:
19776 +#else
19777 + pax_enter_kernel
19778 +#endif
19779 movq %rsp,%rdi /* pt_regs pointer */
19780 movq ORIG_RAX(%rsp),%rsi /* get error code */
19781 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19782 call \do_sym
19783 jmp paranoid_exit /* %ebx: no swapgs flag */
19784 CFI_ENDPROC
19785 -END(\sym)
19786 +ENDPROC(\sym)
19787 .endm
19788
19789 zeroentry divide_error do_divide_error
19790 @@ -1315,9 +1695,10 @@ gs_change:
19791 2: mfence /* workaround */
19792 SWAPGS
19793 popfq_cfi
19794 + pax_force_retaddr
19795 ret
19796 CFI_ENDPROC
19797 -END(native_load_gs_index)
19798 +ENDPROC(native_load_gs_index)
19799
19800 _ASM_EXTABLE(gs_change,bad_gs)
19801 .section .fixup,"ax"
19802 @@ -1345,9 +1726,10 @@ ENTRY(call_softirq)
19803 CFI_DEF_CFA_REGISTER rsp
19804 CFI_ADJUST_CFA_OFFSET -8
19805 decl PER_CPU_VAR(irq_count)
19806 + pax_force_retaddr
19807 ret
19808 CFI_ENDPROC
19809 -END(call_softirq)
19810 +ENDPROC(call_softirq)
19811
19812 #ifdef CONFIG_XEN
19813 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
19814 @@ -1385,7 +1767,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
19815 decl PER_CPU_VAR(irq_count)
19816 jmp error_exit
19817 CFI_ENDPROC
19818 -END(xen_do_hypervisor_callback)
19819 +ENDPROC(xen_do_hypervisor_callback)
19820
19821 /*
19822 * Hypervisor uses this for application faults while it executes.
19823 @@ -1444,7 +1826,7 @@ ENTRY(xen_failsafe_callback)
19824 SAVE_ALL
19825 jmp error_exit
19826 CFI_ENDPROC
19827 -END(xen_failsafe_callback)
19828 +ENDPROC(xen_failsafe_callback)
19829
19830 apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
19831 xen_hvm_callback_vector xen_evtchn_do_upcall
19832 @@ -1498,16 +1880,31 @@ ENTRY(paranoid_exit)
19833 TRACE_IRQS_OFF_DEBUG
19834 testl %ebx,%ebx /* swapgs needed? */
19835 jnz paranoid_restore
19836 - testl $3,CS(%rsp)
19837 + testb $3,CS(%rsp)
19838 jnz paranoid_userspace
19839 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19840 + pax_exit_kernel
19841 + TRACE_IRQS_IRETQ 0
19842 + SWAPGS_UNSAFE_STACK
19843 + RESTORE_ALL 8
19844 + pax_force_retaddr_bts
19845 + jmp irq_return
19846 +#endif
19847 paranoid_swapgs:
19848 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19849 + pax_exit_kernel_user
19850 +#else
19851 + pax_exit_kernel
19852 +#endif
19853 TRACE_IRQS_IRETQ 0
19854 SWAPGS_UNSAFE_STACK
19855 RESTORE_ALL 8
19856 jmp irq_return
19857 paranoid_restore:
19858 + pax_exit_kernel
19859 TRACE_IRQS_IRETQ_DEBUG 0
19860 RESTORE_ALL 8
19861 + pax_force_retaddr_bts
19862 jmp irq_return
19863 paranoid_userspace:
19864 GET_THREAD_INFO(%rcx)
19865 @@ -1536,7 +1933,7 @@ paranoid_schedule:
19866 TRACE_IRQS_OFF
19867 jmp paranoid_userspace
19868 CFI_ENDPROC
19869 -END(paranoid_exit)
19870 +ENDPROC(paranoid_exit)
19871
19872 /*
19873 * Exception entry point. This expects an error code/orig_rax on the stack.
19874 @@ -1563,12 +1960,13 @@ ENTRY(error_entry)
19875 movq_cfi r14, R14+8
19876 movq_cfi r15, R15+8
19877 xorl %ebx,%ebx
19878 - testl $3,CS+8(%rsp)
19879 + testb $3,CS+8(%rsp)
19880 je error_kernelspace
19881 error_swapgs:
19882 SWAPGS
19883 error_sti:
19884 TRACE_IRQS_OFF
19885 + pax_force_retaddr_bts
19886 ret
19887
19888 /*
19889 @@ -1595,7 +1993,7 @@ bstep_iret:
19890 movq %rcx,RIP+8(%rsp)
19891 jmp error_swapgs
19892 CFI_ENDPROC
19893 -END(error_entry)
19894 +ENDPROC(error_entry)
19895
19896
19897 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
19898 @@ -1615,7 +2013,7 @@ ENTRY(error_exit)
19899 jnz retint_careful
19900 jmp retint_swapgs
19901 CFI_ENDPROC
19902 -END(error_exit)
19903 +ENDPROC(error_exit)
19904
19905 /*
19906 * Test if a given stack is an NMI stack or not.
19907 @@ -1673,9 +2071,11 @@ ENTRY(nmi)
19908 * If %cs was not the kernel segment, then the NMI triggered in user
19909 * space, which means it is definitely not nested.
19910 */
19911 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
19912 + je 1f
19913 cmpl $__KERNEL_CS, 16(%rsp)
19914 jne first_nmi
19915 -
19916 +1:
19917 /*
19918 * Check the special variable on the stack to see if NMIs are
19919 * executing.
19920 @@ -1709,8 +2109,7 @@ nested_nmi:
19921
19922 1:
19923 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
19924 - leaq -1*8(%rsp), %rdx
19925 - movq %rdx, %rsp
19926 + subq $8, %rsp
19927 CFI_ADJUST_CFA_OFFSET 1*8
19928 leaq -10*8(%rsp), %rdx
19929 pushq_cfi $__KERNEL_DS
19930 @@ -1728,6 +2127,7 @@ nested_nmi_out:
19931 CFI_RESTORE rdx
19932
19933 /* No need to check faults here */
19934 + pax_force_retaddr_bts
19935 INTERRUPT_RETURN
19936
19937 CFI_RESTORE_STATE
19938 @@ -1844,6 +2244,17 @@ end_repeat_nmi:
19939 */
19940 movq %cr2, %r12
19941
19942 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19943 + testb $3, CS(%rsp)
19944 + jnz 1f
19945 + pax_enter_kernel
19946 + jmp 2f
19947 +1: pax_enter_kernel_user
19948 +2:
19949 +#else
19950 + pax_enter_kernel
19951 +#endif
19952 +
19953 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
19954 movq %rsp,%rdi
19955 movq $-1,%rsi
19956 @@ -1859,23 +2270,34 @@ end_repeat_nmi:
19957 testl %ebx,%ebx /* swapgs needed? */
19958 jnz nmi_restore
19959 nmi_swapgs:
19960 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19961 + pax_exit_kernel_user
19962 +#else
19963 + pax_exit_kernel
19964 +#endif
19965 SWAPGS_UNSAFE_STACK
19966 + RESTORE_ALL 6*8
19967 + /* Clear the NMI executing stack variable */
19968 + movq $0, 5*8(%rsp)
19969 + jmp irq_return
19970 nmi_restore:
19971 + pax_exit_kernel
19972 /* Pop the extra iret frame at once */
19973 RESTORE_ALL 6*8
19974 + pax_force_retaddr_bts
19975
19976 /* Clear the NMI executing stack variable */
19977 movq $0, 5*8(%rsp)
19978 jmp irq_return
19979 CFI_ENDPROC
19980 -END(nmi)
19981 +ENDPROC(nmi)
19982
19983 ENTRY(ignore_sysret)
19984 CFI_STARTPROC
19985 mov $-ENOSYS,%eax
19986 sysret
19987 CFI_ENDPROC
19988 -END(ignore_sysret)
19989 +ENDPROC(ignore_sysret)
19990
19991 /*
19992 * End of kprobes section
19993 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
19994 index 42a392a..fbbd930 100644
19995 --- a/arch/x86/kernel/ftrace.c
19996 +++ b/arch/x86/kernel/ftrace.c
19997 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
19998 {
19999 unsigned char replaced[MCOUNT_INSN_SIZE];
20000
20001 + ip = ktla_ktva(ip);
20002 +
20003 /*
20004 * Note: Due to modules and __init, code can
20005 * disappear and change, we need to protect against faulting
20006 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20007 unsigned char old[MCOUNT_INSN_SIZE], *new;
20008 int ret;
20009
20010 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
20011 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
20012 new = ftrace_call_replace(ip, (unsigned long)func);
20013
20014 /* See comment above by declaration of modifying_ftrace_code */
20015 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20016 /* Also update the regs callback function */
20017 if (!ret) {
20018 ip = (unsigned long)(&ftrace_regs_call);
20019 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
20020 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
20021 new = ftrace_call_replace(ip, (unsigned long)func);
20022 ret = ftrace_modify_code(ip, old, new);
20023 }
20024 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
20025 * kernel identity mapping to modify code.
20026 */
20027 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
20028 - ip = (unsigned long)__va(__pa_symbol(ip));
20029 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
20030
20031 return probe_kernel_write((void *)ip, val, size);
20032 }
20033 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
20034 unsigned char replaced[MCOUNT_INSN_SIZE];
20035 unsigned char brk = BREAKPOINT_INSTRUCTION;
20036
20037 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
20038 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
20039 return -EFAULT;
20040
20041 /* Make sure it is what we expect it to be */
20042 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
20043 return ret;
20044
20045 fail_update:
20046 - probe_kernel_write((void *)ip, &old_code[0], 1);
20047 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
20048 goto out;
20049 }
20050
20051 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
20052 {
20053 unsigned char code[MCOUNT_INSN_SIZE];
20054
20055 + ip = ktla_ktva(ip);
20056 +
20057 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
20058 return -EFAULT;
20059
20060 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
20061 index 8f3201d..aa860bf 100644
20062 --- a/arch/x86/kernel/head64.c
20063 +++ b/arch/x86/kernel/head64.c
20064 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
20065 if (console_loglevel == 10)
20066 early_printk("Kernel alive\n");
20067
20068 - clear_page(init_level4_pgt);
20069 /* set init_level4_pgt kernel high mapping*/
20070 init_level4_pgt[511] = early_level4_pgt[511];
20071
20072 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
20073 index 73afd11..d1670f5 100644
20074 --- a/arch/x86/kernel/head_32.S
20075 +++ b/arch/x86/kernel/head_32.S
20076 @@ -26,6 +26,12 @@
20077 /* Physical address */
20078 #define pa(X) ((X) - __PAGE_OFFSET)
20079
20080 +#ifdef CONFIG_PAX_KERNEXEC
20081 +#define ta(X) (X)
20082 +#else
20083 +#define ta(X) ((X) - __PAGE_OFFSET)
20084 +#endif
20085 +
20086 /*
20087 * References to members of the new_cpu_data structure.
20088 */
20089 @@ -55,11 +61,7 @@
20090 * and small than max_low_pfn, otherwise will waste some page table entries
20091 */
20092
20093 -#if PTRS_PER_PMD > 1
20094 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
20095 -#else
20096 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
20097 -#endif
20098 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
20099
20100 /* Number of possible pages in the lowmem region */
20101 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
20102 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
20103 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20104
20105 /*
20106 + * Real beginning of normal "text" segment
20107 + */
20108 +ENTRY(stext)
20109 +ENTRY(_stext)
20110 +
20111 +/*
20112 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20113 * %esi points to the real-mode code as a 32-bit pointer.
20114 * CS and DS must be 4 GB flat segments, but we don't depend on
20115 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20116 * can.
20117 */
20118 __HEAD
20119 +
20120 +#ifdef CONFIG_PAX_KERNEXEC
20121 + jmp startup_32
20122 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20123 +.fill PAGE_SIZE-5,1,0xcc
20124 +#endif
20125 +
20126 ENTRY(startup_32)
20127 movl pa(stack_start),%ecx
20128
20129 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20130 2:
20131 leal -__PAGE_OFFSET(%ecx),%esp
20132
20133 +#ifdef CONFIG_SMP
20134 + movl $pa(cpu_gdt_table),%edi
20135 + movl $__per_cpu_load,%eax
20136 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20137 + rorl $16,%eax
20138 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20139 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20140 + movl $__per_cpu_end - 1,%eax
20141 + subl $__per_cpu_start,%eax
20142 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20143 +#endif
20144 +
20145 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20146 + movl $NR_CPUS,%ecx
20147 + movl $pa(cpu_gdt_table),%edi
20148 +1:
20149 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20150 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20151 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20152 + addl $PAGE_SIZE_asm,%edi
20153 + loop 1b
20154 +#endif
20155 +
20156 +#ifdef CONFIG_PAX_KERNEXEC
20157 + movl $pa(boot_gdt),%edi
20158 + movl $__LOAD_PHYSICAL_ADDR,%eax
20159 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20160 + rorl $16,%eax
20161 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20162 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20163 + rorl $16,%eax
20164 +
20165 + ljmp $(__BOOT_CS),$1f
20166 +1:
20167 +
20168 + movl $NR_CPUS,%ecx
20169 + movl $pa(cpu_gdt_table),%edi
20170 + addl $__PAGE_OFFSET,%eax
20171 +1:
20172 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20173 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20174 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20175 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20176 + rorl $16,%eax
20177 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20178 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20179 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20180 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20181 + rorl $16,%eax
20182 + addl $PAGE_SIZE_asm,%edi
20183 + loop 1b
20184 +#endif
20185 +
20186 /*
20187 * Clear BSS first so that there are no surprises...
20188 */
20189 @@ -201,8 +269,11 @@ ENTRY(startup_32)
20190 movl %eax, pa(max_pfn_mapped)
20191
20192 /* Do early initialization of the fixmap area */
20193 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20194 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20195 +#ifdef CONFIG_COMPAT_VDSO
20196 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20197 +#else
20198 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20199 +#endif
20200 #else /* Not PAE */
20201
20202 page_pde_offset = (__PAGE_OFFSET >> 20);
20203 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20204 movl %eax, pa(max_pfn_mapped)
20205
20206 /* Do early initialization of the fixmap area */
20207 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20208 - movl %eax,pa(initial_page_table+0xffc)
20209 +#ifdef CONFIG_COMPAT_VDSO
20210 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20211 +#else
20212 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20213 +#endif
20214 #endif
20215
20216 #ifdef CONFIG_PARAVIRT
20217 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20218 cmpl $num_subarch_entries, %eax
20219 jae bad_subarch
20220
20221 - movl pa(subarch_entries)(,%eax,4), %eax
20222 - subl $__PAGE_OFFSET, %eax
20223 - jmp *%eax
20224 + jmp *pa(subarch_entries)(,%eax,4)
20225
20226 bad_subarch:
20227 WEAK(lguest_entry)
20228 @@ -261,10 +333,10 @@ WEAK(xen_entry)
20229 __INITDATA
20230
20231 subarch_entries:
20232 - .long default_entry /* normal x86/PC */
20233 - .long lguest_entry /* lguest hypervisor */
20234 - .long xen_entry /* Xen hypervisor */
20235 - .long default_entry /* Moorestown MID */
20236 + .long ta(default_entry) /* normal x86/PC */
20237 + .long ta(lguest_entry) /* lguest hypervisor */
20238 + .long ta(xen_entry) /* Xen hypervisor */
20239 + .long ta(default_entry) /* Moorestown MID */
20240 num_subarch_entries = (. - subarch_entries) / 4
20241 .previous
20242 #else
20243 @@ -355,6 +427,7 @@ default_entry:
20244 movl pa(mmu_cr4_features),%eax
20245 movl %eax,%cr4
20246
20247 +#ifdef CONFIG_X86_PAE
20248 testb $X86_CR4_PAE, %al # check if PAE is enabled
20249 jz enable_paging
20250
20251 @@ -383,6 +456,9 @@ default_entry:
20252 /* Make changes effective */
20253 wrmsr
20254
20255 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20256 +#endif
20257 +
20258 enable_paging:
20259
20260 /*
20261 @@ -451,14 +527,20 @@ is486:
20262 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20263 movl %eax,%ss # after changing gdt.
20264
20265 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20266 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20267 movl %eax,%ds
20268 movl %eax,%es
20269
20270 movl $(__KERNEL_PERCPU), %eax
20271 movl %eax,%fs # set this cpu's percpu
20272
20273 +#ifdef CONFIG_CC_STACKPROTECTOR
20274 movl $(__KERNEL_STACK_CANARY),%eax
20275 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20276 + movl $(__USER_DS),%eax
20277 +#else
20278 + xorl %eax,%eax
20279 +#endif
20280 movl %eax,%gs
20281
20282 xorl %eax,%eax # Clear LDT
20283 @@ -534,8 +616,11 @@ setup_once:
20284 * relocation. Manually set base address in stack canary
20285 * segment descriptor.
20286 */
20287 - movl $gdt_page,%eax
20288 + movl $cpu_gdt_table,%eax
20289 movl $stack_canary,%ecx
20290 +#ifdef CONFIG_SMP
20291 + addl $__per_cpu_load,%ecx
20292 +#endif
20293 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20294 shrl $16, %ecx
20295 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20296 @@ -566,7 +651,7 @@ ENDPROC(early_idt_handlers)
20297 /* This is global to keep gas from relaxing the jumps */
20298 ENTRY(early_idt_handler)
20299 cld
20300 - cmpl $2,%ss:early_recursion_flag
20301 + cmpl $1,%ss:early_recursion_flag
20302 je hlt_loop
20303 incl %ss:early_recursion_flag
20304
20305 @@ -604,8 +689,8 @@ ENTRY(early_idt_handler)
20306 pushl (20+6*4)(%esp) /* trapno */
20307 pushl $fault_msg
20308 call printk
20309 -#endif
20310 call dump_stack
20311 +#endif
20312 hlt_loop:
20313 hlt
20314 jmp hlt_loop
20315 @@ -624,8 +709,11 @@ ENDPROC(early_idt_handler)
20316 /* This is the default interrupt "handler" :-) */
20317 ALIGN
20318 ignore_int:
20319 - cld
20320 #ifdef CONFIG_PRINTK
20321 + cmpl $2,%ss:early_recursion_flag
20322 + je hlt_loop
20323 + incl %ss:early_recursion_flag
20324 + cld
20325 pushl %eax
20326 pushl %ecx
20327 pushl %edx
20328 @@ -634,9 +722,6 @@ ignore_int:
20329 movl $(__KERNEL_DS),%eax
20330 movl %eax,%ds
20331 movl %eax,%es
20332 - cmpl $2,early_recursion_flag
20333 - je hlt_loop
20334 - incl early_recursion_flag
20335 pushl 16(%esp)
20336 pushl 24(%esp)
20337 pushl 32(%esp)
20338 @@ -670,29 +755,43 @@ ENTRY(setup_once_ref)
20339 /*
20340 * BSS section
20341 */
20342 -__PAGE_ALIGNED_BSS
20343 - .align PAGE_SIZE
20344 #ifdef CONFIG_X86_PAE
20345 +.section .initial_pg_pmd,"a",@progbits
20346 initial_pg_pmd:
20347 .fill 1024*KPMDS,4,0
20348 #else
20349 +.section .initial_page_table,"a",@progbits
20350 ENTRY(initial_page_table)
20351 .fill 1024,4,0
20352 #endif
20353 +.section .initial_pg_fixmap,"a",@progbits
20354 initial_pg_fixmap:
20355 .fill 1024,4,0
20356 +.section .empty_zero_page,"a",@progbits
20357 ENTRY(empty_zero_page)
20358 .fill 4096,1,0
20359 +.section .swapper_pg_dir,"a",@progbits
20360 ENTRY(swapper_pg_dir)
20361 +#ifdef CONFIG_X86_PAE
20362 + .fill 4,8,0
20363 +#else
20364 .fill 1024,4,0
20365 +#endif
20366 +
20367 +/*
20368 + * The IDT has to be page-aligned to simplify the Pentium
20369 + * F0 0F bug workaround.. We have a special link segment
20370 + * for this.
20371 + */
20372 +.section .idt,"a",@progbits
20373 +ENTRY(idt_table)
20374 + .fill 256,8,0
20375
20376 /*
20377 * This starts the data section.
20378 */
20379 #ifdef CONFIG_X86_PAE
20380 -__PAGE_ALIGNED_DATA
20381 - /* Page-aligned for the benefit of paravirt? */
20382 - .align PAGE_SIZE
20383 +.section .initial_page_table,"a",@progbits
20384 ENTRY(initial_page_table)
20385 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20386 # if KPMDS == 3
20387 @@ -711,12 +810,20 @@ ENTRY(initial_page_table)
20388 # error "Kernel PMDs should be 1, 2 or 3"
20389 # endif
20390 .align PAGE_SIZE /* needs to be page-sized too */
20391 +
20392 +#ifdef CONFIG_PAX_PER_CPU_PGD
20393 +ENTRY(cpu_pgd)
20394 + .rept NR_CPUS
20395 + .fill 4,8,0
20396 + .endr
20397 +#endif
20398 +
20399 #endif
20400
20401 .data
20402 .balign 4
20403 ENTRY(stack_start)
20404 - .long init_thread_union+THREAD_SIZE
20405 + .long init_thread_union+THREAD_SIZE-8
20406
20407 __INITRODATA
20408 int_msg:
20409 @@ -744,7 +851,7 @@ fault_msg:
20410 * segment size, and 32-bit linear address value:
20411 */
20412
20413 - .data
20414 +.section .rodata,"a",@progbits
20415 .globl boot_gdt_descr
20416 .globl idt_descr
20417
20418 @@ -753,7 +860,7 @@ fault_msg:
20419 .word 0 # 32 bit align gdt_desc.address
20420 boot_gdt_descr:
20421 .word __BOOT_DS+7
20422 - .long boot_gdt - __PAGE_OFFSET
20423 + .long pa(boot_gdt)
20424
20425 .word 0 # 32-bit align idt_desc.address
20426 idt_descr:
20427 @@ -764,7 +871,7 @@ idt_descr:
20428 .word 0 # 32 bit align gdt_desc.address
20429 ENTRY(early_gdt_descr)
20430 .word GDT_ENTRIES*8-1
20431 - .long gdt_page /* Overwritten for secondary CPUs */
20432 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20433
20434 /*
20435 * The boot_gdt must mirror the equivalent in setup.S and is
20436 @@ -773,5 +880,65 @@ ENTRY(early_gdt_descr)
20437 .align L1_CACHE_BYTES
20438 ENTRY(boot_gdt)
20439 .fill GDT_ENTRY_BOOT_CS,8,0
20440 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20441 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20442 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20443 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20444 +
20445 + .align PAGE_SIZE_asm
20446 +ENTRY(cpu_gdt_table)
20447 + .rept NR_CPUS
20448 + .quad 0x0000000000000000 /* NULL descriptor */
20449 + .quad 0x0000000000000000 /* 0x0b reserved */
20450 + .quad 0x0000000000000000 /* 0x13 reserved */
20451 + .quad 0x0000000000000000 /* 0x1b reserved */
20452 +
20453 +#ifdef CONFIG_PAX_KERNEXEC
20454 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20455 +#else
20456 + .quad 0x0000000000000000 /* 0x20 unused */
20457 +#endif
20458 +
20459 + .quad 0x0000000000000000 /* 0x28 unused */
20460 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20461 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20462 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20463 + .quad 0x0000000000000000 /* 0x4b reserved */
20464 + .quad 0x0000000000000000 /* 0x53 reserved */
20465 + .quad 0x0000000000000000 /* 0x5b reserved */
20466 +
20467 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20468 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20469 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20470 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20471 +
20472 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20473 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20474 +
20475 + /*
20476 + * Segments used for calling PnP BIOS have byte granularity.
20477 + * The code segments and data segments have fixed 64k limits,
20478 + * the transfer segment sizes are set at run time.
20479 + */
20480 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20481 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20482 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20483 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20484 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20485 +
20486 + /*
20487 + * The APM segments have byte granularity and their bases
20488 + * are set at run time. All have 64k limits.
20489 + */
20490 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20491 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20492 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20493 +
20494 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20495 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20496 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20497 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20498 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20499 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20500 +
20501 + /* Be sure this is zeroed to avoid false validations in Xen */
20502 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20503 + .endr
20504 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20505 index 08f7e80..40cbed5 100644
20506 --- a/arch/x86/kernel/head_64.S
20507 +++ b/arch/x86/kernel/head_64.S
20508 @@ -20,6 +20,8 @@
20509 #include <asm/processor-flags.h>
20510 #include <asm/percpu.h>
20511 #include <asm/nops.h>
20512 +#include <asm/cpufeature.h>
20513 +#include <asm/alternative-asm.h>
20514
20515 #ifdef CONFIG_PARAVIRT
20516 #include <asm/asm-offsets.h>
20517 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20518 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20519 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20520 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20521 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20522 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20523 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20524 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20525 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20526 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20527
20528 .text
20529 __HEAD
20530 @@ -89,11 +97,15 @@ startup_64:
20531 * Fixup the physical addresses in the page table
20532 */
20533 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
20534 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20535 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20536 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20537
20538 addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20539 addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20540
20541 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20542 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20543
20544 /*
20545 * Set up the identity mapping for the switchover. These
20546 @@ -175,8 +187,8 @@ ENTRY(secondary_startup_64)
20547 movq $(init_level4_pgt - __START_KERNEL_map), %rax
20548 1:
20549
20550 - /* Enable PAE mode and PGE */
20551 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
20552 + /* Enable PAE mode and PSE/PGE */
20553 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
20554 movq %rcx, %cr4
20555
20556 /* Setup early boot stage 4 level pagetables. */
20557 @@ -197,10 +209,18 @@ ENTRY(secondary_startup_64)
20558 movl $MSR_EFER, %ecx
20559 rdmsr
20560 btsl $_EFER_SCE, %eax /* Enable System Call */
20561 - btl $20,%edi /* No Execute supported? */
20562 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20563 jnc 1f
20564 btsl $_EFER_NX, %eax
20565 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
20566 + leaq init_level4_pgt(%rip), %rdi
20567 +#ifndef CONFIG_EFI
20568 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20569 +#endif
20570 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20571 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20572 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20573 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20574 1: wrmsr /* Make changes effective */
20575
20576 /* Setup cr0 */
20577 @@ -280,6 +300,7 @@ ENTRY(secondary_startup_64)
20578 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
20579 * address given in m16:64.
20580 */
20581 + pax_set_fptr_mask
20582 movq initial_code(%rip),%rax
20583 pushq $0 # fake return address to stop unwinder
20584 pushq $__KERNEL_CS # set correct cs
20585 @@ -386,7 +407,7 @@ ENTRY(early_idt_handler)
20586 call dump_stack
20587 #ifdef CONFIG_KALLSYMS
20588 leaq early_idt_ripmsg(%rip),%rdi
20589 - movq 40(%rsp),%rsi # %rip again
20590 + movq 88(%rsp),%rsi # %rip again
20591 call __print_symbol
20592 #endif
20593 #endif /* EARLY_PRINTK */
20594 @@ -414,6 +435,7 @@ ENDPROC(early_idt_handler)
20595 early_recursion_flag:
20596 .long 0
20597
20598 + .section .rodata,"a",@progbits
20599 #ifdef CONFIG_EARLY_PRINTK
20600 early_idt_msg:
20601 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20602 @@ -443,27 +465,50 @@ NEXT_PAGE(early_dynamic_pgts)
20603
20604 .data
20605
20606 -#ifndef CONFIG_XEN
20607 NEXT_PAGE(init_level4_pgt)
20608 - .fill 512,8,0
20609 -#else
20610 -NEXT_PAGE(init_level4_pgt)
20611 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20612 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
20613 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20614 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
20615 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
20616 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
20617 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
20618 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
20619 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20620 .org init_level4_pgt + L4_START_KERNEL*8, 0
20621 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
20622 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
20623
20624 +#ifdef CONFIG_PAX_PER_CPU_PGD
20625 +NEXT_PAGE(cpu_pgd)
20626 + .rept NR_CPUS
20627 + .fill 512,8,0
20628 + .endr
20629 +#endif
20630 +
20631 NEXT_PAGE(level3_ident_pgt)
20632 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20633 +#ifdef CONFIG_XEN
20634 .fill 511, 8, 0
20635 +#else
20636 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
20637 + .fill 510,8,0
20638 +#endif
20639 +
20640 +NEXT_PAGE(level3_vmalloc_start_pgt)
20641 + .fill 512,8,0
20642 +
20643 +NEXT_PAGE(level3_vmalloc_end_pgt)
20644 + .fill 512,8,0
20645 +
20646 +NEXT_PAGE(level3_vmemmap_pgt)
20647 + .fill L3_VMEMMAP_START,8,0
20648 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20649 +
20650 NEXT_PAGE(level2_ident_pgt)
20651 - /* Since I easily can, map the first 1G.
20652 + /* Since I easily can, map the first 2G.
20653 * Don't set NX because code runs from these pages.
20654 */
20655 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
20656 -#endif
20657 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
20658
20659 NEXT_PAGE(level3_kernel_pgt)
20660 .fill L3_START_KERNEL,8,0
20661 @@ -471,6 +516,9 @@ NEXT_PAGE(level3_kernel_pgt)
20662 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
20663 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20664
20665 +NEXT_PAGE(level2_vmemmap_pgt)
20666 + .fill 512,8,0
20667 +
20668 NEXT_PAGE(level2_kernel_pgt)
20669 /*
20670 * 512 MB kernel mapping. We spend a full page on this pagetable
20671 @@ -486,38 +534,64 @@ NEXT_PAGE(level2_kernel_pgt)
20672 KERNEL_IMAGE_SIZE/PMD_SIZE)
20673
20674 NEXT_PAGE(level2_fixmap_pgt)
20675 - .fill 506,8,0
20676 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20677 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
20678 - .fill 5,8,0
20679 + .fill 507,8,0
20680 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
20681 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
20682 + .fill 4,8,0
20683
20684 -NEXT_PAGE(level1_fixmap_pgt)
20685 +NEXT_PAGE(level1_vsyscall_pgt)
20686 .fill 512,8,0
20687
20688 #undef PMDS
20689
20690 - .data
20691 + .align PAGE_SIZE
20692 +ENTRY(cpu_gdt_table)
20693 + .rept NR_CPUS
20694 + .quad 0x0000000000000000 /* NULL descriptor */
20695 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
20696 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
20697 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
20698 + .quad 0x00cffb000000ffff /* __USER32_CS */
20699 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
20700 + .quad 0x00affb000000ffff /* __USER_CS */
20701 +
20702 +#ifdef CONFIG_PAX_KERNEXEC
20703 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
20704 +#else
20705 + .quad 0x0 /* unused */
20706 +#endif
20707 +
20708 + .quad 0,0 /* TSS */
20709 + .quad 0,0 /* LDT */
20710 + .quad 0,0,0 /* three TLS descriptors */
20711 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
20712 + /* asm/segment.h:GDT_ENTRIES must match this */
20713 +
20714 + /* zero the remaining page */
20715 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
20716 + .endr
20717 +
20718 .align 16
20719 .globl early_gdt_descr
20720 early_gdt_descr:
20721 .word GDT_ENTRIES*8-1
20722 early_gdt_descr_base:
20723 - .quad INIT_PER_CPU_VAR(gdt_page)
20724 + .quad cpu_gdt_table
20725
20726 ENTRY(phys_base)
20727 /* This must match the first entry in level2_kernel_pgt */
20728 .quad 0x0000000000000000
20729
20730 #include "../../x86/xen/xen-head.S"
20731 -
20732 - .section .bss, "aw", @nobits
20733 +
20734 + .section .rodata,"a",@progbits
20735 .align L1_CACHE_BYTES
20736 ENTRY(idt_table)
20737 - .skip IDT_ENTRIES * 16
20738 + .fill 512,8,0
20739
20740 .align L1_CACHE_BYTES
20741 ENTRY(nmi_idt_table)
20742 - .skip IDT_ENTRIES * 16
20743 + .fill 512,8,0
20744
20745 __PAGE_ALIGNED_BSS
20746 NEXT_PAGE(empty_zero_page)
20747 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
20748 index 0fa6912..37fce70 100644
20749 --- a/arch/x86/kernel/i386_ksyms_32.c
20750 +++ b/arch/x86/kernel/i386_ksyms_32.c
20751 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
20752 EXPORT_SYMBOL(cmpxchg8b_emu);
20753 #endif
20754
20755 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
20756 +
20757 /* Networking helper routines. */
20758 EXPORT_SYMBOL(csum_partial_copy_generic);
20759 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
20760 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
20761
20762 EXPORT_SYMBOL(__get_user_1);
20763 EXPORT_SYMBOL(__get_user_2);
20764 @@ -37,3 +41,7 @@ EXPORT_SYMBOL(strstr);
20765
20766 EXPORT_SYMBOL(csum_partial);
20767 EXPORT_SYMBOL(empty_zero_page);
20768 +
20769 +#ifdef CONFIG_PAX_KERNEXEC
20770 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
20771 +#endif
20772 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
20773 index 245a71d..89d9ce4 100644
20774 --- a/arch/x86/kernel/i387.c
20775 +++ b/arch/x86/kernel/i387.c
20776 @@ -55,7 +55,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
20777 static inline bool interrupted_user_mode(void)
20778 {
20779 struct pt_regs *regs = get_irq_regs();
20780 - return regs && user_mode_vm(regs);
20781 + return regs && user_mode(regs);
20782 }
20783
20784 /*
20785 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
20786 index 9a5c460..84868423 100644
20787 --- a/arch/x86/kernel/i8259.c
20788 +++ b/arch/x86/kernel/i8259.c
20789 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
20790 static void make_8259A_irq(unsigned int irq)
20791 {
20792 disable_irq_nosync(irq);
20793 - io_apic_irqs &= ~(1<<irq);
20794 + io_apic_irqs &= ~(1UL<<irq);
20795 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
20796 i8259A_chip.name);
20797 enable_irq(irq);
20798 @@ -209,7 +209,7 @@ spurious_8259A_irq:
20799 "spurious 8259A interrupt: IRQ%d.\n", irq);
20800 spurious_irq_mask |= irqmask;
20801 }
20802 - atomic_inc(&irq_err_count);
20803 + atomic_inc_unchecked(&irq_err_count);
20804 /*
20805 * Theoretically we do not have to handle this IRQ,
20806 * but in Linux this does not cause problems and is
20807 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
20808 /* (slave's support for AEOI in flat mode is to be investigated) */
20809 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
20810
20811 + pax_open_kernel();
20812 if (auto_eoi)
20813 /*
20814 * In AEOI mode we just have to mask the interrupt
20815 * when acking.
20816 */
20817 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
20818 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
20819 else
20820 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20821 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20822 + pax_close_kernel();
20823
20824 udelay(100); /* wait for 8259A to initialize */
20825
20826 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
20827 index a979b5b..1d6db75 100644
20828 --- a/arch/x86/kernel/io_delay.c
20829 +++ b/arch/x86/kernel/io_delay.c
20830 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
20831 * Quirk table for systems that misbehave (lock up, etc.) if port
20832 * 0x80 is used:
20833 */
20834 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
20835 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
20836 {
20837 .callback = dmi_io_delay_0xed_port,
20838 .ident = "Compaq Presario V6000",
20839 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
20840 index 4ddaf66..6292f4e 100644
20841 --- a/arch/x86/kernel/ioport.c
20842 +++ b/arch/x86/kernel/ioport.c
20843 @@ -6,6 +6,7 @@
20844 #include <linux/sched.h>
20845 #include <linux/kernel.h>
20846 #include <linux/capability.h>
20847 +#include <linux/security.h>
20848 #include <linux/errno.h>
20849 #include <linux/types.h>
20850 #include <linux/ioport.h>
20851 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20852
20853 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
20854 return -EINVAL;
20855 +#ifdef CONFIG_GRKERNSEC_IO
20856 + if (turn_on && grsec_disable_privio) {
20857 + gr_handle_ioperm();
20858 + return -EPERM;
20859 + }
20860 +#endif
20861 if (turn_on && !capable(CAP_SYS_RAWIO))
20862 return -EPERM;
20863
20864 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20865 * because the ->io_bitmap_max value must match the bitmap
20866 * contents:
20867 */
20868 - tss = &per_cpu(init_tss, get_cpu());
20869 + tss = init_tss + get_cpu();
20870
20871 if (turn_on)
20872 bitmap_clear(t->io_bitmap_ptr, from, num);
20873 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
20874 return -EINVAL;
20875 /* Trying to gain more privileges? */
20876 if (level > old) {
20877 +#ifdef CONFIG_GRKERNSEC_IO
20878 + if (grsec_disable_privio) {
20879 + gr_handle_iopl();
20880 + return -EPERM;
20881 + }
20882 +#endif
20883 if (!capable(CAP_SYS_RAWIO))
20884 return -EPERM;
20885 }
20886 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
20887 index 84b7789..e65e8be 100644
20888 --- a/arch/x86/kernel/irq.c
20889 +++ b/arch/x86/kernel/irq.c
20890 @@ -18,7 +18,7 @@
20891 #include <asm/mce.h>
20892 #include <asm/hw_irq.h>
20893
20894 -atomic_t irq_err_count;
20895 +atomic_unchecked_t irq_err_count;
20896
20897 /* Function pointer for generic interrupt vector handling */
20898 void (*x86_platform_ipi_callback)(void) = NULL;
20899 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
20900 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
20901 seq_printf(p, " Machine check polls\n");
20902 #endif
20903 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
20904 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
20905 #if defined(CONFIG_X86_IO_APIC)
20906 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
20907 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
20908 #endif
20909 return 0;
20910 }
20911 @@ -164,7 +164,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
20912
20913 u64 arch_irq_stat(void)
20914 {
20915 - u64 sum = atomic_read(&irq_err_count);
20916 + u64 sum = atomic_read_unchecked(&irq_err_count);
20917 return sum;
20918 }
20919
20920 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
20921 index 344faf8..355f60d 100644
20922 --- a/arch/x86/kernel/irq_32.c
20923 +++ b/arch/x86/kernel/irq_32.c
20924 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
20925 __asm__ __volatile__("andl %%esp,%0" :
20926 "=r" (sp) : "0" (THREAD_SIZE - 1));
20927
20928 - return sp < (sizeof(struct thread_info) + STACK_WARN);
20929 + return sp < STACK_WARN;
20930 }
20931
20932 static void print_stack_overflow(void)
20933 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
20934 * per-CPU IRQ handling contexts (thread information and stack)
20935 */
20936 union irq_ctx {
20937 - struct thread_info tinfo;
20938 - u32 stack[THREAD_SIZE/sizeof(u32)];
20939 + unsigned long previous_esp;
20940 + u32 stack[THREAD_SIZE/sizeof(u32)];
20941 } __attribute__((aligned(THREAD_SIZE)));
20942
20943 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
20944 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
20945 static inline int
20946 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20947 {
20948 - union irq_ctx *curctx, *irqctx;
20949 + union irq_ctx *irqctx;
20950 u32 *isp, arg1, arg2;
20951
20952 - curctx = (union irq_ctx *) current_thread_info();
20953 irqctx = __this_cpu_read(hardirq_ctx);
20954
20955 /*
20956 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20957 * handler) we can't do that and just have to keep using the
20958 * current stack (which is the irq stack already after all)
20959 */
20960 - if (unlikely(curctx == irqctx))
20961 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
20962 return 0;
20963
20964 /* build the stack frame on the IRQ stack */
20965 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
20966 - irqctx->tinfo.task = curctx->tinfo.task;
20967 - irqctx->tinfo.previous_esp = current_stack_pointer;
20968 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
20969 + irqctx->previous_esp = current_stack_pointer;
20970
20971 - /* Copy the preempt_count so that the [soft]irq checks work. */
20972 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
20973 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20974 + __set_fs(MAKE_MM_SEG(0));
20975 +#endif
20976
20977 if (unlikely(overflow))
20978 call_on_stack(print_stack_overflow, isp);
20979 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20980 : "0" (irq), "1" (desc), "2" (isp),
20981 "D" (desc->handle_irq)
20982 : "memory", "cc", "ecx");
20983 +
20984 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20985 + __set_fs(current_thread_info()->addr_limit);
20986 +#endif
20987 +
20988 return 1;
20989 }
20990
20991 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
20992 */
20993 void __cpuinit irq_ctx_init(int cpu)
20994 {
20995 - union irq_ctx *irqctx;
20996 -
20997 if (per_cpu(hardirq_ctx, cpu))
20998 return;
20999
21000 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21001 - THREADINFO_GFP,
21002 - THREAD_SIZE_ORDER));
21003 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21004 - irqctx->tinfo.cpu = cpu;
21005 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
21006 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21007 -
21008 - per_cpu(hardirq_ctx, cpu) = irqctx;
21009 -
21010 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21011 - THREADINFO_GFP,
21012 - THREAD_SIZE_ORDER));
21013 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21014 - irqctx->tinfo.cpu = cpu;
21015 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21016 -
21017 - per_cpu(softirq_ctx, cpu) = irqctx;
21018 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21019 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21020 +
21021 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21022 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21023
21024 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21025 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21026 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
21027 asmlinkage void do_softirq(void)
21028 {
21029 unsigned long flags;
21030 - struct thread_info *curctx;
21031 union irq_ctx *irqctx;
21032 u32 *isp;
21033
21034 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
21035 local_irq_save(flags);
21036
21037 if (local_softirq_pending()) {
21038 - curctx = current_thread_info();
21039 irqctx = __this_cpu_read(softirq_ctx);
21040 - irqctx->tinfo.task = curctx->task;
21041 - irqctx->tinfo.previous_esp = current_stack_pointer;
21042 + irqctx->previous_esp = current_stack_pointer;
21043
21044 /* build the stack frame on the softirq stack */
21045 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21046 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21047 +
21048 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21049 + __set_fs(MAKE_MM_SEG(0));
21050 +#endif
21051
21052 call_on_stack(__do_softirq, isp);
21053 +
21054 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21055 + __set_fs(current_thread_info()->addr_limit);
21056 +#endif
21057 +
21058 /*
21059 * Shouldn't happen, we returned above if in_interrupt():
21060 */
21061 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
21062 if (unlikely(!desc))
21063 return false;
21064
21065 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21066 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21067 if (unlikely(overflow))
21068 print_stack_overflow();
21069 desc->handle_irq(irq, desc);
21070 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
21071 index d04d3ec..ea4b374 100644
21072 --- a/arch/x86/kernel/irq_64.c
21073 +++ b/arch/x86/kernel/irq_64.c
21074 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21075 u64 estack_top, estack_bottom;
21076 u64 curbase = (u64)task_stack_page(current);
21077
21078 - if (user_mode_vm(regs))
21079 + if (user_mode(regs))
21080 return;
21081
21082 if (regs->sp >= curbase + sizeof(struct thread_info) +
21083 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21084 index dc1404b..bbc43e7 100644
21085 --- a/arch/x86/kernel/kdebugfs.c
21086 +++ b/arch/x86/kernel/kdebugfs.c
21087 @@ -27,7 +27,7 @@ struct setup_data_node {
21088 u32 len;
21089 };
21090
21091 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21092 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21093 size_t count, loff_t *ppos)
21094 {
21095 struct setup_data_node *node = file->private_data;
21096 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21097 index 836f832..a8bda67 100644
21098 --- a/arch/x86/kernel/kgdb.c
21099 +++ b/arch/x86/kernel/kgdb.c
21100 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21101 #ifdef CONFIG_X86_32
21102 switch (regno) {
21103 case GDB_SS:
21104 - if (!user_mode_vm(regs))
21105 + if (!user_mode(regs))
21106 *(unsigned long *)mem = __KERNEL_DS;
21107 break;
21108 case GDB_SP:
21109 - if (!user_mode_vm(regs))
21110 + if (!user_mode(regs))
21111 *(unsigned long *)mem = kernel_stack_pointer(regs);
21112 break;
21113 case GDB_GS:
21114 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21115 bp->attr.bp_addr = breakinfo[breakno].addr;
21116 bp->attr.bp_len = breakinfo[breakno].len;
21117 bp->attr.bp_type = breakinfo[breakno].type;
21118 - info->address = breakinfo[breakno].addr;
21119 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21120 + info->address = ktla_ktva(breakinfo[breakno].addr);
21121 + else
21122 + info->address = breakinfo[breakno].addr;
21123 info->len = breakinfo[breakno].len;
21124 info->type = breakinfo[breakno].type;
21125 val = arch_install_hw_breakpoint(bp);
21126 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21127 case 'k':
21128 /* clear the trace bit */
21129 linux_regs->flags &= ~X86_EFLAGS_TF;
21130 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21131 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21132
21133 /* set the trace bit if we're stepping */
21134 if (remcomInBuffer[0] == 's') {
21135 linux_regs->flags |= X86_EFLAGS_TF;
21136 - atomic_set(&kgdb_cpu_doing_single_step,
21137 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21138 raw_smp_processor_id());
21139 }
21140
21141 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21142
21143 switch (cmd) {
21144 case DIE_DEBUG:
21145 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21146 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21147 if (user_mode(regs))
21148 return single_step_cont(regs, args);
21149 break;
21150 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21151 #endif /* CONFIG_DEBUG_RODATA */
21152
21153 bpt->type = BP_BREAKPOINT;
21154 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21155 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21156 BREAK_INSTR_SIZE);
21157 if (err)
21158 return err;
21159 - err = probe_kernel_write((char *)bpt->bpt_addr,
21160 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21161 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21162 #ifdef CONFIG_DEBUG_RODATA
21163 if (!err)
21164 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21165 return -EBUSY;
21166 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21167 BREAK_INSTR_SIZE);
21168 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21169 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21170 if (err)
21171 return err;
21172 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21173 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21174 if (mutex_is_locked(&text_mutex))
21175 goto knl_write;
21176 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21177 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21178 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21179 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21180 goto knl_write;
21181 return err;
21182 knl_write:
21183 #endif /* CONFIG_DEBUG_RODATA */
21184 - return probe_kernel_write((char *)bpt->bpt_addr,
21185 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21186 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21187 }
21188
21189 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
21190 index 7bfe318..383d238 100644
21191 --- a/arch/x86/kernel/kprobes/core.c
21192 +++ b/arch/x86/kernel/kprobes/core.c
21193 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21194 s32 raddr;
21195 } __packed *insn;
21196
21197 - insn = (struct __arch_relative_insn *)from;
21198 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21199 +
21200 + pax_open_kernel();
21201 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21202 insn->op = op;
21203 + pax_close_kernel();
21204 }
21205
21206 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21207 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21208 kprobe_opcode_t opcode;
21209 kprobe_opcode_t *orig_opcodes = opcodes;
21210
21211 - if (search_exception_tables((unsigned long)opcodes))
21212 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21213 return 0; /* Page fault may occur on this address. */
21214
21215 retry:
21216 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21217 * for the first byte, we can recover the original instruction
21218 * from it and kp->opcode.
21219 */
21220 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21221 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21222 buf[0] = kp->opcode;
21223 - return (unsigned long)buf;
21224 + return ktva_ktla((unsigned long)buf);
21225 }
21226
21227 /*
21228 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21229 /* Another subsystem puts a breakpoint, failed to recover */
21230 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21231 return 0;
21232 + pax_open_kernel();
21233 memcpy(dest, insn.kaddr, insn.length);
21234 + pax_close_kernel();
21235
21236 #ifdef CONFIG_X86_64
21237 if (insn_rip_relative(&insn)) {
21238 @@ -355,7 +360,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21239 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
21240 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
21241 disp = (u8 *) dest + insn_offset_displacement(&insn);
21242 + pax_open_kernel();
21243 *(s32 *) disp = (s32) newdisp;
21244 + pax_close_kernel();
21245 }
21246 #endif
21247 return insn.length;
21248 @@ -488,7 +495,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21249 * nor set current_kprobe, because it doesn't use single
21250 * stepping.
21251 */
21252 - regs->ip = (unsigned long)p->ainsn.insn;
21253 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21254 preempt_enable_no_resched();
21255 return;
21256 }
21257 @@ -505,9 +512,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21258 regs->flags &= ~X86_EFLAGS_IF;
21259 /* single step inline if the instruction is an int3 */
21260 if (p->opcode == BREAKPOINT_INSTRUCTION)
21261 - regs->ip = (unsigned long)p->addr;
21262 + regs->ip = ktla_ktva((unsigned long)p->addr);
21263 else
21264 - regs->ip = (unsigned long)p->ainsn.insn;
21265 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21266 }
21267
21268 /*
21269 @@ -586,7 +593,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21270 setup_singlestep(p, regs, kcb, 0);
21271 return 1;
21272 }
21273 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21274 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21275 /*
21276 * The breakpoint instruction was removed right
21277 * after we hit it. Another cpu has removed
21278 @@ -632,6 +639,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21279 " movq %rax, 152(%rsp)\n"
21280 RESTORE_REGS_STRING
21281 " popfq\n"
21282 +#ifdef KERNEXEC_PLUGIN
21283 + " btsq $63,(%rsp)\n"
21284 +#endif
21285 #else
21286 " pushf\n"
21287 SAVE_REGS_STRING
21288 @@ -769,7 +779,7 @@ static void __kprobes
21289 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21290 {
21291 unsigned long *tos = stack_addr(regs);
21292 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21293 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21294 unsigned long orig_ip = (unsigned long)p->addr;
21295 kprobe_opcode_t *insn = p->ainsn.insn;
21296
21297 @@ -951,7 +961,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21298 struct die_args *args = data;
21299 int ret = NOTIFY_DONE;
21300
21301 - if (args->regs && user_mode_vm(args->regs))
21302 + if (args->regs && user_mode(args->regs))
21303 return ret;
21304
21305 switch (val) {
21306 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
21307 index 76dc6f0..66bdfc3 100644
21308 --- a/arch/x86/kernel/kprobes/opt.c
21309 +++ b/arch/x86/kernel/kprobes/opt.c
21310 @@ -79,6 +79,7 @@ found:
21311 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
21312 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
21313 {
21314 + pax_open_kernel();
21315 #ifdef CONFIG_X86_64
21316 *addr++ = 0x48;
21317 *addr++ = 0xbf;
21318 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
21319 *addr++ = 0xb8;
21320 #endif
21321 *(unsigned long *)addr = val;
21322 + pax_close_kernel();
21323 }
21324
21325 static void __used __kprobes kprobes_optinsn_template_holder(void)
21326 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21327 * Verify if the address gap is in 2GB range, because this uses
21328 * a relative jump.
21329 */
21330 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21331 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21332 if (abs(rel) > 0x7fffffff)
21333 return -ERANGE;
21334
21335 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21336 op->optinsn.size = ret;
21337
21338 /* Copy arch-dep-instance from template */
21339 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21340 + pax_open_kernel();
21341 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21342 + pax_close_kernel();
21343
21344 /* Set probe information */
21345 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21346
21347 /* Set probe function call */
21348 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21349 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21350
21351 /* Set returning jmp instruction at the tail of out-of-line buffer */
21352 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21353 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21354 (u8 *)op->kp.addr + op->optinsn.size);
21355
21356 flush_icache_range((unsigned long) buf,
21357 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21358 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21359
21360 /* Backup instructions which will be replaced by jump address */
21361 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21362 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21363 RELATIVE_ADDR_SIZE);
21364
21365 insn_buf[0] = RELATIVEJUMP_OPCODE;
21366 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21367 /* This kprobe is really able to run optimized path. */
21368 op = container_of(p, struct optimized_kprobe, kp);
21369 /* Detour through copied instructions */
21370 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21371 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21372 if (!reenter)
21373 reset_current_kprobe();
21374 preempt_enable_no_resched();
21375 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21376 index b686a90..60d36fb 100644
21377 --- a/arch/x86/kernel/kvm.c
21378 +++ b/arch/x86/kernel/kvm.c
21379 @@ -453,7 +453,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21380 return NOTIFY_OK;
21381 }
21382
21383 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21384 +static struct notifier_block kvm_cpu_notifier = {
21385 .notifier_call = kvm_cpu_notify,
21386 };
21387 #endif
21388 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21389 index ebc9873..1b9724b 100644
21390 --- a/arch/x86/kernel/ldt.c
21391 +++ b/arch/x86/kernel/ldt.c
21392 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21393 if (reload) {
21394 #ifdef CONFIG_SMP
21395 preempt_disable();
21396 - load_LDT(pc);
21397 + load_LDT_nolock(pc);
21398 if (!cpumask_equal(mm_cpumask(current->mm),
21399 cpumask_of(smp_processor_id())))
21400 smp_call_function(flush_ldt, current->mm, 1);
21401 preempt_enable();
21402 #else
21403 - load_LDT(pc);
21404 + load_LDT_nolock(pc);
21405 #endif
21406 }
21407 if (oldsize) {
21408 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21409 return err;
21410
21411 for (i = 0; i < old->size; i++)
21412 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21413 + write_ldt_entry(new->ldt, i, old->ldt + i);
21414 return 0;
21415 }
21416
21417 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21418 retval = copy_ldt(&mm->context, &old_mm->context);
21419 mutex_unlock(&old_mm->context.lock);
21420 }
21421 +
21422 + if (tsk == current) {
21423 + mm->context.vdso = 0;
21424 +
21425 +#ifdef CONFIG_X86_32
21426 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21427 + mm->context.user_cs_base = 0UL;
21428 + mm->context.user_cs_limit = ~0UL;
21429 +
21430 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21431 + cpus_clear(mm->context.cpu_user_cs_mask);
21432 +#endif
21433 +
21434 +#endif
21435 +#endif
21436 +
21437 + }
21438 +
21439 return retval;
21440 }
21441
21442 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21443 }
21444 }
21445
21446 +#ifdef CONFIG_PAX_SEGMEXEC
21447 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21448 + error = -EINVAL;
21449 + goto out_unlock;
21450 + }
21451 +#endif
21452 +
21453 fill_ldt(&ldt, &ldt_info);
21454 if (oldmode)
21455 ldt.avl = 0;
21456 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21457 index 5b19e4d..6476a76 100644
21458 --- a/arch/x86/kernel/machine_kexec_32.c
21459 +++ b/arch/x86/kernel/machine_kexec_32.c
21460 @@ -26,7 +26,7 @@
21461 #include <asm/cacheflush.h>
21462 #include <asm/debugreg.h>
21463
21464 -static void set_idt(void *newidt, __u16 limit)
21465 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21466 {
21467 struct desc_ptr curidt;
21468
21469 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21470 }
21471
21472
21473 -static void set_gdt(void *newgdt, __u16 limit)
21474 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21475 {
21476 struct desc_ptr curgdt;
21477
21478 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21479 }
21480
21481 control_page = page_address(image->control_code_page);
21482 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21483 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21484
21485 relocate_kernel_ptr = control_page;
21486 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21487 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21488 index 22db92b..d546bec 100644
21489 --- a/arch/x86/kernel/microcode_core.c
21490 +++ b/arch/x86/kernel/microcode_core.c
21491 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21492 return NOTIFY_OK;
21493 }
21494
21495 -static struct notifier_block __refdata mc_cpu_notifier = {
21496 +static struct notifier_block mc_cpu_notifier = {
21497 .notifier_call = mc_cpu_callback,
21498 };
21499
21500 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21501 index 5fb2ceb..3ae90bb 100644
21502 --- a/arch/x86/kernel/microcode_intel.c
21503 +++ b/arch/x86/kernel/microcode_intel.c
21504 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21505
21506 static int get_ucode_user(void *to, const void *from, size_t n)
21507 {
21508 - return copy_from_user(to, from, n);
21509 + return copy_from_user(to, (const void __force_user *)from, n);
21510 }
21511
21512 static enum ucode_state
21513 request_microcode_user(int cpu, const void __user *buf, size_t size)
21514 {
21515 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21516 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21517 }
21518
21519 static void microcode_fini_cpu(int cpu)
21520 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21521 index 216a4d7..228255a 100644
21522 --- a/arch/x86/kernel/module.c
21523 +++ b/arch/x86/kernel/module.c
21524 @@ -43,15 +43,60 @@ do { \
21525 } while (0)
21526 #endif
21527
21528 -void *module_alloc(unsigned long size)
21529 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21530 {
21531 - if (PAGE_ALIGN(size) > MODULES_LEN)
21532 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21533 return NULL;
21534 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21535 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21536 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21537 -1, __builtin_return_address(0));
21538 }
21539
21540 +void *module_alloc(unsigned long size)
21541 +{
21542 +
21543 +#ifdef CONFIG_PAX_KERNEXEC
21544 + return __module_alloc(size, PAGE_KERNEL);
21545 +#else
21546 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21547 +#endif
21548 +
21549 +}
21550 +
21551 +#ifdef CONFIG_PAX_KERNEXEC
21552 +#ifdef CONFIG_X86_32
21553 +void *module_alloc_exec(unsigned long size)
21554 +{
21555 + struct vm_struct *area;
21556 +
21557 + if (size == 0)
21558 + return NULL;
21559 +
21560 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21561 + return area ? area->addr : NULL;
21562 +}
21563 +EXPORT_SYMBOL(module_alloc_exec);
21564 +
21565 +void module_free_exec(struct module *mod, void *module_region)
21566 +{
21567 + vunmap(module_region);
21568 +}
21569 +EXPORT_SYMBOL(module_free_exec);
21570 +#else
21571 +void module_free_exec(struct module *mod, void *module_region)
21572 +{
21573 + module_free(mod, module_region);
21574 +}
21575 +EXPORT_SYMBOL(module_free_exec);
21576 +
21577 +void *module_alloc_exec(unsigned long size)
21578 +{
21579 + return __module_alloc(size, PAGE_KERNEL_RX);
21580 +}
21581 +EXPORT_SYMBOL(module_alloc_exec);
21582 +#endif
21583 +#endif
21584 +
21585 #ifdef CONFIG_X86_32
21586 int apply_relocate(Elf32_Shdr *sechdrs,
21587 const char *strtab,
21588 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21589 unsigned int i;
21590 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21591 Elf32_Sym *sym;
21592 - uint32_t *location;
21593 + uint32_t *plocation, location;
21594
21595 DEBUGP("Applying relocate section %u to %u\n",
21596 relsec, sechdrs[relsec].sh_info);
21597 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21598 /* This is where to make the change */
21599 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21600 - + rel[i].r_offset;
21601 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21602 + location = (uint32_t)plocation;
21603 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21604 + plocation = ktla_ktva((void *)plocation);
21605 /* This is the symbol it is referring to. Note that all
21606 undefined symbols have been resolved. */
21607 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
21608 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21609 switch (ELF32_R_TYPE(rel[i].r_info)) {
21610 case R_386_32:
21611 /* We add the value into the location given */
21612 - *location += sym->st_value;
21613 + pax_open_kernel();
21614 + *plocation += sym->st_value;
21615 + pax_close_kernel();
21616 break;
21617 case R_386_PC32:
21618 /* Add the value, subtract its position */
21619 - *location += sym->st_value - (uint32_t)location;
21620 + pax_open_kernel();
21621 + *plocation += sym->st_value - location;
21622 + pax_close_kernel();
21623 break;
21624 default:
21625 pr_err("%s: Unknown relocation: %u\n",
21626 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
21627 case R_X86_64_NONE:
21628 break;
21629 case R_X86_64_64:
21630 + pax_open_kernel();
21631 *(u64 *)loc = val;
21632 + pax_close_kernel();
21633 break;
21634 case R_X86_64_32:
21635 + pax_open_kernel();
21636 *(u32 *)loc = val;
21637 + pax_close_kernel();
21638 if (val != *(u32 *)loc)
21639 goto overflow;
21640 break;
21641 case R_X86_64_32S:
21642 + pax_open_kernel();
21643 *(s32 *)loc = val;
21644 + pax_close_kernel();
21645 if ((s64)val != *(s32 *)loc)
21646 goto overflow;
21647 break;
21648 case R_X86_64_PC32:
21649 val -= (u64)loc;
21650 + pax_open_kernel();
21651 *(u32 *)loc = val;
21652 + pax_close_kernel();
21653 +
21654 #if 0
21655 if ((s64)val != *(s32 *)loc)
21656 goto overflow;
21657 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
21658 index ce13049..e2e9c3c 100644
21659 --- a/arch/x86/kernel/msr.c
21660 +++ b/arch/x86/kernel/msr.c
21661 @@ -233,7 +233,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
21662 return notifier_from_errno(err);
21663 }
21664
21665 -static struct notifier_block __refdata msr_class_cpu_notifier = {
21666 +static struct notifier_block msr_class_cpu_notifier = {
21667 .notifier_call = msr_class_cpu_callback,
21668 };
21669
21670 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
21671 index 6030805..2d33f21 100644
21672 --- a/arch/x86/kernel/nmi.c
21673 +++ b/arch/x86/kernel/nmi.c
21674 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
21675 return handled;
21676 }
21677
21678 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21679 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
21680 {
21681 struct nmi_desc *desc = nmi_to_desc(type);
21682 unsigned long flags;
21683 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21684 * event confuses some handlers (kdump uses this flag)
21685 */
21686 if (action->flags & NMI_FLAG_FIRST)
21687 - list_add_rcu(&action->list, &desc->head);
21688 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
21689 else
21690 - list_add_tail_rcu(&action->list, &desc->head);
21691 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
21692
21693 spin_unlock_irqrestore(&desc->lock, flags);
21694 return 0;
21695 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
21696 if (!strcmp(n->name, name)) {
21697 WARN(in_nmi(),
21698 "Trying to free NMI (%s) from NMI context!\n", n->name);
21699 - list_del_rcu(&n->list);
21700 + pax_list_del_rcu((struct list_head *)&n->list);
21701 break;
21702 }
21703 }
21704 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
21705 dotraplinkage notrace __kprobes void
21706 do_nmi(struct pt_regs *regs, long error_code)
21707 {
21708 +
21709 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
21710 + if (!user_mode(regs)) {
21711 + unsigned long cs = regs->cs & 0xFFFF;
21712 + unsigned long ip = ktva_ktla(regs->ip);
21713 +
21714 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
21715 + regs->ip = ip;
21716 + }
21717 +#endif
21718 +
21719 nmi_nesting_preprocess(regs);
21720
21721 nmi_enter();
21722 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
21723 index 6d9582e..f746287 100644
21724 --- a/arch/x86/kernel/nmi_selftest.c
21725 +++ b/arch/x86/kernel/nmi_selftest.c
21726 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
21727 {
21728 /* trap all the unknown NMIs we may generate */
21729 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
21730 - __initdata);
21731 + __initconst);
21732 }
21733
21734 static void __init cleanup_nmi_testsuite(void)
21735 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
21736 unsigned long timeout;
21737
21738 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
21739 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
21740 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
21741 nmi_fail = FAILURE;
21742 return;
21743 }
21744 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
21745 index 676b8c7..870ba04 100644
21746 --- a/arch/x86/kernel/paravirt-spinlocks.c
21747 +++ b/arch/x86/kernel/paravirt-spinlocks.c
21748 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
21749 arch_spin_lock(lock);
21750 }
21751
21752 -struct pv_lock_ops pv_lock_ops = {
21753 +struct pv_lock_ops pv_lock_ops __read_only = {
21754 #ifdef CONFIG_SMP
21755 .spin_is_locked = __ticket_spin_is_locked,
21756 .spin_is_contended = __ticket_spin_is_contended,
21757 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
21758 index 8bfb335..c1463c6 100644
21759 --- a/arch/x86/kernel/paravirt.c
21760 +++ b/arch/x86/kernel/paravirt.c
21761 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
21762 {
21763 return x;
21764 }
21765 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21766 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
21767 +#endif
21768
21769 void __init default_banner(void)
21770 {
21771 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
21772 if (opfunc == NULL)
21773 /* If there's no function, patch it with a ud2a (BUG) */
21774 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
21775 - else if (opfunc == _paravirt_nop)
21776 + else if (opfunc == (void *)_paravirt_nop)
21777 /* If the operation is a nop, then nop the callsite */
21778 ret = paravirt_patch_nop();
21779
21780 /* identity functions just return their single argument */
21781 - else if (opfunc == _paravirt_ident_32)
21782 + else if (opfunc == (void *)_paravirt_ident_32)
21783 ret = paravirt_patch_ident_32(insnbuf, len);
21784 - else if (opfunc == _paravirt_ident_64)
21785 + else if (opfunc == (void *)_paravirt_ident_64)
21786 ret = paravirt_patch_ident_64(insnbuf, len);
21787 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21788 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
21789 + ret = paravirt_patch_ident_64(insnbuf, len);
21790 +#endif
21791
21792 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
21793 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
21794 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
21795 if (insn_len > len || start == NULL)
21796 insn_len = len;
21797 else
21798 - memcpy(insnbuf, start, insn_len);
21799 + memcpy(insnbuf, ktla_ktva(start), insn_len);
21800
21801 return insn_len;
21802 }
21803 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
21804 return this_cpu_read(paravirt_lazy_mode);
21805 }
21806
21807 -struct pv_info pv_info = {
21808 +struct pv_info pv_info __read_only = {
21809 .name = "bare hardware",
21810 .paravirt_enabled = 0,
21811 .kernel_rpl = 0,
21812 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
21813 #endif
21814 };
21815
21816 -struct pv_init_ops pv_init_ops = {
21817 +struct pv_init_ops pv_init_ops __read_only = {
21818 .patch = native_patch,
21819 };
21820
21821 -struct pv_time_ops pv_time_ops = {
21822 +struct pv_time_ops pv_time_ops __read_only = {
21823 .sched_clock = native_sched_clock,
21824 .steal_clock = native_steal_clock,
21825 };
21826
21827 -struct pv_irq_ops pv_irq_ops = {
21828 +struct pv_irq_ops pv_irq_ops __read_only = {
21829 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
21830 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
21831 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
21832 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
21833 #endif
21834 };
21835
21836 -struct pv_cpu_ops pv_cpu_ops = {
21837 +struct pv_cpu_ops pv_cpu_ops __read_only = {
21838 .cpuid = native_cpuid,
21839 .get_debugreg = native_get_debugreg,
21840 .set_debugreg = native_set_debugreg,
21841 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
21842 .end_context_switch = paravirt_nop,
21843 };
21844
21845 -struct pv_apic_ops pv_apic_ops = {
21846 +struct pv_apic_ops pv_apic_ops __read_only= {
21847 #ifdef CONFIG_X86_LOCAL_APIC
21848 .startup_ipi_hook = paravirt_nop,
21849 #endif
21850 };
21851
21852 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
21853 +#ifdef CONFIG_X86_32
21854 +#ifdef CONFIG_X86_PAE
21855 +/* 64-bit pagetable entries */
21856 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
21857 +#else
21858 /* 32-bit pagetable entries */
21859 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
21860 +#endif
21861 #else
21862 /* 64-bit pagetable entries */
21863 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
21864 #endif
21865
21866 -struct pv_mmu_ops pv_mmu_ops = {
21867 +struct pv_mmu_ops pv_mmu_ops __read_only = {
21868
21869 .read_cr2 = native_read_cr2,
21870 .write_cr2 = native_write_cr2,
21871 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
21872 .make_pud = PTE_IDENT,
21873
21874 .set_pgd = native_set_pgd,
21875 + .set_pgd_batched = native_set_pgd_batched,
21876 #endif
21877 #endif /* PAGETABLE_LEVELS >= 3 */
21878
21879 @@ -479,6 +492,12 @@ struct pv_mmu_ops pv_mmu_ops = {
21880 },
21881
21882 .set_fixmap = native_set_fixmap,
21883 +
21884 +#ifdef CONFIG_PAX_KERNEXEC
21885 + .pax_open_kernel = native_pax_open_kernel,
21886 + .pax_close_kernel = native_pax_close_kernel,
21887 +#endif
21888 +
21889 };
21890
21891 EXPORT_SYMBOL_GPL(pv_time_ops);
21892 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
21893 index 299d493..2ccb0ee 100644
21894 --- a/arch/x86/kernel/pci-calgary_64.c
21895 +++ b/arch/x86/kernel/pci-calgary_64.c
21896 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
21897 tce_space = be64_to_cpu(readq(target));
21898 tce_space = tce_space & TAR_SW_BITS;
21899
21900 - tce_space = tce_space & (~specified_table_size);
21901 + tce_space = tce_space & (~(unsigned long)specified_table_size);
21902 info->tce_space = (u64 *)__va(tce_space);
21903 }
21904 }
21905 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
21906 index 35ccf75..7a15747 100644
21907 --- a/arch/x86/kernel/pci-iommu_table.c
21908 +++ b/arch/x86/kernel/pci-iommu_table.c
21909 @@ -2,7 +2,7 @@
21910 #include <asm/iommu_table.h>
21911 #include <linux/string.h>
21912 #include <linux/kallsyms.h>
21913 -
21914 +#include <linux/sched.h>
21915
21916 #define DEBUG 1
21917
21918 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
21919 index 6c483ba..d10ce2f 100644
21920 --- a/arch/x86/kernel/pci-swiotlb.c
21921 +++ b/arch/x86/kernel/pci-swiotlb.c
21922 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
21923 void *vaddr, dma_addr_t dma_addr,
21924 struct dma_attrs *attrs)
21925 {
21926 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
21927 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
21928 }
21929
21930 static struct dma_map_ops swiotlb_dma_ops = {
21931 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
21932 index 14ae100..752a4f6 100644
21933 --- a/arch/x86/kernel/process.c
21934 +++ b/arch/x86/kernel/process.c
21935 @@ -36,7 +36,8 @@
21936 * section. Since TSS's are completely CPU-local, we want them
21937 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
21938 */
21939 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
21940 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
21941 +EXPORT_SYMBOL(init_tss);
21942
21943 #ifdef CONFIG_X86_64
21944 static DEFINE_PER_CPU(unsigned char, is_idle);
21945 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
21946 task_xstate_cachep =
21947 kmem_cache_create("task_xstate", xstate_size,
21948 __alignof__(union thread_xstate),
21949 - SLAB_PANIC | SLAB_NOTRACK, NULL);
21950 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
21951 }
21952
21953 /*
21954 @@ -105,7 +106,7 @@ void exit_thread(void)
21955 unsigned long *bp = t->io_bitmap_ptr;
21956
21957 if (bp) {
21958 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
21959 + struct tss_struct *tss = init_tss + get_cpu();
21960
21961 t->io_bitmap_ptr = NULL;
21962 clear_thread_flag(TIF_IO_BITMAP);
21963 @@ -136,7 +137,7 @@ void show_regs_common(void)
21964 board = dmi_get_system_info(DMI_BOARD_NAME);
21965
21966 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
21967 - current->pid, current->comm, print_tainted(),
21968 + task_pid_nr(current), current->comm, print_tainted(),
21969 init_utsname()->release,
21970 (int)strcspn(init_utsname()->version, " "),
21971 init_utsname()->version,
21972 @@ -149,6 +150,9 @@ void flush_thread(void)
21973 {
21974 struct task_struct *tsk = current;
21975
21976 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
21977 + loadsegment(gs, 0);
21978 +#endif
21979 flush_ptrace_hw_breakpoint(tsk);
21980 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
21981 drop_init_fpu(tsk);
21982 @@ -295,7 +299,7 @@ static void __exit_idle(void)
21983 void exit_idle(void)
21984 {
21985 /* idle loop has pid 0 */
21986 - if (current->pid)
21987 + if (task_pid_nr(current))
21988 return;
21989 __exit_idle();
21990 }
21991 @@ -398,7 +402,7 @@ bool xen_set_default_idle(void)
21992 return ret;
21993 }
21994 #endif
21995 -void stop_this_cpu(void *dummy)
21996 +__noreturn void stop_this_cpu(void *dummy)
21997 {
21998 local_irq_disable();
21999 /*
22000 @@ -544,16 +548,37 @@ static int __init idle_setup(char *str)
22001 }
22002 early_param("idle", idle_setup);
22003
22004 -unsigned long arch_align_stack(unsigned long sp)
22005 +#ifdef CONFIG_PAX_RANDKSTACK
22006 +void pax_randomize_kstack(struct pt_regs *regs)
22007 {
22008 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
22009 - sp -= get_random_int() % 8192;
22010 - return sp & ~0xf;
22011 -}
22012 + struct thread_struct *thread = &current->thread;
22013 + unsigned long time;
22014
22015 -unsigned long arch_randomize_brk(struct mm_struct *mm)
22016 -{
22017 - unsigned long range_end = mm->brk + 0x02000000;
22018 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
22019 -}
22020 + if (!randomize_va_space)
22021 + return;
22022 +
22023 + if (v8086_mode(regs))
22024 + return;
22025
22026 + rdtscl(time);
22027 +
22028 + /* P4 seems to return a 0 LSB, ignore it */
22029 +#ifdef CONFIG_MPENTIUM4
22030 + time &= 0x3EUL;
22031 + time <<= 2;
22032 +#elif defined(CONFIG_X86_64)
22033 + time &= 0xFUL;
22034 + time <<= 4;
22035 +#else
22036 + time &= 0x1FUL;
22037 + time <<= 3;
22038 +#endif
22039 +
22040 + thread->sp0 ^= time;
22041 + load_sp0(init_tss + smp_processor_id(), thread);
22042 +
22043 +#ifdef CONFIG_X86_64
22044 + this_cpu_write(kernel_stack, thread->sp0);
22045 +#endif
22046 +}
22047 +#endif
22048 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
22049 index b5a8905..d9cacac 100644
22050 --- a/arch/x86/kernel/process_32.c
22051 +++ b/arch/x86/kernel/process_32.c
22052 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
22053 unsigned long thread_saved_pc(struct task_struct *tsk)
22054 {
22055 return ((unsigned long *)tsk->thread.sp)[3];
22056 +//XXX return tsk->thread.eip;
22057 }
22058
22059 void __show_regs(struct pt_regs *regs, int all)
22060 @@ -74,21 +75,20 @@ void __show_regs(struct pt_regs *regs, int all)
22061 unsigned long sp;
22062 unsigned short ss, gs;
22063
22064 - if (user_mode_vm(regs)) {
22065 + if (user_mode(regs)) {
22066 sp = regs->sp;
22067 ss = regs->ss & 0xffff;
22068 - gs = get_user_gs(regs);
22069 } else {
22070 sp = kernel_stack_pointer(regs);
22071 savesegment(ss, ss);
22072 - savesegment(gs, gs);
22073 }
22074 + gs = get_user_gs(regs);
22075
22076 show_regs_common();
22077
22078 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
22079 (u16)regs->cs, regs->ip, regs->flags,
22080 - smp_processor_id());
22081 + raw_smp_processor_id());
22082 print_symbol("EIP is at %s\n", regs->ip);
22083
22084 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
22085 @@ -130,20 +130,21 @@ void release_thread(struct task_struct *dead_task)
22086 int copy_thread(unsigned long clone_flags, unsigned long sp,
22087 unsigned long arg, struct task_struct *p)
22088 {
22089 - struct pt_regs *childregs = task_pt_regs(p);
22090 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
22091 struct task_struct *tsk;
22092 int err;
22093
22094 p->thread.sp = (unsigned long) childregs;
22095 p->thread.sp0 = (unsigned long) (childregs+1);
22096 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22097
22098 if (unlikely(p->flags & PF_KTHREAD)) {
22099 /* kernel thread */
22100 memset(childregs, 0, sizeof(struct pt_regs));
22101 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22102 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22103 - childregs->ds = __USER_DS;
22104 - childregs->es = __USER_DS;
22105 + savesegment(gs, childregs->gs);
22106 + childregs->ds = __KERNEL_DS;
22107 + childregs->es = __KERNEL_DS;
22108 childregs->fs = __KERNEL_PERCPU;
22109 childregs->bx = sp; /* function */
22110 childregs->bp = arg;
22111 @@ -250,7 +251,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22112 struct thread_struct *prev = &prev_p->thread,
22113 *next = &next_p->thread;
22114 int cpu = smp_processor_id();
22115 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22116 + struct tss_struct *tss = init_tss + cpu;
22117 fpu_switch_t fpu;
22118
22119 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22120 @@ -274,6 +275,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22121 */
22122 lazy_save_gs(prev->gs);
22123
22124 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22125 + __set_fs(task_thread_info(next_p)->addr_limit);
22126 +#endif
22127 +
22128 /*
22129 * Load the per-thread Thread-Local Storage descriptor.
22130 */
22131 @@ -304,6 +309,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22132 */
22133 arch_end_context_switch(next_p);
22134
22135 + this_cpu_write(current_task, next_p);
22136 + this_cpu_write(current_tinfo, &next_p->tinfo);
22137 +
22138 /*
22139 * Restore %gs if needed (which is common)
22140 */
22141 @@ -312,8 +320,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22142
22143 switch_fpu_finish(next_p, fpu);
22144
22145 - this_cpu_write(current_task, next_p);
22146 -
22147 return prev_p;
22148 }
22149
22150 @@ -343,4 +349,3 @@ unsigned long get_wchan(struct task_struct *p)
22151 } while (count++ < 16);
22152 return 0;
22153 }
22154 -
22155 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22156 index 0f49677..fcbf88c 100644
22157 --- a/arch/x86/kernel/process_64.c
22158 +++ b/arch/x86/kernel/process_64.c
22159 @@ -152,10 +152,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22160 struct pt_regs *childregs;
22161 struct task_struct *me = current;
22162
22163 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22164 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22165 childregs = task_pt_regs(p);
22166 p->thread.sp = (unsigned long) childregs;
22167 p->thread.usersp = me->thread.usersp;
22168 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22169 set_tsk_thread_flag(p, TIF_FORK);
22170 p->fpu_counter = 0;
22171 p->thread.io_bitmap_ptr = NULL;
22172 @@ -274,7 +275,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22173 struct thread_struct *prev = &prev_p->thread;
22174 struct thread_struct *next = &next_p->thread;
22175 int cpu = smp_processor_id();
22176 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22177 + struct tss_struct *tss = init_tss + cpu;
22178 unsigned fsindex, gsindex;
22179 fpu_switch_t fpu;
22180
22181 @@ -356,10 +357,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22182 prev->usersp = this_cpu_read(old_rsp);
22183 this_cpu_write(old_rsp, next->usersp);
22184 this_cpu_write(current_task, next_p);
22185 + this_cpu_write(current_tinfo, &next_p->tinfo);
22186
22187 - this_cpu_write(kernel_stack,
22188 - (unsigned long)task_stack_page(next_p) +
22189 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22190 + this_cpu_write(kernel_stack, next->sp0);
22191
22192 /*
22193 * Now maybe reload the debug registers and handle I/O bitmaps
22194 @@ -428,12 +428,11 @@ unsigned long get_wchan(struct task_struct *p)
22195 if (!p || p == current || p->state == TASK_RUNNING)
22196 return 0;
22197 stack = (unsigned long)task_stack_page(p);
22198 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22199 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22200 return 0;
22201 fp = *(u64 *)(p->thread.sp);
22202 do {
22203 - if (fp < (unsigned long)stack ||
22204 - fp >= (unsigned long)stack+THREAD_SIZE)
22205 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22206 return 0;
22207 ip = *(u64 *)(fp+8);
22208 if (!in_sched_functions(ip))
22209 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22210 index 29a8120..a50b5ee 100644
22211 --- a/arch/x86/kernel/ptrace.c
22212 +++ b/arch/x86/kernel/ptrace.c
22213 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22214 {
22215 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22216 unsigned long sp = (unsigned long)&regs->sp;
22217 - struct thread_info *tinfo;
22218
22219 - if (context == (sp & ~(THREAD_SIZE - 1)))
22220 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22221 return sp;
22222
22223 - tinfo = (struct thread_info *)context;
22224 - if (tinfo->previous_esp)
22225 - return tinfo->previous_esp;
22226 + sp = *(unsigned long *)context;
22227 + if (sp)
22228 + return sp;
22229
22230 return (unsigned long)regs;
22231 }
22232 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22233 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22234 {
22235 int i;
22236 - int dr7 = 0;
22237 + unsigned long dr7 = 0;
22238 struct arch_hw_breakpoint *info;
22239
22240 for (i = 0; i < HBP_NUM; i++) {
22241 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22242 unsigned long addr, unsigned long data)
22243 {
22244 int ret;
22245 - unsigned long __user *datap = (unsigned long __user *)data;
22246 + unsigned long __user *datap = (__force unsigned long __user *)data;
22247
22248 switch (request) {
22249 /* read the word at location addr in the USER area. */
22250 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22251 if ((int) addr < 0)
22252 return -EIO;
22253 ret = do_get_thread_area(child, addr,
22254 - (struct user_desc __user *)data);
22255 + (__force struct user_desc __user *) data);
22256 break;
22257
22258 case PTRACE_SET_THREAD_AREA:
22259 if ((int) addr < 0)
22260 return -EIO;
22261 ret = do_set_thread_area(child, addr,
22262 - (struct user_desc __user *)data, 0);
22263 + (__force struct user_desc __user *) data, 0);
22264 break;
22265 #endif
22266
22267 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22268
22269 #ifdef CONFIG_X86_64
22270
22271 -static struct user_regset x86_64_regsets[] __read_mostly = {
22272 +static user_regset_no_const x86_64_regsets[] __read_only = {
22273 [REGSET_GENERAL] = {
22274 .core_note_type = NT_PRSTATUS,
22275 .n = sizeof(struct user_regs_struct) / sizeof(long),
22276 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22277 #endif /* CONFIG_X86_64 */
22278
22279 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22280 -static struct user_regset x86_32_regsets[] __read_mostly = {
22281 +static user_regset_no_const x86_32_regsets[] __read_only = {
22282 [REGSET_GENERAL] = {
22283 .core_note_type = NT_PRSTATUS,
22284 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22285 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22286 */
22287 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22288
22289 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22290 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22291 {
22292 #ifdef CONFIG_X86_64
22293 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22294 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22295 memset(info, 0, sizeof(*info));
22296 info->si_signo = SIGTRAP;
22297 info->si_code = si_code;
22298 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22299 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22300 }
22301
22302 void user_single_step_siginfo(struct task_struct *tsk,
22303 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22304 # define IS_IA32 0
22305 #endif
22306
22307 +#ifdef CONFIG_GRKERNSEC_SETXID
22308 +extern void gr_delayed_cred_worker(void);
22309 +#endif
22310 +
22311 /*
22312 * We must return the syscall number to actually look up in the table.
22313 * This can be -1L to skip running any syscall at all.
22314 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22315
22316 user_exit();
22317
22318 +#ifdef CONFIG_GRKERNSEC_SETXID
22319 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22320 + gr_delayed_cred_worker();
22321 +#endif
22322 +
22323 /*
22324 * If we stepped into a sysenter/syscall insn, it trapped in
22325 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22326 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22327 */
22328 user_exit();
22329
22330 +#ifdef CONFIG_GRKERNSEC_SETXID
22331 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22332 + gr_delayed_cred_worker();
22333 +#endif
22334 +
22335 audit_syscall_exit(regs);
22336
22337 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22338 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22339 index 2cb9470..ff1fd80 100644
22340 --- a/arch/x86/kernel/pvclock.c
22341 +++ b/arch/x86/kernel/pvclock.c
22342 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22343 return pv_tsc_khz;
22344 }
22345
22346 -static atomic64_t last_value = ATOMIC64_INIT(0);
22347 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22348
22349 void pvclock_resume(void)
22350 {
22351 - atomic64_set(&last_value, 0);
22352 + atomic64_set_unchecked(&last_value, 0);
22353 }
22354
22355 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22356 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22357 * updating at the same time, and one of them could be slightly behind,
22358 * making the assumption that last_value always go forward fail to hold.
22359 */
22360 - last = atomic64_read(&last_value);
22361 + last = atomic64_read_unchecked(&last_value);
22362 do {
22363 if (ret < last)
22364 return last;
22365 - last = atomic64_cmpxchg(&last_value, last, ret);
22366 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22367 } while (unlikely(last != ret));
22368
22369 return ret;
22370 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22371 index 76fa1e9..abf09ea 100644
22372 --- a/arch/x86/kernel/reboot.c
22373 +++ b/arch/x86/kernel/reboot.c
22374 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22375 EXPORT_SYMBOL(pm_power_off);
22376
22377 static const struct desc_ptr no_idt = {};
22378 -static int reboot_mode;
22379 +static unsigned short reboot_mode;
22380 enum reboot_type reboot_type = BOOT_ACPI;
22381 int reboot_force;
22382
22383 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22384
22385 void __noreturn machine_real_restart(unsigned int type)
22386 {
22387 +
22388 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22389 + struct desc_struct *gdt;
22390 +#endif
22391 +
22392 local_irq_disable();
22393
22394 /*
22395 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22396
22397 /* Jump to the identity-mapped low memory code */
22398 #ifdef CONFIG_X86_32
22399 - asm volatile("jmpl *%0" : :
22400 +
22401 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22402 + gdt = get_cpu_gdt_table(smp_processor_id());
22403 + pax_open_kernel();
22404 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22405 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22406 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22407 + loadsegment(ds, __KERNEL_DS);
22408 + loadsegment(es, __KERNEL_DS);
22409 + loadsegment(ss, __KERNEL_DS);
22410 +#endif
22411 +#ifdef CONFIG_PAX_KERNEXEC
22412 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22413 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22414 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22415 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22416 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22417 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22418 +#endif
22419 + pax_close_kernel();
22420 +#endif
22421 +
22422 + asm volatile("ljmpl *%0" : :
22423 "rm" (real_mode_header->machine_real_restart_asm),
22424 "a" (type));
22425 #else
22426 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22427 * try to force a triple fault and then cycle between hitting the keyboard
22428 * controller and doing that
22429 */
22430 -static void native_machine_emergency_restart(void)
22431 +static void __noreturn native_machine_emergency_restart(void)
22432 {
22433 int i;
22434 int attempt = 0;
22435 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22436 #endif
22437 }
22438
22439 -static void __machine_emergency_restart(int emergency)
22440 +static void __noreturn __machine_emergency_restart(int emergency)
22441 {
22442 reboot_emergency = emergency;
22443 machine_ops.emergency_restart();
22444 }
22445
22446 -static void native_machine_restart(char *__unused)
22447 +static void __noreturn native_machine_restart(char *__unused)
22448 {
22449 pr_notice("machine restart\n");
22450
22451 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22452 __machine_emergency_restart(0);
22453 }
22454
22455 -static void native_machine_halt(void)
22456 +static void __noreturn native_machine_halt(void)
22457 {
22458 /* Stop other cpus and apics */
22459 machine_shutdown();
22460 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22461 stop_this_cpu(NULL);
22462 }
22463
22464 -static void native_machine_power_off(void)
22465 +static void __noreturn native_machine_power_off(void)
22466 {
22467 if (pm_power_off) {
22468 if (!reboot_force)
22469 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22470 }
22471 /* A fallback in case there is no PM info available */
22472 tboot_shutdown(TB_SHUTDOWN_HALT);
22473 + unreachable();
22474 }
22475
22476 -struct machine_ops machine_ops = {
22477 +struct machine_ops machine_ops __read_only = {
22478 .power_off = native_machine_power_off,
22479 .shutdown = native_machine_shutdown,
22480 .emergency_restart = native_machine_emergency_restart,
22481 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22482 index 7a6f3b3..bed145d7 100644
22483 --- a/arch/x86/kernel/relocate_kernel_64.S
22484 +++ b/arch/x86/kernel/relocate_kernel_64.S
22485 @@ -11,6 +11,7 @@
22486 #include <asm/kexec.h>
22487 #include <asm/processor-flags.h>
22488 #include <asm/pgtable_types.h>
22489 +#include <asm/alternative-asm.h>
22490
22491 /*
22492 * Must be relocatable PIC code callable as a C function
22493 @@ -160,13 +161,14 @@ identity_mapped:
22494 xorq %rbp, %rbp
22495 xorq %r8, %r8
22496 xorq %r9, %r9
22497 - xorq %r10, %r9
22498 + xorq %r10, %r10
22499 xorq %r11, %r11
22500 xorq %r12, %r12
22501 xorq %r13, %r13
22502 xorq %r14, %r14
22503 xorq %r15, %r15
22504
22505 + pax_force_retaddr 0, 1
22506 ret
22507
22508 1:
22509 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22510 index fae9134..b7d4a57 100644
22511 --- a/arch/x86/kernel/setup.c
22512 +++ b/arch/x86/kernel/setup.c
22513 @@ -111,6 +111,7 @@
22514 #include <asm/mce.h>
22515 #include <asm/alternative.h>
22516 #include <asm/prom.h>
22517 +#include <asm/boot.h>
22518
22519 /*
22520 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
22521 @@ -447,7 +448,7 @@ static void __init parse_setup_data(void)
22522
22523 switch (data->type) {
22524 case SETUP_E820_EXT:
22525 - parse_e820_ext(data);
22526 + parse_e820_ext((struct setup_data __force_kernel *)data);
22527 break;
22528 case SETUP_DTB:
22529 add_dtb(pa_data);
22530 @@ -774,7 +775,7 @@ static void __init trim_bios_range(void)
22531 * area (640->1Mb) as ram even though it is not.
22532 * take them out.
22533 */
22534 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22535 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22536
22537 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22538 }
22539 @@ -844,8 +845,12 @@ static void __init trim_low_memory_range(void)
22540
22541 void __init setup_arch(char **cmdline_p)
22542 {
22543 +#ifdef CONFIG_X86_32
22544 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - ____LOAD_PHYSICAL_ADDR);
22545 +#else
22546 memblock_reserve(__pa_symbol(_text),
22547 (unsigned long)__bss_stop - (unsigned long)_text);
22548 +#endif
22549
22550 early_reserve_initrd();
22551
22552 @@ -937,14 +942,14 @@ void __init setup_arch(char **cmdline_p)
22553
22554 if (!boot_params.hdr.root_flags)
22555 root_mountflags &= ~MS_RDONLY;
22556 - init_mm.start_code = (unsigned long) _text;
22557 - init_mm.end_code = (unsigned long) _etext;
22558 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22559 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22560 init_mm.end_data = (unsigned long) _edata;
22561 init_mm.brk = _brk_end;
22562
22563 - code_resource.start = __pa_symbol(_text);
22564 - code_resource.end = __pa_symbol(_etext)-1;
22565 - data_resource.start = __pa_symbol(_etext);
22566 + code_resource.start = __pa_symbol(ktla_ktva(_text));
22567 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
22568 + data_resource.start = __pa_symbol(_sdata);
22569 data_resource.end = __pa_symbol(_edata)-1;
22570 bss_resource.start = __pa_symbol(__bss_start);
22571 bss_resource.end = __pa_symbol(__bss_stop)-1;
22572 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22573 index 5cdff03..80fa283 100644
22574 --- a/arch/x86/kernel/setup_percpu.c
22575 +++ b/arch/x86/kernel/setup_percpu.c
22576 @@ -21,19 +21,17 @@
22577 #include <asm/cpu.h>
22578 #include <asm/stackprotector.h>
22579
22580 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22581 +#ifdef CONFIG_SMP
22582 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22583 EXPORT_PER_CPU_SYMBOL(cpu_number);
22584 +#endif
22585
22586 -#ifdef CONFIG_X86_64
22587 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22588 -#else
22589 -#define BOOT_PERCPU_OFFSET 0
22590 -#endif
22591
22592 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22593 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22594
22595 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22596 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22597 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22598 };
22599 EXPORT_SYMBOL(__per_cpu_offset);
22600 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22601 {
22602 #ifdef CONFIG_NEED_MULTIPLE_NODES
22603 pg_data_t *last = NULL;
22604 - unsigned int cpu;
22605 + int cpu;
22606
22607 for_each_possible_cpu(cpu) {
22608 int node = early_cpu_to_node(cpu);
22609 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22610 {
22611 #ifdef CONFIG_X86_32
22612 struct desc_struct gdt;
22613 + unsigned long base = per_cpu_offset(cpu);
22614
22615 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22616 - 0x2 | DESCTYPE_S, 0x8);
22617 - gdt.s = 1;
22618 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22619 + 0x83 | DESCTYPE_S, 0xC);
22620 write_gdt_entry(get_cpu_gdt_table(cpu),
22621 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22622 #endif
22623 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22624 /* alrighty, percpu areas up and running */
22625 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22626 for_each_possible_cpu(cpu) {
22627 +#ifdef CONFIG_CC_STACKPROTECTOR
22628 +#ifdef CONFIG_X86_32
22629 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
22630 +#endif
22631 +#endif
22632 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
22633 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
22634 per_cpu(cpu_number, cpu) = cpu;
22635 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
22636 */
22637 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
22638 #endif
22639 +#ifdef CONFIG_CC_STACKPROTECTOR
22640 +#ifdef CONFIG_X86_32
22641 + if (!cpu)
22642 + per_cpu(stack_canary.canary, cpu) = canary;
22643 +#endif
22644 +#endif
22645 /*
22646 * Up to this point, the boot CPU has been using .init.data
22647 * area. Reload any changed state for the boot CPU.
22648 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
22649 index 6956299..f20beae 100644
22650 --- a/arch/x86/kernel/signal.c
22651 +++ b/arch/x86/kernel/signal.c
22652 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
22653 * Align the stack pointer according to the i386 ABI,
22654 * i.e. so that on function entry ((sp + 4) & 15) == 0.
22655 */
22656 - sp = ((sp + 4) & -16ul) - 4;
22657 + sp = ((sp - 12) & -16ul) - 4;
22658 #else /* !CONFIG_X86_32 */
22659 sp = round_down(sp, 16) - 8;
22660 #endif
22661 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22662 }
22663
22664 if (current->mm->context.vdso)
22665 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22666 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22667 else
22668 - restorer = &frame->retcode;
22669 + restorer = (void __user *)&frame->retcode;
22670 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22671 restorer = ksig->ka.sa.sa_restorer;
22672
22673 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22674 * reasons and because gdb uses it as a signature to notice
22675 * signal handler stack frames.
22676 */
22677 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
22678 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
22679
22680 if (err)
22681 return -EFAULT;
22682 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22683 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
22684
22685 /* Set up to return from userspace. */
22686 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22687 + if (current->mm->context.vdso)
22688 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22689 + else
22690 + restorer = (void __user *)&frame->retcode;
22691 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22692 restorer = ksig->ka.sa.sa_restorer;
22693 put_user_ex(restorer, &frame->pretcode);
22694 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22695 * reasons and because gdb uses it as a signature to notice
22696 * signal handler stack frames.
22697 */
22698 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
22699 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
22700 } put_user_catch(err);
22701
22702 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
22703 @@ -615,7 +618,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22704 {
22705 int usig = signr_convert(ksig->sig);
22706 sigset_t *set = sigmask_to_save();
22707 - compat_sigset_t *cset = (compat_sigset_t *) set;
22708 + sigset_t sigcopy;
22709 + compat_sigset_t *cset;
22710 +
22711 + sigcopy = *set;
22712 +
22713 + cset = (compat_sigset_t *) &sigcopy;
22714
22715 /* Set up the stack frame */
22716 if (is_ia32_frame()) {
22717 @@ -626,7 +634,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22718 } else if (is_x32_frame()) {
22719 return x32_setup_rt_frame(ksig, cset, regs);
22720 } else {
22721 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
22722 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
22723 }
22724 }
22725
22726 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
22727 index 48d2b7d..90d328a 100644
22728 --- a/arch/x86/kernel/smp.c
22729 +++ b/arch/x86/kernel/smp.c
22730 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
22731
22732 __setup("nonmi_ipi", nonmi_ipi_setup);
22733
22734 -struct smp_ops smp_ops = {
22735 +struct smp_ops smp_ops __read_only = {
22736 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
22737 .smp_prepare_cpus = native_smp_prepare_cpus,
22738 .smp_cpus_done = native_smp_cpus_done,
22739 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
22740 index 9f190a2..90a0688 100644
22741 --- a/arch/x86/kernel/smpboot.c
22742 +++ b/arch/x86/kernel/smpboot.c
22743 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22744 idle->thread.sp = (unsigned long) (((struct pt_regs *)
22745 (THREAD_SIZE + task_stack_page(idle))) - 1);
22746 per_cpu(current_task, cpu) = idle;
22747 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
22748
22749 #ifdef CONFIG_X86_32
22750 /* Stack for startup_32 can be just as for start_secondary onwards */
22751 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22752 #else
22753 clear_tsk_thread_flag(idle, TIF_FORK);
22754 initial_gs = per_cpu_offset(cpu);
22755 - per_cpu(kernel_stack, cpu) =
22756 - (unsigned long)task_stack_page(idle) -
22757 - KERNEL_STACK_OFFSET + THREAD_SIZE;
22758 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
22759 #endif
22760 +
22761 + pax_open_kernel();
22762 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
22763 + pax_close_kernel();
22764 +
22765 initial_code = (unsigned long)start_secondary;
22766 stack_start = idle->thread.sp;
22767
22768 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
22769 /* the FPU context is blank, nobody can own it */
22770 __cpu_disable_lazy_restore(cpu);
22771
22772 +#ifdef CONFIG_PAX_PER_CPU_PGD
22773 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
22774 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
22775 + KERNEL_PGD_PTRS);
22776 +#endif
22777 +
22778 + /* the FPU context is blank, nobody can own it */
22779 + __cpu_disable_lazy_restore(cpu);
22780 +
22781 err = do_boot_cpu(apicid, cpu, tidle);
22782 if (err) {
22783 pr_debug("do_boot_cpu failed %d\n", err);
22784 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
22785 index 9b4d51d..5d28b58 100644
22786 --- a/arch/x86/kernel/step.c
22787 +++ b/arch/x86/kernel/step.c
22788 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22789 struct desc_struct *desc;
22790 unsigned long base;
22791
22792 - seg &= ~7UL;
22793 + seg >>= 3;
22794
22795 mutex_lock(&child->mm->context.lock);
22796 - if (unlikely((seg >> 3) >= child->mm->context.size))
22797 + if (unlikely(seg >= child->mm->context.size))
22798 addr = -1L; /* bogus selector, access would fault */
22799 else {
22800 desc = child->mm->context.ldt + seg;
22801 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22802 addr += base;
22803 }
22804 mutex_unlock(&child->mm->context.lock);
22805 - }
22806 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
22807 + addr = ktla_ktva(addr);
22808
22809 return addr;
22810 }
22811 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
22812 unsigned char opcode[15];
22813 unsigned long addr = convert_ip_to_linear(child, regs);
22814
22815 + if (addr == -EINVAL)
22816 + return 0;
22817 +
22818 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
22819 for (i = 0; i < copied; i++) {
22820 switch (opcode[i]) {
22821 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
22822 new file mode 100644
22823 index 0000000..207bec6
22824 --- /dev/null
22825 +++ b/arch/x86/kernel/sys_i386_32.c
22826 @@ -0,0 +1,250 @@
22827 +/*
22828 + * This file contains various random system calls that
22829 + * have a non-standard calling sequence on the Linux/i386
22830 + * platform.
22831 + */
22832 +
22833 +#include <linux/errno.h>
22834 +#include <linux/sched.h>
22835 +#include <linux/mm.h>
22836 +#include <linux/fs.h>
22837 +#include <linux/smp.h>
22838 +#include <linux/sem.h>
22839 +#include <linux/msg.h>
22840 +#include <linux/shm.h>
22841 +#include <linux/stat.h>
22842 +#include <linux/syscalls.h>
22843 +#include <linux/mman.h>
22844 +#include <linux/file.h>
22845 +#include <linux/utsname.h>
22846 +#include <linux/ipc.h>
22847 +
22848 +#include <linux/uaccess.h>
22849 +#include <linux/unistd.h>
22850 +
22851 +#include <asm/syscalls.h>
22852 +
22853 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
22854 +{
22855 + unsigned long pax_task_size = TASK_SIZE;
22856 +
22857 +#ifdef CONFIG_PAX_SEGMEXEC
22858 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
22859 + pax_task_size = SEGMEXEC_TASK_SIZE;
22860 +#endif
22861 +
22862 + if (flags & MAP_FIXED)
22863 + if (len > pax_task_size || addr > pax_task_size - len)
22864 + return -EINVAL;
22865 +
22866 + return 0;
22867 +}
22868 +
22869 +unsigned long
22870 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
22871 + unsigned long len, unsigned long pgoff, unsigned long flags)
22872 +{
22873 + struct mm_struct *mm = current->mm;
22874 + struct vm_area_struct *vma;
22875 + unsigned long start_addr, pax_task_size = TASK_SIZE;
22876 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22877 +
22878 +#ifdef CONFIG_PAX_SEGMEXEC
22879 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22880 + pax_task_size = SEGMEXEC_TASK_SIZE;
22881 +#endif
22882 +
22883 + pax_task_size -= PAGE_SIZE;
22884 +
22885 + if (len > pax_task_size)
22886 + return -ENOMEM;
22887 +
22888 + if (flags & MAP_FIXED)
22889 + return addr;
22890 +
22891 +#ifdef CONFIG_PAX_RANDMMAP
22892 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22893 +#endif
22894 +
22895 + if (addr) {
22896 + addr = PAGE_ALIGN(addr);
22897 + if (pax_task_size - len >= addr) {
22898 + vma = find_vma(mm, addr);
22899 + if (check_heap_stack_gap(vma, addr, len, offset))
22900 + return addr;
22901 + }
22902 + }
22903 + if (len > mm->cached_hole_size) {
22904 + start_addr = addr = mm->free_area_cache;
22905 + } else {
22906 + start_addr = addr = mm->mmap_base;
22907 + mm->cached_hole_size = 0;
22908 + }
22909 +
22910 +#ifdef CONFIG_PAX_PAGEEXEC
22911 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE) && start_addr >= mm->mmap_base) {
22912 + start_addr = 0x00110000UL;
22913 +
22914 +#ifdef CONFIG_PAX_RANDMMAP
22915 + if (mm->pax_flags & MF_PAX_RANDMMAP)
22916 + start_addr += mm->delta_mmap & 0x03FFF000UL;
22917 +#endif
22918 +
22919 + if (mm->start_brk <= start_addr && start_addr < mm->mmap_base)
22920 + start_addr = addr = mm->mmap_base;
22921 + else
22922 + addr = start_addr;
22923 + }
22924 +#endif
22925 +
22926 +full_search:
22927 + for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
22928 + /* At this point: (!vma || addr < vma->vm_end). */
22929 + if (pax_task_size - len < addr) {
22930 + /*
22931 + * Start a new search - just in case we missed
22932 + * some holes.
22933 + */
22934 + if (start_addr != mm->mmap_base) {
22935 + start_addr = addr = mm->mmap_base;
22936 + mm->cached_hole_size = 0;
22937 + goto full_search;
22938 + }
22939 + return -ENOMEM;
22940 + }
22941 + if (check_heap_stack_gap(vma, addr, len, offset))
22942 + break;
22943 + if (addr + mm->cached_hole_size < vma->vm_start)
22944 + mm->cached_hole_size = vma->vm_start - addr;
22945 + addr = vma->vm_end;
22946 + if (mm->start_brk <= addr && addr < mm->mmap_base) {
22947 + start_addr = addr = mm->mmap_base;
22948 + mm->cached_hole_size = 0;
22949 + goto full_search;
22950 + }
22951 + }
22952 +
22953 + /*
22954 + * Remember the place where we stopped the search:
22955 + */
22956 + mm->free_area_cache = addr + len;
22957 + return addr;
22958 +}
22959 +
22960 +unsigned long
22961 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
22962 + const unsigned long len, const unsigned long pgoff,
22963 + const unsigned long flags)
22964 +{
22965 + struct vm_area_struct *vma;
22966 + struct mm_struct *mm = current->mm;
22967 + unsigned long base = mm->mmap_base, addr = addr0, pax_task_size = TASK_SIZE;
22968 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22969 +
22970 +#ifdef CONFIG_PAX_SEGMEXEC
22971 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22972 + pax_task_size = SEGMEXEC_TASK_SIZE;
22973 +#endif
22974 +
22975 + pax_task_size -= PAGE_SIZE;
22976 +
22977 + /* requested length too big for entire address space */
22978 + if (len > pax_task_size)
22979 + return -ENOMEM;
22980 +
22981 + if (flags & MAP_FIXED)
22982 + return addr;
22983 +
22984 +#ifdef CONFIG_PAX_PAGEEXEC
22985 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
22986 + goto bottomup;
22987 +#endif
22988 +
22989 +#ifdef CONFIG_PAX_RANDMMAP
22990 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22991 +#endif
22992 +
22993 + /* requesting a specific address */
22994 + if (addr) {
22995 + addr = PAGE_ALIGN(addr);
22996 + if (pax_task_size - len >= addr) {
22997 + vma = find_vma(mm, addr);
22998 + if (check_heap_stack_gap(vma, addr, len, offset))
22999 + return addr;
23000 + }
23001 + }
23002 +
23003 + /* check if free_area_cache is useful for us */
23004 + if (len <= mm->cached_hole_size) {
23005 + mm->cached_hole_size = 0;
23006 + mm->free_area_cache = mm->mmap_base;
23007 + }
23008 +
23009 + /* either no address requested or can't fit in requested address hole */
23010 + addr = mm->free_area_cache;
23011 +
23012 + /* make sure it can fit in the remaining address space */
23013 + if (addr > len) {
23014 + vma = find_vma(mm, addr-len);
23015 + if (check_heap_stack_gap(vma, addr - len, len, offset))
23016 + /* remember the address as a hint for next time */
23017 + return (mm->free_area_cache = addr-len);
23018 + }
23019 +
23020 + if (mm->mmap_base < len)
23021 + goto bottomup;
23022 +
23023 + addr = mm->mmap_base-len;
23024 +
23025 + do {
23026 + /*
23027 + * Lookup failure means no vma is above this address,
23028 + * else if new region fits below vma->vm_start,
23029 + * return with success:
23030 + */
23031 + vma = find_vma(mm, addr);
23032 + if (check_heap_stack_gap(vma, addr, len, offset))
23033 + /* remember the address as a hint for next time */
23034 + return (mm->free_area_cache = addr);
23035 +
23036 + /* remember the largest hole we saw so far */
23037 + if (addr + mm->cached_hole_size < vma->vm_start)
23038 + mm->cached_hole_size = vma->vm_start - addr;
23039 +
23040 + /* try just below the current vma->vm_start */
23041 + addr = skip_heap_stack_gap(vma, len, offset);
23042 + } while (!IS_ERR_VALUE(addr));
23043 +
23044 +bottomup:
23045 + /*
23046 + * A failed mmap() very likely causes application failure,
23047 + * so fall back to the bottom-up function here. This scenario
23048 + * can happen with large stack limits and large mmap()
23049 + * allocations.
23050 + */
23051 +
23052 +#ifdef CONFIG_PAX_SEGMEXEC
23053 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23054 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
23055 + else
23056 +#endif
23057 +
23058 + mm->mmap_base = TASK_UNMAPPED_BASE;
23059 +
23060 +#ifdef CONFIG_PAX_RANDMMAP
23061 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23062 + mm->mmap_base += mm->delta_mmap;
23063 +#endif
23064 +
23065 + mm->free_area_cache = mm->mmap_base;
23066 + mm->cached_hole_size = ~0UL;
23067 + addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
23068 + /*
23069 + * Restore the topdown base:
23070 + */
23071 + mm->mmap_base = base;
23072 + mm->free_area_cache = base;
23073 + mm->cached_hole_size = ~0UL;
23074 +
23075 + return addr;
23076 +}
23077 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
23078 index dbded5a..ace2781 100644
23079 --- a/arch/x86/kernel/sys_x86_64.c
23080 +++ b/arch/x86/kernel/sys_x86_64.c
23081 @@ -81,8 +81,8 @@ out:
23082 return error;
23083 }
23084
23085 -static void find_start_end(unsigned long flags, unsigned long *begin,
23086 - unsigned long *end)
23087 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
23088 + unsigned long *begin, unsigned long *end)
23089 {
23090 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
23091 unsigned long new_begin;
23092 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
23093 *begin = new_begin;
23094 }
23095 } else {
23096 - *begin = TASK_UNMAPPED_BASE;
23097 + *begin = mm->mmap_base;
23098 *end = TASK_SIZE;
23099 }
23100 }
23101 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23102 struct vm_area_struct *vma;
23103 struct vm_unmapped_area_info info;
23104 unsigned long begin, end;
23105 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23106
23107 if (flags & MAP_FIXED)
23108 return addr;
23109
23110 - find_start_end(flags, &begin, &end);
23111 + find_start_end(mm, flags, &begin, &end);
23112
23113 if (len > end)
23114 return -ENOMEM;
23115
23116 +#ifdef CONFIG_PAX_RANDMMAP
23117 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23118 +#endif
23119 +
23120 if (addr) {
23121 addr = PAGE_ALIGN(addr);
23122 vma = find_vma(mm, addr);
23123 - if (end - len >= addr &&
23124 - (!vma || addr + len <= vma->vm_start))
23125 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23126 return addr;
23127 }
23128
23129 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23130 info.high_limit = end;
23131 info.align_mask = filp ? get_align_mask() : 0;
23132 info.align_offset = pgoff << PAGE_SHIFT;
23133 + info.threadstack_offset = offset;
23134 return vm_unmapped_area(&info);
23135 }
23136
23137 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23138 struct mm_struct *mm = current->mm;
23139 unsigned long addr = addr0;
23140 struct vm_unmapped_area_info info;
23141 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23142
23143 /* requested length too big for entire address space */
23144 if (len > TASK_SIZE)
23145 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23146 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23147 goto bottomup;
23148
23149 +#ifdef CONFIG_PAX_RANDMMAP
23150 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23151 +#endif
23152 +
23153 /* requesting a specific address */
23154 if (addr) {
23155 addr = PAGE_ALIGN(addr);
23156 vma = find_vma(mm, addr);
23157 - if (TASK_SIZE - len >= addr &&
23158 - (!vma || addr + len <= vma->vm_start))
23159 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23160 return addr;
23161 }
23162
23163 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23164 info.high_limit = mm->mmap_base;
23165 info.align_mask = filp ? get_align_mask() : 0;
23166 info.align_offset = pgoff << PAGE_SHIFT;
23167 + info.threadstack_offset = offset;
23168 addr = vm_unmapped_area(&info);
23169 if (!(addr & ~PAGE_MASK))
23170 return addr;
23171 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23172 index f84fe00..f41d9f1 100644
23173 --- a/arch/x86/kernel/tboot.c
23174 +++ b/arch/x86/kernel/tboot.c
23175 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23176
23177 void tboot_shutdown(u32 shutdown_type)
23178 {
23179 - void (*shutdown)(void);
23180 + void (* __noreturn shutdown)(void);
23181
23182 if (!tboot_enabled())
23183 return;
23184 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23185
23186 switch_to_tboot_pt();
23187
23188 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23189 + shutdown = (void *)tboot->shutdown_entry;
23190 shutdown();
23191
23192 /* should not reach here */
23193 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23194 return 0;
23195 }
23196
23197 -static atomic_t ap_wfs_count;
23198 +static atomic_unchecked_t ap_wfs_count;
23199
23200 static int tboot_wait_for_aps(int num_aps)
23201 {
23202 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23203 {
23204 switch (action) {
23205 case CPU_DYING:
23206 - atomic_inc(&ap_wfs_count);
23207 + atomic_inc_unchecked(&ap_wfs_count);
23208 if (num_online_cpus() == 1)
23209 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23210 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23211 return NOTIFY_BAD;
23212 break;
23213 }
23214 return NOTIFY_OK;
23215 }
23216
23217 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23218 +static struct notifier_block tboot_cpu_notifier =
23219 {
23220 .notifier_call = tboot_cpu_callback,
23221 };
23222 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23223
23224 tboot_create_trampoline();
23225
23226 - atomic_set(&ap_wfs_count, 0);
23227 + atomic_set_unchecked(&ap_wfs_count, 0);
23228 register_hotcpu_notifier(&tboot_cpu_notifier);
23229
23230 acpi_os_set_prepare_sleep(&tboot_sleep);
23231 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23232 index 24d3c91..d06b473 100644
23233 --- a/arch/x86/kernel/time.c
23234 +++ b/arch/x86/kernel/time.c
23235 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23236 {
23237 unsigned long pc = instruction_pointer(regs);
23238
23239 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23240 + if (!user_mode(regs) && in_lock_functions(pc)) {
23241 #ifdef CONFIG_FRAME_POINTER
23242 - return *(unsigned long *)(regs->bp + sizeof(long));
23243 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23244 #else
23245 unsigned long *sp =
23246 (unsigned long *)kernel_stack_pointer(regs);
23247 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23248 * or above a saved flags. Eflags has bits 22-31 zero,
23249 * kernel addresses don't.
23250 */
23251 +
23252 +#ifdef CONFIG_PAX_KERNEXEC
23253 + return ktla_ktva(sp[0]);
23254 +#else
23255 if (sp[0] >> 22)
23256 return sp[0];
23257 if (sp[1] >> 22)
23258 return sp[1];
23259 #endif
23260 +
23261 +#endif
23262 }
23263 return pc;
23264 }
23265 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23266 index 9d9d2f9..cad418a 100644
23267 --- a/arch/x86/kernel/tls.c
23268 +++ b/arch/x86/kernel/tls.c
23269 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23270 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23271 return -EINVAL;
23272
23273 +#ifdef CONFIG_PAX_SEGMEXEC
23274 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23275 + return -EINVAL;
23276 +#endif
23277 +
23278 set_tls_desc(p, idx, &info, 1);
23279
23280 return 0;
23281 @@ -204,7 +209,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23282
23283 if (kbuf)
23284 info = kbuf;
23285 - else if (__copy_from_user(infobuf, ubuf, count))
23286 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23287 return -EFAULT;
23288 else
23289 info = infobuf;
23290 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23291 index 68bda7a..3ec7bb7 100644
23292 --- a/arch/x86/kernel/traps.c
23293 +++ b/arch/x86/kernel/traps.c
23294 @@ -68,12 +68,6 @@
23295 #include <asm/setup.h>
23296
23297 asmlinkage int system_call(void);
23298 -
23299 -/*
23300 - * The IDT has to be page-aligned to simplify the Pentium
23301 - * F0 0F bug workaround.
23302 - */
23303 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23304 #endif
23305
23306 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23307 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23308 }
23309
23310 static int __kprobes
23311 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23312 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23313 struct pt_regs *regs, long error_code)
23314 {
23315 #ifdef CONFIG_X86_32
23316 - if (regs->flags & X86_VM_MASK) {
23317 + if (v8086_mode(regs)) {
23318 /*
23319 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23320 * On nmi (interrupt 2), do_trap should not be called.
23321 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23322 return -1;
23323 }
23324 #endif
23325 - if (!user_mode(regs)) {
23326 + if (!user_mode_novm(regs)) {
23327 if (!fixup_exception(regs)) {
23328 tsk->thread.error_code = error_code;
23329 tsk->thread.trap_nr = trapnr;
23330 +
23331 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23332 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23333 + str = "PAX: suspicious stack segment fault";
23334 +#endif
23335 +
23336 die(str, regs, error_code);
23337 }
23338 +
23339 +#ifdef CONFIG_PAX_REFCOUNT
23340 + if (trapnr == 4)
23341 + pax_report_refcount_overflow(regs);
23342 +#endif
23343 +
23344 return 0;
23345 }
23346
23347 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23348 }
23349
23350 static void __kprobes
23351 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23352 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23353 long error_code, siginfo_t *info)
23354 {
23355 struct task_struct *tsk = current;
23356 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23357 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23358 printk_ratelimit()) {
23359 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23360 - tsk->comm, tsk->pid, str,
23361 + tsk->comm, task_pid_nr(tsk), str,
23362 regs->ip, regs->sp, error_code);
23363 print_vma_addr(" in ", regs->ip);
23364 pr_cont("\n");
23365 @@ -266,7 +272,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23366 conditional_sti(regs);
23367
23368 #ifdef CONFIG_X86_32
23369 - if (regs->flags & X86_VM_MASK) {
23370 + if (v8086_mode(regs)) {
23371 local_irq_enable();
23372 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23373 goto exit;
23374 @@ -274,18 +280,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23375 #endif
23376
23377 tsk = current;
23378 - if (!user_mode(regs)) {
23379 + if (!user_mode_novm(regs)) {
23380 if (fixup_exception(regs))
23381 goto exit;
23382
23383 tsk->thread.error_code = error_code;
23384 tsk->thread.trap_nr = X86_TRAP_GP;
23385 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23386 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23387 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23388 +
23389 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23390 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23391 + die("PAX: suspicious general protection fault", regs, error_code);
23392 + else
23393 +#endif
23394 +
23395 die("general protection fault", regs, error_code);
23396 + }
23397 goto exit;
23398 }
23399
23400 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23401 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23402 + struct mm_struct *mm = tsk->mm;
23403 + unsigned long limit;
23404 +
23405 + down_write(&mm->mmap_sem);
23406 + limit = mm->context.user_cs_limit;
23407 + if (limit < TASK_SIZE) {
23408 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23409 + up_write(&mm->mmap_sem);
23410 + return;
23411 + }
23412 + up_write(&mm->mmap_sem);
23413 + }
23414 +#endif
23415 +
23416 tsk->thread.error_code = error_code;
23417 tsk->thread.trap_nr = X86_TRAP_GP;
23418
23419 @@ -440,7 +470,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23420 /* It's safe to allow irq's after DR6 has been saved */
23421 preempt_conditional_sti(regs);
23422
23423 - if (regs->flags & X86_VM_MASK) {
23424 + if (v8086_mode(regs)) {
23425 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23426 X86_TRAP_DB);
23427 preempt_conditional_cli(regs);
23428 @@ -455,7 +485,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23429 * We already checked v86 mode above, so we can check for kernel mode
23430 * by just checking the CPL of CS.
23431 */
23432 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23433 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23434 tsk->thread.debugreg6 &= ~DR_STEP;
23435 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23436 regs->flags &= ~X86_EFLAGS_TF;
23437 @@ -487,7 +517,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23438 return;
23439 conditional_sti(regs);
23440
23441 - if (!user_mode_vm(regs))
23442 + if (!user_mode(regs))
23443 {
23444 if (!fixup_exception(regs)) {
23445 task->thread.error_code = error_code;
23446 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23447 index 0ba4cfb..4596bec 100644
23448 --- a/arch/x86/kernel/uprobes.c
23449 +++ b/arch/x86/kernel/uprobes.c
23450 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23451 int ret = NOTIFY_DONE;
23452
23453 /* We are only interested in userspace traps */
23454 - if (regs && !user_mode_vm(regs))
23455 + if (regs && !user_mode(regs))
23456 return NOTIFY_DONE;
23457
23458 switch (val) {
23459 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23460 index b9242ba..50c5edd 100644
23461 --- a/arch/x86/kernel/verify_cpu.S
23462 +++ b/arch/x86/kernel/verify_cpu.S
23463 @@ -20,6 +20,7 @@
23464 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23465 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23466 * arch/x86/kernel/head_32.S: processor startup
23467 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23468 *
23469 * verify_cpu, returns the status of longmode and SSE in register %eax.
23470 * 0: Success 1: Failure
23471 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23472 index 3dbdd9c..888b14e 100644
23473 --- a/arch/x86/kernel/vm86_32.c
23474 +++ b/arch/x86/kernel/vm86_32.c
23475 @@ -44,6 +44,7 @@
23476 #include <linux/ptrace.h>
23477 #include <linux/audit.h>
23478 #include <linux/stddef.h>
23479 +#include <linux/grsecurity.h>
23480
23481 #include <asm/uaccess.h>
23482 #include <asm/io.h>
23483 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23484 do_exit(SIGSEGV);
23485 }
23486
23487 - tss = &per_cpu(init_tss, get_cpu());
23488 + tss = init_tss + get_cpu();
23489 current->thread.sp0 = current->thread.saved_sp0;
23490 current->thread.sysenter_cs = __KERNEL_CS;
23491 load_sp0(tss, &current->thread);
23492 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
23493
23494 if (tsk->thread.saved_sp0)
23495 goto out;
23496 +
23497 +#ifdef CONFIG_GRKERNSEC_VM86
23498 + if (!capable(CAP_SYS_RAWIO)) {
23499 + gr_handle_vm86();
23500 + goto out;
23501 + }
23502 +#endif
23503 +
23504 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
23505 offsetof(struct kernel_vm86_struct, vm86plus) -
23506 sizeof(info.regs));
23507 @@ -242,6 +251,14 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
23508 int tmp, ret;
23509 struct vm86plus_struct __user *v86;
23510
23511 +#ifdef CONFIG_GRKERNSEC_VM86
23512 + if (!capable(CAP_SYS_RAWIO)) {
23513 + gr_handle_vm86();
23514 + ret = -EPERM;
23515 + goto out;
23516 + }
23517 +#endif
23518 +
23519 tsk = current;
23520 switch (cmd) {
23521 case VM86_REQUEST_IRQ:
23522 @@ -329,7 +346,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23523 tsk->thread.saved_fs = info->regs32->fs;
23524 tsk->thread.saved_gs = get_user_gs(info->regs32);
23525
23526 - tss = &per_cpu(init_tss, get_cpu());
23527 + tss = init_tss + get_cpu();
23528 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23529 if (cpu_has_sep)
23530 tsk->thread.sysenter_cs = 0;
23531 @@ -536,7 +553,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23532 goto cannot_handle;
23533 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23534 goto cannot_handle;
23535 - intr_ptr = (unsigned long __user *) (i << 2);
23536 + intr_ptr = (__force unsigned long __user *) (i << 2);
23537 if (get_user(segoffs, intr_ptr))
23538 goto cannot_handle;
23539 if ((segoffs >> 16) == BIOSSEG)
23540 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23541 index 22a1530..8fbaaad 100644
23542 --- a/arch/x86/kernel/vmlinux.lds.S
23543 +++ b/arch/x86/kernel/vmlinux.lds.S
23544 @@ -26,6 +26,13 @@
23545 #include <asm/page_types.h>
23546 #include <asm/cache.h>
23547 #include <asm/boot.h>
23548 +#include <asm/segment.h>
23549 +
23550 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23551 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23552 +#else
23553 +#define __KERNEL_TEXT_OFFSET 0
23554 +#endif
23555
23556 #undef i386 /* in case the preprocessor is a 32bit one */
23557
23558 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23559
23560 PHDRS {
23561 text PT_LOAD FLAGS(5); /* R_E */
23562 +#ifdef CONFIG_X86_32
23563 + module PT_LOAD FLAGS(5); /* R_E */
23564 +#endif
23565 +#ifdef CONFIG_XEN
23566 + rodata PT_LOAD FLAGS(5); /* R_E */
23567 +#else
23568 + rodata PT_LOAD FLAGS(4); /* R__ */
23569 +#endif
23570 data PT_LOAD FLAGS(6); /* RW_ */
23571 -#ifdef CONFIG_X86_64
23572 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23573 #ifdef CONFIG_SMP
23574 percpu PT_LOAD FLAGS(6); /* RW_ */
23575 #endif
23576 + text.init PT_LOAD FLAGS(5); /* R_E */
23577 + text.exit PT_LOAD FLAGS(5); /* R_E */
23578 init PT_LOAD FLAGS(7); /* RWE */
23579 -#endif
23580 note PT_NOTE FLAGS(0); /* ___ */
23581 }
23582
23583 SECTIONS
23584 {
23585 #ifdef CONFIG_X86_32
23586 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23587 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23588 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23589 #else
23590 - . = __START_KERNEL;
23591 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23592 + . = __START_KERNEL;
23593 #endif
23594
23595 /* Text and read-only data */
23596 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23597 - _text = .;
23598 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23599 /* bootstrapping code */
23600 +#ifdef CONFIG_X86_32
23601 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23602 +#else
23603 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23604 +#endif
23605 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23606 + _text = .;
23607 HEAD_TEXT
23608 #ifdef CONFIG_X86_32
23609 . = ALIGN(PAGE_SIZE);
23610 @@ -108,13 +128,48 @@ SECTIONS
23611 IRQENTRY_TEXT
23612 *(.fixup)
23613 *(.gnu.warning)
23614 - /* End of text section */
23615 - _etext = .;
23616 } :text = 0x9090
23617
23618 - NOTES :text :note
23619 + . += __KERNEL_TEXT_OFFSET;
23620
23621 - EXCEPTION_TABLE(16) :text = 0x9090
23622 +#ifdef CONFIG_X86_32
23623 + . = ALIGN(PAGE_SIZE);
23624 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23625 +
23626 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_MODULES)
23627 + MODULES_EXEC_VADDR = .;
23628 + BYTE(0)
23629 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23630 + . = ALIGN(HPAGE_SIZE) - 1;
23631 + MODULES_EXEC_END = .;
23632 +#endif
23633 +
23634 + } :module
23635 +#endif
23636 +
23637 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23638 + /* End of text section */
23639 + BYTE(0)
23640 + _etext = . - __KERNEL_TEXT_OFFSET;
23641 + }
23642 +
23643 +#ifdef CONFIG_X86_32
23644 + . = ALIGN(PAGE_SIZE);
23645 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23646 + *(.idt)
23647 + . = ALIGN(PAGE_SIZE);
23648 + *(.empty_zero_page)
23649 + *(.initial_pg_fixmap)
23650 + *(.initial_pg_pmd)
23651 + *(.initial_page_table)
23652 + *(.swapper_pg_dir)
23653 + } :rodata
23654 +#endif
23655 +
23656 + . = ALIGN(PAGE_SIZE);
23657 + NOTES :rodata :note
23658 +
23659 + EXCEPTION_TABLE(16) :rodata
23660
23661 #if defined(CONFIG_DEBUG_RODATA)
23662 /* .text should occupy whole number of pages */
23663 @@ -126,16 +181,20 @@ SECTIONS
23664
23665 /* Data */
23666 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23667 +
23668 +#ifdef CONFIG_PAX_KERNEXEC
23669 + . = ALIGN(HPAGE_SIZE);
23670 +#else
23671 + . = ALIGN(PAGE_SIZE);
23672 +#endif
23673 +
23674 /* Start of data section */
23675 _sdata = .;
23676
23677 /* init_task */
23678 INIT_TASK_DATA(THREAD_SIZE)
23679
23680 -#ifdef CONFIG_X86_32
23681 - /* 32 bit has nosave before _edata */
23682 NOSAVE_DATA
23683 -#endif
23684
23685 PAGE_ALIGNED_DATA(PAGE_SIZE)
23686
23687 @@ -176,12 +235,19 @@ SECTIONS
23688 #endif /* CONFIG_X86_64 */
23689
23690 /* Init code and data - will be freed after init */
23691 - . = ALIGN(PAGE_SIZE);
23692 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
23693 + BYTE(0)
23694 +
23695 +#ifdef CONFIG_PAX_KERNEXEC
23696 + . = ALIGN(HPAGE_SIZE);
23697 +#else
23698 + . = ALIGN(PAGE_SIZE);
23699 +#endif
23700 +
23701 __init_begin = .; /* paired with __init_end */
23702 - }
23703 + } :init.begin
23704
23705 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
23706 +#ifdef CONFIG_SMP
23707 /*
23708 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
23709 * output PHDR, so the next output section - .init.text - should
23710 @@ -190,12 +256,27 @@ SECTIONS
23711 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
23712 #endif
23713
23714 - INIT_TEXT_SECTION(PAGE_SIZE)
23715 -#ifdef CONFIG_X86_64
23716 - :init
23717 -#endif
23718 + . = ALIGN(PAGE_SIZE);
23719 + init_begin = .;
23720 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
23721 + VMLINUX_SYMBOL(_sinittext) = .;
23722 + INIT_TEXT
23723 + VMLINUX_SYMBOL(_einittext) = .;
23724 + . = ALIGN(PAGE_SIZE);
23725 + } :text.init
23726
23727 - INIT_DATA_SECTION(16)
23728 + /*
23729 + * .exit.text is discard at runtime, not link time, to deal with
23730 + * references from .altinstructions and .eh_frame
23731 + */
23732 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23733 + EXIT_TEXT
23734 + . = ALIGN(16);
23735 + } :text.exit
23736 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
23737 +
23738 + . = ALIGN(PAGE_SIZE);
23739 + INIT_DATA_SECTION(16) :init
23740
23741 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
23742 __x86_cpu_dev_start = .;
23743 @@ -257,19 +338,12 @@ SECTIONS
23744 }
23745
23746 . = ALIGN(8);
23747 - /*
23748 - * .exit.text is discard at runtime, not link time, to deal with
23749 - * references from .altinstructions and .eh_frame
23750 - */
23751 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
23752 - EXIT_TEXT
23753 - }
23754
23755 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
23756 EXIT_DATA
23757 }
23758
23759 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
23760 +#ifndef CONFIG_SMP
23761 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
23762 #endif
23763
23764 @@ -288,16 +362,10 @@ SECTIONS
23765 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
23766 __smp_locks = .;
23767 *(.smp_locks)
23768 - . = ALIGN(PAGE_SIZE);
23769 __smp_locks_end = .;
23770 + . = ALIGN(PAGE_SIZE);
23771 }
23772
23773 -#ifdef CONFIG_X86_64
23774 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
23775 - NOSAVE_DATA
23776 - }
23777 -#endif
23778 -
23779 /* BSS */
23780 . = ALIGN(PAGE_SIZE);
23781 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
23782 @@ -313,6 +381,7 @@ SECTIONS
23783 __brk_base = .;
23784 . += 64 * 1024; /* 64k alignment slop space */
23785 *(.brk_reservation) /* areas brk users have reserved */
23786 + . = ALIGN(HPAGE_SIZE);
23787 __brk_limit = .;
23788 }
23789
23790 @@ -339,13 +408,12 @@ SECTIONS
23791 * for the boot processor.
23792 */
23793 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
23794 -INIT_PER_CPU(gdt_page);
23795 INIT_PER_CPU(irq_stack_union);
23796
23797 /*
23798 * Build-time check on the image size:
23799 */
23800 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
23801 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
23802 "kernel image bigger than KERNEL_IMAGE_SIZE");
23803
23804 #ifdef CONFIG_SMP
23805 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
23806 index 9a907a6..f83f921 100644
23807 --- a/arch/x86/kernel/vsyscall_64.c
23808 +++ b/arch/x86/kernel/vsyscall_64.c
23809 @@ -56,15 +56,13 @@
23810 DEFINE_VVAR(int, vgetcpu_mode);
23811 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
23812
23813 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
23814 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
23815
23816 static int __init vsyscall_setup(char *str)
23817 {
23818 if (str) {
23819 if (!strcmp("emulate", str))
23820 vsyscall_mode = EMULATE;
23821 - else if (!strcmp("native", str))
23822 - vsyscall_mode = NATIVE;
23823 else if (!strcmp("none", str))
23824 vsyscall_mode = NONE;
23825 else
23826 @@ -323,8 +321,7 @@ do_ret:
23827 return true;
23828
23829 sigsegv:
23830 - force_sig(SIGSEGV, current);
23831 - return true;
23832 + do_group_exit(SIGKILL);
23833 }
23834
23835 /*
23836 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
23837 extern char __vvar_page;
23838 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
23839
23840 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
23841 - vsyscall_mode == NATIVE
23842 - ? PAGE_KERNEL_VSYSCALL
23843 - : PAGE_KERNEL_VVAR);
23844 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
23845 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
23846 (unsigned long)VSYSCALL_START);
23847
23848 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
23849 index b014d94..6d6ca7b 100644
23850 --- a/arch/x86/kernel/x8664_ksyms_64.c
23851 +++ b/arch/x86/kernel/x8664_ksyms_64.c
23852 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
23853 EXPORT_SYMBOL(copy_user_generic_unrolled);
23854 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
23855 EXPORT_SYMBOL(__copy_user_nocache);
23856 -EXPORT_SYMBOL(_copy_from_user);
23857 -EXPORT_SYMBOL(_copy_to_user);
23858
23859 EXPORT_SYMBOL(copy_page);
23860 EXPORT_SYMBOL(clear_page);
23861 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
23862 index 45a14db..075bb9b 100644
23863 --- a/arch/x86/kernel/x86_init.c
23864 +++ b/arch/x86/kernel/x86_init.c
23865 @@ -85,7 +85,7 @@ struct x86_init_ops x86_init __initdata = {
23866 },
23867 };
23868
23869 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23870 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
23871 .early_percpu_clock_init = x86_init_noop,
23872 .setup_percpu_clockev = setup_secondary_APIC_clock,
23873 };
23874 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23875 static void default_nmi_init(void) { };
23876 static int default_i8042_detect(void) { return 1; };
23877
23878 -struct x86_platform_ops x86_platform = {
23879 +struct x86_platform_ops x86_platform __read_only = {
23880 .calibrate_tsc = native_calibrate_tsc,
23881 .get_wallclock = mach_get_cmos_time,
23882 .set_wallclock = mach_set_rtc_mmss,
23883 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
23884 };
23885
23886 EXPORT_SYMBOL_GPL(x86_platform);
23887 -struct x86_msi_ops x86_msi = {
23888 +struct x86_msi_ops x86_msi __read_only = {
23889 .setup_msi_irqs = native_setup_msi_irqs,
23890 .compose_msi_msg = native_compose_msi_msg,
23891 .teardown_msi_irq = native_teardown_msi_irq,
23892 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
23893 .setup_hpet_msi = default_setup_hpet_msi,
23894 };
23895
23896 -struct x86_io_apic_ops x86_io_apic_ops = {
23897 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
23898 .init = native_io_apic_init_mappings,
23899 .read = native_io_apic_read,
23900 .write = native_io_apic_write,
23901 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
23902 index ada87a3..afea76d 100644
23903 --- a/arch/x86/kernel/xsave.c
23904 +++ b/arch/x86/kernel/xsave.c
23905 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
23906 {
23907 int err;
23908
23909 + buf = (struct xsave_struct __user *)____m(buf);
23910 if (use_xsave())
23911 err = xsave_user(buf);
23912 else if (use_fxsr())
23913 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
23914 */
23915 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
23916 {
23917 + buf = (void __user *)____m(buf);
23918 if (use_xsave()) {
23919 if ((unsigned long)buf % 64 || fx_only) {
23920 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
23921 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
23922 index a20ecb5..d0e2194 100644
23923 --- a/arch/x86/kvm/cpuid.c
23924 +++ b/arch/x86/kvm/cpuid.c
23925 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
23926 struct kvm_cpuid2 *cpuid,
23927 struct kvm_cpuid_entry2 __user *entries)
23928 {
23929 - int r;
23930 + int r, i;
23931
23932 r = -E2BIG;
23933 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
23934 goto out;
23935 r = -EFAULT;
23936 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
23937 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23938 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23939 goto out;
23940 + for (i = 0; i < cpuid->nent; ++i) {
23941 + struct kvm_cpuid_entry2 cpuid_entry;
23942 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
23943 + goto out;
23944 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
23945 + }
23946 vcpu->arch.cpuid_nent = cpuid->nent;
23947 kvm_apic_set_version(vcpu);
23948 kvm_x86_ops->cpuid_update(vcpu);
23949 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
23950 struct kvm_cpuid2 *cpuid,
23951 struct kvm_cpuid_entry2 __user *entries)
23952 {
23953 - int r;
23954 + int r, i;
23955
23956 r = -E2BIG;
23957 if (cpuid->nent < vcpu->arch.cpuid_nent)
23958 goto out;
23959 r = -EFAULT;
23960 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
23961 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23962 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23963 goto out;
23964 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
23965 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
23966 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
23967 + goto out;
23968 + }
23969 return 0;
23970
23971 out:
23972 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
23973 index 59622c9..f338414 100644
23974 --- a/arch/x86/kvm/emulate.c
23975 +++ b/arch/x86/kvm/emulate.c
23976 @@ -328,6 +328,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23977
23978 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
23979 do { \
23980 + unsigned long _tmp; \
23981 __asm__ __volatile__ ( \
23982 _PRE_EFLAGS("0", "4", "2") \
23983 _op _suffix " %"_x"3,%1; " \
23984 @@ -342,8 +343,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23985 /* Raw emulation: instruction has two explicit operands. */
23986 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
23987 do { \
23988 - unsigned long _tmp; \
23989 - \
23990 switch ((ctxt)->dst.bytes) { \
23991 case 2: \
23992 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
23993 @@ -359,7 +358,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23994
23995 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
23996 do { \
23997 - unsigned long _tmp; \
23998 switch ((ctxt)->dst.bytes) { \
23999 case 1: \
24000 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
24001 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
24002 index f77df1c..6f20690 100644
24003 --- a/arch/x86/kvm/lapic.c
24004 +++ b/arch/x86/kvm/lapic.c
24005 @@ -55,7 +55,7 @@
24006 #define APIC_BUS_CYCLE_NS 1
24007
24008 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
24009 -#define apic_debug(fmt, arg...)
24010 +#define apic_debug(fmt, arg...) do {} while (0)
24011
24012 #define APIC_LVT_NUM 6
24013 /* 14 is the version for Xeon and Pentium 8.4.8*/
24014 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
24015 index 105dd5b..1b0ccc2 100644
24016 --- a/arch/x86/kvm/paging_tmpl.h
24017 +++ b/arch/x86/kvm/paging_tmpl.h
24018 @@ -208,7 +208,7 @@ retry_walk:
24019 if (unlikely(kvm_is_error_hva(host_addr)))
24020 goto error;
24021
24022 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
24023 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
24024 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
24025 goto error;
24026 walker->ptep_user[walker->level - 1] = ptep_user;
24027 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
24028 index e1b1ce2..f7b4b43 100644
24029 --- a/arch/x86/kvm/svm.c
24030 +++ b/arch/x86/kvm/svm.c
24031 @@ -3507,7 +3507,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
24032 int cpu = raw_smp_processor_id();
24033
24034 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
24035 +
24036 + pax_open_kernel();
24037 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
24038 + pax_close_kernel();
24039 +
24040 load_TR_desc();
24041 }
24042
24043 @@ -3901,6 +3905,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
24044 #endif
24045 #endif
24046
24047 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
24048 + __set_fs(current_thread_info()->addr_limit);
24049 +#endif
24050 +
24051 reload_tss(vcpu);
24052
24053 local_irq_disable();
24054 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
24055 index 0af1807..06912bb 100644
24056 --- a/arch/x86/kvm/vmx.c
24057 +++ b/arch/x86/kvm/vmx.c
24058 @@ -1184,12 +1184,12 @@ static void vmcs_write64(unsigned long field, u64 value)
24059 #endif
24060 }
24061
24062 -static void vmcs_clear_bits(unsigned long field, u32 mask)
24063 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
24064 {
24065 vmcs_writel(field, vmcs_readl(field) & ~mask);
24066 }
24067
24068 -static void vmcs_set_bits(unsigned long field, u32 mask)
24069 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
24070 {
24071 vmcs_writel(field, vmcs_readl(field) | mask);
24072 }
24073 @@ -1390,7 +1390,11 @@ static void reload_tss(void)
24074 struct desc_struct *descs;
24075
24076 descs = (void *)gdt->address;
24077 +
24078 + pax_open_kernel();
24079 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
24080 + pax_close_kernel();
24081 +
24082 load_TR_desc();
24083 }
24084
24085 @@ -1614,6 +1618,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
24086 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
24087 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
24088
24089 +#ifdef CONFIG_PAX_PER_CPU_PGD
24090 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24091 +#endif
24092 +
24093 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
24094 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
24095 vmx->loaded_vmcs->cpu = cpu;
24096 @@ -2779,8 +2787,11 @@ static __init int hardware_setup(void)
24097 if (!cpu_has_vmx_flexpriority())
24098 flexpriority_enabled = 0;
24099
24100 - if (!cpu_has_vmx_tpr_shadow())
24101 - kvm_x86_ops->update_cr8_intercept = NULL;
24102 + if (!cpu_has_vmx_tpr_shadow()) {
24103 + pax_open_kernel();
24104 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24105 + pax_close_kernel();
24106 + }
24107
24108 if (enable_ept && !cpu_has_vmx_ept_2m_page())
24109 kvm_disable_largepages();
24110 @@ -2792,10 +2803,12 @@ static __init int hardware_setup(void)
24111 !cpu_has_vmx_virtual_intr_delivery())
24112 enable_apicv_reg_vid = 0;
24113
24114 + pax_open_kernel();
24115 if (enable_apicv_reg_vid)
24116 - kvm_x86_ops->update_cr8_intercept = NULL;
24117 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24118 else
24119 - kvm_x86_ops->hwapic_irr_update = NULL;
24120 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
24121 + pax_close_kernel();
24122
24123 if (nested)
24124 nested_vmx_setup_ctls_msrs();
24125 @@ -3883,7 +3896,10 @@ static void vmx_set_constant_host_state(void)
24126
24127 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
24128 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
24129 +
24130 +#ifndef CONFIG_PAX_PER_CPU_PGD
24131 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24132 +#endif
24133
24134 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24135 #ifdef CONFIG_X86_64
24136 @@ -3904,7 +3920,7 @@ static void vmx_set_constant_host_state(void)
24137 native_store_idt(&dt);
24138 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24139
24140 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24141 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24142
24143 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
24144 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
24145 @@ -6580,6 +6596,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24146 "jmp 2f \n\t"
24147 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
24148 "2: "
24149 +
24150 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24151 + "ljmp %[cs],$3f\n\t"
24152 + "3: "
24153 +#endif
24154 +
24155 /* Save guest registers, load host registers, keep flags */
24156 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
24157 "pop %0 \n\t"
24158 @@ -6632,6 +6654,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24159 #endif
24160 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
24161 [wordsize]"i"(sizeof(ulong))
24162 +
24163 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24164 + ,[cs]"i"(__KERNEL_CS)
24165 +#endif
24166 +
24167 : "cc", "memory"
24168 #ifdef CONFIG_X86_64
24169 , "rax", "rbx", "rdi", "rsi"
24170 @@ -6645,7 +6672,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24171 if (debugctlmsr)
24172 update_debugctlmsr(debugctlmsr);
24173
24174 -#ifndef CONFIG_X86_64
24175 +#ifdef CONFIG_X86_32
24176 /*
24177 * The sysexit path does not restore ds/es, so we must set them to
24178 * a reasonable value ourselves.
24179 @@ -6654,8 +6681,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24180 * may be executed in interrupt context, which saves and restore segments
24181 * around it, nullifying its effect.
24182 */
24183 - loadsegment(ds, __USER_DS);
24184 - loadsegment(es, __USER_DS);
24185 + loadsegment(ds, __KERNEL_DS);
24186 + loadsegment(es, __KERNEL_DS);
24187 + loadsegment(ss, __KERNEL_DS);
24188 +
24189 +#ifdef CONFIG_PAX_KERNEXEC
24190 + loadsegment(fs, __KERNEL_PERCPU);
24191 +#endif
24192 +
24193 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24194 + __set_fs(current_thread_info()->addr_limit);
24195 +#endif
24196 +
24197 #endif
24198
24199 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24200 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24201 index e172132..c3d3e27 100644
24202 --- a/arch/x86/kvm/x86.c
24203 +++ b/arch/x86/kvm/x86.c
24204 @@ -1686,8 +1686,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24205 {
24206 struct kvm *kvm = vcpu->kvm;
24207 int lm = is_long_mode(vcpu);
24208 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24209 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24210 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24211 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24212 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24213 : kvm->arch.xen_hvm_config.blob_size_32;
24214 u32 page_num = data & ~PAGE_MASK;
24215 @@ -2567,6 +2567,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24216 if (n < msr_list.nmsrs)
24217 goto out;
24218 r = -EFAULT;
24219 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24220 + goto out;
24221 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24222 num_msrs_to_save * sizeof(u32)))
24223 goto out;
24224 @@ -2696,7 +2698,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
24225 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
24226 struct kvm_interrupt *irq)
24227 {
24228 - if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS)
24229 + if (irq->irq >= KVM_NR_INTERRUPTS)
24230 return -EINVAL;
24231 if (irqchip_in_kernel(vcpu->kvm))
24232 return -ENXIO;
24233 @@ -5247,7 +5249,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24234 };
24235 #endif
24236
24237 -int kvm_arch_init(void *opaque)
24238 +int kvm_arch_init(const void *opaque)
24239 {
24240 int r;
24241 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24242 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24243 index 7114c63..a1018fc 100644
24244 --- a/arch/x86/lguest/boot.c
24245 +++ b/arch/x86/lguest/boot.c
24246 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24247 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24248 * Launcher to reboot us.
24249 */
24250 -static void lguest_restart(char *reason)
24251 +static __noreturn void lguest_restart(char *reason)
24252 {
24253 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24254 + BUG();
24255 }
24256
24257 /*G:050
24258 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24259 index 00933d5..3a64af9 100644
24260 --- a/arch/x86/lib/atomic64_386_32.S
24261 +++ b/arch/x86/lib/atomic64_386_32.S
24262 @@ -48,6 +48,10 @@ BEGIN(read)
24263 movl (v), %eax
24264 movl 4(v), %edx
24265 RET_ENDP
24266 +BEGIN(read_unchecked)
24267 + movl (v), %eax
24268 + movl 4(v), %edx
24269 +RET_ENDP
24270 #undef v
24271
24272 #define v %esi
24273 @@ -55,6 +59,10 @@ BEGIN(set)
24274 movl %ebx, (v)
24275 movl %ecx, 4(v)
24276 RET_ENDP
24277 +BEGIN(set_unchecked)
24278 + movl %ebx, (v)
24279 + movl %ecx, 4(v)
24280 +RET_ENDP
24281 #undef v
24282
24283 #define v %esi
24284 @@ -70,6 +78,20 @@ RET_ENDP
24285 BEGIN(add)
24286 addl %eax, (v)
24287 adcl %edx, 4(v)
24288 +
24289 +#ifdef CONFIG_PAX_REFCOUNT
24290 + jno 0f
24291 + subl %eax, (v)
24292 + sbbl %edx, 4(v)
24293 + int $4
24294 +0:
24295 + _ASM_EXTABLE(0b, 0b)
24296 +#endif
24297 +
24298 +RET_ENDP
24299 +BEGIN(add_unchecked)
24300 + addl %eax, (v)
24301 + adcl %edx, 4(v)
24302 RET_ENDP
24303 #undef v
24304
24305 @@ -77,6 +99,24 @@ RET_ENDP
24306 BEGIN(add_return)
24307 addl (v), %eax
24308 adcl 4(v), %edx
24309 +
24310 +#ifdef CONFIG_PAX_REFCOUNT
24311 + into
24312 +1234:
24313 + _ASM_EXTABLE(1234b, 2f)
24314 +#endif
24315 +
24316 + movl %eax, (v)
24317 + movl %edx, 4(v)
24318 +
24319 +#ifdef CONFIG_PAX_REFCOUNT
24320 +2:
24321 +#endif
24322 +
24323 +RET_ENDP
24324 +BEGIN(add_return_unchecked)
24325 + addl (v), %eax
24326 + adcl 4(v), %edx
24327 movl %eax, (v)
24328 movl %edx, 4(v)
24329 RET_ENDP
24330 @@ -86,6 +126,20 @@ RET_ENDP
24331 BEGIN(sub)
24332 subl %eax, (v)
24333 sbbl %edx, 4(v)
24334 +
24335 +#ifdef CONFIG_PAX_REFCOUNT
24336 + jno 0f
24337 + addl %eax, (v)
24338 + adcl %edx, 4(v)
24339 + int $4
24340 +0:
24341 + _ASM_EXTABLE(0b, 0b)
24342 +#endif
24343 +
24344 +RET_ENDP
24345 +BEGIN(sub_unchecked)
24346 + subl %eax, (v)
24347 + sbbl %edx, 4(v)
24348 RET_ENDP
24349 #undef v
24350
24351 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24352 sbbl $0, %edx
24353 addl (v), %eax
24354 adcl 4(v), %edx
24355 +
24356 +#ifdef CONFIG_PAX_REFCOUNT
24357 + into
24358 +1234:
24359 + _ASM_EXTABLE(1234b, 2f)
24360 +#endif
24361 +
24362 + movl %eax, (v)
24363 + movl %edx, 4(v)
24364 +
24365 +#ifdef CONFIG_PAX_REFCOUNT
24366 +2:
24367 +#endif
24368 +
24369 +RET_ENDP
24370 +BEGIN(sub_return_unchecked)
24371 + negl %edx
24372 + negl %eax
24373 + sbbl $0, %edx
24374 + addl (v), %eax
24375 + adcl 4(v), %edx
24376 movl %eax, (v)
24377 movl %edx, 4(v)
24378 RET_ENDP
24379 @@ -105,6 +180,20 @@ RET_ENDP
24380 BEGIN(inc)
24381 addl $1, (v)
24382 adcl $0, 4(v)
24383 +
24384 +#ifdef CONFIG_PAX_REFCOUNT
24385 + jno 0f
24386 + subl $1, (v)
24387 + sbbl $0, 4(v)
24388 + int $4
24389 +0:
24390 + _ASM_EXTABLE(0b, 0b)
24391 +#endif
24392 +
24393 +RET_ENDP
24394 +BEGIN(inc_unchecked)
24395 + addl $1, (v)
24396 + adcl $0, 4(v)
24397 RET_ENDP
24398 #undef v
24399
24400 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24401 movl 4(v), %edx
24402 addl $1, %eax
24403 adcl $0, %edx
24404 +
24405 +#ifdef CONFIG_PAX_REFCOUNT
24406 + into
24407 +1234:
24408 + _ASM_EXTABLE(1234b, 2f)
24409 +#endif
24410 +
24411 + movl %eax, (v)
24412 + movl %edx, 4(v)
24413 +
24414 +#ifdef CONFIG_PAX_REFCOUNT
24415 +2:
24416 +#endif
24417 +
24418 +RET_ENDP
24419 +BEGIN(inc_return_unchecked)
24420 + movl (v), %eax
24421 + movl 4(v), %edx
24422 + addl $1, %eax
24423 + adcl $0, %edx
24424 movl %eax, (v)
24425 movl %edx, 4(v)
24426 RET_ENDP
24427 @@ -123,6 +232,20 @@ RET_ENDP
24428 BEGIN(dec)
24429 subl $1, (v)
24430 sbbl $0, 4(v)
24431 +
24432 +#ifdef CONFIG_PAX_REFCOUNT
24433 + jno 0f
24434 + addl $1, (v)
24435 + adcl $0, 4(v)
24436 + int $4
24437 +0:
24438 + _ASM_EXTABLE(0b, 0b)
24439 +#endif
24440 +
24441 +RET_ENDP
24442 +BEGIN(dec_unchecked)
24443 + subl $1, (v)
24444 + sbbl $0, 4(v)
24445 RET_ENDP
24446 #undef v
24447
24448 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24449 movl 4(v), %edx
24450 subl $1, %eax
24451 sbbl $0, %edx
24452 +
24453 +#ifdef CONFIG_PAX_REFCOUNT
24454 + into
24455 +1234:
24456 + _ASM_EXTABLE(1234b, 2f)
24457 +#endif
24458 +
24459 + movl %eax, (v)
24460 + movl %edx, 4(v)
24461 +
24462 +#ifdef CONFIG_PAX_REFCOUNT
24463 +2:
24464 +#endif
24465 +
24466 +RET_ENDP
24467 +BEGIN(dec_return_unchecked)
24468 + movl (v), %eax
24469 + movl 4(v), %edx
24470 + subl $1, %eax
24471 + sbbl $0, %edx
24472 movl %eax, (v)
24473 movl %edx, 4(v)
24474 RET_ENDP
24475 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24476 adcl %edx, %edi
24477 addl (v), %eax
24478 adcl 4(v), %edx
24479 +
24480 +#ifdef CONFIG_PAX_REFCOUNT
24481 + into
24482 +1234:
24483 + _ASM_EXTABLE(1234b, 2f)
24484 +#endif
24485 +
24486 cmpl %eax, %ecx
24487 je 3f
24488 1:
24489 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24490 1:
24491 addl $1, %eax
24492 adcl $0, %edx
24493 +
24494 +#ifdef CONFIG_PAX_REFCOUNT
24495 + into
24496 +1234:
24497 + _ASM_EXTABLE(1234b, 2f)
24498 +#endif
24499 +
24500 movl %eax, (v)
24501 movl %edx, 4(v)
24502 movl $1, %eax
24503 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24504 movl 4(v), %edx
24505 subl $1, %eax
24506 sbbl $0, %edx
24507 +
24508 +#ifdef CONFIG_PAX_REFCOUNT
24509 + into
24510 +1234:
24511 + _ASM_EXTABLE(1234b, 1f)
24512 +#endif
24513 +
24514 js 1f
24515 movl %eax, (v)
24516 movl %edx, 4(v)
24517 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24518 index f5cc9eb..51fa319 100644
24519 --- a/arch/x86/lib/atomic64_cx8_32.S
24520 +++ b/arch/x86/lib/atomic64_cx8_32.S
24521 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24522 CFI_STARTPROC
24523
24524 read64 %ecx
24525 + pax_force_retaddr
24526 ret
24527 CFI_ENDPROC
24528 ENDPROC(atomic64_read_cx8)
24529
24530 +ENTRY(atomic64_read_unchecked_cx8)
24531 + CFI_STARTPROC
24532 +
24533 + read64 %ecx
24534 + pax_force_retaddr
24535 + ret
24536 + CFI_ENDPROC
24537 +ENDPROC(atomic64_read_unchecked_cx8)
24538 +
24539 ENTRY(atomic64_set_cx8)
24540 CFI_STARTPROC
24541
24542 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24543 cmpxchg8b (%esi)
24544 jne 1b
24545
24546 + pax_force_retaddr
24547 ret
24548 CFI_ENDPROC
24549 ENDPROC(atomic64_set_cx8)
24550
24551 +ENTRY(atomic64_set_unchecked_cx8)
24552 + CFI_STARTPROC
24553 +
24554 +1:
24555 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24556 + * are atomic on 586 and newer */
24557 + cmpxchg8b (%esi)
24558 + jne 1b
24559 +
24560 + pax_force_retaddr
24561 + ret
24562 + CFI_ENDPROC
24563 +ENDPROC(atomic64_set_unchecked_cx8)
24564 +
24565 ENTRY(atomic64_xchg_cx8)
24566 CFI_STARTPROC
24567
24568 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24569 cmpxchg8b (%esi)
24570 jne 1b
24571
24572 + pax_force_retaddr
24573 ret
24574 CFI_ENDPROC
24575 ENDPROC(atomic64_xchg_cx8)
24576
24577 -.macro addsub_return func ins insc
24578 -ENTRY(atomic64_\func\()_return_cx8)
24579 +.macro addsub_return func ins insc unchecked=""
24580 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24581 CFI_STARTPROC
24582 SAVE ebp
24583 SAVE ebx
24584 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24585 movl %edx, %ecx
24586 \ins\()l %esi, %ebx
24587 \insc\()l %edi, %ecx
24588 +
24589 +.ifb \unchecked
24590 +#ifdef CONFIG_PAX_REFCOUNT
24591 + into
24592 +2:
24593 + _ASM_EXTABLE(2b, 3f)
24594 +#endif
24595 +.endif
24596 +
24597 LOCK_PREFIX
24598 cmpxchg8b (%ebp)
24599 jne 1b
24600 -
24601 -10:
24602 movl %ebx, %eax
24603 movl %ecx, %edx
24604 +
24605 +.ifb \unchecked
24606 +#ifdef CONFIG_PAX_REFCOUNT
24607 +3:
24608 +#endif
24609 +.endif
24610 +
24611 RESTORE edi
24612 RESTORE esi
24613 RESTORE ebx
24614 RESTORE ebp
24615 + pax_force_retaddr
24616 ret
24617 CFI_ENDPROC
24618 -ENDPROC(atomic64_\func\()_return_cx8)
24619 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24620 .endm
24621
24622 addsub_return add add adc
24623 addsub_return sub sub sbb
24624 +addsub_return add add adc _unchecked
24625 +addsub_return sub sub sbb _unchecked
24626
24627 -.macro incdec_return func ins insc
24628 -ENTRY(atomic64_\func\()_return_cx8)
24629 +.macro incdec_return func ins insc unchecked=""
24630 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24631 CFI_STARTPROC
24632 SAVE ebx
24633
24634 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24635 movl %edx, %ecx
24636 \ins\()l $1, %ebx
24637 \insc\()l $0, %ecx
24638 +
24639 +.ifb \unchecked
24640 +#ifdef CONFIG_PAX_REFCOUNT
24641 + into
24642 +2:
24643 + _ASM_EXTABLE(2b, 3f)
24644 +#endif
24645 +.endif
24646 +
24647 LOCK_PREFIX
24648 cmpxchg8b (%esi)
24649 jne 1b
24650
24651 -10:
24652 movl %ebx, %eax
24653 movl %ecx, %edx
24654 +
24655 +.ifb \unchecked
24656 +#ifdef CONFIG_PAX_REFCOUNT
24657 +3:
24658 +#endif
24659 +.endif
24660 +
24661 RESTORE ebx
24662 + pax_force_retaddr
24663 ret
24664 CFI_ENDPROC
24665 -ENDPROC(atomic64_\func\()_return_cx8)
24666 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24667 .endm
24668
24669 incdec_return inc add adc
24670 incdec_return dec sub sbb
24671 +incdec_return inc add adc _unchecked
24672 +incdec_return dec sub sbb _unchecked
24673
24674 ENTRY(atomic64_dec_if_positive_cx8)
24675 CFI_STARTPROC
24676 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
24677 movl %edx, %ecx
24678 subl $1, %ebx
24679 sbb $0, %ecx
24680 +
24681 +#ifdef CONFIG_PAX_REFCOUNT
24682 + into
24683 +1234:
24684 + _ASM_EXTABLE(1234b, 2f)
24685 +#endif
24686 +
24687 js 2f
24688 LOCK_PREFIX
24689 cmpxchg8b (%esi)
24690 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
24691 movl %ebx, %eax
24692 movl %ecx, %edx
24693 RESTORE ebx
24694 + pax_force_retaddr
24695 ret
24696 CFI_ENDPROC
24697 ENDPROC(atomic64_dec_if_positive_cx8)
24698 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
24699 movl %edx, %ecx
24700 addl %ebp, %ebx
24701 adcl %edi, %ecx
24702 +
24703 +#ifdef CONFIG_PAX_REFCOUNT
24704 + into
24705 +1234:
24706 + _ASM_EXTABLE(1234b, 3f)
24707 +#endif
24708 +
24709 LOCK_PREFIX
24710 cmpxchg8b (%esi)
24711 jne 1b
24712 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
24713 CFI_ADJUST_CFA_OFFSET -8
24714 RESTORE ebx
24715 RESTORE ebp
24716 + pax_force_retaddr
24717 ret
24718 4:
24719 cmpl %edx, 4(%esp)
24720 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
24721 xorl %ecx, %ecx
24722 addl $1, %ebx
24723 adcl %edx, %ecx
24724 +
24725 +#ifdef CONFIG_PAX_REFCOUNT
24726 + into
24727 +1234:
24728 + _ASM_EXTABLE(1234b, 3f)
24729 +#endif
24730 +
24731 LOCK_PREFIX
24732 cmpxchg8b (%esi)
24733 jne 1b
24734 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
24735 movl $1, %eax
24736 3:
24737 RESTORE ebx
24738 + pax_force_retaddr
24739 ret
24740 CFI_ENDPROC
24741 ENDPROC(atomic64_inc_not_zero_cx8)
24742 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
24743 index 2af5df3..62b1a5a 100644
24744 --- a/arch/x86/lib/checksum_32.S
24745 +++ b/arch/x86/lib/checksum_32.S
24746 @@ -29,7 +29,8 @@
24747 #include <asm/dwarf2.h>
24748 #include <asm/errno.h>
24749 #include <asm/asm.h>
24750 -
24751 +#include <asm/segment.h>
24752 +
24753 /*
24754 * computes a partial checksum, e.g. for TCP/UDP fragments
24755 */
24756 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
24757
24758 #define ARGBASE 16
24759 #define FP 12
24760 -
24761 -ENTRY(csum_partial_copy_generic)
24762 +
24763 +ENTRY(csum_partial_copy_generic_to_user)
24764 CFI_STARTPROC
24765 +
24766 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24767 + pushl_cfi %gs
24768 + popl_cfi %es
24769 + jmp csum_partial_copy_generic
24770 +#endif
24771 +
24772 +ENTRY(csum_partial_copy_generic_from_user)
24773 +
24774 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24775 + pushl_cfi %gs
24776 + popl_cfi %ds
24777 +#endif
24778 +
24779 +ENTRY(csum_partial_copy_generic)
24780 subl $4,%esp
24781 CFI_ADJUST_CFA_OFFSET 4
24782 pushl_cfi %edi
24783 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
24784 jmp 4f
24785 SRC(1: movw (%esi), %bx )
24786 addl $2, %esi
24787 -DST( movw %bx, (%edi) )
24788 +DST( movw %bx, %es:(%edi) )
24789 addl $2, %edi
24790 addw %bx, %ax
24791 adcl $0, %eax
24792 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
24793 SRC(1: movl (%esi), %ebx )
24794 SRC( movl 4(%esi), %edx )
24795 adcl %ebx, %eax
24796 -DST( movl %ebx, (%edi) )
24797 +DST( movl %ebx, %es:(%edi) )
24798 adcl %edx, %eax
24799 -DST( movl %edx, 4(%edi) )
24800 +DST( movl %edx, %es:4(%edi) )
24801
24802 SRC( movl 8(%esi), %ebx )
24803 SRC( movl 12(%esi), %edx )
24804 adcl %ebx, %eax
24805 -DST( movl %ebx, 8(%edi) )
24806 +DST( movl %ebx, %es:8(%edi) )
24807 adcl %edx, %eax
24808 -DST( movl %edx, 12(%edi) )
24809 +DST( movl %edx, %es:12(%edi) )
24810
24811 SRC( movl 16(%esi), %ebx )
24812 SRC( movl 20(%esi), %edx )
24813 adcl %ebx, %eax
24814 -DST( movl %ebx, 16(%edi) )
24815 +DST( movl %ebx, %es:16(%edi) )
24816 adcl %edx, %eax
24817 -DST( movl %edx, 20(%edi) )
24818 +DST( movl %edx, %es:20(%edi) )
24819
24820 SRC( movl 24(%esi), %ebx )
24821 SRC( movl 28(%esi), %edx )
24822 adcl %ebx, %eax
24823 -DST( movl %ebx, 24(%edi) )
24824 +DST( movl %ebx, %es:24(%edi) )
24825 adcl %edx, %eax
24826 -DST( movl %edx, 28(%edi) )
24827 +DST( movl %edx, %es:28(%edi) )
24828
24829 lea 32(%esi), %esi
24830 lea 32(%edi), %edi
24831 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
24832 shrl $2, %edx # This clears CF
24833 SRC(3: movl (%esi), %ebx )
24834 adcl %ebx, %eax
24835 -DST( movl %ebx, (%edi) )
24836 +DST( movl %ebx, %es:(%edi) )
24837 lea 4(%esi), %esi
24838 lea 4(%edi), %edi
24839 dec %edx
24840 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
24841 jb 5f
24842 SRC( movw (%esi), %cx )
24843 leal 2(%esi), %esi
24844 -DST( movw %cx, (%edi) )
24845 +DST( movw %cx, %es:(%edi) )
24846 leal 2(%edi), %edi
24847 je 6f
24848 shll $16,%ecx
24849 SRC(5: movb (%esi), %cl )
24850 -DST( movb %cl, (%edi) )
24851 +DST( movb %cl, %es:(%edi) )
24852 6: addl %ecx, %eax
24853 adcl $0, %eax
24854 7:
24855 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
24856
24857 6001:
24858 movl ARGBASE+20(%esp), %ebx # src_err_ptr
24859 - movl $-EFAULT, (%ebx)
24860 + movl $-EFAULT, %ss:(%ebx)
24861
24862 # zero the complete destination - computing the rest
24863 # is too much work
24864 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
24865
24866 6002:
24867 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24868 - movl $-EFAULT,(%ebx)
24869 + movl $-EFAULT,%ss:(%ebx)
24870 jmp 5000b
24871
24872 .previous
24873
24874 + pushl_cfi %ss
24875 + popl_cfi %ds
24876 + pushl_cfi %ss
24877 + popl_cfi %es
24878 popl_cfi %ebx
24879 CFI_RESTORE ebx
24880 popl_cfi %esi
24881 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
24882 popl_cfi %ecx # equivalent to addl $4,%esp
24883 ret
24884 CFI_ENDPROC
24885 -ENDPROC(csum_partial_copy_generic)
24886 +ENDPROC(csum_partial_copy_generic_to_user)
24887
24888 #else
24889
24890 /* Version for PentiumII/PPro */
24891
24892 #define ROUND1(x) \
24893 + nop; nop; nop; \
24894 SRC(movl x(%esi), %ebx ) ; \
24895 addl %ebx, %eax ; \
24896 - DST(movl %ebx, x(%edi) ) ;
24897 + DST(movl %ebx, %es:x(%edi)) ;
24898
24899 #define ROUND(x) \
24900 + nop; nop; nop; \
24901 SRC(movl x(%esi), %ebx ) ; \
24902 adcl %ebx, %eax ; \
24903 - DST(movl %ebx, x(%edi) ) ;
24904 + DST(movl %ebx, %es:x(%edi)) ;
24905
24906 #define ARGBASE 12
24907 -
24908 -ENTRY(csum_partial_copy_generic)
24909 +
24910 +ENTRY(csum_partial_copy_generic_to_user)
24911 CFI_STARTPROC
24912 +
24913 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24914 + pushl_cfi %gs
24915 + popl_cfi %es
24916 + jmp csum_partial_copy_generic
24917 +#endif
24918 +
24919 +ENTRY(csum_partial_copy_generic_from_user)
24920 +
24921 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24922 + pushl_cfi %gs
24923 + popl_cfi %ds
24924 +#endif
24925 +
24926 +ENTRY(csum_partial_copy_generic)
24927 pushl_cfi %ebx
24928 CFI_REL_OFFSET ebx, 0
24929 pushl_cfi %edi
24930 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
24931 subl %ebx, %edi
24932 lea -1(%esi),%edx
24933 andl $-32,%edx
24934 - lea 3f(%ebx,%ebx), %ebx
24935 + lea 3f(%ebx,%ebx,2), %ebx
24936 testl %esi, %esi
24937 jmp *%ebx
24938 1: addl $64,%esi
24939 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
24940 jb 5f
24941 SRC( movw (%esi), %dx )
24942 leal 2(%esi), %esi
24943 -DST( movw %dx, (%edi) )
24944 +DST( movw %dx, %es:(%edi) )
24945 leal 2(%edi), %edi
24946 je 6f
24947 shll $16,%edx
24948 5:
24949 SRC( movb (%esi), %dl )
24950 -DST( movb %dl, (%edi) )
24951 +DST( movb %dl, %es:(%edi) )
24952 6: addl %edx, %eax
24953 adcl $0, %eax
24954 7:
24955 .section .fixup, "ax"
24956 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
24957 - movl $-EFAULT, (%ebx)
24958 + movl $-EFAULT, %ss:(%ebx)
24959 # zero the complete destination (computing the rest is too much work)
24960 movl ARGBASE+8(%esp),%edi # dst
24961 movl ARGBASE+12(%esp),%ecx # len
24962 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
24963 rep; stosb
24964 jmp 7b
24965 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24966 - movl $-EFAULT, (%ebx)
24967 + movl $-EFAULT, %ss:(%ebx)
24968 jmp 7b
24969 .previous
24970
24971 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24972 + pushl_cfi %ss
24973 + popl_cfi %ds
24974 + pushl_cfi %ss
24975 + popl_cfi %es
24976 +#endif
24977 +
24978 popl_cfi %esi
24979 CFI_RESTORE esi
24980 popl_cfi %edi
24981 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
24982 CFI_RESTORE ebx
24983 ret
24984 CFI_ENDPROC
24985 -ENDPROC(csum_partial_copy_generic)
24986 +ENDPROC(csum_partial_copy_generic_to_user)
24987
24988 #undef ROUND
24989 #undef ROUND1
24990 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
24991 index f2145cf..cea889d 100644
24992 --- a/arch/x86/lib/clear_page_64.S
24993 +++ b/arch/x86/lib/clear_page_64.S
24994 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
24995 movl $4096/8,%ecx
24996 xorl %eax,%eax
24997 rep stosq
24998 + pax_force_retaddr
24999 ret
25000 CFI_ENDPROC
25001 ENDPROC(clear_page_c)
25002 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
25003 movl $4096,%ecx
25004 xorl %eax,%eax
25005 rep stosb
25006 + pax_force_retaddr
25007 ret
25008 CFI_ENDPROC
25009 ENDPROC(clear_page_c_e)
25010 @@ -43,6 +45,7 @@ ENTRY(clear_page)
25011 leaq 64(%rdi),%rdi
25012 jnz .Lloop
25013 nop
25014 + pax_force_retaddr
25015 ret
25016 CFI_ENDPROC
25017 .Lclear_page_end:
25018 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
25019
25020 #include <asm/cpufeature.h>
25021
25022 - .section .altinstr_replacement,"ax"
25023 + .section .altinstr_replacement,"a"
25024 1: .byte 0xeb /* jmp <disp8> */
25025 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
25026 2: .byte 0xeb /* jmp <disp8> */
25027 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
25028 index 1e572c5..2a162cd 100644
25029 --- a/arch/x86/lib/cmpxchg16b_emu.S
25030 +++ b/arch/x86/lib/cmpxchg16b_emu.S
25031 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
25032
25033 popf
25034 mov $1, %al
25035 + pax_force_retaddr
25036 ret
25037
25038 not_same:
25039 popf
25040 xor %al,%al
25041 + pax_force_retaddr
25042 ret
25043
25044 CFI_ENDPROC
25045 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
25046 index 176cca6..1166c50 100644
25047 --- a/arch/x86/lib/copy_page_64.S
25048 +++ b/arch/x86/lib/copy_page_64.S
25049 @@ -9,6 +9,7 @@ copy_page_rep:
25050 CFI_STARTPROC
25051 movl $4096/8, %ecx
25052 rep movsq
25053 + pax_force_retaddr
25054 ret
25055 CFI_ENDPROC
25056 ENDPROC(copy_page_rep)
25057 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
25058
25059 ENTRY(copy_page)
25060 CFI_STARTPROC
25061 - subq $2*8, %rsp
25062 - CFI_ADJUST_CFA_OFFSET 2*8
25063 + subq $3*8, %rsp
25064 + CFI_ADJUST_CFA_OFFSET 3*8
25065 movq %rbx, (%rsp)
25066 CFI_REL_OFFSET rbx, 0
25067 movq %r12, 1*8(%rsp)
25068 CFI_REL_OFFSET r12, 1*8
25069 + movq %r13, 2*8(%rsp)
25070 + CFI_REL_OFFSET r13, 2*8
25071
25072 movl $(4096/64)-5, %ecx
25073 .p2align 4
25074 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25075 movq 0x8*2(%rsi), %rdx
25076 movq 0x8*3(%rsi), %r8
25077 movq 0x8*4(%rsi), %r9
25078 - movq 0x8*5(%rsi), %r10
25079 + movq 0x8*5(%rsi), %r13
25080 movq 0x8*6(%rsi), %r11
25081 movq 0x8*7(%rsi), %r12
25082
25083 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25084 movq %rdx, 0x8*2(%rdi)
25085 movq %r8, 0x8*3(%rdi)
25086 movq %r9, 0x8*4(%rdi)
25087 - movq %r10, 0x8*5(%rdi)
25088 + movq %r13, 0x8*5(%rdi)
25089 movq %r11, 0x8*6(%rdi)
25090 movq %r12, 0x8*7(%rdi)
25091
25092 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25093 movq 0x8*2(%rsi), %rdx
25094 movq 0x8*3(%rsi), %r8
25095 movq 0x8*4(%rsi), %r9
25096 - movq 0x8*5(%rsi), %r10
25097 + movq 0x8*5(%rsi), %r13
25098 movq 0x8*6(%rsi), %r11
25099 movq 0x8*7(%rsi), %r12
25100
25101 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25102 movq %rdx, 0x8*2(%rdi)
25103 movq %r8, 0x8*3(%rdi)
25104 movq %r9, 0x8*4(%rdi)
25105 - movq %r10, 0x8*5(%rdi)
25106 + movq %r13, 0x8*5(%rdi)
25107 movq %r11, 0x8*6(%rdi)
25108 movq %r12, 0x8*7(%rdi)
25109
25110 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25111 CFI_RESTORE rbx
25112 movq 1*8(%rsp), %r12
25113 CFI_RESTORE r12
25114 - addq $2*8, %rsp
25115 - CFI_ADJUST_CFA_OFFSET -2*8
25116 + movq 2*8(%rsp), %r13
25117 + CFI_RESTORE r13
25118 + addq $3*8, %rsp
25119 + CFI_ADJUST_CFA_OFFSET -3*8
25120 + pax_force_retaddr
25121 ret
25122 .Lcopy_page_end:
25123 CFI_ENDPROC
25124 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25125
25126 #include <asm/cpufeature.h>
25127
25128 - .section .altinstr_replacement,"ax"
25129 + .section .altinstr_replacement,"a"
25130 1: .byte 0xeb /* jmp <disp8> */
25131 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25132 2:
25133 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25134 index a30ca15..d25fab6 100644
25135 --- a/arch/x86/lib/copy_user_64.S
25136 +++ b/arch/x86/lib/copy_user_64.S
25137 @@ -18,6 +18,7 @@
25138 #include <asm/alternative-asm.h>
25139 #include <asm/asm.h>
25140 #include <asm/smap.h>
25141 +#include <asm/pgtable.h>
25142
25143 /*
25144 * By placing feature2 after feature1 in altinstructions section, we logically
25145 @@ -31,7 +32,7 @@
25146 .byte 0xe9 /* 32bit jump */
25147 .long \orig-1f /* by default jump to orig */
25148 1:
25149 - .section .altinstr_replacement,"ax"
25150 + .section .altinstr_replacement,"a"
25151 2: .byte 0xe9 /* near jump with 32bit immediate */
25152 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25153 3: .byte 0xe9 /* near jump with 32bit immediate */
25154 @@ -70,47 +71,20 @@
25155 #endif
25156 .endm
25157
25158 -/* Standard copy_to_user with segment limit checking */
25159 -ENTRY(_copy_to_user)
25160 - CFI_STARTPROC
25161 - GET_THREAD_INFO(%rax)
25162 - movq %rdi,%rcx
25163 - addq %rdx,%rcx
25164 - jc bad_to_user
25165 - cmpq TI_addr_limit(%rax),%rcx
25166 - ja bad_to_user
25167 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25168 - copy_user_generic_unrolled,copy_user_generic_string, \
25169 - copy_user_enhanced_fast_string
25170 - CFI_ENDPROC
25171 -ENDPROC(_copy_to_user)
25172 -
25173 -/* Standard copy_from_user with segment limit checking */
25174 -ENTRY(_copy_from_user)
25175 - CFI_STARTPROC
25176 - GET_THREAD_INFO(%rax)
25177 - movq %rsi,%rcx
25178 - addq %rdx,%rcx
25179 - jc bad_from_user
25180 - cmpq TI_addr_limit(%rax),%rcx
25181 - ja bad_from_user
25182 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25183 - copy_user_generic_unrolled,copy_user_generic_string, \
25184 - copy_user_enhanced_fast_string
25185 - CFI_ENDPROC
25186 -ENDPROC(_copy_from_user)
25187 -
25188 .section .fixup,"ax"
25189 /* must zero dest */
25190 ENTRY(bad_from_user)
25191 bad_from_user:
25192 CFI_STARTPROC
25193 + testl %edx,%edx
25194 + js bad_to_user
25195 movl %edx,%ecx
25196 xorl %eax,%eax
25197 rep
25198 stosb
25199 bad_to_user:
25200 movl %edx,%eax
25201 + pax_force_retaddr
25202 ret
25203 CFI_ENDPROC
25204 ENDPROC(bad_from_user)
25205 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25206 jz 17f
25207 1: movq (%rsi),%r8
25208 2: movq 1*8(%rsi),%r9
25209 -3: movq 2*8(%rsi),%r10
25210 +3: movq 2*8(%rsi),%rax
25211 4: movq 3*8(%rsi),%r11
25212 5: movq %r8,(%rdi)
25213 6: movq %r9,1*8(%rdi)
25214 -7: movq %r10,2*8(%rdi)
25215 +7: movq %rax,2*8(%rdi)
25216 8: movq %r11,3*8(%rdi)
25217 9: movq 4*8(%rsi),%r8
25218 10: movq 5*8(%rsi),%r9
25219 -11: movq 6*8(%rsi),%r10
25220 +11: movq 6*8(%rsi),%rax
25221 12: movq 7*8(%rsi),%r11
25222 13: movq %r8,4*8(%rdi)
25223 14: movq %r9,5*8(%rdi)
25224 -15: movq %r10,6*8(%rdi)
25225 +15: movq %rax,6*8(%rdi)
25226 16: movq %r11,7*8(%rdi)
25227 leaq 64(%rsi),%rsi
25228 leaq 64(%rdi),%rdi
25229 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25230 jnz 21b
25231 23: xor %eax,%eax
25232 ASM_CLAC
25233 + pax_force_retaddr
25234 ret
25235
25236 .section .fixup,"ax"
25237 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25238 movsb
25239 4: xorl %eax,%eax
25240 ASM_CLAC
25241 + pax_force_retaddr
25242 ret
25243
25244 .section .fixup,"ax"
25245 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25246 movsb
25247 2: xorl %eax,%eax
25248 ASM_CLAC
25249 + pax_force_retaddr
25250 ret
25251
25252 .section .fixup,"ax"
25253 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25254 index 6a4f43c..f08b4a2 100644
25255 --- a/arch/x86/lib/copy_user_nocache_64.S
25256 +++ b/arch/x86/lib/copy_user_nocache_64.S
25257 @@ -8,6 +8,7 @@
25258
25259 #include <linux/linkage.h>
25260 #include <asm/dwarf2.h>
25261 +#include <asm/alternative-asm.h>
25262
25263 #define FIX_ALIGNMENT 1
25264
25265 @@ -16,6 +17,7 @@
25266 #include <asm/thread_info.h>
25267 #include <asm/asm.h>
25268 #include <asm/smap.h>
25269 +#include <asm/pgtable.h>
25270
25271 .macro ALIGN_DESTINATION
25272 #ifdef FIX_ALIGNMENT
25273 @@ -49,6 +51,15 @@
25274 */
25275 ENTRY(__copy_user_nocache)
25276 CFI_STARTPROC
25277 +
25278 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25279 + mov pax_user_shadow_base,%rcx
25280 + cmp %rcx,%rsi
25281 + jae 1f
25282 + add %rcx,%rsi
25283 +1:
25284 +#endif
25285 +
25286 ASM_STAC
25287 cmpl $8,%edx
25288 jb 20f /* less then 8 bytes, go to byte copy loop */
25289 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25290 jz 17f
25291 1: movq (%rsi),%r8
25292 2: movq 1*8(%rsi),%r9
25293 -3: movq 2*8(%rsi),%r10
25294 +3: movq 2*8(%rsi),%rax
25295 4: movq 3*8(%rsi),%r11
25296 5: movnti %r8,(%rdi)
25297 6: movnti %r9,1*8(%rdi)
25298 -7: movnti %r10,2*8(%rdi)
25299 +7: movnti %rax,2*8(%rdi)
25300 8: movnti %r11,3*8(%rdi)
25301 9: movq 4*8(%rsi),%r8
25302 10: movq 5*8(%rsi),%r9
25303 -11: movq 6*8(%rsi),%r10
25304 +11: movq 6*8(%rsi),%rax
25305 12: movq 7*8(%rsi),%r11
25306 13: movnti %r8,4*8(%rdi)
25307 14: movnti %r9,5*8(%rdi)
25308 -15: movnti %r10,6*8(%rdi)
25309 +15: movnti %rax,6*8(%rdi)
25310 16: movnti %r11,7*8(%rdi)
25311 leaq 64(%rsi),%rsi
25312 leaq 64(%rdi),%rdi
25313 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25314 23: xorl %eax,%eax
25315 ASM_CLAC
25316 sfence
25317 + pax_force_retaddr
25318 ret
25319
25320 .section .fixup,"ax"
25321 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25322 index 2419d5f..953ee51 100644
25323 --- a/arch/x86/lib/csum-copy_64.S
25324 +++ b/arch/x86/lib/csum-copy_64.S
25325 @@ -9,6 +9,7 @@
25326 #include <asm/dwarf2.h>
25327 #include <asm/errno.h>
25328 #include <asm/asm.h>
25329 +#include <asm/alternative-asm.h>
25330
25331 /*
25332 * Checksum copy with exception handling.
25333 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25334 CFI_RESTORE rbp
25335 addq $7*8, %rsp
25336 CFI_ADJUST_CFA_OFFSET -7*8
25337 + pax_force_retaddr 0, 1
25338 ret
25339 CFI_RESTORE_STATE
25340
25341 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25342 index 25b7ae8..169fafc 100644
25343 --- a/arch/x86/lib/csum-wrappers_64.c
25344 +++ b/arch/x86/lib/csum-wrappers_64.c
25345 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25346 len -= 2;
25347 }
25348 }
25349 - isum = csum_partial_copy_generic((__force const void *)src,
25350 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25351 dst, len, isum, errp, NULL);
25352 if (unlikely(*errp))
25353 goto out_err;
25354 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25355 }
25356
25357 *errp = 0;
25358 - return csum_partial_copy_generic(src, (void __force *)dst,
25359 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25360 len, isum, NULL, errp);
25361 }
25362 EXPORT_SYMBOL(csum_partial_copy_to_user);
25363 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25364 index a451235..79fb5cf 100644
25365 --- a/arch/x86/lib/getuser.S
25366 +++ b/arch/x86/lib/getuser.S
25367 @@ -33,17 +33,40 @@
25368 #include <asm/thread_info.h>
25369 #include <asm/asm.h>
25370 #include <asm/smap.h>
25371 +#include <asm/segment.h>
25372 +#include <asm/pgtable.h>
25373 +#include <asm/alternative-asm.h>
25374 +
25375 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25376 +#define __copyuser_seg gs;
25377 +#else
25378 +#define __copyuser_seg
25379 +#endif
25380
25381 .text
25382 ENTRY(__get_user_1)
25383 CFI_STARTPROC
25384 +
25385 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25386 GET_THREAD_INFO(%_ASM_DX)
25387 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25388 jae bad_get_user
25389 ASM_STAC
25390 -1: movzbl (%_ASM_AX),%edx
25391 +
25392 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25393 + mov pax_user_shadow_base,%_ASM_DX
25394 + cmp %_ASM_DX,%_ASM_AX
25395 + jae 1234f
25396 + add %_ASM_DX,%_ASM_AX
25397 +1234:
25398 +#endif
25399 +
25400 +#endif
25401 +
25402 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
25403 xor %eax,%eax
25404 ASM_CLAC
25405 + pax_force_retaddr
25406 ret
25407 CFI_ENDPROC
25408 ENDPROC(__get_user_1)
25409 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
25410 ENTRY(__get_user_2)
25411 CFI_STARTPROC
25412 add $1,%_ASM_AX
25413 +
25414 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25415 jc bad_get_user
25416 GET_THREAD_INFO(%_ASM_DX)
25417 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25418 jae bad_get_user
25419 ASM_STAC
25420 -2: movzwl -1(%_ASM_AX),%edx
25421 +
25422 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25423 + mov pax_user_shadow_base,%_ASM_DX
25424 + cmp %_ASM_DX,%_ASM_AX
25425 + jae 1234f
25426 + add %_ASM_DX,%_ASM_AX
25427 +1234:
25428 +#endif
25429 +
25430 +#endif
25431 +
25432 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25433 xor %eax,%eax
25434 ASM_CLAC
25435 + pax_force_retaddr
25436 ret
25437 CFI_ENDPROC
25438 ENDPROC(__get_user_2)
25439 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
25440 ENTRY(__get_user_4)
25441 CFI_STARTPROC
25442 add $3,%_ASM_AX
25443 +
25444 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25445 jc bad_get_user
25446 GET_THREAD_INFO(%_ASM_DX)
25447 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25448 jae bad_get_user
25449 ASM_STAC
25450 -3: movl -3(%_ASM_AX),%edx
25451 +
25452 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25453 + mov pax_user_shadow_base,%_ASM_DX
25454 + cmp %_ASM_DX,%_ASM_AX
25455 + jae 1234f
25456 + add %_ASM_DX,%_ASM_AX
25457 +1234:
25458 +#endif
25459 +
25460 +#endif
25461 +
25462 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
25463 xor %eax,%eax
25464 ASM_CLAC
25465 + pax_force_retaddr
25466 ret
25467 CFI_ENDPROC
25468 ENDPROC(__get_user_4)
25469 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
25470 GET_THREAD_INFO(%_ASM_DX)
25471 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25472 jae bad_get_user
25473 +
25474 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25475 + mov pax_user_shadow_base,%_ASM_DX
25476 + cmp %_ASM_DX,%_ASM_AX
25477 + jae 1234f
25478 + add %_ASM_DX,%_ASM_AX
25479 +1234:
25480 +#endif
25481 +
25482 ASM_STAC
25483 4: movq -7(%_ASM_AX),%rdx
25484 xor %eax,%eax
25485 ASM_CLAC
25486 + pax_force_retaddr
25487 ret
25488 #else
25489 add $7,%_ASM_AX
25490 @@ -102,6 +163,7 @@ ENTRY(__get_user_8)
25491 5: movl -3(%_ASM_AX),%ecx
25492 xor %eax,%eax
25493 ASM_CLAC
25494 + pax_force_retaddr
25495 ret
25496 #endif
25497 CFI_ENDPROC
25498 @@ -113,6 +175,7 @@ bad_get_user:
25499 xor %edx,%edx
25500 mov $(-EFAULT),%_ASM_AX
25501 ASM_CLAC
25502 + pax_force_retaddr
25503 ret
25504 CFI_ENDPROC
25505 END(bad_get_user)
25506 @@ -124,6 +187,7 @@ bad_get_user_8:
25507 xor %ecx,%ecx
25508 mov $(-EFAULT),%_ASM_AX
25509 ASM_CLAC
25510 + pax_force_retaddr
25511 ret
25512 CFI_ENDPROC
25513 END(bad_get_user_8)
25514 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25515 index 54fcffe..7be149e 100644
25516 --- a/arch/x86/lib/insn.c
25517 +++ b/arch/x86/lib/insn.c
25518 @@ -20,8 +20,10 @@
25519
25520 #ifdef __KERNEL__
25521 #include <linux/string.h>
25522 +#include <asm/pgtable_types.h>
25523 #else
25524 #include <string.h>
25525 +#define ktla_ktva(addr) addr
25526 #endif
25527 #include <asm/inat.h>
25528 #include <asm/insn.h>
25529 @@ -53,8 +55,8 @@
25530 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25531 {
25532 memset(insn, 0, sizeof(*insn));
25533 - insn->kaddr = kaddr;
25534 - insn->next_byte = kaddr;
25535 + insn->kaddr = ktla_ktva(kaddr);
25536 + insn->next_byte = ktla_ktva(kaddr);
25537 insn->x86_64 = x86_64 ? 1 : 0;
25538 insn->opnd_bytes = 4;
25539 if (x86_64)
25540 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25541 index 05a95e7..326f2fa 100644
25542 --- a/arch/x86/lib/iomap_copy_64.S
25543 +++ b/arch/x86/lib/iomap_copy_64.S
25544 @@ -17,6 +17,7 @@
25545
25546 #include <linux/linkage.h>
25547 #include <asm/dwarf2.h>
25548 +#include <asm/alternative-asm.h>
25549
25550 /*
25551 * override generic version in lib/iomap_copy.c
25552 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25553 CFI_STARTPROC
25554 movl %edx,%ecx
25555 rep movsd
25556 + pax_force_retaddr
25557 ret
25558 CFI_ENDPROC
25559 ENDPROC(__iowrite32_copy)
25560 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25561 index 1c273be..da9cc0e 100644
25562 --- a/arch/x86/lib/memcpy_64.S
25563 +++ b/arch/x86/lib/memcpy_64.S
25564 @@ -33,6 +33,7 @@
25565 rep movsq
25566 movl %edx, %ecx
25567 rep movsb
25568 + pax_force_retaddr
25569 ret
25570 .Lmemcpy_e:
25571 .previous
25572 @@ -49,6 +50,7 @@
25573 movq %rdi, %rax
25574 movq %rdx, %rcx
25575 rep movsb
25576 + pax_force_retaddr
25577 ret
25578 .Lmemcpy_e_e:
25579 .previous
25580 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25581 */
25582 movq 0*8(%rsi), %r8
25583 movq 1*8(%rsi), %r9
25584 - movq 2*8(%rsi), %r10
25585 + movq 2*8(%rsi), %rcx
25586 movq 3*8(%rsi), %r11
25587 leaq 4*8(%rsi), %rsi
25588
25589 movq %r8, 0*8(%rdi)
25590 movq %r9, 1*8(%rdi)
25591 - movq %r10, 2*8(%rdi)
25592 + movq %rcx, 2*8(%rdi)
25593 movq %r11, 3*8(%rdi)
25594 leaq 4*8(%rdi), %rdi
25595 jae .Lcopy_forward_loop
25596 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25597 subq $0x20, %rdx
25598 movq -1*8(%rsi), %r8
25599 movq -2*8(%rsi), %r9
25600 - movq -3*8(%rsi), %r10
25601 + movq -3*8(%rsi), %rcx
25602 movq -4*8(%rsi), %r11
25603 leaq -4*8(%rsi), %rsi
25604 movq %r8, -1*8(%rdi)
25605 movq %r9, -2*8(%rdi)
25606 - movq %r10, -3*8(%rdi)
25607 + movq %rcx, -3*8(%rdi)
25608 movq %r11, -4*8(%rdi)
25609 leaq -4*8(%rdi), %rdi
25610 jae .Lcopy_backward_loop
25611 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25612 */
25613 movq 0*8(%rsi), %r8
25614 movq 1*8(%rsi), %r9
25615 - movq -2*8(%rsi, %rdx), %r10
25616 + movq -2*8(%rsi, %rdx), %rcx
25617 movq -1*8(%rsi, %rdx), %r11
25618 movq %r8, 0*8(%rdi)
25619 movq %r9, 1*8(%rdi)
25620 - movq %r10, -2*8(%rdi, %rdx)
25621 + movq %rcx, -2*8(%rdi, %rdx)
25622 movq %r11, -1*8(%rdi, %rdx)
25623 + pax_force_retaddr
25624 retq
25625 .p2align 4
25626 .Lless_16bytes:
25627 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25628 movq -1*8(%rsi, %rdx), %r9
25629 movq %r8, 0*8(%rdi)
25630 movq %r9, -1*8(%rdi, %rdx)
25631 + pax_force_retaddr
25632 retq
25633 .p2align 4
25634 .Lless_8bytes:
25635 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25636 movl -4(%rsi, %rdx), %r8d
25637 movl %ecx, (%rdi)
25638 movl %r8d, -4(%rdi, %rdx)
25639 + pax_force_retaddr
25640 retq
25641 .p2align 4
25642 .Lless_3bytes:
25643 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25644 movb %cl, (%rdi)
25645
25646 .Lend:
25647 + pax_force_retaddr
25648 retq
25649 CFI_ENDPROC
25650 ENDPROC(memcpy)
25651 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25652 index ee16461..c39c199 100644
25653 --- a/arch/x86/lib/memmove_64.S
25654 +++ b/arch/x86/lib/memmove_64.S
25655 @@ -61,13 +61,13 @@ ENTRY(memmove)
25656 5:
25657 sub $0x20, %rdx
25658 movq 0*8(%rsi), %r11
25659 - movq 1*8(%rsi), %r10
25660 + movq 1*8(%rsi), %rcx
25661 movq 2*8(%rsi), %r9
25662 movq 3*8(%rsi), %r8
25663 leaq 4*8(%rsi), %rsi
25664
25665 movq %r11, 0*8(%rdi)
25666 - movq %r10, 1*8(%rdi)
25667 + movq %rcx, 1*8(%rdi)
25668 movq %r9, 2*8(%rdi)
25669 movq %r8, 3*8(%rdi)
25670 leaq 4*8(%rdi), %rdi
25671 @@ -81,10 +81,10 @@ ENTRY(memmove)
25672 4:
25673 movq %rdx, %rcx
25674 movq -8(%rsi, %rdx), %r11
25675 - lea -8(%rdi, %rdx), %r10
25676 + lea -8(%rdi, %rdx), %r9
25677 shrq $3, %rcx
25678 rep movsq
25679 - movq %r11, (%r10)
25680 + movq %r11, (%r9)
25681 jmp 13f
25682 .Lmemmove_end_forward:
25683
25684 @@ -95,14 +95,14 @@ ENTRY(memmove)
25685 7:
25686 movq %rdx, %rcx
25687 movq (%rsi), %r11
25688 - movq %rdi, %r10
25689 + movq %rdi, %r9
25690 leaq -8(%rsi, %rdx), %rsi
25691 leaq -8(%rdi, %rdx), %rdi
25692 shrq $3, %rcx
25693 std
25694 rep movsq
25695 cld
25696 - movq %r11, (%r10)
25697 + movq %r11, (%r9)
25698 jmp 13f
25699
25700 /*
25701 @@ -127,13 +127,13 @@ ENTRY(memmove)
25702 8:
25703 subq $0x20, %rdx
25704 movq -1*8(%rsi), %r11
25705 - movq -2*8(%rsi), %r10
25706 + movq -2*8(%rsi), %rcx
25707 movq -3*8(%rsi), %r9
25708 movq -4*8(%rsi), %r8
25709 leaq -4*8(%rsi), %rsi
25710
25711 movq %r11, -1*8(%rdi)
25712 - movq %r10, -2*8(%rdi)
25713 + movq %rcx, -2*8(%rdi)
25714 movq %r9, -3*8(%rdi)
25715 movq %r8, -4*8(%rdi)
25716 leaq -4*8(%rdi), %rdi
25717 @@ -151,11 +151,11 @@ ENTRY(memmove)
25718 * Move data from 16 bytes to 31 bytes.
25719 */
25720 movq 0*8(%rsi), %r11
25721 - movq 1*8(%rsi), %r10
25722 + movq 1*8(%rsi), %rcx
25723 movq -2*8(%rsi, %rdx), %r9
25724 movq -1*8(%rsi, %rdx), %r8
25725 movq %r11, 0*8(%rdi)
25726 - movq %r10, 1*8(%rdi)
25727 + movq %rcx, 1*8(%rdi)
25728 movq %r9, -2*8(%rdi, %rdx)
25729 movq %r8, -1*8(%rdi, %rdx)
25730 jmp 13f
25731 @@ -167,9 +167,9 @@ ENTRY(memmove)
25732 * Move data from 8 bytes to 15 bytes.
25733 */
25734 movq 0*8(%rsi), %r11
25735 - movq -1*8(%rsi, %rdx), %r10
25736 + movq -1*8(%rsi, %rdx), %r9
25737 movq %r11, 0*8(%rdi)
25738 - movq %r10, -1*8(%rdi, %rdx)
25739 + movq %r9, -1*8(%rdi, %rdx)
25740 jmp 13f
25741 10:
25742 cmpq $4, %rdx
25743 @@ -178,9 +178,9 @@ ENTRY(memmove)
25744 * Move data from 4 bytes to 7 bytes.
25745 */
25746 movl (%rsi), %r11d
25747 - movl -4(%rsi, %rdx), %r10d
25748 + movl -4(%rsi, %rdx), %r9d
25749 movl %r11d, (%rdi)
25750 - movl %r10d, -4(%rdi, %rdx)
25751 + movl %r9d, -4(%rdi, %rdx)
25752 jmp 13f
25753 11:
25754 cmp $2, %rdx
25755 @@ -189,9 +189,9 @@ ENTRY(memmove)
25756 * Move data from 2 bytes to 3 bytes.
25757 */
25758 movw (%rsi), %r11w
25759 - movw -2(%rsi, %rdx), %r10w
25760 + movw -2(%rsi, %rdx), %r9w
25761 movw %r11w, (%rdi)
25762 - movw %r10w, -2(%rdi, %rdx)
25763 + movw %r9w, -2(%rdi, %rdx)
25764 jmp 13f
25765 12:
25766 cmp $1, %rdx
25767 @@ -202,6 +202,7 @@ ENTRY(memmove)
25768 movb (%rsi), %r11b
25769 movb %r11b, (%rdi)
25770 13:
25771 + pax_force_retaddr
25772 retq
25773 CFI_ENDPROC
25774
25775 @@ -210,6 +211,7 @@ ENTRY(memmove)
25776 /* Forward moving data. */
25777 movq %rdx, %rcx
25778 rep movsb
25779 + pax_force_retaddr
25780 retq
25781 .Lmemmove_end_forward_efs:
25782 .previous
25783 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
25784 index 2dcb380..963660a 100644
25785 --- a/arch/x86/lib/memset_64.S
25786 +++ b/arch/x86/lib/memset_64.S
25787 @@ -30,6 +30,7 @@
25788 movl %edx,%ecx
25789 rep stosb
25790 movq %r9,%rax
25791 + pax_force_retaddr
25792 ret
25793 .Lmemset_e:
25794 .previous
25795 @@ -52,6 +53,7 @@
25796 movq %rdx,%rcx
25797 rep stosb
25798 movq %r9,%rax
25799 + pax_force_retaddr
25800 ret
25801 .Lmemset_e_e:
25802 .previous
25803 @@ -59,7 +61,7 @@
25804 ENTRY(memset)
25805 ENTRY(__memset)
25806 CFI_STARTPROC
25807 - movq %rdi,%r10
25808 + movq %rdi,%r11
25809
25810 /* expand byte value */
25811 movzbl %sil,%ecx
25812 @@ -117,7 +119,8 @@ ENTRY(__memset)
25813 jnz .Lloop_1
25814
25815 .Lende:
25816 - movq %r10,%rax
25817 + movq %r11,%rax
25818 + pax_force_retaddr
25819 ret
25820
25821 CFI_RESTORE_STATE
25822 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
25823 index c9f2d9b..e7fd2c0 100644
25824 --- a/arch/x86/lib/mmx_32.c
25825 +++ b/arch/x86/lib/mmx_32.c
25826 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25827 {
25828 void *p;
25829 int i;
25830 + unsigned long cr0;
25831
25832 if (unlikely(in_interrupt()))
25833 return __memcpy(to, from, len);
25834 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25835 kernel_fpu_begin();
25836
25837 __asm__ __volatile__ (
25838 - "1: prefetch (%0)\n" /* This set is 28 bytes */
25839 - " prefetch 64(%0)\n"
25840 - " prefetch 128(%0)\n"
25841 - " prefetch 192(%0)\n"
25842 - " prefetch 256(%0)\n"
25843 + "1: prefetch (%1)\n" /* This set is 28 bytes */
25844 + " prefetch 64(%1)\n"
25845 + " prefetch 128(%1)\n"
25846 + " prefetch 192(%1)\n"
25847 + " prefetch 256(%1)\n"
25848 "2: \n"
25849 ".section .fixup, \"ax\"\n"
25850 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25851 + "3: \n"
25852 +
25853 +#ifdef CONFIG_PAX_KERNEXEC
25854 + " movl %%cr0, %0\n"
25855 + " movl %0, %%eax\n"
25856 + " andl $0xFFFEFFFF, %%eax\n"
25857 + " movl %%eax, %%cr0\n"
25858 +#endif
25859 +
25860 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25861 +
25862 +#ifdef CONFIG_PAX_KERNEXEC
25863 + " movl %0, %%cr0\n"
25864 +#endif
25865 +
25866 " jmp 2b\n"
25867 ".previous\n"
25868 _ASM_EXTABLE(1b, 3b)
25869 - : : "r" (from));
25870 + : "=&r" (cr0) : "r" (from) : "ax");
25871
25872 for ( ; i > 5; i--) {
25873 __asm__ __volatile__ (
25874 - "1: prefetch 320(%0)\n"
25875 - "2: movq (%0), %%mm0\n"
25876 - " movq 8(%0), %%mm1\n"
25877 - " movq 16(%0), %%mm2\n"
25878 - " movq 24(%0), %%mm3\n"
25879 - " movq %%mm0, (%1)\n"
25880 - " movq %%mm1, 8(%1)\n"
25881 - " movq %%mm2, 16(%1)\n"
25882 - " movq %%mm3, 24(%1)\n"
25883 - " movq 32(%0), %%mm0\n"
25884 - " movq 40(%0), %%mm1\n"
25885 - " movq 48(%0), %%mm2\n"
25886 - " movq 56(%0), %%mm3\n"
25887 - " movq %%mm0, 32(%1)\n"
25888 - " movq %%mm1, 40(%1)\n"
25889 - " movq %%mm2, 48(%1)\n"
25890 - " movq %%mm3, 56(%1)\n"
25891 + "1: prefetch 320(%1)\n"
25892 + "2: movq (%1), %%mm0\n"
25893 + " movq 8(%1), %%mm1\n"
25894 + " movq 16(%1), %%mm2\n"
25895 + " movq 24(%1), %%mm3\n"
25896 + " movq %%mm0, (%2)\n"
25897 + " movq %%mm1, 8(%2)\n"
25898 + " movq %%mm2, 16(%2)\n"
25899 + " movq %%mm3, 24(%2)\n"
25900 + " movq 32(%1), %%mm0\n"
25901 + " movq 40(%1), %%mm1\n"
25902 + " movq 48(%1), %%mm2\n"
25903 + " movq 56(%1), %%mm3\n"
25904 + " movq %%mm0, 32(%2)\n"
25905 + " movq %%mm1, 40(%2)\n"
25906 + " movq %%mm2, 48(%2)\n"
25907 + " movq %%mm3, 56(%2)\n"
25908 ".section .fixup, \"ax\"\n"
25909 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25910 + "3:\n"
25911 +
25912 +#ifdef CONFIG_PAX_KERNEXEC
25913 + " movl %%cr0, %0\n"
25914 + " movl %0, %%eax\n"
25915 + " andl $0xFFFEFFFF, %%eax\n"
25916 + " movl %%eax, %%cr0\n"
25917 +#endif
25918 +
25919 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25920 +
25921 +#ifdef CONFIG_PAX_KERNEXEC
25922 + " movl %0, %%cr0\n"
25923 +#endif
25924 +
25925 " jmp 2b\n"
25926 ".previous\n"
25927 _ASM_EXTABLE(1b, 3b)
25928 - : : "r" (from), "r" (to) : "memory");
25929 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
25930
25931 from += 64;
25932 to += 64;
25933 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
25934 static void fast_copy_page(void *to, void *from)
25935 {
25936 int i;
25937 + unsigned long cr0;
25938
25939 kernel_fpu_begin();
25940
25941 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
25942 * but that is for later. -AV
25943 */
25944 __asm__ __volatile__(
25945 - "1: prefetch (%0)\n"
25946 - " prefetch 64(%0)\n"
25947 - " prefetch 128(%0)\n"
25948 - " prefetch 192(%0)\n"
25949 - " prefetch 256(%0)\n"
25950 + "1: prefetch (%1)\n"
25951 + " prefetch 64(%1)\n"
25952 + " prefetch 128(%1)\n"
25953 + " prefetch 192(%1)\n"
25954 + " prefetch 256(%1)\n"
25955 "2: \n"
25956 ".section .fixup, \"ax\"\n"
25957 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25958 + "3: \n"
25959 +
25960 +#ifdef CONFIG_PAX_KERNEXEC
25961 + " movl %%cr0, %0\n"
25962 + " movl %0, %%eax\n"
25963 + " andl $0xFFFEFFFF, %%eax\n"
25964 + " movl %%eax, %%cr0\n"
25965 +#endif
25966 +
25967 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25968 +
25969 +#ifdef CONFIG_PAX_KERNEXEC
25970 + " movl %0, %%cr0\n"
25971 +#endif
25972 +
25973 " jmp 2b\n"
25974 ".previous\n"
25975 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
25976 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
25977
25978 for (i = 0; i < (4096-320)/64; i++) {
25979 __asm__ __volatile__ (
25980 - "1: prefetch 320(%0)\n"
25981 - "2: movq (%0), %%mm0\n"
25982 - " movntq %%mm0, (%1)\n"
25983 - " movq 8(%0), %%mm1\n"
25984 - " movntq %%mm1, 8(%1)\n"
25985 - " movq 16(%0), %%mm2\n"
25986 - " movntq %%mm2, 16(%1)\n"
25987 - " movq 24(%0), %%mm3\n"
25988 - " movntq %%mm3, 24(%1)\n"
25989 - " movq 32(%0), %%mm4\n"
25990 - " movntq %%mm4, 32(%1)\n"
25991 - " movq 40(%0), %%mm5\n"
25992 - " movntq %%mm5, 40(%1)\n"
25993 - " movq 48(%0), %%mm6\n"
25994 - " movntq %%mm6, 48(%1)\n"
25995 - " movq 56(%0), %%mm7\n"
25996 - " movntq %%mm7, 56(%1)\n"
25997 + "1: prefetch 320(%1)\n"
25998 + "2: movq (%1), %%mm0\n"
25999 + " movntq %%mm0, (%2)\n"
26000 + " movq 8(%1), %%mm1\n"
26001 + " movntq %%mm1, 8(%2)\n"
26002 + " movq 16(%1), %%mm2\n"
26003 + " movntq %%mm2, 16(%2)\n"
26004 + " movq 24(%1), %%mm3\n"
26005 + " movntq %%mm3, 24(%2)\n"
26006 + " movq 32(%1), %%mm4\n"
26007 + " movntq %%mm4, 32(%2)\n"
26008 + " movq 40(%1), %%mm5\n"
26009 + " movntq %%mm5, 40(%2)\n"
26010 + " movq 48(%1), %%mm6\n"
26011 + " movntq %%mm6, 48(%2)\n"
26012 + " movq 56(%1), %%mm7\n"
26013 + " movntq %%mm7, 56(%2)\n"
26014 ".section .fixup, \"ax\"\n"
26015 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26016 + "3:\n"
26017 +
26018 +#ifdef CONFIG_PAX_KERNEXEC
26019 + " movl %%cr0, %0\n"
26020 + " movl %0, %%eax\n"
26021 + " andl $0xFFFEFFFF, %%eax\n"
26022 + " movl %%eax, %%cr0\n"
26023 +#endif
26024 +
26025 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26026 +
26027 +#ifdef CONFIG_PAX_KERNEXEC
26028 + " movl %0, %%cr0\n"
26029 +#endif
26030 +
26031 " jmp 2b\n"
26032 ".previous\n"
26033 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
26034 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26035
26036 from += 64;
26037 to += 64;
26038 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
26039 static void fast_copy_page(void *to, void *from)
26040 {
26041 int i;
26042 + unsigned long cr0;
26043
26044 kernel_fpu_begin();
26045
26046 __asm__ __volatile__ (
26047 - "1: prefetch (%0)\n"
26048 - " prefetch 64(%0)\n"
26049 - " prefetch 128(%0)\n"
26050 - " prefetch 192(%0)\n"
26051 - " prefetch 256(%0)\n"
26052 + "1: prefetch (%1)\n"
26053 + " prefetch 64(%1)\n"
26054 + " prefetch 128(%1)\n"
26055 + " prefetch 192(%1)\n"
26056 + " prefetch 256(%1)\n"
26057 "2: \n"
26058 ".section .fixup, \"ax\"\n"
26059 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26060 + "3: \n"
26061 +
26062 +#ifdef CONFIG_PAX_KERNEXEC
26063 + " movl %%cr0, %0\n"
26064 + " movl %0, %%eax\n"
26065 + " andl $0xFFFEFFFF, %%eax\n"
26066 + " movl %%eax, %%cr0\n"
26067 +#endif
26068 +
26069 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26070 +
26071 +#ifdef CONFIG_PAX_KERNEXEC
26072 + " movl %0, %%cr0\n"
26073 +#endif
26074 +
26075 " jmp 2b\n"
26076 ".previous\n"
26077 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26078 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26079
26080 for (i = 0; i < 4096/64; i++) {
26081 __asm__ __volatile__ (
26082 - "1: prefetch 320(%0)\n"
26083 - "2: movq (%0), %%mm0\n"
26084 - " movq 8(%0), %%mm1\n"
26085 - " movq 16(%0), %%mm2\n"
26086 - " movq 24(%0), %%mm3\n"
26087 - " movq %%mm0, (%1)\n"
26088 - " movq %%mm1, 8(%1)\n"
26089 - " movq %%mm2, 16(%1)\n"
26090 - " movq %%mm3, 24(%1)\n"
26091 - " movq 32(%0), %%mm0\n"
26092 - " movq 40(%0), %%mm1\n"
26093 - " movq 48(%0), %%mm2\n"
26094 - " movq 56(%0), %%mm3\n"
26095 - " movq %%mm0, 32(%1)\n"
26096 - " movq %%mm1, 40(%1)\n"
26097 - " movq %%mm2, 48(%1)\n"
26098 - " movq %%mm3, 56(%1)\n"
26099 + "1: prefetch 320(%1)\n"
26100 + "2: movq (%1), %%mm0\n"
26101 + " movq 8(%1), %%mm1\n"
26102 + " movq 16(%1), %%mm2\n"
26103 + " movq 24(%1), %%mm3\n"
26104 + " movq %%mm0, (%2)\n"
26105 + " movq %%mm1, 8(%2)\n"
26106 + " movq %%mm2, 16(%2)\n"
26107 + " movq %%mm3, 24(%2)\n"
26108 + " movq 32(%1), %%mm0\n"
26109 + " movq 40(%1), %%mm1\n"
26110 + " movq 48(%1), %%mm2\n"
26111 + " movq 56(%1), %%mm3\n"
26112 + " movq %%mm0, 32(%2)\n"
26113 + " movq %%mm1, 40(%2)\n"
26114 + " movq %%mm2, 48(%2)\n"
26115 + " movq %%mm3, 56(%2)\n"
26116 ".section .fixup, \"ax\"\n"
26117 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26118 + "3:\n"
26119 +
26120 +#ifdef CONFIG_PAX_KERNEXEC
26121 + " movl %%cr0, %0\n"
26122 + " movl %0, %%eax\n"
26123 + " andl $0xFFFEFFFF, %%eax\n"
26124 + " movl %%eax, %%cr0\n"
26125 +#endif
26126 +
26127 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26128 +
26129 +#ifdef CONFIG_PAX_KERNEXEC
26130 + " movl %0, %%cr0\n"
26131 +#endif
26132 +
26133 " jmp 2b\n"
26134 ".previous\n"
26135 _ASM_EXTABLE(1b, 3b)
26136 - : : "r" (from), "r" (to) : "memory");
26137 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26138
26139 from += 64;
26140 to += 64;
26141 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26142 index f6d13ee..aca5f0b 100644
26143 --- a/arch/x86/lib/msr-reg.S
26144 +++ b/arch/x86/lib/msr-reg.S
26145 @@ -3,6 +3,7 @@
26146 #include <asm/dwarf2.h>
26147 #include <asm/asm.h>
26148 #include <asm/msr.h>
26149 +#include <asm/alternative-asm.h>
26150
26151 #ifdef CONFIG_X86_64
26152 /*
26153 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26154 CFI_STARTPROC
26155 pushq_cfi %rbx
26156 pushq_cfi %rbp
26157 - movq %rdi, %r10 /* Save pointer */
26158 + movq %rdi, %r9 /* Save pointer */
26159 xorl %r11d, %r11d /* Return value */
26160 movl (%rdi), %eax
26161 movl 4(%rdi), %ecx
26162 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26163 movl 28(%rdi), %edi
26164 CFI_REMEMBER_STATE
26165 1: \op
26166 -2: movl %eax, (%r10)
26167 +2: movl %eax, (%r9)
26168 movl %r11d, %eax /* Return value */
26169 - movl %ecx, 4(%r10)
26170 - movl %edx, 8(%r10)
26171 - movl %ebx, 12(%r10)
26172 - movl %ebp, 20(%r10)
26173 - movl %esi, 24(%r10)
26174 - movl %edi, 28(%r10)
26175 + movl %ecx, 4(%r9)
26176 + movl %edx, 8(%r9)
26177 + movl %ebx, 12(%r9)
26178 + movl %ebp, 20(%r9)
26179 + movl %esi, 24(%r9)
26180 + movl %edi, 28(%r9)
26181 popq_cfi %rbp
26182 popq_cfi %rbx
26183 + pax_force_retaddr
26184 ret
26185 3:
26186 CFI_RESTORE_STATE
26187 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26188 index fc6ba17..d4d989d 100644
26189 --- a/arch/x86/lib/putuser.S
26190 +++ b/arch/x86/lib/putuser.S
26191 @@ -16,7 +16,9 @@
26192 #include <asm/errno.h>
26193 #include <asm/asm.h>
26194 #include <asm/smap.h>
26195 -
26196 +#include <asm/segment.h>
26197 +#include <asm/pgtable.h>
26198 +#include <asm/alternative-asm.h>
26199
26200 /*
26201 * __put_user_X
26202 @@ -30,57 +32,125 @@
26203 * as they get called from within inline assembly.
26204 */
26205
26206 -#define ENTER CFI_STARTPROC ; \
26207 - GET_THREAD_INFO(%_ASM_BX)
26208 -#define EXIT ASM_CLAC ; \
26209 - ret ; \
26210 +#define ENTER CFI_STARTPROC
26211 +#define EXIT ASM_CLAC ; \
26212 + pax_force_retaddr ; \
26213 + ret ; \
26214 CFI_ENDPROC
26215
26216 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26217 +#define _DEST %_ASM_CX,%_ASM_BX
26218 +#else
26219 +#define _DEST %_ASM_CX
26220 +#endif
26221 +
26222 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26223 +#define __copyuser_seg gs;
26224 +#else
26225 +#define __copyuser_seg
26226 +#endif
26227 +
26228 .text
26229 ENTRY(__put_user_1)
26230 ENTER
26231 +
26232 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26233 + GET_THREAD_INFO(%_ASM_BX)
26234 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26235 jae bad_put_user
26236 ASM_STAC
26237 -1: movb %al,(%_ASM_CX)
26238 +
26239 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26240 + mov pax_user_shadow_base,%_ASM_BX
26241 + cmp %_ASM_BX,%_ASM_CX
26242 + jb 1234f
26243 + xor %ebx,%ebx
26244 +1234:
26245 +#endif
26246 +
26247 +#endif
26248 +
26249 +1: __copyuser_seg movb %al,(_DEST)
26250 xor %eax,%eax
26251 EXIT
26252 ENDPROC(__put_user_1)
26253
26254 ENTRY(__put_user_2)
26255 ENTER
26256 +
26257 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26258 + GET_THREAD_INFO(%_ASM_BX)
26259 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26260 sub $1,%_ASM_BX
26261 cmp %_ASM_BX,%_ASM_CX
26262 jae bad_put_user
26263 ASM_STAC
26264 -2: movw %ax,(%_ASM_CX)
26265 +
26266 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26267 + mov pax_user_shadow_base,%_ASM_BX
26268 + cmp %_ASM_BX,%_ASM_CX
26269 + jb 1234f
26270 + xor %ebx,%ebx
26271 +1234:
26272 +#endif
26273 +
26274 +#endif
26275 +
26276 +2: __copyuser_seg movw %ax,(_DEST)
26277 xor %eax,%eax
26278 EXIT
26279 ENDPROC(__put_user_2)
26280
26281 ENTRY(__put_user_4)
26282 ENTER
26283 +
26284 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26285 + GET_THREAD_INFO(%_ASM_BX)
26286 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26287 sub $3,%_ASM_BX
26288 cmp %_ASM_BX,%_ASM_CX
26289 jae bad_put_user
26290 ASM_STAC
26291 -3: movl %eax,(%_ASM_CX)
26292 +
26293 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26294 + mov pax_user_shadow_base,%_ASM_BX
26295 + cmp %_ASM_BX,%_ASM_CX
26296 + jb 1234f
26297 + xor %ebx,%ebx
26298 +1234:
26299 +#endif
26300 +
26301 +#endif
26302 +
26303 +3: __copyuser_seg movl %eax,(_DEST)
26304 xor %eax,%eax
26305 EXIT
26306 ENDPROC(__put_user_4)
26307
26308 ENTRY(__put_user_8)
26309 ENTER
26310 +
26311 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26312 + GET_THREAD_INFO(%_ASM_BX)
26313 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26314 sub $7,%_ASM_BX
26315 cmp %_ASM_BX,%_ASM_CX
26316 jae bad_put_user
26317 ASM_STAC
26318 -4: mov %_ASM_AX,(%_ASM_CX)
26319 +
26320 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26321 + mov pax_user_shadow_base,%_ASM_BX
26322 + cmp %_ASM_BX,%_ASM_CX
26323 + jb 1234f
26324 + xor %ebx,%ebx
26325 +1234:
26326 +#endif
26327 +
26328 +#endif
26329 +
26330 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26331 #ifdef CONFIG_X86_32
26332 -5: movl %edx,4(%_ASM_CX)
26333 +5: __copyuser_seg movl %edx,4(_DEST)
26334 #endif
26335 xor %eax,%eax
26336 EXIT
26337 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26338 index 1cad221..de671ee 100644
26339 --- a/arch/x86/lib/rwlock.S
26340 +++ b/arch/x86/lib/rwlock.S
26341 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26342 FRAME
26343 0: LOCK_PREFIX
26344 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26345 +
26346 +#ifdef CONFIG_PAX_REFCOUNT
26347 + jno 1234f
26348 + LOCK_PREFIX
26349 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26350 + int $4
26351 +1234:
26352 + _ASM_EXTABLE(1234b, 1234b)
26353 +#endif
26354 +
26355 1: rep; nop
26356 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26357 jne 1b
26358 LOCK_PREFIX
26359 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26360 +
26361 +#ifdef CONFIG_PAX_REFCOUNT
26362 + jno 1234f
26363 + LOCK_PREFIX
26364 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26365 + int $4
26366 +1234:
26367 + _ASM_EXTABLE(1234b, 1234b)
26368 +#endif
26369 +
26370 jnz 0b
26371 ENDFRAME
26372 + pax_force_retaddr
26373 ret
26374 CFI_ENDPROC
26375 END(__write_lock_failed)
26376 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26377 FRAME
26378 0: LOCK_PREFIX
26379 READ_LOCK_SIZE(inc) (%__lock_ptr)
26380 +
26381 +#ifdef CONFIG_PAX_REFCOUNT
26382 + jno 1234f
26383 + LOCK_PREFIX
26384 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26385 + int $4
26386 +1234:
26387 + _ASM_EXTABLE(1234b, 1234b)
26388 +#endif
26389 +
26390 1: rep; nop
26391 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26392 js 1b
26393 LOCK_PREFIX
26394 READ_LOCK_SIZE(dec) (%__lock_ptr)
26395 +
26396 +#ifdef CONFIG_PAX_REFCOUNT
26397 + jno 1234f
26398 + LOCK_PREFIX
26399 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26400 + int $4
26401 +1234:
26402 + _ASM_EXTABLE(1234b, 1234b)
26403 +#endif
26404 +
26405 js 0b
26406 ENDFRAME
26407 + pax_force_retaddr
26408 ret
26409 CFI_ENDPROC
26410 END(__read_lock_failed)
26411 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26412 index 5dff5f0..cadebf4 100644
26413 --- a/arch/x86/lib/rwsem.S
26414 +++ b/arch/x86/lib/rwsem.S
26415 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26416 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26417 CFI_RESTORE __ASM_REG(dx)
26418 restore_common_regs
26419 + pax_force_retaddr
26420 ret
26421 CFI_ENDPROC
26422 ENDPROC(call_rwsem_down_read_failed)
26423 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26424 movq %rax,%rdi
26425 call rwsem_down_write_failed
26426 restore_common_regs
26427 + pax_force_retaddr
26428 ret
26429 CFI_ENDPROC
26430 ENDPROC(call_rwsem_down_write_failed)
26431 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26432 movq %rax,%rdi
26433 call rwsem_wake
26434 restore_common_regs
26435 -1: ret
26436 +1: pax_force_retaddr
26437 + ret
26438 CFI_ENDPROC
26439 ENDPROC(call_rwsem_wake)
26440
26441 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26442 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26443 CFI_RESTORE __ASM_REG(dx)
26444 restore_common_regs
26445 + pax_force_retaddr
26446 ret
26447 CFI_ENDPROC
26448 ENDPROC(call_rwsem_downgrade_wake)
26449 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26450 index a63efd6..ccecad8 100644
26451 --- a/arch/x86/lib/thunk_64.S
26452 +++ b/arch/x86/lib/thunk_64.S
26453 @@ -8,6 +8,7 @@
26454 #include <linux/linkage.h>
26455 #include <asm/dwarf2.h>
26456 #include <asm/calling.h>
26457 +#include <asm/alternative-asm.h>
26458
26459 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26460 .macro THUNK name, func, put_ret_addr_in_rdi=0
26461 @@ -41,5 +42,6 @@
26462 SAVE_ARGS
26463 restore:
26464 RESTORE_ARGS
26465 + pax_force_retaddr
26466 ret
26467 CFI_ENDPROC
26468 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26469 index f0312d7..9c39d63 100644
26470 --- a/arch/x86/lib/usercopy_32.c
26471 +++ b/arch/x86/lib/usercopy_32.c
26472 @@ -42,11 +42,13 @@ do { \
26473 int __d0; \
26474 might_fault(); \
26475 __asm__ __volatile__( \
26476 + __COPYUSER_SET_ES \
26477 ASM_STAC "\n" \
26478 "0: rep; stosl\n" \
26479 " movl %2,%0\n" \
26480 "1: rep; stosb\n" \
26481 "2: " ASM_CLAC "\n" \
26482 + __COPYUSER_RESTORE_ES \
26483 ".section .fixup,\"ax\"\n" \
26484 "3: lea 0(%2,%0,4),%0\n" \
26485 " jmp 2b\n" \
26486 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26487
26488 #ifdef CONFIG_X86_INTEL_USERCOPY
26489 static unsigned long
26490 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26491 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26492 {
26493 int d0, d1;
26494 __asm__ __volatile__(
26495 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26496 " .align 2,0x90\n"
26497 "3: movl 0(%4), %%eax\n"
26498 "4: movl 4(%4), %%edx\n"
26499 - "5: movl %%eax, 0(%3)\n"
26500 - "6: movl %%edx, 4(%3)\n"
26501 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26502 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26503 "7: movl 8(%4), %%eax\n"
26504 "8: movl 12(%4),%%edx\n"
26505 - "9: movl %%eax, 8(%3)\n"
26506 - "10: movl %%edx, 12(%3)\n"
26507 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26508 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26509 "11: movl 16(%4), %%eax\n"
26510 "12: movl 20(%4), %%edx\n"
26511 - "13: movl %%eax, 16(%3)\n"
26512 - "14: movl %%edx, 20(%3)\n"
26513 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26514 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26515 "15: movl 24(%4), %%eax\n"
26516 "16: movl 28(%4), %%edx\n"
26517 - "17: movl %%eax, 24(%3)\n"
26518 - "18: movl %%edx, 28(%3)\n"
26519 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26520 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26521 "19: movl 32(%4), %%eax\n"
26522 "20: movl 36(%4), %%edx\n"
26523 - "21: movl %%eax, 32(%3)\n"
26524 - "22: movl %%edx, 36(%3)\n"
26525 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26526 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26527 "23: movl 40(%4), %%eax\n"
26528 "24: movl 44(%4), %%edx\n"
26529 - "25: movl %%eax, 40(%3)\n"
26530 - "26: movl %%edx, 44(%3)\n"
26531 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26532 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26533 "27: movl 48(%4), %%eax\n"
26534 "28: movl 52(%4), %%edx\n"
26535 - "29: movl %%eax, 48(%3)\n"
26536 - "30: movl %%edx, 52(%3)\n"
26537 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26538 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26539 "31: movl 56(%4), %%eax\n"
26540 "32: movl 60(%4), %%edx\n"
26541 - "33: movl %%eax, 56(%3)\n"
26542 - "34: movl %%edx, 60(%3)\n"
26543 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26544 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26545 " addl $-64, %0\n"
26546 " addl $64, %4\n"
26547 " addl $64, %3\n"
26548 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26549 " shrl $2, %0\n"
26550 " andl $3, %%eax\n"
26551 " cld\n"
26552 + __COPYUSER_SET_ES
26553 "99: rep; movsl\n"
26554 "36: movl %%eax, %0\n"
26555 "37: rep; movsb\n"
26556 "100:\n"
26557 + __COPYUSER_RESTORE_ES
26558 ".section .fixup,\"ax\"\n"
26559 "101: lea 0(%%eax,%0,4),%0\n"
26560 " jmp 100b\n"
26561 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26562 }
26563
26564 static unsigned long
26565 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26566 +{
26567 + int d0, d1;
26568 + __asm__ __volatile__(
26569 + " .align 2,0x90\n"
26570 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26571 + " cmpl $67, %0\n"
26572 + " jbe 3f\n"
26573 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26574 + " .align 2,0x90\n"
26575 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26576 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26577 + "5: movl %%eax, 0(%3)\n"
26578 + "6: movl %%edx, 4(%3)\n"
26579 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26580 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26581 + "9: movl %%eax, 8(%3)\n"
26582 + "10: movl %%edx, 12(%3)\n"
26583 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26584 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26585 + "13: movl %%eax, 16(%3)\n"
26586 + "14: movl %%edx, 20(%3)\n"
26587 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26588 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26589 + "17: movl %%eax, 24(%3)\n"
26590 + "18: movl %%edx, 28(%3)\n"
26591 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26592 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26593 + "21: movl %%eax, 32(%3)\n"
26594 + "22: movl %%edx, 36(%3)\n"
26595 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26596 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26597 + "25: movl %%eax, 40(%3)\n"
26598 + "26: movl %%edx, 44(%3)\n"
26599 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26600 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26601 + "29: movl %%eax, 48(%3)\n"
26602 + "30: movl %%edx, 52(%3)\n"
26603 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26604 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26605 + "33: movl %%eax, 56(%3)\n"
26606 + "34: movl %%edx, 60(%3)\n"
26607 + " addl $-64, %0\n"
26608 + " addl $64, %4\n"
26609 + " addl $64, %3\n"
26610 + " cmpl $63, %0\n"
26611 + " ja 1b\n"
26612 + "35: movl %0, %%eax\n"
26613 + " shrl $2, %0\n"
26614 + " andl $3, %%eax\n"
26615 + " cld\n"
26616 + "99: rep; "__copyuser_seg" movsl\n"
26617 + "36: movl %%eax, %0\n"
26618 + "37: rep; "__copyuser_seg" movsb\n"
26619 + "100:\n"
26620 + ".section .fixup,\"ax\"\n"
26621 + "101: lea 0(%%eax,%0,4),%0\n"
26622 + " jmp 100b\n"
26623 + ".previous\n"
26624 + _ASM_EXTABLE(1b,100b)
26625 + _ASM_EXTABLE(2b,100b)
26626 + _ASM_EXTABLE(3b,100b)
26627 + _ASM_EXTABLE(4b,100b)
26628 + _ASM_EXTABLE(5b,100b)
26629 + _ASM_EXTABLE(6b,100b)
26630 + _ASM_EXTABLE(7b,100b)
26631 + _ASM_EXTABLE(8b,100b)
26632 + _ASM_EXTABLE(9b,100b)
26633 + _ASM_EXTABLE(10b,100b)
26634 + _ASM_EXTABLE(11b,100b)
26635 + _ASM_EXTABLE(12b,100b)
26636 + _ASM_EXTABLE(13b,100b)
26637 + _ASM_EXTABLE(14b,100b)
26638 + _ASM_EXTABLE(15b,100b)
26639 + _ASM_EXTABLE(16b,100b)
26640 + _ASM_EXTABLE(17b,100b)
26641 + _ASM_EXTABLE(18b,100b)
26642 + _ASM_EXTABLE(19b,100b)
26643 + _ASM_EXTABLE(20b,100b)
26644 + _ASM_EXTABLE(21b,100b)
26645 + _ASM_EXTABLE(22b,100b)
26646 + _ASM_EXTABLE(23b,100b)
26647 + _ASM_EXTABLE(24b,100b)
26648 + _ASM_EXTABLE(25b,100b)
26649 + _ASM_EXTABLE(26b,100b)
26650 + _ASM_EXTABLE(27b,100b)
26651 + _ASM_EXTABLE(28b,100b)
26652 + _ASM_EXTABLE(29b,100b)
26653 + _ASM_EXTABLE(30b,100b)
26654 + _ASM_EXTABLE(31b,100b)
26655 + _ASM_EXTABLE(32b,100b)
26656 + _ASM_EXTABLE(33b,100b)
26657 + _ASM_EXTABLE(34b,100b)
26658 + _ASM_EXTABLE(35b,100b)
26659 + _ASM_EXTABLE(36b,100b)
26660 + _ASM_EXTABLE(37b,100b)
26661 + _ASM_EXTABLE(99b,101b)
26662 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26663 + : "1"(to), "2"(from), "0"(size)
26664 + : "eax", "edx", "memory");
26665 + return size;
26666 +}
26667 +
26668 +static unsigned long __size_overflow(3)
26669 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26670 {
26671 int d0, d1;
26672 __asm__ __volatile__(
26673 " .align 2,0x90\n"
26674 - "0: movl 32(%4), %%eax\n"
26675 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26676 " cmpl $67, %0\n"
26677 " jbe 2f\n"
26678 - "1: movl 64(%4), %%eax\n"
26679 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26680 " .align 2,0x90\n"
26681 - "2: movl 0(%4), %%eax\n"
26682 - "21: movl 4(%4), %%edx\n"
26683 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26684 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26685 " movl %%eax, 0(%3)\n"
26686 " movl %%edx, 4(%3)\n"
26687 - "3: movl 8(%4), %%eax\n"
26688 - "31: movl 12(%4),%%edx\n"
26689 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26690 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26691 " movl %%eax, 8(%3)\n"
26692 " movl %%edx, 12(%3)\n"
26693 - "4: movl 16(%4), %%eax\n"
26694 - "41: movl 20(%4), %%edx\n"
26695 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26696 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26697 " movl %%eax, 16(%3)\n"
26698 " movl %%edx, 20(%3)\n"
26699 - "10: movl 24(%4), %%eax\n"
26700 - "51: movl 28(%4), %%edx\n"
26701 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26702 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26703 " movl %%eax, 24(%3)\n"
26704 " movl %%edx, 28(%3)\n"
26705 - "11: movl 32(%4), %%eax\n"
26706 - "61: movl 36(%4), %%edx\n"
26707 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26708 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26709 " movl %%eax, 32(%3)\n"
26710 " movl %%edx, 36(%3)\n"
26711 - "12: movl 40(%4), %%eax\n"
26712 - "71: movl 44(%4), %%edx\n"
26713 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26714 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26715 " movl %%eax, 40(%3)\n"
26716 " movl %%edx, 44(%3)\n"
26717 - "13: movl 48(%4), %%eax\n"
26718 - "81: movl 52(%4), %%edx\n"
26719 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26720 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26721 " movl %%eax, 48(%3)\n"
26722 " movl %%edx, 52(%3)\n"
26723 - "14: movl 56(%4), %%eax\n"
26724 - "91: movl 60(%4), %%edx\n"
26725 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26726 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26727 " movl %%eax, 56(%3)\n"
26728 " movl %%edx, 60(%3)\n"
26729 " addl $-64, %0\n"
26730 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26731 " shrl $2, %0\n"
26732 " andl $3, %%eax\n"
26733 " cld\n"
26734 - "6: rep; movsl\n"
26735 + "6: rep; "__copyuser_seg" movsl\n"
26736 " movl %%eax,%0\n"
26737 - "7: rep; movsb\n"
26738 + "7: rep; "__copyuser_seg" movsb\n"
26739 "8:\n"
26740 ".section .fixup,\"ax\"\n"
26741 "9: lea 0(%%eax,%0,4),%0\n"
26742 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26743 * hyoshiok@miraclelinux.com
26744 */
26745
26746 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26747 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
26748 const void __user *from, unsigned long size)
26749 {
26750 int d0, d1;
26751
26752 __asm__ __volatile__(
26753 " .align 2,0x90\n"
26754 - "0: movl 32(%4), %%eax\n"
26755 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26756 " cmpl $67, %0\n"
26757 " jbe 2f\n"
26758 - "1: movl 64(%4), %%eax\n"
26759 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26760 " .align 2,0x90\n"
26761 - "2: movl 0(%4), %%eax\n"
26762 - "21: movl 4(%4), %%edx\n"
26763 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26764 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26765 " movnti %%eax, 0(%3)\n"
26766 " movnti %%edx, 4(%3)\n"
26767 - "3: movl 8(%4), %%eax\n"
26768 - "31: movl 12(%4),%%edx\n"
26769 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26770 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26771 " movnti %%eax, 8(%3)\n"
26772 " movnti %%edx, 12(%3)\n"
26773 - "4: movl 16(%4), %%eax\n"
26774 - "41: movl 20(%4), %%edx\n"
26775 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26776 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26777 " movnti %%eax, 16(%3)\n"
26778 " movnti %%edx, 20(%3)\n"
26779 - "10: movl 24(%4), %%eax\n"
26780 - "51: movl 28(%4), %%edx\n"
26781 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26782 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26783 " movnti %%eax, 24(%3)\n"
26784 " movnti %%edx, 28(%3)\n"
26785 - "11: movl 32(%4), %%eax\n"
26786 - "61: movl 36(%4), %%edx\n"
26787 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26788 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26789 " movnti %%eax, 32(%3)\n"
26790 " movnti %%edx, 36(%3)\n"
26791 - "12: movl 40(%4), %%eax\n"
26792 - "71: movl 44(%4), %%edx\n"
26793 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26794 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26795 " movnti %%eax, 40(%3)\n"
26796 " movnti %%edx, 44(%3)\n"
26797 - "13: movl 48(%4), %%eax\n"
26798 - "81: movl 52(%4), %%edx\n"
26799 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26800 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26801 " movnti %%eax, 48(%3)\n"
26802 " movnti %%edx, 52(%3)\n"
26803 - "14: movl 56(%4), %%eax\n"
26804 - "91: movl 60(%4), %%edx\n"
26805 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26806 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26807 " movnti %%eax, 56(%3)\n"
26808 " movnti %%edx, 60(%3)\n"
26809 " addl $-64, %0\n"
26810 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26811 " shrl $2, %0\n"
26812 " andl $3, %%eax\n"
26813 " cld\n"
26814 - "6: rep; movsl\n"
26815 + "6: rep; "__copyuser_seg" movsl\n"
26816 " movl %%eax,%0\n"
26817 - "7: rep; movsb\n"
26818 + "7: rep; "__copyuser_seg" movsb\n"
26819 "8:\n"
26820 ".section .fixup,\"ax\"\n"
26821 "9: lea 0(%%eax,%0,4),%0\n"
26822 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26823 return size;
26824 }
26825
26826 -static unsigned long __copy_user_intel_nocache(void *to,
26827 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
26828 const void __user *from, unsigned long size)
26829 {
26830 int d0, d1;
26831
26832 __asm__ __volatile__(
26833 " .align 2,0x90\n"
26834 - "0: movl 32(%4), %%eax\n"
26835 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26836 " cmpl $67, %0\n"
26837 " jbe 2f\n"
26838 - "1: movl 64(%4), %%eax\n"
26839 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26840 " .align 2,0x90\n"
26841 - "2: movl 0(%4), %%eax\n"
26842 - "21: movl 4(%4), %%edx\n"
26843 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26844 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26845 " movnti %%eax, 0(%3)\n"
26846 " movnti %%edx, 4(%3)\n"
26847 - "3: movl 8(%4), %%eax\n"
26848 - "31: movl 12(%4),%%edx\n"
26849 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26850 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26851 " movnti %%eax, 8(%3)\n"
26852 " movnti %%edx, 12(%3)\n"
26853 - "4: movl 16(%4), %%eax\n"
26854 - "41: movl 20(%4), %%edx\n"
26855 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26856 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26857 " movnti %%eax, 16(%3)\n"
26858 " movnti %%edx, 20(%3)\n"
26859 - "10: movl 24(%4), %%eax\n"
26860 - "51: movl 28(%4), %%edx\n"
26861 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26862 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26863 " movnti %%eax, 24(%3)\n"
26864 " movnti %%edx, 28(%3)\n"
26865 - "11: movl 32(%4), %%eax\n"
26866 - "61: movl 36(%4), %%edx\n"
26867 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26868 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26869 " movnti %%eax, 32(%3)\n"
26870 " movnti %%edx, 36(%3)\n"
26871 - "12: movl 40(%4), %%eax\n"
26872 - "71: movl 44(%4), %%edx\n"
26873 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26874 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26875 " movnti %%eax, 40(%3)\n"
26876 " movnti %%edx, 44(%3)\n"
26877 - "13: movl 48(%4), %%eax\n"
26878 - "81: movl 52(%4), %%edx\n"
26879 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26880 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26881 " movnti %%eax, 48(%3)\n"
26882 " movnti %%edx, 52(%3)\n"
26883 - "14: movl 56(%4), %%eax\n"
26884 - "91: movl 60(%4), %%edx\n"
26885 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26886 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26887 " movnti %%eax, 56(%3)\n"
26888 " movnti %%edx, 60(%3)\n"
26889 " addl $-64, %0\n"
26890 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
26891 " shrl $2, %0\n"
26892 " andl $3, %%eax\n"
26893 " cld\n"
26894 - "6: rep; movsl\n"
26895 + "6: rep; "__copyuser_seg" movsl\n"
26896 " movl %%eax,%0\n"
26897 - "7: rep; movsb\n"
26898 + "7: rep; "__copyuser_seg" movsb\n"
26899 "8:\n"
26900 ".section .fixup,\"ax\"\n"
26901 "9: lea 0(%%eax,%0,4),%0\n"
26902 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
26903 */
26904 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
26905 unsigned long size);
26906 -unsigned long __copy_user_intel(void __user *to, const void *from,
26907 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
26908 + unsigned long size);
26909 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
26910 unsigned long size);
26911 unsigned long __copy_user_zeroing_intel_nocache(void *to,
26912 const void __user *from, unsigned long size);
26913 #endif /* CONFIG_X86_INTEL_USERCOPY */
26914
26915 /* Generic arbitrary sized copy. */
26916 -#define __copy_user(to, from, size) \
26917 +#define __copy_user(to, from, size, prefix, set, restore) \
26918 do { \
26919 int __d0, __d1, __d2; \
26920 __asm__ __volatile__( \
26921 + set \
26922 " cmp $7,%0\n" \
26923 " jbe 1f\n" \
26924 " movl %1,%0\n" \
26925 " negl %0\n" \
26926 " andl $7,%0\n" \
26927 " subl %0,%3\n" \
26928 - "4: rep; movsb\n" \
26929 + "4: rep; "prefix"movsb\n" \
26930 " movl %3,%0\n" \
26931 " shrl $2,%0\n" \
26932 " andl $3,%3\n" \
26933 " .align 2,0x90\n" \
26934 - "0: rep; movsl\n" \
26935 + "0: rep; "prefix"movsl\n" \
26936 " movl %3,%0\n" \
26937 - "1: rep; movsb\n" \
26938 + "1: rep; "prefix"movsb\n" \
26939 "2:\n" \
26940 + restore \
26941 ".section .fixup,\"ax\"\n" \
26942 "5: addl %3,%0\n" \
26943 " jmp 2b\n" \
26944 @@ -538,14 +650,14 @@ do { \
26945 " negl %0\n" \
26946 " andl $7,%0\n" \
26947 " subl %0,%3\n" \
26948 - "4: rep; movsb\n" \
26949 + "4: rep; "__copyuser_seg"movsb\n" \
26950 " movl %3,%0\n" \
26951 " shrl $2,%0\n" \
26952 " andl $3,%3\n" \
26953 " .align 2,0x90\n" \
26954 - "0: rep; movsl\n" \
26955 + "0: rep; "__copyuser_seg"movsl\n" \
26956 " movl %3,%0\n" \
26957 - "1: rep; movsb\n" \
26958 + "1: rep; "__copyuser_seg"movsb\n" \
26959 "2:\n" \
26960 ".section .fixup,\"ax\"\n" \
26961 "5: addl %3,%0\n" \
26962 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
26963 {
26964 stac();
26965 if (movsl_is_ok(to, from, n))
26966 - __copy_user(to, from, n);
26967 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
26968 else
26969 - n = __copy_user_intel(to, from, n);
26970 + n = __generic_copy_to_user_intel(to, from, n);
26971 clac();
26972 return n;
26973 }
26974 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
26975 {
26976 stac();
26977 if (movsl_is_ok(to, from, n))
26978 - __copy_user(to, from, n);
26979 + __copy_user(to, from, n, __copyuser_seg, "", "");
26980 else
26981 - n = __copy_user_intel((void __user *)to,
26982 - (const void *)from, n);
26983 + n = __generic_copy_from_user_intel(to, from, n);
26984 clac();
26985 return n;
26986 }
26987 @@ -632,66 +743,51 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
26988 if (n > 64 && cpu_has_xmm2)
26989 n = __copy_user_intel_nocache(to, from, n);
26990 else
26991 - __copy_user(to, from, n);
26992 + __copy_user(to, from, n, __copyuser_seg, "", "");
26993 #else
26994 - __copy_user(to, from, n);
26995 + __copy_user(to, from, n, __copyuser_seg, "", "");
26996 #endif
26997 clac();
26998 return n;
26999 }
27000 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
27001
27002 -/**
27003 - * copy_to_user: - Copy a block of data into user space.
27004 - * @to: Destination address, in user space.
27005 - * @from: Source address, in kernel space.
27006 - * @n: Number of bytes to copy.
27007 - *
27008 - * Context: User context only. This function may sleep.
27009 - *
27010 - * Copy data from kernel space to user space.
27011 - *
27012 - * Returns number of bytes that could not be copied.
27013 - * On success, this will be zero.
27014 - */
27015 -unsigned long
27016 -copy_to_user(void __user *to, const void *from, unsigned long n)
27017 -{
27018 - if (access_ok(VERIFY_WRITE, to, n))
27019 - n = __copy_to_user(to, from, n);
27020 - return n;
27021 -}
27022 -EXPORT_SYMBOL(copy_to_user);
27023 -
27024 -/**
27025 - * copy_from_user: - Copy a block of data from user space.
27026 - * @to: Destination address, in kernel space.
27027 - * @from: Source address, in user space.
27028 - * @n: Number of bytes to copy.
27029 - *
27030 - * Context: User context only. This function may sleep.
27031 - *
27032 - * Copy data from user space to kernel space.
27033 - *
27034 - * Returns number of bytes that could not be copied.
27035 - * On success, this will be zero.
27036 - *
27037 - * If some data could not be copied, this function will pad the copied
27038 - * data to the requested size using zero bytes.
27039 - */
27040 -unsigned long
27041 -_copy_from_user(void *to, const void __user *from, unsigned long n)
27042 -{
27043 - if (access_ok(VERIFY_READ, from, n))
27044 - n = __copy_from_user(to, from, n);
27045 - else
27046 - memset(to, 0, n);
27047 - return n;
27048 -}
27049 -EXPORT_SYMBOL(_copy_from_user);
27050 -
27051 void copy_from_user_overflow(void)
27052 {
27053 WARN(1, "Buffer overflow detected!\n");
27054 }
27055 EXPORT_SYMBOL(copy_from_user_overflow);
27056 +
27057 +void copy_to_user_overflow(void)
27058 +{
27059 + WARN(1, "Buffer overflow detected!\n");
27060 +}
27061 +EXPORT_SYMBOL(copy_to_user_overflow);
27062 +
27063 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27064 +void __set_fs(mm_segment_t x)
27065 +{
27066 + switch (x.seg) {
27067 + case 0:
27068 + loadsegment(gs, 0);
27069 + break;
27070 + case TASK_SIZE_MAX:
27071 + loadsegment(gs, __USER_DS);
27072 + break;
27073 + case -1UL:
27074 + loadsegment(gs, __KERNEL_DS);
27075 + break;
27076 + default:
27077 + BUG();
27078 + }
27079 + return;
27080 +}
27081 +EXPORT_SYMBOL(__set_fs);
27082 +
27083 +void set_fs(mm_segment_t x)
27084 +{
27085 + current_thread_info()->addr_limit = x;
27086 + __set_fs(x);
27087 +}
27088 +EXPORT_SYMBOL(set_fs);
27089 +#endif
27090 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27091 index 906fea3..ee8a097 100644
27092 --- a/arch/x86/lib/usercopy_64.c
27093 +++ b/arch/x86/lib/usercopy_64.c
27094 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27095 _ASM_EXTABLE(0b,3b)
27096 _ASM_EXTABLE(1b,2b)
27097 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27098 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27099 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27100 [zero] "r" (0UL), [eight] "r" (8UL));
27101 clac();
27102 return size;
27103 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27104 }
27105 EXPORT_SYMBOL(clear_user);
27106
27107 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27108 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27109 {
27110 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27111 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27112 - }
27113 - return len;
27114 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27115 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27116 + return len;
27117 }
27118 EXPORT_SYMBOL(copy_in_user);
27119
27120 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27121 * it is not necessary to optimize tail handling.
27122 */
27123 unsigned long
27124 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27125 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27126 {
27127 char c;
27128 unsigned zero_len;
27129 @@ -87,3 +86,15 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27130 clac();
27131 return len;
27132 }
27133 +
27134 +void copy_from_user_overflow(void)
27135 +{
27136 + WARN(1, "Buffer overflow detected!\n");
27137 +}
27138 +EXPORT_SYMBOL(copy_from_user_overflow);
27139 +
27140 +void copy_to_user_overflow(void)
27141 +{
27142 + WARN(1, "Buffer overflow detected!\n");
27143 +}
27144 +EXPORT_SYMBOL(copy_to_user_overflow);
27145 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27146 index 903ec1e..c4166b2 100644
27147 --- a/arch/x86/mm/extable.c
27148 +++ b/arch/x86/mm/extable.c
27149 @@ -6,12 +6,24 @@
27150 static inline unsigned long
27151 ex_insn_addr(const struct exception_table_entry *x)
27152 {
27153 - return (unsigned long)&x->insn + x->insn;
27154 + unsigned long reloc = 0;
27155 +
27156 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27157 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27158 +#endif
27159 +
27160 + return (unsigned long)&x->insn + x->insn + reloc;
27161 }
27162 static inline unsigned long
27163 ex_fixup_addr(const struct exception_table_entry *x)
27164 {
27165 - return (unsigned long)&x->fixup + x->fixup;
27166 + unsigned long reloc = 0;
27167 +
27168 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27169 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27170 +#endif
27171 +
27172 + return (unsigned long)&x->fixup + x->fixup + reloc;
27173 }
27174
27175 int fixup_exception(struct pt_regs *regs)
27176 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27177 unsigned long new_ip;
27178
27179 #ifdef CONFIG_PNPBIOS
27180 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27181 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27182 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27183 extern u32 pnp_bios_is_utter_crap;
27184 pnp_bios_is_utter_crap = 1;
27185 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27186 i += 4;
27187 p->fixup -= i;
27188 i += 4;
27189 +
27190 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27191 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27192 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27193 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27194 +#endif
27195 +
27196 }
27197 }
27198
27199 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27200 index 0e88336..2bb9777 100644
27201 --- a/arch/x86/mm/fault.c
27202 +++ b/arch/x86/mm/fault.c
27203 @@ -13,12 +13,19 @@
27204 #include <linux/perf_event.h> /* perf_sw_event */
27205 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27206 #include <linux/prefetch.h> /* prefetchw */
27207 +#include <linux/unistd.h>
27208 +#include <linux/compiler.h>
27209
27210 #include <asm/traps.h> /* dotraplinkage, ... */
27211 #include <asm/pgalloc.h> /* pgd_*(), ... */
27212 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27213 #include <asm/fixmap.h> /* VSYSCALL_START */
27214 #include <asm/context_tracking.h> /* exception_enter(), ... */
27215 +#include <asm/tlbflush.h>
27216 +
27217 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27218 +#include <asm/stacktrace.h>
27219 +#endif
27220
27221 /*
27222 * Page fault error code bits:
27223 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27224 int ret = 0;
27225
27226 /* kprobe_running() needs smp_processor_id() */
27227 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27228 + if (kprobes_built_in() && !user_mode(regs)) {
27229 preempt_disable();
27230 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27231 ret = 1;
27232 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27233 return !instr_lo || (instr_lo>>1) == 1;
27234 case 0x00:
27235 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27236 - if (probe_kernel_address(instr, opcode))
27237 + if (user_mode(regs)) {
27238 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27239 + return 0;
27240 + } else if (probe_kernel_address(instr, opcode))
27241 return 0;
27242
27243 *prefetch = (instr_lo == 0xF) &&
27244 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27245 while (instr < max_instr) {
27246 unsigned char opcode;
27247
27248 - if (probe_kernel_address(instr, opcode))
27249 + if (user_mode(regs)) {
27250 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27251 + break;
27252 + } else if (probe_kernel_address(instr, opcode))
27253 break;
27254
27255 instr++;
27256 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27257 force_sig_info(si_signo, &info, tsk);
27258 }
27259
27260 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27261 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27262 +#endif
27263 +
27264 +#ifdef CONFIG_PAX_EMUTRAMP
27265 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27266 +#endif
27267 +
27268 +#ifdef CONFIG_PAX_PAGEEXEC
27269 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27270 +{
27271 + pgd_t *pgd;
27272 + pud_t *pud;
27273 + pmd_t *pmd;
27274 +
27275 + pgd = pgd_offset(mm, address);
27276 + if (!pgd_present(*pgd))
27277 + return NULL;
27278 + pud = pud_offset(pgd, address);
27279 + if (!pud_present(*pud))
27280 + return NULL;
27281 + pmd = pmd_offset(pud, address);
27282 + if (!pmd_present(*pmd))
27283 + return NULL;
27284 + return pmd;
27285 +}
27286 +#endif
27287 +
27288 DEFINE_SPINLOCK(pgd_lock);
27289 LIST_HEAD(pgd_list);
27290
27291 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27292 for (address = VMALLOC_START & PMD_MASK;
27293 address >= TASK_SIZE && address < FIXADDR_TOP;
27294 address += PMD_SIZE) {
27295 +
27296 +#ifdef CONFIG_PAX_PER_CPU_PGD
27297 + unsigned long cpu;
27298 +#else
27299 struct page *page;
27300 +#endif
27301
27302 spin_lock(&pgd_lock);
27303 +
27304 +#ifdef CONFIG_PAX_PER_CPU_PGD
27305 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27306 + pgd_t *pgd = get_cpu_pgd(cpu);
27307 + pmd_t *ret;
27308 +#else
27309 list_for_each_entry(page, &pgd_list, lru) {
27310 + pgd_t *pgd;
27311 spinlock_t *pgt_lock;
27312 pmd_t *ret;
27313
27314 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27315 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27316
27317 spin_lock(pgt_lock);
27318 - ret = vmalloc_sync_one(page_address(page), address);
27319 + pgd = page_address(page);
27320 +#endif
27321 +
27322 + ret = vmalloc_sync_one(pgd, address);
27323 +
27324 +#ifndef CONFIG_PAX_PER_CPU_PGD
27325 spin_unlock(pgt_lock);
27326 +#endif
27327
27328 if (!ret)
27329 break;
27330 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27331 * an interrupt in the middle of a task switch..
27332 */
27333 pgd_paddr = read_cr3();
27334 +
27335 +#ifdef CONFIG_PAX_PER_CPU_PGD
27336 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27337 +#endif
27338 +
27339 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27340 if (!pmd_k)
27341 return -1;
27342 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27343 * happen within a race in page table update. In the later
27344 * case just flush:
27345 */
27346 +
27347 +#ifdef CONFIG_PAX_PER_CPU_PGD
27348 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27349 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27350 +#else
27351 pgd = pgd_offset(current->active_mm, address);
27352 +#endif
27353 +
27354 pgd_ref = pgd_offset_k(address);
27355 if (pgd_none(*pgd_ref))
27356 return -1;
27357 @@ -543,7 +614,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27358 static int is_errata100(struct pt_regs *regs, unsigned long address)
27359 {
27360 #ifdef CONFIG_X86_64
27361 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27362 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27363 return 1;
27364 #endif
27365 return 0;
27366 @@ -570,7 +641,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27367 }
27368
27369 static const char nx_warning[] = KERN_CRIT
27370 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27371 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27372
27373 static void
27374 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27375 @@ -579,15 +650,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27376 if (!oops_may_print())
27377 return;
27378
27379 - if (error_code & PF_INSTR) {
27380 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27381 unsigned int level;
27382
27383 pte_t *pte = lookup_address(address, &level);
27384
27385 if (pte && pte_present(*pte) && !pte_exec(*pte))
27386 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27387 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27388 }
27389
27390 +#ifdef CONFIG_PAX_KERNEXEC
27391 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27392 + if (current->signal->curr_ip)
27393 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27394 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27395 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27396 + else
27397 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27398 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27399 + }
27400 +#endif
27401 +
27402 printk(KERN_ALERT "BUG: unable to handle kernel ");
27403 if (address < PAGE_SIZE)
27404 printk(KERN_CONT "NULL pointer dereference");
27405 @@ -750,6 +833,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27406 return;
27407 }
27408 #endif
27409 +
27410 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27411 + if (pax_is_fetch_fault(regs, error_code, address)) {
27412 +
27413 +#ifdef CONFIG_PAX_EMUTRAMP
27414 + switch (pax_handle_fetch_fault(regs)) {
27415 + case 2:
27416 + return;
27417 + }
27418 +#endif
27419 +
27420 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27421 + do_group_exit(SIGKILL);
27422 + }
27423 +#endif
27424 +
27425 /* Kernel addresses are always protection faults: */
27426 if (address >= TASK_SIZE)
27427 error_code |= PF_PROT;
27428 @@ -835,7 +934,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27429 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27430 printk(KERN_ERR
27431 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27432 - tsk->comm, tsk->pid, address);
27433 + tsk->comm, task_pid_nr(tsk), address);
27434 code = BUS_MCEERR_AR;
27435 }
27436 #endif
27437 @@ -898,6 +997,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27438 return 1;
27439 }
27440
27441 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27442 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27443 +{
27444 + pte_t *pte;
27445 + pmd_t *pmd;
27446 + spinlock_t *ptl;
27447 + unsigned char pte_mask;
27448 +
27449 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27450 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27451 + return 0;
27452 +
27453 + /* PaX: it's our fault, let's handle it if we can */
27454 +
27455 + /* PaX: take a look at read faults before acquiring any locks */
27456 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27457 + /* instruction fetch attempt from a protected page in user mode */
27458 + up_read(&mm->mmap_sem);
27459 +
27460 +#ifdef CONFIG_PAX_EMUTRAMP
27461 + switch (pax_handle_fetch_fault(regs)) {
27462 + case 2:
27463 + return 1;
27464 + }
27465 +#endif
27466 +
27467 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27468 + do_group_exit(SIGKILL);
27469 + }
27470 +
27471 + pmd = pax_get_pmd(mm, address);
27472 + if (unlikely(!pmd))
27473 + return 0;
27474 +
27475 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27476 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27477 + pte_unmap_unlock(pte, ptl);
27478 + return 0;
27479 + }
27480 +
27481 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27482 + /* write attempt to a protected page in user mode */
27483 + pte_unmap_unlock(pte, ptl);
27484 + return 0;
27485 + }
27486 +
27487 +#ifdef CONFIG_SMP
27488 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27489 +#else
27490 + if (likely(address > get_limit(regs->cs)))
27491 +#endif
27492 + {
27493 + set_pte(pte, pte_mkread(*pte));
27494 + __flush_tlb_one(address);
27495 + pte_unmap_unlock(pte, ptl);
27496 + up_read(&mm->mmap_sem);
27497 + return 1;
27498 + }
27499 +
27500 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27501 +
27502 + /*
27503 + * PaX: fill DTLB with user rights and retry
27504 + */
27505 + __asm__ __volatile__ (
27506 + "orb %2,(%1)\n"
27507 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27508 +/*
27509 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27510 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27511 + * page fault when examined during a TLB load attempt. this is true not only
27512 + * for PTEs holding a non-present entry but also present entries that will
27513 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27514 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27515 + * for our target pages since their PTEs are simply not in the TLBs at all.
27516 +
27517 + * the best thing in omitting it is that we gain around 15-20% speed in the
27518 + * fast path of the page fault handler and can get rid of tracing since we
27519 + * can no longer flush unintended entries.
27520 + */
27521 + "invlpg (%0)\n"
27522 +#endif
27523 + __copyuser_seg"testb $0,(%0)\n"
27524 + "xorb %3,(%1)\n"
27525 + :
27526 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27527 + : "memory", "cc");
27528 + pte_unmap_unlock(pte, ptl);
27529 + up_read(&mm->mmap_sem);
27530 + return 1;
27531 +}
27532 +#endif
27533 +
27534 /*
27535 * Handle a spurious fault caused by a stale TLB entry.
27536 *
27537 @@ -964,6 +1156,9 @@ int show_unhandled_signals = 1;
27538 static inline int
27539 access_error(unsigned long error_code, struct vm_area_struct *vma)
27540 {
27541 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27542 + return 1;
27543 +
27544 if (error_code & PF_WRITE) {
27545 /* write, present and write, not present: */
27546 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27547 @@ -992,7 +1187,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27548 if (error_code & PF_USER)
27549 return false;
27550
27551 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27552 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27553 return false;
27554
27555 return true;
27556 @@ -1008,18 +1203,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27557 {
27558 struct vm_area_struct *vma;
27559 struct task_struct *tsk;
27560 - unsigned long address;
27561 struct mm_struct *mm;
27562 int fault;
27563 int write = error_code & PF_WRITE;
27564 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27565 (write ? FAULT_FLAG_WRITE : 0);
27566
27567 - tsk = current;
27568 - mm = tsk->mm;
27569 -
27570 /* Get the faulting address: */
27571 - address = read_cr2();
27572 + unsigned long address = read_cr2();
27573 +
27574 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27575 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
27576 + if (!search_exception_tables(regs->ip)) {
27577 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27578 + bad_area_nosemaphore(regs, error_code, address);
27579 + return;
27580 + }
27581 + if (address < pax_user_shadow_base) {
27582 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27583 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27584 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27585 + } else
27586 + address -= pax_user_shadow_base;
27587 + }
27588 +#endif
27589 +
27590 + tsk = current;
27591 + mm = tsk->mm;
27592
27593 /*
27594 * Detect and handle instructions that would cause a page fault for
27595 @@ -1080,7 +1290,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27596 * User-mode registers count as a user access even for any
27597 * potential system fault or CPU buglet:
27598 */
27599 - if (user_mode_vm(regs)) {
27600 + if (user_mode(regs)) {
27601 local_irq_enable();
27602 error_code |= PF_USER;
27603 } else {
27604 @@ -1142,6 +1352,11 @@ retry:
27605 might_sleep();
27606 }
27607
27608 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27609 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27610 + return;
27611 +#endif
27612 +
27613 vma = find_vma(mm, address);
27614 if (unlikely(!vma)) {
27615 bad_area(regs, error_code, address);
27616 @@ -1153,18 +1368,24 @@ retry:
27617 bad_area(regs, error_code, address);
27618 return;
27619 }
27620 - if (error_code & PF_USER) {
27621 - /*
27622 - * Accessing the stack below %sp is always a bug.
27623 - * The large cushion allows instructions like enter
27624 - * and pusha to work. ("enter $65535, $31" pushes
27625 - * 32 pointers and then decrements %sp by 65535.)
27626 - */
27627 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27628 - bad_area(regs, error_code, address);
27629 - return;
27630 - }
27631 + /*
27632 + * Accessing the stack below %sp is always a bug.
27633 + * The large cushion allows instructions like enter
27634 + * and pusha to work. ("enter $65535, $31" pushes
27635 + * 32 pointers and then decrements %sp by 65535.)
27636 + */
27637 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27638 + bad_area(regs, error_code, address);
27639 + return;
27640 }
27641 +
27642 +#ifdef CONFIG_PAX_SEGMEXEC
27643 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27644 + bad_area(regs, error_code, address);
27645 + return;
27646 + }
27647 +#endif
27648 +
27649 if (unlikely(expand_stack(vma, address))) {
27650 bad_area(regs, error_code, address);
27651 return;
27652 @@ -1228,3 +1449,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27653 __do_page_fault(regs, error_code);
27654 exception_exit(regs);
27655 }
27656 +
27657 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27658 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27659 +{
27660 + struct mm_struct *mm = current->mm;
27661 + unsigned long ip = regs->ip;
27662 +
27663 + if (v8086_mode(regs))
27664 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27665 +
27666 +#ifdef CONFIG_PAX_PAGEEXEC
27667 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27668 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27669 + return true;
27670 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27671 + return true;
27672 + return false;
27673 + }
27674 +#endif
27675 +
27676 +#ifdef CONFIG_PAX_SEGMEXEC
27677 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27678 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27679 + return true;
27680 + return false;
27681 + }
27682 +#endif
27683 +
27684 + return false;
27685 +}
27686 +#endif
27687 +
27688 +#ifdef CONFIG_PAX_EMUTRAMP
27689 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
27690 +{
27691 + int err;
27692 +
27693 + do { /* PaX: libffi trampoline emulation */
27694 + unsigned char mov, jmp;
27695 + unsigned int addr1, addr2;
27696 +
27697 +#ifdef CONFIG_X86_64
27698 + if ((regs->ip + 9) >> 32)
27699 + break;
27700 +#endif
27701 +
27702 + err = get_user(mov, (unsigned char __user *)regs->ip);
27703 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27704 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27705 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27706 +
27707 + if (err)
27708 + break;
27709 +
27710 + if (mov == 0xB8 && jmp == 0xE9) {
27711 + regs->ax = addr1;
27712 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27713 + return 2;
27714 + }
27715 + } while (0);
27716 +
27717 + do { /* PaX: gcc trampoline emulation #1 */
27718 + unsigned char mov1, mov2;
27719 + unsigned short jmp;
27720 + unsigned int addr1, addr2;
27721 +
27722 +#ifdef CONFIG_X86_64
27723 + if ((regs->ip + 11) >> 32)
27724 + break;
27725 +#endif
27726 +
27727 + err = get_user(mov1, (unsigned char __user *)regs->ip);
27728 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27729 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
27730 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27731 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
27732 +
27733 + if (err)
27734 + break;
27735 +
27736 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
27737 + regs->cx = addr1;
27738 + regs->ax = addr2;
27739 + regs->ip = addr2;
27740 + return 2;
27741 + }
27742 + } while (0);
27743 +
27744 + do { /* PaX: gcc trampoline emulation #2 */
27745 + unsigned char mov, jmp;
27746 + unsigned int addr1, addr2;
27747 +
27748 +#ifdef CONFIG_X86_64
27749 + if ((regs->ip + 9) >> 32)
27750 + break;
27751 +#endif
27752 +
27753 + err = get_user(mov, (unsigned char __user *)regs->ip);
27754 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27755 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27756 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27757 +
27758 + if (err)
27759 + break;
27760 +
27761 + if (mov == 0xB9 && jmp == 0xE9) {
27762 + regs->cx = addr1;
27763 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27764 + return 2;
27765 + }
27766 + } while (0);
27767 +
27768 + return 1; /* PaX in action */
27769 +}
27770 +
27771 +#ifdef CONFIG_X86_64
27772 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
27773 +{
27774 + int err;
27775 +
27776 + do { /* PaX: libffi trampoline emulation */
27777 + unsigned short mov1, mov2, jmp1;
27778 + unsigned char stcclc, jmp2;
27779 + unsigned long addr1, addr2;
27780 +
27781 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27782 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27783 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27784 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27785 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
27786 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
27787 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
27788 +
27789 + if (err)
27790 + break;
27791 +
27792 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27793 + regs->r11 = addr1;
27794 + regs->r10 = addr2;
27795 + if (stcclc == 0xF8)
27796 + regs->flags &= ~X86_EFLAGS_CF;
27797 + else
27798 + regs->flags |= X86_EFLAGS_CF;
27799 + regs->ip = addr1;
27800 + return 2;
27801 + }
27802 + } while (0);
27803 +
27804 + do { /* PaX: gcc trampoline emulation #1 */
27805 + unsigned short mov1, mov2, jmp1;
27806 + unsigned char jmp2;
27807 + unsigned int addr1;
27808 + unsigned long addr2;
27809 +
27810 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27811 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
27812 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
27813 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
27814 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
27815 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
27816 +
27817 + if (err)
27818 + break;
27819 +
27820 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27821 + regs->r11 = addr1;
27822 + regs->r10 = addr2;
27823 + regs->ip = addr1;
27824 + return 2;
27825 + }
27826 + } while (0);
27827 +
27828 + do { /* PaX: gcc trampoline emulation #2 */
27829 + unsigned short mov1, mov2, jmp1;
27830 + unsigned char jmp2;
27831 + unsigned long addr1, addr2;
27832 +
27833 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27834 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27835 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27836 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27837 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
27838 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
27839 +
27840 + if (err)
27841 + break;
27842 +
27843 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27844 + regs->r11 = addr1;
27845 + regs->r10 = addr2;
27846 + regs->ip = addr1;
27847 + return 2;
27848 + }
27849 + } while (0);
27850 +
27851 + return 1; /* PaX in action */
27852 +}
27853 +#endif
27854 +
27855 +/*
27856 + * PaX: decide what to do with offenders (regs->ip = fault address)
27857 + *
27858 + * returns 1 when task should be killed
27859 + * 2 when gcc trampoline was detected
27860 + */
27861 +static int pax_handle_fetch_fault(struct pt_regs *regs)
27862 +{
27863 + if (v8086_mode(regs))
27864 + return 1;
27865 +
27866 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
27867 + return 1;
27868 +
27869 +#ifdef CONFIG_X86_32
27870 + return pax_handle_fetch_fault_32(regs);
27871 +#else
27872 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
27873 + return pax_handle_fetch_fault_32(regs);
27874 + else
27875 + return pax_handle_fetch_fault_64(regs);
27876 +#endif
27877 +}
27878 +#endif
27879 +
27880 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27881 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
27882 +{
27883 + long i;
27884 +
27885 + printk(KERN_ERR "PAX: bytes at PC: ");
27886 + for (i = 0; i < 20; i++) {
27887 + unsigned char c;
27888 + if (get_user(c, (unsigned char __force_user *)pc+i))
27889 + printk(KERN_CONT "?? ");
27890 + else
27891 + printk(KERN_CONT "%02x ", c);
27892 + }
27893 + printk("\n");
27894 +
27895 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
27896 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
27897 + unsigned long c;
27898 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
27899 +#ifdef CONFIG_X86_32
27900 + printk(KERN_CONT "???????? ");
27901 +#else
27902 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
27903 + printk(KERN_CONT "???????? ???????? ");
27904 + else
27905 + printk(KERN_CONT "???????????????? ");
27906 +#endif
27907 + } else {
27908 +#ifdef CONFIG_X86_64
27909 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
27910 + printk(KERN_CONT "%08x ", (unsigned int)c);
27911 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
27912 + } else
27913 +#endif
27914 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
27915 + }
27916 + }
27917 + printk("\n");
27918 +}
27919 +#endif
27920 +
27921 +/**
27922 + * probe_kernel_write(): safely attempt to write to a location
27923 + * @dst: address to write to
27924 + * @src: pointer to the data that shall be written
27925 + * @size: size of the data chunk
27926 + *
27927 + * Safely write to address @dst from the buffer at @src. If a kernel fault
27928 + * happens, handle that and return -EFAULT.
27929 + */
27930 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
27931 +{
27932 + long ret;
27933 + mm_segment_t old_fs = get_fs();
27934 +
27935 + set_fs(KERNEL_DS);
27936 + pagefault_disable();
27937 + pax_open_kernel();
27938 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
27939 + pax_close_kernel();
27940 + pagefault_enable();
27941 + set_fs(old_fs);
27942 +
27943 + return ret ? -EFAULT : 0;
27944 +}
27945 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
27946 index dd74e46..7d26398 100644
27947 --- a/arch/x86/mm/gup.c
27948 +++ b/arch/x86/mm/gup.c
27949 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
27950 addr = start;
27951 len = (unsigned long) nr_pages << PAGE_SHIFT;
27952 end = start + len;
27953 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27954 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27955 (void __user *)start, len)))
27956 return 0;
27957
27958 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
27959 index 6f31ee5..8ee4164 100644
27960 --- a/arch/x86/mm/highmem_32.c
27961 +++ b/arch/x86/mm/highmem_32.c
27962 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
27963 idx = type + KM_TYPE_NR*smp_processor_id();
27964 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
27965 BUG_ON(!pte_none(*(kmap_pte-idx)));
27966 +
27967 + pax_open_kernel();
27968 set_pte(kmap_pte-idx, mk_pte(page, prot));
27969 + pax_close_kernel();
27970 +
27971 arch_flush_lazy_mmu_mode();
27972
27973 return (void *)vaddr;
27974 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
27975 index ae1aa71..d9bea75 100644
27976 --- a/arch/x86/mm/hugetlbpage.c
27977 +++ b/arch/x86/mm/hugetlbpage.c
27978 @@ -271,23 +271,30 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
27979 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
27980 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
27981 unsigned long addr, unsigned long len,
27982 - unsigned long pgoff, unsigned long flags)
27983 + unsigned long pgoff, unsigned long flags, unsigned long offset)
27984 {
27985 struct hstate *h = hstate_file(file);
27986 struct vm_unmapped_area_info info;
27987 -
27988 +
27989 info.flags = 0;
27990 info.length = len;
27991 info.low_limit = TASK_UNMAPPED_BASE;
27992 +
27993 +#ifdef CONFIG_PAX_RANDMMAP
27994 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
27995 + info.low_limit += current->mm->delta_mmap;
27996 +#endif
27997 +
27998 info.high_limit = TASK_SIZE;
27999 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28000 info.align_offset = 0;
28001 + info.threadstack_offset = offset;
28002 return vm_unmapped_area(&info);
28003 }
28004
28005 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28006 unsigned long addr0, unsigned long len,
28007 - unsigned long pgoff, unsigned long flags)
28008 + unsigned long pgoff, unsigned long flags, unsigned long offset)
28009 {
28010 struct hstate *h = hstate_file(file);
28011 struct vm_unmapped_area_info info;
28012 @@ -299,6 +306,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28013 info.high_limit = current->mm->mmap_base;
28014 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28015 info.align_offset = 0;
28016 + info.threadstack_offset = offset;
28017 addr = vm_unmapped_area(&info);
28018
28019 /*
28020 @@ -311,6 +319,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28021 VM_BUG_ON(addr != -ENOMEM);
28022 info.flags = 0;
28023 info.low_limit = TASK_UNMAPPED_BASE;
28024 +
28025 +#ifdef CONFIG_PAX_RANDMMAP
28026 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28027 + info.low_limit += current->mm->delta_mmap;
28028 +#endif
28029 +
28030 info.high_limit = TASK_SIZE;
28031 addr = vm_unmapped_area(&info);
28032 }
28033 @@ -325,10 +339,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28034 struct hstate *h = hstate_file(file);
28035 struct mm_struct *mm = current->mm;
28036 struct vm_area_struct *vma;
28037 + unsigned long pax_task_size = TASK_SIZE;
28038 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
28039
28040 if (len & ~huge_page_mask(h))
28041 return -EINVAL;
28042 - if (len > TASK_SIZE)
28043 +
28044 +#ifdef CONFIG_PAX_SEGMEXEC
28045 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28046 + pax_task_size = SEGMEXEC_TASK_SIZE;
28047 +#endif
28048 +
28049 + pax_task_size -= PAGE_SIZE;
28050 +
28051 + if (len > pax_task_size)
28052 return -ENOMEM;
28053
28054 if (flags & MAP_FIXED) {
28055 @@ -337,19 +361,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28056 return addr;
28057 }
28058
28059 +#ifdef CONFIG_PAX_RANDMMAP
28060 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28061 +#endif
28062 +
28063 if (addr) {
28064 addr = ALIGN(addr, huge_page_size(h));
28065 vma = find_vma(mm, addr);
28066 - if (TASK_SIZE - len >= addr &&
28067 - (!vma || addr + len <= vma->vm_start))
28068 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28069 return addr;
28070 }
28071 if (mm->get_unmapped_area == arch_get_unmapped_area)
28072 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
28073 - pgoff, flags);
28074 + pgoff, flags, offset);
28075 else
28076 return hugetlb_get_unmapped_area_topdown(file, addr, len,
28077 - pgoff, flags);
28078 + pgoff, flags, offset);
28079 }
28080
28081 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
28082 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
28083 index 59b7fc4..b1dd75f 100644
28084 --- a/arch/x86/mm/init.c
28085 +++ b/arch/x86/mm/init.c
28086 @@ -4,6 +4,7 @@
28087 #include <linux/swap.h>
28088 #include <linux/memblock.h>
28089 #include <linux/bootmem.h> /* for max_low_pfn */
28090 +#include <linux/tboot.h>
28091
28092 #include <asm/cacheflush.h>
28093 #include <asm/e820.h>
28094 @@ -17,6 +18,8 @@
28095 #include <asm/proto.h>
28096 #include <asm/dma.h> /* for MAX_DMA_PFN */
28097 #include <asm/microcode.h>
28098 +#include <asm/desc.h>
28099 +#include <asm/bios_ebda.h>
28100
28101 #include "mm_internal.h"
28102
28103 @@ -464,10 +467,40 @@ void __init init_mem_mapping(void)
28104 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
28105 * mmio resources as well as potential bios/acpi data regions.
28106 */
28107 +
28108 +#ifdef CONFIG_GRKERNSEC_KMEM
28109 +static unsigned int ebda_start __read_only;
28110 +static unsigned int ebda_end __read_only;
28111 +#endif
28112 +
28113 int devmem_is_allowed(unsigned long pagenr)
28114 {
28115 - if (pagenr < 256)
28116 +#ifdef CONFIG_GRKERNSEC_KMEM
28117 + /* allow BDA */
28118 + if (!pagenr)
28119 return 1;
28120 + /* allow EBDA */
28121 + if (pagenr >= ebda_start && pagenr < ebda_end)
28122 + return 1;
28123 + /* if tboot is in use, allow access to its hardcoded serial log range */
28124 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28125 + return 1;
28126 +#else
28127 + if (!pagenr)
28128 + return 1;
28129 +#ifdef CONFIG_VM86
28130 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28131 + return 1;
28132 +#endif
28133 +#endif
28134 +
28135 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28136 + return 1;
28137 +#ifdef CONFIG_GRKERNSEC_KMEM
28138 + /* throw out everything else below 1MB */
28139 + if (pagenr <= 256)
28140 + return 0;
28141 +#endif
28142 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28143 return 0;
28144 if (!page_is_ram(pagenr))
28145 @@ -524,8 +557,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28146 #endif
28147 }
28148
28149 +#ifdef CONFIG_GRKERNSEC_KMEM
28150 +static inline void gr_init_ebda(void)
28151 +{
28152 + unsigned int ebda_addr;
28153 + unsigned int ebda_size = 0;
28154 +
28155 + ebda_addr = get_bios_ebda();
28156 + if (ebda_addr) {
28157 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28158 + ebda_size <<= 10;
28159 + }
28160 + if (ebda_addr && ebda_size) {
28161 + ebda_start = ebda_addr >> PAGE_SHIFT;
28162 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28163 + } else {
28164 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28165 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28166 + }
28167 +}
28168 +#else
28169 +static inline void gr_init_ebda(void) { }
28170 +#endif
28171 +
28172 void free_initmem(void)
28173 {
28174 +#ifdef CONFIG_PAX_KERNEXEC
28175 +#ifdef CONFIG_X86_32
28176 + /* PaX: limit KERNEL_CS to actual size */
28177 + unsigned long addr, limit;
28178 + struct desc_struct d;
28179 + int cpu;
28180 +#else
28181 + pgd_t *pgd;
28182 + pud_t *pud;
28183 + pmd_t *pmd;
28184 + unsigned long addr, end;
28185 +#endif
28186 +#endif
28187 +
28188 + gr_init_ebda();
28189 +
28190 +#ifdef CONFIG_PAX_KERNEXEC
28191 +#ifdef CONFIG_X86_32
28192 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28193 + limit = (limit - 1UL) >> PAGE_SHIFT;
28194 +
28195 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28196 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28197 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28198 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28199 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28200 + }
28201 +
28202 + /* PaX: make KERNEL_CS read-only */
28203 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28204 + if (!paravirt_enabled())
28205 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28206 +/*
28207 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28208 + pgd = pgd_offset_k(addr);
28209 + pud = pud_offset(pgd, addr);
28210 + pmd = pmd_offset(pud, addr);
28211 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28212 + }
28213 +*/
28214 +#ifdef CONFIG_X86_PAE
28215 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28216 +/*
28217 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28218 + pgd = pgd_offset_k(addr);
28219 + pud = pud_offset(pgd, addr);
28220 + pmd = pmd_offset(pud, addr);
28221 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28222 + }
28223 +*/
28224 +#endif
28225 +
28226 +#ifdef CONFIG_MODULES
28227 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28228 +#endif
28229 +
28230 +#else
28231 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28232 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28233 + pgd = pgd_offset_k(addr);
28234 + pud = pud_offset(pgd, addr);
28235 + pmd = pmd_offset(pud, addr);
28236 + if (!pmd_present(*pmd))
28237 + continue;
28238 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28239 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28240 + else
28241 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28242 + }
28243 +
28244 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28245 + end = addr + KERNEL_IMAGE_SIZE;
28246 + for (; addr < end; addr += PMD_SIZE) {
28247 + pgd = pgd_offset_k(addr);
28248 + pud = pud_offset(pgd, addr);
28249 + pmd = pmd_offset(pud, addr);
28250 + if (!pmd_present(*pmd))
28251 + continue;
28252 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28253 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28254 + }
28255 +#endif
28256 +
28257 + flush_tlb_all();
28258 +#endif
28259 +
28260 free_init_pages("unused kernel memory",
28261 (unsigned long)(&__init_begin),
28262 (unsigned long)(&__init_end));
28263 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28264 index 2d19001..6a1046c 100644
28265 --- a/arch/x86/mm/init_32.c
28266 +++ b/arch/x86/mm/init_32.c
28267 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
28268 bool __read_mostly __vmalloc_start_set = false;
28269
28270 /*
28271 - * Creates a middle page table and puts a pointer to it in the
28272 - * given global directory entry. This only returns the gd entry
28273 - * in non-PAE compilation mode, since the middle layer is folded.
28274 - */
28275 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28276 -{
28277 - pud_t *pud;
28278 - pmd_t *pmd_table;
28279 -
28280 -#ifdef CONFIG_X86_PAE
28281 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28282 - pmd_table = (pmd_t *)alloc_low_page();
28283 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28284 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28285 - pud = pud_offset(pgd, 0);
28286 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28287 -
28288 - return pmd_table;
28289 - }
28290 -#endif
28291 - pud = pud_offset(pgd, 0);
28292 - pmd_table = pmd_offset(pud, 0);
28293 -
28294 - return pmd_table;
28295 -}
28296 -
28297 -/*
28298 * Create a page table and place a pointer to it in a middle page
28299 * directory entry:
28300 */
28301 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28302 pte_t *page_table = (pte_t *)alloc_low_page();
28303
28304 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28305 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28306 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28307 +#else
28308 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28309 +#endif
28310 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28311 }
28312
28313 return pte_offset_kernel(pmd, 0);
28314 }
28315
28316 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28317 +{
28318 + pud_t *pud;
28319 + pmd_t *pmd_table;
28320 +
28321 + pud = pud_offset(pgd, 0);
28322 + pmd_table = pmd_offset(pud, 0);
28323 +
28324 + return pmd_table;
28325 +}
28326 +
28327 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28328 {
28329 int pgd_idx = pgd_index(vaddr);
28330 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28331 int pgd_idx, pmd_idx;
28332 unsigned long vaddr;
28333 pgd_t *pgd;
28334 + pud_t *pud;
28335 pmd_t *pmd;
28336 pte_t *pte = NULL;
28337 unsigned long count = page_table_range_init_count(start, end);
28338 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28339 pgd = pgd_base + pgd_idx;
28340
28341 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28342 - pmd = one_md_table_init(pgd);
28343 - pmd = pmd + pmd_index(vaddr);
28344 + pud = pud_offset(pgd, vaddr);
28345 + pmd = pmd_offset(pud, vaddr);
28346 +
28347 +#ifdef CONFIG_X86_PAE
28348 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28349 +#endif
28350 +
28351 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28352 pmd++, pmd_idx++) {
28353 pte = page_table_kmap_check(one_page_table_init(pmd),
28354 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28355 }
28356 }
28357
28358 -static inline int is_kernel_text(unsigned long addr)
28359 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28360 {
28361 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28362 - return 1;
28363 - return 0;
28364 + if ((start > ktla_ktva((unsigned long)_etext) ||
28365 + end <= ktla_ktva((unsigned long)_stext)) &&
28366 + (start > ktla_ktva((unsigned long)_einittext) ||
28367 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28368 +
28369 +#ifdef CONFIG_ACPI_SLEEP
28370 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28371 +#endif
28372 +
28373 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28374 + return 0;
28375 + return 1;
28376 }
28377
28378 /*
28379 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
28380 unsigned long last_map_addr = end;
28381 unsigned long start_pfn, end_pfn;
28382 pgd_t *pgd_base = swapper_pg_dir;
28383 - int pgd_idx, pmd_idx, pte_ofs;
28384 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28385 unsigned long pfn;
28386 pgd_t *pgd;
28387 + pud_t *pud;
28388 pmd_t *pmd;
28389 pte_t *pte;
28390 unsigned pages_2m, pages_4k;
28391 @@ -291,8 +295,13 @@ repeat:
28392 pfn = start_pfn;
28393 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28394 pgd = pgd_base + pgd_idx;
28395 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28396 - pmd = one_md_table_init(pgd);
28397 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28398 + pud = pud_offset(pgd, 0);
28399 + pmd = pmd_offset(pud, 0);
28400 +
28401 +#ifdef CONFIG_X86_PAE
28402 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28403 +#endif
28404
28405 if (pfn >= end_pfn)
28406 continue;
28407 @@ -304,14 +313,13 @@ repeat:
28408 #endif
28409 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28410 pmd++, pmd_idx++) {
28411 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28412 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28413
28414 /*
28415 * Map with big pages if possible, otherwise
28416 * create normal page tables:
28417 */
28418 if (use_pse) {
28419 - unsigned int addr2;
28420 pgprot_t prot = PAGE_KERNEL_LARGE;
28421 /*
28422 * first pass will use the same initial
28423 @@ -322,11 +330,7 @@ repeat:
28424 _PAGE_PSE);
28425
28426 pfn &= PMD_MASK >> PAGE_SHIFT;
28427 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28428 - PAGE_OFFSET + PAGE_SIZE-1;
28429 -
28430 - if (is_kernel_text(addr) ||
28431 - is_kernel_text(addr2))
28432 + if (is_kernel_text(address, address + PMD_SIZE))
28433 prot = PAGE_KERNEL_LARGE_EXEC;
28434
28435 pages_2m++;
28436 @@ -343,7 +347,7 @@ repeat:
28437 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28438 pte += pte_ofs;
28439 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28440 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28441 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28442 pgprot_t prot = PAGE_KERNEL;
28443 /*
28444 * first pass will use the same initial
28445 @@ -351,7 +355,7 @@ repeat:
28446 */
28447 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28448
28449 - if (is_kernel_text(addr))
28450 + if (is_kernel_text(address, address + PAGE_SIZE))
28451 prot = PAGE_KERNEL_EXEC;
28452
28453 pages_4k++;
28454 @@ -482,7 +486,7 @@ void __init native_pagetable_init(void)
28455
28456 pud = pud_offset(pgd, va);
28457 pmd = pmd_offset(pud, va);
28458 - if (!pmd_present(*pmd))
28459 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
28460 break;
28461
28462 /* should not be large page here */
28463 @@ -540,12 +544,10 @@ void __init early_ioremap_page_table_range_init(void)
28464
28465 static void __init pagetable_init(void)
28466 {
28467 - pgd_t *pgd_base = swapper_pg_dir;
28468 -
28469 - permanent_kmaps_init(pgd_base);
28470 + permanent_kmaps_init(swapper_pg_dir);
28471 }
28472
28473 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28474 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28475 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28476
28477 /* user-defined highmem size */
28478 @@ -752,6 +754,12 @@ void __init mem_init(void)
28479
28480 pci_iommu_alloc();
28481
28482 +#ifdef CONFIG_PAX_PER_CPU_PGD
28483 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28484 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28485 + KERNEL_PGD_PTRS);
28486 +#endif
28487 +
28488 #ifdef CONFIG_FLATMEM
28489 BUG_ON(!mem_map);
28490 #endif
28491 @@ -780,7 +788,7 @@ void __init mem_init(void)
28492 after_bootmem = 1;
28493
28494 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28495 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28496 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28497 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28498
28499 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28500 @@ -821,10 +829,10 @@ void __init mem_init(void)
28501 ((unsigned long)&__init_end -
28502 (unsigned long)&__init_begin) >> 10,
28503
28504 - (unsigned long)&_etext, (unsigned long)&_edata,
28505 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28506 + (unsigned long)&_sdata, (unsigned long)&_edata,
28507 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28508
28509 - (unsigned long)&_text, (unsigned long)&_etext,
28510 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28511 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28512
28513 /*
28514 @@ -914,6 +922,7 @@ void set_kernel_text_rw(void)
28515 if (!kernel_set_to_readonly)
28516 return;
28517
28518 + start = ktla_ktva(start);
28519 pr_debug("Set kernel text: %lx - %lx for read write\n",
28520 start, start+size);
28521
28522 @@ -928,6 +937,7 @@ void set_kernel_text_ro(void)
28523 if (!kernel_set_to_readonly)
28524 return;
28525
28526 + start = ktla_ktva(start);
28527 pr_debug("Set kernel text: %lx - %lx for read only\n",
28528 start, start+size);
28529
28530 @@ -956,6 +966,7 @@ void mark_rodata_ro(void)
28531 unsigned long start = PFN_ALIGN(_text);
28532 unsigned long size = PFN_ALIGN(_etext) - start;
28533
28534 + start = ktla_ktva(start);
28535 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28536 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28537 size >> 10);
28538 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28539 index 474e28f..647dd12 100644
28540 --- a/arch/x86/mm/init_64.c
28541 +++ b/arch/x86/mm/init_64.c
28542 @@ -150,7 +150,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28543 * around without checking the pgd every time.
28544 */
28545
28546 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28547 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28548 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28549
28550 int force_personality32;
28551 @@ -183,12 +183,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28552
28553 for (address = start; address <= end; address += PGDIR_SIZE) {
28554 const pgd_t *pgd_ref = pgd_offset_k(address);
28555 +
28556 +#ifdef CONFIG_PAX_PER_CPU_PGD
28557 + unsigned long cpu;
28558 +#else
28559 struct page *page;
28560 +#endif
28561
28562 if (pgd_none(*pgd_ref))
28563 continue;
28564
28565 spin_lock(&pgd_lock);
28566 +
28567 +#ifdef CONFIG_PAX_PER_CPU_PGD
28568 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28569 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28570 +#else
28571 list_for_each_entry(page, &pgd_list, lru) {
28572 pgd_t *pgd;
28573 spinlock_t *pgt_lock;
28574 @@ -197,6 +207,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28575 /* the pgt_lock only for Xen */
28576 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28577 spin_lock(pgt_lock);
28578 +#endif
28579
28580 if (pgd_none(*pgd))
28581 set_pgd(pgd, *pgd_ref);
28582 @@ -204,7 +215,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28583 BUG_ON(pgd_page_vaddr(*pgd)
28584 != pgd_page_vaddr(*pgd_ref));
28585
28586 +#ifndef CONFIG_PAX_PER_CPU_PGD
28587 spin_unlock(pgt_lock);
28588 +#endif
28589 +
28590 }
28591 spin_unlock(&pgd_lock);
28592 }
28593 @@ -237,7 +251,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28594 {
28595 if (pgd_none(*pgd)) {
28596 pud_t *pud = (pud_t *)spp_getpage();
28597 - pgd_populate(&init_mm, pgd, pud);
28598 + pgd_populate_kernel(&init_mm, pgd, pud);
28599 if (pud != pud_offset(pgd, 0))
28600 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28601 pud, pud_offset(pgd, 0));
28602 @@ -249,7 +263,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28603 {
28604 if (pud_none(*pud)) {
28605 pmd_t *pmd = (pmd_t *) spp_getpage();
28606 - pud_populate(&init_mm, pud, pmd);
28607 + pud_populate_kernel(&init_mm, pud, pmd);
28608 if (pmd != pmd_offset(pud, 0))
28609 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28610 pmd, pmd_offset(pud, 0));
28611 @@ -278,7 +292,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28612 pmd = fill_pmd(pud, vaddr);
28613 pte = fill_pte(pmd, vaddr);
28614
28615 + pax_open_kernel();
28616 set_pte(pte, new_pte);
28617 + pax_close_kernel();
28618
28619 /*
28620 * It's enough to flush this one mapping.
28621 @@ -337,14 +353,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28622 pgd = pgd_offset_k((unsigned long)__va(phys));
28623 if (pgd_none(*pgd)) {
28624 pud = (pud_t *) spp_getpage();
28625 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28626 - _PAGE_USER));
28627 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28628 }
28629 pud = pud_offset(pgd, (unsigned long)__va(phys));
28630 if (pud_none(*pud)) {
28631 pmd = (pmd_t *) spp_getpage();
28632 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28633 - _PAGE_USER));
28634 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28635 }
28636 pmd = pmd_offset(pud, phys);
28637 BUG_ON(!pmd_none(*pmd));
28638 @@ -585,7 +599,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28639 prot);
28640
28641 spin_lock(&init_mm.page_table_lock);
28642 - pud_populate(&init_mm, pud, pmd);
28643 + pud_populate_kernel(&init_mm, pud, pmd);
28644 spin_unlock(&init_mm.page_table_lock);
28645 }
28646 __flush_tlb_all();
28647 @@ -626,7 +640,7 @@ kernel_physical_mapping_init(unsigned long start,
28648 page_size_mask);
28649
28650 spin_lock(&init_mm.page_table_lock);
28651 - pgd_populate(&init_mm, pgd, pud);
28652 + pgd_populate_kernel(&init_mm, pgd, pud);
28653 spin_unlock(&init_mm.page_table_lock);
28654 pgd_changed = true;
28655 }
28656 @@ -1065,6 +1079,12 @@ void __init mem_init(void)
28657
28658 pci_iommu_alloc();
28659
28660 +#ifdef CONFIG_PAX_PER_CPU_PGD
28661 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28662 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28663 + KERNEL_PGD_PTRS);
28664 +#endif
28665 +
28666 /* clear_bss() already clear the empty_zero_page */
28667
28668 reservedpages = 0;
28669 @@ -1224,8 +1244,8 @@ int kern_addr_valid(unsigned long addr)
28670 static struct vm_area_struct gate_vma = {
28671 .vm_start = VSYSCALL_START,
28672 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28673 - .vm_page_prot = PAGE_READONLY_EXEC,
28674 - .vm_flags = VM_READ | VM_EXEC
28675 + .vm_page_prot = PAGE_READONLY,
28676 + .vm_flags = VM_READ
28677 };
28678
28679 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28680 @@ -1259,7 +1279,7 @@ int in_gate_area_no_mm(unsigned long addr)
28681
28682 const char *arch_vma_name(struct vm_area_struct *vma)
28683 {
28684 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28685 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28686 return "[vdso]";
28687 if (vma == &gate_vma)
28688 return "[vsyscall]";
28689 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28690 index 7b179b4..6bd17777 100644
28691 --- a/arch/x86/mm/iomap_32.c
28692 +++ b/arch/x86/mm/iomap_32.c
28693 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
28694 type = kmap_atomic_idx_push();
28695 idx = type + KM_TYPE_NR * smp_processor_id();
28696 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28697 +
28698 + pax_open_kernel();
28699 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
28700 + pax_close_kernel();
28701 +
28702 arch_flush_lazy_mmu_mode();
28703
28704 return (void *)vaddr;
28705 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
28706 index 78fe3f1..73b95e2 100644
28707 --- a/arch/x86/mm/ioremap.c
28708 +++ b/arch/x86/mm/ioremap.c
28709 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
28710 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
28711 int is_ram = page_is_ram(pfn);
28712
28713 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
28714 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
28715 return NULL;
28716 WARN_ON_ONCE(is_ram);
28717 }
28718 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
28719 *
28720 * Caller must ensure there is only one unmapping for the same pointer.
28721 */
28722 -void iounmap(volatile void __iomem *addr)
28723 +void iounmap(const volatile void __iomem *addr)
28724 {
28725 struct vm_struct *p, *o;
28726
28727 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28728
28729 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
28730 if (page_is_ram(start >> PAGE_SHIFT))
28731 +#ifdef CONFIG_HIGHMEM
28732 + if ((start >> PAGE_SHIFT) < max_low_pfn)
28733 +#endif
28734 return __va(phys);
28735
28736 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
28737 @@ -327,6 +330,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28738 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
28739 {
28740 if (page_is_ram(phys >> PAGE_SHIFT))
28741 +#ifdef CONFIG_HIGHMEM
28742 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
28743 +#endif
28744 return;
28745
28746 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
28747 @@ -344,7 +350,7 @@ static int __init early_ioremap_debug_setup(char *str)
28748 early_param("early_ioremap_debug", early_ioremap_debug_setup);
28749
28750 static __initdata int after_paging_init;
28751 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
28752 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
28753
28754 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
28755 {
28756 @@ -381,8 +387,7 @@ void __init early_ioremap_init(void)
28757 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
28758
28759 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
28760 - memset(bm_pte, 0, sizeof(bm_pte));
28761 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
28762 + pmd_populate_user(&init_mm, pmd, bm_pte);
28763
28764 /*
28765 * The boot-ioremap range spans multiple pmds, for which
28766 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
28767 index d87dd6d..bf3fa66 100644
28768 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
28769 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
28770 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
28771 * memory (e.g. tracked pages)? For now, we need this to avoid
28772 * invoking kmemcheck for PnP BIOS calls.
28773 */
28774 - if (regs->flags & X86_VM_MASK)
28775 + if (v8086_mode(regs))
28776 return false;
28777 - if (regs->cs != __KERNEL_CS)
28778 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
28779 return false;
28780
28781 pte = kmemcheck_pte_lookup(address);
28782 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
28783 index 845df68..1d8d29f 100644
28784 --- a/arch/x86/mm/mmap.c
28785 +++ b/arch/x86/mm/mmap.c
28786 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
28787 * Leave an at least ~128 MB hole with possible stack randomization.
28788 */
28789 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
28790 -#define MAX_GAP (TASK_SIZE/6*5)
28791 +#define MAX_GAP (pax_task_size/6*5)
28792
28793 static int mmap_is_legacy(void)
28794 {
28795 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
28796 return rnd << PAGE_SHIFT;
28797 }
28798
28799 -static unsigned long mmap_base(void)
28800 +static unsigned long mmap_base(struct mm_struct *mm)
28801 {
28802 unsigned long gap = rlimit(RLIMIT_STACK);
28803 + unsigned long pax_task_size = TASK_SIZE;
28804 +
28805 +#ifdef CONFIG_PAX_SEGMEXEC
28806 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28807 + pax_task_size = SEGMEXEC_TASK_SIZE;
28808 +#endif
28809
28810 if (gap < MIN_GAP)
28811 gap = MIN_GAP;
28812 else if (gap > MAX_GAP)
28813 gap = MAX_GAP;
28814
28815 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
28816 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
28817 }
28818
28819 /*
28820 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
28821 * does, but not when emulating X86_32
28822 */
28823 -static unsigned long mmap_legacy_base(void)
28824 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
28825 {
28826 - if (mmap_is_ia32())
28827 + if (mmap_is_ia32()) {
28828 +
28829 +#ifdef CONFIG_PAX_SEGMEXEC
28830 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28831 + return SEGMEXEC_TASK_UNMAPPED_BASE;
28832 + else
28833 +#endif
28834 +
28835 return TASK_UNMAPPED_BASE;
28836 - else
28837 + } else
28838 return TASK_UNMAPPED_BASE + mmap_rnd();
28839 }
28840
28841 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
28842 void arch_pick_mmap_layout(struct mm_struct *mm)
28843 {
28844 if (mmap_is_legacy()) {
28845 - mm->mmap_base = mmap_legacy_base();
28846 + mm->mmap_base = mmap_legacy_base(mm);
28847 +
28848 +#ifdef CONFIG_PAX_RANDMMAP
28849 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28850 + mm->mmap_base += mm->delta_mmap;
28851 +#endif
28852 +
28853 mm->get_unmapped_area = arch_get_unmapped_area;
28854 mm->unmap_area = arch_unmap_area;
28855 } else {
28856 - mm->mmap_base = mmap_base();
28857 + mm->mmap_base = mmap_base(mm);
28858 +
28859 +#ifdef CONFIG_PAX_RANDMMAP
28860 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28861 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
28862 +#endif
28863 +
28864 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
28865 mm->unmap_area = arch_unmap_area_topdown;
28866 }
28867 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
28868 index dc0b727..f612039 100644
28869 --- a/arch/x86/mm/mmio-mod.c
28870 +++ b/arch/x86/mm/mmio-mod.c
28871 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
28872 break;
28873 default:
28874 {
28875 - unsigned char *ip = (unsigned char *)instptr;
28876 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
28877 my_trace->opcode = MMIO_UNKNOWN_OP;
28878 my_trace->width = 0;
28879 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
28880 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
28881 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28882 void __iomem *addr)
28883 {
28884 - static atomic_t next_id;
28885 + static atomic_unchecked_t next_id;
28886 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
28887 /* These are page-unaligned. */
28888 struct mmiotrace_map map = {
28889 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28890 .private = trace
28891 },
28892 .phys = offset,
28893 - .id = atomic_inc_return(&next_id)
28894 + .id = atomic_inc_return_unchecked(&next_id)
28895 };
28896 map.map_id = trace->id;
28897
28898 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
28899 ioremap_trace_core(offset, size, addr);
28900 }
28901
28902 -static void iounmap_trace_core(volatile void __iomem *addr)
28903 +static void iounmap_trace_core(const volatile void __iomem *addr)
28904 {
28905 struct mmiotrace_map map = {
28906 .phys = 0,
28907 @@ -328,7 +328,7 @@ not_enabled:
28908 }
28909 }
28910
28911 -void mmiotrace_iounmap(volatile void __iomem *addr)
28912 +void mmiotrace_iounmap(const volatile void __iomem *addr)
28913 {
28914 might_sleep();
28915 if (is_enabled()) /* recheck and proper locking in *_core() */
28916 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
28917 index 72fe01e..f1a8daa 100644
28918 --- a/arch/x86/mm/numa.c
28919 +++ b/arch/x86/mm/numa.c
28920 @@ -477,7 +477,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
28921 return true;
28922 }
28923
28924 -static int __init numa_register_memblks(struct numa_meminfo *mi)
28925 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
28926 {
28927 unsigned long uninitialized_var(pfn_align);
28928 int i, nid;
28929 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
28930 index 0e38951..4ca8458 100644
28931 --- a/arch/x86/mm/pageattr-test.c
28932 +++ b/arch/x86/mm/pageattr-test.c
28933 @@ -36,7 +36,7 @@ enum {
28934
28935 static int pte_testbit(pte_t pte)
28936 {
28937 - return pte_flags(pte) & _PAGE_UNUSED1;
28938 + return pte_flags(pte) & _PAGE_CPA_TEST;
28939 }
28940
28941 struct split_state {
28942 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
28943 index fb4e73e..43f7238 100644
28944 --- a/arch/x86/mm/pageattr.c
28945 +++ b/arch/x86/mm/pageattr.c
28946 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28947 */
28948 #ifdef CONFIG_PCI_BIOS
28949 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
28950 - pgprot_val(forbidden) |= _PAGE_NX;
28951 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28952 #endif
28953
28954 /*
28955 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28956 * Does not cover __inittext since that is gone later on. On
28957 * 64bit we do not enforce !NX on the low mapping
28958 */
28959 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
28960 - pgprot_val(forbidden) |= _PAGE_NX;
28961 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
28962 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28963
28964 +#ifdef CONFIG_DEBUG_RODATA
28965 /*
28966 * The .rodata section needs to be read-only. Using the pfn
28967 * catches all aliases.
28968 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28969 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
28970 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
28971 pgprot_val(forbidden) |= _PAGE_RW;
28972 +#endif
28973
28974 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
28975 /*
28976 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28977 }
28978 #endif
28979
28980 +#ifdef CONFIG_PAX_KERNEXEC
28981 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
28982 + pgprot_val(forbidden) |= _PAGE_RW;
28983 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28984 + }
28985 +#endif
28986 +
28987 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
28988
28989 return prot;
28990 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
28991 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
28992 {
28993 /* change init_mm */
28994 + pax_open_kernel();
28995 set_pte_atomic(kpte, pte);
28996 +
28997 #ifdef CONFIG_X86_32
28998 if (!SHARED_KERNEL_PMD) {
28999 +
29000 +#ifdef CONFIG_PAX_PER_CPU_PGD
29001 + unsigned long cpu;
29002 +#else
29003 struct page *page;
29004 +#endif
29005
29006 +#ifdef CONFIG_PAX_PER_CPU_PGD
29007 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29008 + pgd_t *pgd = get_cpu_pgd(cpu);
29009 +#else
29010 list_for_each_entry(page, &pgd_list, lru) {
29011 - pgd_t *pgd;
29012 + pgd_t *pgd = (pgd_t *)page_address(page);
29013 +#endif
29014 +
29015 pud_t *pud;
29016 pmd_t *pmd;
29017
29018 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
29019 + pgd += pgd_index(address);
29020 pud = pud_offset(pgd, address);
29021 pmd = pmd_offset(pud, address);
29022 set_pte_atomic((pte_t *)pmd, pte);
29023 }
29024 }
29025 #endif
29026 + pax_close_kernel();
29027 }
29028
29029 static int
29030 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
29031 index 6574388..87e9bef 100644
29032 --- a/arch/x86/mm/pat.c
29033 +++ b/arch/x86/mm/pat.c
29034 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
29035
29036 if (!entry) {
29037 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
29038 - current->comm, current->pid, start, end - 1);
29039 + current->comm, task_pid_nr(current), start, end - 1);
29040 return -EINVAL;
29041 }
29042
29043 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29044
29045 while (cursor < to) {
29046 if (!devmem_is_allowed(pfn)) {
29047 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
29048 - current->comm, from, to - 1);
29049 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
29050 + current->comm, from, to - 1, cursor);
29051 return 0;
29052 }
29053 cursor += PAGE_SIZE;
29054 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
29055 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
29056 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
29057 "for [mem %#010Lx-%#010Lx]\n",
29058 - current->comm, current->pid,
29059 + current->comm, task_pid_nr(current),
29060 cattr_name(flags),
29061 base, (unsigned long long)(base + size-1));
29062 return -EINVAL;
29063 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29064 flags = lookup_memtype(paddr);
29065 if (want_flags != flags) {
29066 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
29067 - current->comm, current->pid,
29068 + current->comm, task_pid_nr(current),
29069 cattr_name(want_flags),
29070 (unsigned long long)paddr,
29071 (unsigned long long)(paddr + size - 1),
29072 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29073 free_memtype(paddr, paddr + size);
29074 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
29075 " for [mem %#010Lx-%#010Lx], got %s\n",
29076 - current->comm, current->pid,
29077 + current->comm, task_pid_nr(current),
29078 cattr_name(want_flags),
29079 (unsigned long long)paddr,
29080 (unsigned long long)(paddr + size - 1),
29081 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
29082 index 9f0614d..92ae64a 100644
29083 --- a/arch/x86/mm/pf_in.c
29084 +++ b/arch/x86/mm/pf_in.c
29085 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
29086 int i;
29087 enum reason_type rv = OTHERS;
29088
29089 - p = (unsigned char *)ins_addr;
29090 + p = (unsigned char *)ktla_ktva(ins_addr);
29091 p += skip_prefix(p, &prf);
29092 p += get_opcode(p, &opcode);
29093
29094 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
29095 struct prefix_bits prf;
29096 int i;
29097
29098 - p = (unsigned char *)ins_addr;
29099 + p = (unsigned char *)ktla_ktva(ins_addr);
29100 p += skip_prefix(p, &prf);
29101 p += get_opcode(p, &opcode);
29102
29103 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29104 struct prefix_bits prf;
29105 int i;
29106
29107 - p = (unsigned char *)ins_addr;
29108 + p = (unsigned char *)ktla_ktva(ins_addr);
29109 p += skip_prefix(p, &prf);
29110 p += get_opcode(p, &opcode);
29111
29112 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29113 struct prefix_bits prf;
29114 int i;
29115
29116 - p = (unsigned char *)ins_addr;
29117 + p = (unsigned char *)ktla_ktva(ins_addr);
29118 p += skip_prefix(p, &prf);
29119 p += get_opcode(p, &opcode);
29120 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29121 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29122 struct prefix_bits prf;
29123 int i;
29124
29125 - p = (unsigned char *)ins_addr;
29126 + p = (unsigned char *)ktla_ktva(ins_addr);
29127 p += skip_prefix(p, &prf);
29128 p += get_opcode(p, &opcode);
29129 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29130 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29131 index 17fda6a..489c74a 100644
29132 --- a/arch/x86/mm/pgtable.c
29133 +++ b/arch/x86/mm/pgtable.c
29134 @@ -91,10 +91,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29135 list_del(&page->lru);
29136 }
29137
29138 -#define UNSHARED_PTRS_PER_PGD \
29139 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29140 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29141 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29142
29143 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29144 +{
29145 + unsigned int count = USER_PGD_PTRS;
29146
29147 + while (count--)
29148 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29149 +}
29150 +#endif
29151 +
29152 +#ifdef CONFIG_PAX_PER_CPU_PGD
29153 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29154 +{
29155 + unsigned int count = USER_PGD_PTRS;
29156 +
29157 + while (count--) {
29158 + pgd_t pgd;
29159 +
29160 +#ifdef CONFIG_X86_64
29161 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29162 +#else
29163 + pgd = *src++;
29164 +#endif
29165 +
29166 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29167 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29168 +#endif
29169 +
29170 + *dst++ = pgd;
29171 + }
29172 +
29173 +}
29174 +#endif
29175 +
29176 +#ifdef CONFIG_X86_64
29177 +#define pxd_t pud_t
29178 +#define pyd_t pgd_t
29179 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29180 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29181 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29182 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29183 +#define PYD_SIZE PGDIR_SIZE
29184 +#else
29185 +#define pxd_t pmd_t
29186 +#define pyd_t pud_t
29187 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29188 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29189 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29190 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29191 +#define PYD_SIZE PUD_SIZE
29192 +#endif
29193 +
29194 +#ifdef CONFIG_PAX_PER_CPU_PGD
29195 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29196 +static inline void pgd_dtor(pgd_t *pgd) {}
29197 +#else
29198 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29199 {
29200 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29201 @@ -135,6 +189,7 @@ static void pgd_dtor(pgd_t *pgd)
29202 pgd_list_del(pgd);
29203 spin_unlock(&pgd_lock);
29204 }
29205 +#endif
29206
29207 /*
29208 * List of all pgd's needed for non-PAE so it can invalidate entries
29209 @@ -147,7 +202,7 @@ static void pgd_dtor(pgd_t *pgd)
29210 * -- nyc
29211 */
29212
29213 -#ifdef CONFIG_X86_PAE
29214 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29215 /*
29216 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29217 * updating the top-level pagetable entries to guarantee the
29218 @@ -159,7 +214,7 @@ static void pgd_dtor(pgd_t *pgd)
29219 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29220 * and initialize the kernel pmds here.
29221 */
29222 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29223 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29224
29225 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29226 {
29227 @@ -177,36 +232,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29228 */
29229 flush_tlb_mm(mm);
29230 }
29231 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29232 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29233 #else /* !CONFIG_X86_PAE */
29234
29235 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29236 -#define PREALLOCATED_PMDS 0
29237 +#define PREALLOCATED_PXDS 0
29238
29239 #endif /* CONFIG_X86_PAE */
29240
29241 -static void free_pmds(pmd_t *pmds[])
29242 +static void free_pxds(pxd_t *pxds[])
29243 {
29244 int i;
29245
29246 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29247 - if (pmds[i])
29248 - free_page((unsigned long)pmds[i]);
29249 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29250 + if (pxds[i])
29251 + free_page((unsigned long)pxds[i]);
29252 }
29253
29254 -static int preallocate_pmds(pmd_t *pmds[])
29255 +static int preallocate_pxds(pxd_t *pxds[])
29256 {
29257 int i;
29258 bool failed = false;
29259
29260 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29261 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29262 - if (pmd == NULL)
29263 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29264 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29265 + if (pxd == NULL)
29266 failed = true;
29267 - pmds[i] = pmd;
29268 + pxds[i] = pxd;
29269 }
29270
29271 if (failed) {
29272 - free_pmds(pmds);
29273 + free_pxds(pxds);
29274 return -ENOMEM;
29275 }
29276
29277 @@ -219,51 +276,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29278 * preallocate which never got a corresponding vma will need to be
29279 * freed manually.
29280 */
29281 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29282 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29283 {
29284 int i;
29285
29286 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29287 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29288 pgd_t pgd = pgdp[i];
29289
29290 if (pgd_val(pgd) != 0) {
29291 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29292 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29293
29294 - pgdp[i] = native_make_pgd(0);
29295 + set_pgd(pgdp + i, native_make_pgd(0));
29296
29297 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29298 - pmd_free(mm, pmd);
29299 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29300 + pxd_free(mm, pxd);
29301 }
29302 }
29303 }
29304
29305 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29306 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29307 {
29308 - pud_t *pud;
29309 + pyd_t *pyd;
29310 unsigned long addr;
29311 int i;
29312
29313 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29314 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29315 return;
29316
29317 - pud = pud_offset(pgd, 0);
29318 +#ifdef CONFIG_X86_64
29319 + pyd = pyd_offset(mm, 0L);
29320 +#else
29321 + pyd = pyd_offset(pgd, 0L);
29322 +#endif
29323
29324 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29325 - i++, pud++, addr += PUD_SIZE) {
29326 - pmd_t *pmd = pmds[i];
29327 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29328 + i++, pyd++, addr += PYD_SIZE) {
29329 + pxd_t *pxd = pxds[i];
29330
29331 if (i >= KERNEL_PGD_BOUNDARY)
29332 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29333 - sizeof(pmd_t) * PTRS_PER_PMD);
29334 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29335 + sizeof(pxd_t) * PTRS_PER_PMD);
29336
29337 - pud_populate(mm, pud, pmd);
29338 + pyd_populate(mm, pyd, pxd);
29339 }
29340 }
29341
29342 pgd_t *pgd_alloc(struct mm_struct *mm)
29343 {
29344 pgd_t *pgd;
29345 - pmd_t *pmds[PREALLOCATED_PMDS];
29346 + pxd_t *pxds[PREALLOCATED_PXDS];
29347
29348 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29349
29350 @@ -272,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29351
29352 mm->pgd = pgd;
29353
29354 - if (preallocate_pmds(pmds) != 0)
29355 + if (preallocate_pxds(pxds) != 0)
29356 goto out_free_pgd;
29357
29358 if (paravirt_pgd_alloc(mm) != 0)
29359 - goto out_free_pmds;
29360 + goto out_free_pxds;
29361
29362 /*
29363 * Make sure that pre-populating the pmds is atomic with
29364 @@ -286,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29365 spin_lock(&pgd_lock);
29366
29367 pgd_ctor(mm, pgd);
29368 - pgd_prepopulate_pmd(mm, pgd, pmds);
29369 + pgd_prepopulate_pxd(mm, pgd, pxds);
29370
29371 spin_unlock(&pgd_lock);
29372
29373 return pgd;
29374
29375 -out_free_pmds:
29376 - free_pmds(pmds);
29377 +out_free_pxds:
29378 + free_pxds(pxds);
29379 out_free_pgd:
29380 free_page((unsigned long)pgd);
29381 out:
29382 @@ -302,7 +363,7 @@ out:
29383
29384 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29385 {
29386 - pgd_mop_up_pmds(mm, pgd);
29387 + pgd_mop_up_pxds(mm, pgd);
29388 pgd_dtor(pgd);
29389 paravirt_pgd_free(mm, pgd);
29390 free_page((unsigned long)pgd);
29391 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29392 index a69bcb8..19068ab 100644
29393 --- a/arch/x86/mm/pgtable_32.c
29394 +++ b/arch/x86/mm/pgtable_32.c
29395 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29396 return;
29397 }
29398 pte = pte_offset_kernel(pmd, vaddr);
29399 +
29400 + pax_open_kernel();
29401 if (pte_val(pteval))
29402 set_pte_at(&init_mm, vaddr, pte, pteval);
29403 else
29404 pte_clear(&init_mm, vaddr, pte);
29405 + pax_close_kernel();
29406
29407 /*
29408 * It's enough to flush this one mapping.
29409 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29410 index e666cbb..61788c45 100644
29411 --- a/arch/x86/mm/physaddr.c
29412 +++ b/arch/x86/mm/physaddr.c
29413 @@ -10,7 +10,7 @@
29414 #ifdef CONFIG_X86_64
29415
29416 #ifdef CONFIG_DEBUG_VIRTUAL
29417 -unsigned long __phys_addr(unsigned long x)
29418 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29419 {
29420 unsigned long y = x - __START_KERNEL_map;
29421
29422 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29423 #else
29424
29425 #ifdef CONFIG_DEBUG_VIRTUAL
29426 -unsigned long __phys_addr(unsigned long x)
29427 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29428 {
29429 unsigned long phys_addr = x - PAGE_OFFSET;
29430 /* VMALLOC_* aren't constants */
29431 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29432 index 410531d..0f16030 100644
29433 --- a/arch/x86/mm/setup_nx.c
29434 +++ b/arch/x86/mm/setup_nx.c
29435 @@ -5,8 +5,10 @@
29436 #include <asm/pgtable.h>
29437 #include <asm/proto.h>
29438
29439 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29440 static int disable_nx __cpuinitdata;
29441
29442 +#ifndef CONFIG_PAX_PAGEEXEC
29443 /*
29444 * noexec = on|off
29445 *
29446 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29447 return 0;
29448 }
29449 early_param("noexec", noexec_setup);
29450 +#endif
29451 +
29452 +#endif
29453
29454 void __cpuinit x86_configure_nx(void)
29455 {
29456 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29457 if (cpu_has_nx && !disable_nx)
29458 __supported_pte_mask |= _PAGE_NX;
29459 else
29460 +#endif
29461 __supported_pte_mask &= ~_PAGE_NX;
29462 }
29463
29464 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29465 index 282375f..e03a98f 100644
29466 --- a/arch/x86/mm/tlb.c
29467 +++ b/arch/x86/mm/tlb.c
29468 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29469 BUG();
29470 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29471 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29472 +
29473 +#ifndef CONFIG_PAX_PER_CPU_PGD
29474 load_cr3(swapper_pg_dir);
29475 +#endif
29476 +
29477 }
29478 }
29479 EXPORT_SYMBOL_GPL(leave_mm);
29480 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29481 index 877b9a1..a8ecf42 100644
29482 --- a/arch/x86/net/bpf_jit.S
29483 +++ b/arch/x86/net/bpf_jit.S
29484 @@ -9,6 +9,7 @@
29485 */
29486 #include <linux/linkage.h>
29487 #include <asm/dwarf2.h>
29488 +#include <asm/alternative-asm.h>
29489
29490 /*
29491 * Calling convention :
29492 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29493 jle bpf_slow_path_word
29494 mov (SKBDATA,%rsi),%eax
29495 bswap %eax /* ntohl() */
29496 + pax_force_retaddr
29497 ret
29498
29499 sk_load_half:
29500 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29501 jle bpf_slow_path_half
29502 movzwl (SKBDATA,%rsi),%eax
29503 rol $8,%ax # ntohs()
29504 + pax_force_retaddr
29505 ret
29506
29507 sk_load_byte:
29508 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29509 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29510 jle bpf_slow_path_byte
29511 movzbl (SKBDATA,%rsi),%eax
29512 + pax_force_retaddr
29513 ret
29514
29515 /**
29516 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29517 movzbl (SKBDATA,%rsi),%ebx
29518 and $15,%bl
29519 shl $2,%bl
29520 + pax_force_retaddr
29521 ret
29522
29523 /* rsi contains offset and can be scratched */
29524 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29525 js bpf_error
29526 mov -12(%rbp),%eax
29527 bswap %eax
29528 + pax_force_retaddr
29529 ret
29530
29531 bpf_slow_path_half:
29532 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29533 mov -12(%rbp),%ax
29534 rol $8,%ax
29535 movzwl %ax,%eax
29536 + pax_force_retaddr
29537 ret
29538
29539 bpf_slow_path_byte:
29540 bpf_slow_path_common(1)
29541 js bpf_error
29542 movzbl -12(%rbp),%eax
29543 + pax_force_retaddr
29544 ret
29545
29546 bpf_slow_path_byte_msh:
29547 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29548 and $15,%al
29549 shl $2,%al
29550 xchg %eax,%ebx
29551 + pax_force_retaddr
29552 ret
29553
29554 #define sk_negative_common(SIZE) \
29555 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29556 sk_negative_common(4)
29557 mov (%rax), %eax
29558 bswap %eax
29559 + pax_force_retaddr
29560 ret
29561
29562 bpf_slow_path_half_neg:
29563 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29564 mov (%rax),%ax
29565 rol $8,%ax
29566 movzwl %ax,%eax
29567 + pax_force_retaddr
29568 ret
29569
29570 bpf_slow_path_byte_neg:
29571 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29572 .globl sk_load_byte_negative_offset
29573 sk_negative_common(1)
29574 movzbl (%rax), %eax
29575 + pax_force_retaddr
29576 ret
29577
29578 bpf_slow_path_byte_msh_neg:
29579 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29580 and $15,%al
29581 shl $2,%al
29582 xchg %eax,%ebx
29583 + pax_force_retaddr
29584 ret
29585
29586 bpf_error:
29587 @@ -197,4 +210,5 @@ bpf_error:
29588 xor %eax,%eax
29589 mov -8(%rbp),%rbx
29590 leaveq
29591 + pax_force_retaddr
29592 ret
29593 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29594 index 3cbe4538..003d011 100644
29595 --- a/arch/x86/net/bpf_jit_comp.c
29596 +++ b/arch/x86/net/bpf_jit_comp.c
29597 @@ -12,6 +12,7 @@
29598 #include <linux/netdevice.h>
29599 #include <linux/filter.h>
29600 #include <linux/if_vlan.h>
29601 +#include <linux/random.h>
29602
29603 /*
29604 * Conventions :
29605 @@ -49,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29606 return ptr + len;
29607 }
29608
29609 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29610 +#define MAX_INSTR_CODE_SIZE 96
29611 +#else
29612 +#define MAX_INSTR_CODE_SIZE 64
29613 +#endif
29614 +
29615 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29616
29617 #define EMIT1(b1) EMIT(b1, 1)
29618 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29619 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29620 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29621 +
29622 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29623 +/* original constant will appear in ecx */
29624 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29625 +do { \
29626 + /* mov ecx, randkey */ \
29627 + EMIT1(0xb9); \
29628 + EMIT(_key, 4); \
29629 + /* xor ecx, randkey ^ off */ \
29630 + EMIT2(0x81, 0xf1); \
29631 + EMIT((_key) ^ (_off), 4); \
29632 +} while (0)
29633 +
29634 +#define EMIT1_off32(b1, _off) \
29635 +do { \
29636 + switch (b1) { \
29637 + case 0x05: /* add eax, imm32 */ \
29638 + case 0x2d: /* sub eax, imm32 */ \
29639 + case 0x25: /* and eax, imm32 */ \
29640 + case 0x0d: /* or eax, imm32 */ \
29641 + case 0xb8: /* mov eax, imm32 */ \
29642 + case 0x35: /* xor eax, imm32 */ \
29643 + case 0x3d: /* cmp eax, imm32 */ \
29644 + case 0xa9: /* test eax, imm32 */ \
29645 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29646 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29647 + break; \
29648 + case 0xbb: /* mov ebx, imm32 */ \
29649 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29650 + /* mov ebx, ecx */ \
29651 + EMIT2(0x89, 0xcb); \
29652 + break; \
29653 + case 0xbe: /* mov esi, imm32 */ \
29654 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29655 + /* mov esi, ecx */ \
29656 + EMIT2(0x89, 0xce); \
29657 + break; \
29658 + case 0xe8: /* call rel imm32, always to known funcs */ \
29659 + EMIT1(b1); \
29660 + EMIT(_off, 4); \
29661 + break; \
29662 + case 0xe9: /* jmp rel imm32 */ \
29663 + EMIT1(b1); \
29664 + EMIT(_off, 4); \
29665 + /* prevent fall-through, we're not called if off = 0 */ \
29666 + EMIT(0xcccccccc, 4); \
29667 + EMIT(0xcccccccc, 4); \
29668 + break; \
29669 + default: \
29670 + BUILD_BUG(); \
29671 + } \
29672 +} while (0)
29673 +
29674 +#define EMIT2_off32(b1, b2, _off) \
29675 +do { \
29676 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29677 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29678 + EMIT(randkey, 4); \
29679 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29680 + EMIT((_off) - randkey, 4); \
29681 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29682 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29683 + /* imul eax, ecx */ \
29684 + EMIT3(0x0f, 0xaf, 0xc1); \
29685 + } else { \
29686 + BUILD_BUG(); \
29687 + } \
29688 +} while (0)
29689 +#else
29690 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
29691 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
29692 +#endif
29693
29694 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
29695 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
29696 @@ -90,6 +168,24 @@ do { \
29697 #define X86_JBE 0x76
29698 #define X86_JA 0x77
29699
29700 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29701 +#define APPEND_FLOW_VERIFY() \
29702 +do { \
29703 + /* mov ecx, randkey */ \
29704 + EMIT1(0xb9); \
29705 + EMIT(randkey, 4); \
29706 + /* cmp ecx, randkey */ \
29707 + EMIT2(0x81, 0xf9); \
29708 + EMIT(randkey, 4); \
29709 + /* jz after 8 int 3s */ \
29710 + EMIT2(0x74, 0x08); \
29711 + EMIT(0xcccccccc, 4); \
29712 + EMIT(0xcccccccc, 4); \
29713 +} while (0)
29714 +#else
29715 +#define APPEND_FLOW_VERIFY() do { } while (0)
29716 +#endif
29717 +
29718 #define EMIT_COND_JMP(op, offset) \
29719 do { \
29720 if (is_near(offset)) \
29721 @@ -97,6 +193,7 @@ do { \
29722 else { \
29723 EMIT2(0x0f, op + 0x10); \
29724 EMIT(offset, 4); /* jxx .+off32 */ \
29725 + APPEND_FLOW_VERIFY(); \
29726 } \
29727 } while (0)
29728
29729 @@ -121,6 +218,11 @@ static inline void bpf_flush_icache(void *start, void *end)
29730 set_fs(old_fs);
29731 }
29732
29733 +struct bpf_jit_work {
29734 + struct work_struct work;
29735 + void *image;
29736 +};
29737 +
29738 #define CHOOSE_LOAD_FUNC(K, func) \
29739 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
29740
29741 @@ -146,7 +248,7 @@ static int pkt_type_offset(void)
29742
29743 void bpf_jit_compile(struct sk_filter *fp)
29744 {
29745 - u8 temp[64];
29746 + u8 temp[MAX_INSTR_CODE_SIZE];
29747 u8 *prog;
29748 unsigned int proglen, oldproglen = 0;
29749 int ilen, i;
29750 @@ -159,6 +261,9 @@ void bpf_jit_compile(struct sk_filter *fp)
29751 unsigned int *addrs;
29752 const struct sock_filter *filter = fp->insns;
29753 int flen = fp->len;
29754 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29755 + unsigned int randkey;
29756 +#endif
29757
29758 if (!bpf_jit_enable)
29759 return;
29760 @@ -167,11 +272,19 @@ void bpf_jit_compile(struct sk_filter *fp)
29761 if (addrs == NULL)
29762 return;
29763
29764 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
29765 + if (!fp->work)
29766 + goto out;
29767 +
29768 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29769 + randkey = get_random_int();
29770 +#endif
29771 +
29772 /* Before first pass, make a rough estimation of addrs[]
29773 - * each bpf instruction is translated to less than 64 bytes
29774 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
29775 */
29776 for (proglen = 0, i = 0; i < flen; i++) {
29777 - proglen += 64;
29778 + proglen += MAX_INSTR_CODE_SIZE;
29779 addrs[i] = proglen;
29780 }
29781 cleanup_addr = proglen; /* epilogue address */
29782 @@ -282,10 +395,8 @@ void bpf_jit_compile(struct sk_filter *fp)
29783 case BPF_S_ALU_MUL_K: /* A *= K */
29784 if (is_imm8(K))
29785 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
29786 - else {
29787 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
29788 - EMIT(K, 4);
29789 - }
29790 + else
29791 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
29792 break;
29793 case BPF_S_ALU_DIV_X: /* A /= X; */
29794 seen |= SEEN_XREG;
29795 @@ -325,13 +436,23 @@ void bpf_jit_compile(struct sk_filter *fp)
29796 break;
29797 case BPF_S_ALU_MOD_K: /* A %= K; */
29798 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
29799 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29800 + DILUTE_CONST_SEQUENCE(K, randkey);
29801 +#else
29802 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
29803 +#endif
29804 EMIT2(0xf7, 0xf1); /* div %ecx */
29805 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
29806 break;
29807 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
29808 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29809 + DILUTE_CONST_SEQUENCE(K, randkey);
29810 + // imul rax, rcx
29811 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
29812 +#else
29813 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
29814 EMIT(K, 4);
29815 +#endif
29816 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
29817 break;
29818 case BPF_S_ALU_AND_X:
29819 @@ -602,8 +723,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
29820 if (is_imm8(K)) {
29821 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
29822 } else {
29823 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
29824 - EMIT(K, 4);
29825 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
29826 }
29827 } else {
29828 EMIT2(0x89,0xde); /* mov %ebx,%esi */
29829 @@ -686,17 +806,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29830 break;
29831 default:
29832 /* hmm, too complex filter, give up with jit compiler */
29833 - goto out;
29834 + goto error;
29835 }
29836 ilen = prog - temp;
29837 if (image) {
29838 if (unlikely(proglen + ilen > oldproglen)) {
29839 pr_err("bpb_jit_compile fatal error\n");
29840 - kfree(addrs);
29841 - module_free(NULL, image);
29842 - return;
29843 + module_free_exec(NULL, image);
29844 + goto error;
29845 }
29846 + pax_open_kernel();
29847 memcpy(image + proglen, temp, ilen);
29848 + pax_close_kernel();
29849 }
29850 proglen += ilen;
29851 addrs[i] = proglen;
29852 @@ -717,11 +838,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29853 break;
29854 }
29855 if (proglen == oldproglen) {
29856 - image = module_alloc(max_t(unsigned int,
29857 - proglen,
29858 - sizeof(struct work_struct)));
29859 + image = module_alloc_exec(proglen);
29860 if (!image)
29861 - goto out;
29862 + goto error;
29863 }
29864 oldproglen = proglen;
29865 }
29866 @@ -737,7 +856,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29867 bpf_flush_icache(image, image + proglen);
29868
29869 fp->bpf_func = (void *)image;
29870 - }
29871 + } else
29872 +error:
29873 + kfree(fp->work);
29874 +
29875 out:
29876 kfree(addrs);
29877 return;
29878 @@ -745,18 +867,20 @@ out:
29879
29880 static void jit_free_defer(struct work_struct *arg)
29881 {
29882 - module_free(NULL, arg);
29883 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
29884 + kfree(arg);
29885 }
29886
29887 /* run from softirq, we must use a work_struct to call
29888 - * module_free() from process context
29889 + * module_free_exec() from process context
29890 */
29891 void bpf_jit_free(struct sk_filter *fp)
29892 {
29893 if (fp->bpf_func != sk_run_filter) {
29894 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
29895 + struct work_struct *work = &fp->work->work;
29896
29897 INIT_WORK(work, jit_free_defer);
29898 + fp->work->image = fp->bpf_func;
29899 schedule_work(work);
29900 }
29901 }
29902 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
29903 index d6aa6e8..266395a 100644
29904 --- a/arch/x86/oprofile/backtrace.c
29905 +++ b/arch/x86/oprofile/backtrace.c
29906 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
29907 struct stack_frame_ia32 *fp;
29908 unsigned long bytes;
29909
29910 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29911 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29912 if (bytes != sizeof(bufhead))
29913 return NULL;
29914
29915 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
29916 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
29917
29918 oprofile_add_trace(bufhead[0].return_address);
29919
29920 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
29921 struct stack_frame bufhead[2];
29922 unsigned long bytes;
29923
29924 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29925 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29926 if (bytes != sizeof(bufhead))
29927 return NULL;
29928
29929 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
29930 {
29931 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
29932
29933 - if (!user_mode_vm(regs)) {
29934 + if (!user_mode(regs)) {
29935 unsigned long stack = kernel_stack_pointer(regs);
29936 if (depth)
29937 dump_trace(NULL, regs, (unsigned long *)stack, 0,
29938 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
29939 index 48768df..ba9143c 100644
29940 --- a/arch/x86/oprofile/nmi_int.c
29941 +++ b/arch/x86/oprofile/nmi_int.c
29942 @@ -23,6 +23,7 @@
29943 #include <asm/nmi.h>
29944 #include <asm/msr.h>
29945 #include <asm/apic.h>
29946 +#include <asm/pgtable.h>
29947
29948 #include "op_counter.h"
29949 #include "op_x86_model.h"
29950 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
29951 if (ret)
29952 return ret;
29953
29954 - if (!model->num_virt_counters)
29955 - model->num_virt_counters = model->num_counters;
29956 + if (!model->num_virt_counters) {
29957 + pax_open_kernel();
29958 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
29959 + pax_close_kernel();
29960 + }
29961
29962 mux_init(ops);
29963
29964 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
29965 index b2b9443..be58856 100644
29966 --- a/arch/x86/oprofile/op_model_amd.c
29967 +++ b/arch/x86/oprofile/op_model_amd.c
29968 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
29969 num_counters = AMD64_NUM_COUNTERS;
29970 }
29971
29972 - op_amd_spec.num_counters = num_counters;
29973 - op_amd_spec.num_controls = num_counters;
29974 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29975 + pax_open_kernel();
29976 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
29977 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
29978 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29979 + pax_close_kernel();
29980
29981 return 0;
29982 }
29983 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
29984 index d90528e..0127e2b 100644
29985 --- a/arch/x86/oprofile/op_model_ppro.c
29986 +++ b/arch/x86/oprofile/op_model_ppro.c
29987 @@ -19,6 +19,7 @@
29988 #include <asm/msr.h>
29989 #include <asm/apic.h>
29990 #include <asm/nmi.h>
29991 +#include <asm/pgtable.h>
29992
29993 #include "op_x86_model.h"
29994 #include "op_counter.h"
29995 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
29996
29997 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
29998
29999 - op_arch_perfmon_spec.num_counters = num_counters;
30000 - op_arch_perfmon_spec.num_controls = num_counters;
30001 + pax_open_kernel();
30002 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
30003 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
30004 + pax_close_kernel();
30005 }
30006
30007 static int arch_perfmon_init(struct oprofile_operations *ignore)
30008 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
30009 index 71e8a67..6a313bb 100644
30010 --- a/arch/x86/oprofile/op_x86_model.h
30011 +++ b/arch/x86/oprofile/op_x86_model.h
30012 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
30013 void (*switch_ctrl)(struct op_x86_model_spec const *model,
30014 struct op_msrs const * const msrs);
30015 #endif
30016 -};
30017 +} __do_const;
30018
30019 struct op_counter_config;
30020
30021 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
30022 index e9e6ed5..e47ae67 100644
30023 --- a/arch/x86/pci/amd_bus.c
30024 +++ b/arch/x86/pci/amd_bus.c
30025 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
30026 return NOTIFY_OK;
30027 }
30028
30029 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
30030 +static struct notifier_block amd_cpu_notifier = {
30031 .notifier_call = amd_cpu_notify,
30032 };
30033
30034 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
30035 index 372e9b8..e775a6c 100644
30036 --- a/arch/x86/pci/irq.c
30037 +++ b/arch/x86/pci/irq.c
30038 @@ -50,7 +50,7 @@ struct irq_router {
30039 struct irq_router_handler {
30040 u16 vendor;
30041 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
30042 -};
30043 +} __do_const;
30044
30045 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
30046 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
30047 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
30048 return 0;
30049 }
30050
30051 -static __initdata struct irq_router_handler pirq_routers[] = {
30052 +static __initconst const struct irq_router_handler pirq_routers[] = {
30053 { PCI_VENDOR_ID_INTEL, intel_router_probe },
30054 { PCI_VENDOR_ID_AL, ali_router_probe },
30055 { PCI_VENDOR_ID_ITE, ite_router_probe },
30056 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
30057 static void __init pirq_find_router(struct irq_router *r)
30058 {
30059 struct irq_routing_table *rt = pirq_table;
30060 - struct irq_router_handler *h;
30061 + const struct irq_router_handler *h;
30062
30063 #ifdef CONFIG_PCI_BIOS
30064 if (!rt->signature) {
30065 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
30066 return 0;
30067 }
30068
30069 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
30070 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
30071 {
30072 .callback = fix_broken_hp_bios_irq9,
30073 .ident = "HP Pavilion N5400 Series Laptop",
30074 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
30075 index 6eb18c4..20d83de 100644
30076 --- a/arch/x86/pci/mrst.c
30077 +++ b/arch/x86/pci/mrst.c
30078 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
30079 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
30080 pci_mmcfg_late_init();
30081 pcibios_enable_irq = mrst_pci_irq_enable;
30082 - pci_root_ops = pci_mrst_ops;
30083 + pax_open_kernel();
30084 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
30085 + pax_close_kernel();
30086 pci_soc_mode = 1;
30087 /* Continue with standard init */
30088 return 1;
30089 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
30090 index c77b24a..c979855 100644
30091 --- a/arch/x86/pci/pcbios.c
30092 +++ b/arch/x86/pci/pcbios.c
30093 @@ -79,7 +79,7 @@ union bios32 {
30094 static struct {
30095 unsigned long address;
30096 unsigned short segment;
30097 -} bios32_indirect = { 0, __KERNEL_CS };
30098 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
30099
30100 /*
30101 * Returns the entry point for the given service, NULL on error
30102 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30103 unsigned long length; /* %ecx */
30104 unsigned long entry; /* %edx */
30105 unsigned long flags;
30106 + struct desc_struct d, *gdt;
30107
30108 local_irq_save(flags);
30109 - __asm__("lcall *(%%edi); cld"
30110 +
30111 + gdt = get_cpu_gdt_table(smp_processor_id());
30112 +
30113 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30114 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30115 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30116 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30117 +
30118 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30119 : "=a" (return_code),
30120 "=b" (address),
30121 "=c" (length),
30122 "=d" (entry)
30123 : "0" (service),
30124 "1" (0),
30125 - "D" (&bios32_indirect));
30126 + "D" (&bios32_indirect),
30127 + "r"(__PCIBIOS_DS)
30128 + : "memory");
30129 +
30130 + pax_open_kernel();
30131 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30132 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30133 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30134 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30135 + pax_close_kernel();
30136 +
30137 local_irq_restore(flags);
30138
30139 switch (return_code) {
30140 - case 0:
30141 - return address + entry;
30142 - case 0x80: /* Not present */
30143 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30144 - return 0;
30145 - default: /* Shouldn't happen */
30146 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30147 - service, return_code);
30148 + case 0: {
30149 + int cpu;
30150 + unsigned char flags;
30151 +
30152 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30153 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30154 + printk(KERN_WARNING "bios32_service: not valid\n");
30155 return 0;
30156 + }
30157 + address = address + PAGE_OFFSET;
30158 + length += 16UL; /* some BIOSs underreport this... */
30159 + flags = 4;
30160 + if (length >= 64*1024*1024) {
30161 + length >>= PAGE_SHIFT;
30162 + flags |= 8;
30163 + }
30164 +
30165 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30166 + gdt = get_cpu_gdt_table(cpu);
30167 + pack_descriptor(&d, address, length, 0x9b, flags);
30168 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30169 + pack_descriptor(&d, address, length, 0x93, flags);
30170 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30171 + }
30172 + return entry;
30173 + }
30174 + case 0x80: /* Not present */
30175 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30176 + return 0;
30177 + default: /* Shouldn't happen */
30178 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30179 + service, return_code);
30180 + return 0;
30181 }
30182 }
30183
30184 static struct {
30185 unsigned long address;
30186 unsigned short segment;
30187 -} pci_indirect = { 0, __KERNEL_CS };
30188 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30189
30190 -static int pci_bios_present;
30191 +static int pci_bios_present __read_only;
30192
30193 static int check_pcibios(void)
30194 {
30195 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30196 unsigned long flags, pcibios_entry;
30197
30198 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30199 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30200 + pci_indirect.address = pcibios_entry;
30201
30202 local_irq_save(flags);
30203 - __asm__(
30204 - "lcall *(%%edi); cld\n\t"
30205 + __asm__("movw %w6, %%ds\n\t"
30206 + "lcall *%%ss:(%%edi); cld\n\t"
30207 + "push %%ss\n\t"
30208 + "pop %%ds\n\t"
30209 "jc 1f\n\t"
30210 "xor %%ah, %%ah\n"
30211 "1:"
30212 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30213 "=b" (ebx),
30214 "=c" (ecx)
30215 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30216 - "D" (&pci_indirect)
30217 + "D" (&pci_indirect),
30218 + "r" (__PCIBIOS_DS)
30219 : "memory");
30220 local_irq_restore(flags);
30221
30222 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30223
30224 switch (len) {
30225 case 1:
30226 - __asm__("lcall *(%%esi); cld\n\t"
30227 + __asm__("movw %w6, %%ds\n\t"
30228 + "lcall *%%ss:(%%esi); cld\n\t"
30229 + "push %%ss\n\t"
30230 + "pop %%ds\n\t"
30231 "jc 1f\n\t"
30232 "xor %%ah, %%ah\n"
30233 "1:"
30234 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30235 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30236 "b" (bx),
30237 "D" ((long)reg),
30238 - "S" (&pci_indirect));
30239 + "S" (&pci_indirect),
30240 + "r" (__PCIBIOS_DS));
30241 /*
30242 * Zero-extend the result beyond 8 bits, do not trust the
30243 * BIOS having done it:
30244 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30245 *value &= 0xff;
30246 break;
30247 case 2:
30248 - __asm__("lcall *(%%esi); cld\n\t"
30249 + __asm__("movw %w6, %%ds\n\t"
30250 + "lcall *%%ss:(%%esi); cld\n\t"
30251 + "push %%ss\n\t"
30252 + "pop %%ds\n\t"
30253 "jc 1f\n\t"
30254 "xor %%ah, %%ah\n"
30255 "1:"
30256 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30257 : "1" (PCIBIOS_READ_CONFIG_WORD),
30258 "b" (bx),
30259 "D" ((long)reg),
30260 - "S" (&pci_indirect));
30261 + "S" (&pci_indirect),
30262 + "r" (__PCIBIOS_DS));
30263 /*
30264 * Zero-extend the result beyond 16 bits, do not trust the
30265 * BIOS having done it:
30266 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30267 *value &= 0xffff;
30268 break;
30269 case 4:
30270 - __asm__("lcall *(%%esi); cld\n\t"
30271 + __asm__("movw %w6, %%ds\n\t"
30272 + "lcall *%%ss:(%%esi); cld\n\t"
30273 + "push %%ss\n\t"
30274 + "pop %%ds\n\t"
30275 "jc 1f\n\t"
30276 "xor %%ah, %%ah\n"
30277 "1:"
30278 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30279 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30280 "b" (bx),
30281 "D" ((long)reg),
30282 - "S" (&pci_indirect));
30283 + "S" (&pci_indirect),
30284 + "r" (__PCIBIOS_DS));
30285 break;
30286 }
30287
30288 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30289
30290 switch (len) {
30291 case 1:
30292 - __asm__("lcall *(%%esi); cld\n\t"
30293 + __asm__("movw %w6, %%ds\n\t"
30294 + "lcall *%%ss:(%%esi); cld\n\t"
30295 + "push %%ss\n\t"
30296 + "pop %%ds\n\t"
30297 "jc 1f\n\t"
30298 "xor %%ah, %%ah\n"
30299 "1:"
30300 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30301 "c" (value),
30302 "b" (bx),
30303 "D" ((long)reg),
30304 - "S" (&pci_indirect));
30305 + "S" (&pci_indirect),
30306 + "r" (__PCIBIOS_DS));
30307 break;
30308 case 2:
30309 - __asm__("lcall *(%%esi); cld\n\t"
30310 + __asm__("movw %w6, %%ds\n\t"
30311 + "lcall *%%ss:(%%esi); cld\n\t"
30312 + "push %%ss\n\t"
30313 + "pop %%ds\n\t"
30314 "jc 1f\n\t"
30315 "xor %%ah, %%ah\n"
30316 "1:"
30317 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30318 "c" (value),
30319 "b" (bx),
30320 "D" ((long)reg),
30321 - "S" (&pci_indirect));
30322 + "S" (&pci_indirect),
30323 + "r" (__PCIBIOS_DS));
30324 break;
30325 case 4:
30326 - __asm__("lcall *(%%esi); cld\n\t"
30327 + __asm__("movw %w6, %%ds\n\t"
30328 + "lcall *%%ss:(%%esi); cld\n\t"
30329 + "push %%ss\n\t"
30330 + "pop %%ds\n\t"
30331 "jc 1f\n\t"
30332 "xor %%ah, %%ah\n"
30333 "1:"
30334 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30335 "c" (value),
30336 "b" (bx),
30337 "D" ((long)reg),
30338 - "S" (&pci_indirect));
30339 + "S" (&pci_indirect),
30340 + "r" (__PCIBIOS_DS));
30341 break;
30342 }
30343
30344 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30345
30346 DBG("PCI: Fetching IRQ routing table... ");
30347 __asm__("push %%es\n\t"
30348 + "movw %w8, %%ds\n\t"
30349 "push %%ds\n\t"
30350 "pop %%es\n\t"
30351 - "lcall *(%%esi); cld\n\t"
30352 + "lcall *%%ss:(%%esi); cld\n\t"
30353 "pop %%es\n\t"
30354 + "push %%ss\n\t"
30355 + "pop %%ds\n"
30356 "jc 1f\n\t"
30357 "xor %%ah, %%ah\n"
30358 "1:"
30359 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30360 "1" (0),
30361 "D" ((long) &opt),
30362 "S" (&pci_indirect),
30363 - "m" (opt)
30364 + "m" (opt),
30365 + "r" (__PCIBIOS_DS)
30366 : "memory");
30367 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30368 if (ret & 0xff00)
30369 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30370 {
30371 int ret;
30372
30373 - __asm__("lcall *(%%esi); cld\n\t"
30374 + __asm__("movw %w5, %%ds\n\t"
30375 + "lcall *%%ss:(%%esi); cld\n\t"
30376 + "push %%ss\n\t"
30377 + "pop %%ds\n"
30378 "jc 1f\n\t"
30379 "xor %%ah, %%ah\n"
30380 "1:"
30381 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30382 : "0" (PCIBIOS_SET_PCI_HW_INT),
30383 "b" ((dev->bus->number << 8) | dev->devfn),
30384 "c" ((irq << 8) | (pin + 10)),
30385 - "S" (&pci_indirect));
30386 + "S" (&pci_indirect),
30387 + "r" (__PCIBIOS_DS));
30388 return !(ret & 0xff00);
30389 }
30390 EXPORT_SYMBOL(pcibios_set_irq_routing);
30391 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30392 index 40e4469..1ab536e 100644
30393 --- a/arch/x86/platform/efi/efi_32.c
30394 +++ b/arch/x86/platform/efi/efi_32.c
30395 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30396 {
30397 struct desc_ptr gdt_descr;
30398
30399 +#ifdef CONFIG_PAX_KERNEXEC
30400 + struct desc_struct d;
30401 +#endif
30402 +
30403 local_irq_save(efi_rt_eflags);
30404
30405 load_cr3(initial_page_table);
30406 __flush_tlb_all();
30407
30408 +#ifdef CONFIG_PAX_KERNEXEC
30409 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30410 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30411 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30412 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30413 +#endif
30414 +
30415 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30416 gdt_descr.size = GDT_SIZE - 1;
30417 load_gdt(&gdt_descr);
30418 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
30419 {
30420 struct desc_ptr gdt_descr;
30421
30422 +#ifdef CONFIG_PAX_KERNEXEC
30423 + struct desc_struct d;
30424 +
30425 + memset(&d, 0, sizeof d);
30426 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30427 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30428 +#endif
30429 +
30430 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30431 gdt_descr.size = GDT_SIZE - 1;
30432 load_gdt(&gdt_descr);
30433 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30434 index fbe66e6..eae5e38 100644
30435 --- a/arch/x86/platform/efi/efi_stub_32.S
30436 +++ b/arch/x86/platform/efi/efi_stub_32.S
30437 @@ -6,7 +6,9 @@
30438 */
30439
30440 #include <linux/linkage.h>
30441 +#include <linux/init.h>
30442 #include <asm/page_types.h>
30443 +#include <asm/segment.h>
30444
30445 /*
30446 * efi_call_phys(void *, ...) is a function with variable parameters.
30447 @@ -20,7 +22,7 @@
30448 * service functions will comply with gcc calling convention, too.
30449 */
30450
30451 -.text
30452 +__INIT
30453 ENTRY(efi_call_phys)
30454 /*
30455 * 0. The function can only be called in Linux kernel. So CS has been
30456 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30457 * The mapping of lower virtual memory has been created in prelog and
30458 * epilog.
30459 */
30460 - movl $1f, %edx
30461 - subl $__PAGE_OFFSET, %edx
30462 - jmp *%edx
30463 +#ifdef CONFIG_PAX_KERNEXEC
30464 + movl $(__KERNEXEC_EFI_DS), %edx
30465 + mov %edx, %ds
30466 + mov %edx, %es
30467 + mov %edx, %ss
30468 + addl $2f,(1f)
30469 + ljmp *(1f)
30470 +
30471 +__INITDATA
30472 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30473 +.previous
30474 +
30475 +2:
30476 + subl $2b,(1b)
30477 +#else
30478 + jmp 1f-__PAGE_OFFSET
30479 1:
30480 +#endif
30481
30482 /*
30483 * 2. Now on the top of stack is the return
30484 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30485 * parameter 2, ..., param n. To make things easy, we save the return
30486 * address of efi_call_phys in a global variable.
30487 */
30488 - popl %edx
30489 - movl %edx, saved_return_addr
30490 - /* get the function pointer into ECX*/
30491 - popl %ecx
30492 - movl %ecx, efi_rt_function_ptr
30493 - movl $2f, %edx
30494 - subl $__PAGE_OFFSET, %edx
30495 - pushl %edx
30496 + popl (saved_return_addr)
30497 + popl (efi_rt_function_ptr)
30498
30499 /*
30500 * 3. Clear PG bit in %CR0.
30501 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30502 /*
30503 * 5. Call the physical function.
30504 */
30505 - jmp *%ecx
30506 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30507
30508 -2:
30509 /*
30510 * 6. After EFI runtime service returns, control will return to
30511 * following instruction. We'd better readjust stack pointer first.
30512 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30513 movl %cr0, %edx
30514 orl $0x80000000, %edx
30515 movl %edx, %cr0
30516 - jmp 1f
30517 -1:
30518 +
30519 /*
30520 * 8. Now restore the virtual mode from flat mode by
30521 * adding EIP with PAGE_OFFSET.
30522 */
30523 - movl $1f, %edx
30524 - jmp *%edx
30525 +#ifdef CONFIG_PAX_KERNEXEC
30526 + movl $(__KERNEL_DS), %edx
30527 + mov %edx, %ds
30528 + mov %edx, %es
30529 + mov %edx, %ss
30530 + ljmp $(__KERNEL_CS),$1f
30531 +#else
30532 + jmp 1f+__PAGE_OFFSET
30533 +#endif
30534 1:
30535
30536 /*
30537 * 9. Balance the stack. And because EAX contain the return value,
30538 * we'd better not clobber it.
30539 */
30540 - leal efi_rt_function_ptr, %edx
30541 - movl (%edx), %ecx
30542 - pushl %ecx
30543 + pushl (efi_rt_function_ptr)
30544
30545 /*
30546 - * 10. Push the saved return address onto the stack and return.
30547 + * 10. Return to the saved return address.
30548 */
30549 - leal saved_return_addr, %edx
30550 - movl (%edx), %ecx
30551 - pushl %ecx
30552 - ret
30553 + jmpl *(saved_return_addr)
30554 ENDPROC(efi_call_phys)
30555 .previous
30556
30557 -.data
30558 +__INITDATA
30559 saved_return_addr:
30560 .long 0
30561 efi_rt_function_ptr:
30562 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30563 index 4c07cca..2c8427d 100644
30564 --- a/arch/x86/platform/efi/efi_stub_64.S
30565 +++ b/arch/x86/platform/efi/efi_stub_64.S
30566 @@ -7,6 +7,7 @@
30567 */
30568
30569 #include <linux/linkage.h>
30570 +#include <asm/alternative-asm.h>
30571
30572 #define SAVE_XMM \
30573 mov %rsp, %rax; \
30574 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30575 call *%rdi
30576 addq $32, %rsp
30577 RESTORE_XMM
30578 + pax_force_retaddr 0, 1
30579 ret
30580 ENDPROC(efi_call0)
30581
30582 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30583 call *%rdi
30584 addq $32, %rsp
30585 RESTORE_XMM
30586 + pax_force_retaddr 0, 1
30587 ret
30588 ENDPROC(efi_call1)
30589
30590 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30591 call *%rdi
30592 addq $32, %rsp
30593 RESTORE_XMM
30594 + pax_force_retaddr 0, 1
30595 ret
30596 ENDPROC(efi_call2)
30597
30598 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30599 call *%rdi
30600 addq $32, %rsp
30601 RESTORE_XMM
30602 + pax_force_retaddr 0, 1
30603 ret
30604 ENDPROC(efi_call3)
30605
30606 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30607 call *%rdi
30608 addq $32, %rsp
30609 RESTORE_XMM
30610 + pax_force_retaddr 0, 1
30611 ret
30612 ENDPROC(efi_call4)
30613
30614 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30615 call *%rdi
30616 addq $48, %rsp
30617 RESTORE_XMM
30618 + pax_force_retaddr 0, 1
30619 ret
30620 ENDPROC(efi_call5)
30621
30622 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30623 call *%rdi
30624 addq $48, %rsp
30625 RESTORE_XMM
30626 + pax_force_retaddr 0, 1
30627 ret
30628 ENDPROC(efi_call6)
30629 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30630 index e31bcd8..f12dc46 100644
30631 --- a/arch/x86/platform/mrst/mrst.c
30632 +++ b/arch/x86/platform/mrst/mrst.c
30633 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30634 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30635 int sfi_mrtc_num;
30636
30637 -static void mrst_power_off(void)
30638 +static __noreturn void mrst_power_off(void)
30639 {
30640 + BUG();
30641 }
30642
30643 -static void mrst_reboot(void)
30644 +static __noreturn void mrst_reboot(void)
30645 {
30646 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30647 + BUG();
30648 }
30649
30650 /* parse all the mtimer info to a static mtimer array */
30651 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30652 index d6ee929..3637cb5 100644
30653 --- a/arch/x86/platform/olpc/olpc_dt.c
30654 +++ b/arch/x86/platform/olpc/olpc_dt.c
30655 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30656 return res;
30657 }
30658
30659 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30660 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30661 .nextprop = olpc_dt_nextprop,
30662 .getproplen = olpc_dt_getproplen,
30663 .getproperty = olpc_dt_getproperty,
30664 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30665 index 3c68768..07e82b8 100644
30666 --- a/arch/x86/power/cpu.c
30667 +++ b/arch/x86/power/cpu.c
30668 @@ -134,7 +134,7 @@ static void do_fpu_end(void)
30669 static void fix_processor_context(void)
30670 {
30671 int cpu = smp_processor_id();
30672 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30673 + struct tss_struct *t = init_tss + cpu;
30674
30675 set_tss_desc(cpu, t); /*
30676 * This just modifies memory; should not be
30677 @@ -144,8 +144,6 @@ static void fix_processor_context(void)
30678 */
30679
30680 #ifdef CONFIG_X86_64
30681 - get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
30682 -
30683 syscall_init(); /* This sets MSR_*STAR and related */
30684 #endif
30685 load_TR_desc(); /* This does ltr */
30686 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30687 index a44f457..9140171 100644
30688 --- a/arch/x86/realmode/init.c
30689 +++ b/arch/x86/realmode/init.c
30690 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
30691 __va(real_mode_header->trampoline_header);
30692
30693 #ifdef CONFIG_X86_32
30694 - trampoline_header->start = __pa_symbol(startup_32_smp);
30695 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
30696 +
30697 +#ifdef CONFIG_PAX_KERNEXEC
30698 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
30699 +#endif
30700 +
30701 + trampoline_header->boot_cs = __BOOT_CS;
30702 trampoline_header->gdt_limit = __BOOT_DS + 7;
30703 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
30704 #else
30705 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
30706 *trampoline_cr4_features = read_cr4();
30707
30708 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
30709 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
30710 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
30711 trampoline_pgd[511] = init_level4_pgt[511].pgd;
30712 #endif
30713 }
30714 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
30715 index 8869287..d577672 100644
30716 --- a/arch/x86/realmode/rm/Makefile
30717 +++ b/arch/x86/realmode/rm/Makefile
30718 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
30719 $(call cc-option, -fno-unit-at-a-time)) \
30720 $(call cc-option, -fno-stack-protector) \
30721 $(call cc-option, -mpreferred-stack-boundary=2)
30722 +ifdef CONSTIFY_PLUGIN
30723 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
30724 +endif
30725 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
30726 GCOV_PROFILE := n
30727 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
30728 index a28221d..93c40f1 100644
30729 --- a/arch/x86/realmode/rm/header.S
30730 +++ b/arch/x86/realmode/rm/header.S
30731 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
30732 #endif
30733 /* APM/BIOS reboot */
30734 .long pa_machine_real_restart_asm
30735 -#ifdef CONFIG_X86_64
30736 +#ifdef CONFIG_X86_32
30737 + .long __KERNEL_CS
30738 +#else
30739 .long __KERNEL32_CS
30740 #endif
30741 END(real_mode_header)
30742 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
30743 index c1b2791..f9e31c7 100644
30744 --- a/arch/x86/realmode/rm/trampoline_32.S
30745 +++ b/arch/x86/realmode/rm/trampoline_32.S
30746 @@ -25,6 +25,12 @@
30747 #include <asm/page_types.h>
30748 #include "realmode.h"
30749
30750 +#ifdef CONFIG_PAX_KERNEXEC
30751 +#define ta(X) (X)
30752 +#else
30753 +#define ta(X) (pa_ ## X)
30754 +#endif
30755 +
30756 .text
30757 .code16
30758
30759 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
30760
30761 cli # We should be safe anyway
30762
30763 - movl tr_start, %eax # where we need to go
30764 -
30765 movl $0xA5A5A5A5, trampoline_status
30766 # write marker for master knows we're running
30767
30768 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
30769 movw $1, %dx # protected mode (PE) bit
30770 lmsw %dx # into protected mode
30771
30772 - ljmpl $__BOOT_CS, $pa_startup_32
30773 + ljmpl *(trampoline_header)
30774
30775 .section ".text32","ax"
30776 .code32
30777 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
30778 .balign 8
30779 GLOBAL(trampoline_header)
30780 tr_start: .space 4
30781 - tr_gdt_pad: .space 2
30782 + tr_boot_cs: .space 2
30783 tr_gdt: .space 6
30784 END(trampoline_header)
30785
30786 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
30787 index bb360dc..3e5945f 100644
30788 --- a/arch/x86/realmode/rm/trampoline_64.S
30789 +++ b/arch/x86/realmode/rm/trampoline_64.S
30790 @@ -107,7 +107,7 @@ ENTRY(startup_32)
30791 wrmsr
30792
30793 # Enable paging and in turn activate Long Mode
30794 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
30795 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
30796 movl %eax, %cr0
30797
30798 /*
30799 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
30800 index 79d67bd..c7e1b90 100644
30801 --- a/arch/x86/tools/relocs.c
30802 +++ b/arch/x86/tools/relocs.c
30803 @@ -12,10 +12,13 @@
30804 #include <regex.h>
30805 #include <tools/le_byteshift.h>
30806
30807 +#include "../../../include/generated/autoconf.h"
30808 +
30809 static void die(char *fmt, ...);
30810
30811 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
30812 static Elf32_Ehdr ehdr;
30813 +static Elf32_Phdr *phdr;
30814 static unsigned long reloc_count, reloc_idx;
30815 static unsigned long *relocs;
30816 static unsigned long reloc16_count, reloc16_idx;
30817 @@ -330,9 +333,39 @@ static void read_ehdr(FILE *fp)
30818 }
30819 }
30820
30821 +static void read_phdrs(FILE *fp)
30822 +{
30823 + unsigned int i;
30824 +
30825 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
30826 + if (!phdr) {
30827 + die("Unable to allocate %d program headers\n",
30828 + ehdr.e_phnum);
30829 + }
30830 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
30831 + die("Seek to %d failed: %s\n",
30832 + ehdr.e_phoff, strerror(errno));
30833 + }
30834 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
30835 + die("Cannot read ELF program headers: %s\n",
30836 + strerror(errno));
30837 + }
30838 + for(i = 0; i < ehdr.e_phnum; i++) {
30839 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
30840 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
30841 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
30842 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
30843 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
30844 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
30845 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
30846 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
30847 + }
30848 +
30849 +}
30850 +
30851 static void read_shdrs(FILE *fp)
30852 {
30853 - int i;
30854 + unsigned int i;
30855 Elf32_Shdr shdr;
30856
30857 secs = calloc(ehdr.e_shnum, sizeof(struct section));
30858 @@ -367,7 +400,7 @@ static void read_shdrs(FILE *fp)
30859
30860 static void read_strtabs(FILE *fp)
30861 {
30862 - int i;
30863 + unsigned int i;
30864 for (i = 0; i < ehdr.e_shnum; i++) {
30865 struct section *sec = &secs[i];
30866 if (sec->shdr.sh_type != SHT_STRTAB) {
30867 @@ -392,7 +425,7 @@ static void read_strtabs(FILE *fp)
30868
30869 static void read_symtabs(FILE *fp)
30870 {
30871 - int i,j;
30872 + unsigned int i,j;
30873 for (i = 0; i < ehdr.e_shnum; i++) {
30874 struct section *sec = &secs[i];
30875 if (sec->shdr.sh_type != SHT_SYMTAB) {
30876 @@ -423,9 +456,11 @@ static void read_symtabs(FILE *fp)
30877 }
30878
30879
30880 -static void read_relocs(FILE *fp)
30881 +static void read_relocs(FILE *fp, int use_real_mode)
30882 {
30883 - int i,j;
30884 + unsigned int i,j;
30885 + uint32_t base;
30886 +
30887 for (i = 0; i < ehdr.e_shnum; i++) {
30888 struct section *sec = &secs[i];
30889 if (sec->shdr.sh_type != SHT_REL) {
30890 @@ -445,9 +480,22 @@ static void read_relocs(FILE *fp)
30891 die("Cannot read symbol table: %s\n",
30892 strerror(errno));
30893 }
30894 + base = 0;
30895 +
30896 +#ifdef CONFIG_X86_32
30897 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
30898 + if (phdr[j].p_type != PT_LOAD )
30899 + continue;
30900 + if (secs[sec->shdr.sh_info].shdr.sh_offset < phdr[j].p_offset || secs[sec->shdr.sh_info].shdr.sh_offset >= phdr[j].p_offset + phdr[j].p_filesz)
30901 + continue;
30902 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
30903 + break;
30904 + }
30905 +#endif
30906 +
30907 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
30908 Elf32_Rel *rel = &sec->reltab[j];
30909 - rel->r_offset = elf32_to_cpu(rel->r_offset);
30910 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
30911 rel->r_info = elf32_to_cpu(rel->r_info);
30912 }
30913 }
30914 @@ -456,13 +504,13 @@ static void read_relocs(FILE *fp)
30915
30916 static void print_absolute_symbols(void)
30917 {
30918 - int i;
30919 + unsigned int i;
30920 printf("Absolute symbols\n");
30921 printf(" Num: Value Size Type Bind Visibility Name\n");
30922 for (i = 0; i < ehdr.e_shnum; i++) {
30923 struct section *sec = &secs[i];
30924 char *sym_strtab;
30925 - int j;
30926 + unsigned int j;
30927
30928 if (sec->shdr.sh_type != SHT_SYMTAB) {
30929 continue;
30930 @@ -489,14 +537,14 @@ static void print_absolute_symbols(void)
30931
30932 static void print_absolute_relocs(void)
30933 {
30934 - int i, printed = 0;
30935 + unsigned int i, printed = 0;
30936
30937 for (i = 0; i < ehdr.e_shnum; i++) {
30938 struct section *sec = &secs[i];
30939 struct section *sec_applies, *sec_symtab;
30940 char *sym_strtab;
30941 Elf32_Sym *sh_symtab;
30942 - int j;
30943 + unsigned int j;
30944 if (sec->shdr.sh_type != SHT_REL) {
30945 continue;
30946 }
30947 @@ -558,13 +606,13 @@ static void print_absolute_relocs(void)
30948 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
30949 int use_real_mode)
30950 {
30951 - int i;
30952 + unsigned int i;
30953 /* Walk through the relocations */
30954 for (i = 0; i < ehdr.e_shnum; i++) {
30955 char *sym_strtab;
30956 Elf32_Sym *sh_symtab;
30957 struct section *sec_applies, *sec_symtab;
30958 - int j;
30959 + unsigned int j;
30960 struct section *sec = &secs[i];
30961
30962 if (sec->shdr.sh_type != SHT_REL) {
30963 @@ -588,6 +636,24 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
30964 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
30965 r_type = ELF32_R_TYPE(rel->r_info);
30966
30967 + if (!use_real_mode) {
30968 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
30969 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
30970 + continue;
30971 +
30972 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
30973 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
30974 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
30975 + continue;
30976 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
30977 + continue;
30978 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
30979 + continue;
30980 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
30981 + continue;
30982 +#endif
30983 + }
30984 +
30985 shn_abs = sym->st_shndx == SHN_ABS;
30986
30987 switch (r_type) {
30988 @@ -681,7 +747,7 @@ static int write32(unsigned int v, FILE *f)
30989
30990 static void emit_relocs(int as_text, int use_real_mode)
30991 {
30992 - int i;
30993 + unsigned int i;
30994 /* Count how many relocations I have and allocate space for them. */
30995 reloc_count = 0;
30996 walk_relocs(count_reloc, use_real_mode);
30997 @@ -808,10 +874,11 @@ int main(int argc, char **argv)
30998 fname, strerror(errno));
30999 }
31000 read_ehdr(fp);
31001 + read_phdrs(fp);
31002 read_shdrs(fp);
31003 read_strtabs(fp);
31004 read_symtabs(fp);
31005 - read_relocs(fp);
31006 + read_relocs(fp, use_real_mode);
31007 if (show_absolute_syms) {
31008 print_absolute_symbols();
31009 goto out;
31010 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
31011 index fd14be1..e3c79c0 100644
31012 --- a/arch/x86/vdso/Makefile
31013 +++ b/arch/x86/vdso/Makefile
31014 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
31015 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
31016 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
31017
31018 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31019 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31020 GCOV_PROFILE := n
31021
31022 #
31023 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
31024 index 0faad64..39ef157 100644
31025 --- a/arch/x86/vdso/vdso32-setup.c
31026 +++ b/arch/x86/vdso/vdso32-setup.c
31027 @@ -25,6 +25,7 @@
31028 #include <asm/tlbflush.h>
31029 #include <asm/vdso.h>
31030 #include <asm/proto.h>
31031 +#include <asm/mman.h>
31032
31033 enum {
31034 VDSO_DISABLED = 0,
31035 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
31036 void enable_sep_cpu(void)
31037 {
31038 int cpu = get_cpu();
31039 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
31040 + struct tss_struct *tss = init_tss + cpu;
31041
31042 if (!boot_cpu_has(X86_FEATURE_SEP)) {
31043 put_cpu();
31044 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
31045 gate_vma.vm_start = FIXADDR_USER_START;
31046 gate_vma.vm_end = FIXADDR_USER_END;
31047 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
31048 - gate_vma.vm_page_prot = __P101;
31049 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
31050
31051 return 0;
31052 }
31053 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31054 if (compat)
31055 addr = VDSO_HIGH_BASE;
31056 else {
31057 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
31058 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
31059 if (IS_ERR_VALUE(addr)) {
31060 ret = addr;
31061 goto up_fail;
31062 }
31063 }
31064
31065 - current->mm->context.vdso = (void *)addr;
31066 + current->mm->context.vdso = addr;
31067
31068 if (compat_uses_vma || !compat) {
31069 /*
31070 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31071 }
31072
31073 current_thread_info()->sysenter_return =
31074 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31075 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31076
31077 up_fail:
31078 if (ret)
31079 - current->mm->context.vdso = NULL;
31080 + current->mm->context.vdso = 0;
31081
31082 up_write(&mm->mmap_sem);
31083
31084 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
31085
31086 const char *arch_vma_name(struct vm_area_struct *vma)
31087 {
31088 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31089 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31090 return "[vdso]";
31091 +
31092 +#ifdef CONFIG_PAX_SEGMEXEC
31093 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
31094 + return "[vdso]";
31095 +#endif
31096 +
31097 return NULL;
31098 }
31099
31100 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31101 * Check to see if the corresponding task was created in compat vdso
31102 * mode.
31103 */
31104 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
31105 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
31106 return &gate_vma;
31107 return NULL;
31108 }
31109 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
31110 index 431e875..cbb23f3 100644
31111 --- a/arch/x86/vdso/vma.c
31112 +++ b/arch/x86/vdso/vma.c
31113 @@ -16,8 +16,6 @@
31114 #include <asm/vdso.h>
31115 #include <asm/page.h>
31116
31117 -unsigned int __read_mostly vdso_enabled = 1;
31118 -
31119 extern char vdso_start[], vdso_end[];
31120 extern unsigned short vdso_sync_cpuid;
31121
31122 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31123 * unaligned here as a result of stack start randomization.
31124 */
31125 addr = PAGE_ALIGN(addr);
31126 - addr = align_vdso_addr(addr);
31127
31128 return addr;
31129 }
31130 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31131 unsigned size)
31132 {
31133 struct mm_struct *mm = current->mm;
31134 - unsigned long addr;
31135 + unsigned long addr = 0;
31136 int ret;
31137
31138 - if (!vdso_enabled)
31139 - return 0;
31140 -
31141 down_write(&mm->mmap_sem);
31142 +
31143 +#ifdef CONFIG_PAX_RANDMMAP
31144 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31145 +#endif
31146 +
31147 addr = vdso_addr(mm->start_stack, size);
31148 + addr = align_vdso_addr(addr);
31149 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31150 if (IS_ERR_VALUE(addr)) {
31151 ret = addr;
31152 goto up_fail;
31153 }
31154
31155 - current->mm->context.vdso = (void *)addr;
31156 + mm->context.vdso = addr;
31157
31158 ret = install_special_mapping(mm, addr, size,
31159 VM_READ|VM_EXEC|
31160 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31161 pages);
31162 - if (ret) {
31163 - current->mm->context.vdso = NULL;
31164 - goto up_fail;
31165 - }
31166 + if (ret)
31167 + mm->context.vdso = 0;
31168
31169 up_fail:
31170 up_write(&mm->mmap_sem);
31171 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31172 vdsox32_size);
31173 }
31174 #endif
31175 -
31176 -static __init int vdso_setup(char *s)
31177 -{
31178 - vdso_enabled = simple_strtoul(s, NULL, 0);
31179 - return 0;
31180 -}
31181 -__setup("vdso=", vdso_setup);
31182 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31183 index cf95e19..17e9f50 100644
31184 --- a/arch/x86/xen/enlighten.c
31185 +++ b/arch/x86/xen/enlighten.c
31186 @@ -100,8 +100,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31187
31188 struct shared_info xen_dummy_shared_info;
31189
31190 -void *xen_initial_gdt;
31191 -
31192 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31193 __read_mostly int xen_have_vector_callback;
31194 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31195 @@ -511,8 +509,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31196 {
31197 unsigned long va = dtr->address;
31198 unsigned int size = dtr->size + 1;
31199 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31200 - unsigned long frames[pages];
31201 + unsigned long frames[65536 / PAGE_SIZE];
31202 int f;
31203
31204 /*
31205 @@ -560,8 +557,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31206 {
31207 unsigned long va = dtr->address;
31208 unsigned int size = dtr->size + 1;
31209 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31210 - unsigned long frames[pages];
31211 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
31212 int f;
31213
31214 /*
31215 @@ -569,7 +565,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31216 * 8-byte entries, or 16 4k pages..
31217 */
31218
31219 - BUG_ON(size > 65536);
31220 + BUG_ON(size > GDT_SIZE);
31221 BUG_ON(va & ~PAGE_MASK);
31222
31223 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
31224 @@ -954,7 +950,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31225 return 0;
31226 }
31227
31228 -static void set_xen_basic_apic_ops(void)
31229 +static void __init set_xen_basic_apic_ops(void)
31230 {
31231 apic->read = xen_apic_read;
31232 apic->write = xen_apic_write;
31233 @@ -1260,30 +1256,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31234 #endif
31235 };
31236
31237 -static void xen_reboot(int reason)
31238 +static __noreturn void xen_reboot(int reason)
31239 {
31240 struct sched_shutdown r = { .reason = reason };
31241
31242 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31243 - BUG();
31244 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31245 + BUG();
31246 }
31247
31248 -static void xen_restart(char *msg)
31249 +static __noreturn void xen_restart(char *msg)
31250 {
31251 xen_reboot(SHUTDOWN_reboot);
31252 }
31253
31254 -static void xen_emergency_restart(void)
31255 +static __noreturn void xen_emergency_restart(void)
31256 {
31257 xen_reboot(SHUTDOWN_reboot);
31258 }
31259
31260 -static void xen_machine_halt(void)
31261 +static __noreturn void xen_machine_halt(void)
31262 {
31263 xen_reboot(SHUTDOWN_poweroff);
31264 }
31265
31266 -static void xen_machine_power_off(void)
31267 +static __noreturn void xen_machine_power_off(void)
31268 {
31269 if (pm_power_off)
31270 pm_power_off();
31271 @@ -1385,7 +1381,17 @@ asmlinkage void __init xen_start_kernel(void)
31272 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31273
31274 /* Work out if we support NX */
31275 - x86_configure_nx();
31276 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31277 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31278 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31279 + unsigned l, h;
31280 +
31281 + __supported_pte_mask |= _PAGE_NX;
31282 + rdmsr(MSR_EFER, l, h);
31283 + l |= EFER_NX;
31284 + wrmsr(MSR_EFER, l, h);
31285 + }
31286 +#endif
31287
31288 xen_setup_features();
31289
31290 @@ -1416,13 +1422,6 @@ asmlinkage void __init xen_start_kernel(void)
31291
31292 machine_ops = xen_machine_ops;
31293
31294 - /*
31295 - * The only reliable way to retain the initial address of the
31296 - * percpu gdt_page is to remember it here, so we can go and
31297 - * mark it RW later, when the initial percpu area is freed.
31298 - */
31299 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31300 -
31301 xen_smp_init();
31302
31303 #ifdef CONFIG_ACPI_NUMA
31304 @@ -1616,7 +1615,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31305 return NOTIFY_OK;
31306 }
31307
31308 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31309 +static struct notifier_block xen_hvm_cpu_notifier = {
31310 .notifier_call = xen_hvm_cpu_notify,
31311 };
31312
31313 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31314 index e006c18..b9a7d6c 100644
31315 --- a/arch/x86/xen/mmu.c
31316 +++ b/arch/x86/xen/mmu.c
31317 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31318 /* L3_k[510] -> level2_kernel_pgt
31319 * L3_i[511] -> level2_fixmap_pgt */
31320 convert_pfn_mfn(level3_kernel_pgt);
31321 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31322 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31323 + convert_pfn_mfn(level3_vmemmap_pgt);
31324
31325 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31326 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31327 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31328 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31329 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31330 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31331 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31332 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31333 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31334 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31335 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31336 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31337 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31338 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31339
31340 @@ -2110,6 +2117,7 @@ static void __init xen_post_allocator_init(void)
31341 pv_mmu_ops.set_pud = xen_set_pud;
31342 #if PAGETABLE_LEVELS == 4
31343 pv_mmu_ops.set_pgd = xen_set_pgd;
31344 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31345 #endif
31346
31347 /* This will work as long as patching hasn't happened yet
31348 @@ -2188,6 +2196,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31349 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31350 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31351 .set_pgd = xen_set_pgd_hyper,
31352 + .set_pgd_batched = xen_set_pgd_hyper,
31353
31354 .alloc_pud = xen_alloc_pmd_init,
31355 .release_pud = xen_release_pmd_init,
31356 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31357 index 22c800a..8915f1e 100644
31358 --- a/arch/x86/xen/smp.c
31359 +++ b/arch/x86/xen/smp.c
31360 @@ -229,11 +229,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31361 {
31362 BUG_ON(smp_processor_id() != 0);
31363 native_smp_prepare_boot_cpu();
31364 -
31365 - /* We've switched to the "real" per-cpu gdt, so make sure the
31366 - old memory can be recycled */
31367 - make_lowmem_page_readwrite(xen_initial_gdt);
31368 -
31369 xen_filter_cpu_maps();
31370 xen_setup_vcpu_info_placement();
31371 }
31372 @@ -303,7 +298,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31373 ctxt->user_regs.ss = __KERNEL_DS;
31374 #ifdef CONFIG_X86_32
31375 ctxt->user_regs.fs = __KERNEL_PERCPU;
31376 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31377 + savesegment(gs, ctxt->user_regs.gs);
31378 #else
31379 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31380 #endif
31381 @@ -313,8 +308,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31382
31383 {
31384 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
31385 - ctxt->user_regs.ds = __USER_DS;
31386 - ctxt->user_regs.es = __USER_DS;
31387 + ctxt->user_regs.ds = __KERNEL_DS;
31388 + ctxt->user_regs.es = __KERNEL_DS;
31389
31390 xen_copy_trap_info(ctxt->trap_ctxt);
31391
31392 @@ -359,13 +354,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31393 int rc;
31394
31395 per_cpu(current_task, cpu) = idle;
31396 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31397 #ifdef CONFIG_X86_32
31398 irq_ctx_init(cpu);
31399 #else
31400 clear_tsk_thread_flag(idle, TIF_FORK);
31401 - per_cpu(kernel_stack, cpu) =
31402 - (unsigned long)task_stack_page(idle) -
31403 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31404 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31405 #endif
31406 xen_setup_runstate_info(cpu);
31407 xen_setup_timer(cpu);
31408 @@ -634,7 +628,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31409
31410 void __init xen_smp_init(void)
31411 {
31412 - smp_ops = xen_smp_ops;
31413 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31414 xen_fill_possible_map();
31415 xen_init_spinlocks();
31416 }
31417 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31418 index 33ca6e4..0ded929 100644
31419 --- a/arch/x86/xen/xen-asm_32.S
31420 +++ b/arch/x86/xen/xen-asm_32.S
31421 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31422 ESP_OFFSET=4 # bytes pushed onto stack
31423
31424 /*
31425 - * Store vcpu_info pointer for easy access. Do it this way to
31426 - * avoid having to reload %fs
31427 + * Store vcpu_info pointer for easy access.
31428 */
31429 #ifdef CONFIG_SMP
31430 - GET_THREAD_INFO(%eax)
31431 - movl %ss:TI_cpu(%eax), %eax
31432 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31433 - mov %ss:xen_vcpu(%eax), %eax
31434 + push %fs
31435 + mov $(__KERNEL_PERCPU), %eax
31436 + mov %eax, %fs
31437 + mov PER_CPU_VAR(xen_vcpu), %eax
31438 + pop %fs
31439 #else
31440 movl %ss:xen_vcpu, %eax
31441 #endif
31442 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31443 index 7faed58..ba4427c 100644
31444 --- a/arch/x86/xen/xen-head.S
31445 +++ b/arch/x86/xen/xen-head.S
31446 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31447 #ifdef CONFIG_X86_32
31448 mov %esi,xen_start_info
31449 mov $init_thread_union+THREAD_SIZE,%esp
31450 +#ifdef CONFIG_SMP
31451 + movl $cpu_gdt_table,%edi
31452 + movl $__per_cpu_load,%eax
31453 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31454 + rorl $16,%eax
31455 + movb %al,__KERNEL_PERCPU + 4(%edi)
31456 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31457 + movl $__per_cpu_end - 1,%eax
31458 + subl $__per_cpu_start,%eax
31459 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31460 +#endif
31461 #else
31462 mov %rsi,xen_start_info
31463 mov $init_thread_union+THREAD_SIZE,%rsp
31464 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31465 index a95b417..b6dbd0b 100644
31466 --- a/arch/x86/xen/xen-ops.h
31467 +++ b/arch/x86/xen/xen-ops.h
31468 @@ -10,8 +10,6 @@
31469 extern const char xen_hypervisor_callback[];
31470 extern const char xen_failsafe_callback[];
31471
31472 -extern void *xen_initial_gdt;
31473 -
31474 struct trap_info;
31475 void xen_copy_trap_info(struct trap_info *traps);
31476
31477 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31478 index 525bd3d..ef888b1 100644
31479 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31480 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31481 @@ -119,9 +119,9 @@
31482 ----------------------------------------------------------------------*/
31483
31484 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31485 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31486 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31487 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31488 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31489
31490 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31491 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31492 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31493 index 2f33760..835e50a 100644
31494 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31495 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31496 @@ -11,6 +11,7 @@
31497 #ifndef _XTENSA_CORE_H
31498 #define _XTENSA_CORE_H
31499
31500 +#include <linux/const.h>
31501
31502 /****************************************************************************
31503 Parameters Useful for Any Code, USER or PRIVILEGED
31504 @@ -112,9 +113,9 @@
31505 ----------------------------------------------------------------------*/
31506
31507 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31508 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31509 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31510 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31511 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31512
31513 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31514 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31515 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31516 index af00795..2bb8105 100644
31517 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31518 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31519 @@ -11,6 +11,7 @@
31520 #ifndef _XTENSA_CORE_CONFIGURATION_H
31521 #define _XTENSA_CORE_CONFIGURATION_H
31522
31523 +#include <linux/const.h>
31524
31525 /****************************************************************************
31526 Parameters Useful for Any Code, USER or PRIVILEGED
31527 @@ -118,9 +119,9 @@
31528 ----------------------------------------------------------------------*/
31529
31530 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31531 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31532 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31533 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31534 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31535
31536 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31537 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31538 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31539 index 58916af..eb9dbcf6 100644
31540 --- a/block/blk-iopoll.c
31541 +++ b/block/blk-iopoll.c
31542 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31543 }
31544 EXPORT_SYMBOL(blk_iopoll_complete);
31545
31546 -static void blk_iopoll_softirq(struct softirq_action *h)
31547 +static void blk_iopoll_softirq(void)
31548 {
31549 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31550 int rearm = 0, budget = blk_iopoll_budget;
31551 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31552 return NOTIFY_OK;
31553 }
31554
31555 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31556 +static struct notifier_block blk_iopoll_cpu_notifier = {
31557 .notifier_call = blk_iopoll_cpu_notify,
31558 };
31559
31560 diff --git a/block/blk-map.c b/block/blk-map.c
31561 index 623e1cd..ca1e109 100644
31562 --- a/block/blk-map.c
31563 +++ b/block/blk-map.c
31564 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31565 if (!len || !kbuf)
31566 return -EINVAL;
31567
31568 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31569 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31570 if (do_copy)
31571 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31572 else
31573 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31574 index 467c8de..f3628c5 100644
31575 --- a/block/blk-softirq.c
31576 +++ b/block/blk-softirq.c
31577 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31578 * Softirq action handler - move entries to local list and loop over them
31579 * while passing them to the queue registered handler.
31580 */
31581 -static void blk_done_softirq(struct softirq_action *h)
31582 +static void blk_done_softirq(void)
31583 {
31584 struct list_head *cpu_list, local_list;
31585
31586 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31587 return NOTIFY_OK;
31588 }
31589
31590 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31591 +static struct notifier_block blk_cpu_notifier = {
31592 .notifier_call = blk_cpu_notify,
31593 };
31594
31595 diff --git a/block/bsg.c b/block/bsg.c
31596 index 420a5a9..23834aa 100644
31597 --- a/block/bsg.c
31598 +++ b/block/bsg.c
31599 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31600 struct sg_io_v4 *hdr, struct bsg_device *bd,
31601 fmode_t has_write_perm)
31602 {
31603 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31604 + unsigned char *cmdptr;
31605 +
31606 if (hdr->request_len > BLK_MAX_CDB) {
31607 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31608 if (!rq->cmd)
31609 return -ENOMEM;
31610 - }
31611 + cmdptr = rq->cmd;
31612 + } else
31613 + cmdptr = tmpcmd;
31614
31615 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31616 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31617 hdr->request_len))
31618 return -EFAULT;
31619
31620 + if (cmdptr != rq->cmd)
31621 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31622 +
31623 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31624 if (blk_verify_command(rq->cmd, has_write_perm))
31625 return -EPERM;
31626 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31627 index 7c668c8..db3521c 100644
31628 --- a/block/compat_ioctl.c
31629 +++ b/block/compat_ioctl.c
31630 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31631 err |= __get_user(f->spec1, &uf->spec1);
31632 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31633 err |= __get_user(name, &uf->name);
31634 - f->name = compat_ptr(name);
31635 + f->name = (void __force_kernel *)compat_ptr(name);
31636 if (err) {
31637 err = -EFAULT;
31638 goto out;
31639 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31640 index ff5804e..a88acad 100644
31641 --- a/block/partitions/efi.c
31642 +++ b/block/partitions/efi.c
31643 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31644 if (!gpt)
31645 return NULL;
31646
31647 + if (!le32_to_cpu(gpt->num_partition_entries))
31648 + return NULL;
31649 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31650 + if (!pte)
31651 + return NULL;
31652 +
31653 count = le32_to_cpu(gpt->num_partition_entries) *
31654 le32_to_cpu(gpt->sizeof_partition_entry);
31655 - if (!count)
31656 - return NULL;
31657 - pte = kzalloc(count, GFP_KERNEL);
31658 - if (!pte)
31659 - return NULL;
31660 -
31661 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31662 (u8 *) pte,
31663 count) < count) {
31664 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
31665 index 9a87daa..fb17486 100644
31666 --- a/block/scsi_ioctl.c
31667 +++ b/block/scsi_ioctl.c
31668 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
31669 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
31670 struct sg_io_hdr *hdr, fmode_t mode)
31671 {
31672 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
31673 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31674 + unsigned char *cmdptr;
31675 +
31676 + if (rq->cmd != rq->__cmd)
31677 + cmdptr = rq->cmd;
31678 + else
31679 + cmdptr = tmpcmd;
31680 +
31681 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
31682 return -EFAULT;
31683 +
31684 + if (cmdptr != rq->cmd)
31685 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
31686 +
31687 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
31688 return -EPERM;
31689
31690 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31691 int err;
31692 unsigned int in_len, out_len, bytes, opcode, cmdlen;
31693 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
31694 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31695 + unsigned char *cmdptr;
31696
31697 if (!sic)
31698 return -EINVAL;
31699 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31700 */
31701 err = -EFAULT;
31702 rq->cmd_len = cmdlen;
31703 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
31704 +
31705 + if (rq->cmd != rq->__cmd)
31706 + cmdptr = rq->cmd;
31707 + else
31708 + cmdptr = tmpcmd;
31709 +
31710 + if (copy_from_user(cmdptr, sic->data, cmdlen))
31711 goto error;
31712
31713 + if (rq->cmd != cmdptr)
31714 + memcpy(rq->cmd, cmdptr, cmdlen);
31715 +
31716 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
31717 goto error;
31718
31719 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
31720 index 7bdd61b..afec999 100644
31721 --- a/crypto/cryptd.c
31722 +++ b/crypto/cryptd.c
31723 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
31724
31725 struct cryptd_blkcipher_request_ctx {
31726 crypto_completion_t complete;
31727 -};
31728 +} __no_const;
31729
31730 struct cryptd_hash_ctx {
31731 struct crypto_shash *child;
31732 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
31733
31734 struct cryptd_aead_request_ctx {
31735 crypto_completion_t complete;
31736 -};
31737 +} __no_const;
31738
31739 static void cryptd_queue_worker(struct work_struct *work);
31740
31741 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
31742 index f220d64..d359ad6 100644
31743 --- a/drivers/acpi/apei/apei-internal.h
31744 +++ b/drivers/acpi/apei/apei-internal.h
31745 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
31746 struct apei_exec_ins_type {
31747 u32 flags;
31748 apei_exec_ins_func_t run;
31749 -};
31750 +} __do_const;
31751
31752 struct apei_exec_context {
31753 u32 ip;
31754 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
31755 index fefc2ca..12a535d 100644
31756 --- a/drivers/acpi/apei/cper.c
31757 +++ b/drivers/acpi/apei/cper.c
31758 @@ -39,12 +39,12 @@
31759 */
31760 u64 cper_next_record_id(void)
31761 {
31762 - static atomic64_t seq;
31763 + static atomic64_unchecked_t seq;
31764
31765 - if (!atomic64_read(&seq))
31766 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
31767 + if (!atomic64_read_unchecked(&seq))
31768 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
31769
31770 - return atomic64_inc_return(&seq);
31771 + return atomic64_inc_return_unchecked(&seq);
31772 }
31773 EXPORT_SYMBOL_GPL(cper_next_record_id);
31774
31775 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
31776 index be60399..778b33e8 100644
31777 --- a/drivers/acpi/bgrt.c
31778 +++ b/drivers/acpi/bgrt.c
31779 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
31780 return -ENODEV;
31781
31782 sysfs_bin_attr_init(&image_attr);
31783 - image_attr.private = bgrt_image;
31784 - image_attr.size = bgrt_image_size;
31785 + pax_open_kernel();
31786 + *(void **)&image_attr.private = bgrt_image;
31787 + *(size_t *)&image_attr.size = bgrt_image_size;
31788 + pax_close_kernel();
31789
31790 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
31791 if (!bgrt_kobj)
31792 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
31793 index cb96296..b81293b 100644
31794 --- a/drivers/acpi/blacklist.c
31795 +++ b/drivers/acpi/blacklist.c
31796 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
31797 u32 is_critical_error;
31798 };
31799
31800 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
31801 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
31802
31803 /*
31804 * POLICY: If *anything* doesn't work, put it on the blacklist.
31805 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
31806 return 0;
31807 }
31808
31809 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
31810 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
31811 {
31812 .callback = dmi_disable_osi_vista,
31813 .ident = "Fujitsu Siemens",
31814 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
31815 index 7586544..636a2f0 100644
31816 --- a/drivers/acpi/ec_sys.c
31817 +++ b/drivers/acpi/ec_sys.c
31818 @@ -12,6 +12,7 @@
31819 #include <linux/acpi.h>
31820 #include <linux/debugfs.h>
31821 #include <linux/module.h>
31822 +#include <linux/uaccess.h>
31823 #include "internal.h"
31824
31825 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
31826 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31827 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
31828 */
31829 unsigned int size = EC_SPACE_SIZE;
31830 - u8 *data = (u8 *) buf;
31831 + u8 data;
31832 loff_t init_off = *off;
31833 int err = 0;
31834
31835 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31836 size = count;
31837
31838 while (size) {
31839 - err = ec_read(*off, &data[*off - init_off]);
31840 + err = ec_read(*off, &data);
31841 if (err)
31842 return err;
31843 + if (put_user(data, &buf[*off - init_off]))
31844 + return -EFAULT;
31845 *off += 1;
31846 size--;
31847 }
31848 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31849
31850 unsigned int size = count;
31851 loff_t init_off = *off;
31852 - u8 *data = (u8 *) buf;
31853 int err = 0;
31854
31855 if (*off >= EC_SPACE_SIZE)
31856 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31857 }
31858
31859 while (size) {
31860 - u8 byte_write = data[*off - init_off];
31861 + u8 byte_write;
31862 + if (get_user(byte_write, &buf[*off - init_off]))
31863 + return -EFAULT;
31864 err = ec_write(*off, byte_write);
31865 if (err)
31866 return err;
31867 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
31868 index ee255c6..747c68b 100644
31869 --- a/drivers/acpi/processor_idle.c
31870 +++ b/drivers/acpi/processor_idle.c
31871 @@ -986,7 +986,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
31872 {
31873 int i, count = CPUIDLE_DRIVER_STATE_START;
31874 struct acpi_processor_cx *cx;
31875 - struct cpuidle_state *state;
31876 + cpuidle_state_no_const *state;
31877 struct cpuidle_driver *drv = &acpi_idle_driver;
31878
31879 if (!pr->flags.power_setup_done)
31880 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
31881 index 41c0504..f8c0836 100644
31882 --- a/drivers/acpi/sysfs.c
31883 +++ b/drivers/acpi/sysfs.c
31884 @@ -420,11 +420,11 @@ static u32 num_counters;
31885 static struct attribute **all_attrs;
31886 static u32 acpi_gpe_count;
31887
31888 -static struct attribute_group interrupt_stats_attr_group = {
31889 +static attribute_group_no_const interrupt_stats_attr_group = {
31890 .name = "interrupts",
31891 };
31892
31893 -static struct kobj_attribute *counter_attrs;
31894 +static kobj_attribute_no_const *counter_attrs;
31895
31896 static void delete_gpe_attr_array(void)
31897 {
31898 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
31899 index 34c8216..f56c828 100644
31900 --- a/drivers/ata/libahci.c
31901 +++ b/drivers/ata/libahci.c
31902 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
31903 }
31904 EXPORT_SYMBOL_GPL(ahci_kick_engine);
31905
31906 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
31907 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
31908 struct ata_taskfile *tf, int is_cmd, u16 flags,
31909 unsigned long timeout_msec)
31910 {
31911 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
31912 index 63c743b..0422dc6 100644
31913 --- a/drivers/ata/libata-core.c
31914 +++ b/drivers/ata/libata-core.c
31915 @@ -4786,7 +4786,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
31916 struct ata_port *ap;
31917 unsigned int tag;
31918
31919 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31920 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31921 ap = qc->ap;
31922
31923 qc->flags = 0;
31924 @@ -4802,7 +4802,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
31925 struct ata_port *ap;
31926 struct ata_link *link;
31927
31928 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31929 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
31930 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
31931 ap = qc->ap;
31932 link = qc->dev->link;
31933 @@ -5920,6 +5920,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
31934 return;
31935
31936 spin_lock(&lock);
31937 + pax_open_kernel();
31938
31939 for (cur = ops->inherits; cur; cur = cur->inherits) {
31940 void **inherit = (void **)cur;
31941 @@ -5933,8 +5934,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
31942 if (IS_ERR(*pp))
31943 *pp = NULL;
31944
31945 - ops->inherits = NULL;
31946 + *(struct ata_port_operations **)&ops->inherits = NULL;
31947
31948 + pax_close_kernel();
31949 spin_unlock(&lock);
31950 }
31951
31952 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
31953 index 405022d..fb70e53 100644
31954 --- a/drivers/ata/pata_arasan_cf.c
31955 +++ b/drivers/ata/pata_arasan_cf.c
31956 @@ -864,7 +864,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
31957 /* Handle platform specific quirks */
31958 if (pdata->quirk) {
31959 if (pdata->quirk & CF_BROKEN_PIO) {
31960 - ap->ops->set_piomode = NULL;
31961 + pax_open_kernel();
31962 + *(void **)&ap->ops->set_piomode = NULL;
31963 + pax_close_kernel();
31964 ap->pio_mask = 0;
31965 }
31966 if (pdata->quirk & CF_BROKEN_MWDMA)
31967 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
31968 index f9b983a..887b9d8 100644
31969 --- a/drivers/atm/adummy.c
31970 +++ b/drivers/atm/adummy.c
31971 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
31972 vcc->pop(vcc, skb);
31973 else
31974 dev_kfree_skb_any(skb);
31975 - atomic_inc(&vcc->stats->tx);
31976 + atomic_inc_unchecked(&vcc->stats->tx);
31977
31978 return 0;
31979 }
31980 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
31981 index 77a7480d..05cde58 100644
31982 --- a/drivers/atm/ambassador.c
31983 +++ b/drivers/atm/ambassador.c
31984 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
31985 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
31986
31987 // VC layer stats
31988 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
31989 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
31990
31991 // free the descriptor
31992 kfree (tx_descr);
31993 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
31994 dump_skb ("<<<", vc, skb);
31995
31996 // VC layer stats
31997 - atomic_inc(&atm_vcc->stats->rx);
31998 + atomic_inc_unchecked(&atm_vcc->stats->rx);
31999 __net_timestamp(skb);
32000 // end of our responsibility
32001 atm_vcc->push (atm_vcc, skb);
32002 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32003 } else {
32004 PRINTK (KERN_INFO, "dropped over-size frame");
32005 // should we count this?
32006 - atomic_inc(&atm_vcc->stats->rx_drop);
32007 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32008 }
32009
32010 } else {
32011 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
32012 }
32013
32014 if (check_area (skb->data, skb->len)) {
32015 - atomic_inc(&atm_vcc->stats->tx_err);
32016 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
32017 return -ENOMEM; // ?
32018 }
32019
32020 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
32021 index 0e3f8f9..765a7a5 100644
32022 --- a/drivers/atm/atmtcp.c
32023 +++ b/drivers/atm/atmtcp.c
32024 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32025 if (vcc->pop) vcc->pop(vcc,skb);
32026 else dev_kfree_skb(skb);
32027 if (dev_data) return 0;
32028 - atomic_inc(&vcc->stats->tx_err);
32029 + atomic_inc_unchecked(&vcc->stats->tx_err);
32030 return -ENOLINK;
32031 }
32032 size = skb->len+sizeof(struct atmtcp_hdr);
32033 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32034 if (!new_skb) {
32035 if (vcc->pop) vcc->pop(vcc,skb);
32036 else dev_kfree_skb(skb);
32037 - atomic_inc(&vcc->stats->tx_err);
32038 + atomic_inc_unchecked(&vcc->stats->tx_err);
32039 return -ENOBUFS;
32040 }
32041 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
32042 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32043 if (vcc->pop) vcc->pop(vcc,skb);
32044 else dev_kfree_skb(skb);
32045 out_vcc->push(out_vcc,new_skb);
32046 - atomic_inc(&vcc->stats->tx);
32047 - atomic_inc(&out_vcc->stats->rx);
32048 + atomic_inc_unchecked(&vcc->stats->tx);
32049 + atomic_inc_unchecked(&out_vcc->stats->rx);
32050 return 0;
32051 }
32052
32053 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32054 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32055 read_unlock(&vcc_sklist_lock);
32056 if (!out_vcc) {
32057 - atomic_inc(&vcc->stats->tx_err);
32058 + atomic_inc_unchecked(&vcc->stats->tx_err);
32059 goto done;
32060 }
32061 skb_pull(skb,sizeof(struct atmtcp_hdr));
32062 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32063 __net_timestamp(new_skb);
32064 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32065 out_vcc->push(out_vcc,new_skb);
32066 - atomic_inc(&vcc->stats->tx);
32067 - atomic_inc(&out_vcc->stats->rx);
32068 + atomic_inc_unchecked(&vcc->stats->tx);
32069 + atomic_inc_unchecked(&out_vcc->stats->rx);
32070 done:
32071 if (vcc->pop) vcc->pop(vcc,skb);
32072 else dev_kfree_skb(skb);
32073 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32074 index b1955ba..b179940 100644
32075 --- a/drivers/atm/eni.c
32076 +++ b/drivers/atm/eni.c
32077 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32078 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32079 vcc->dev->number);
32080 length = 0;
32081 - atomic_inc(&vcc->stats->rx_err);
32082 + atomic_inc_unchecked(&vcc->stats->rx_err);
32083 }
32084 else {
32085 length = ATM_CELL_SIZE-1; /* no HEC */
32086 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32087 size);
32088 }
32089 eff = length = 0;
32090 - atomic_inc(&vcc->stats->rx_err);
32091 + atomic_inc_unchecked(&vcc->stats->rx_err);
32092 }
32093 else {
32094 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32095 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32096 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32097 vcc->dev->number,vcc->vci,length,size << 2,descr);
32098 length = eff = 0;
32099 - atomic_inc(&vcc->stats->rx_err);
32100 + atomic_inc_unchecked(&vcc->stats->rx_err);
32101 }
32102 }
32103 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32104 @@ -767,7 +767,7 @@ rx_dequeued++;
32105 vcc->push(vcc,skb);
32106 pushed++;
32107 }
32108 - atomic_inc(&vcc->stats->rx);
32109 + atomic_inc_unchecked(&vcc->stats->rx);
32110 }
32111 wake_up(&eni_dev->rx_wait);
32112 }
32113 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32114 PCI_DMA_TODEVICE);
32115 if (vcc->pop) vcc->pop(vcc,skb);
32116 else dev_kfree_skb_irq(skb);
32117 - atomic_inc(&vcc->stats->tx);
32118 + atomic_inc_unchecked(&vcc->stats->tx);
32119 wake_up(&eni_dev->tx_wait);
32120 dma_complete++;
32121 }
32122 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32123 index b41c948..a002b17 100644
32124 --- a/drivers/atm/firestream.c
32125 +++ b/drivers/atm/firestream.c
32126 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32127 }
32128 }
32129
32130 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32131 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32132
32133 fs_dprintk (FS_DEBUG_TXMEM, "i");
32134 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32135 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32136 #endif
32137 skb_put (skb, qe->p1 & 0xffff);
32138 ATM_SKB(skb)->vcc = atm_vcc;
32139 - atomic_inc(&atm_vcc->stats->rx);
32140 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32141 __net_timestamp(skb);
32142 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32143 atm_vcc->push (atm_vcc, skb);
32144 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32145 kfree (pe);
32146 }
32147 if (atm_vcc)
32148 - atomic_inc(&atm_vcc->stats->rx_drop);
32149 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32150 break;
32151 case 0x1f: /* Reassembly abort: no buffers. */
32152 /* Silently increment error counter. */
32153 if (atm_vcc)
32154 - atomic_inc(&atm_vcc->stats->rx_drop);
32155 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32156 break;
32157 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32158 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32159 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32160 index 204814e..cede831 100644
32161 --- a/drivers/atm/fore200e.c
32162 +++ b/drivers/atm/fore200e.c
32163 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32164 #endif
32165 /* check error condition */
32166 if (*entry->status & STATUS_ERROR)
32167 - atomic_inc(&vcc->stats->tx_err);
32168 + atomic_inc_unchecked(&vcc->stats->tx_err);
32169 else
32170 - atomic_inc(&vcc->stats->tx);
32171 + atomic_inc_unchecked(&vcc->stats->tx);
32172 }
32173 }
32174
32175 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32176 if (skb == NULL) {
32177 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32178
32179 - atomic_inc(&vcc->stats->rx_drop);
32180 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32181 return -ENOMEM;
32182 }
32183
32184 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32185
32186 dev_kfree_skb_any(skb);
32187
32188 - atomic_inc(&vcc->stats->rx_drop);
32189 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32190 return -ENOMEM;
32191 }
32192
32193 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32194
32195 vcc->push(vcc, skb);
32196 - atomic_inc(&vcc->stats->rx);
32197 + atomic_inc_unchecked(&vcc->stats->rx);
32198
32199 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32200
32201 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32202 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32203 fore200e->atm_dev->number,
32204 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32205 - atomic_inc(&vcc->stats->rx_err);
32206 + atomic_inc_unchecked(&vcc->stats->rx_err);
32207 }
32208 }
32209
32210 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32211 goto retry_here;
32212 }
32213
32214 - atomic_inc(&vcc->stats->tx_err);
32215 + atomic_inc_unchecked(&vcc->stats->tx_err);
32216
32217 fore200e->tx_sat++;
32218 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32219 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32220 index d689126..e78e412 100644
32221 --- a/drivers/atm/he.c
32222 +++ b/drivers/atm/he.c
32223 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32224
32225 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32226 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32227 - atomic_inc(&vcc->stats->rx_drop);
32228 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32229 goto return_host_buffers;
32230 }
32231
32232 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32233 RBRQ_LEN_ERR(he_dev->rbrq_head)
32234 ? "LEN_ERR" : "",
32235 vcc->vpi, vcc->vci);
32236 - atomic_inc(&vcc->stats->rx_err);
32237 + atomic_inc_unchecked(&vcc->stats->rx_err);
32238 goto return_host_buffers;
32239 }
32240
32241 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32242 vcc->push(vcc, skb);
32243 spin_lock(&he_dev->global_lock);
32244
32245 - atomic_inc(&vcc->stats->rx);
32246 + atomic_inc_unchecked(&vcc->stats->rx);
32247
32248 return_host_buffers:
32249 ++pdus_assembled;
32250 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32251 tpd->vcc->pop(tpd->vcc, tpd->skb);
32252 else
32253 dev_kfree_skb_any(tpd->skb);
32254 - atomic_inc(&tpd->vcc->stats->tx_err);
32255 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32256 }
32257 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32258 return;
32259 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32260 vcc->pop(vcc, skb);
32261 else
32262 dev_kfree_skb_any(skb);
32263 - atomic_inc(&vcc->stats->tx_err);
32264 + atomic_inc_unchecked(&vcc->stats->tx_err);
32265 return -EINVAL;
32266 }
32267
32268 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32269 vcc->pop(vcc, skb);
32270 else
32271 dev_kfree_skb_any(skb);
32272 - atomic_inc(&vcc->stats->tx_err);
32273 + atomic_inc_unchecked(&vcc->stats->tx_err);
32274 return -EINVAL;
32275 }
32276 #endif
32277 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32278 vcc->pop(vcc, skb);
32279 else
32280 dev_kfree_skb_any(skb);
32281 - atomic_inc(&vcc->stats->tx_err);
32282 + atomic_inc_unchecked(&vcc->stats->tx_err);
32283 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32284 return -ENOMEM;
32285 }
32286 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32287 vcc->pop(vcc, skb);
32288 else
32289 dev_kfree_skb_any(skb);
32290 - atomic_inc(&vcc->stats->tx_err);
32291 + atomic_inc_unchecked(&vcc->stats->tx_err);
32292 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32293 return -ENOMEM;
32294 }
32295 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32296 __enqueue_tpd(he_dev, tpd, cid);
32297 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32298
32299 - atomic_inc(&vcc->stats->tx);
32300 + atomic_inc_unchecked(&vcc->stats->tx);
32301
32302 return 0;
32303 }
32304 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32305 index 1dc0519..1aadaf7 100644
32306 --- a/drivers/atm/horizon.c
32307 +++ b/drivers/atm/horizon.c
32308 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32309 {
32310 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32311 // VC layer stats
32312 - atomic_inc(&vcc->stats->rx);
32313 + atomic_inc_unchecked(&vcc->stats->rx);
32314 __net_timestamp(skb);
32315 // end of our responsibility
32316 vcc->push (vcc, skb);
32317 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32318 dev->tx_iovec = NULL;
32319
32320 // VC layer stats
32321 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32322 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32323
32324 // free the skb
32325 hrz_kfree_skb (skb);
32326 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32327 index 272f009..a18ba55 100644
32328 --- a/drivers/atm/idt77252.c
32329 +++ b/drivers/atm/idt77252.c
32330 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32331 else
32332 dev_kfree_skb(skb);
32333
32334 - atomic_inc(&vcc->stats->tx);
32335 + atomic_inc_unchecked(&vcc->stats->tx);
32336 }
32337
32338 atomic_dec(&scq->used);
32339 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32340 if ((sb = dev_alloc_skb(64)) == NULL) {
32341 printk("%s: Can't allocate buffers for aal0.\n",
32342 card->name);
32343 - atomic_add(i, &vcc->stats->rx_drop);
32344 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32345 break;
32346 }
32347 if (!atm_charge(vcc, sb->truesize)) {
32348 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32349 card->name);
32350 - atomic_add(i - 1, &vcc->stats->rx_drop);
32351 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32352 dev_kfree_skb(sb);
32353 break;
32354 }
32355 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32356 ATM_SKB(sb)->vcc = vcc;
32357 __net_timestamp(sb);
32358 vcc->push(vcc, sb);
32359 - atomic_inc(&vcc->stats->rx);
32360 + atomic_inc_unchecked(&vcc->stats->rx);
32361
32362 cell += ATM_CELL_PAYLOAD;
32363 }
32364 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32365 "(CDC: %08x)\n",
32366 card->name, len, rpp->len, readl(SAR_REG_CDC));
32367 recycle_rx_pool_skb(card, rpp);
32368 - atomic_inc(&vcc->stats->rx_err);
32369 + atomic_inc_unchecked(&vcc->stats->rx_err);
32370 return;
32371 }
32372 if (stat & SAR_RSQE_CRC) {
32373 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32374 recycle_rx_pool_skb(card, rpp);
32375 - atomic_inc(&vcc->stats->rx_err);
32376 + atomic_inc_unchecked(&vcc->stats->rx_err);
32377 return;
32378 }
32379 if (skb_queue_len(&rpp->queue) > 1) {
32380 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32381 RXPRINTK("%s: Can't alloc RX skb.\n",
32382 card->name);
32383 recycle_rx_pool_skb(card, rpp);
32384 - atomic_inc(&vcc->stats->rx_err);
32385 + atomic_inc_unchecked(&vcc->stats->rx_err);
32386 return;
32387 }
32388 if (!atm_charge(vcc, skb->truesize)) {
32389 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32390 __net_timestamp(skb);
32391
32392 vcc->push(vcc, skb);
32393 - atomic_inc(&vcc->stats->rx);
32394 + atomic_inc_unchecked(&vcc->stats->rx);
32395
32396 return;
32397 }
32398 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32399 __net_timestamp(skb);
32400
32401 vcc->push(vcc, skb);
32402 - atomic_inc(&vcc->stats->rx);
32403 + atomic_inc_unchecked(&vcc->stats->rx);
32404
32405 if (skb->truesize > SAR_FB_SIZE_3)
32406 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32407 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32408 if (vcc->qos.aal != ATM_AAL0) {
32409 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32410 card->name, vpi, vci);
32411 - atomic_inc(&vcc->stats->rx_drop);
32412 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32413 goto drop;
32414 }
32415
32416 if ((sb = dev_alloc_skb(64)) == NULL) {
32417 printk("%s: Can't allocate buffers for AAL0.\n",
32418 card->name);
32419 - atomic_inc(&vcc->stats->rx_err);
32420 + atomic_inc_unchecked(&vcc->stats->rx_err);
32421 goto drop;
32422 }
32423
32424 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32425 ATM_SKB(sb)->vcc = vcc;
32426 __net_timestamp(sb);
32427 vcc->push(vcc, sb);
32428 - atomic_inc(&vcc->stats->rx);
32429 + atomic_inc_unchecked(&vcc->stats->rx);
32430
32431 drop:
32432 skb_pull(queue, 64);
32433 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32434
32435 if (vc == NULL) {
32436 printk("%s: NULL connection in send().\n", card->name);
32437 - atomic_inc(&vcc->stats->tx_err);
32438 + atomic_inc_unchecked(&vcc->stats->tx_err);
32439 dev_kfree_skb(skb);
32440 return -EINVAL;
32441 }
32442 if (!test_bit(VCF_TX, &vc->flags)) {
32443 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32444 - atomic_inc(&vcc->stats->tx_err);
32445 + atomic_inc_unchecked(&vcc->stats->tx_err);
32446 dev_kfree_skb(skb);
32447 return -EINVAL;
32448 }
32449 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32450 break;
32451 default:
32452 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32453 - atomic_inc(&vcc->stats->tx_err);
32454 + atomic_inc_unchecked(&vcc->stats->tx_err);
32455 dev_kfree_skb(skb);
32456 return -EINVAL;
32457 }
32458
32459 if (skb_shinfo(skb)->nr_frags != 0) {
32460 printk("%s: No scatter-gather yet.\n", card->name);
32461 - atomic_inc(&vcc->stats->tx_err);
32462 + atomic_inc_unchecked(&vcc->stats->tx_err);
32463 dev_kfree_skb(skb);
32464 return -EINVAL;
32465 }
32466 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32467
32468 err = queue_skb(card, vc, skb, oam);
32469 if (err) {
32470 - atomic_inc(&vcc->stats->tx_err);
32471 + atomic_inc_unchecked(&vcc->stats->tx_err);
32472 dev_kfree_skb(skb);
32473 return err;
32474 }
32475 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32476 skb = dev_alloc_skb(64);
32477 if (!skb) {
32478 printk("%s: Out of memory in send_oam().\n", card->name);
32479 - atomic_inc(&vcc->stats->tx_err);
32480 + atomic_inc_unchecked(&vcc->stats->tx_err);
32481 return -ENOMEM;
32482 }
32483 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32484 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32485 index 4217f29..88f547a 100644
32486 --- a/drivers/atm/iphase.c
32487 +++ b/drivers/atm/iphase.c
32488 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32489 status = (u_short) (buf_desc_ptr->desc_mode);
32490 if (status & (RX_CER | RX_PTE | RX_OFL))
32491 {
32492 - atomic_inc(&vcc->stats->rx_err);
32493 + atomic_inc_unchecked(&vcc->stats->rx_err);
32494 IF_ERR(printk("IA: bad packet, dropping it");)
32495 if (status & RX_CER) {
32496 IF_ERR(printk(" cause: packet CRC error\n");)
32497 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32498 len = dma_addr - buf_addr;
32499 if (len > iadev->rx_buf_sz) {
32500 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32501 - atomic_inc(&vcc->stats->rx_err);
32502 + atomic_inc_unchecked(&vcc->stats->rx_err);
32503 goto out_free_desc;
32504 }
32505
32506 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32507 ia_vcc = INPH_IA_VCC(vcc);
32508 if (ia_vcc == NULL)
32509 {
32510 - atomic_inc(&vcc->stats->rx_err);
32511 + atomic_inc_unchecked(&vcc->stats->rx_err);
32512 atm_return(vcc, skb->truesize);
32513 dev_kfree_skb_any(skb);
32514 goto INCR_DLE;
32515 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32516 if ((length > iadev->rx_buf_sz) || (length >
32517 (skb->len - sizeof(struct cpcs_trailer))))
32518 {
32519 - atomic_inc(&vcc->stats->rx_err);
32520 + atomic_inc_unchecked(&vcc->stats->rx_err);
32521 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32522 length, skb->len);)
32523 atm_return(vcc, skb->truesize);
32524 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32525
32526 IF_RX(printk("rx_dle_intr: skb push");)
32527 vcc->push(vcc,skb);
32528 - atomic_inc(&vcc->stats->rx);
32529 + atomic_inc_unchecked(&vcc->stats->rx);
32530 iadev->rx_pkt_cnt++;
32531 }
32532 INCR_DLE:
32533 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32534 {
32535 struct k_sonet_stats *stats;
32536 stats = &PRIV(_ia_dev[board])->sonet_stats;
32537 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32538 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32539 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32540 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32541 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32542 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32543 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32544 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32545 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32546 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32547 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32548 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32549 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32550 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32551 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32552 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32553 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32554 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32555 }
32556 ia_cmds.status = 0;
32557 break;
32558 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32559 if ((desc == 0) || (desc > iadev->num_tx_desc))
32560 {
32561 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32562 - atomic_inc(&vcc->stats->tx);
32563 + atomic_inc_unchecked(&vcc->stats->tx);
32564 if (vcc->pop)
32565 vcc->pop(vcc, skb);
32566 else
32567 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32568 ATM_DESC(skb) = vcc->vci;
32569 skb_queue_tail(&iadev->tx_dma_q, skb);
32570
32571 - atomic_inc(&vcc->stats->tx);
32572 + atomic_inc_unchecked(&vcc->stats->tx);
32573 iadev->tx_pkt_cnt++;
32574 /* Increment transaction counter */
32575 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32576
32577 #if 0
32578 /* add flow control logic */
32579 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32580 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32581 if (iavcc->vc_desc_cnt > 10) {
32582 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32583 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32584 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32585 index fa7d701..1e404c7 100644
32586 --- a/drivers/atm/lanai.c
32587 +++ b/drivers/atm/lanai.c
32588 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32589 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32590 lanai_endtx(lanai, lvcc);
32591 lanai_free_skb(lvcc->tx.atmvcc, skb);
32592 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32593 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32594 }
32595
32596 /* Try to fill the buffer - don't call unless there is backlog */
32597 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
32598 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
32599 __net_timestamp(skb);
32600 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
32601 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
32602 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
32603 out:
32604 lvcc->rx.buf.ptr = end;
32605 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
32606 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32607 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
32608 "vcc %d\n", lanai->number, (unsigned int) s, vci);
32609 lanai->stats.service_rxnotaal5++;
32610 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32611 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32612 return 0;
32613 }
32614 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
32615 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32616 int bytes;
32617 read_unlock(&vcc_sklist_lock);
32618 DPRINTK("got trashed rx pdu on vci %d\n", vci);
32619 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32620 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32621 lvcc->stats.x.aal5.service_trash++;
32622 bytes = (SERVICE_GET_END(s) * 16) -
32623 (((unsigned long) lvcc->rx.buf.ptr) -
32624 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32625 }
32626 if (s & SERVICE_STREAM) {
32627 read_unlock(&vcc_sklist_lock);
32628 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32629 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32630 lvcc->stats.x.aal5.service_stream++;
32631 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
32632 "PDU on VCI %d!\n", lanai->number, vci);
32633 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32634 return 0;
32635 }
32636 DPRINTK("got rx crc error on vci %d\n", vci);
32637 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32638 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32639 lvcc->stats.x.aal5.service_rxcrc++;
32640 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
32641 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
32642 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
32643 index 6587dc2..149833d 100644
32644 --- a/drivers/atm/nicstar.c
32645 +++ b/drivers/atm/nicstar.c
32646 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32647 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
32648 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
32649 card->index);
32650 - atomic_inc(&vcc->stats->tx_err);
32651 + atomic_inc_unchecked(&vcc->stats->tx_err);
32652 dev_kfree_skb_any(skb);
32653 return -EINVAL;
32654 }
32655 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32656 if (!vc->tx) {
32657 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
32658 card->index);
32659 - atomic_inc(&vcc->stats->tx_err);
32660 + atomic_inc_unchecked(&vcc->stats->tx_err);
32661 dev_kfree_skb_any(skb);
32662 return -EINVAL;
32663 }
32664 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32665 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
32666 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
32667 card->index);
32668 - atomic_inc(&vcc->stats->tx_err);
32669 + atomic_inc_unchecked(&vcc->stats->tx_err);
32670 dev_kfree_skb_any(skb);
32671 return -EINVAL;
32672 }
32673
32674 if (skb_shinfo(skb)->nr_frags != 0) {
32675 printk("nicstar%d: No scatter-gather yet.\n", card->index);
32676 - atomic_inc(&vcc->stats->tx_err);
32677 + atomic_inc_unchecked(&vcc->stats->tx_err);
32678 dev_kfree_skb_any(skb);
32679 return -EINVAL;
32680 }
32681 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32682 }
32683
32684 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
32685 - atomic_inc(&vcc->stats->tx_err);
32686 + atomic_inc_unchecked(&vcc->stats->tx_err);
32687 dev_kfree_skb_any(skb);
32688 return -EIO;
32689 }
32690 - atomic_inc(&vcc->stats->tx);
32691 + atomic_inc_unchecked(&vcc->stats->tx);
32692
32693 return 0;
32694 }
32695 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32696 printk
32697 ("nicstar%d: Can't allocate buffers for aal0.\n",
32698 card->index);
32699 - atomic_add(i, &vcc->stats->rx_drop);
32700 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32701 break;
32702 }
32703 if (!atm_charge(vcc, sb->truesize)) {
32704 RXPRINTK
32705 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
32706 card->index);
32707 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32708 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32709 dev_kfree_skb_any(sb);
32710 break;
32711 }
32712 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32713 ATM_SKB(sb)->vcc = vcc;
32714 __net_timestamp(sb);
32715 vcc->push(vcc, sb);
32716 - atomic_inc(&vcc->stats->rx);
32717 + atomic_inc_unchecked(&vcc->stats->rx);
32718 cell += ATM_CELL_PAYLOAD;
32719 }
32720
32721 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32722 if (iovb == NULL) {
32723 printk("nicstar%d: Out of iovec buffers.\n",
32724 card->index);
32725 - atomic_inc(&vcc->stats->rx_drop);
32726 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32727 recycle_rx_buf(card, skb);
32728 return;
32729 }
32730 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32731 small or large buffer itself. */
32732 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
32733 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
32734 - atomic_inc(&vcc->stats->rx_err);
32735 + atomic_inc_unchecked(&vcc->stats->rx_err);
32736 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32737 NS_MAX_IOVECS);
32738 NS_PRV_IOVCNT(iovb) = 0;
32739 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32740 ("nicstar%d: Expected a small buffer, and this is not one.\n",
32741 card->index);
32742 which_list(card, skb);
32743 - atomic_inc(&vcc->stats->rx_err);
32744 + atomic_inc_unchecked(&vcc->stats->rx_err);
32745 recycle_rx_buf(card, skb);
32746 vc->rx_iov = NULL;
32747 recycle_iov_buf(card, iovb);
32748 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32749 ("nicstar%d: Expected a large buffer, and this is not one.\n",
32750 card->index);
32751 which_list(card, skb);
32752 - atomic_inc(&vcc->stats->rx_err);
32753 + atomic_inc_unchecked(&vcc->stats->rx_err);
32754 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32755 NS_PRV_IOVCNT(iovb));
32756 vc->rx_iov = NULL;
32757 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32758 printk(" - PDU size mismatch.\n");
32759 else
32760 printk(".\n");
32761 - atomic_inc(&vcc->stats->rx_err);
32762 + atomic_inc_unchecked(&vcc->stats->rx_err);
32763 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32764 NS_PRV_IOVCNT(iovb));
32765 vc->rx_iov = NULL;
32766 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32767 /* skb points to a small buffer */
32768 if (!atm_charge(vcc, skb->truesize)) {
32769 push_rxbufs(card, skb);
32770 - atomic_inc(&vcc->stats->rx_drop);
32771 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32772 } else {
32773 skb_put(skb, len);
32774 dequeue_sm_buf(card, skb);
32775 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32776 ATM_SKB(skb)->vcc = vcc;
32777 __net_timestamp(skb);
32778 vcc->push(vcc, skb);
32779 - atomic_inc(&vcc->stats->rx);
32780 + atomic_inc_unchecked(&vcc->stats->rx);
32781 }
32782 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
32783 struct sk_buff *sb;
32784 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32785 if (len <= NS_SMBUFSIZE) {
32786 if (!atm_charge(vcc, sb->truesize)) {
32787 push_rxbufs(card, sb);
32788 - atomic_inc(&vcc->stats->rx_drop);
32789 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32790 } else {
32791 skb_put(sb, len);
32792 dequeue_sm_buf(card, sb);
32793 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32794 ATM_SKB(sb)->vcc = vcc;
32795 __net_timestamp(sb);
32796 vcc->push(vcc, sb);
32797 - atomic_inc(&vcc->stats->rx);
32798 + atomic_inc_unchecked(&vcc->stats->rx);
32799 }
32800
32801 push_rxbufs(card, skb);
32802 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32803
32804 if (!atm_charge(vcc, skb->truesize)) {
32805 push_rxbufs(card, skb);
32806 - atomic_inc(&vcc->stats->rx_drop);
32807 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32808 } else {
32809 dequeue_lg_buf(card, skb);
32810 #ifdef NS_USE_DESTRUCTORS
32811 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32812 ATM_SKB(skb)->vcc = vcc;
32813 __net_timestamp(skb);
32814 vcc->push(vcc, skb);
32815 - atomic_inc(&vcc->stats->rx);
32816 + atomic_inc_unchecked(&vcc->stats->rx);
32817 }
32818
32819 push_rxbufs(card, sb);
32820 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32821 printk
32822 ("nicstar%d: Out of huge buffers.\n",
32823 card->index);
32824 - atomic_inc(&vcc->stats->rx_drop);
32825 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32826 recycle_iovec_rx_bufs(card,
32827 (struct iovec *)
32828 iovb->data,
32829 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32830 card->hbpool.count++;
32831 } else
32832 dev_kfree_skb_any(hb);
32833 - atomic_inc(&vcc->stats->rx_drop);
32834 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32835 } else {
32836 /* Copy the small buffer to the huge buffer */
32837 sb = (struct sk_buff *)iov->iov_base;
32838 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32839 #endif /* NS_USE_DESTRUCTORS */
32840 __net_timestamp(hb);
32841 vcc->push(vcc, hb);
32842 - atomic_inc(&vcc->stats->rx);
32843 + atomic_inc_unchecked(&vcc->stats->rx);
32844 }
32845 }
32846
32847 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
32848 index 32784d1..4a8434a 100644
32849 --- a/drivers/atm/solos-pci.c
32850 +++ b/drivers/atm/solos-pci.c
32851 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
32852 }
32853 atm_charge(vcc, skb->truesize);
32854 vcc->push(vcc, skb);
32855 - atomic_inc(&vcc->stats->rx);
32856 + atomic_inc_unchecked(&vcc->stats->rx);
32857 break;
32858
32859 case PKT_STATUS:
32860 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
32861 vcc = SKB_CB(oldskb)->vcc;
32862
32863 if (vcc) {
32864 - atomic_inc(&vcc->stats->tx);
32865 + atomic_inc_unchecked(&vcc->stats->tx);
32866 solos_pop(vcc, oldskb);
32867 } else {
32868 dev_kfree_skb_irq(oldskb);
32869 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
32870 index 0215934..ce9f5b1 100644
32871 --- a/drivers/atm/suni.c
32872 +++ b/drivers/atm/suni.c
32873 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
32874
32875
32876 #define ADD_LIMITED(s,v) \
32877 - atomic_add((v),&stats->s); \
32878 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
32879 + atomic_add_unchecked((v),&stats->s); \
32880 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
32881
32882
32883 static void suni_hz(unsigned long from_timer)
32884 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
32885 index 5120a96..e2572bd 100644
32886 --- a/drivers/atm/uPD98402.c
32887 +++ b/drivers/atm/uPD98402.c
32888 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
32889 struct sonet_stats tmp;
32890 int error = 0;
32891
32892 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
32893 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
32894 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
32895 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
32896 if (zero && !error) {
32897 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
32898
32899
32900 #define ADD_LIMITED(s,v) \
32901 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
32902 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
32903 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
32904 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
32905 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
32906 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
32907
32908
32909 static void stat_event(struct atm_dev *dev)
32910 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
32911 if (reason & uPD98402_INT_PFM) stat_event(dev);
32912 if (reason & uPD98402_INT_PCO) {
32913 (void) GET(PCOCR); /* clear interrupt cause */
32914 - atomic_add(GET(HECCT),
32915 + atomic_add_unchecked(GET(HECCT),
32916 &PRIV(dev)->sonet_stats.uncorr_hcs);
32917 }
32918 if ((reason & uPD98402_INT_RFO) &&
32919 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
32920 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
32921 uPD98402_INT_LOS),PIMR); /* enable them */
32922 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
32923 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
32924 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
32925 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
32926 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
32927 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
32928 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
32929 return 0;
32930 }
32931
32932 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
32933 index 969c3c2..9b72956 100644
32934 --- a/drivers/atm/zatm.c
32935 +++ b/drivers/atm/zatm.c
32936 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
32937 }
32938 if (!size) {
32939 dev_kfree_skb_irq(skb);
32940 - if (vcc) atomic_inc(&vcc->stats->rx_err);
32941 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
32942 continue;
32943 }
32944 if (!atm_charge(vcc,skb->truesize)) {
32945 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
32946 skb->len = size;
32947 ATM_SKB(skb)->vcc = vcc;
32948 vcc->push(vcc,skb);
32949 - atomic_inc(&vcc->stats->rx);
32950 + atomic_inc_unchecked(&vcc->stats->rx);
32951 }
32952 zout(pos & 0xffff,MTA(mbx));
32953 #if 0 /* probably a stupid idea */
32954 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
32955 skb_queue_head(&zatm_vcc->backlog,skb);
32956 break;
32957 }
32958 - atomic_inc(&vcc->stats->tx);
32959 + atomic_inc_unchecked(&vcc->stats->tx);
32960 wake_up(&zatm_vcc->tx_wait);
32961 }
32962
32963 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
32964 index 519865b..e540db3 100644
32965 --- a/drivers/base/bus.c
32966 +++ b/drivers/base/bus.c
32967 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
32968 return -EINVAL;
32969
32970 mutex_lock(&subsys->p->mutex);
32971 - list_add_tail(&sif->node, &subsys->p->interfaces);
32972 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
32973 if (sif->add_dev) {
32974 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
32975 while ((dev = subsys_dev_iter_next(&iter)))
32976 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
32977 subsys = sif->subsys;
32978
32979 mutex_lock(&subsys->p->mutex);
32980 - list_del_init(&sif->node);
32981 + pax_list_del_init((struct list_head *)&sif->node);
32982 if (sif->remove_dev) {
32983 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
32984 while ((dev = subsys_dev_iter_next(&iter)))
32985 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
32986 index 01fc5b0..917801f 100644
32987 --- a/drivers/base/devtmpfs.c
32988 +++ b/drivers/base/devtmpfs.c
32989 @@ -348,7 +348,7 @@ int devtmpfs_mount(const char *mntdir)
32990 if (!thread)
32991 return 0;
32992
32993 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
32994 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
32995 if (err)
32996 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
32997 else
32998 @@ -373,11 +373,11 @@ static int devtmpfsd(void *p)
32999 *err = sys_unshare(CLONE_NEWNS);
33000 if (*err)
33001 goto out;
33002 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
33003 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
33004 if (*err)
33005 goto out;
33006 - sys_chdir("/.."); /* will traverse into overmounted root */
33007 - sys_chroot(".");
33008 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
33009 + sys_chroot((char __force_user *)".");
33010 complete(&setup_done);
33011 while (1) {
33012 spin_lock(&req_lock);
33013 diff --git a/drivers/base/node.c b/drivers/base/node.c
33014 index fac124a..66bd4ab 100644
33015 --- a/drivers/base/node.c
33016 +++ b/drivers/base/node.c
33017 @@ -625,7 +625,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
33018 struct node_attr {
33019 struct device_attribute attr;
33020 enum node_states state;
33021 -};
33022 +} __do_const;
33023
33024 static ssize_t show_node_state(struct device *dev,
33025 struct device_attribute *attr, char *buf)
33026 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
33027 index 9a6b05a..2fc8fb9 100644
33028 --- a/drivers/base/power/domain.c
33029 +++ b/drivers/base/power/domain.c
33030 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
33031 {
33032 struct cpuidle_driver *cpuidle_drv;
33033 struct gpd_cpu_data *cpu_data;
33034 - struct cpuidle_state *idle_state;
33035 + cpuidle_state_no_const *idle_state;
33036 int ret = 0;
33037
33038 if (IS_ERR_OR_NULL(genpd) || state < 0)
33039 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
33040 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
33041 {
33042 struct gpd_cpu_data *cpu_data;
33043 - struct cpuidle_state *idle_state;
33044 + cpuidle_state_no_const *idle_state;
33045 int ret = 0;
33046
33047 if (IS_ERR_OR_NULL(genpd))
33048 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
33049 index 79715e7..df06b3b 100644
33050 --- a/drivers/base/power/wakeup.c
33051 +++ b/drivers/base/power/wakeup.c
33052 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
33053 * They need to be modified together atomically, so it's better to use one
33054 * atomic variable to hold them both.
33055 */
33056 -static atomic_t combined_event_count = ATOMIC_INIT(0);
33057 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
33058
33059 #define IN_PROGRESS_BITS (sizeof(int) * 4)
33060 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
33061
33062 static void split_counters(unsigned int *cnt, unsigned int *inpr)
33063 {
33064 - unsigned int comb = atomic_read(&combined_event_count);
33065 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
33066
33067 *cnt = (comb >> IN_PROGRESS_BITS);
33068 *inpr = comb & MAX_IN_PROGRESS;
33069 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33070 ws->start_prevent_time = ws->last_time;
33071
33072 /* Increment the counter of events in progress. */
33073 - cec = atomic_inc_return(&combined_event_count);
33074 + cec = atomic_inc_return_unchecked(&combined_event_count);
33075
33076 trace_wakeup_source_activate(ws->name, cec);
33077 }
33078 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33079 * Increment the counter of registered wakeup events and decrement the
33080 * couter of wakeup events in progress simultaneously.
33081 */
33082 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33083 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33084 trace_wakeup_source_deactivate(ws->name, cec);
33085
33086 split_counters(&cnt, &inpr);
33087 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33088 index e8d11b6..7b1b36f 100644
33089 --- a/drivers/base/syscore.c
33090 +++ b/drivers/base/syscore.c
33091 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33092 void register_syscore_ops(struct syscore_ops *ops)
33093 {
33094 mutex_lock(&syscore_ops_lock);
33095 - list_add_tail(&ops->node, &syscore_ops_list);
33096 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33097 mutex_unlock(&syscore_ops_lock);
33098 }
33099 EXPORT_SYMBOL_GPL(register_syscore_ops);
33100 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
33101 void unregister_syscore_ops(struct syscore_ops *ops)
33102 {
33103 mutex_lock(&syscore_ops_lock);
33104 - list_del(&ops->node);
33105 + pax_list_del((struct list_head *)&ops->node);
33106 mutex_unlock(&syscore_ops_lock);
33107 }
33108 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33109 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33110 index 1c1b8e5..b7fc681 100644
33111 --- a/drivers/block/cciss.c
33112 +++ b/drivers/block/cciss.c
33113 @@ -1196,6 +1196,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33114 int err;
33115 u32 cp;
33116
33117 + memset(&arg64, 0, sizeof(arg64));
33118 +
33119 err = 0;
33120 err |=
33121 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33122 @@ -3005,7 +3007,7 @@ static void start_io(ctlr_info_t *h)
33123 while (!list_empty(&h->reqQ)) {
33124 c = list_entry(h->reqQ.next, CommandList_struct, list);
33125 /* can't do anything if fifo is full */
33126 - if ((h->access.fifo_full(h))) {
33127 + if ((h->access->fifo_full(h))) {
33128 dev_warn(&h->pdev->dev, "fifo full\n");
33129 break;
33130 }
33131 @@ -3015,7 +3017,7 @@ static void start_io(ctlr_info_t *h)
33132 h->Qdepth--;
33133
33134 /* Tell the controller execute command */
33135 - h->access.submit_command(h, c);
33136 + h->access->submit_command(h, c);
33137
33138 /* Put job onto the completed Q */
33139 addQ(&h->cmpQ, c);
33140 @@ -3441,17 +3443,17 @@ startio:
33141
33142 static inline unsigned long get_next_completion(ctlr_info_t *h)
33143 {
33144 - return h->access.command_completed(h);
33145 + return h->access->command_completed(h);
33146 }
33147
33148 static inline int interrupt_pending(ctlr_info_t *h)
33149 {
33150 - return h->access.intr_pending(h);
33151 + return h->access->intr_pending(h);
33152 }
33153
33154 static inline long interrupt_not_for_us(ctlr_info_t *h)
33155 {
33156 - return ((h->access.intr_pending(h) == 0) ||
33157 + return ((h->access->intr_pending(h) == 0) ||
33158 (h->interrupts_enabled == 0));
33159 }
33160
33161 @@ -3484,7 +3486,7 @@ static inline u32 next_command(ctlr_info_t *h)
33162 u32 a;
33163
33164 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33165 - return h->access.command_completed(h);
33166 + return h->access->command_completed(h);
33167
33168 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33169 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33170 @@ -4041,7 +4043,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33171 trans_support & CFGTBL_Trans_use_short_tags);
33172
33173 /* Change the access methods to the performant access methods */
33174 - h->access = SA5_performant_access;
33175 + h->access = &SA5_performant_access;
33176 h->transMethod = CFGTBL_Trans_Performant;
33177
33178 return;
33179 @@ -4310,7 +4312,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33180 if (prod_index < 0)
33181 return -ENODEV;
33182 h->product_name = products[prod_index].product_name;
33183 - h->access = *(products[prod_index].access);
33184 + h->access = products[prod_index].access;
33185
33186 if (cciss_board_disabled(h)) {
33187 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33188 @@ -5032,7 +5034,7 @@ reinit_after_soft_reset:
33189 }
33190
33191 /* make sure the board interrupts are off */
33192 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33193 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33194 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33195 if (rc)
33196 goto clean2;
33197 @@ -5082,7 +5084,7 @@ reinit_after_soft_reset:
33198 * fake ones to scoop up any residual completions.
33199 */
33200 spin_lock_irqsave(&h->lock, flags);
33201 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33202 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33203 spin_unlock_irqrestore(&h->lock, flags);
33204 free_irq(h->intr[h->intr_mode], h);
33205 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33206 @@ -5102,9 +5104,9 @@ reinit_after_soft_reset:
33207 dev_info(&h->pdev->dev, "Board READY.\n");
33208 dev_info(&h->pdev->dev,
33209 "Waiting for stale completions to drain.\n");
33210 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33211 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33212 msleep(10000);
33213 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33214 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33215
33216 rc = controller_reset_failed(h->cfgtable);
33217 if (rc)
33218 @@ -5127,7 +5129,7 @@ reinit_after_soft_reset:
33219 cciss_scsi_setup(h);
33220
33221 /* Turn the interrupts on so we can service requests */
33222 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33223 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33224
33225 /* Get the firmware version */
33226 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33227 @@ -5199,7 +5201,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33228 kfree(flush_buf);
33229 if (return_code != IO_OK)
33230 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33231 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33232 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33233 free_irq(h->intr[h->intr_mode], h);
33234 }
33235
33236 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33237 index 7fda30e..eb5dfe0 100644
33238 --- a/drivers/block/cciss.h
33239 +++ b/drivers/block/cciss.h
33240 @@ -101,7 +101,7 @@ struct ctlr_info
33241 /* information about each logical volume */
33242 drive_info_struct *drv[CISS_MAX_LUN];
33243
33244 - struct access_method access;
33245 + struct access_method *access;
33246
33247 /* queue and queue Info */
33248 struct list_head reqQ;
33249 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33250 index 3f08713..56a586a 100644
33251 --- a/drivers/block/cpqarray.c
33252 +++ b/drivers/block/cpqarray.c
33253 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33254 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33255 goto Enomem4;
33256 }
33257 - hba[i]->access.set_intr_mask(hba[i], 0);
33258 + hba[i]->access->set_intr_mask(hba[i], 0);
33259 if (request_irq(hba[i]->intr, do_ida_intr,
33260 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33261 {
33262 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33263 add_timer(&hba[i]->timer);
33264
33265 /* Enable IRQ now that spinlock and rate limit timer are set up */
33266 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33267 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33268
33269 for(j=0; j<NWD; j++) {
33270 struct gendisk *disk = ida_gendisk[i][j];
33271 @@ -694,7 +694,7 @@ DBGINFO(
33272 for(i=0; i<NR_PRODUCTS; i++) {
33273 if (board_id == products[i].board_id) {
33274 c->product_name = products[i].product_name;
33275 - c->access = *(products[i].access);
33276 + c->access = products[i].access;
33277 break;
33278 }
33279 }
33280 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33281 hba[ctlr]->intr = intr;
33282 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33283 hba[ctlr]->product_name = products[j].product_name;
33284 - hba[ctlr]->access = *(products[j].access);
33285 + hba[ctlr]->access = products[j].access;
33286 hba[ctlr]->ctlr = ctlr;
33287 hba[ctlr]->board_id = board_id;
33288 hba[ctlr]->pci_dev = NULL; /* not PCI */
33289 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
33290
33291 while((c = h->reqQ) != NULL) {
33292 /* Can't do anything if we're busy */
33293 - if (h->access.fifo_full(h) == 0)
33294 + if (h->access->fifo_full(h) == 0)
33295 return;
33296
33297 /* Get the first entry from the request Q */
33298 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
33299 h->Qdepth--;
33300
33301 /* Tell the controller to do our bidding */
33302 - h->access.submit_command(h, c);
33303 + h->access->submit_command(h, c);
33304
33305 /* Get onto the completion Q */
33306 addQ(&h->cmpQ, c);
33307 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33308 unsigned long flags;
33309 __u32 a,a1;
33310
33311 - istat = h->access.intr_pending(h);
33312 + istat = h->access->intr_pending(h);
33313 /* Is this interrupt for us? */
33314 if (istat == 0)
33315 return IRQ_NONE;
33316 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33317 */
33318 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33319 if (istat & FIFO_NOT_EMPTY) {
33320 - while((a = h->access.command_completed(h))) {
33321 + while((a = h->access->command_completed(h))) {
33322 a1 = a; a &= ~3;
33323 if ((c = h->cmpQ) == NULL)
33324 {
33325 @@ -1449,11 +1449,11 @@ static int sendcmd(
33326 /*
33327 * Disable interrupt
33328 */
33329 - info_p->access.set_intr_mask(info_p, 0);
33330 + info_p->access->set_intr_mask(info_p, 0);
33331 /* Make sure there is room in the command FIFO */
33332 /* Actually it should be completely empty at this time. */
33333 for (i = 200000; i > 0; i--) {
33334 - temp = info_p->access.fifo_full(info_p);
33335 + temp = info_p->access->fifo_full(info_p);
33336 if (temp != 0) {
33337 break;
33338 }
33339 @@ -1466,7 +1466,7 @@ DBG(
33340 /*
33341 * Send the cmd
33342 */
33343 - info_p->access.submit_command(info_p, c);
33344 + info_p->access->submit_command(info_p, c);
33345 complete = pollcomplete(ctlr);
33346
33347 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33348 @@ -1549,9 +1549,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33349 * we check the new geometry. Then turn interrupts back on when
33350 * we're done.
33351 */
33352 - host->access.set_intr_mask(host, 0);
33353 + host->access->set_intr_mask(host, 0);
33354 getgeometry(ctlr);
33355 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33356 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33357
33358 for(i=0; i<NWD; i++) {
33359 struct gendisk *disk = ida_gendisk[ctlr][i];
33360 @@ -1591,7 +1591,7 @@ static int pollcomplete(int ctlr)
33361 /* Wait (up to 2 seconds) for a command to complete */
33362
33363 for (i = 200000; i > 0; i--) {
33364 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33365 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33366 if (done == 0) {
33367 udelay(10); /* a short fixed delay */
33368 } else
33369 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33370 index be73e9d..7fbf140 100644
33371 --- a/drivers/block/cpqarray.h
33372 +++ b/drivers/block/cpqarray.h
33373 @@ -99,7 +99,7 @@ struct ctlr_info {
33374 drv_info_t drv[NWD];
33375 struct proc_dir_entry *proc;
33376
33377 - struct access_method access;
33378 + struct access_method *access;
33379
33380 cmdlist_t *reqQ;
33381 cmdlist_t *cmpQ;
33382 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33383 index 6b51afa..17e1191 100644
33384 --- a/drivers/block/drbd/drbd_int.h
33385 +++ b/drivers/block/drbd/drbd_int.h
33386 @@ -582,7 +582,7 @@ struct drbd_epoch {
33387 struct drbd_tconn *tconn;
33388 struct list_head list;
33389 unsigned int barrier_nr;
33390 - atomic_t epoch_size; /* increased on every request added. */
33391 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33392 atomic_t active; /* increased on every req. added, and dec on every finished. */
33393 unsigned long flags;
33394 };
33395 @@ -1011,7 +1011,7 @@ struct drbd_conf {
33396 int al_tr_cycle;
33397 int al_tr_pos; /* position of the next transaction in the journal */
33398 wait_queue_head_t seq_wait;
33399 - atomic_t packet_seq;
33400 + atomic_unchecked_t packet_seq;
33401 unsigned int peer_seq;
33402 spinlock_t peer_seq_lock;
33403 unsigned int minor;
33404 @@ -1527,7 +1527,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33405 char __user *uoptval;
33406 int err;
33407
33408 - uoptval = (char __user __force *)optval;
33409 + uoptval = (char __force_user *)optval;
33410
33411 set_fs(KERNEL_DS);
33412 if (level == SOL_SOCKET)
33413 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33414 index 54d03d4..332f311 100644
33415 --- a/drivers/block/drbd/drbd_main.c
33416 +++ b/drivers/block/drbd/drbd_main.c
33417 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33418 p->sector = sector;
33419 p->block_id = block_id;
33420 p->blksize = blksize;
33421 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33422 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33423 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33424 }
33425
33426 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33427 return -EIO;
33428 p->sector = cpu_to_be64(req->i.sector);
33429 p->block_id = (unsigned long)req;
33430 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33431 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33432 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33433 if (mdev->state.conn >= C_SYNC_SOURCE &&
33434 mdev->state.conn <= C_PAUSED_SYNC_T)
33435 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33436 {
33437 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33438
33439 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33440 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33441 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33442 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33443 kfree(tconn->current_epoch);
33444
33445 idr_destroy(&tconn->volumes);
33446 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33447 index 2f5fffd..b22a1ae 100644
33448 --- a/drivers/block/drbd/drbd_receiver.c
33449 +++ b/drivers/block/drbd/drbd_receiver.c
33450 @@ -833,7 +833,7 @@ int drbd_connected(struct drbd_conf *mdev)
33451 {
33452 int err;
33453
33454 - atomic_set(&mdev->packet_seq, 0);
33455 + atomic_set_unchecked(&mdev->packet_seq, 0);
33456 mdev->peer_seq = 0;
33457
33458 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33459 @@ -1191,7 +1191,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33460 do {
33461 next_epoch = NULL;
33462
33463 - epoch_size = atomic_read(&epoch->epoch_size);
33464 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33465
33466 switch (ev & ~EV_CLEANUP) {
33467 case EV_PUT:
33468 @@ -1231,7 +1231,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33469 rv = FE_DESTROYED;
33470 } else {
33471 epoch->flags = 0;
33472 - atomic_set(&epoch->epoch_size, 0);
33473 + atomic_set_unchecked(&epoch->epoch_size, 0);
33474 /* atomic_set(&epoch->active, 0); is already zero */
33475 if (rv == FE_STILL_LIVE)
33476 rv = FE_RECYCLED;
33477 @@ -1449,7 +1449,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33478 conn_wait_active_ee_empty(tconn);
33479 drbd_flush(tconn);
33480
33481 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33482 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33483 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33484 if (epoch)
33485 break;
33486 @@ -1462,11 +1462,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33487 }
33488
33489 epoch->flags = 0;
33490 - atomic_set(&epoch->epoch_size, 0);
33491 + atomic_set_unchecked(&epoch->epoch_size, 0);
33492 atomic_set(&epoch->active, 0);
33493
33494 spin_lock(&tconn->epoch_lock);
33495 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33496 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33497 list_add(&epoch->list, &tconn->current_epoch->list);
33498 tconn->current_epoch = epoch;
33499 tconn->epochs++;
33500 @@ -2170,7 +2170,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33501
33502 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33503 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33504 - atomic_inc(&tconn->current_epoch->epoch_size);
33505 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33506 err2 = drbd_drain_block(mdev, pi->size);
33507 if (!err)
33508 err = err2;
33509 @@ -2204,7 +2204,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33510
33511 spin_lock(&tconn->epoch_lock);
33512 peer_req->epoch = tconn->current_epoch;
33513 - atomic_inc(&peer_req->epoch->epoch_size);
33514 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33515 atomic_inc(&peer_req->epoch->active);
33516 spin_unlock(&tconn->epoch_lock);
33517
33518 @@ -4345,7 +4345,7 @@ struct data_cmd {
33519 int expect_payload;
33520 size_t pkt_size;
33521 int (*fn)(struct drbd_tconn *, struct packet_info *);
33522 -};
33523 +} __do_const;
33524
33525 static struct data_cmd drbd_cmd_handler[] = {
33526 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33527 @@ -4465,7 +4465,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33528 if (!list_empty(&tconn->current_epoch->list))
33529 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33530 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33531 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33532 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33533 tconn->send.seen_any_write_yet = false;
33534
33535 conn_info(tconn, "Connection closed\n");
33536 @@ -5221,7 +5221,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33537 struct asender_cmd {
33538 size_t pkt_size;
33539 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33540 -};
33541 +} __do_const;
33542
33543 static struct asender_cmd asender_tbl[] = {
33544 [P_PING] = { 0, got_Ping },
33545 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33546 index dfe7583..83768bb 100644
33547 --- a/drivers/block/loop.c
33548 +++ b/drivers/block/loop.c
33549 @@ -231,7 +231,7 @@ static int __do_lo_send_write(struct file *file,
33550 mm_segment_t old_fs = get_fs();
33551
33552 set_fs(get_ds());
33553 - bw = file->f_op->write(file, buf, len, &pos);
33554 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33555 set_fs(old_fs);
33556 if (likely(bw == len))
33557 return 0;
33558 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
33559 index 2e7de7a..ed86dc0 100644
33560 --- a/drivers/block/pktcdvd.c
33561 +++ b/drivers/block/pktcdvd.c
33562 @@ -83,7 +83,7 @@
33563
33564 #define MAX_SPEED 0xffff
33565
33566 -#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1))
33567 +#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1UL))
33568
33569 static DEFINE_MUTEX(pktcdvd_mutex);
33570 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
33571 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33572 index d620b44..587561e 100644
33573 --- a/drivers/cdrom/cdrom.c
33574 +++ b/drivers/cdrom/cdrom.c
33575 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33576 ENSURE(reset, CDC_RESET);
33577 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33578 cdi->mc_flags = 0;
33579 - cdo->n_minors = 0;
33580 cdi->options = CDO_USE_FFLAGS;
33581
33582 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33583 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33584 else
33585 cdi->cdda_method = CDDA_OLD;
33586
33587 - if (!cdo->generic_packet)
33588 - cdo->generic_packet = cdrom_dummy_generic_packet;
33589 + if (!cdo->generic_packet) {
33590 + pax_open_kernel();
33591 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33592 + pax_close_kernel();
33593 + }
33594
33595 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33596 mutex_lock(&cdrom_mutex);
33597 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33598 if (cdi->exit)
33599 cdi->exit(cdi);
33600
33601 - cdi->ops->n_minors--;
33602 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33603 }
33604
33605 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33606 index d59cdcb..11afddf 100644
33607 --- a/drivers/cdrom/gdrom.c
33608 +++ b/drivers/cdrom/gdrom.c
33609 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33610 .audio_ioctl = gdrom_audio_ioctl,
33611 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33612 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33613 - .n_minors = 1,
33614 };
33615
33616 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33617 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33618 index 3bb6fa3..34013fb 100644
33619 --- a/drivers/char/Kconfig
33620 +++ b/drivers/char/Kconfig
33621 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
33622
33623 config DEVKMEM
33624 bool "/dev/kmem virtual device support"
33625 - default y
33626 + default n
33627 + depends on !GRKERNSEC_KMEM
33628 help
33629 Say Y here if you want to support the /dev/kmem device. The
33630 /dev/kmem device is rarely used, but can be used for certain
33631 @@ -582,6 +583,7 @@ config DEVPORT
33632 bool
33633 depends on !M68K
33634 depends on ISA || PCI
33635 + depends on !GRKERNSEC_KMEM
33636 default y
33637
33638 source "drivers/s390/char/Kconfig"
33639 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
33640 index a48e05b..6bac831 100644
33641 --- a/drivers/char/agp/compat_ioctl.c
33642 +++ b/drivers/char/agp/compat_ioctl.c
33643 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
33644 return -ENOMEM;
33645 }
33646
33647 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
33648 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
33649 sizeof(*usegment) * ureserve.seg_count)) {
33650 kfree(usegment);
33651 kfree(ksegment);
33652 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
33653 index 2e04433..771f2cc 100644
33654 --- a/drivers/char/agp/frontend.c
33655 +++ b/drivers/char/agp/frontend.c
33656 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33657 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
33658 return -EFAULT;
33659
33660 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
33661 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
33662 return -EFAULT;
33663
33664 client = agp_find_client_by_pid(reserve.pid);
33665 @@ -847,7 +847,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33666 if (segment == NULL)
33667 return -ENOMEM;
33668
33669 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
33670 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
33671 sizeof(struct agp_segment) * reserve.seg_count)) {
33672 kfree(segment);
33673 return -EFAULT;
33674 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
33675 index 21cb980..f15107c 100644
33676 --- a/drivers/char/genrtc.c
33677 +++ b/drivers/char/genrtc.c
33678 @@ -272,6 +272,7 @@ static int gen_rtc_ioctl(struct file *file,
33679 switch (cmd) {
33680
33681 case RTC_PLL_GET:
33682 + memset(&pll, 0, sizeof(pll));
33683 if (get_rtc_pll(&pll))
33684 return -EINVAL;
33685 else
33686 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
33687 index d784650..e8bfd69 100644
33688 --- a/drivers/char/hpet.c
33689 +++ b/drivers/char/hpet.c
33690 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
33691 }
33692
33693 static int
33694 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
33695 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
33696 struct hpet_info *info)
33697 {
33698 struct hpet_timer __iomem *timer;
33699 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
33700 index 053201b0..8335cce 100644
33701 --- a/drivers/char/ipmi/ipmi_msghandler.c
33702 +++ b/drivers/char/ipmi/ipmi_msghandler.c
33703 @@ -420,7 +420,7 @@ struct ipmi_smi {
33704 struct proc_dir_entry *proc_dir;
33705 char proc_dir_name[10];
33706
33707 - atomic_t stats[IPMI_NUM_STATS];
33708 + atomic_unchecked_t stats[IPMI_NUM_STATS];
33709
33710 /*
33711 * run_to_completion duplicate of smb_info, smi_info
33712 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
33713
33714
33715 #define ipmi_inc_stat(intf, stat) \
33716 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
33717 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
33718 #define ipmi_get_stat(intf, stat) \
33719 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
33720 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
33721
33722 static int is_lan_addr(struct ipmi_addr *addr)
33723 {
33724 @@ -2884,7 +2884,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
33725 INIT_LIST_HEAD(&intf->cmd_rcvrs);
33726 init_waitqueue_head(&intf->waitq);
33727 for (i = 0; i < IPMI_NUM_STATS; i++)
33728 - atomic_set(&intf->stats[i], 0);
33729 + atomic_set_unchecked(&intf->stats[i], 0);
33730
33731 intf->proc_dir = NULL;
33732
33733 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
33734 index 0ac9b45..6179fb5 100644
33735 --- a/drivers/char/ipmi/ipmi_si_intf.c
33736 +++ b/drivers/char/ipmi/ipmi_si_intf.c
33737 @@ -275,7 +275,7 @@ struct smi_info {
33738 unsigned char slave_addr;
33739
33740 /* Counters and things for the proc filesystem. */
33741 - atomic_t stats[SI_NUM_STATS];
33742 + atomic_unchecked_t stats[SI_NUM_STATS];
33743
33744 struct task_struct *thread;
33745
33746 @@ -284,9 +284,9 @@ struct smi_info {
33747 };
33748
33749 #define smi_inc_stat(smi, stat) \
33750 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
33751 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
33752 #define smi_get_stat(smi, stat) \
33753 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
33754 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
33755
33756 #define SI_MAX_PARMS 4
33757
33758 @@ -3254,7 +3254,7 @@ static int try_smi_init(struct smi_info *new_smi)
33759 atomic_set(&new_smi->req_events, 0);
33760 new_smi->run_to_completion = 0;
33761 for (i = 0; i < SI_NUM_STATS; i++)
33762 - atomic_set(&new_smi->stats[i], 0);
33763 + atomic_set_unchecked(&new_smi->stats[i], 0);
33764
33765 new_smi->interrupt_disabled = 1;
33766 atomic_set(&new_smi->stop_operation, 0);
33767 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
33768 index 2c644af..d4d7f17 100644
33769 --- a/drivers/char/mem.c
33770 +++ b/drivers/char/mem.c
33771 @@ -18,6 +18,7 @@
33772 #include <linux/raw.h>
33773 #include <linux/tty.h>
33774 #include <linux/capability.h>
33775 +#include <linux/security.h>
33776 #include <linux/ptrace.h>
33777 #include <linux/device.h>
33778 #include <linux/highmem.h>
33779 @@ -37,6 +38,10 @@
33780
33781 #define DEVPORT_MINOR 4
33782
33783 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33784 +extern const struct file_operations grsec_fops;
33785 +#endif
33786 +
33787 static inline unsigned long size_inside_page(unsigned long start,
33788 unsigned long size)
33789 {
33790 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33791
33792 while (cursor < to) {
33793 if (!devmem_is_allowed(pfn)) {
33794 +#ifdef CONFIG_GRKERNSEC_KMEM
33795 + gr_handle_mem_readwrite(from, to);
33796 +#else
33797 printk(KERN_INFO
33798 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
33799 current->comm, from, to);
33800 +#endif
33801 return 0;
33802 }
33803 cursor += PAGE_SIZE;
33804 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33805 }
33806 return 1;
33807 }
33808 +#elif defined(CONFIG_GRKERNSEC_KMEM)
33809 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33810 +{
33811 + return 0;
33812 +}
33813 #else
33814 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33815 {
33816 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33817
33818 while (count > 0) {
33819 unsigned long remaining;
33820 + char *temp;
33821
33822 sz = size_inside_page(p, count);
33823
33824 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
33825 if (!ptr)
33826 return -EFAULT;
33827
33828 - remaining = copy_to_user(buf, ptr, sz);
33829 +#ifdef CONFIG_PAX_USERCOPY
33830 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
33831 + if (!temp) {
33832 + unxlate_dev_mem_ptr(p, ptr);
33833 + return -ENOMEM;
33834 + }
33835 + memcpy(temp, ptr, sz);
33836 +#else
33837 + temp = ptr;
33838 +#endif
33839 +
33840 + remaining = copy_to_user(buf, temp, sz);
33841 +
33842 +#ifdef CONFIG_PAX_USERCOPY
33843 + kfree(temp);
33844 +#endif
33845 +
33846 unxlate_dev_mem_ptr(p, ptr);
33847 if (remaining)
33848 return -EFAULT;
33849 @@ -378,7 +409,7 @@ static ssize_t read_oldmem(struct file *file, char __user *buf,
33850 else
33851 csize = count;
33852
33853 - rc = copy_oldmem_page(pfn, buf, csize, offset, 1);
33854 + rc = copy_oldmem_page(pfn, (char __force_kernel *)buf, csize, offset, 1);
33855 if (rc < 0)
33856 return rc;
33857 buf += csize;
33858 @@ -398,9 +429,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33859 size_t count, loff_t *ppos)
33860 {
33861 unsigned long p = *ppos;
33862 - ssize_t low_count, read, sz;
33863 + ssize_t low_count, read, sz, err = 0;
33864 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
33865 - int err = 0;
33866
33867 read = 0;
33868 if (p < (unsigned long) high_memory) {
33869 @@ -422,6 +452,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33870 }
33871 #endif
33872 while (low_count > 0) {
33873 + char *temp;
33874 +
33875 sz = size_inside_page(p, low_count);
33876
33877 /*
33878 @@ -431,7 +463,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
33879 */
33880 kbuf = xlate_dev_kmem_ptr((char *)p);
33881
33882 - if (copy_to_user(buf, kbuf, sz))
33883 +#ifdef CONFIG_PAX_USERCOPY
33884 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
33885 + if (!temp)
33886 + return -ENOMEM;
33887 + memcpy(temp, kbuf, sz);
33888 +#else
33889 + temp = kbuf;
33890 +#endif
33891 +
33892 + err = copy_to_user(buf, temp, sz);
33893 +
33894 +#ifdef CONFIG_PAX_USERCOPY
33895 + kfree(temp);
33896 +#endif
33897 +
33898 + if (err)
33899 return -EFAULT;
33900 buf += sz;
33901 p += sz;
33902 @@ -833,6 +880,9 @@ static const struct memdev {
33903 #ifdef CONFIG_CRASH_DUMP
33904 [12] = { "oldmem", 0, &oldmem_fops, NULL },
33905 #endif
33906 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33907 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
33908 +#endif
33909 };
33910
33911 static int memory_open(struct inode *inode, struct file *filp)
33912 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
33913 index 9df78e2..01ba9ae 100644
33914 --- a/drivers/char/nvram.c
33915 +++ b/drivers/char/nvram.c
33916 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
33917
33918 spin_unlock_irq(&rtc_lock);
33919
33920 - if (copy_to_user(buf, contents, tmp - contents))
33921 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
33922 return -EFAULT;
33923
33924 *ppos = i;
33925 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
33926 index 5c5cc00..ac9edb7 100644
33927 --- a/drivers/char/pcmcia/synclink_cs.c
33928 +++ b/drivers/char/pcmcia/synclink_cs.c
33929 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
33930
33931 if (debug_level >= DEBUG_LEVEL_INFO)
33932 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
33933 - __FILE__, __LINE__, info->device_name, port->count);
33934 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
33935
33936 - WARN_ON(!port->count);
33937 + WARN_ON(!atomic_read(&port->count));
33938
33939 if (tty_port_close_start(port, tty, filp) == 0)
33940 goto cleanup;
33941 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
33942 cleanup:
33943 if (debug_level >= DEBUG_LEVEL_INFO)
33944 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
33945 - tty->driver->name, port->count);
33946 + tty->driver->name, atomic_read(&port->count));
33947 }
33948
33949 /* Wait until the transmitter is empty.
33950 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
33951
33952 if (debug_level >= DEBUG_LEVEL_INFO)
33953 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
33954 - __FILE__, __LINE__, tty->driver->name, port->count);
33955 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
33956
33957 /* If port is closing, signal caller to try again */
33958 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
33959 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
33960 goto cleanup;
33961 }
33962 spin_lock(&port->lock);
33963 - port->count++;
33964 + atomic_inc(&port->count);
33965 spin_unlock(&port->lock);
33966 spin_unlock_irqrestore(&info->netlock, flags);
33967
33968 - if (port->count == 1) {
33969 + if (atomic_read(&port->count) == 1) {
33970 /* 1st open on this device, init hardware */
33971 retval = startup(info, tty);
33972 if (retval < 0)
33973 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
33974 unsigned short new_crctype;
33975
33976 /* return error if TTY interface open */
33977 - if (info->port.count)
33978 + if (atomic_read(&info->port.count))
33979 return -EBUSY;
33980
33981 switch (encoding)
33982 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
33983
33984 /* arbitrate between network and tty opens */
33985 spin_lock_irqsave(&info->netlock, flags);
33986 - if (info->port.count != 0 || info->netcount != 0) {
33987 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
33988 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
33989 spin_unlock_irqrestore(&info->netlock, flags);
33990 return -EBUSY;
33991 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
33992 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
33993
33994 /* return error if TTY interface open */
33995 - if (info->port.count)
33996 + if (atomic_read(&info->port.count))
33997 return -EBUSY;
33998
33999 if (cmd != SIOCWANDEV)
34000 diff --git a/drivers/char/random.c b/drivers/char/random.c
34001 index 32a6c57..98038d5 100644
34002 --- a/drivers/char/random.c
34003 +++ b/drivers/char/random.c
34004 @@ -272,8 +272,13 @@
34005 /*
34006 * Configuration information
34007 */
34008 +#ifdef CONFIG_GRKERNSEC_RANDNET
34009 +#define INPUT_POOL_WORDS 512
34010 +#define OUTPUT_POOL_WORDS 128
34011 +#else
34012 #define INPUT_POOL_WORDS 128
34013 #define OUTPUT_POOL_WORDS 32
34014 +#endif
34015 #define SEC_XFER_SIZE 512
34016 #define EXTRACT_SIZE 10
34017
34018 @@ -313,10 +318,17 @@ static struct poolinfo {
34019 int poolwords;
34020 int tap1, tap2, tap3, tap4, tap5;
34021 } poolinfo_table[] = {
34022 +#ifdef CONFIG_GRKERNSEC_RANDNET
34023 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
34024 + { 512, 411, 308, 208, 104, 1 },
34025 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
34026 + { 128, 103, 76, 51, 25, 1 },
34027 +#else
34028 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
34029 { 128, 103, 76, 51, 25, 1 },
34030 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
34031 { 32, 26, 20, 14, 7, 1 },
34032 +#endif
34033 #if 0
34034 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
34035 { 2048, 1638, 1231, 819, 411, 1 },
34036 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
34037 input_rotate += i ? 7 : 14;
34038 }
34039
34040 - ACCESS_ONCE(r->input_rotate) = input_rotate;
34041 - ACCESS_ONCE(r->add_ptr) = i;
34042 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
34043 + ACCESS_ONCE_RW(r->add_ptr) = i;
34044 smp_wmb();
34045
34046 if (out)
34047 @@ -865,16 +877,24 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
34048 if (r->entropy_count / 8 < min + reserved) {
34049 nbytes = 0;
34050 } else {
34051 + int entropy_count, orig;
34052 +retry:
34053 + entropy_count = orig = ACCESS_ONCE(r->entropy_count);
34054 /* If limited, never pull more than available */
34055 - if (r->limit && nbytes + reserved >= r->entropy_count / 8)
34056 - nbytes = r->entropy_count/8 - reserved;
34057 + if (r->limit && nbytes + reserved >= entropy_count / 8)
34058 + nbytes = entropy_count/8 - reserved;
34059
34060 - if (r->entropy_count / 8 >= nbytes + reserved)
34061 - r->entropy_count -= nbytes*8;
34062 - else
34063 - r->entropy_count = reserved;
34064 + if (entropy_count / 8 >= nbytes + reserved) {
34065 + entropy_count -= nbytes*8;
34066 + if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig)
34067 + goto retry;
34068 + } else {
34069 + entropy_count = reserved;
34070 + if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig)
34071 + goto retry;
34072 + }
34073
34074 - if (r->entropy_count < random_write_wakeup_thresh)
34075 + if (entropy_count < random_write_wakeup_thresh)
34076 wakeup_write = 1;
34077 }
34078
34079 @@ -957,10 +977,23 @@ static ssize_t extract_entropy(struct entropy_store *r, void *buf,
34080 {
34081 ssize_t ret = 0, i;
34082 __u8 tmp[EXTRACT_SIZE];
34083 + unsigned long flags;
34084
34085 /* if last_data isn't primed, we need EXTRACT_SIZE extra bytes */
34086 - if (fips_enabled && !r->last_data_init)
34087 - nbytes += EXTRACT_SIZE;
34088 + if (fips_enabled) {
34089 + spin_lock_irqsave(&r->lock, flags);
34090 + if (!r->last_data_init) {
34091 + r->last_data_init = true;
34092 + spin_unlock_irqrestore(&r->lock, flags);
34093 + trace_extract_entropy(r->name, EXTRACT_SIZE,
34094 + r->entropy_count, _RET_IP_);
34095 + xfer_secondary_pool(r, EXTRACT_SIZE);
34096 + extract_buf(r, tmp);
34097 + spin_lock_irqsave(&r->lock, flags);
34098 + memcpy(r->last_data, tmp, EXTRACT_SIZE);
34099 + }
34100 + spin_unlock_irqrestore(&r->lock, flags);
34101 + }
34102
34103 trace_extract_entropy(r->name, nbytes, r->entropy_count, _RET_IP_);
34104 xfer_secondary_pool(r, nbytes);
34105 @@ -970,19 +1003,6 @@ static ssize_t extract_entropy(struct entropy_store *r, void *buf,
34106 extract_buf(r, tmp);
34107
34108 if (fips_enabled) {
34109 - unsigned long flags;
34110 -
34111 -
34112 - /* prime last_data value if need be, per fips 140-2 */
34113 - if (!r->last_data_init) {
34114 - spin_lock_irqsave(&r->lock, flags);
34115 - memcpy(r->last_data, tmp, EXTRACT_SIZE);
34116 - r->last_data_init = true;
34117 - nbytes -= EXTRACT_SIZE;
34118 - spin_unlock_irqrestore(&r->lock, flags);
34119 - extract_buf(r, tmp);
34120 - }
34121 -
34122 spin_lock_irqsave(&r->lock, flags);
34123 if (!memcmp(tmp, r->last_data, EXTRACT_SIZE))
34124 panic("Hardware RNG duplicated output!\n");
34125 @@ -1024,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
34126
34127 extract_buf(r, tmp);
34128 i = min_t(int, nbytes, EXTRACT_SIZE);
34129 - if (copy_to_user(buf, tmp, i)) {
34130 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
34131 ret = -EFAULT;
34132 break;
34133 }
34134 @@ -1360,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
34135 #include <linux/sysctl.h>
34136
34137 static int min_read_thresh = 8, min_write_thresh;
34138 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
34139 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
34140 static int max_write_thresh = INPUT_POOL_WORDS * 32;
34141 static char sysctl_bootid[16];
34142
34143 @@ -1376,7 +1396,7 @@ static char sysctl_bootid[16];
34144 static int proc_do_uuid(ctl_table *table, int write,
34145 void __user *buffer, size_t *lenp, loff_t *ppos)
34146 {
34147 - ctl_table fake_table;
34148 + ctl_table_no_const fake_table;
34149 unsigned char buf[64], tmp_uuid[16], *uuid;
34150
34151 uuid = table->data;
34152 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
34153 index bf2349db..5456d53 100644
34154 --- a/drivers/char/sonypi.c
34155 +++ b/drivers/char/sonypi.c
34156 @@ -54,6 +54,7 @@
34157
34158 #include <asm/uaccess.h>
34159 #include <asm/io.h>
34160 +#include <asm/local.h>
34161
34162 #include <linux/sonypi.h>
34163
34164 @@ -490,7 +491,7 @@ static struct sonypi_device {
34165 spinlock_t fifo_lock;
34166 wait_queue_head_t fifo_proc_list;
34167 struct fasync_struct *fifo_async;
34168 - int open_count;
34169 + local_t open_count;
34170 int model;
34171 struct input_dev *input_jog_dev;
34172 struct input_dev *input_key_dev;
34173 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
34174 static int sonypi_misc_release(struct inode *inode, struct file *file)
34175 {
34176 mutex_lock(&sonypi_device.lock);
34177 - sonypi_device.open_count--;
34178 + local_dec(&sonypi_device.open_count);
34179 mutex_unlock(&sonypi_device.lock);
34180 return 0;
34181 }
34182 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
34183 {
34184 mutex_lock(&sonypi_device.lock);
34185 /* Flush input queue on first open */
34186 - if (!sonypi_device.open_count)
34187 + if (!local_read(&sonypi_device.open_count))
34188 kfifo_reset(&sonypi_device.fifo);
34189 - sonypi_device.open_count++;
34190 + local_inc(&sonypi_device.open_count);
34191 mutex_unlock(&sonypi_device.lock);
34192
34193 return 0;
34194 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34195 index 64420b3..5c40b56 100644
34196 --- a/drivers/char/tpm/tpm_acpi.c
34197 +++ b/drivers/char/tpm/tpm_acpi.c
34198 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34199 virt = acpi_os_map_memory(start, len);
34200 if (!virt) {
34201 kfree(log->bios_event_log);
34202 + log->bios_event_log = NULL;
34203 printk("%s: ERROR - Unable to map memory\n", __func__);
34204 return -EIO;
34205 }
34206
34207 - memcpy_fromio(log->bios_event_log, virt, len);
34208 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
34209
34210 acpi_os_unmap_memory(virt, len);
34211 return 0;
34212 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34213 index 84ddc55..1d32f1e 100644
34214 --- a/drivers/char/tpm/tpm_eventlog.c
34215 +++ b/drivers/char/tpm/tpm_eventlog.c
34216 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34217 event = addr;
34218
34219 if ((event->event_type == 0 && event->event_size == 0) ||
34220 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34221 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34222 return NULL;
34223
34224 return addr;
34225 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34226 return NULL;
34227
34228 if ((event->event_type == 0 && event->event_size == 0) ||
34229 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34230 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34231 return NULL;
34232
34233 (*pos)++;
34234 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34235 int i;
34236
34237 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34238 - seq_putc(m, data[i]);
34239 + if (!seq_putc(m, data[i]))
34240 + return -EFAULT;
34241
34242 return 0;
34243 }
34244 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34245 index ce5f3fc..e2d3e55 100644
34246 --- a/drivers/char/virtio_console.c
34247 +++ b/drivers/char/virtio_console.c
34248 @@ -679,7 +679,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34249 if (to_user) {
34250 ssize_t ret;
34251
34252 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34253 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34254 if (ret)
34255 return -EFAULT;
34256 } else {
34257 @@ -778,7 +778,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34258 if (!port_has_data(port) && !port->host_connected)
34259 return 0;
34260
34261 - return fill_readbuf(port, ubuf, count, true);
34262 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34263 }
34264
34265 static int wait_port_writable(struct port *port, bool nonblock)
34266 diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
34267 index d7ad425..3e3f81f 100644
34268 --- a/drivers/clocksource/arm_arch_timer.c
34269 +++ b/drivers/clocksource/arm_arch_timer.c
34270 @@ -262,7 +262,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34271 return NOTIFY_OK;
34272 }
34273
34274 -static struct notifier_block arch_timer_cpu_nb __cpuinitdata = {
34275 +static struct notifier_block arch_timer_cpu_nb = {
34276 .notifier_call = arch_timer_cpu_notify,
34277 };
34278
34279 diff --git a/drivers/clocksource/metag_generic.c b/drivers/clocksource/metag_generic.c
34280 index ade7513..069445f 100644
34281 --- a/drivers/clocksource/metag_generic.c
34282 +++ b/drivers/clocksource/metag_generic.c
34283 @@ -169,7 +169,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34284 return NOTIFY_OK;
34285 }
34286
34287 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34288 +static struct notifier_block arch_timer_cpu_nb = {
34289 .notifier_call = arch_timer_cpu_notify,
34290 };
34291
34292 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34293 index 57a8774..545e993 100644
34294 --- a/drivers/cpufreq/acpi-cpufreq.c
34295 +++ b/drivers/cpufreq/acpi-cpufreq.c
34296 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34297 return sprintf(buf, "%u\n", boost_enabled);
34298 }
34299
34300 -static struct global_attr global_boost = __ATTR(boost, 0644,
34301 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34302 show_global_boost,
34303 store_global_boost);
34304
34305 @@ -712,8 +712,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34306 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34307 per_cpu(acfreq_data, cpu) = data;
34308
34309 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34310 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34311 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34312 + pax_open_kernel();
34313 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34314 + pax_close_kernel();
34315 + }
34316
34317 result = acpi_processor_register_performance(data->acpi_data, cpu);
34318 if (result)
34319 @@ -839,7 +842,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34320 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34321 break;
34322 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34323 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34324 + pax_open_kernel();
34325 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34326 + pax_close_kernel();
34327 policy->cur = get_cur_freq_on_cpu(cpu);
34328 break;
34329 default:
34330 @@ -850,8 +855,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34331 acpi_processor_notify_smm(THIS_MODULE);
34332
34333 /* Check for APERF/MPERF support in hardware */
34334 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34335 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34336 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34337 + pax_open_kernel();
34338 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34339 + pax_close_kernel();
34340 + }
34341
34342 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34343 for (i = 0; i < perf->state_count; i++)
34344 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34345 index b02824d..51e44aa 100644
34346 --- a/drivers/cpufreq/cpufreq.c
34347 +++ b/drivers/cpufreq/cpufreq.c
34348 @@ -1813,7 +1813,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34349 return NOTIFY_OK;
34350 }
34351
34352 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34353 +static struct notifier_block cpufreq_cpu_notifier = {
34354 .notifier_call = cpufreq_cpu_callback,
34355 };
34356
34357 @@ -1845,8 +1845,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34358
34359 pr_debug("trying to register driver %s\n", driver_data->name);
34360
34361 - if (driver_data->setpolicy)
34362 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34363 + if (driver_data->setpolicy) {
34364 + pax_open_kernel();
34365 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34366 + pax_close_kernel();
34367 + }
34368
34369 spin_lock_irqsave(&cpufreq_driver_lock, flags);
34370 if (cpufreq_driver) {
34371 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34372 index 5a76086..0f4d394 100644
34373 --- a/drivers/cpufreq/cpufreq_governor.c
34374 +++ b/drivers/cpufreq/cpufreq_governor.c
34375 @@ -201,8 +201,8 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34376 {
34377 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
34378 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
34379 - struct cs_ops *cs_ops = NULL;
34380 - struct od_ops *od_ops = NULL;
34381 + const struct cs_ops *cs_ops = NULL;
34382 + const struct od_ops *od_ops = NULL;
34383 struct od_dbs_tuners *od_tuners = dbs_data->tuners;
34384 struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
34385 struct cpu_dbs_common_info *cpu_cdbs;
34386 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34387 index cc4bd2f..ad142bc 100644
34388 --- a/drivers/cpufreq/cpufreq_governor.h
34389 +++ b/drivers/cpufreq/cpufreq_governor.h
34390 @@ -142,7 +142,7 @@ struct dbs_data {
34391 void (*gov_check_cpu)(int cpu, unsigned int load);
34392
34393 /* Governor specific ops, see below */
34394 - void *gov_ops;
34395 + const void *gov_ops;
34396 };
34397
34398 /* Governor specific ops, will be passed to dbs_data->gov_ops */
34399 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34400 index bfd6273..e39dd63 100644
34401 --- a/drivers/cpufreq/cpufreq_stats.c
34402 +++ b/drivers/cpufreq/cpufreq_stats.c
34403 @@ -365,7 +365,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34404 }
34405
34406 /* priority=1 so this will get called before cpufreq_remove_dev */
34407 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34408 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34409 .notifier_call = cpufreq_stat_cpu_callback,
34410 .priority = 1,
34411 };
34412 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34413 index 827629c9..0bc6a03 100644
34414 --- a/drivers/cpufreq/p4-clockmod.c
34415 +++ b/drivers/cpufreq/p4-clockmod.c
34416 @@ -167,10 +167,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34417 case 0x0F: /* Core Duo */
34418 case 0x16: /* Celeron Core */
34419 case 0x1C: /* Atom */
34420 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34421 + pax_open_kernel();
34422 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34423 + pax_close_kernel();
34424 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34425 case 0x0D: /* Pentium M (Dothan) */
34426 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34427 + pax_open_kernel();
34428 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34429 + pax_close_kernel();
34430 /* fall through */
34431 case 0x09: /* Pentium M (Banias) */
34432 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34433 @@ -182,7 +186,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34434
34435 /* on P-4s, the TSC runs with constant frequency independent whether
34436 * throttling is active or not. */
34437 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34438 + pax_open_kernel();
34439 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34440 + pax_close_kernel();
34441
34442 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34443 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34444 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34445 index 3a953d5..f5993f6 100644
34446 --- a/drivers/cpufreq/speedstep-centrino.c
34447 +++ b/drivers/cpufreq/speedstep-centrino.c
34448 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34449 !cpu_has(cpu, X86_FEATURE_EST))
34450 return -ENODEV;
34451
34452 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34453 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34454 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34455 + pax_open_kernel();
34456 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34457 + pax_close_kernel();
34458 + }
34459
34460 if (policy->cpu != 0)
34461 return -ENODEV;
34462 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34463 index eba6929..0f53baf 100644
34464 --- a/drivers/cpuidle/cpuidle.c
34465 +++ b/drivers/cpuidle/cpuidle.c
34466 @@ -277,7 +277,7 @@ static int poll_idle(struct cpuidle_device *dev,
34467
34468 static void poll_idle_init(struct cpuidle_driver *drv)
34469 {
34470 - struct cpuidle_state *state = &drv->states[0];
34471 + cpuidle_state_no_const *state = &drv->states[0];
34472
34473 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34474 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34475 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34476 index ea2f8e7..70ac501 100644
34477 --- a/drivers/cpuidle/governor.c
34478 +++ b/drivers/cpuidle/governor.c
34479 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34480 mutex_lock(&cpuidle_lock);
34481 if (__cpuidle_find_governor(gov->name) == NULL) {
34482 ret = 0;
34483 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34484 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34485 if (!cpuidle_curr_governor ||
34486 cpuidle_curr_governor->rating < gov->rating)
34487 cpuidle_switch_governor(gov);
34488 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34489 new_gov = cpuidle_replace_governor(gov->rating);
34490 cpuidle_switch_governor(new_gov);
34491 }
34492 - list_del(&gov->governor_list);
34493 + pax_list_del((struct list_head *)&gov->governor_list);
34494 mutex_unlock(&cpuidle_lock);
34495 }
34496
34497 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34498 index 428754a..8bdf9cc 100644
34499 --- a/drivers/cpuidle/sysfs.c
34500 +++ b/drivers/cpuidle/sysfs.c
34501 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34502 NULL
34503 };
34504
34505 -static struct attribute_group cpuidle_attr_group = {
34506 +static attribute_group_no_const cpuidle_attr_group = {
34507 .attrs = cpuidle_default_attrs,
34508 .name = "cpuidle",
34509 };
34510 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34511 index 3b36797..289c16a 100644
34512 --- a/drivers/devfreq/devfreq.c
34513 +++ b/drivers/devfreq/devfreq.c
34514 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34515 goto err_out;
34516 }
34517
34518 - list_add(&governor->node, &devfreq_governor_list);
34519 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34520
34521 list_for_each_entry(devfreq, &devfreq_list, node) {
34522 int ret = 0;
34523 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34524 }
34525 }
34526
34527 - list_del(&governor->node);
34528 + pax_list_del((struct list_head *)&governor->node);
34529 err_out:
34530 mutex_unlock(&devfreq_list_lock);
34531
34532 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34533 index b70709b..1d8d02a 100644
34534 --- a/drivers/dma/sh/shdma.c
34535 +++ b/drivers/dma/sh/shdma.c
34536 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34537 return ret;
34538 }
34539
34540 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34541 +static struct notifier_block sh_dmae_nmi_notifier = {
34542 .notifier_call = sh_dmae_nmi_handler,
34543
34544 /* Run before NMI debug handler and KGDB */
34545 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34546 index 769d92e..a3dcc1e 100644
34547 --- a/drivers/edac/edac_mc_sysfs.c
34548 +++ b/drivers/edac/edac_mc_sysfs.c
34549 @@ -148,7 +148,7 @@ static const char *edac_caps[] = {
34550 struct dev_ch_attribute {
34551 struct device_attribute attr;
34552 int channel;
34553 -};
34554 +} __do_const;
34555
34556 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34557 struct dev_ch_attribute dev_attr_legacy_##_name = \
34558 @@ -1003,14 +1003,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
34559 }
34560
34561 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
34562 + pax_open_kernel();
34563 if (mci->get_sdram_scrub_rate) {
34564 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34565 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34566 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34567 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34568 }
34569 if (mci->set_sdram_scrub_rate) {
34570 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34571 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34572 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34573 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34574 }
34575 + pax_close_kernel();
34576 err = device_create_file(&mci->dev,
34577 &dev_attr_sdram_scrub_rate);
34578 if (err) {
34579 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34580 index e8658e4..22746d6 100644
34581 --- a/drivers/edac/edac_pci_sysfs.c
34582 +++ b/drivers/edac/edac_pci_sysfs.c
34583 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34584 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34585 static int edac_pci_poll_msec = 1000; /* one second workq period */
34586
34587 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34588 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34589 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34590 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34591
34592 static struct kobject *edac_pci_top_main_kobj;
34593 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34594 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34595 void *value;
34596 ssize_t(*show) (void *, char *);
34597 ssize_t(*store) (void *, const char *, size_t);
34598 -};
34599 +} __do_const;
34600
34601 /* Set of show/store abstract level functions for PCI Parity object */
34602 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34603 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34604 edac_printk(KERN_CRIT, EDAC_PCI,
34605 "Signaled System Error on %s\n",
34606 pci_name(dev));
34607 - atomic_inc(&pci_nonparity_count);
34608 + atomic_inc_unchecked(&pci_nonparity_count);
34609 }
34610
34611 if (status & (PCI_STATUS_PARITY)) {
34612 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34613 "Master Data Parity Error on %s\n",
34614 pci_name(dev));
34615
34616 - atomic_inc(&pci_parity_count);
34617 + atomic_inc_unchecked(&pci_parity_count);
34618 }
34619
34620 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34621 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34622 "Detected Parity Error on %s\n",
34623 pci_name(dev));
34624
34625 - atomic_inc(&pci_parity_count);
34626 + atomic_inc_unchecked(&pci_parity_count);
34627 }
34628 }
34629
34630 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34631 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
34632 "Signaled System Error on %s\n",
34633 pci_name(dev));
34634 - atomic_inc(&pci_nonparity_count);
34635 + atomic_inc_unchecked(&pci_nonparity_count);
34636 }
34637
34638 if (status & (PCI_STATUS_PARITY)) {
34639 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34640 "Master Data Parity Error on "
34641 "%s\n", pci_name(dev));
34642
34643 - atomic_inc(&pci_parity_count);
34644 + atomic_inc_unchecked(&pci_parity_count);
34645 }
34646
34647 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34648 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34649 "Detected Parity Error on %s\n",
34650 pci_name(dev));
34651
34652 - atomic_inc(&pci_parity_count);
34653 + atomic_inc_unchecked(&pci_parity_count);
34654 }
34655 }
34656 }
34657 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
34658 if (!check_pci_errors)
34659 return;
34660
34661 - before_count = atomic_read(&pci_parity_count);
34662 + before_count = atomic_read_unchecked(&pci_parity_count);
34663
34664 /* scan all PCI devices looking for a Parity Error on devices and
34665 * bridges.
34666 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
34667 /* Only if operator has selected panic on PCI Error */
34668 if (edac_pci_get_panic_on_pe()) {
34669 /* If the count is different 'after' from 'before' */
34670 - if (before_count != atomic_read(&pci_parity_count))
34671 + if (before_count != atomic_read_unchecked(&pci_parity_count))
34672 panic("EDAC: PCI Parity Error");
34673 }
34674 }
34675 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
34676 index 51b7e3a..aa8a3e8 100644
34677 --- a/drivers/edac/mce_amd.h
34678 +++ b/drivers/edac/mce_amd.h
34679 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
34680 bool (*mc0_mce)(u16, u8);
34681 bool (*mc1_mce)(u16, u8);
34682 bool (*mc2_mce)(u16, u8);
34683 -};
34684 +} __no_const;
34685
34686 void amd_report_gart_errors(bool);
34687 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
34688 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
34689 index 57ea7f4..789e3c3 100644
34690 --- a/drivers/firewire/core-card.c
34691 +++ b/drivers/firewire/core-card.c
34692 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
34693
34694 void fw_core_remove_card(struct fw_card *card)
34695 {
34696 - struct fw_card_driver dummy_driver = dummy_driver_template;
34697 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
34698
34699 card->driver->update_phy_reg(card, 4,
34700 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
34701 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
34702 index 27ac423..13573e8 100644
34703 --- a/drivers/firewire/core-cdev.c
34704 +++ b/drivers/firewire/core-cdev.c
34705 @@ -1366,8 +1366,7 @@ static int init_iso_resource(struct client *client,
34706 int ret;
34707
34708 if ((request->channels == 0 && request->bandwidth == 0) ||
34709 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
34710 - request->bandwidth < 0)
34711 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
34712 return -EINVAL;
34713
34714 r = kmalloc(sizeof(*r), GFP_KERNEL);
34715 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
34716 index 03ce7d9..b70f5da 100644
34717 --- a/drivers/firewire/core-device.c
34718 +++ b/drivers/firewire/core-device.c
34719 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
34720 struct config_rom_attribute {
34721 struct device_attribute attr;
34722 u32 key;
34723 -};
34724 +} __do_const;
34725
34726 static ssize_t show_immediate(struct device *dev,
34727 struct device_attribute *dattr, char *buf)
34728 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
34729 index 28a94c7..58da63a 100644
34730 --- a/drivers/firewire/core-transaction.c
34731 +++ b/drivers/firewire/core-transaction.c
34732 @@ -38,6 +38,7 @@
34733 #include <linux/timer.h>
34734 #include <linux/types.h>
34735 #include <linux/workqueue.h>
34736 +#include <linux/sched.h>
34737
34738 #include <asm/byteorder.h>
34739
34740 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
34741 index 515a42c..5ecf3ba 100644
34742 --- a/drivers/firewire/core.h
34743 +++ b/drivers/firewire/core.h
34744 @@ -111,6 +111,7 @@ struct fw_card_driver {
34745
34746 int (*stop_iso)(struct fw_iso_context *ctx);
34747 };
34748 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
34749
34750 void fw_card_initialize(struct fw_card *card,
34751 const struct fw_card_driver *driver, struct device *device);
34752 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
34753 index 94a58a0..f5eba42 100644
34754 --- a/drivers/firmware/dmi-id.c
34755 +++ b/drivers/firmware/dmi-id.c
34756 @@ -16,7 +16,7 @@
34757 struct dmi_device_attribute{
34758 struct device_attribute dev_attr;
34759 int field;
34760 -};
34761 +} __do_const;
34762 #define to_dmi_dev_attr(_dev_attr) \
34763 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
34764
34765 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
34766 index 4cd392d..4b629e1 100644
34767 --- a/drivers/firmware/dmi_scan.c
34768 +++ b/drivers/firmware/dmi_scan.c
34769 @@ -490,11 +490,6 @@ void __init dmi_scan_machine(void)
34770 }
34771 }
34772 else {
34773 - /*
34774 - * no iounmap() for that ioremap(); it would be a no-op, but
34775 - * it's so early in setup that sucker gets confused into doing
34776 - * what it shouldn't if we actually call it.
34777 - */
34778 p = dmi_ioremap(0xF0000, 0x10000);
34779 if (p == NULL)
34780 goto error;
34781 @@ -769,7 +764,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
34782 if (buf == NULL)
34783 return -1;
34784
34785 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
34786 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
34787
34788 iounmap(buf);
34789 return 0;
34790 diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
34791 index f4baa11..7970c3a 100644
34792 --- a/drivers/firmware/efivars.c
34793 +++ b/drivers/firmware/efivars.c
34794 @@ -139,7 +139,7 @@ struct efivar_attribute {
34795 };
34796
34797 static struct efivars __efivars;
34798 -static struct efivar_operations ops;
34799 +static efivar_operations_no_const ops __read_only;
34800
34801 #define PSTORE_EFI_ATTRIBUTES \
34802 (EFI_VARIABLE_NON_VOLATILE | \
34803 @@ -1844,7 +1844,7 @@ efivar_create_sysfs_entry(struct efivars *efivars,
34804 static int
34805 create_efivars_bin_attributes(struct efivars *efivars)
34806 {
34807 - struct bin_attribute *attr;
34808 + bin_attribute_no_const *attr;
34809 int error;
34810
34811 /* new_var */
34812 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
34813 index 2a90ba6..07f3733 100644
34814 --- a/drivers/firmware/google/memconsole.c
34815 +++ b/drivers/firmware/google/memconsole.c
34816 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
34817 if (!found_memconsole())
34818 return -ENODEV;
34819
34820 - memconsole_bin_attr.size = memconsole_length;
34821 + pax_open_kernel();
34822 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
34823 + pax_close_kernel();
34824
34825 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
34826
34827 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
34828 index de3c317..b7cd029 100644
34829 --- a/drivers/gpio/gpio-ich.c
34830 +++ b/drivers/gpio/gpio-ich.c
34831 @@ -69,7 +69,7 @@ struct ichx_desc {
34832 /* Some chipsets have quirks, let these use their own request/get */
34833 int (*request)(struct gpio_chip *chip, unsigned offset);
34834 int (*get)(struct gpio_chip *chip, unsigned offset);
34835 -};
34836 +} __do_const;
34837
34838 static struct {
34839 spinlock_t lock;
34840 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
34841 index 9902732..64b62dd 100644
34842 --- a/drivers/gpio/gpio-vr41xx.c
34843 +++ b/drivers/gpio/gpio-vr41xx.c
34844 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
34845 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
34846 maskl, pendl, maskh, pendh);
34847
34848 - atomic_inc(&irq_err_count);
34849 + atomic_inc_unchecked(&irq_err_count);
34850
34851 return -EINVAL;
34852 }
34853 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
34854 index 7b2d378..cc947ea 100644
34855 --- a/drivers/gpu/drm/drm_crtc_helper.c
34856 +++ b/drivers/gpu/drm/drm_crtc_helper.c
34857 @@ -319,7 +319,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
34858 struct drm_crtc *tmp;
34859 int crtc_mask = 1;
34860
34861 - WARN(!crtc, "checking null crtc?\n");
34862 + BUG_ON(!crtc);
34863
34864 dev = crtc->dev;
34865
34866 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
34867 index 25f91cd..a376f55 100644
34868 --- a/drivers/gpu/drm/drm_drv.c
34869 +++ b/drivers/gpu/drm/drm_drv.c
34870 @@ -306,7 +306,7 @@ module_exit(drm_core_exit);
34871 /**
34872 * Copy and IOCTL return string to user space
34873 */
34874 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
34875 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
34876 {
34877 int len;
34878
34879 @@ -376,7 +376,7 @@ long drm_ioctl(struct file *filp,
34880 struct drm_file *file_priv = filp->private_data;
34881 struct drm_device *dev;
34882 struct drm_ioctl_desc *ioctl;
34883 - drm_ioctl_t *func;
34884 + drm_ioctl_no_const_t func;
34885 unsigned int nr = DRM_IOCTL_NR(cmd);
34886 int retcode = -EINVAL;
34887 char stack_kdata[128];
34888 @@ -389,7 +389,7 @@ long drm_ioctl(struct file *filp,
34889 return -ENODEV;
34890
34891 atomic_inc(&dev->ioctl_count);
34892 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
34893 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
34894 ++file_priv->ioctl_count;
34895
34896 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
34897 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
34898 index 429e07d..e681a2c 100644
34899 --- a/drivers/gpu/drm/drm_fops.c
34900 +++ b/drivers/gpu/drm/drm_fops.c
34901 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
34902 }
34903
34904 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
34905 - atomic_set(&dev->counts[i], 0);
34906 + atomic_set_unchecked(&dev->counts[i], 0);
34907
34908 dev->sigdata.lock = NULL;
34909
34910 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
34911 if (drm_device_is_unplugged(dev))
34912 return -ENODEV;
34913
34914 - if (!dev->open_count++)
34915 + if (local_inc_return(&dev->open_count) == 1)
34916 need_setup = 1;
34917 mutex_lock(&dev->struct_mutex);
34918 old_imapping = inode->i_mapping;
34919 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
34920 retcode = drm_open_helper(inode, filp, dev);
34921 if (retcode)
34922 goto err_undo;
34923 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
34924 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
34925 if (need_setup) {
34926 retcode = drm_setup(dev);
34927 if (retcode)
34928 @@ -166,7 +166,7 @@ err_undo:
34929 iput(container_of(dev->dev_mapping, struct inode, i_data));
34930 dev->dev_mapping = old_mapping;
34931 mutex_unlock(&dev->struct_mutex);
34932 - dev->open_count--;
34933 + local_dec(&dev->open_count);
34934 return retcode;
34935 }
34936 EXPORT_SYMBOL(drm_open);
34937 @@ -441,7 +441,7 @@ int drm_release(struct inode *inode, struct file *filp)
34938
34939 mutex_lock(&drm_global_mutex);
34940
34941 - DRM_DEBUG("open_count = %d\n", dev->open_count);
34942 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
34943
34944 if (dev->driver->preclose)
34945 dev->driver->preclose(dev, file_priv);
34946 @@ -450,10 +450,10 @@ int drm_release(struct inode *inode, struct file *filp)
34947 * Begin inline drm_release
34948 */
34949
34950 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
34951 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
34952 task_pid_nr(current),
34953 (long)old_encode_dev(file_priv->minor->device),
34954 - dev->open_count);
34955 + local_read(&dev->open_count));
34956
34957 /* Release any auth tokens that might point to this file_priv,
34958 (do that under the drm_global_mutex) */
34959 @@ -550,8 +550,8 @@ int drm_release(struct inode *inode, struct file *filp)
34960 * End inline drm_release
34961 */
34962
34963 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
34964 - if (!--dev->open_count) {
34965 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
34966 + if (local_dec_and_test(&dev->open_count)) {
34967 if (atomic_read(&dev->ioctl_count)) {
34968 DRM_ERROR("Device busy: %d\n",
34969 atomic_read(&dev->ioctl_count));
34970 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
34971 index f731116..629842c 100644
34972 --- a/drivers/gpu/drm/drm_global.c
34973 +++ b/drivers/gpu/drm/drm_global.c
34974 @@ -36,7 +36,7 @@
34975 struct drm_global_item {
34976 struct mutex mutex;
34977 void *object;
34978 - int refcount;
34979 + atomic_t refcount;
34980 };
34981
34982 static struct drm_global_item glob[DRM_GLOBAL_NUM];
34983 @@ -49,7 +49,7 @@ void drm_global_init(void)
34984 struct drm_global_item *item = &glob[i];
34985 mutex_init(&item->mutex);
34986 item->object = NULL;
34987 - item->refcount = 0;
34988 + atomic_set(&item->refcount, 0);
34989 }
34990 }
34991
34992 @@ -59,7 +59,7 @@ void drm_global_release(void)
34993 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
34994 struct drm_global_item *item = &glob[i];
34995 BUG_ON(item->object != NULL);
34996 - BUG_ON(item->refcount != 0);
34997 + BUG_ON(atomic_read(&item->refcount) != 0);
34998 }
34999 }
35000
35001 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35002 void *object;
35003
35004 mutex_lock(&item->mutex);
35005 - if (item->refcount == 0) {
35006 + if (atomic_read(&item->refcount) == 0) {
35007 item->object = kzalloc(ref->size, GFP_KERNEL);
35008 if (unlikely(item->object == NULL)) {
35009 ret = -ENOMEM;
35010 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35011 goto out_err;
35012
35013 }
35014 - ++item->refcount;
35015 + atomic_inc(&item->refcount);
35016 ref->object = item->object;
35017 object = item->object;
35018 mutex_unlock(&item->mutex);
35019 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
35020 struct drm_global_item *item = &glob[ref->global_type];
35021
35022 mutex_lock(&item->mutex);
35023 - BUG_ON(item->refcount == 0);
35024 + BUG_ON(atomic_read(&item->refcount) == 0);
35025 BUG_ON(ref->object != item->object);
35026 - if (--item->refcount == 0) {
35027 + if (atomic_dec_and_test(&item->refcount)) {
35028 ref->release(ref);
35029 item->object = NULL;
35030 }
35031 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
35032 index d4b20ce..77a8d41 100644
35033 --- a/drivers/gpu/drm/drm_info.c
35034 +++ b/drivers/gpu/drm/drm_info.c
35035 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
35036 struct drm_local_map *map;
35037 struct drm_map_list *r_list;
35038
35039 - /* Hardcoded from _DRM_FRAME_BUFFER,
35040 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
35041 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
35042 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
35043 + static const char * const types[] = {
35044 + [_DRM_FRAME_BUFFER] = "FB",
35045 + [_DRM_REGISTERS] = "REG",
35046 + [_DRM_SHM] = "SHM",
35047 + [_DRM_AGP] = "AGP",
35048 + [_DRM_SCATTER_GATHER] = "SG",
35049 + [_DRM_CONSISTENT] = "PCI",
35050 + [_DRM_GEM] = "GEM" };
35051 const char *type;
35052 int i;
35053
35054 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
35055 map = r_list->map;
35056 if (!map)
35057 continue;
35058 - if (map->type < 0 || map->type > 5)
35059 + if (map->type >= ARRAY_SIZE(types))
35060 type = "??";
35061 else
35062 type = types[map->type];
35063 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
35064 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
35065 vma->vm_flags & VM_LOCKED ? 'l' : '-',
35066 vma->vm_flags & VM_IO ? 'i' : '-',
35067 +#ifdef CONFIG_GRKERNSEC_HIDESYM
35068 + 0);
35069 +#else
35070 vma->vm_pgoff);
35071 +#endif
35072
35073 #if defined(__i386__)
35074 pgprot = pgprot_val(vma->vm_page_prot);
35075 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
35076 index 2f4c434..dd12cd2 100644
35077 --- a/drivers/gpu/drm/drm_ioc32.c
35078 +++ b/drivers/gpu/drm/drm_ioc32.c
35079 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
35080 request = compat_alloc_user_space(nbytes);
35081 if (!access_ok(VERIFY_WRITE, request, nbytes))
35082 return -EFAULT;
35083 - list = (struct drm_buf_desc *) (request + 1);
35084 + list = (struct drm_buf_desc __user *) (request + 1);
35085
35086 if (__put_user(count, &request->count)
35087 || __put_user(list, &request->list))
35088 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
35089 request = compat_alloc_user_space(nbytes);
35090 if (!access_ok(VERIFY_WRITE, request, nbytes))
35091 return -EFAULT;
35092 - list = (struct drm_buf_pub *) (request + 1);
35093 + list = (struct drm_buf_pub __user *) (request + 1);
35094
35095 if (__put_user(count, &request->count)
35096 || __put_user(list, &request->list))
35097 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
35098 return 0;
35099 }
35100
35101 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
35102 +drm_ioctl_compat_t drm_compat_ioctls[] = {
35103 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
35104 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
35105 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
35106 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
35107 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35108 {
35109 unsigned int nr = DRM_IOCTL_NR(cmd);
35110 - drm_ioctl_compat_t *fn;
35111 int ret;
35112
35113 /* Assume that ioctls without an explicit compat routine will just
35114 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35115 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
35116 return drm_ioctl(filp, cmd, arg);
35117
35118 - fn = drm_compat_ioctls[nr];
35119 -
35120 - if (fn != NULL)
35121 - ret = (*fn) (filp, cmd, arg);
35122 + if (drm_compat_ioctls[nr] != NULL)
35123 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
35124 else
35125 ret = drm_ioctl(filp, cmd, arg);
35126
35127 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
35128 index e77bd8b..1571b85 100644
35129 --- a/drivers/gpu/drm/drm_ioctl.c
35130 +++ b/drivers/gpu/drm/drm_ioctl.c
35131 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
35132 stats->data[i].value =
35133 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
35134 else
35135 - stats->data[i].value = atomic_read(&dev->counts[i]);
35136 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
35137 stats->data[i].type = dev->types[i];
35138 }
35139
35140 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
35141 index d752c96..fe08455 100644
35142 --- a/drivers/gpu/drm/drm_lock.c
35143 +++ b/drivers/gpu/drm/drm_lock.c
35144 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35145 if (drm_lock_take(&master->lock, lock->context)) {
35146 master->lock.file_priv = file_priv;
35147 master->lock.lock_time = jiffies;
35148 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
35149 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
35150 break; /* Got lock */
35151 }
35152
35153 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35154 return -EINVAL;
35155 }
35156
35157 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
35158 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
35159
35160 if (drm_lock_free(&master->lock, lock->context)) {
35161 /* FIXME: Should really bail out here. */
35162 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
35163 index 7d30802..42c6cbb 100644
35164 --- a/drivers/gpu/drm/drm_stub.c
35165 +++ b/drivers/gpu/drm/drm_stub.c
35166 @@ -501,7 +501,7 @@ void drm_unplug_dev(struct drm_device *dev)
35167
35168 drm_device_set_unplugged(dev);
35169
35170 - if (dev->open_count == 0) {
35171 + if (local_read(&dev->open_count) == 0) {
35172 drm_put_dev(dev);
35173 }
35174 mutex_unlock(&drm_global_mutex);
35175 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
35176 index 004ecdf..db1f6e0 100644
35177 --- a/drivers/gpu/drm/i810/i810_dma.c
35178 +++ b/drivers/gpu/drm/i810/i810_dma.c
35179 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
35180 dma->buflist[vertex->idx],
35181 vertex->discard, vertex->used);
35182
35183 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35184 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35185 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35186 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35187 sarea_priv->last_enqueue = dev_priv->counter - 1;
35188 sarea_priv->last_dispatch = (int)hw_status[5];
35189
35190 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35191 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35192 mc->last_render);
35193
35194 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35195 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35196 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35197 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35198 sarea_priv->last_enqueue = dev_priv->counter - 1;
35199 sarea_priv->last_dispatch = (int)hw_status[5];
35200
35201 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35202 index 6e0acad..93c8289 100644
35203 --- a/drivers/gpu/drm/i810/i810_drv.h
35204 +++ b/drivers/gpu/drm/i810/i810_drv.h
35205 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35206 int page_flipping;
35207
35208 wait_queue_head_t irq_queue;
35209 - atomic_t irq_received;
35210 - atomic_t irq_emitted;
35211 + atomic_unchecked_t irq_received;
35212 + atomic_unchecked_t irq_emitted;
35213
35214 int front_offset;
35215 } drm_i810_private_t;
35216 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
35217 index 7299ea4..5314487 100644
35218 --- a/drivers/gpu/drm/i915/i915_debugfs.c
35219 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
35220 @@ -499,7 +499,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
35221 I915_READ(GTIMR));
35222 }
35223 seq_printf(m, "Interrupts received: %d\n",
35224 - atomic_read(&dev_priv->irq_received));
35225 + atomic_read_unchecked(&dev_priv->irq_received));
35226 for_each_ring(ring, dev_priv, i) {
35227 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35228 seq_printf(m,
35229 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35230 index 4fa6beb..f930fec 100644
35231 --- a/drivers/gpu/drm/i915/i915_dma.c
35232 +++ b/drivers/gpu/drm/i915/i915_dma.c
35233 @@ -1259,7 +1259,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35234 bool can_switch;
35235
35236 spin_lock(&dev->count_lock);
35237 - can_switch = (dev->open_count == 0);
35238 + can_switch = (local_read(&dev->open_count) == 0);
35239 spin_unlock(&dev->count_lock);
35240 return can_switch;
35241 }
35242 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35243 index ef99b1c..09ce7fb 100644
35244 --- a/drivers/gpu/drm/i915/i915_drv.h
35245 +++ b/drivers/gpu/drm/i915/i915_drv.h
35246 @@ -893,7 +893,7 @@ typedef struct drm_i915_private {
35247 drm_dma_handle_t *status_page_dmah;
35248 struct resource mch_res;
35249
35250 - atomic_t irq_received;
35251 + atomic_unchecked_t irq_received;
35252
35253 /* protects the irq masks */
35254 spinlock_t irq_lock;
35255 @@ -1775,7 +1775,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35256 struct drm_i915_private *dev_priv, unsigned port);
35257 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35258 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35259 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35260 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35261 {
35262 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35263 }
35264 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35265 index 9a48e1a..f0cbc3e 100644
35266 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35267 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35268 @@ -729,9 +729,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35269
35270 static int
35271 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35272 - int count)
35273 + unsigned int count)
35274 {
35275 - int i;
35276 + unsigned int i;
35277 int relocs_total = 0;
35278 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35279
35280 @@ -1195,7 +1195,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
35281 return -ENOMEM;
35282 }
35283 ret = copy_from_user(exec2_list,
35284 - (struct drm_i915_relocation_entry __user *)
35285 + (struct drm_i915_gem_exec_object2 __user *)
35286 (uintptr_t) args->buffers_ptr,
35287 sizeof(*exec2_list) * args->buffer_count);
35288 if (ret != 0) {
35289 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35290 index 3c59584..500f2e9 100644
35291 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35292 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35293 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35294 (unsigned long)request);
35295 }
35296
35297 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35298 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35299 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35300 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35301 [DRM_I915_GETPARAM] = compat_i915_getparam,
35302 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35303 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35304 {
35305 unsigned int nr = DRM_IOCTL_NR(cmd);
35306 - drm_ioctl_compat_t *fn = NULL;
35307 int ret;
35308
35309 if (nr < DRM_COMMAND_BASE)
35310 return drm_compat_ioctl(filp, cmd, arg);
35311
35312 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35313 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35314 -
35315 - if (fn != NULL)
35316 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35317 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35318 ret = (*fn) (filp, cmd, arg);
35319 - else
35320 + } else
35321 ret = drm_ioctl(filp, cmd, arg);
35322
35323 return ret;
35324 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35325 index 3c7bb04..182e049 100644
35326 --- a/drivers/gpu/drm/i915/i915_irq.c
35327 +++ b/drivers/gpu/drm/i915/i915_irq.c
35328 @@ -549,7 +549,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35329 int pipe;
35330 u32 pipe_stats[I915_MAX_PIPES];
35331
35332 - atomic_inc(&dev_priv->irq_received);
35333 + atomic_inc_unchecked(&dev_priv->irq_received);
35334
35335 while (true) {
35336 iir = I915_READ(VLV_IIR);
35337 @@ -705,7 +705,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35338 irqreturn_t ret = IRQ_NONE;
35339 int i;
35340
35341 - atomic_inc(&dev_priv->irq_received);
35342 + atomic_inc_unchecked(&dev_priv->irq_received);
35343
35344 /* disable master interrupt before clearing iir */
35345 de_ier = I915_READ(DEIER);
35346 @@ -791,7 +791,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35347 int ret = IRQ_NONE;
35348 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
35349
35350 - atomic_inc(&dev_priv->irq_received);
35351 + atomic_inc_unchecked(&dev_priv->irq_received);
35352
35353 /* disable master interrupt before clearing iir */
35354 de_ier = I915_READ(DEIER);
35355 @@ -1886,7 +1886,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35356 {
35357 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35358
35359 - atomic_set(&dev_priv->irq_received, 0);
35360 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35361
35362 I915_WRITE(HWSTAM, 0xeffe);
35363
35364 @@ -1912,7 +1912,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35365 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35366 int pipe;
35367
35368 - atomic_set(&dev_priv->irq_received, 0);
35369 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35370
35371 /* VLV magic */
35372 I915_WRITE(VLV_IMR, 0);
35373 @@ -2208,7 +2208,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35374 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35375 int pipe;
35376
35377 - atomic_set(&dev_priv->irq_received, 0);
35378 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35379
35380 for_each_pipe(pipe)
35381 I915_WRITE(PIPESTAT(pipe), 0);
35382 @@ -2259,7 +2259,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35383 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35384 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35385
35386 - atomic_inc(&dev_priv->irq_received);
35387 + atomic_inc_unchecked(&dev_priv->irq_received);
35388
35389 iir = I915_READ16(IIR);
35390 if (iir == 0)
35391 @@ -2344,7 +2344,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35392 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35393 int pipe;
35394
35395 - atomic_set(&dev_priv->irq_received, 0);
35396 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35397
35398 if (I915_HAS_HOTPLUG(dev)) {
35399 I915_WRITE(PORT_HOTPLUG_EN, 0);
35400 @@ -2448,7 +2448,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35401 };
35402 int pipe, ret = IRQ_NONE;
35403
35404 - atomic_inc(&dev_priv->irq_received);
35405 + atomic_inc_unchecked(&dev_priv->irq_received);
35406
35407 iir = I915_READ(IIR);
35408 do {
35409 @@ -2574,7 +2574,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35410 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35411 int pipe;
35412
35413 - atomic_set(&dev_priv->irq_received, 0);
35414 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35415
35416 I915_WRITE(PORT_HOTPLUG_EN, 0);
35417 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35418 @@ -2690,7 +2690,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35419 int irq_received;
35420 int ret = IRQ_NONE, pipe;
35421
35422 - atomic_inc(&dev_priv->irq_received);
35423 + atomic_inc_unchecked(&dev_priv->irq_received);
35424
35425 iir = I915_READ(IIR);
35426
35427 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35428 index c2d173a..f4357cc 100644
35429 --- a/drivers/gpu/drm/i915/intel_display.c
35430 +++ b/drivers/gpu/drm/i915/intel_display.c
35431 @@ -8722,13 +8722,13 @@ struct intel_quirk {
35432 int subsystem_vendor;
35433 int subsystem_device;
35434 void (*hook)(struct drm_device *dev);
35435 -};
35436 +} __do_const;
35437
35438 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35439 struct intel_dmi_quirk {
35440 void (*hook)(struct drm_device *dev);
35441 const struct dmi_system_id (*dmi_id_list)[];
35442 -};
35443 +} __do_const;
35444
35445 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35446 {
35447 @@ -8736,18 +8736,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35448 return 1;
35449 }
35450
35451 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35452 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35453 {
35454 - .dmi_id_list = &(const struct dmi_system_id[]) {
35455 - {
35456 - .callback = intel_dmi_reverse_brightness,
35457 - .ident = "NCR Corporation",
35458 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35459 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35460 - },
35461 - },
35462 - { } /* terminating entry */
35463 + .callback = intel_dmi_reverse_brightness,
35464 + .ident = "NCR Corporation",
35465 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35466 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35467 },
35468 + },
35469 + { } /* terminating entry */
35470 +};
35471 +
35472 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35473 + {
35474 + .dmi_id_list = &intel_dmi_quirks_table,
35475 .hook = quirk_invert_brightness,
35476 },
35477 };
35478 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35479 index 54558a0..2d97005 100644
35480 --- a/drivers/gpu/drm/mga/mga_drv.h
35481 +++ b/drivers/gpu/drm/mga/mga_drv.h
35482 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35483 u32 clear_cmd;
35484 u32 maccess;
35485
35486 - atomic_t vbl_received; /**< Number of vblanks received. */
35487 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35488 wait_queue_head_t fence_queue;
35489 - atomic_t last_fence_retired;
35490 + atomic_unchecked_t last_fence_retired;
35491 u32 next_fence_to_post;
35492
35493 unsigned int fb_cpp;
35494 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35495 index 709e90d..89a1c0d 100644
35496 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35497 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35498 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35499 return 0;
35500 }
35501
35502 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35503 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35504 [DRM_MGA_INIT] = compat_mga_init,
35505 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35506 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35507 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35508 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35509 {
35510 unsigned int nr = DRM_IOCTL_NR(cmd);
35511 - drm_ioctl_compat_t *fn = NULL;
35512 int ret;
35513
35514 if (nr < DRM_COMMAND_BASE)
35515 return drm_compat_ioctl(filp, cmd, arg);
35516
35517 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35518 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35519 -
35520 - if (fn != NULL)
35521 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35522 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35523 ret = (*fn) (filp, cmd, arg);
35524 - else
35525 + } else
35526 ret = drm_ioctl(filp, cmd, arg);
35527
35528 return ret;
35529 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35530 index 598c281..60d590e 100644
35531 --- a/drivers/gpu/drm/mga/mga_irq.c
35532 +++ b/drivers/gpu/drm/mga/mga_irq.c
35533 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35534 if (crtc != 0)
35535 return 0;
35536
35537 - return atomic_read(&dev_priv->vbl_received);
35538 + return atomic_read_unchecked(&dev_priv->vbl_received);
35539 }
35540
35541
35542 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35543 /* VBLANK interrupt */
35544 if (status & MGA_VLINEPEN) {
35545 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35546 - atomic_inc(&dev_priv->vbl_received);
35547 + atomic_inc_unchecked(&dev_priv->vbl_received);
35548 drm_handle_vblank(dev, 0);
35549 handled = 1;
35550 }
35551 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35552 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35553 MGA_WRITE(MGA_PRIMEND, prim_end);
35554
35555 - atomic_inc(&dev_priv->last_fence_retired);
35556 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35557 DRM_WAKEUP(&dev_priv->fence_queue);
35558 handled = 1;
35559 }
35560 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35561 * using fences.
35562 */
35563 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35564 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35565 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35566 - *sequence) <= (1 << 23)));
35567
35568 *sequence = cur_fence;
35569 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35570 index 50a6dd0..ea66ed8 100644
35571 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35572 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35573 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35574 struct bit_table {
35575 const char id;
35576 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35577 -};
35578 +} __no_const;
35579
35580 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35581
35582 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35583 index 9c39baf..30a22be 100644
35584 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35585 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35586 @@ -81,7 +81,7 @@ struct nouveau_drm {
35587 struct drm_global_reference mem_global_ref;
35588 struct ttm_bo_global_ref bo_global_ref;
35589 struct ttm_bo_device bdev;
35590 - atomic_t validate_sequence;
35591 + atomic_unchecked_t validate_sequence;
35592 int (*move)(struct nouveau_channel *,
35593 struct ttm_buffer_object *,
35594 struct ttm_mem_reg *, struct ttm_mem_reg *);
35595 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35596 index b4b4d0c..b7edc15 100644
35597 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35598 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35599 @@ -322,7 +322,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35600 int ret, i;
35601 struct nouveau_bo *res_bo = NULL;
35602
35603 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35604 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35605 retry:
35606 if (++trycnt > 100000) {
35607 NV_ERROR(cli, "%s failed and gave up.\n", __func__);
35608 @@ -359,7 +359,7 @@ retry:
35609 if (ret) {
35610 validate_fini(op, NULL);
35611 if (unlikely(ret == -EAGAIN)) {
35612 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35613 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35614 ret = ttm_bo_reserve_slowpath(&nvbo->bo, true,
35615 sequence);
35616 if (!ret)
35617 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35618 index 08214bc..9208577 100644
35619 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35620 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35621 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35622 unsigned long arg)
35623 {
35624 unsigned int nr = DRM_IOCTL_NR(cmd);
35625 - drm_ioctl_compat_t *fn = NULL;
35626 + drm_ioctl_compat_t fn = NULL;
35627 int ret;
35628
35629 if (nr < DRM_COMMAND_BASE)
35630 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35631 index 25d3495..d81aaf6 100644
35632 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35633 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35634 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35635 bool can_switch;
35636
35637 spin_lock(&dev->count_lock);
35638 - can_switch = (dev->open_count == 0);
35639 + can_switch = (local_read(&dev->open_count) == 0);
35640 spin_unlock(&dev->count_lock);
35641 return can_switch;
35642 }
35643 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
35644 index d4660cf..70dbe65 100644
35645 --- a/drivers/gpu/drm/r128/r128_cce.c
35646 +++ b/drivers/gpu/drm/r128/r128_cce.c
35647 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
35648
35649 /* GH: Simple idle check.
35650 */
35651 - atomic_set(&dev_priv->idle_count, 0);
35652 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35653
35654 /* We don't support anything other than bus-mastering ring mode,
35655 * but the ring can be in either AGP or PCI space for the ring
35656 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
35657 index 930c71b..499aded 100644
35658 --- a/drivers/gpu/drm/r128/r128_drv.h
35659 +++ b/drivers/gpu/drm/r128/r128_drv.h
35660 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
35661 int is_pci;
35662 unsigned long cce_buffers_offset;
35663
35664 - atomic_t idle_count;
35665 + atomic_unchecked_t idle_count;
35666
35667 int page_flipping;
35668 int current_page;
35669 u32 crtc_offset;
35670 u32 crtc_offset_cntl;
35671
35672 - atomic_t vbl_received;
35673 + atomic_unchecked_t vbl_received;
35674
35675 u32 color_fmt;
35676 unsigned int front_offset;
35677 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
35678 index a954c54..9cc595c 100644
35679 --- a/drivers/gpu/drm/r128/r128_ioc32.c
35680 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
35681 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
35682 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
35683 }
35684
35685 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
35686 +drm_ioctl_compat_t r128_compat_ioctls[] = {
35687 [DRM_R128_INIT] = compat_r128_init,
35688 [DRM_R128_DEPTH] = compat_r128_depth,
35689 [DRM_R128_STIPPLE] = compat_r128_stipple,
35690 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
35691 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35692 {
35693 unsigned int nr = DRM_IOCTL_NR(cmd);
35694 - drm_ioctl_compat_t *fn = NULL;
35695 int ret;
35696
35697 if (nr < DRM_COMMAND_BASE)
35698 return drm_compat_ioctl(filp, cmd, arg);
35699
35700 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
35701 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35702 -
35703 - if (fn != NULL)
35704 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
35705 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35706 ret = (*fn) (filp, cmd, arg);
35707 - else
35708 + } else
35709 ret = drm_ioctl(filp, cmd, arg);
35710
35711 return ret;
35712 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
35713 index 2ea4f09..d391371 100644
35714 --- a/drivers/gpu/drm/r128/r128_irq.c
35715 +++ b/drivers/gpu/drm/r128/r128_irq.c
35716 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
35717 if (crtc != 0)
35718 return 0;
35719
35720 - return atomic_read(&dev_priv->vbl_received);
35721 + return atomic_read_unchecked(&dev_priv->vbl_received);
35722 }
35723
35724 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35725 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
35726 /* VBLANK interrupt */
35727 if (status & R128_CRTC_VBLANK_INT) {
35728 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
35729 - atomic_inc(&dev_priv->vbl_received);
35730 + atomic_inc_unchecked(&dev_priv->vbl_received);
35731 drm_handle_vblank(dev, 0);
35732 return IRQ_HANDLED;
35733 }
35734 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
35735 index 19bb7e6..de7e2a2 100644
35736 --- a/drivers/gpu/drm/r128/r128_state.c
35737 +++ b/drivers/gpu/drm/r128/r128_state.c
35738 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
35739
35740 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
35741 {
35742 - if (atomic_read(&dev_priv->idle_count) == 0)
35743 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
35744 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
35745 else
35746 - atomic_set(&dev_priv->idle_count, 0);
35747 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35748 }
35749
35750 #endif
35751 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
35752 index 5a82b6b..9e69c73 100644
35753 --- a/drivers/gpu/drm/radeon/mkregtable.c
35754 +++ b/drivers/gpu/drm/radeon/mkregtable.c
35755 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
35756 regex_t mask_rex;
35757 regmatch_t match[4];
35758 char buf[1024];
35759 - size_t end;
35760 + long end;
35761 int len;
35762 int done = 0;
35763 int r;
35764 unsigned o;
35765 struct offset *offset;
35766 char last_reg_s[10];
35767 - int last_reg;
35768 + unsigned long last_reg;
35769
35770 if (regcomp
35771 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
35772 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
35773 index 44b8034..cc722fd 100644
35774 --- a/drivers/gpu/drm/radeon/radeon_device.c
35775 +++ b/drivers/gpu/drm/radeon/radeon_device.c
35776 @@ -977,7 +977,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
35777 bool can_switch;
35778
35779 spin_lock(&dev->count_lock);
35780 - can_switch = (dev->open_count == 0);
35781 + can_switch = (local_read(&dev->open_count) == 0);
35782 spin_unlock(&dev->count_lock);
35783 return can_switch;
35784 }
35785 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
35786 index b369d42..8dd04eb 100644
35787 --- a/drivers/gpu/drm/radeon/radeon_drv.h
35788 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
35789 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
35790
35791 /* SW interrupt */
35792 wait_queue_head_t swi_queue;
35793 - atomic_t swi_emitted;
35794 + atomic_unchecked_t swi_emitted;
35795 int vblank_crtc;
35796 uint32_t irq_enable_reg;
35797 uint32_t r500_disp_irq_reg;
35798 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
35799 index c180df8..5fd8186 100644
35800 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
35801 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
35802 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35803 request = compat_alloc_user_space(sizeof(*request));
35804 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
35805 || __put_user(req32.param, &request->param)
35806 - || __put_user((void __user *)(unsigned long)req32.value,
35807 + || __put_user((unsigned long)req32.value,
35808 &request->value))
35809 return -EFAULT;
35810
35811 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
35812 #define compat_radeon_cp_setparam NULL
35813 #endif /* X86_64 || IA64 */
35814
35815 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35816 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
35817 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
35818 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
35819 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
35820 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
35821 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35822 {
35823 unsigned int nr = DRM_IOCTL_NR(cmd);
35824 - drm_ioctl_compat_t *fn = NULL;
35825 int ret;
35826
35827 if (nr < DRM_COMMAND_BASE)
35828 return drm_compat_ioctl(filp, cmd, arg);
35829
35830 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
35831 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35832 -
35833 - if (fn != NULL)
35834 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
35835 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
35836 ret = (*fn) (filp, cmd, arg);
35837 - else
35838 + } else
35839 ret = drm_ioctl(filp, cmd, arg);
35840
35841 return ret;
35842 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
35843 index 8d68e97..9dcfed8 100644
35844 --- a/drivers/gpu/drm/radeon/radeon_irq.c
35845 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
35846 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
35847 unsigned int ret;
35848 RING_LOCALS;
35849
35850 - atomic_inc(&dev_priv->swi_emitted);
35851 - ret = atomic_read(&dev_priv->swi_emitted);
35852 + atomic_inc_unchecked(&dev_priv->swi_emitted);
35853 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
35854
35855 BEGIN_RING(4);
35856 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
35857 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
35858 drm_radeon_private_t *dev_priv =
35859 (drm_radeon_private_t *) dev->dev_private;
35860
35861 - atomic_set(&dev_priv->swi_emitted, 0);
35862 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
35863 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
35864
35865 dev->max_vblank_count = 0x001fffff;
35866 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
35867 index 4d20910..6726b6d 100644
35868 --- a/drivers/gpu/drm/radeon/radeon_state.c
35869 +++ b/drivers/gpu/drm/radeon/radeon_state.c
35870 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
35871 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
35872 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
35873
35874 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
35875 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
35876 sarea_priv->nbox * sizeof(depth_boxes[0])))
35877 return -EFAULT;
35878
35879 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
35880 {
35881 drm_radeon_private_t *dev_priv = dev->dev_private;
35882 drm_radeon_getparam_t *param = data;
35883 - int value;
35884 + int value = 0;
35885
35886 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
35887
35888 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
35889 index 6c0ce89..66f6d65 100644
35890 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
35891 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
35892 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
35893 man->size = size >> PAGE_SHIFT;
35894 }
35895
35896 -static struct vm_operations_struct radeon_ttm_vm_ops;
35897 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
35898 static const struct vm_operations_struct *ttm_vm_ops = NULL;
35899
35900 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
35901 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
35902 }
35903 if (unlikely(ttm_vm_ops == NULL)) {
35904 ttm_vm_ops = vma->vm_ops;
35905 + pax_open_kernel();
35906 radeon_ttm_vm_ops = *ttm_vm_ops;
35907 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
35908 + pax_close_kernel();
35909 }
35910 vma->vm_ops = &radeon_ttm_vm_ops;
35911 return 0;
35912 @@ -862,28 +864,33 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
35913 sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
35914 else
35915 sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
35916 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35917 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
35918 - radeon_mem_types_list[i].driver_features = 0;
35919 + pax_open_kernel();
35920 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35921 + *(void **)&radeon_mem_types_list[i].show = &radeon_mm_dump_table;
35922 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35923 if (i == 0)
35924 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
35925 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
35926 else
35927 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
35928 -
35929 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
35930 + pax_close_kernel();
35931 }
35932 /* Add ttm page pool to debugfs */
35933 sprintf(radeon_mem_types_names[i], "ttm_page_pool");
35934 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35935 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
35936 - radeon_mem_types_list[i].driver_features = 0;
35937 - radeon_mem_types_list[i++].data = NULL;
35938 + pax_open_kernel();
35939 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35940 + *(void **)&radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
35941 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35942 + *(void **)&radeon_mem_types_list[i++].data = NULL;
35943 + pax_close_kernel();
35944 #ifdef CONFIG_SWIOTLB
35945 if (swiotlb_nr_tbl()) {
35946 sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
35947 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35948 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
35949 - radeon_mem_types_list[i].driver_features = 0;
35950 - radeon_mem_types_list[i++].data = NULL;
35951 + pax_open_kernel();
35952 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
35953 + *(void **)&radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
35954 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
35955 + *(void **)&radeon_mem_types_list[i++].data = NULL;
35956 + pax_close_kernel();
35957 }
35958 #endif
35959 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
35960 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
35961 index 5706d2a..17aedaa 100644
35962 --- a/drivers/gpu/drm/radeon/rs690.c
35963 +++ b/drivers/gpu/drm/radeon/rs690.c
35964 @@ -304,9 +304,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
35965 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
35966 rdev->pm.sideport_bandwidth.full)
35967 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
35968 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
35969 + read_delay_latency.full = dfixed_const(800 * 1000);
35970 read_delay_latency.full = dfixed_div(read_delay_latency,
35971 rdev->pm.igp_sideport_mclk);
35972 + a.full = dfixed_const(370);
35973 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
35974 } else {
35975 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
35976 rdev->pm.k8_bandwidth.full)
35977 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
35978 index bd2a3b4..122d9ad 100644
35979 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
35980 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
35981 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
35982 static int ttm_pool_mm_shrink(struct shrinker *shrink,
35983 struct shrink_control *sc)
35984 {
35985 - static atomic_t start_pool = ATOMIC_INIT(0);
35986 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
35987 unsigned i;
35988 - unsigned pool_offset = atomic_add_return(1, &start_pool);
35989 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
35990 struct ttm_page_pool *pool;
35991 int shrink_pages = sc->nr_to_scan;
35992
35993 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
35994 index 9f4be3d..cbc9fcc 100644
35995 --- a/drivers/gpu/drm/udl/udl_fb.c
35996 +++ b/drivers/gpu/drm/udl/udl_fb.c
35997 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
35998 fb_deferred_io_cleanup(info);
35999 kfree(info->fbdefio);
36000 info->fbdefio = NULL;
36001 - info->fbops->fb_mmap = udl_fb_mmap;
36002 }
36003
36004 pr_warn("released /dev/fb%d user=%d count=%d\n",
36005 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
36006 index 893a650..6190d3b 100644
36007 --- a/drivers/gpu/drm/via/via_drv.h
36008 +++ b/drivers/gpu/drm/via/via_drv.h
36009 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
36010 typedef uint32_t maskarray_t[5];
36011
36012 typedef struct drm_via_irq {
36013 - atomic_t irq_received;
36014 + atomic_unchecked_t irq_received;
36015 uint32_t pending_mask;
36016 uint32_t enable_mask;
36017 wait_queue_head_t irq_queue;
36018 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
36019 struct timeval last_vblank;
36020 int last_vblank_valid;
36021 unsigned usec_per_vblank;
36022 - atomic_t vbl_received;
36023 + atomic_unchecked_t vbl_received;
36024 drm_via_state_t hc_state;
36025 char pci_buf[VIA_PCI_BUF_SIZE];
36026 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
36027 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
36028 index ac98964..5dbf512 100644
36029 --- a/drivers/gpu/drm/via/via_irq.c
36030 +++ b/drivers/gpu/drm/via/via_irq.c
36031 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
36032 if (crtc != 0)
36033 return 0;
36034
36035 - return atomic_read(&dev_priv->vbl_received);
36036 + return atomic_read_unchecked(&dev_priv->vbl_received);
36037 }
36038
36039 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36040 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36041
36042 status = VIA_READ(VIA_REG_INTERRUPT);
36043 if (status & VIA_IRQ_VBLANK_PENDING) {
36044 - atomic_inc(&dev_priv->vbl_received);
36045 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
36046 + atomic_inc_unchecked(&dev_priv->vbl_received);
36047 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
36048 do_gettimeofday(&cur_vblank);
36049 if (dev_priv->last_vblank_valid) {
36050 dev_priv->usec_per_vblank =
36051 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36052 dev_priv->last_vblank = cur_vblank;
36053 dev_priv->last_vblank_valid = 1;
36054 }
36055 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
36056 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
36057 DRM_DEBUG("US per vblank is: %u\n",
36058 dev_priv->usec_per_vblank);
36059 }
36060 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36061
36062 for (i = 0; i < dev_priv->num_irqs; ++i) {
36063 if (status & cur_irq->pending_mask) {
36064 - atomic_inc(&cur_irq->irq_received);
36065 + atomic_inc_unchecked(&cur_irq->irq_received);
36066 DRM_WAKEUP(&cur_irq->irq_queue);
36067 handled = 1;
36068 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
36069 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
36070 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36071 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
36072 masks[irq][4]));
36073 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
36074 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
36075 } else {
36076 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36077 (((cur_irq_sequence =
36078 - atomic_read(&cur_irq->irq_received)) -
36079 + atomic_read_unchecked(&cur_irq->irq_received)) -
36080 *sequence) <= (1 << 23)));
36081 }
36082 *sequence = cur_irq_sequence;
36083 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
36084 }
36085
36086 for (i = 0; i < dev_priv->num_irqs; ++i) {
36087 - atomic_set(&cur_irq->irq_received, 0);
36088 + atomic_set_unchecked(&cur_irq->irq_received, 0);
36089 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
36090 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
36091 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
36092 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
36093 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
36094 case VIA_IRQ_RELATIVE:
36095 irqwait->request.sequence +=
36096 - atomic_read(&cur_irq->irq_received);
36097 + atomic_read_unchecked(&cur_irq->irq_received);
36098 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
36099 case VIA_IRQ_ABSOLUTE:
36100 break;
36101 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36102 index 13aeda7..4a952d1 100644
36103 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36104 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36105 @@ -290,7 +290,7 @@ struct vmw_private {
36106 * Fencing and IRQs.
36107 */
36108
36109 - atomic_t marker_seq;
36110 + atomic_unchecked_t marker_seq;
36111 wait_queue_head_t fence_queue;
36112 wait_queue_head_t fifo_queue;
36113 int fence_queue_waiters; /* Protected by hw_mutex */
36114 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36115 index 3eb1486..0a47ee9 100644
36116 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36117 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36118 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
36119 (unsigned int) min,
36120 (unsigned int) fifo->capabilities);
36121
36122 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36123 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36124 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
36125 vmw_marker_queue_init(&fifo->marker_queue);
36126 return vmw_fifo_send_fence(dev_priv, &dummy);
36127 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
36128 if (reserveable)
36129 iowrite32(bytes, fifo_mem +
36130 SVGA_FIFO_RESERVED);
36131 - return fifo_mem + (next_cmd >> 2);
36132 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
36133 } else {
36134 need_bounce = true;
36135 }
36136 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36137
36138 fm = vmw_fifo_reserve(dev_priv, bytes);
36139 if (unlikely(fm == NULL)) {
36140 - *seqno = atomic_read(&dev_priv->marker_seq);
36141 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36142 ret = -ENOMEM;
36143 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
36144 false, 3*HZ);
36145 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36146 }
36147
36148 do {
36149 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36150 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36151 } while (*seqno == 0);
36152
36153 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36154 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36155 index c509d40..3b640c3 100644
36156 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36157 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36158 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
36159 int ret;
36160
36161 num_clips = arg->num_clips;
36162 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36163 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36164
36165 if (unlikely(num_clips == 0))
36166 return 0;
36167 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
36168 int ret;
36169
36170 num_clips = arg->num_clips;
36171 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36172 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36173
36174 if (unlikely(num_clips == 0))
36175 return 0;
36176 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36177 index 4640adb..e1384ed 100644
36178 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36179 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36180 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
36181 * emitted. Then the fence is stale and signaled.
36182 */
36183
36184 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
36185 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
36186 > VMW_FENCE_WRAP);
36187
36188 return ret;
36189 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36190
36191 if (fifo_idle)
36192 down_read(&fifo_state->rwsem);
36193 - signal_seq = atomic_read(&dev_priv->marker_seq);
36194 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36195 ret = 0;
36196
36197 for (;;) {
36198 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36199 index 8a8725c2..afed796 100644
36200 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36201 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36202 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36203 while (!vmw_lag_lt(queue, us)) {
36204 spin_lock(&queue->lock);
36205 if (list_empty(&queue->head))
36206 - seqno = atomic_read(&dev_priv->marker_seq);
36207 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36208 else {
36209 marker = list_first_entry(&queue->head,
36210 struct vmw_marker, head);
36211 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36212 index e6dbf09..3dd2540 100644
36213 --- a/drivers/hid/hid-core.c
36214 +++ b/drivers/hid/hid-core.c
36215 @@ -2268,7 +2268,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36216
36217 int hid_add_device(struct hid_device *hdev)
36218 {
36219 - static atomic_t id = ATOMIC_INIT(0);
36220 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36221 int ret;
36222
36223 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36224 @@ -2302,7 +2302,7 @@ int hid_add_device(struct hid_device *hdev)
36225 /* XXX hack, any other cleaner solution after the driver core
36226 * is converted to allow more than 20 bytes as the device name? */
36227 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36228 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36229 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36230
36231 hid_debug_register(hdev, dev_name(&hdev->dev));
36232 ret = device_add(&hdev->dev);
36233 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36234 index 90124ff..3761764 100644
36235 --- a/drivers/hid/hid-wiimote-debug.c
36236 +++ b/drivers/hid/hid-wiimote-debug.c
36237 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36238 else if (size == 0)
36239 return -EIO;
36240
36241 - if (copy_to_user(u, buf, size))
36242 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36243 return -EFAULT;
36244
36245 *off += size;
36246 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36247 index 0b122f8..b1d8160 100644
36248 --- a/drivers/hv/channel.c
36249 +++ b/drivers/hv/channel.c
36250 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36251 int ret = 0;
36252 int t;
36253
36254 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36255 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36256 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36257 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36258
36259 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36260 if (ret)
36261 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36262 index 7311589..861e9ef 100644
36263 --- a/drivers/hv/hv.c
36264 +++ b/drivers/hv/hv.c
36265 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36266 u64 output_address = (output) ? virt_to_phys(output) : 0;
36267 u32 output_address_hi = output_address >> 32;
36268 u32 output_address_lo = output_address & 0xFFFFFFFF;
36269 - void *hypercall_page = hv_context.hypercall_page;
36270 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36271
36272 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36273 "=a"(hv_status_lo) : "d" (control_hi),
36274 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36275 index 12f2f9e..679603c 100644
36276 --- a/drivers/hv/hyperv_vmbus.h
36277 +++ b/drivers/hv/hyperv_vmbus.h
36278 @@ -591,7 +591,7 @@ enum vmbus_connect_state {
36279 struct vmbus_connection {
36280 enum vmbus_connect_state conn_state;
36281
36282 - atomic_t next_gpadl_handle;
36283 + atomic_unchecked_t next_gpadl_handle;
36284
36285 /*
36286 * Represents channel interrupts. Each bit position represents a
36287 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36288 index bf421e0..ce2c897 100644
36289 --- a/drivers/hv/vmbus_drv.c
36290 +++ b/drivers/hv/vmbus_drv.c
36291 @@ -668,10 +668,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36292 {
36293 int ret = 0;
36294
36295 - static atomic_t device_num = ATOMIC_INIT(0);
36296 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36297
36298 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36299 - atomic_inc_return(&device_num));
36300 + atomic_inc_return_unchecked(&device_num));
36301
36302 child_device_obj->device.bus = &hv_bus;
36303 child_device_obj->device.parent = &hv_acpi_dev->dev;
36304 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36305 index 6351aba..dc4aaf4 100644
36306 --- a/drivers/hwmon/acpi_power_meter.c
36307 +++ b/drivers/hwmon/acpi_power_meter.c
36308 @@ -117,7 +117,7 @@ struct sensor_template {
36309 struct device_attribute *devattr,
36310 const char *buf, size_t count);
36311 int index;
36312 -};
36313 +} __do_const;
36314
36315 /* Averaging interval */
36316 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36317 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36318 struct sensor_template *attrs)
36319 {
36320 struct device *dev = &resource->acpi_dev->dev;
36321 - struct sensor_device_attribute *sensors =
36322 + sensor_device_attribute_no_const *sensors =
36323 &resource->sensors[resource->num_sensors];
36324 int res = 0;
36325
36326 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36327 index b41baff..4953e4d 100644
36328 --- a/drivers/hwmon/applesmc.c
36329 +++ b/drivers/hwmon/applesmc.c
36330 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36331 {
36332 struct applesmc_node_group *grp;
36333 struct applesmc_dev_attr *node;
36334 - struct attribute *attr;
36335 + attribute_no_const *attr;
36336 int ret, i;
36337
36338 for (grp = groups; grp->format; grp++) {
36339 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36340 index b25c643..a13460d 100644
36341 --- a/drivers/hwmon/asus_atk0110.c
36342 +++ b/drivers/hwmon/asus_atk0110.c
36343 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36344 struct atk_sensor_data {
36345 struct list_head list;
36346 struct atk_data *data;
36347 - struct device_attribute label_attr;
36348 - struct device_attribute input_attr;
36349 - struct device_attribute limit1_attr;
36350 - struct device_attribute limit2_attr;
36351 + device_attribute_no_const label_attr;
36352 + device_attribute_no_const input_attr;
36353 + device_attribute_no_const limit1_attr;
36354 + device_attribute_no_const limit2_attr;
36355 char label_attr_name[ATTR_NAME_SIZE];
36356 char input_attr_name[ATTR_NAME_SIZE];
36357 char limit1_attr_name[ATTR_NAME_SIZE];
36358 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36359 static struct device_attribute atk_name_attr =
36360 __ATTR(name, 0444, atk_name_show, NULL);
36361
36362 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36363 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36364 sysfs_show_func show)
36365 {
36366 sysfs_attr_init(&attr->attr);
36367 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36368 index 3f1e297..a6cafb5 100644
36369 --- a/drivers/hwmon/coretemp.c
36370 +++ b/drivers/hwmon/coretemp.c
36371 @@ -791,7 +791,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36372 return NOTIFY_OK;
36373 }
36374
36375 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36376 +static struct notifier_block coretemp_cpu_notifier = {
36377 .notifier_call = coretemp_cpu_callback,
36378 };
36379
36380 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36381 index a14f634..2916ee2 100644
36382 --- a/drivers/hwmon/ibmaem.c
36383 +++ b/drivers/hwmon/ibmaem.c
36384 @@ -925,7 +925,7 @@ static int aem_register_sensors(struct aem_data *data,
36385 struct aem_rw_sensor_template *rw)
36386 {
36387 struct device *dev = &data->pdev->dev;
36388 - struct sensor_device_attribute *sensors = data->sensors;
36389 + sensor_device_attribute_no_const *sensors = data->sensors;
36390 int err;
36391
36392 /* Set up read-only sensors */
36393 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36394 index 9add6092..ee7ba3f 100644
36395 --- a/drivers/hwmon/pmbus/pmbus_core.c
36396 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36397 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
36398 return 0;
36399 }
36400
36401 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36402 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
36403 const char *name,
36404 umode_t mode,
36405 ssize_t (*show)(struct device *dev,
36406 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36407 dev_attr->store = store;
36408 }
36409
36410 -static void pmbus_attr_init(struct sensor_device_attribute *a,
36411 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
36412 const char *name,
36413 umode_t mode,
36414 ssize_t (*show)(struct device *dev,
36415 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
36416 u16 reg, u8 mask)
36417 {
36418 struct pmbus_boolean *boolean;
36419 - struct sensor_device_attribute *a;
36420 + sensor_device_attribute_no_const *a;
36421
36422 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
36423 if (!boolean)
36424 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
36425 bool update, bool readonly)
36426 {
36427 struct pmbus_sensor *sensor;
36428 - struct device_attribute *a;
36429 + device_attribute_no_const *a;
36430
36431 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
36432 if (!sensor)
36433 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
36434 const char *lstring, int index)
36435 {
36436 struct pmbus_label *label;
36437 - struct device_attribute *a;
36438 + device_attribute_no_const *a;
36439
36440 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
36441 if (!label)
36442 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36443 index 2507f90..1645765 100644
36444 --- a/drivers/hwmon/sht15.c
36445 +++ b/drivers/hwmon/sht15.c
36446 @@ -169,7 +169,7 @@ struct sht15_data {
36447 int supply_uv;
36448 bool supply_uv_valid;
36449 struct work_struct update_supply_work;
36450 - atomic_t interrupt_handled;
36451 + atomic_unchecked_t interrupt_handled;
36452 };
36453
36454 /**
36455 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
36456 ret = gpio_direction_input(data->pdata->gpio_data);
36457 if (ret)
36458 return ret;
36459 - atomic_set(&data->interrupt_handled, 0);
36460 + atomic_set_unchecked(&data->interrupt_handled, 0);
36461
36462 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36463 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36464 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36465 /* Only relevant if the interrupt hasn't occurred. */
36466 - if (!atomic_read(&data->interrupt_handled))
36467 + if (!atomic_read_unchecked(&data->interrupt_handled))
36468 schedule_work(&data->read_work);
36469 }
36470 ret = wait_event_timeout(data->wait_queue,
36471 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36472
36473 /* First disable the interrupt */
36474 disable_irq_nosync(irq);
36475 - atomic_inc(&data->interrupt_handled);
36476 + atomic_inc_unchecked(&data->interrupt_handled);
36477 /* Then schedule a reading work struct */
36478 if (data->state != SHT15_READING_NOTHING)
36479 schedule_work(&data->read_work);
36480 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36481 * If not, then start the interrupt again - care here as could
36482 * have gone low in meantime so verify it hasn't!
36483 */
36484 - atomic_set(&data->interrupt_handled, 0);
36485 + atomic_set_unchecked(&data->interrupt_handled, 0);
36486 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36487 /* If still not occurred or another handler was scheduled */
36488 if (gpio_get_value(data->pdata->gpio_data)
36489 - || atomic_read(&data->interrupt_handled))
36490 + || atomic_read_unchecked(&data->interrupt_handled))
36491 return;
36492 }
36493
36494 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36495 index 76f157b..9c0db1b 100644
36496 --- a/drivers/hwmon/via-cputemp.c
36497 +++ b/drivers/hwmon/via-cputemp.c
36498 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36499 return NOTIFY_OK;
36500 }
36501
36502 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36503 +static struct notifier_block via_cputemp_cpu_notifier = {
36504 .notifier_call = via_cputemp_cpu_callback,
36505 };
36506
36507 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36508 index 378fcb5..5e91fa8 100644
36509 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36510 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36511 @@ -43,7 +43,7 @@
36512 extern struct i2c_adapter amd756_smbus;
36513
36514 static struct i2c_adapter *s4882_adapter;
36515 -static struct i2c_algorithm *s4882_algo;
36516 +static i2c_algorithm_no_const *s4882_algo;
36517
36518 /* Wrapper access functions for multiplexed SMBus */
36519 static DEFINE_MUTEX(amd756_lock);
36520 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36521 index 29015eb..af2d8e9 100644
36522 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36523 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36524 @@ -41,7 +41,7 @@
36525 extern struct i2c_adapter *nforce2_smbus;
36526
36527 static struct i2c_adapter *s4985_adapter;
36528 -static struct i2c_algorithm *s4985_algo;
36529 +static i2c_algorithm_no_const *s4985_algo;
36530
36531 /* Wrapper access functions for multiplexed SMBus */
36532 static DEFINE_MUTEX(nforce2_lock);
36533 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
36534 index c3ccdea..5b3dc1a 100644
36535 --- a/drivers/i2c/i2c-dev.c
36536 +++ b/drivers/i2c/i2c-dev.c
36537 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
36538 break;
36539 }
36540
36541 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
36542 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
36543 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
36544 if (IS_ERR(rdwr_pa[i].buf)) {
36545 res = PTR_ERR(rdwr_pa[i].buf);
36546 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
36547 index 8126824..55a2798 100644
36548 --- a/drivers/ide/ide-cd.c
36549 +++ b/drivers/ide/ide-cd.c
36550 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
36551 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
36552 if ((unsigned long)buf & alignment
36553 || blk_rq_bytes(rq) & q->dma_pad_mask
36554 - || object_is_on_stack(buf))
36555 + || object_starts_on_stack(buf))
36556 drive->dma = 0;
36557 }
36558 }
36559 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
36560 index 8848f16..f8e6dd8 100644
36561 --- a/drivers/iio/industrialio-core.c
36562 +++ b/drivers/iio/industrialio-core.c
36563 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
36564 }
36565
36566 static
36567 -int __iio_device_attr_init(struct device_attribute *dev_attr,
36568 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
36569 const char *postfix,
36570 struct iio_chan_spec const *chan,
36571 ssize_t (*readfunc)(struct device *dev,
36572 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
36573 index 784b97c..c9ceadf 100644
36574 --- a/drivers/infiniband/core/cm.c
36575 +++ b/drivers/infiniband/core/cm.c
36576 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
36577
36578 struct cm_counter_group {
36579 struct kobject obj;
36580 - atomic_long_t counter[CM_ATTR_COUNT];
36581 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
36582 };
36583
36584 struct cm_counter_attribute {
36585 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
36586 struct ib_mad_send_buf *msg = NULL;
36587 int ret;
36588
36589 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36590 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36591 counter[CM_REQ_COUNTER]);
36592
36593 /* Quick state check to discard duplicate REQs. */
36594 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
36595 if (!cm_id_priv)
36596 return;
36597
36598 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36599 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36600 counter[CM_REP_COUNTER]);
36601 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
36602 if (ret)
36603 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
36604 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
36605 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
36606 spin_unlock_irq(&cm_id_priv->lock);
36607 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36608 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36609 counter[CM_RTU_COUNTER]);
36610 goto out;
36611 }
36612 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
36613 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
36614 dreq_msg->local_comm_id);
36615 if (!cm_id_priv) {
36616 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36617 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36618 counter[CM_DREQ_COUNTER]);
36619 cm_issue_drep(work->port, work->mad_recv_wc);
36620 return -EINVAL;
36621 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
36622 case IB_CM_MRA_REP_RCVD:
36623 break;
36624 case IB_CM_TIMEWAIT:
36625 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36626 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36627 counter[CM_DREQ_COUNTER]);
36628 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36629 goto unlock;
36630 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
36631 cm_free_msg(msg);
36632 goto deref;
36633 case IB_CM_DREQ_RCVD:
36634 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36635 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36636 counter[CM_DREQ_COUNTER]);
36637 goto unlock;
36638 default:
36639 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
36640 ib_modify_mad(cm_id_priv->av.port->mad_agent,
36641 cm_id_priv->msg, timeout)) {
36642 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
36643 - atomic_long_inc(&work->port->
36644 + atomic_long_inc_unchecked(&work->port->
36645 counter_group[CM_RECV_DUPLICATES].
36646 counter[CM_MRA_COUNTER]);
36647 goto out;
36648 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
36649 break;
36650 case IB_CM_MRA_REQ_RCVD:
36651 case IB_CM_MRA_REP_RCVD:
36652 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36653 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36654 counter[CM_MRA_COUNTER]);
36655 /* fall through */
36656 default:
36657 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
36658 case IB_CM_LAP_IDLE:
36659 break;
36660 case IB_CM_MRA_LAP_SENT:
36661 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36662 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36663 counter[CM_LAP_COUNTER]);
36664 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36665 goto unlock;
36666 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
36667 cm_free_msg(msg);
36668 goto deref;
36669 case IB_CM_LAP_RCVD:
36670 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36671 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36672 counter[CM_LAP_COUNTER]);
36673 goto unlock;
36674 default:
36675 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
36676 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
36677 if (cur_cm_id_priv) {
36678 spin_unlock_irq(&cm.lock);
36679 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36680 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36681 counter[CM_SIDR_REQ_COUNTER]);
36682 goto out; /* Duplicate message. */
36683 }
36684 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
36685 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
36686 msg->retries = 1;
36687
36688 - atomic_long_add(1 + msg->retries,
36689 + atomic_long_add_unchecked(1 + msg->retries,
36690 &port->counter_group[CM_XMIT].counter[attr_index]);
36691 if (msg->retries)
36692 - atomic_long_add(msg->retries,
36693 + atomic_long_add_unchecked(msg->retries,
36694 &port->counter_group[CM_XMIT_RETRIES].
36695 counter[attr_index]);
36696
36697 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
36698 }
36699
36700 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
36701 - atomic_long_inc(&port->counter_group[CM_RECV].
36702 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
36703 counter[attr_id - CM_ATTR_ID_OFFSET]);
36704
36705 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
36706 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
36707 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
36708
36709 return sprintf(buf, "%ld\n",
36710 - atomic_long_read(&group->counter[cm_attr->index]));
36711 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
36712 }
36713
36714 static const struct sysfs_ops cm_counter_ops = {
36715 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
36716 index 9f5ad7c..588cd84 100644
36717 --- a/drivers/infiniband/core/fmr_pool.c
36718 +++ b/drivers/infiniband/core/fmr_pool.c
36719 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
36720
36721 struct task_struct *thread;
36722
36723 - atomic_t req_ser;
36724 - atomic_t flush_ser;
36725 + atomic_unchecked_t req_ser;
36726 + atomic_unchecked_t flush_ser;
36727
36728 wait_queue_head_t force_wait;
36729 };
36730 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36731 struct ib_fmr_pool *pool = pool_ptr;
36732
36733 do {
36734 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
36735 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
36736 ib_fmr_batch_release(pool);
36737
36738 - atomic_inc(&pool->flush_ser);
36739 + atomic_inc_unchecked(&pool->flush_ser);
36740 wake_up_interruptible(&pool->force_wait);
36741
36742 if (pool->flush_function)
36743 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36744 }
36745
36746 set_current_state(TASK_INTERRUPTIBLE);
36747 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
36748 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
36749 !kthread_should_stop())
36750 schedule();
36751 __set_current_state(TASK_RUNNING);
36752 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
36753 pool->dirty_watermark = params->dirty_watermark;
36754 pool->dirty_len = 0;
36755 spin_lock_init(&pool->pool_lock);
36756 - atomic_set(&pool->req_ser, 0);
36757 - atomic_set(&pool->flush_ser, 0);
36758 + atomic_set_unchecked(&pool->req_ser, 0);
36759 + atomic_set_unchecked(&pool->flush_ser, 0);
36760 init_waitqueue_head(&pool->force_wait);
36761
36762 pool->thread = kthread_run(ib_fmr_cleanup_thread,
36763 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
36764 }
36765 spin_unlock_irq(&pool->pool_lock);
36766
36767 - serial = atomic_inc_return(&pool->req_ser);
36768 + serial = atomic_inc_return_unchecked(&pool->req_ser);
36769 wake_up_process(pool->thread);
36770
36771 if (wait_event_interruptible(pool->force_wait,
36772 - atomic_read(&pool->flush_ser) - serial >= 0))
36773 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
36774 return -EINTR;
36775
36776 return 0;
36777 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
36778 } else {
36779 list_add_tail(&fmr->list, &pool->dirty_list);
36780 if (++pool->dirty_len >= pool->dirty_watermark) {
36781 - atomic_inc(&pool->req_ser);
36782 + atomic_inc_unchecked(&pool->req_ser);
36783 wake_up_process(pool->thread);
36784 }
36785 }
36786 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
36787 index 903a92d..9262548 100644
36788 --- a/drivers/infiniband/hw/cxgb4/mem.c
36789 +++ b/drivers/infiniband/hw/cxgb4/mem.c
36790 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36791 int err;
36792 struct fw_ri_tpte tpt;
36793 u32 stag_idx;
36794 - static atomic_t key;
36795 + static atomic_unchecked_t key;
36796
36797 if (c4iw_fatal_error(rdev))
36798 return -EIO;
36799 @@ -139,7 +139,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36800 if (rdev->stats.stag.cur > rdev->stats.stag.max)
36801 rdev->stats.stag.max = rdev->stats.stag.cur;
36802 mutex_unlock(&rdev->stats.lock);
36803 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
36804 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
36805 }
36806 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
36807 __func__, stag_state, type, pdid, stag_idx);
36808 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
36809 index 79b3dbc..96e5fcc 100644
36810 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
36811 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
36812 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36813 struct ib_atomic_eth *ateth;
36814 struct ipath_ack_entry *e;
36815 u64 vaddr;
36816 - atomic64_t *maddr;
36817 + atomic64_unchecked_t *maddr;
36818 u64 sdata;
36819 u32 rkey;
36820 u8 next;
36821 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
36822 IB_ACCESS_REMOTE_ATOMIC)))
36823 goto nack_acc_unlck;
36824 /* Perform atomic OP and save result. */
36825 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
36826 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
36827 sdata = be64_to_cpu(ateth->swap_data);
36828 e = &qp->s_ack_queue[qp->r_head_ack_queue];
36829 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
36830 - (u64) atomic64_add_return(sdata, maddr) - sdata :
36831 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
36832 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
36833 be64_to_cpu(ateth->compare_data),
36834 sdata);
36835 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
36836 index 1f95bba..9530f87 100644
36837 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
36838 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
36839 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
36840 unsigned long flags;
36841 struct ib_wc wc;
36842 u64 sdata;
36843 - atomic64_t *maddr;
36844 + atomic64_unchecked_t *maddr;
36845 enum ib_wc_status send_status;
36846
36847 /*
36848 @@ -382,11 +382,11 @@ again:
36849 IB_ACCESS_REMOTE_ATOMIC)))
36850 goto acc_err;
36851 /* Perform atomic OP and save result. */
36852 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
36853 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
36854 sdata = wqe->wr.wr.atomic.compare_add;
36855 *(u64 *) sqp->s_sge.sge.vaddr =
36856 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
36857 - (u64) atomic64_add_return(sdata, maddr) - sdata :
36858 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
36859 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
36860 sdata, wqe->wr.wr.atomic.swap);
36861 goto send_comp;
36862 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
36863 index 9d3e5c1..d9afe4a 100644
36864 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
36865 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
36866 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
36867 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
36868 }
36869
36870 -int mthca_QUERY_FW(struct mthca_dev *dev)
36871 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
36872 {
36873 struct mthca_mailbox *mailbox;
36874 u32 *outbox;
36875 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
36876 index ed9a989..e0c5871 100644
36877 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
36878 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
36879 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
36880 return key;
36881 }
36882
36883 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
36884 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
36885 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
36886 {
36887 struct mthca_mailbox *mailbox;
36888 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
36889 index 4291410..d2ab1fb 100644
36890 --- a/drivers/infiniband/hw/nes/nes.c
36891 +++ b/drivers/infiniband/hw/nes/nes.c
36892 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
36893 LIST_HEAD(nes_adapter_list);
36894 static LIST_HEAD(nes_dev_list);
36895
36896 -atomic_t qps_destroyed;
36897 +atomic_unchecked_t qps_destroyed;
36898
36899 static unsigned int ee_flsh_adapter;
36900 static unsigned int sysfs_nonidx_addr;
36901 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
36902 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
36903 struct nes_adapter *nesadapter = nesdev->nesadapter;
36904
36905 - atomic_inc(&qps_destroyed);
36906 + atomic_inc_unchecked(&qps_destroyed);
36907
36908 /* Free the control structures */
36909
36910 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
36911 index 33cc589..3bd6538 100644
36912 --- a/drivers/infiniband/hw/nes/nes.h
36913 +++ b/drivers/infiniband/hw/nes/nes.h
36914 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
36915 extern unsigned int wqm_quanta;
36916 extern struct list_head nes_adapter_list;
36917
36918 -extern atomic_t cm_connects;
36919 -extern atomic_t cm_accepts;
36920 -extern atomic_t cm_disconnects;
36921 -extern atomic_t cm_closes;
36922 -extern atomic_t cm_connecteds;
36923 -extern atomic_t cm_connect_reqs;
36924 -extern atomic_t cm_rejects;
36925 -extern atomic_t mod_qp_timouts;
36926 -extern atomic_t qps_created;
36927 -extern atomic_t qps_destroyed;
36928 -extern atomic_t sw_qps_destroyed;
36929 +extern atomic_unchecked_t cm_connects;
36930 +extern atomic_unchecked_t cm_accepts;
36931 +extern atomic_unchecked_t cm_disconnects;
36932 +extern atomic_unchecked_t cm_closes;
36933 +extern atomic_unchecked_t cm_connecteds;
36934 +extern atomic_unchecked_t cm_connect_reqs;
36935 +extern atomic_unchecked_t cm_rejects;
36936 +extern atomic_unchecked_t mod_qp_timouts;
36937 +extern atomic_unchecked_t qps_created;
36938 +extern atomic_unchecked_t qps_destroyed;
36939 +extern atomic_unchecked_t sw_qps_destroyed;
36940 extern u32 mh_detected;
36941 extern u32 mh_pauses_sent;
36942 extern u32 cm_packets_sent;
36943 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
36944 extern u32 cm_packets_received;
36945 extern u32 cm_packets_dropped;
36946 extern u32 cm_packets_retrans;
36947 -extern atomic_t cm_listens_created;
36948 -extern atomic_t cm_listens_destroyed;
36949 +extern atomic_unchecked_t cm_listens_created;
36950 +extern atomic_unchecked_t cm_listens_destroyed;
36951 extern u32 cm_backlog_drops;
36952 -extern atomic_t cm_loopbacks;
36953 -extern atomic_t cm_nodes_created;
36954 -extern atomic_t cm_nodes_destroyed;
36955 -extern atomic_t cm_accel_dropped_pkts;
36956 -extern atomic_t cm_resets_recvd;
36957 -extern atomic_t pau_qps_created;
36958 -extern atomic_t pau_qps_destroyed;
36959 +extern atomic_unchecked_t cm_loopbacks;
36960 +extern atomic_unchecked_t cm_nodes_created;
36961 +extern atomic_unchecked_t cm_nodes_destroyed;
36962 +extern atomic_unchecked_t cm_accel_dropped_pkts;
36963 +extern atomic_unchecked_t cm_resets_recvd;
36964 +extern atomic_unchecked_t pau_qps_created;
36965 +extern atomic_unchecked_t pau_qps_destroyed;
36966
36967 extern u32 int_mod_timer_init;
36968 extern u32 int_mod_cq_depth_256;
36969 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
36970 index 24b9f1a..00fd004 100644
36971 --- a/drivers/infiniband/hw/nes/nes_cm.c
36972 +++ b/drivers/infiniband/hw/nes/nes_cm.c
36973 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
36974 u32 cm_packets_retrans;
36975 u32 cm_packets_created;
36976 u32 cm_packets_received;
36977 -atomic_t cm_listens_created;
36978 -atomic_t cm_listens_destroyed;
36979 +atomic_unchecked_t cm_listens_created;
36980 +atomic_unchecked_t cm_listens_destroyed;
36981 u32 cm_backlog_drops;
36982 -atomic_t cm_loopbacks;
36983 -atomic_t cm_nodes_created;
36984 -atomic_t cm_nodes_destroyed;
36985 -atomic_t cm_accel_dropped_pkts;
36986 -atomic_t cm_resets_recvd;
36987 +atomic_unchecked_t cm_loopbacks;
36988 +atomic_unchecked_t cm_nodes_created;
36989 +atomic_unchecked_t cm_nodes_destroyed;
36990 +atomic_unchecked_t cm_accel_dropped_pkts;
36991 +atomic_unchecked_t cm_resets_recvd;
36992
36993 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
36994 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
36995 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
36996
36997 static struct nes_cm_core *g_cm_core;
36998
36999 -atomic_t cm_connects;
37000 -atomic_t cm_accepts;
37001 -atomic_t cm_disconnects;
37002 -atomic_t cm_closes;
37003 -atomic_t cm_connecteds;
37004 -atomic_t cm_connect_reqs;
37005 -atomic_t cm_rejects;
37006 +atomic_unchecked_t cm_connects;
37007 +atomic_unchecked_t cm_accepts;
37008 +atomic_unchecked_t cm_disconnects;
37009 +atomic_unchecked_t cm_closes;
37010 +atomic_unchecked_t cm_connecteds;
37011 +atomic_unchecked_t cm_connect_reqs;
37012 +atomic_unchecked_t cm_rejects;
37013
37014 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
37015 {
37016 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
37017 kfree(listener);
37018 listener = NULL;
37019 ret = 0;
37020 - atomic_inc(&cm_listens_destroyed);
37021 + atomic_inc_unchecked(&cm_listens_destroyed);
37022 } else {
37023 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
37024 }
37025 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
37026 cm_node->rem_mac);
37027
37028 add_hte_node(cm_core, cm_node);
37029 - atomic_inc(&cm_nodes_created);
37030 + atomic_inc_unchecked(&cm_nodes_created);
37031
37032 return cm_node;
37033 }
37034 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
37035 }
37036
37037 atomic_dec(&cm_core->node_cnt);
37038 - atomic_inc(&cm_nodes_destroyed);
37039 + atomic_inc_unchecked(&cm_nodes_destroyed);
37040 nesqp = cm_node->nesqp;
37041 if (nesqp) {
37042 nesqp->cm_node = NULL;
37043 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
37044
37045 static void drop_packet(struct sk_buff *skb)
37046 {
37047 - atomic_inc(&cm_accel_dropped_pkts);
37048 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37049 dev_kfree_skb_any(skb);
37050 }
37051
37052 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
37053 {
37054
37055 int reset = 0; /* whether to send reset in case of err.. */
37056 - atomic_inc(&cm_resets_recvd);
37057 + atomic_inc_unchecked(&cm_resets_recvd);
37058 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
37059 " refcnt=%d\n", cm_node, cm_node->state,
37060 atomic_read(&cm_node->ref_count));
37061 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
37062 rem_ref_cm_node(cm_node->cm_core, cm_node);
37063 return NULL;
37064 }
37065 - atomic_inc(&cm_loopbacks);
37066 + atomic_inc_unchecked(&cm_loopbacks);
37067 loopbackremotenode->loopbackpartner = cm_node;
37068 loopbackremotenode->tcp_cntxt.rcv_wscale =
37069 NES_CM_DEFAULT_RCV_WND_SCALE;
37070 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
37071 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
37072 else {
37073 rem_ref_cm_node(cm_core, cm_node);
37074 - atomic_inc(&cm_accel_dropped_pkts);
37075 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37076 dev_kfree_skb_any(skb);
37077 }
37078 break;
37079 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37080
37081 if ((cm_id) && (cm_id->event_handler)) {
37082 if (issue_disconn) {
37083 - atomic_inc(&cm_disconnects);
37084 + atomic_inc_unchecked(&cm_disconnects);
37085 cm_event.event = IW_CM_EVENT_DISCONNECT;
37086 cm_event.status = disconn_status;
37087 cm_event.local_addr = cm_id->local_addr;
37088 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37089 }
37090
37091 if (issue_close) {
37092 - atomic_inc(&cm_closes);
37093 + atomic_inc_unchecked(&cm_closes);
37094 nes_disconnect(nesqp, 1);
37095
37096 cm_id->provider_data = nesqp;
37097 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37098
37099 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
37100 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
37101 - atomic_inc(&cm_accepts);
37102 + atomic_inc_unchecked(&cm_accepts);
37103
37104 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
37105 netdev_refcnt_read(nesvnic->netdev));
37106 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
37107 struct nes_cm_core *cm_core;
37108 u8 *start_buff;
37109
37110 - atomic_inc(&cm_rejects);
37111 + atomic_inc_unchecked(&cm_rejects);
37112 cm_node = (struct nes_cm_node *)cm_id->provider_data;
37113 loopback = cm_node->loopbackpartner;
37114 cm_core = cm_node->cm_core;
37115 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37116 ntohl(cm_id->local_addr.sin_addr.s_addr),
37117 ntohs(cm_id->local_addr.sin_port));
37118
37119 - atomic_inc(&cm_connects);
37120 + atomic_inc_unchecked(&cm_connects);
37121 nesqp->active_conn = 1;
37122
37123 /* cache the cm_id in the qp */
37124 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
37125 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
37126 return err;
37127 }
37128 - atomic_inc(&cm_listens_created);
37129 + atomic_inc_unchecked(&cm_listens_created);
37130 }
37131
37132 cm_id->add_ref(cm_id);
37133 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
37134
37135 if (nesqp->destroyed)
37136 return;
37137 - atomic_inc(&cm_connecteds);
37138 + atomic_inc_unchecked(&cm_connecteds);
37139 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
37140 " local port 0x%04X. jiffies = %lu.\n",
37141 nesqp->hwqp.qp_id,
37142 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
37143
37144 cm_id->add_ref(cm_id);
37145 ret = cm_id->event_handler(cm_id, &cm_event);
37146 - atomic_inc(&cm_closes);
37147 + atomic_inc_unchecked(&cm_closes);
37148 cm_event.event = IW_CM_EVENT_CLOSE;
37149 cm_event.status = 0;
37150 cm_event.provider_data = cm_id->provider_data;
37151 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
37152 return;
37153 cm_id = cm_node->cm_id;
37154
37155 - atomic_inc(&cm_connect_reqs);
37156 + atomic_inc_unchecked(&cm_connect_reqs);
37157 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37158 cm_node, cm_id, jiffies);
37159
37160 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
37161 return;
37162 cm_id = cm_node->cm_id;
37163
37164 - atomic_inc(&cm_connect_reqs);
37165 + atomic_inc_unchecked(&cm_connect_reqs);
37166 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37167 cm_node, cm_id, jiffies);
37168
37169 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
37170 index 4166452..fc952c3 100644
37171 --- a/drivers/infiniband/hw/nes/nes_mgt.c
37172 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
37173 @@ -40,8 +40,8 @@
37174 #include "nes.h"
37175 #include "nes_mgt.h"
37176
37177 -atomic_t pau_qps_created;
37178 -atomic_t pau_qps_destroyed;
37179 +atomic_unchecked_t pau_qps_created;
37180 +atomic_unchecked_t pau_qps_destroyed;
37181
37182 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
37183 {
37184 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
37185 {
37186 struct sk_buff *skb;
37187 unsigned long flags;
37188 - atomic_inc(&pau_qps_destroyed);
37189 + atomic_inc_unchecked(&pau_qps_destroyed);
37190
37191 /* Free packets that have not yet been forwarded */
37192 /* Lock is acquired by skb_dequeue when removing the skb */
37193 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
37194 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
37195 skb_queue_head_init(&nesqp->pau_list);
37196 spin_lock_init(&nesqp->pau_lock);
37197 - atomic_inc(&pau_qps_created);
37198 + atomic_inc_unchecked(&pau_qps_created);
37199 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
37200 }
37201
37202 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37203 index 85cf4d1..05d8e71 100644
37204 --- a/drivers/infiniband/hw/nes/nes_nic.c
37205 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37206 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37207 target_stat_values[++index] = mh_detected;
37208 target_stat_values[++index] = mh_pauses_sent;
37209 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37210 - target_stat_values[++index] = atomic_read(&cm_connects);
37211 - target_stat_values[++index] = atomic_read(&cm_accepts);
37212 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37213 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37214 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37215 - target_stat_values[++index] = atomic_read(&cm_rejects);
37216 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37217 - target_stat_values[++index] = atomic_read(&qps_created);
37218 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37219 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37220 - target_stat_values[++index] = atomic_read(&cm_closes);
37221 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37222 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37223 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37224 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37225 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37226 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37227 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37228 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37229 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37230 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37231 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37232 target_stat_values[++index] = cm_packets_sent;
37233 target_stat_values[++index] = cm_packets_bounced;
37234 target_stat_values[++index] = cm_packets_created;
37235 target_stat_values[++index] = cm_packets_received;
37236 target_stat_values[++index] = cm_packets_dropped;
37237 target_stat_values[++index] = cm_packets_retrans;
37238 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37239 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37240 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37241 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37242 target_stat_values[++index] = cm_backlog_drops;
37243 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37244 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37245 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37246 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37247 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37248 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37249 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37250 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37251 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37252 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37253 target_stat_values[++index] = nesadapter->free_4kpbl;
37254 target_stat_values[++index] = nesadapter->free_256pbl;
37255 target_stat_values[++index] = int_mod_timer_init;
37256 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37257 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37258 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37259 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37260 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37261 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37262 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37263 }
37264
37265 /**
37266 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37267 index 8f67fe2..8960859 100644
37268 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37269 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37270 @@ -46,9 +46,9 @@
37271
37272 #include <rdma/ib_umem.h>
37273
37274 -atomic_t mod_qp_timouts;
37275 -atomic_t qps_created;
37276 -atomic_t sw_qps_destroyed;
37277 +atomic_unchecked_t mod_qp_timouts;
37278 +atomic_unchecked_t qps_created;
37279 +atomic_unchecked_t sw_qps_destroyed;
37280
37281 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37282
37283 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37284 if (init_attr->create_flags)
37285 return ERR_PTR(-EINVAL);
37286
37287 - atomic_inc(&qps_created);
37288 + atomic_inc_unchecked(&qps_created);
37289 switch (init_attr->qp_type) {
37290 case IB_QPT_RC:
37291 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37292 @@ -1465,7 +1465,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37293 struct iw_cm_event cm_event;
37294 int ret = 0;
37295
37296 - atomic_inc(&sw_qps_destroyed);
37297 + atomic_inc_unchecked(&sw_qps_destroyed);
37298 nesqp->destroyed = 1;
37299
37300 /* Blow away the connection if it exists. */
37301 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37302 index 4d11575..3e890e5 100644
37303 --- a/drivers/infiniband/hw/qib/qib.h
37304 +++ b/drivers/infiniband/hw/qib/qib.h
37305 @@ -51,6 +51,7 @@
37306 #include <linux/completion.h>
37307 #include <linux/kref.h>
37308 #include <linux/sched.h>
37309 +#include <linux/slab.h>
37310
37311 #include "qib_common.h"
37312 #include "qib_verbs.h"
37313 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37314 index da739d9..da1c7f4 100644
37315 --- a/drivers/input/gameport/gameport.c
37316 +++ b/drivers/input/gameport/gameport.c
37317 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37318 */
37319 static void gameport_init_port(struct gameport *gameport)
37320 {
37321 - static atomic_t gameport_no = ATOMIC_INIT(0);
37322 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37323
37324 __module_get(THIS_MODULE);
37325
37326 mutex_init(&gameport->drv_mutex);
37327 device_initialize(&gameport->dev);
37328 dev_set_name(&gameport->dev, "gameport%lu",
37329 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37330 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37331 gameport->dev.bus = &gameport_bus;
37332 gameport->dev.release = gameport_release_port;
37333 if (gameport->parent)
37334 diff --git a/drivers/input/input.c b/drivers/input/input.c
37335 index c044699..174d71a 100644
37336 --- a/drivers/input/input.c
37337 +++ b/drivers/input/input.c
37338 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37339 */
37340 int input_register_device(struct input_dev *dev)
37341 {
37342 - static atomic_t input_no = ATOMIC_INIT(0);
37343 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37344 struct input_devres *devres = NULL;
37345 struct input_handler *handler;
37346 unsigned int packet_size;
37347 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37348 dev->setkeycode = input_default_setkeycode;
37349
37350 dev_set_name(&dev->dev, "input%ld",
37351 - (unsigned long) atomic_inc_return(&input_no) - 1);
37352 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37353
37354 error = device_add(&dev->dev);
37355 if (error)
37356 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37357 index 04c69af..5f92d00 100644
37358 --- a/drivers/input/joystick/sidewinder.c
37359 +++ b/drivers/input/joystick/sidewinder.c
37360 @@ -30,6 +30,7 @@
37361 #include <linux/kernel.h>
37362 #include <linux/module.h>
37363 #include <linux/slab.h>
37364 +#include <linux/sched.h>
37365 #include <linux/init.h>
37366 #include <linux/input.h>
37367 #include <linux/gameport.h>
37368 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37369 index d6cbfe9..6225402 100644
37370 --- a/drivers/input/joystick/xpad.c
37371 +++ b/drivers/input/joystick/xpad.c
37372 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37373
37374 static int xpad_led_probe(struct usb_xpad *xpad)
37375 {
37376 - static atomic_t led_seq = ATOMIC_INIT(0);
37377 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37378 long led_no;
37379 struct xpad_led *led;
37380 struct led_classdev *led_cdev;
37381 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37382 if (!led)
37383 return -ENOMEM;
37384
37385 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37386 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37387
37388 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37389 led->xpad = xpad;
37390 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37391 index 2f0b39d..7370f13 100644
37392 --- a/drivers/input/mouse/psmouse.h
37393 +++ b/drivers/input/mouse/psmouse.h
37394 @@ -116,7 +116,7 @@ struct psmouse_attribute {
37395 ssize_t (*set)(struct psmouse *psmouse, void *data,
37396 const char *buf, size_t count);
37397 bool protect;
37398 -};
37399 +} __do_const;
37400 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37401
37402 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37403 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37404 index 4c842c3..590b0bf 100644
37405 --- a/drivers/input/mousedev.c
37406 +++ b/drivers/input/mousedev.c
37407 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37408
37409 spin_unlock_irq(&client->packet_lock);
37410
37411 - if (copy_to_user(buffer, data, count))
37412 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37413 return -EFAULT;
37414
37415 return count;
37416 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37417 index 25fc597..558bf3b3 100644
37418 --- a/drivers/input/serio/serio.c
37419 +++ b/drivers/input/serio/serio.c
37420 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37421 */
37422 static void serio_init_port(struct serio *serio)
37423 {
37424 - static atomic_t serio_no = ATOMIC_INIT(0);
37425 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37426
37427 __module_get(THIS_MODULE);
37428
37429 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37430 mutex_init(&serio->drv_mutex);
37431 device_initialize(&serio->dev);
37432 dev_set_name(&serio->dev, "serio%ld",
37433 - (long)atomic_inc_return(&serio_no) - 1);
37434 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37435 serio->dev.bus = &serio_bus;
37436 serio->dev.release = serio_release_port;
37437 serio->dev.groups = serio_device_attr_groups;
37438 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37439 index b972d43..8943713 100644
37440 --- a/drivers/iommu/iommu.c
37441 +++ b/drivers/iommu/iommu.c
37442 @@ -554,7 +554,7 @@ static struct notifier_block iommu_bus_nb = {
37443 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37444 {
37445 bus_register_notifier(bus, &iommu_bus_nb);
37446 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37447 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37448 }
37449
37450 /**
37451 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
37452 index 7c11ff3..5b2d7a7 100644
37453 --- a/drivers/iommu/irq_remapping.c
37454 +++ b/drivers/iommu/irq_remapping.c
37455 @@ -369,10 +369,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
37456
37457 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
37458 {
37459 - chip->irq_print_chip = ir_print_prefix;
37460 - chip->irq_ack = ir_ack_apic_edge;
37461 - chip->irq_eoi = ir_ack_apic_level;
37462 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37463 + pax_open_kernel();
37464 + *(void **)&chip->irq_print_chip = ir_print_prefix;
37465 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
37466 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
37467 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37468 + pax_close_kernel();
37469 }
37470
37471 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
37472 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
37473 index fc6aebf..762c5f5 100644
37474 --- a/drivers/irqchip/irq-gic.c
37475 +++ b/drivers/irqchip/irq-gic.c
37476 @@ -83,7 +83,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
37477 * Supported arch specific GIC irq extension.
37478 * Default make them NULL.
37479 */
37480 -struct irq_chip gic_arch_extn = {
37481 +irq_chip_no_const gic_arch_extn = {
37482 .irq_eoi = NULL,
37483 .irq_mask = NULL,
37484 .irq_unmask = NULL,
37485 @@ -332,7 +332,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
37486 chained_irq_exit(chip, desc);
37487 }
37488
37489 -static struct irq_chip gic_chip = {
37490 +static irq_chip_no_const gic_chip __read_only = {
37491 .name = "GIC",
37492 .irq_mask = gic_mask_irq,
37493 .irq_unmask = gic_unmask_irq,
37494 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37495 index 89562a8..218999b 100644
37496 --- a/drivers/isdn/capi/capi.c
37497 +++ b/drivers/isdn/capi/capi.c
37498 @@ -81,8 +81,8 @@ struct capiminor {
37499
37500 struct capi20_appl *ap;
37501 u32 ncci;
37502 - atomic_t datahandle;
37503 - atomic_t msgid;
37504 + atomic_unchecked_t datahandle;
37505 + atomic_unchecked_t msgid;
37506
37507 struct tty_port port;
37508 int ttyinstop;
37509 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37510 capimsg_setu16(s, 2, mp->ap->applid);
37511 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37512 capimsg_setu8 (s, 5, CAPI_RESP);
37513 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37514 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37515 capimsg_setu32(s, 8, mp->ncci);
37516 capimsg_setu16(s, 12, datahandle);
37517 }
37518 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
37519 mp->outbytes -= len;
37520 spin_unlock_bh(&mp->outlock);
37521
37522 - datahandle = atomic_inc_return(&mp->datahandle);
37523 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
37524 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
37525 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37526 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37527 capimsg_setu16(skb->data, 2, mp->ap->applid);
37528 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
37529 capimsg_setu8 (skb->data, 5, CAPI_REQ);
37530 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
37531 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
37532 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
37533 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
37534 capimsg_setu16(skb->data, 16, len); /* Data length */
37535 diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c
37536 index 9b1b274..c123709 100644
37537 --- a/drivers/isdn/capi/kcapi.c
37538 +++ b/drivers/isdn/capi/kcapi.c
37539 @@ -93,7 +93,7 @@ capi_ctr_put(struct capi_ctr *ctr)
37540
37541 static inline struct capi_ctr *get_capi_ctr_by_nr(u16 contr)
37542 {
37543 - if (contr - 1 >= CAPI_MAXCONTR)
37544 + if (contr < 1 || contr - 1 >= CAPI_MAXCONTR)
37545 return NULL;
37546
37547 return capi_controller[contr - 1];
37548 @@ -103,7 +103,7 @@ static inline struct capi20_appl *__get_capi_appl_by_nr(u16 applid)
37549 {
37550 lockdep_assert_held(&capi_controller_lock);
37551
37552 - if (applid - 1 >= CAPI_MAXAPPL)
37553 + if (applid < 1 || applid - 1 >= CAPI_MAXAPPL)
37554 return NULL;
37555
37556 return capi_applications[applid - 1];
37557 @@ -111,7 +111,7 @@ static inline struct capi20_appl *__get_capi_appl_by_nr(u16 applid)
37558
37559 static inline struct capi20_appl *get_capi_appl_by_nr(u16 applid)
37560 {
37561 - if (applid - 1 >= CAPI_MAXAPPL)
37562 + if (applid < 1 || applid - 1 >= CAPI_MAXAPPL)
37563 return NULL;
37564
37565 return rcu_dereference(capi_applications[applid - 1]);
37566 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
37567 index e2b5396..c5486dc 100644
37568 --- a/drivers/isdn/gigaset/interface.c
37569 +++ b/drivers/isdn/gigaset/interface.c
37570 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
37571 }
37572 tty->driver_data = cs;
37573
37574 - ++cs->port.count;
37575 + atomic_inc(&cs->port.count);
37576
37577 - if (cs->port.count == 1) {
37578 + if (atomic_read(&cs->port.count) == 1) {
37579 tty_port_tty_set(&cs->port, tty);
37580 cs->port.low_latency = 1;
37581 }
37582 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
37583
37584 if (!cs->connected)
37585 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
37586 - else if (!cs->port.count)
37587 + else if (!atomic_read(&cs->port.count))
37588 dev_warn(cs->dev, "%s: device not opened\n", __func__);
37589 - else if (!--cs->port.count)
37590 + else if (!atomic_dec_return(&cs->port.count))
37591 tty_port_tty_set(&cs->port, NULL);
37592
37593 mutex_unlock(&cs->mutex);
37594 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
37595 index 821f7ac..28d4030 100644
37596 --- a/drivers/isdn/hardware/avm/b1.c
37597 +++ b/drivers/isdn/hardware/avm/b1.c
37598 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
37599 }
37600 if (left) {
37601 if (t4file->user) {
37602 - if (copy_from_user(buf, dp, left))
37603 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37604 return -EFAULT;
37605 } else {
37606 memcpy(buf, dp, left);
37607 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
37608 }
37609 if (left) {
37610 if (config->user) {
37611 - if (copy_from_user(buf, dp, left))
37612 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37613 return -EFAULT;
37614 } else {
37615 memcpy(buf, dp, left);
37616 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
37617 index ebaebdf..acd4405 100644
37618 --- a/drivers/isdn/i4l/isdn_tty.c
37619 +++ b/drivers/isdn/i4l/isdn_tty.c
37620 @@ -1511,9 +1511,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
37621
37622 #ifdef ISDN_DEBUG_MODEM_OPEN
37623 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
37624 - port->count);
37625 + atomic_read(&port->count));
37626 #endif
37627 - port->count++;
37628 + atomic_inc(&port->count);
37629 port->tty = tty;
37630 /*
37631 * Start up serial port
37632 @@ -1557,7 +1557,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37633 #endif
37634 return;
37635 }
37636 - if ((tty->count == 1) && (port->count != 1)) {
37637 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
37638 /*
37639 * Uh, oh. tty->count is 1, which means that the tty
37640 * structure will be freed. Info->count should always
37641 @@ -1566,15 +1566,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37642 * serial port won't be shutdown.
37643 */
37644 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
37645 - "info->count is %d\n", port->count);
37646 - port->count = 1;
37647 + "info->count is %d\n", atomic_read(&port->count));
37648 + atomic_set(&port->count, 1);
37649 }
37650 - if (--port->count < 0) {
37651 + if (atomic_dec_return(&port->count) < 0) {
37652 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
37653 - info->line, port->count);
37654 - port->count = 0;
37655 + info->line, atomic_read(&port->count));
37656 + atomic_set(&port->count, 0);
37657 }
37658 - if (port->count) {
37659 + if (atomic_read(&port->count)) {
37660 #ifdef ISDN_DEBUG_MODEM_OPEN
37661 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
37662 #endif
37663 @@ -1628,7 +1628,7 @@ isdn_tty_hangup(struct tty_struct *tty)
37664 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
37665 return;
37666 isdn_tty_shutdown(info);
37667 - port->count = 0;
37668 + atomic_set(&port->count, 0);
37669 port->flags &= ~ASYNC_NORMAL_ACTIVE;
37670 port->tty = NULL;
37671 wake_up_interruptible(&port->open_wait);
37672 @@ -1973,7 +1973,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
37673 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
37674 modem_info *info = &dev->mdm.info[i];
37675
37676 - if (info->port.count == 0)
37677 + if (atomic_read(&info->port.count) == 0)
37678 continue;
37679 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
37680 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
37681 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
37682 index e74df7c..03a03ba 100644
37683 --- a/drivers/isdn/icn/icn.c
37684 +++ b/drivers/isdn/icn/icn.c
37685 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
37686 if (count > len)
37687 count = len;
37688 if (user) {
37689 - if (copy_from_user(msg, buf, count))
37690 + if (count > sizeof msg || copy_from_user(msg, buf, count))
37691 return -EFAULT;
37692 } else
37693 memcpy(msg, buf, count);
37694 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
37695 index 6a8405d..0bd1c7e 100644
37696 --- a/drivers/leds/leds-clevo-mail.c
37697 +++ b/drivers/leds/leds-clevo-mail.c
37698 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
37699 * detected as working, but in reality it is not) as low as
37700 * possible.
37701 */
37702 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
37703 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
37704 {
37705 .callback = clevo_mail_led_dmi_callback,
37706 .ident = "Clevo D410J",
37707 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
37708 index 64e204e..c6bf189 100644
37709 --- a/drivers/leds/leds-ss4200.c
37710 +++ b/drivers/leds/leds-ss4200.c
37711 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
37712 * detected as working, but in reality it is not) as low as
37713 * possible.
37714 */
37715 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
37716 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
37717 {
37718 .callback = ss4200_led_dmi_callback,
37719 .ident = "Intel SS4200-E",
37720 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
37721 index a5ebc00..982886f 100644
37722 --- a/drivers/lguest/core.c
37723 +++ b/drivers/lguest/core.c
37724 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
37725 * it's worked so far. The end address needs +1 because __get_vm_area
37726 * allocates an extra guard page, so we need space for that.
37727 */
37728 +
37729 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
37730 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37731 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
37732 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37733 +#else
37734 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37735 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
37736 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37737 +#endif
37738 +
37739 if (!switcher_vma) {
37740 err = -ENOMEM;
37741 printk("lguest: could not map switcher pages high\n");
37742 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
37743 * Now the Switcher is mapped at the right address, we can't fail!
37744 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
37745 */
37746 - memcpy(switcher_vma->addr, start_switcher_text,
37747 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
37748 end_switcher_text - start_switcher_text);
37749
37750 printk(KERN_INFO "lguest: mapped switcher at %p\n",
37751 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
37752 index 3b62be16..e33134a 100644
37753 --- a/drivers/lguest/page_tables.c
37754 +++ b/drivers/lguest/page_tables.c
37755 @@ -532,7 +532,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
37756 /*:*/
37757
37758 #ifdef CONFIG_X86_PAE
37759 -static void release_pmd(pmd_t *spmd)
37760 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
37761 {
37762 /* If the entry's not present, there's nothing to release. */
37763 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
37764 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
37765 index 4af12e1..0e89afe 100644
37766 --- a/drivers/lguest/x86/core.c
37767 +++ b/drivers/lguest/x86/core.c
37768 @@ -59,7 +59,7 @@ static struct {
37769 /* Offset from where switcher.S was compiled to where we've copied it */
37770 static unsigned long switcher_offset(void)
37771 {
37772 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
37773 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
37774 }
37775
37776 /* This cpu's struct lguest_pages. */
37777 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
37778 * These copies are pretty cheap, so we do them unconditionally: */
37779 /* Save the current Host top-level page directory.
37780 */
37781 +
37782 +#ifdef CONFIG_PAX_PER_CPU_PGD
37783 + pages->state.host_cr3 = read_cr3();
37784 +#else
37785 pages->state.host_cr3 = __pa(current->mm->pgd);
37786 +#endif
37787 +
37788 /*
37789 * Set up the Guest's page tables to see this CPU's pages (and no
37790 * other CPU's pages).
37791 @@ -476,7 +482,7 @@ void __init lguest_arch_host_init(void)
37792 * compiled-in switcher code and the high-mapped copy we just made.
37793 */
37794 for (i = 0; i < IDT_ENTRIES; i++)
37795 - default_idt_entries[i] += switcher_offset();
37796 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
37797
37798 /*
37799 * Set up the Switcher's per-cpu areas.
37800 @@ -559,7 +565,7 @@ void __init lguest_arch_host_init(void)
37801 * it will be undisturbed when we switch. To change %cs and jump we
37802 * need this structure to feed to Intel's "lcall" instruction.
37803 */
37804 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
37805 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
37806 lguest_entry.segment = LGUEST_CS;
37807
37808 /*
37809 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
37810 index 40634b0..4f5855e 100644
37811 --- a/drivers/lguest/x86/switcher_32.S
37812 +++ b/drivers/lguest/x86/switcher_32.S
37813 @@ -87,6 +87,7 @@
37814 #include <asm/page.h>
37815 #include <asm/segment.h>
37816 #include <asm/lguest.h>
37817 +#include <asm/processor-flags.h>
37818
37819 // We mark the start of the code to copy
37820 // It's placed in .text tho it's never run here
37821 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
37822 // Changes type when we load it: damn Intel!
37823 // For after we switch over our page tables
37824 // That entry will be read-only: we'd crash.
37825 +
37826 +#ifdef CONFIG_PAX_KERNEXEC
37827 + mov %cr0, %edx
37828 + xor $X86_CR0_WP, %edx
37829 + mov %edx, %cr0
37830 +#endif
37831 +
37832 movl $(GDT_ENTRY_TSS*8), %edx
37833 ltr %dx
37834
37835 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
37836 // Let's clear it again for our return.
37837 // The GDT descriptor of the Host
37838 // Points to the table after two "size" bytes
37839 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
37840 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
37841 // Clear "used" from type field (byte 5, bit 2)
37842 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
37843 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
37844 +
37845 +#ifdef CONFIG_PAX_KERNEXEC
37846 + mov %cr0, %eax
37847 + xor $X86_CR0_WP, %eax
37848 + mov %eax, %cr0
37849 +#endif
37850
37851 // Once our page table's switched, the Guest is live!
37852 // The Host fades as we run this final step.
37853 @@ -295,13 +309,12 @@ deliver_to_host:
37854 // I consulted gcc, and it gave
37855 // These instructions, which I gladly credit:
37856 leal (%edx,%ebx,8), %eax
37857 - movzwl (%eax),%edx
37858 - movl 4(%eax), %eax
37859 - xorw %ax, %ax
37860 - orl %eax, %edx
37861 + movl 4(%eax), %edx
37862 + movw (%eax), %dx
37863 // Now the address of the handler's in %edx
37864 // We call it now: its "iret" drops us home.
37865 - jmp *%edx
37866 + ljmp $__KERNEL_CS, $1f
37867 +1: jmp *%edx
37868
37869 // Every interrupt can come to us here
37870 // But we must truly tell each apart.
37871 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
37872 index 4fd9d6a..834fa03 100644
37873 --- a/drivers/md/bitmap.c
37874 +++ b/drivers/md/bitmap.c
37875 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
37876 chunk_kb ? "KB" : "B");
37877 if (bitmap->storage.file) {
37878 seq_printf(seq, ", file: ");
37879 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
37880 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
37881 }
37882
37883 seq_printf(seq, "\n");
37884 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
37885 index aa04f02..2a1309e 100644
37886 --- a/drivers/md/dm-ioctl.c
37887 +++ b/drivers/md/dm-ioctl.c
37888 @@ -1694,7 +1694,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
37889 cmd == DM_LIST_VERSIONS_CMD)
37890 return 0;
37891
37892 - if ((cmd == DM_DEV_CREATE_CMD)) {
37893 + if (cmd == DM_DEV_CREATE_CMD) {
37894 if (!*param->name) {
37895 DMWARN("name not supplied when creating device");
37896 return -EINVAL;
37897 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
37898 index d053098..05cc375 100644
37899 --- a/drivers/md/dm-raid1.c
37900 +++ b/drivers/md/dm-raid1.c
37901 @@ -40,7 +40,7 @@ enum dm_raid1_error {
37902
37903 struct mirror {
37904 struct mirror_set *ms;
37905 - atomic_t error_count;
37906 + atomic_unchecked_t error_count;
37907 unsigned long error_type;
37908 struct dm_dev *dev;
37909 sector_t offset;
37910 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
37911 struct mirror *m;
37912
37913 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
37914 - if (!atomic_read(&m->error_count))
37915 + if (!atomic_read_unchecked(&m->error_count))
37916 return m;
37917
37918 return NULL;
37919 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
37920 * simple way to tell if a device has encountered
37921 * errors.
37922 */
37923 - atomic_inc(&m->error_count);
37924 + atomic_inc_unchecked(&m->error_count);
37925
37926 if (test_and_set_bit(error_type, &m->error_type))
37927 return;
37928 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
37929 struct mirror *m = get_default_mirror(ms);
37930
37931 do {
37932 - if (likely(!atomic_read(&m->error_count)))
37933 + if (likely(!atomic_read_unchecked(&m->error_count)))
37934 return m;
37935
37936 if (m-- == ms->mirror)
37937 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
37938 {
37939 struct mirror *default_mirror = get_default_mirror(m->ms);
37940
37941 - return !atomic_read(&default_mirror->error_count);
37942 + return !atomic_read_unchecked(&default_mirror->error_count);
37943 }
37944
37945 static int mirror_available(struct mirror_set *ms, struct bio *bio)
37946 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
37947 */
37948 if (likely(region_in_sync(ms, region, 1)))
37949 m = choose_mirror(ms, bio->bi_sector);
37950 - else if (m && atomic_read(&m->error_count))
37951 + else if (m && atomic_read_unchecked(&m->error_count))
37952 m = NULL;
37953
37954 if (likely(m))
37955 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
37956 }
37957
37958 ms->mirror[mirror].ms = ms;
37959 - atomic_set(&(ms->mirror[mirror].error_count), 0);
37960 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
37961 ms->mirror[mirror].error_type = 0;
37962 ms->mirror[mirror].offset = offset;
37963
37964 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
37965 */
37966 static char device_status_char(struct mirror *m)
37967 {
37968 - if (!atomic_read(&(m->error_count)))
37969 + if (!atomic_read_unchecked(&(m->error_count)))
37970 return 'A';
37971
37972 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
37973 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
37974 index 7b8b2b9..9c7d145 100644
37975 --- a/drivers/md/dm-stripe.c
37976 +++ b/drivers/md/dm-stripe.c
37977 @@ -20,7 +20,7 @@ struct stripe {
37978 struct dm_dev *dev;
37979 sector_t physical_start;
37980
37981 - atomic_t error_count;
37982 + atomic_unchecked_t error_count;
37983 };
37984
37985 struct stripe_c {
37986 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
37987 kfree(sc);
37988 return r;
37989 }
37990 - atomic_set(&(sc->stripe[i].error_count), 0);
37991 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
37992 }
37993
37994 ti->private = sc;
37995 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
37996 DMEMIT("%d ", sc->stripes);
37997 for (i = 0; i < sc->stripes; i++) {
37998 DMEMIT("%s ", sc->stripe[i].dev->name);
37999 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
38000 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
38001 'D' : 'A';
38002 }
38003 buffer[i] = '\0';
38004 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
38005 */
38006 for (i = 0; i < sc->stripes; i++)
38007 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
38008 - atomic_inc(&(sc->stripe[i].error_count));
38009 - if (atomic_read(&(sc->stripe[i].error_count)) <
38010 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
38011 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
38012 DM_IO_ERROR_THRESHOLD)
38013 schedule_work(&sc->trigger_event);
38014 }
38015 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
38016 index 1ff252a..ee384c1 100644
38017 --- a/drivers/md/dm-table.c
38018 +++ b/drivers/md/dm-table.c
38019 @@ -389,7 +389,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
38020 if (!dev_size)
38021 return 0;
38022
38023 - if ((start >= dev_size) || (start + len > dev_size)) {
38024 + if ((start >= dev_size) || (len > dev_size - start)) {
38025 DMWARN("%s: %s too small for target: "
38026 "start=%llu, len=%llu, dev_size=%llu",
38027 dm_device_name(ti->table->md), bdevname(bdev, b),
38028 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
38029 index 00cee02..b89a29d 100644
38030 --- a/drivers/md/dm-thin-metadata.c
38031 +++ b/drivers/md/dm-thin-metadata.c
38032 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38033 {
38034 pmd->info.tm = pmd->tm;
38035 pmd->info.levels = 2;
38036 - pmd->info.value_type.context = pmd->data_sm;
38037 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38038 pmd->info.value_type.size = sizeof(__le64);
38039 pmd->info.value_type.inc = data_block_inc;
38040 pmd->info.value_type.dec = data_block_dec;
38041 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38042
38043 pmd->bl_info.tm = pmd->tm;
38044 pmd->bl_info.levels = 1;
38045 - pmd->bl_info.value_type.context = pmd->data_sm;
38046 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38047 pmd->bl_info.value_type.size = sizeof(__le64);
38048 pmd->bl_info.value_type.inc = data_block_inc;
38049 pmd->bl_info.value_type.dec = data_block_dec;
38050 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
38051 index 9a0bdad..4df9543 100644
38052 --- a/drivers/md/dm.c
38053 +++ b/drivers/md/dm.c
38054 @@ -169,9 +169,9 @@ struct mapped_device {
38055 /*
38056 * Event handling.
38057 */
38058 - atomic_t event_nr;
38059 + atomic_unchecked_t event_nr;
38060 wait_queue_head_t eventq;
38061 - atomic_t uevent_seq;
38062 + atomic_unchecked_t uevent_seq;
38063 struct list_head uevent_list;
38064 spinlock_t uevent_lock; /* Protect access to uevent_list */
38065
38066 @@ -1879,8 +1879,8 @@ static struct mapped_device *alloc_dev(int minor)
38067 rwlock_init(&md->map_lock);
38068 atomic_set(&md->holders, 1);
38069 atomic_set(&md->open_count, 0);
38070 - atomic_set(&md->event_nr, 0);
38071 - atomic_set(&md->uevent_seq, 0);
38072 + atomic_set_unchecked(&md->event_nr, 0);
38073 + atomic_set_unchecked(&md->uevent_seq, 0);
38074 INIT_LIST_HEAD(&md->uevent_list);
38075 spin_lock_init(&md->uevent_lock);
38076
38077 @@ -2028,7 +2028,7 @@ static void event_callback(void *context)
38078
38079 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
38080
38081 - atomic_inc(&md->event_nr);
38082 + atomic_inc_unchecked(&md->event_nr);
38083 wake_up(&md->eventq);
38084 }
38085
38086 @@ -2685,18 +2685,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
38087
38088 uint32_t dm_next_uevent_seq(struct mapped_device *md)
38089 {
38090 - return atomic_add_return(1, &md->uevent_seq);
38091 + return atomic_add_return_unchecked(1, &md->uevent_seq);
38092 }
38093
38094 uint32_t dm_get_event_nr(struct mapped_device *md)
38095 {
38096 - return atomic_read(&md->event_nr);
38097 + return atomic_read_unchecked(&md->event_nr);
38098 }
38099
38100 int dm_wait_event(struct mapped_device *md, int event_nr)
38101 {
38102 return wait_event_interruptible(md->eventq,
38103 - (event_nr != atomic_read(&md->event_nr)));
38104 + (event_nr != atomic_read_unchecked(&md->event_nr)));
38105 }
38106
38107 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
38108 diff --git a/drivers/md/md.c b/drivers/md/md.c
38109 index a4a93b9..4747b63 100644
38110 --- a/drivers/md/md.c
38111 +++ b/drivers/md/md.c
38112 @@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
38113 * start build, activate spare
38114 */
38115 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
38116 -static atomic_t md_event_count;
38117 +static atomic_unchecked_t md_event_count;
38118 void md_new_event(struct mddev *mddev)
38119 {
38120 - atomic_inc(&md_event_count);
38121 + atomic_inc_unchecked(&md_event_count);
38122 wake_up(&md_event_waiters);
38123 }
38124 EXPORT_SYMBOL_GPL(md_new_event);
38125 @@ -253,7 +253,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
38126 */
38127 static void md_new_event_inintr(struct mddev *mddev)
38128 {
38129 - atomic_inc(&md_event_count);
38130 + atomic_inc_unchecked(&md_event_count);
38131 wake_up(&md_event_waiters);
38132 }
38133
38134 @@ -1507,7 +1507,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
38135 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
38136 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
38137 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
38138 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38139 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38140
38141 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
38142 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
38143 @@ -1751,7 +1751,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
38144 else
38145 sb->resync_offset = cpu_to_le64(0);
38146
38147 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
38148 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
38149
38150 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
38151 sb->size = cpu_to_le64(mddev->dev_sectors);
38152 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
38153 static ssize_t
38154 errors_show(struct md_rdev *rdev, char *page)
38155 {
38156 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
38157 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
38158 }
38159
38160 static ssize_t
38161 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
38162 char *e;
38163 unsigned long n = simple_strtoul(buf, &e, 10);
38164 if (*buf && (*e == 0 || *e == '\n')) {
38165 - atomic_set(&rdev->corrected_errors, n);
38166 + atomic_set_unchecked(&rdev->corrected_errors, n);
38167 return len;
38168 }
38169 return -EINVAL;
38170 @@ -3210,8 +3210,8 @@ int md_rdev_init(struct md_rdev *rdev)
38171 rdev->sb_loaded = 0;
38172 rdev->bb_page = NULL;
38173 atomic_set(&rdev->nr_pending, 0);
38174 - atomic_set(&rdev->read_errors, 0);
38175 - atomic_set(&rdev->corrected_errors, 0);
38176 + atomic_set_unchecked(&rdev->read_errors, 0);
38177 + atomic_set_unchecked(&rdev->corrected_errors, 0);
38178
38179 INIT_LIST_HEAD(&rdev->same_set);
38180 init_waitqueue_head(&rdev->blocked_wait);
38181 @@ -6994,7 +6994,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
38182
38183 spin_unlock(&pers_lock);
38184 seq_printf(seq, "\n");
38185 - seq->poll_event = atomic_read(&md_event_count);
38186 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38187 return 0;
38188 }
38189 if (v == (void*)2) {
38190 @@ -7097,7 +7097,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
38191 return error;
38192
38193 seq = file->private_data;
38194 - seq->poll_event = atomic_read(&md_event_count);
38195 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38196 return error;
38197 }
38198
38199 @@ -7111,7 +7111,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
38200 /* always allow read */
38201 mask = POLLIN | POLLRDNORM;
38202
38203 - if (seq->poll_event != atomic_read(&md_event_count))
38204 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
38205 mask |= POLLERR | POLLPRI;
38206 return mask;
38207 }
38208 @@ -7155,7 +7155,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
38209 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
38210 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
38211 (int)part_stat_read(&disk->part0, sectors[1]) -
38212 - atomic_read(&disk->sync_io);
38213 + atomic_read_unchecked(&disk->sync_io);
38214 /* sync IO will cause sync_io to increase before the disk_stats
38215 * as sync_io is counted when a request starts, and
38216 * disk_stats is counted when it completes.
38217 diff --git a/drivers/md/md.h b/drivers/md/md.h
38218 index d90fb1a..4174a2b 100644
38219 --- a/drivers/md/md.h
38220 +++ b/drivers/md/md.h
38221 @@ -94,13 +94,13 @@ struct md_rdev {
38222 * only maintained for arrays that
38223 * support hot removal
38224 */
38225 - atomic_t read_errors; /* number of consecutive read errors that
38226 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
38227 * we have tried to ignore.
38228 */
38229 struct timespec last_read_error; /* monotonic time since our
38230 * last read error
38231 */
38232 - atomic_t corrected_errors; /* number of corrected read errors,
38233 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
38234 * for reporting to userspace and storing
38235 * in superblock.
38236 */
38237 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
38238
38239 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
38240 {
38241 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38242 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38243 }
38244
38245 struct md_personality
38246 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
38247 index 1cbfc6b..56e1dbb 100644
38248 --- a/drivers/md/persistent-data/dm-space-map.h
38249 +++ b/drivers/md/persistent-data/dm-space-map.h
38250 @@ -60,6 +60,7 @@ struct dm_space_map {
38251 int (*root_size)(struct dm_space_map *sm, size_t *result);
38252 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
38253 };
38254 +typedef struct dm_space_map __no_const dm_space_map_no_const;
38255
38256 /*----------------------------------------------------------------*/
38257
38258 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
38259 index 6af167f..40c25a1 100644
38260 --- a/drivers/md/raid1.c
38261 +++ b/drivers/md/raid1.c
38262 @@ -1826,7 +1826,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
38263 if (r1_sync_page_io(rdev, sect, s,
38264 bio->bi_io_vec[idx].bv_page,
38265 READ) != 0)
38266 - atomic_add(s, &rdev->corrected_errors);
38267 + atomic_add_unchecked(s, &rdev->corrected_errors);
38268 }
38269 sectors -= s;
38270 sect += s;
38271 @@ -2048,7 +2048,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
38272 test_bit(In_sync, &rdev->flags)) {
38273 if (r1_sync_page_io(rdev, sect, s,
38274 conf->tmppage, READ)) {
38275 - atomic_add(s, &rdev->corrected_errors);
38276 + atomic_add_unchecked(s, &rdev->corrected_errors);
38277 printk(KERN_INFO
38278 "md/raid1:%s: read error corrected "
38279 "(%d sectors at %llu on %s)\n",
38280 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38281 index 46c14e5..4db5966 100644
38282 --- a/drivers/md/raid10.c
38283 +++ b/drivers/md/raid10.c
38284 @@ -1932,7 +1932,7 @@ static void end_sync_read(struct bio *bio, int error)
38285 /* The write handler will notice the lack of
38286 * R10BIO_Uptodate and record any errors etc
38287 */
38288 - atomic_add(r10_bio->sectors,
38289 + atomic_add_unchecked(r10_bio->sectors,
38290 &conf->mirrors[d].rdev->corrected_errors);
38291
38292 /* for reconstruct, we always reschedule after a read.
38293 @@ -2281,7 +2281,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38294 {
38295 struct timespec cur_time_mon;
38296 unsigned long hours_since_last;
38297 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38298 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38299
38300 ktime_get_ts(&cur_time_mon);
38301
38302 @@ -2303,9 +2303,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38303 * overflowing the shift of read_errors by hours_since_last.
38304 */
38305 if (hours_since_last >= 8 * sizeof(read_errors))
38306 - atomic_set(&rdev->read_errors, 0);
38307 + atomic_set_unchecked(&rdev->read_errors, 0);
38308 else
38309 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38310 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38311 }
38312
38313 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38314 @@ -2359,8 +2359,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38315 return;
38316
38317 check_decay_read_errors(mddev, rdev);
38318 - atomic_inc(&rdev->read_errors);
38319 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38320 + atomic_inc_unchecked(&rdev->read_errors);
38321 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38322 char b[BDEVNAME_SIZE];
38323 bdevname(rdev->bdev, b);
38324
38325 @@ -2368,7 +2368,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38326 "md/raid10:%s: %s: Raid device exceeded "
38327 "read_error threshold [cur %d:max %d]\n",
38328 mdname(mddev), b,
38329 - atomic_read(&rdev->read_errors), max_read_errors);
38330 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38331 printk(KERN_NOTICE
38332 "md/raid10:%s: %s: Failing raid device\n",
38333 mdname(mddev), b);
38334 @@ -2523,7 +2523,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38335 sect +
38336 choose_data_offset(r10_bio, rdev)),
38337 bdevname(rdev->bdev, b));
38338 - atomic_add(s, &rdev->corrected_errors);
38339 + atomic_add_unchecked(s, &rdev->corrected_errors);
38340 }
38341
38342 rdev_dec_pending(rdev, mddev);
38343 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38344 index f4e87bf..0d4ad3f 100644
38345 --- a/drivers/md/raid5.c
38346 +++ b/drivers/md/raid5.c
38347 @@ -1763,21 +1763,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38348 mdname(conf->mddev), STRIPE_SECTORS,
38349 (unsigned long long)s,
38350 bdevname(rdev->bdev, b));
38351 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38352 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38353 clear_bit(R5_ReadError, &sh->dev[i].flags);
38354 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38355 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38356 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38357
38358 - if (atomic_read(&rdev->read_errors))
38359 - atomic_set(&rdev->read_errors, 0);
38360 + if (atomic_read_unchecked(&rdev->read_errors))
38361 + atomic_set_unchecked(&rdev->read_errors, 0);
38362 } else {
38363 const char *bdn = bdevname(rdev->bdev, b);
38364 int retry = 0;
38365 int set_bad = 0;
38366
38367 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38368 - atomic_inc(&rdev->read_errors);
38369 + atomic_inc_unchecked(&rdev->read_errors);
38370 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38371 printk_ratelimited(
38372 KERN_WARNING
38373 @@ -1805,7 +1805,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38374 mdname(conf->mddev),
38375 (unsigned long long)s,
38376 bdn);
38377 - } else if (atomic_read(&rdev->read_errors)
38378 + } else if (atomic_read_unchecked(&rdev->read_errors)
38379 > conf->max_nr_stripes)
38380 printk(KERN_WARNING
38381 "md/raid:%s: Too many read errors, failing device %s.\n",
38382 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38383 index 401ef64..836e563 100644
38384 --- a/drivers/media/dvb-core/dvbdev.c
38385 +++ b/drivers/media/dvb-core/dvbdev.c
38386 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38387 const struct dvb_device *template, void *priv, int type)
38388 {
38389 struct dvb_device *dvbdev;
38390 - struct file_operations *dvbdevfops;
38391 + file_operations_no_const *dvbdevfops;
38392 struct device *clsdev;
38393 int minor;
38394 int id;
38395 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38396 index 9b6c3bb..baeb5c7 100644
38397 --- a/drivers/media/dvb-frontends/dib3000.h
38398 +++ b/drivers/media/dvb-frontends/dib3000.h
38399 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38400 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38401 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38402 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38403 -};
38404 +} __no_const;
38405
38406 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
38407 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38408 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38409 index bc78354..42c9459 100644
38410 --- a/drivers/media/pci/cx88/cx88-video.c
38411 +++ b/drivers/media/pci/cx88/cx88-video.c
38412 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38413
38414 /* ------------------------------------------------------------------ */
38415
38416 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38417 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38418 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38419 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38420 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38421 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38422
38423 module_param_array(video_nr, int, NULL, 0444);
38424 module_param_array(vbi_nr, int, NULL, 0444);
38425 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38426 index 96c4a17..1305a79 100644
38427 --- a/drivers/media/platform/omap/omap_vout.c
38428 +++ b/drivers/media/platform/omap/omap_vout.c
38429 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38430 OMAP_VIDEO2,
38431 };
38432
38433 -static struct videobuf_queue_ops video_vbq_ops;
38434 /* Variables configurable through module params*/
38435 static u32 video1_numbuffers = 3;
38436 static u32 video2_numbuffers = 3;
38437 @@ -1012,6 +1011,12 @@ static int omap_vout_open(struct file *file)
38438 {
38439 struct videobuf_queue *q;
38440 struct omap_vout_device *vout = NULL;
38441 + static struct videobuf_queue_ops video_vbq_ops = {
38442 + .buf_setup = omap_vout_buffer_setup,
38443 + .buf_prepare = omap_vout_buffer_prepare,
38444 + .buf_release = omap_vout_buffer_release,
38445 + .buf_queue = omap_vout_buffer_queue,
38446 + };
38447
38448 vout = video_drvdata(file);
38449 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38450 @@ -1029,10 +1034,6 @@ static int omap_vout_open(struct file *file)
38451 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38452
38453 q = &vout->vbq;
38454 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38455 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38456 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38457 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38458 spin_lock_init(&vout->vbq_lock);
38459
38460 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38461 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38462 index 04e6490..2df65bf 100644
38463 --- a/drivers/media/platform/s5p-tv/mixer.h
38464 +++ b/drivers/media/platform/s5p-tv/mixer.h
38465 @@ -156,7 +156,7 @@ struct mxr_layer {
38466 /** layer index (unique identifier) */
38467 int idx;
38468 /** callbacks for layer methods */
38469 - struct mxr_layer_ops ops;
38470 + struct mxr_layer_ops *ops;
38471 /** format array */
38472 const struct mxr_format **fmt_array;
38473 /** size of format array */
38474 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38475 index b93a21f..2535195 100644
38476 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38477 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38478 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38479 {
38480 struct mxr_layer *layer;
38481 int ret;
38482 - struct mxr_layer_ops ops = {
38483 + static struct mxr_layer_ops ops = {
38484 .release = mxr_graph_layer_release,
38485 .buffer_set = mxr_graph_buffer_set,
38486 .stream_set = mxr_graph_stream_set,
38487 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38488 index b713403..53cb5ad 100644
38489 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38490 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38491 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38492 layer->update_buf = next;
38493 }
38494
38495 - layer->ops.buffer_set(layer, layer->update_buf);
38496 + layer->ops->buffer_set(layer, layer->update_buf);
38497
38498 if (done && done != layer->shadow_buf)
38499 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38500 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38501 index 82142a2..6de47e8 100644
38502 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38503 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38504 @@ -209,7 +209,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38505 layer->geo.src.height = layer->geo.src.full_height;
38506
38507 mxr_geometry_dump(mdev, &layer->geo);
38508 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38509 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38510 mxr_geometry_dump(mdev, &layer->geo);
38511 }
38512
38513 @@ -227,7 +227,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38514 layer->geo.dst.full_width = mbus_fmt.width;
38515 layer->geo.dst.full_height = mbus_fmt.height;
38516 layer->geo.dst.field = mbus_fmt.field;
38517 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38518 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38519
38520 mxr_geometry_dump(mdev, &layer->geo);
38521 }
38522 @@ -333,7 +333,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38523 /* set source size to highest accepted value */
38524 geo->src.full_width = max(geo->dst.full_width, pix->width);
38525 geo->src.full_height = max(geo->dst.full_height, pix->height);
38526 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38527 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38528 mxr_geometry_dump(mdev, &layer->geo);
38529 /* set cropping to total visible screen */
38530 geo->src.width = pix->width;
38531 @@ -341,12 +341,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38532 geo->src.x_offset = 0;
38533 geo->src.y_offset = 0;
38534 /* assure consistency of geometry */
38535 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38536 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38537 mxr_geometry_dump(mdev, &layer->geo);
38538 /* set full size to lowest possible value */
38539 geo->src.full_width = 0;
38540 geo->src.full_height = 0;
38541 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38542 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38543 mxr_geometry_dump(mdev, &layer->geo);
38544
38545 /* returning results */
38546 @@ -473,7 +473,7 @@ static int mxr_s_selection(struct file *file, void *fh,
38547 target->width = s->r.width;
38548 target->height = s->r.height;
38549
38550 - layer->ops.fix_geometry(layer, stage, s->flags);
38551 + layer->ops->fix_geometry(layer, stage, s->flags);
38552
38553 /* retrieve update selection rectangle */
38554 res.left = target->x_offset;
38555 @@ -938,13 +938,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
38556 mxr_output_get(mdev);
38557
38558 mxr_layer_update_output(layer);
38559 - layer->ops.format_set(layer);
38560 + layer->ops->format_set(layer);
38561 /* enabling layer in hardware */
38562 spin_lock_irqsave(&layer->enq_slock, flags);
38563 layer->state = MXR_LAYER_STREAMING;
38564 spin_unlock_irqrestore(&layer->enq_slock, flags);
38565
38566 - layer->ops.stream_set(layer, MXR_ENABLE);
38567 + layer->ops->stream_set(layer, MXR_ENABLE);
38568 mxr_streamer_get(mdev);
38569
38570 return 0;
38571 @@ -1014,7 +1014,7 @@ static int stop_streaming(struct vb2_queue *vq)
38572 spin_unlock_irqrestore(&layer->enq_slock, flags);
38573
38574 /* disabling layer in hardware */
38575 - layer->ops.stream_set(layer, MXR_DISABLE);
38576 + layer->ops->stream_set(layer, MXR_DISABLE);
38577 /* remove one streamer */
38578 mxr_streamer_put(mdev);
38579 /* allow changes in output configuration */
38580 @@ -1053,8 +1053,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
38581
38582 void mxr_layer_release(struct mxr_layer *layer)
38583 {
38584 - if (layer->ops.release)
38585 - layer->ops.release(layer);
38586 + if (layer->ops->release)
38587 + layer->ops->release(layer);
38588 }
38589
38590 void mxr_base_layer_release(struct mxr_layer *layer)
38591 @@ -1080,7 +1080,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
38592
38593 layer->mdev = mdev;
38594 layer->idx = idx;
38595 - layer->ops = *ops;
38596 + layer->ops = ops;
38597
38598 spin_lock_init(&layer->enq_slock);
38599 INIT_LIST_HEAD(&layer->enq_list);
38600 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38601 index 3d13a63..da31bf1 100644
38602 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38603 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38604 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
38605 {
38606 struct mxr_layer *layer;
38607 int ret;
38608 - struct mxr_layer_ops ops = {
38609 + static struct mxr_layer_ops ops = {
38610 .release = mxr_vp_layer_release,
38611 .buffer_set = mxr_vp_buffer_set,
38612 .stream_set = mxr_vp_stream_set,
38613 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
38614 index 643d80a..56bb96b 100644
38615 --- a/drivers/media/radio/radio-cadet.c
38616 +++ b/drivers/media/radio/radio-cadet.c
38617 @@ -302,6 +302,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38618 unsigned char readbuf[RDS_BUFFER];
38619 int i = 0;
38620
38621 + if (count > RDS_BUFFER)
38622 + return -EFAULT;
38623 mutex_lock(&dev->lock);
38624 if (dev->rdsstat == 0)
38625 cadet_start_rds(dev);
38626 @@ -317,7 +319,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38627 while (i < count && dev->rdsin != dev->rdsout)
38628 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
38629
38630 - if (i && copy_to_user(data, readbuf, i))
38631 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
38632 i = -EFAULT;
38633 unlock:
38634 mutex_unlock(&dev->lock);
38635 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
38636 index 3940bb0..fb3952a 100644
38637 --- a/drivers/media/usb/dvb-usb/cxusb.c
38638 +++ b/drivers/media/usb/dvb-usb/cxusb.c
38639 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
38640
38641 struct dib0700_adapter_state {
38642 int (*set_param_save) (struct dvb_frontend *);
38643 -};
38644 +} __no_const;
38645
38646 static int dib7070_set_param_override(struct dvb_frontend *fe)
38647 {
38648 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
38649 index 9578a67..31aa652 100644
38650 --- a/drivers/media/usb/dvb-usb/dw2102.c
38651 +++ b/drivers/media/usb/dvb-usb/dw2102.c
38652 @@ -115,7 +115,7 @@ struct su3000_state {
38653
38654 struct s6x0_state {
38655 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
38656 -};
38657 +} __no_const;
38658
38659 /* debug */
38660 static int dvb_usb_dw2102_debug;
38661 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
38662 index 7157af3..139e91a 100644
38663 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
38664 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
38665 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
38666 __u32 reserved;
38667 };
38668
38669 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
38670 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
38671 enum v4l2_memory memory)
38672 {
38673 void __user *up_pln;
38674 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
38675 return 0;
38676 }
38677
38678 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
38679 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
38680 enum v4l2_memory memory)
38681 {
38682 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
38683 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
38684 put_user(kp->start_block, &up->start_block) ||
38685 put_user(kp->blocks, &up->blocks) ||
38686 put_user(tmp, &up->edid) ||
38687 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
38688 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
38689 return -EFAULT;
38690 return 0;
38691 }
38692 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
38693 index aa6e7c7..cb5de87 100644
38694 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
38695 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
38696 @@ -236,7 +236,7 @@ static void v4l_print_format(const void *arg, bool write_only)
38697 const struct v4l2_vbi_format *vbi;
38698 const struct v4l2_sliced_vbi_format *sliced;
38699 const struct v4l2_window *win;
38700 - const struct v4l2_clip *clip;
38701 + const struct v4l2_clip __user *pclip;
38702 unsigned i;
38703
38704 pr_cont("type=%s", prt_names(p->type, v4l2_type_names));
38705 @@ -284,12 +284,16 @@ static void v4l_print_format(const void *arg, bool write_only)
38706 win->w.left, win->w.top,
38707 prt_names(win->field, v4l2_field_names),
38708 win->chromakey, win->bitmap, win->global_alpha);
38709 - clip = win->clips;
38710 + pclip = win->clips;
38711 for (i = 0; i < win->clipcount; i++) {
38712 + struct v4l2_clip clip;
38713 +
38714 + if (copy_from_user(&clip, pclip, sizeof clip))
38715 + break;
38716 printk(KERN_DEBUG "clip %u: wxh=%dx%d, x,y=%d,%d\n",
38717 - i, clip->c.width, clip->c.height,
38718 - clip->c.left, clip->c.top);
38719 - clip = clip->next;
38720 + i, clip.c.width, clip.c.height,
38721 + clip.c.left, clip.c.top);
38722 + pclip = clip.next;
38723 }
38724 break;
38725 case V4L2_BUF_TYPE_VBI_CAPTURE:
38726 @@ -1923,7 +1927,8 @@ struct v4l2_ioctl_info {
38727 struct file *file, void *fh, void *p);
38728 } u;
38729 void (*debug)(const void *arg, bool write_only);
38730 -};
38731 +} __do_const;
38732 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
38733
38734 /* This control needs a priority check */
38735 #define INFO_FL_PRIO (1 << 0)
38736 @@ -2108,7 +2113,7 @@ static long __video_do_ioctl(struct file *file,
38737 struct video_device *vfd = video_devdata(file);
38738 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
38739 bool write_only = false;
38740 - struct v4l2_ioctl_info default_info;
38741 + v4l2_ioctl_info_no_const default_info;
38742 const struct v4l2_ioctl_info *info;
38743 void *fh = file->private_data;
38744 struct v4l2_fh *vfh = NULL;
38745 @@ -2193,7 +2198,7 @@ done:
38746 }
38747
38748 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
38749 - void * __user *user_ptr, void ***kernel_ptr)
38750 + void __user **user_ptr, void ***kernel_ptr)
38751 {
38752 int ret = 0;
38753
38754 @@ -2209,7 +2214,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
38755 ret = -EINVAL;
38756 break;
38757 }
38758 - *user_ptr = (void __user *)buf->m.planes;
38759 + *user_ptr = (void __force_user *)buf->m.planes;
38760 *kernel_ptr = (void *)&buf->m.planes;
38761 *array_size = sizeof(struct v4l2_plane) * buf->length;
38762 ret = 1;
38763 @@ -2244,7 +2249,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
38764 ret = -EINVAL;
38765 break;
38766 }
38767 - *user_ptr = (void __user *)ctrls->controls;
38768 + *user_ptr = (void __force_user *)ctrls->controls;
38769 *kernel_ptr = (void *)&ctrls->controls;
38770 *array_size = sizeof(struct v4l2_ext_control)
38771 * ctrls->count;
38772 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
38773 index fb69baa..3aeea2e 100644
38774 --- a/drivers/message/fusion/mptbase.c
38775 +++ b/drivers/message/fusion/mptbase.c
38776 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38777 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
38778 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
38779
38780 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38781 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
38782 +#else
38783 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
38784 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
38785 +#endif
38786 +
38787 /*
38788 * Rounding UP to nearest 4-kB boundary here...
38789 */
38790 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38791 ioc->facts.GlobalCredits);
38792
38793 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
38794 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38795 + NULL, NULL);
38796 +#else
38797 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
38798 +#endif
38799 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
38800 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
38801 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
38802 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
38803 index fa43c39..daeb158 100644
38804 --- a/drivers/message/fusion/mptsas.c
38805 +++ b/drivers/message/fusion/mptsas.c
38806 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
38807 return 0;
38808 }
38809
38810 +static inline void
38811 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38812 +{
38813 + if (phy_info->port_details) {
38814 + phy_info->port_details->rphy = rphy;
38815 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38816 + ioc->name, rphy));
38817 + }
38818 +
38819 + if (rphy) {
38820 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38821 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38822 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38823 + ioc->name, rphy, rphy->dev.release));
38824 + }
38825 +}
38826 +
38827 /* no mutex */
38828 static void
38829 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
38830 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
38831 return NULL;
38832 }
38833
38834 -static inline void
38835 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38836 -{
38837 - if (phy_info->port_details) {
38838 - phy_info->port_details->rphy = rphy;
38839 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38840 - ioc->name, rphy));
38841 - }
38842 -
38843 - if (rphy) {
38844 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38845 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38846 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38847 - ioc->name, rphy, rphy->dev.release));
38848 - }
38849 -}
38850 -
38851 static inline struct sas_port *
38852 mptsas_get_port(struct mptsas_phyinfo *phy_info)
38853 {
38854 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
38855 index 164afa7..b6b2e74 100644
38856 --- a/drivers/message/fusion/mptscsih.c
38857 +++ b/drivers/message/fusion/mptscsih.c
38858 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
38859
38860 h = shost_priv(SChost);
38861
38862 - if (h) {
38863 - if (h->info_kbuf == NULL)
38864 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38865 - return h->info_kbuf;
38866 - h->info_kbuf[0] = '\0';
38867 + if (!h)
38868 + return NULL;
38869
38870 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38871 - h->info_kbuf[size-1] = '\0';
38872 - }
38873 + if (h->info_kbuf == NULL)
38874 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38875 + return h->info_kbuf;
38876 + h->info_kbuf[0] = '\0';
38877 +
38878 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38879 + h->info_kbuf[size-1] = '\0';
38880
38881 return h->info_kbuf;
38882 }
38883 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
38884 index 8001aa6..b137580 100644
38885 --- a/drivers/message/i2o/i2o_proc.c
38886 +++ b/drivers/message/i2o/i2o_proc.c
38887 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
38888 "Array Controller Device"
38889 };
38890
38891 -static char *chtostr(char *tmp, u8 *chars, int n)
38892 -{
38893 - tmp[0] = 0;
38894 - return strncat(tmp, (char *)chars, n);
38895 -}
38896 -
38897 static int i2o_report_query_status(struct seq_file *seq, int block_status,
38898 char *group)
38899 {
38900 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38901 } *result;
38902
38903 i2o_exec_execute_ddm_table ddm_table;
38904 - char tmp[28 + 1];
38905
38906 result = kmalloc(sizeof(*result), GFP_KERNEL);
38907 if (!result)
38908 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38909
38910 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
38911 seq_printf(seq, "%-#8x", ddm_table.module_id);
38912 - seq_printf(seq, "%-29s",
38913 - chtostr(tmp, ddm_table.module_name_version, 28));
38914 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
38915 seq_printf(seq, "%9d ", ddm_table.data_size);
38916 seq_printf(seq, "%8d", ddm_table.code_size);
38917
38918 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38919
38920 i2o_driver_result_table *result;
38921 i2o_driver_store_table *dst;
38922 - char tmp[28 + 1];
38923
38924 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
38925 if (result == NULL)
38926 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38927
38928 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
38929 seq_printf(seq, "%-#8x", dst->module_id);
38930 - seq_printf(seq, "%-29s",
38931 - chtostr(tmp, dst->module_name_version, 28));
38932 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
38933 + seq_printf(seq, "%-.28s", dst->module_name_version);
38934 + seq_printf(seq, "%-.8s", dst->date);
38935 seq_printf(seq, "%8d ", dst->module_size);
38936 seq_printf(seq, "%8d ", dst->mpb_size);
38937 seq_printf(seq, "0x%04x", dst->module_flags);
38938 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
38939 // == (allow) 512d bytes (max)
38940 static u16 *work16 = (u16 *) work32;
38941 int token;
38942 - char tmp[16 + 1];
38943
38944 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
38945
38946 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
38947 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
38948 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
38949 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
38950 - seq_printf(seq, "Vendor info : %s\n",
38951 - chtostr(tmp, (u8 *) (work32 + 2), 16));
38952 - seq_printf(seq, "Product info : %s\n",
38953 - chtostr(tmp, (u8 *) (work32 + 6), 16));
38954 - seq_printf(seq, "Description : %s\n",
38955 - chtostr(tmp, (u8 *) (work32 + 10), 16));
38956 - seq_printf(seq, "Product rev. : %s\n",
38957 - chtostr(tmp, (u8 *) (work32 + 14), 8));
38958 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
38959 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
38960 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
38961 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
38962
38963 seq_printf(seq, "Serial number : ");
38964 print_serial_number(seq, (u8 *) (work32 + 16),
38965 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
38966 u8 pad[256]; // allow up to 256 byte (max) serial number
38967 } result;
38968
38969 - char tmp[24 + 1];
38970 -
38971 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
38972
38973 if (token < 0) {
38974 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
38975 }
38976
38977 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
38978 - seq_printf(seq, "Module name : %s\n",
38979 - chtostr(tmp, result.module_name, 24));
38980 - seq_printf(seq, "Module revision : %s\n",
38981 - chtostr(tmp, result.module_rev, 8));
38982 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
38983 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
38984
38985 seq_printf(seq, "Serial number : ");
38986 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
38987 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
38988 u8 instance_number[4];
38989 } result;
38990
38991 - char tmp[64 + 1];
38992 -
38993 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
38994
38995 if (token < 0) {
38996 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
38997 return 0;
38998 }
38999
39000 - seq_printf(seq, "Device name : %s\n",
39001 - chtostr(tmp, result.device_name, 64));
39002 - seq_printf(seq, "Service name : %s\n",
39003 - chtostr(tmp, result.service_name, 64));
39004 - seq_printf(seq, "Physical name : %s\n",
39005 - chtostr(tmp, result.physical_location, 64));
39006 - seq_printf(seq, "Instance number : %s\n",
39007 - chtostr(tmp, result.instance_number, 4));
39008 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
39009 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
39010 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
39011 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
39012
39013 return 0;
39014 }
39015 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
39016 index a8c08f3..155fe3d 100644
39017 --- a/drivers/message/i2o/iop.c
39018 +++ b/drivers/message/i2o/iop.c
39019 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
39020
39021 spin_lock_irqsave(&c->context_list_lock, flags);
39022
39023 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
39024 - atomic_inc(&c->context_list_counter);
39025 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
39026 + atomic_inc_unchecked(&c->context_list_counter);
39027
39028 - entry->context = atomic_read(&c->context_list_counter);
39029 + entry->context = atomic_read_unchecked(&c->context_list_counter);
39030
39031 list_add(&entry->list, &c->context_list);
39032
39033 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
39034
39035 #if BITS_PER_LONG == 64
39036 spin_lock_init(&c->context_list_lock);
39037 - atomic_set(&c->context_list_counter, 0);
39038 + atomic_set_unchecked(&c->context_list_counter, 0);
39039 INIT_LIST_HEAD(&c->context_list);
39040 #endif
39041
39042 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
39043 index 45ece11..8efa218 100644
39044 --- a/drivers/mfd/janz-cmodio.c
39045 +++ b/drivers/mfd/janz-cmodio.c
39046 @@ -13,6 +13,7 @@
39047
39048 #include <linux/kernel.h>
39049 #include <linux/module.h>
39050 +#include <linux/slab.h>
39051 #include <linux/init.h>
39052 #include <linux/pci.h>
39053 #include <linux/interrupt.h>
39054 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
39055 index a5f9888..1c0ed56 100644
39056 --- a/drivers/mfd/twl4030-irq.c
39057 +++ b/drivers/mfd/twl4030-irq.c
39058 @@ -35,6 +35,7 @@
39059 #include <linux/of.h>
39060 #include <linux/irqdomain.h>
39061 #include <linux/i2c/twl.h>
39062 +#include <asm/pgtable.h>
39063
39064 #include "twl-core.h"
39065
39066 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
39067 * Install an irq handler for each of the SIH modules;
39068 * clone dummy irq_chip since PIH can't *do* anything
39069 */
39070 - twl4030_irq_chip = dummy_irq_chip;
39071 - twl4030_irq_chip.name = "twl4030";
39072 + pax_open_kernel();
39073 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
39074 + *(const char **)&twl4030_irq_chip.name = "twl4030";
39075
39076 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39077 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39078 + pax_close_kernel();
39079
39080 for (i = irq_base; i < irq_end; i++) {
39081 irq_set_chip_and_handler(i, &twl4030_irq_chip,
39082 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
39083 index 277a8db..0e0b754 100644
39084 --- a/drivers/mfd/twl6030-irq.c
39085 +++ b/drivers/mfd/twl6030-irq.c
39086 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
39087 * install an irq handler for each of the modules;
39088 * clone dummy irq_chip since PIH can't *do* anything
39089 */
39090 - twl6030_irq_chip = dummy_irq_chip;
39091 - twl6030_irq_chip.name = "twl6030";
39092 - twl6030_irq_chip.irq_set_type = NULL;
39093 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39094 + pax_open_kernel();
39095 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
39096 + *(const char **)&twl6030_irq_chip.name = "twl6030";
39097 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
39098 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39099 + pax_close_kernel();
39100
39101 for (i = irq_base; i < irq_end; i++) {
39102 irq_set_chip_and_handler(i, &twl6030_irq_chip,
39103 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
39104 index f32550a..e3e52a2 100644
39105 --- a/drivers/misc/c2port/core.c
39106 +++ b/drivers/misc/c2port/core.c
39107 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
39108 mutex_init(&c2dev->mutex);
39109
39110 /* Create binary file */
39111 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39112 + pax_open_kernel();
39113 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39114 + pax_close_kernel();
39115 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
39116 if (unlikely(ret))
39117 goto error_device_create_bin_file;
39118 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
39119 index 36f5d52..32311c3 100644
39120 --- a/drivers/misc/kgdbts.c
39121 +++ b/drivers/misc/kgdbts.c
39122 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
39123 char before[BREAK_INSTR_SIZE];
39124 char after[BREAK_INSTR_SIZE];
39125
39126 - probe_kernel_read(before, (char *)kgdbts_break_test,
39127 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
39128 BREAK_INSTR_SIZE);
39129 init_simple_test();
39130 ts.tst = plant_and_detach_test;
39131 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
39132 /* Activate test with initial breakpoint */
39133 if (!is_early)
39134 kgdb_breakpoint();
39135 - probe_kernel_read(after, (char *)kgdbts_break_test,
39136 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
39137 BREAK_INSTR_SIZE);
39138 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
39139 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
39140 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
39141 index 4a87e5c..76bdf5c 100644
39142 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
39143 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
39144 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
39145 * the lid is closed. This leads to interrupts as soon as a little move
39146 * is done.
39147 */
39148 - atomic_inc(&lis3->count);
39149 + atomic_inc_unchecked(&lis3->count);
39150
39151 wake_up_interruptible(&lis3->misc_wait);
39152 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
39153 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
39154 if (lis3->pm_dev)
39155 pm_runtime_get_sync(lis3->pm_dev);
39156
39157 - atomic_set(&lis3->count, 0);
39158 + atomic_set_unchecked(&lis3->count, 0);
39159 return 0;
39160 }
39161
39162 @@ -617,7 +617,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
39163 add_wait_queue(&lis3->misc_wait, &wait);
39164 while (true) {
39165 set_current_state(TASK_INTERRUPTIBLE);
39166 - data = atomic_xchg(&lis3->count, 0);
39167 + data = atomic_xchg_unchecked(&lis3->count, 0);
39168 if (data)
39169 break;
39170
39171 @@ -658,7 +658,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
39172 struct lis3lv02d, miscdev);
39173
39174 poll_wait(file, &lis3->misc_wait, wait);
39175 - if (atomic_read(&lis3->count))
39176 + if (atomic_read_unchecked(&lis3->count))
39177 return POLLIN | POLLRDNORM;
39178 return 0;
39179 }
39180 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
39181 index c439c82..1f20f57 100644
39182 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
39183 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
39184 @@ -297,7 +297,7 @@ struct lis3lv02d {
39185 struct input_polled_dev *idev; /* input device */
39186 struct platform_device *pdev; /* platform device */
39187 struct regulator_bulk_data regulators[2];
39188 - atomic_t count; /* interrupt count after last read */
39189 + atomic_unchecked_t count; /* interrupt count after last read */
39190 union axis_conversion ac; /* hw -> logical axis */
39191 int mapped_btns[3];
39192
39193 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
39194 index 2f30bad..c4c13d0 100644
39195 --- a/drivers/misc/sgi-gru/gruhandles.c
39196 +++ b/drivers/misc/sgi-gru/gruhandles.c
39197 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
39198 unsigned long nsec;
39199
39200 nsec = CLKS2NSEC(clks);
39201 - atomic_long_inc(&mcs_op_statistics[op].count);
39202 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
39203 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
39204 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
39205 if (mcs_op_statistics[op].max < nsec)
39206 mcs_op_statistics[op].max = nsec;
39207 }
39208 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
39209 index 950dbe9..eeef0f8 100644
39210 --- a/drivers/misc/sgi-gru/gruprocfs.c
39211 +++ b/drivers/misc/sgi-gru/gruprocfs.c
39212 @@ -32,9 +32,9 @@
39213
39214 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
39215
39216 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
39217 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
39218 {
39219 - unsigned long val = atomic_long_read(v);
39220 + unsigned long val = atomic_long_read_unchecked(v);
39221
39222 seq_printf(s, "%16lu %s\n", val, id);
39223 }
39224 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
39225
39226 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
39227 for (op = 0; op < mcsop_last; op++) {
39228 - count = atomic_long_read(&mcs_op_statistics[op].count);
39229 - total = atomic_long_read(&mcs_op_statistics[op].total);
39230 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
39231 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
39232 max = mcs_op_statistics[op].max;
39233 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
39234 count ? total / count : 0, max);
39235 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
39236 index 5c3ce24..4915ccb 100644
39237 --- a/drivers/misc/sgi-gru/grutables.h
39238 +++ b/drivers/misc/sgi-gru/grutables.h
39239 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
39240 * GRU statistics.
39241 */
39242 struct gru_stats_s {
39243 - atomic_long_t vdata_alloc;
39244 - atomic_long_t vdata_free;
39245 - atomic_long_t gts_alloc;
39246 - atomic_long_t gts_free;
39247 - atomic_long_t gms_alloc;
39248 - atomic_long_t gms_free;
39249 - atomic_long_t gts_double_allocate;
39250 - atomic_long_t assign_context;
39251 - atomic_long_t assign_context_failed;
39252 - atomic_long_t free_context;
39253 - atomic_long_t load_user_context;
39254 - atomic_long_t load_kernel_context;
39255 - atomic_long_t lock_kernel_context;
39256 - atomic_long_t unlock_kernel_context;
39257 - atomic_long_t steal_user_context;
39258 - atomic_long_t steal_kernel_context;
39259 - atomic_long_t steal_context_failed;
39260 - atomic_long_t nopfn;
39261 - atomic_long_t asid_new;
39262 - atomic_long_t asid_next;
39263 - atomic_long_t asid_wrap;
39264 - atomic_long_t asid_reuse;
39265 - atomic_long_t intr;
39266 - atomic_long_t intr_cbr;
39267 - atomic_long_t intr_tfh;
39268 - atomic_long_t intr_spurious;
39269 - atomic_long_t intr_mm_lock_failed;
39270 - atomic_long_t call_os;
39271 - atomic_long_t call_os_wait_queue;
39272 - atomic_long_t user_flush_tlb;
39273 - atomic_long_t user_unload_context;
39274 - atomic_long_t user_exception;
39275 - atomic_long_t set_context_option;
39276 - atomic_long_t check_context_retarget_intr;
39277 - atomic_long_t check_context_unload;
39278 - atomic_long_t tlb_dropin;
39279 - atomic_long_t tlb_preload_page;
39280 - atomic_long_t tlb_dropin_fail_no_asid;
39281 - atomic_long_t tlb_dropin_fail_upm;
39282 - atomic_long_t tlb_dropin_fail_invalid;
39283 - atomic_long_t tlb_dropin_fail_range_active;
39284 - atomic_long_t tlb_dropin_fail_idle;
39285 - atomic_long_t tlb_dropin_fail_fmm;
39286 - atomic_long_t tlb_dropin_fail_no_exception;
39287 - atomic_long_t tfh_stale_on_fault;
39288 - atomic_long_t mmu_invalidate_range;
39289 - atomic_long_t mmu_invalidate_page;
39290 - atomic_long_t flush_tlb;
39291 - atomic_long_t flush_tlb_gru;
39292 - atomic_long_t flush_tlb_gru_tgh;
39293 - atomic_long_t flush_tlb_gru_zero_asid;
39294 + atomic_long_unchecked_t vdata_alloc;
39295 + atomic_long_unchecked_t vdata_free;
39296 + atomic_long_unchecked_t gts_alloc;
39297 + atomic_long_unchecked_t gts_free;
39298 + atomic_long_unchecked_t gms_alloc;
39299 + atomic_long_unchecked_t gms_free;
39300 + atomic_long_unchecked_t gts_double_allocate;
39301 + atomic_long_unchecked_t assign_context;
39302 + atomic_long_unchecked_t assign_context_failed;
39303 + atomic_long_unchecked_t free_context;
39304 + atomic_long_unchecked_t load_user_context;
39305 + atomic_long_unchecked_t load_kernel_context;
39306 + atomic_long_unchecked_t lock_kernel_context;
39307 + atomic_long_unchecked_t unlock_kernel_context;
39308 + atomic_long_unchecked_t steal_user_context;
39309 + atomic_long_unchecked_t steal_kernel_context;
39310 + atomic_long_unchecked_t steal_context_failed;
39311 + atomic_long_unchecked_t nopfn;
39312 + atomic_long_unchecked_t asid_new;
39313 + atomic_long_unchecked_t asid_next;
39314 + atomic_long_unchecked_t asid_wrap;
39315 + atomic_long_unchecked_t asid_reuse;
39316 + atomic_long_unchecked_t intr;
39317 + atomic_long_unchecked_t intr_cbr;
39318 + atomic_long_unchecked_t intr_tfh;
39319 + atomic_long_unchecked_t intr_spurious;
39320 + atomic_long_unchecked_t intr_mm_lock_failed;
39321 + atomic_long_unchecked_t call_os;
39322 + atomic_long_unchecked_t call_os_wait_queue;
39323 + atomic_long_unchecked_t user_flush_tlb;
39324 + atomic_long_unchecked_t user_unload_context;
39325 + atomic_long_unchecked_t user_exception;
39326 + atomic_long_unchecked_t set_context_option;
39327 + atomic_long_unchecked_t check_context_retarget_intr;
39328 + atomic_long_unchecked_t check_context_unload;
39329 + atomic_long_unchecked_t tlb_dropin;
39330 + atomic_long_unchecked_t tlb_preload_page;
39331 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
39332 + atomic_long_unchecked_t tlb_dropin_fail_upm;
39333 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
39334 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
39335 + atomic_long_unchecked_t tlb_dropin_fail_idle;
39336 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
39337 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
39338 + atomic_long_unchecked_t tfh_stale_on_fault;
39339 + atomic_long_unchecked_t mmu_invalidate_range;
39340 + atomic_long_unchecked_t mmu_invalidate_page;
39341 + atomic_long_unchecked_t flush_tlb;
39342 + atomic_long_unchecked_t flush_tlb_gru;
39343 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39344 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39345
39346 - atomic_long_t copy_gpa;
39347 - atomic_long_t read_gpa;
39348 + atomic_long_unchecked_t copy_gpa;
39349 + atomic_long_unchecked_t read_gpa;
39350
39351 - atomic_long_t mesq_receive;
39352 - atomic_long_t mesq_receive_none;
39353 - atomic_long_t mesq_send;
39354 - atomic_long_t mesq_send_failed;
39355 - atomic_long_t mesq_noop;
39356 - atomic_long_t mesq_send_unexpected_error;
39357 - atomic_long_t mesq_send_lb_overflow;
39358 - atomic_long_t mesq_send_qlimit_reached;
39359 - atomic_long_t mesq_send_amo_nacked;
39360 - atomic_long_t mesq_send_put_nacked;
39361 - atomic_long_t mesq_page_overflow;
39362 - atomic_long_t mesq_qf_locked;
39363 - atomic_long_t mesq_qf_noop_not_full;
39364 - atomic_long_t mesq_qf_switch_head_failed;
39365 - atomic_long_t mesq_qf_unexpected_error;
39366 - atomic_long_t mesq_noop_unexpected_error;
39367 - atomic_long_t mesq_noop_lb_overflow;
39368 - atomic_long_t mesq_noop_qlimit_reached;
39369 - atomic_long_t mesq_noop_amo_nacked;
39370 - atomic_long_t mesq_noop_put_nacked;
39371 - atomic_long_t mesq_noop_page_overflow;
39372 + atomic_long_unchecked_t mesq_receive;
39373 + atomic_long_unchecked_t mesq_receive_none;
39374 + atomic_long_unchecked_t mesq_send;
39375 + atomic_long_unchecked_t mesq_send_failed;
39376 + atomic_long_unchecked_t mesq_noop;
39377 + atomic_long_unchecked_t mesq_send_unexpected_error;
39378 + atomic_long_unchecked_t mesq_send_lb_overflow;
39379 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39380 + atomic_long_unchecked_t mesq_send_amo_nacked;
39381 + atomic_long_unchecked_t mesq_send_put_nacked;
39382 + atomic_long_unchecked_t mesq_page_overflow;
39383 + atomic_long_unchecked_t mesq_qf_locked;
39384 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39385 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39386 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39387 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39388 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39389 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39390 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39391 + atomic_long_unchecked_t mesq_noop_put_nacked;
39392 + atomic_long_unchecked_t mesq_noop_page_overflow;
39393
39394 };
39395
39396 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39397 tghop_invalidate, mcsop_last};
39398
39399 struct mcs_op_statistic {
39400 - atomic_long_t count;
39401 - atomic_long_t total;
39402 + atomic_long_unchecked_t count;
39403 + atomic_long_unchecked_t total;
39404 unsigned long max;
39405 };
39406
39407 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39408
39409 #define STAT(id) do { \
39410 if (gru_options & OPT_STATS) \
39411 - atomic_long_inc(&gru_stats.id); \
39412 + atomic_long_inc_unchecked(&gru_stats.id); \
39413 } while (0)
39414
39415 #ifdef CONFIG_SGI_GRU_DEBUG
39416 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39417 index c862cd4..0d176fe 100644
39418 --- a/drivers/misc/sgi-xp/xp.h
39419 +++ b/drivers/misc/sgi-xp/xp.h
39420 @@ -288,7 +288,7 @@ struct xpc_interface {
39421 xpc_notify_func, void *);
39422 void (*received) (short, int, void *);
39423 enum xp_retval (*partid_to_nasids) (short, void *);
39424 -};
39425 +} __no_const;
39426
39427 extern struct xpc_interface xpc_interface;
39428
39429 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39430 index b94d5f7..7f494c5 100644
39431 --- a/drivers/misc/sgi-xp/xpc.h
39432 +++ b/drivers/misc/sgi-xp/xpc.h
39433 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39434 void (*received_payload) (struct xpc_channel *, void *);
39435 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39436 };
39437 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39438
39439 /* struct xpc_partition act_state values (for XPC HB) */
39440
39441 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39442 /* found in xpc_main.c */
39443 extern struct device *xpc_part;
39444 extern struct device *xpc_chan;
39445 -extern struct xpc_arch_operations xpc_arch_ops;
39446 +extern xpc_arch_operations_no_const xpc_arch_ops;
39447 extern int xpc_disengage_timelimit;
39448 extern int xpc_disengage_timedout;
39449 extern int xpc_activate_IRQ_rcvd;
39450 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39451 index d971817..33bdca5 100644
39452 --- a/drivers/misc/sgi-xp/xpc_main.c
39453 +++ b/drivers/misc/sgi-xp/xpc_main.c
39454 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39455 .notifier_call = xpc_system_die,
39456 };
39457
39458 -struct xpc_arch_operations xpc_arch_ops;
39459 +xpc_arch_operations_no_const xpc_arch_ops;
39460
39461 /*
39462 * Timer function to enforce the timelimit on the partition disengage.
39463 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39464
39465 if (((die_args->trapnr == X86_TRAP_MF) ||
39466 (die_args->trapnr == X86_TRAP_XF)) &&
39467 - !user_mode_vm(die_args->regs))
39468 + !user_mode(die_args->regs))
39469 xpc_die_deactivate();
39470
39471 break;
39472 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39473 index 49f04bc..65660c2 100644
39474 --- a/drivers/mmc/core/mmc_ops.c
39475 +++ b/drivers/mmc/core/mmc_ops.c
39476 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39477 void *data_buf;
39478 int is_on_stack;
39479
39480 - is_on_stack = object_is_on_stack(buf);
39481 + is_on_stack = object_starts_on_stack(buf);
39482 if (is_on_stack) {
39483 /*
39484 * dma onto stack is unsafe/nonportable, but callers to this
39485 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39486 index 53b8fd9..615b462 100644
39487 --- a/drivers/mmc/host/dw_mmc.h
39488 +++ b/drivers/mmc/host/dw_mmc.h
39489 @@ -205,5 +205,5 @@ struct dw_mci_drv_data {
39490 int (*parse_dt)(struct dw_mci *host);
39491 int (*setup_bus)(struct dw_mci *host,
39492 struct device_node *slot_np, u8 bus_width);
39493 -};
39494 +} __do_const;
39495 #endif /* _DW_MMC_H_ */
39496 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39497 index 7363efe..681558e 100644
39498 --- a/drivers/mmc/host/sdhci-s3c.c
39499 +++ b/drivers/mmc/host/sdhci-s3c.c
39500 @@ -720,9 +720,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39501 * we can use overriding functions instead of default.
39502 */
39503 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39504 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39505 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39506 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39507 + pax_open_kernel();
39508 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39509 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39510 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39511 + pax_close_kernel();
39512 }
39513
39514 /* It supports additional host capabilities if needed */
39515 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
39516 index a4eb8b5..8c0628f 100644
39517 --- a/drivers/mtd/devices/doc2000.c
39518 +++ b/drivers/mtd/devices/doc2000.c
39519 @@ -753,7 +753,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
39520
39521 /* The ECC will not be calculated correctly if less than 512 is written */
39522 /* DBB-
39523 - if (len != 0x200 && eccbuf)
39524 + if (len != 0x200)
39525 printk(KERN_WARNING
39526 "ECC needs a full sector write (adr: %lx size %lx)\n",
39527 (long) to, (long) len);
39528 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39529 index 0c8bb6b..6f35deb 100644
39530 --- a/drivers/mtd/nand/denali.c
39531 +++ b/drivers/mtd/nand/denali.c
39532 @@ -24,6 +24,7 @@
39533 #include <linux/slab.h>
39534 #include <linux/mtd/mtd.h>
39535 #include <linux/module.h>
39536 +#include <linux/slab.h>
39537
39538 #include "denali.h"
39539
39540 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39541 index 51b9d6a..52af9a7 100644
39542 --- a/drivers/mtd/nftlmount.c
39543 +++ b/drivers/mtd/nftlmount.c
39544 @@ -24,6 +24,7 @@
39545 #include <asm/errno.h>
39546 #include <linux/delay.h>
39547 #include <linux/slab.h>
39548 +#include <linux/sched.h>
39549 #include <linux/mtd/mtd.h>
39550 #include <linux/mtd/nand.h>
39551 #include <linux/mtd/nftl.h>
39552 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39553 index 8dd6ba5..419cc1d 100644
39554 --- a/drivers/mtd/sm_ftl.c
39555 +++ b/drivers/mtd/sm_ftl.c
39556 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39557 #define SM_CIS_VENDOR_OFFSET 0x59
39558 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39559 {
39560 - struct attribute_group *attr_group;
39561 + attribute_group_no_const *attr_group;
39562 struct attribute **attributes;
39563 struct sm_sysfs_attribute *vendor_attribute;
39564
39565 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39566 index dbbea0e..3f4a0b1 100644
39567 --- a/drivers/net/bonding/bond_main.c
39568 +++ b/drivers/net/bonding/bond_main.c
39569 @@ -4822,7 +4822,7 @@ static unsigned int bond_get_num_tx_queues(void)
39570 return tx_queues;
39571 }
39572
39573 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39574 +static struct rtnl_link_ops bond_link_ops = {
39575 .kind = "bond",
39576 .priv_size = sizeof(struct bonding),
39577 .setup = bond_setup,
39578 @@ -4947,8 +4947,8 @@ static void __exit bonding_exit(void)
39579
39580 bond_destroy_debugfs();
39581
39582 - rtnl_link_unregister(&bond_link_ops);
39583 unregister_pernet_subsys(&bond_net_ops);
39584 + rtnl_link_unregister(&bond_link_ops);
39585
39586 #ifdef CONFIG_NET_POLL_CONTROLLER
39587 /*
39588 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
39589 index e1d2643..7f4133b 100644
39590 --- a/drivers/net/ethernet/8390/ax88796.c
39591 +++ b/drivers/net/ethernet/8390/ax88796.c
39592 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
39593 if (ax->plat->reg_offsets)
39594 ei_local->reg_offset = ax->plat->reg_offsets;
39595 else {
39596 + resource_size_t _mem_size = mem_size;
39597 + do_div(_mem_size, 0x18);
39598 ei_local->reg_offset = ax->reg_offsets;
39599 for (ret = 0; ret < 0x18; ret++)
39600 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
39601 + ax->reg_offsets[ret] = _mem_size * ret;
39602 }
39603
39604 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
39605 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39606 index aee7671..3ca2651 100644
39607 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39608 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39609 @@ -1093,7 +1093,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
39610 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
39611 {
39612 /* RX_MODE controlling object */
39613 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
39614 + bnx2x_init_rx_mode_obj(bp);
39615
39616 /* multicast configuration controlling object */
39617 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
39618 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39619 index 7306416..5fb7fb5 100644
39620 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39621 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39622 @@ -2381,15 +2381,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
39623 return rc;
39624 }
39625
39626 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39627 - struct bnx2x_rx_mode_obj *o)
39628 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
39629 {
39630 if (CHIP_IS_E1x(bp)) {
39631 - o->wait_comp = bnx2x_empty_rx_mode_wait;
39632 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
39633 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
39634 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
39635 } else {
39636 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
39637 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
39638 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
39639 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
39640 }
39641 }
39642
39643 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39644 index ff90760..08d8aed 100644
39645 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39646 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39647 @@ -1306,8 +1306,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
39648
39649 /********************* RX MODE ****************/
39650
39651 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39652 - struct bnx2x_rx_mode_obj *o);
39653 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
39654
39655 /**
39656 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
39657 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
39658 index 8d7d4c2..95f7681 100644
39659 --- a/drivers/net/ethernet/broadcom/tg3.h
39660 +++ b/drivers/net/ethernet/broadcom/tg3.h
39661 @@ -147,6 +147,7 @@
39662 #define CHIPREV_ID_5750_A0 0x4000
39663 #define CHIPREV_ID_5750_A1 0x4001
39664 #define CHIPREV_ID_5750_A3 0x4003
39665 +#define CHIPREV_ID_5750_C1 0x4201
39666 #define CHIPREV_ID_5750_C2 0x4202
39667 #define CHIPREV_ID_5752_A0_HW 0x5000
39668 #define CHIPREV_ID_5752_A0 0x6000
39669 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39670 index 8cffcdf..aadf043 100644
39671 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39672 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39673 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
39674 */
39675 struct l2t_skb_cb {
39676 arp_failure_handler_func arp_failure_handler;
39677 -};
39678 +} __no_const;
39679
39680 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
39681
39682 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
39683 index 4c83003..2a2a5b9 100644
39684 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
39685 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
39686 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39687 for (i=0; i<ETH_ALEN; i++) {
39688 tmp.addr[i] = dev->dev_addr[i];
39689 }
39690 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39691 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39692 break;
39693
39694 case DE4X5_SET_HWADDR: /* Set the hardware address */
39695 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39696 spin_lock_irqsave(&lp->lock, flags);
39697 memcpy(&statbuf, &lp->pktStats, ioc->len);
39698 spin_unlock_irqrestore(&lp->lock, flags);
39699 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
39700 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
39701 return -EFAULT;
39702 break;
39703 }
39704 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
39705 index 2886c9b..db71673 100644
39706 --- a/drivers/net/ethernet/emulex/benet/be_main.c
39707 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
39708 @@ -455,7 +455,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
39709
39710 if (wrapped)
39711 newacc += 65536;
39712 - ACCESS_ONCE(*acc) = newacc;
39713 + ACCESS_ONCE_RW(*acc) = newacc;
39714 }
39715
39716 void be_parse_stats(struct be_adapter *adapter)
39717 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
39718 index 7c361d1..57e3ff1 100644
39719 --- a/drivers/net/ethernet/faraday/ftgmac100.c
39720 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
39721 @@ -31,6 +31,8 @@
39722 #include <linux/netdevice.h>
39723 #include <linux/phy.h>
39724 #include <linux/platform_device.h>
39725 +#include <linux/interrupt.h>
39726 +#include <linux/irqreturn.h>
39727 #include <net/ip.h>
39728
39729 #include "ftgmac100.h"
39730 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
39731 index b5ea8fb..bd25e9a 100644
39732 --- a/drivers/net/ethernet/faraday/ftmac100.c
39733 +++ b/drivers/net/ethernet/faraday/ftmac100.c
39734 @@ -31,6 +31,8 @@
39735 #include <linux/module.h>
39736 #include <linux/netdevice.h>
39737 #include <linux/platform_device.h>
39738 +#include <linux/interrupt.h>
39739 +#include <linux/irqreturn.h>
39740
39741 #include "ftmac100.h"
39742
39743 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39744 index 331987d..3be1135 100644
39745 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39746 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
39747 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
39748 }
39749
39750 /* update the base incval used to calculate frequency adjustment */
39751 - ACCESS_ONCE(adapter->base_incval) = incval;
39752 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
39753 smp_mb();
39754
39755 /* need lock to prevent incorrect read while modifying cyclecounter */
39756 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39757 index fbe5363..266b4e3 100644
39758 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
39759 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
39760 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39761 struct __vxge_hw_fifo *fifo;
39762 struct vxge_hw_fifo_config *config;
39763 u32 txdl_size, txdl_per_memblock;
39764 - struct vxge_hw_mempool_cbs fifo_mp_callback;
39765 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
39766 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
39767 + };
39768 +
39769 struct __vxge_hw_virtualpath *vpath;
39770
39771 if ((vp == NULL) || (attr == NULL)) {
39772 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
39773 goto exit;
39774 }
39775
39776 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
39777 -
39778 fifo->mempool =
39779 __vxge_hw_mempool_create(vpath->hldev,
39780 fifo->config->memblock_size,
39781 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
39782 index 5c033f2..7bbb0d8 100644
39783 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
39784 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
39785 @@ -1894,7 +1894,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
39786 op_mode = QLCRDX(ahw, QLC_83XX_DRV_OP_MODE);
39787
39788 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
39789 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
39790 + pax_open_kernel();
39791 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
39792 + pax_close_kernel();
39793 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
39794 } else {
39795 return -EIO;
39796 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
39797 index b0c3de9..fc5857e 100644
39798 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
39799 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
39800 @@ -200,15 +200,21 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
39801 if (priv_level == QLCNIC_NON_PRIV_FUNC) {
39802 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
39803 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
39804 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
39805 + pax_open_kernel();
39806 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
39807 + pax_close_kernel();
39808 } else if (priv_level == QLCNIC_PRIV_FUNC) {
39809 ahw->op_mode = QLCNIC_PRIV_FUNC;
39810 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
39811 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
39812 + pax_open_kernel();
39813 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
39814 + pax_close_kernel();
39815 } else if (priv_level == QLCNIC_MGMT_FUNC) {
39816 ahw->op_mode = QLCNIC_MGMT_FUNC;
39817 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
39818 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
39819 + pax_open_kernel();
39820 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
39821 + pax_close_kernel();
39822 } else {
39823 return -EIO;
39824 }
39825 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
39826 index 15ba8c4..3f56838 100644
39827 --- a/drivers/net/ethernet/realtek/r8169.c
39828 +++ b/drivers/net/ethernet/realtek/r8169.c
39829 @@ -740,22 +740,22 @@ struct rtl8169_private {
39830 struct mdio_ops {
39831 void (*write)(struct rtl8169_private *, int, int);
39832 int (*read)(struct rtl8169_private *, int);
39833 - } mdio_ops;
39834 + } __no_const mdio_ops;
39835
39836 struct pll_power_ops {
39837 void (*down)(struct rtl8169_private *);
39838 void (*up)(struct rtl8169_private *);
39839 - } pll_power_ops;
39840 + } __no_const pll_power_ops;
39841
39842 struct jumbo_ops {
39843 void (*enable)(struct rtl8169_private *);
39844 void (*disable)(struct rtl8169_private *);
39845 - } jumbo_ops;
39846 + } __no_const jumbo_ops;
39847
39848 struct csi_ops {
39849 void (*write)(struct rtl8169_private *, int, int);
39850 u32 (*read)(struct rtl8169_private *, int);
39851 - } csi_ops;
39852 + } __no_const csi_ops;
39853
39854 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
39855 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
39856 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
39857 index 3f93624..cf01144 100644
39858 --- a/drivers/net/ethernet/sfc/ptp.c
39859 +++ b/drivers/net/ethernet/sfc/ptp.c
39860 @@ -553,7 +553,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
39861 (u32)((u64)ptp->start.dma_addr >> 32));
39862
39863 /* Clear flag that signals MC ready */
39864 - ACCESS_ONCE(*start) = 0;
39865 + ACCESS_ONCE_RW(*start) = 0;
39866 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
39867 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
39868
39869 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39870 index 50617c5..b13724c 100644
39871 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39872 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
39873 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
39874
39875 writel(value, ioaddr + MMC_CNTRL);
39876
39877 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
39878 - MMC_CNTRL, value);
39879 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
39880 +// MMC_CNTRL, value);
39881 }
39882
39883 /* To mask all all interrupts.*/
39884 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
39885 index e6fe0d8..2b7d752 100644
39886 --- a/drivers/net/hyperv/hyperv_net.h
39887 +++ b/drivers/net/hyperv/hyperv_net.h
39888 @@ -101,7 +101,7 @@ struct rndis_device {
39889
39890 enum rndis_device_state state;
39891 bool link_state;
39892 - atomic_t new_req_id;
39893 + atomic_unchecked_t new_req_id;
39894
39895 spinlock_t request_lock;
39896 struct list_head req_list;
39897 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
39898 index 0775f0a..d4fb316 100644
39899 --- a/drivers/net/hyperv/rndis_filter.c
39900 +++ b/drivers/net/hyperv/rndis_filter.c
39901 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
39902 * template
39903 */
39904 set = &rndis_msg->msg.set_req;
39905 - set->req_id = atomic_inc_return(&dev->new_req_id);
39906 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
39907
39908 /* Add to the request list */
39909 spin_lock_irqsave(&dev->request_lock, flags);
39910 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
39911
39912 /* Setup the rndis set */
39913 halt = &request->request_msg.msg.halt_req;
39914 - halt->req_id = atomic_inc_return(&dev->new_req_id);
39915 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
39916
39917 /* Ignore return since this msg is optional. */
39918 rndis_filter_send_request(dev, request);
39919 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
39920 index 8f1c256..a2991d1 100644
39921 --- a/drivers/net/ieee802154/fakehard.c
39922 +++ b/drivers/net/ieee802154/fakehard.c
39923 @@ -385,7 +385,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
39924 phy->transmit_power = 0xbf;
39925
39926 dev->netdev_ops = &fake_ops;
39927 - dev->ml_priv = &fake_mlme;
39928 + dev->ml_priv = (void *)&fake_mlme;
39929
39930 priv = netdev_priv(dev);
39931 priv->phy = phy;
39932 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
39933 index 011062e..ada88e9 100644
39934 --- a/drivers/net/macvlan.c
39935 +++ b/drivers/net/macvlan.c
39936 @@ -892,13 +892,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
39937 int macvlan_link_register(struct rtnl_link_ops *ops)
39938 {
39939 /* common fields */
39940 - ops->priv_size = sizeof(struct macvlan_dev);
39941 - ops->validate = macvlan_validate;
39942 - ops->maxtype = IFLA_MACVLAN_MAX;
39943 - ops->policy = macvlan_policy;
39944 - ops->changelink = macvlan_changelink;
39945 - ops->get_size = macvlan_get_size;
39946 - ops->fill_info = macvlan_fill_info;
39947 + pax_open_kernel();
39948 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
39949 + *(void **)&ops->validate = macvlan_validate;
39950 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
39951 + *(const void **)&ops->policy = macvlan_policy;
39952 + *(void **)&ops->changelink = macvlan_changelink;
39953 + *(void **)&ops->get_size = macvlan_get_size;
39954 + *(void **)&ops->fill_info = macvlan_fill_info;
39955 + pax_close_kernel();
39956
39957 return rtnl_link_register(ops);
39958 };
39959 @@ -954,7 +956,7 @@ static int macvlan_device_event(struct notifier_block *unused,
39960 return NOTIFY_DONE;
39961 }
39962
39963 -static struct notifier_block macvlan_notifier_block __read_mostly = {
39964 +static struct notifier_block macvlan_notifier_block = {
39965 .notifier_call = macvlan_device_event,
39966 };
39967
39968 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
39969 index a449439..1e468fe 100644
39970 --- a/drivers/net/macvtap.c
39971 +++ b/drivers/net/macvtap.c
39972 @@ -1090,7 +1090,7 @@ static int macvtap_device_event(struct notifier_block *unused,
39973 return NOTIFY_DONE;
39974 }
39975
39976 -static struct notifier_block macvtap_notifier_block __read_mostly = {
39977 +static struct notifier_block macvtap_notifier_block = {
39978 .notifier_call = macvtap_device_event,
39979 };
39980
39981 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
39982 index daec9b0..6428fcb 100644
39983 --- a/drivers/net/phy/mdio-bitbang.c
39984 +++ b/drivers/net/phy/mdio-bitbang.c
39985 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
39986 struct mdiobb_ctrl *ctrl = bus->priv;
39987
39988 module_put(ctrl->ops->owner);
39989 + mdiobus_unregister(bus);
39990 mdiobus_free(bus);
39991 }
39992 EXPORT_SYMBOL(free_mdio_bitbang);
39993 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
39994 index 72ff14b..11d442d 100644
39995 --- a/drivers/net/ppp/ppp_generic.c
39996 +++ b/drivers/net/ppp/ppp_generic.c
39997 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
39998 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
39999 struct ppp_stats stats;
40000 struct ppp_comp_stats cstats;
40001 - char *vers;
40002
40003 switch (cmd) {
40004 case SIOCGPPPSTATS:
40005 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40006 break;
40007
40008 case SIOCGPPPVER:
40009 - vers = PPP_VERSION;
40010 - if (copy_to_user(addr, vers, strlen(vers) + 1))
40011 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
40012 break;
40013 err = 0;
40014 break;
40015 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
40016 index 1252d9c..80e660b 100644
40017 --- a/drivers/net/slip/slhc.c
40018 +++ b/drivers/net/slip/slhc.c
40019 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
40020 register struct tcphdr *thp;
40021 register struct iphdr *ip;
40022 register struct cstate *cs;
40023 - int len, hdrlen;
40024 + long len, hdrlen;
40025 unsigned char *cp = icp;
40026
40027 /* We've got a compressed packet; read the change byte */
40028 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
40029 index bf34192..fba3500 100644
40030 --- a/drivers/net/team/team.c
40031 +++ b/drivers/net/team/team.c
40032 @@ -2668,7 +2668,7 @@ static int team_device_event(struct notifier_block *unused,
40033 return NOTIFY_DONE;
40034 }
40035
40036 -static struct notifier_block team_notifier_block __read_mostly = {
40037 +static struct notifier_block team_notifier_block = {
40038 .notifier_call = team_device_event,
40039 };
40040
40041 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
40042 index 755fa9e..631fdce 100644
40043 --- a/drivers/net/tun.c
40044 +++ b/drivers/net/tun.c
40045 @@ -1841,7 +1841,7 @@ unlock:
40046 }
40047
40048 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40049 - unsigned long arg, int ifreq_len)
40050 + unsigned long arg, size_t ifreq_len)
40051 {
40052 struct tun_file *tfile = file->private_data;
40053 struct tun_struct *tun;
40054 @@ -1853,6 +1853,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40055 int vnet_hdr_sz;
40056 int ret;
40057
40058 + if (ifreq_len > sizeof ifr)
40059 + return -EFAULT;
40060 +
40061 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
40062 if (copy_from_user(&ifr, argp, ifreq_len))
40063 return -EFAULT;
40064 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
40065 index e2dd324..be92fcf 100644
40066 --- a/drivers/net/usb/hso.c
40067 +++ b/drivers/net/usb/hso.c
40068 @@ -71,7 +71,7 @@
40069 #include <asm/byteorder.h>
40070 #include <linux/serial_core.h>
40071 #include <linux/serial.h>
40072 -
40073 +#include <asm/local.h>
40074
40075 #define MOD_AUTHOR "Option Wireless"
40076 #define MOD_DESCRIPTION "USB High Speed Option driver"
40077 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
40078 struct urb *urb;
40079
40080 urb = serial->rx_urb[0];
40081 - if (serial->port.count > 0) {
40082 + if (atomic_read(&serial->port.count) > 0) {
40083 count = put_rxbuf_data(urb, serial);
40084 if (count == -1)
40085 return;
40086 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
40087 DUMP1(urb->transfer_buffer, urb->actual_length);
40088
40089 /* Anyone listening? */
40090 - if (serial->port.count == 0)
40091 + if (atomic_read(&serial->port.count) == 0)
40092 return;
40093
40094 if (status == 0) {
40095 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40096 tty_port_tty_set(&serial->port, tty);
40097
40098 /* check for port already opened, if not set the termios */
40099 - serial->port.count++;
40100 - if (serial->port.count == 1) {
40101 + if (atomic_inc_return(&serial->port.count) == 1) {
40102 serial->rx_state = RX_IDLE;
40103 /* Force default termio settings */
40104 _hso_serial_set_termios(tty, NULL);
40105 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40106 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
40107 if (result) {
40108 hso_stop_serial_device(serial->parent);
40109 - serial->port.count--;
40110 + atomic_dec(&serial->port.count);
40111 kref_put(&serial->parent->ref, hso_serial_ref_free);
40112 }
40113 } else {
40114 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
40115
40116 /* reset the rts and dtr */
40117 /* do the actual close */
40118 - serial->port.count--;
40119 + atomic_dec(&serial->port.count);
40120
40121 - if (serial->port.count <= 0) {
40122 - serial->port.count = 0;
40123 + if (atomic_read(&serial->port.count) <= 0) {
40124 + atomic_set(&serial->port.count, 0);
40125 tty_port_tty_set(&serial->port, NULL);
40126 if (!usb_gone)
40127 hso_stop_serial_device(serial->parent);
40128 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
40129
40130 /* the actual setup */
40131 spin_lock_irqsave(&serial->serial_lock, flags);
40132 - if (serial->port.count)
40133 + if (atomic_read(&serial->port.count))
40134 _hso_serial_set_termios(tty, old);
40135 else
40136 tty->termios = *old;
40137 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
40138 D1("Pending read interrupt on port %d\n", i);
40139 spin_lock(&serial->serial_lock);
40140 if (serial->rx_state == RX_IDLE &&
40141 - serial->port.count > 0) {
40142 + atomic_read(&serial->port.count) > 0) {
40143 /* Setup and send a ctrl req read on
40144 * port i */
40145 if (!serial->rx_urb_filled[0]) {
40146 @@ -3066,7 +3065,7 @@ static int hso_resume(struct usb_interface *iface)
40147 /* Start all serial ports */
40148 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
40149 if (serial_table[i] && (serial_table[i]->interface == iface)) {
40150 - if (dev2ser(serial_table[i])->port.count) {
40151 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
40152 result =
40153 hso_start_serial_device(serial_table[i], GFP_NOIO);
40154 hso_kick_transmit(dev2ser(serial_table[i]));
40155 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
40156 index 7cee7a3..1eb9f3b 100644
40157 --- a/drivers/net/vxlan.c
40158 +++ b/drivers/net/vxlan.c
40159 @@ -1443,7 +1443,7 @@ nla_put_failure:
40160 return -EMSGSIZE;
40161 }
40162
40163 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
40164 +static struct rtnl_link_ops vxlan_link_ops = {
40165 .kind = "vxlan",
40166 .maxtype = IFLA_VXLAN_MAX,
40167 .policy = vxlan_policy,
40168 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
40169 index 5ac5f7a..5f82012 100644
40170 --- a/drivers/net/wireless/at76c50x-usb.c
40171 +++ b/drivers/net/wireless/at76c50x-usb.c
40172 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
40173 }
40174
40175 /* Convert timeout from the DFU status to jiffies */
40176 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
40177 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
40178 {
40179 return msecs_to_jiffies((s->poll_timeout[2] << 16)
40180 | (s->poll_timeout[1] << 8)
40181 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40182 index 8d78253..bebbb68 100644
40183 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40184 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40185 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40186 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
40187 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
40188
40189 - ACCESS_ONCE(ads->ds_link) = i->link;
40190 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
40191 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
40192 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
40193
40194 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
40195 ctl6 = SM(i->keytype, AR_EncrType);
40196 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40197
40198 if ((i->is_first || i->is_last) &&
40199 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
40200 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
40201 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
40202 | set11nTries(i->rates, 1)
40203 | set11nTries(i->rates, 2)
40204 | set11nTries(i->rates, 3)
40205 | (i->dur_update ? AR_DurUpdateEna : 0)
40206 | SM(0, AR_BurstDur);
40207
40208 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
40209 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
40210 | set11nRate(i->rates, 1)
40211 | set11nRate(i->rates, 2)
40212 | set11nRate(i->rates, 3);
40213 } else {
40214 - ACCESS_ONCE(ads->ds_ctl2) = 0;
40215 - ACCESS_ONCE(ads->ds_ctl3) = 0;
40216 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
40217 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
40218 }
40219
40220 if (!i->is_first) {
40221 - ACCESS_ONCE(ads->ds_ctl0) = 0;
40222 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40223 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40224 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
40225 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40226 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40227 return;
40228 }
40229
40230 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40231 break;
40232 }
40233
40234 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40235 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40236 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40237 | SM(i->txpower, AR_XmitPower)
40238 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40239 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40240 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
40241 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
40242
40243 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40244 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40245 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40246 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40247
40248 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
40249 return;
40250
40251 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40252 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40253 | set11nPktDurRTSCTS(i->rates, 1);
40254
40255 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40256 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40257 | set11nPktDurRTSCTS(i->rates, 3);
40258
40259 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40260 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40261 | set11nRateFlags(i->rates, 1)
40262 | set11nRateFlags(i->rates, 2)
40263 | set11nRateFlags(i->rates, 3)
40264 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40265 index 301bf72..3f5654f 100644
40266 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40267 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40268 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40269 (i->qcu << AR_TxQcuNum_S) | desc_len;
40270
40271 checksum += val;
40272 - ACCESS_ONCE(ads->info) = val;
40273 + ACCESS_ONCE_RW(ads->info) = val;
40274
40275 checksum += i->link;
40276 - ACCESS_ONCE(ads->link) = i->link;
40277 + ACCESS_ONCE_RW(ads->link) = i->link;
40278
40279 checksum += i->buf_addr[0];
40280 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
40281 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
40282 checksum += i->buf_addr[1];
40283 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
40284 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
40285 checksum += i->buf_addr[2];
40286 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
40287 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
40288 checksum += i->buf_addr[3];
40289 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
40290 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
40291
40292 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
40293 - ACCESS_ONCE(ads->ctl3) = val;
40294 + ACCESS_ONCE_RW(ads->ctl3) = val;
40295 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
40296 - ACCESS_ONCE(ads->ctl5) = val;
40297 + ACCESS_ONCE_RW(ads->ctl5) = val;
40298 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
40299 - ACCESS_ONCE(ads->ctl7) = val;
40300 + ACCESS_ONCE_RW(ads->ctl7) = val;
40301 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
40302 - ACCESS_ONCE(ads->ctl9) = val;
40303 + ACCESS_ONCE_RW(ads->ctl9) = val;
40304
40305 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
40306 - ACCESS_ONCE(ads->ctl10) = checksum;
40307 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
40308
40309 if (i->is_first || i->is_last) {
40310 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
40311 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
40312 | set11nTries(i->rates, 1)
40313 | set11nTries(i->rates, 2)
40314 | set11nTries(i->rates, 3)
40315 | (i->dur_update ? AR_DurUpdateEna : 0)
40316 | SM(0, AR_BurstDur);
40317
40318 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
40319 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
40320 | set11nRate(i->rates, 1)
40321 | set11nRate(i->rates, 2)
40322 | set11nRate(i->rates, 3);
40323 } else {
40324 - ACCESS_ONCE(ads->ctl13) = 0;
40325 - ACCESS_ONCE(ads->ctl14) = 0;
40326 + ACCESS_ONCE_RW(ads->ctl13) = 0;
40327 + ACCESS_ONCE_RW(ads->ctl14) = 0;
40328 }
40329
40330 ads->ctl20 = 0;
40331 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40332
40333 ctl17 = SM(i->keytype, AR_EncrType);
40334 if (!i->is_first) {
40335 - ACCESS_ONCE(ads->ctl11) = 0;
40336 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40337 - ACCESS_ONCE(ads->ctl15) = 0;
40338 - ACCESS_ONCE(ads->ctl16) = 0;
40339 - ACCESS_ONCE(ads->ctl17) = ctl17;
40340 - ACCESS_ONCE(ads->ctl18) = 0;
40341 - ACCESS_ONCE(ads->ctl19) = 0;
40342 + ACCESS_ONCE_RW(ads->ctl11) = 0;
40343 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40344 + ACCESS_ONCE_RW(ads->ctl15) = 0;
40345 + ACCESS_ONCE_RW(ads->ctl16) = 0;
40346 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40347 + ACCESS_ONCE_RW(ads->ctl18) = 0;
40348 + ACCESS_ONCE_RW(ads->ctl19) = 0;
40349 return;
40350 }
40351
40352 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40353 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40354 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40355 | SM(i->txpower, AR_XmitPower)
40356 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40357 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40358 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
40359 ctl12 |= SM(val, AR_PAPRDChainMask);
40360
40361 - ACCESS_ONCE(ads->ctl12) = ctl12;
40362 - ACCESS_ONCE(ads->ctl17) = ctl17;
40363 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
40364 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40365
40366 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40367 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40368 | set11nPktDurRTSCTS(i->rates, 1);
40369
40370 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40371 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40372 | set11nPktDurRTSCTS(i->rates, 3);
40373
40374 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
40375 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
40376 | set11nRateFlags(i->rates, 1)
40377 | set11nRateFlags(i->rates, 2)
40378 | set11nRateFlags(i->rates, 3)
40379 | SM(i->rtscts_rate, AR_RTSCTSRate);
40380
40381 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
40382 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
40383 }
40384
40385 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
40386 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
40387 index 784e81c..349e01e 100644
40388 --- a/drivers/net/wireless/ath/ath9k/hw.h
40389 +++ b/drivers/net/wireless/ath/ath9k/hw.h
40390 @@ -653,7 +653,7 @@ struct ath_hw_private_ops {
40391
40392 /* ANI */
40393 void (*ani_cache_ini_regs)(struct ath_hw *ah);
40394 -};
40395 +} __no_const;
40396
40397 /**
40398 * struct ath_spec_scan - parameters for Atheros spectral scan
40399 @@ -722,7 +722,7 @@ struct ath_hw_ops {
40400 struct ath_spec_scan *param);
40401 void (*spectral_scan_trigger)(struct ath_hw *ah);
40402 void (*spectral_scan_wait)(struct ath_hw *ah);
40403 -};
40404 +} __no_const;
40405
40406 struct ath_nf_limits {
40407 s16 max;
40408 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
40409 index c353b5f..62aaca2 100644
40410 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
40411 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
40412 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40413 */
40414 if (il3945_mod_params.disable_hw_scan) {
40415 D_INFO("Disabling hw_scan\n");
40416 - il3945_mac_ops.hw_scan = NULL;
40417 + pax_open_kernel();
40418 + *(void **)&il3945_mac_ops.hw_scan = NULL;
40419 + pax_close_kernel();
40420 }
40421
40422 D_INFO("*** LOAD DRIVER ***\n");
40423 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40424 index 81d4071..f2071ea 100644
40425 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40426 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40427 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
40428 {
40429 struct iwl_priv *priv = file->private_data;
40430 char buf[64];
40431 - int buf_size;
40432 + size_t buf_size;
40433 u32 offset, len;
40434
40435 memset(buf, 0, sizeof(buf));
40436 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
40437 struct iwl_priv *priv = file->private_data;
40438
40439 char buf[8];
40440 - int buf_size;
40441 + size_t buf_size;
40442 u32 reset_flag;
40443
40444 memset(buf, 0, sizeof(buf));
40445 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
40446 {
40447 struct iwl_priv *priv = file->private_data;
40448 char buf[8];
40449 - int buf_size;
40450 + size_t buf_size;
40451 int ht40;
40452
40453 memset(buf, 0, sizeof(buf));
40454 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
40455 {
40456 struct iwl_priv *priv = file->private_data;
40457 char buf[8];
40458 - int buf_size;
40459 + size_t buf_size;
40460 int value;
40461
40462 memset(buf, 0, sizeof(buf));
40463 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
40464 {
40465 struct iwl_priv *priv = file->private_data;
40466 char buf[8];
40467 - int buf_size;
40468 + size_t buf_size;
40469 int clear;
40470
40471 memset(buf, 0, sizeof(buf));
40472 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
40473 {
40474 struct iwl_priv *priv = file->private_data;
40475 char buf[8];
40476 - int buf_size;
40477 + size_t buf_size;
40478 int trace;
40479
40480 memset(buf, 0, sizeof(buf));
40481 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
40482 {
40483 struct iwl_priv *priv = file->private_data;
40484 char buf[8];
40485 - int buf_size;
40486 + size_t buf_size;
40487 int missed;
40488
40489 memset(buf, 0, sizeof(buf));
40490 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
40491
40492 struct iwl_priv *priv = file->private_data;
40493 char buf[8];
40494 - int buf_size;
40495 + size_t buf_size;
40496 int plcp;
40497
40498 memset(buf, 0, sizeof(buf));
40499 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
40500
40501 struct iwl_priv *priv = file->private_data;
40502 char buf[8];
40503 - int buf_size;
40504 + size_t buf_size;
40505 int flush;
40506
40507 memset(buf, 0, sizeof(buf));
40508 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
40509
40510 struct iwl_priv *priv = file->private_data;
40511 char buf[8];
40512 - int buf_size;
40513 + size_t buf_size;
40514 int rts;
40515
40516 if (!priv->cfg->ht_params)
40517 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
40518 {
40519 struct iwl_priv *priv = file->private_data;
40520 char buf[8];
40521 - int buf_size;
40522 + size_t buf_size;
40523
40524 memset(buf, 0, sizeof(buf));
40525 buf_size = min(count, sizeof(buf) - 1);
40526 @@ -2256,7 +2256,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
40527 struct iwl_priv *priv = file->private_data;
40528 u32 event_log_flag;
40529 char buf[8];
40530 - int buf_size;
40531 + size_t buf_size;
40532
40533 /* check that the interface is up */
40534 if (!iwl_is_ready(priv))
40535 @@ -2310,7 +2310,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
40536 struct iwl_priv *priv = file->private_data;
40537 char buf[8];
40538 u32 calib_disabled;
40539 - int buf_size;
40540 + size_t buf_size;
40541
40542 memset(buf, 0, sizeof(buf));
40543 buf_size = min(count, sizeof(buf) - 1);
40544 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
40545 index 12c4f31..484d948 100644
40546 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
40547 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
40548 @@ -1328,7 +1328,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
40549 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
40550
40551 char buf[8];
40552 - int buf_size;
40553 + size_t buf_size;
40554 u32 reset_flag;
40555
40556 memset(buf, 0, sizeof(buf));
40557 @@ -1349,7 +1349,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
40558 {
40559 struct iwl_trans *trans = file->private_data;
40560 char buf[8];
40561 - int buf_size;
40562 + size_t buf_size;
40563 int csr;
40564
40565 memset(buf, 0, sizeof(buf));
40566 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
40567 index cffdf4f..7cefb69 100644
40568 --- a/drivers/net/wireless/mac80211_hwsim.c
40569 +++ b/drivers/net/wireless/mac80211_hwsim.c
40570 @@ -2144,25 +2144,19 @@ static int __init init_mac80211_hwsim(void)
40571
40572 if (channels > 1) {
40573 hwsim_if_comb.num_different_channels = channels;
40574 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40575 - mac80211_hwsim_ops.cancel_hw_scan =
40576 - mac80211_hwsim_cancel_hw_scan;
40577 - mac80211_hwsim_ops.sw_scan_start = NULL;
40578 - mac80211_hwsim_ops.sw_scan_complete = NULL;
40579 - mac80211_hwsim_ops.remain_on_channel =
40580 - mac80211_hwsim_roc;
40581 - mac80211_hwsim_ops.cancel_remain_on_channel =
40582 - mac80211_hwsim_croc;
40583 - mac80211_hwsim_ops.add_chanctx =
40584 - mac80211_hwsim_add_chanctx;
40585 - mac80211_hwsim_ops.remove_chanctx =
40586 - mac80211_hwsim_remove_chanctx;
40587 - mac80211_hwsim_ops.change_chanctx =
40588 - mac80211_hwsim_change_chanctx;
40589 - mac80211_hwsim_ops.assign_vif_chanctx =
40590 - mac80211_hwsim_assign_vif_chanctx;
40591 - mac80211_hwsim_ops.unassign_vif_chanctx =
40592 - mac80211_hwsim_unassign_vif_chanctx;
40593 + pax_open_kernel();
40594 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40595 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
40596 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
40597 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
40598 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
40599 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
40600 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
40601 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
40602 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
40603 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
40604 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
40605 + pax_close_kernel();
40606 }
40607
40608 spin_lock_init(&hwsim_radio_lock);
40609 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
40610 index 525fd75..6c9f791 100644
40611 --- a/drivers/net/wireless/rndis_wlan.c
40612 +++ b/drivers/net/wireless/rndis_wlan.c
40613 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
40614
40615 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
40616
40617 - if (rts_threshold < 0 || rts_threshold > 2347)
40618 + if (rts_threshold > 2347)
40619 rts_threshold = 2347;
40620
40621 tmp = cpu_to_le32(rts_threshold);
40622 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
40623 index 086abb4..8279c30 100644
40624 --- a/drivers/net/wireless/rt2x00/rt2x00.h
40625 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
40626 @@ -396,7 +396,7 @@ struct rt2x00_intf {
40627 * for hardware which doesn't support hardware
40628 * sequence counting.
40629 */
40630 - atomic_t seqno;
40631 + atomic_unchecked_t seqno;
40632 };
40633
40634 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
40635 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
40636 index 4d91795..62fccff 100644
40637 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
40638 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
40639 @@ -251,9 +251,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
40640 * sequence counter given by mac80211.
40641 */
40642 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
40643 - seqno = atomic_add_return(0x10, &intf->seqno);
40644 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
40645 else
40646 - seqno = atomic_read(&intf->seqno);
40647 + seqno = atomic_read_unchecked(&intf->seqno);
40648
40649 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
40650 hdr->seq_ctrl |= cpu_to_le16(seqno);
40651 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
40652 index e57ee48..541cf6c 100644
40653 --- a/drivers/net/wireless/ti/wl1251/sdio.c
40654 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
40655 @@ -269,13 +269,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
40656
40657 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
40658
40659 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40660 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40661 + pax_open_kernel();
40662 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40663 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40664 + pax_close_kernel();
40665
40666 wl1251_info("using dedicated interrupt line");
40667 } else {
40668 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40669 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40670 + pax_open_kernel();
40671 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40672 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40673 + pax_close_kernel();
40674
40675 wl1251_info("using SDIO interrupt");
40676 }
40677 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
40678 index 09694e3..24ccec7 100644
40679 --- a/drivers/net/wireless/ti/wl12xx/main.c
40680 +++ b/drivers/net/wireless/ti/wl12xx/main.c
40681 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40682 sizeof(wl->conf.mem));
40683
40684 /* read data preparation is only needed by wl127x */
40685 - wl->ops->prepare_read = wl127x_prepare_read;
40686 + pax_open_kernel();
40687 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40688 + pax_close_kernel();
40689
40690 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
40691 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
40692 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40693 sizeof(wl->conf.mem));
40694
40695 /* read data preparation is only needed by wl127x */
40696 - wl->ops->prepare_read = wl127x_prepare_read;
40697 + pax_open_kernel();
40698 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40699 + pax_close_kernel();
40700
40701 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
40702 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
40703 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
40704 index da3ef1b..4790b95 100644
40705 --- a/drivers/net/wireless/ti/wl18xx/main.c
40706 +++ b/drivers/net/wireless/ti/wl18xx/main.c
40707 @@ -1664,8 +1664,10 @@ static int wl18xx_setup(struct wl1271 *wl)
40708 }
40709
40710 if (!checksum_param) {
40711 - wl18xx_ops.set_rx_csum = NULL;
40712 - wl18xx_ops.init_vif = NULL;
40713 + pax_open_kernel();
40714 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
40715 + *(void **)&wl18xx_ops.init_vif = NULL;
40716 + pax_close_kernel();
40717 }
40718
40719 /* Enable 11a Band only if we have 5G antennas */
40720 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
40721 index 7ef0b4a..ff65c28 100644
40722 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
40723 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
40724 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
40725 {
40726 struct zd_usb *usb = urb->context;
40727 struct zd_usb_interrupt *intr = &usb->intr;
40728 - int len;
40729 + unsigned int len;
40730 u16 int_num;
40731
40732 ZD_ASSERT(in_interrupt());
40733 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
40734 index d93b2b6..ae50401 100644
40735 --- a/drivers/oprofile/buffer_sync.c
40736 +++ b/drivers/oprofile/buffer_sync.c
40737 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
40738 if (cookie == NO_COOKIE)
40739 offset = pc;
40740 if (cookie == INVALID_COOKIE) {
40741 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
40742 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
40743 offset = pc;
40744 }
40745 if (cookie != last_cookie) {
40746 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
40747 /* add userspace sample */
40748
40749 if (!mm) {
40750 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
40751 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
40752 return 0;
40753 }
40754
40755 cookie = lookup_dcookie(mm, s->eip, &offset);
40756
40757 if (cookie == INVALID_COOKIE) {
40758 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
40759 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
40760 return 0;
40761 }
40762
40763 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
40764 /* ignore backtraces if failed to add a sample */
40765 if (state == sb_bt_start) {
40766 state = sb_bt_ignore;
40767 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
40768 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
40769 }
40770 }
40771 release_mm(mm);
40772 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
40773 index c0cc4e7..44d4e54 100644
40774 --- a/drivers/oprofile/event_buffer.c
40775 +++ b/drivers/oprofile/event_buffer.c
40776 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
40777 }
40778
40779 if (buffer_pos == buffer_size) {
40780 - atomic_inc(&oprofile_stats.event_lost_overflow);
40781 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
40782 return;
40783 }
40784
40785 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
40786 index ed2c3ec..deda85a 100644
40787 --- a/drivers/oprofile/oprof.c
40788 +++ b/drivers/oprofile/oprof.c
40789 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
40790 if (oprofile_ops.switch_events())
40791 return;
40792
40793 - atomic_inc(&oprofile_stats.multiplex_counter);
40794 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
40795 start_switch_worker();
40796 }
40797
40798 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
40799 index 84a208d..d61b0a1 100644
40800 --- a/drivers/oprofile/oprofile_files.c
40801 +++ b/drivers/oprofile/oprofile_files.c
40802 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
40803
40804 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
40805
40806 -static ssize_t timeout_read(struct file *file, char __user *buf,
40807 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
40808 size_t count, loff_t *offset)
40809 {
40810 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
40811 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
40812 index 917d28e..d62d981 100644
40813 --- a/drivers/oprofile/oprofile_stats.c
40814 +++ b/drivers/oprofile/oprofile_stats.c
40815 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
40816 cpu_buf->sample_invalid_eip = 0;
40817 }
40818
40819 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
40820 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
40821 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
40822 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
40823 - atomic_set(&oprofile_stats.multiplex_counter, 0);
40824 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
40825 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
40826 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
40827 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
40828 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
40829 }
40830
40831
40832 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
40833 index 38b6fc0..b5cbfce 100644
40834 --- a/drivers/oprofile/oprofile_stats.h
40835 +++ b/drivers/oprofile/oprofile_stats.h
40836 @@ -13,11 +13,11 @@
40837 #include <linux/atomic.h>
40838
40839 struct oprofile_stat_struct {
40840 - atomic_t sample_lost_no_mm;
40841 - atomic_t sample_lost_no_mapping;
40842 - atomic_t bt_lost_no_mapping;
40843 - atomic_t event_lost_overflow;
40844 - atomic_t multiplex_counter;
40845 + atomic_unchecked_t sample_lost_no_mm;
40846 + atomic_unchecked_t sample_lost_no_mapping;
40847 + atomic_unchecked_t bt_lost_no_mapping;
40848 + atomic_unchecked_t event_lost_overflow;
40849 + atomic_unchecked_t multiplex_counter;
40850 };
40851
40852 extern struct oprofile_stat_struct oprofile_stats;
40853 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
40854 index 7c12d9c..558bf3bb 100644
40855 --- a/drivers/oprofile/oprofilefs.c
40856 +++ b/drivers/oprofile/oprofilefs.c
40857 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
40858
40859
40860 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
40861 - char const *name, atomic_t *val)
40862 + char const *name, atomic_unchecked_t *val)
40863 {
40864 return __oprofilefs_create_file(sb, root, name,
40865 &atomic_ro_fops, 0444, val);
40866 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
40867 index 93404f7..4a313d8 100644
40868 --- a/drivers/oprofile/timer_int.c
40869 +++ b/drivers/oprofile/timer_int.c
40870 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
40871 return NOTIFY_OK;
40872 }
40873
40874 -static struct notifier_block __refdata oprofile_cpu_notifier = {
40875 +static struct notifier_block oprofile_cpu_notifier = {
40876 .notifier_call = oprofile_cpu_notify,
40877 };
40878
40879 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
40880 index 3f56bc0..707d642 100644
40881 --- a/drivers/parport/procfs.c
40882 +++ b/drivers/parport/procfs.c
40883 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
40884
40885 *ppos += len;
40886
40887 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
40888 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
40889 }
40890
40891 #ifdef CONFIG_PARPORT_1284
40892 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
40893
40894 *ppos += len;
40895
40896 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
40897 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
40898 }
40899 #endif /* IEEE1284.3 support. */
40900
40901 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
40902 index c35e8ad..fc33beb 100644
40903 --- a/drivers/pci/hotplug/acpiphp_ibm.c
40904 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
40905 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
40906 goto init_cleanup;
40907 }
40908
40909 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
40910 + pax_open_kernel();
40911 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
40912 + pax_close_kernel();
40913 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
40914
40915 return retval;
40916 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
40917 index a6a71c4..c91097b 100644
40918 --- a/drivers/pci/hotplug/cpcihp_generic.c
40919 +++ b/drivers/pci/hotplug/cpcihp_generic.c
40920 @@ -73,7 +73,6 @@ static u16 port;
40921 static unsigned int enum_bit;
40922 static u8 enum_mask;
40923
40924 -static struct cpci_hp_controller_ops generic_hpc_ops;
40925 static struct cpci_hp_controller generic_hpc;
40926
40927 static int __init validate_parameters(void)
40928 @@ -139,6 +138,10 @@ static int query_enum(void)
40929 return ((value & enum_mask) == enum_mask);
40930 }
40931
40932 +static struct cpci_hp_controller_ops generic_hpc_ops = {
40933 + .query_enum = query_enum,
40934 +};
40935 +
40936 static int __init cpcihp_generic_init(void)
40937 {
40938 int status;
40939 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
40940 pci_dev_put(dev);
40941
40942 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
40943 - generic_hpc_ops.query_enum = query_enum;
40944 generic_hpc.ops = &generic_hpc_ops;
40945
40946 status = cpci_hp_register_controller(&generic_hpc);
40947 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
40948 index 449b4bb..257e2e8 100644
40949 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
40950 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
40951 @@ -59,7 +59,6 @@
40952 /* local variables */
40953 static bool debug;
40954 static bool poll;
40955 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
40956 static struct cpci_hp_controller zt5550_hpc;
40957
40958 /* Primary cPCI bus bridge device */
40959 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
40960 return 0;
40961 }
40962
40963 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
40964 + .query_enum = zt5550_hc_query_enum,
40965 +};
40966 +
40967 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
40968 {
40969 int status;
40970 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
40971 dbg("returned from zt5550_hc_config");
40972
40973 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
40974 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
40975 zt5550_hpc.ops = &zt5550_hpc_ops;
40976 if(!poll) {
40977 zt5550_hpc.irq = hc_dev->irq;
40978 zt5550_hpc.irq_flags = IRQF_SHARED;
40979 zt5550_hpc.dev_id = hc_dev;
40980
40981 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
40982 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
40983 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
40984 + pax_open_kernel();
40985 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
40986 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
40987 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
40988 + pax_open_kernel();
40989 } else {
40990 info("using ENUM# polling mode");
40991 }
40992 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
40993 index 76ba8a1..20ca857 100644
40994 --- a/drivers/pci/hotplug/cpqphp_nvram.c
40995 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
40996 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
40997
40998 void compaq_nvram_init (void __iomem *rom_start)
40999 {
41000 +
41001 +#ifndef CONFIG_PAX_KERNEXEC
41002 if (rom_start) {
41003 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
41004 }
41005 +#endif
41006 +
41007 dbg("int15 entry = %p\n", compaq_int15_entry_point);
41008
41009 /* initialize our int15 lock */
41010 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
41011 index 202f4a9..8ee47d0 100644
41012 --- a/drivers/pci/hotplug/pci_hotplug_core.c
41013 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
41014 @@ -448,8 +448,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
41015 return -EINVAL;
41016 }
41017
41018 - slot->ops->owner = owner;
41019 - slot->ops->mod_name = mod_name;
41020 + pax_open_kernel();
41021 + *(struct module **)&slot->ops->owner = owner;
41022 + *(const char **)&slot->ops->mod_name = mod_name;
41023 + pax_close_kernel();
41024
41025 mutex_lock(&pci_hp_mutex);
41026 /*
41027 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
41028 index 7d72c5e..edce02c 100644
41029 --- a/drivers/pci/hotplug/pciehp_core.c
41030 +++ b/drivers/pci/hotplug/pciehp_core.c
41031 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
41032 struct slot *slot = ctrl->slot;
41033 struct hotplug_slot *hotplug = NULL;
41034 struct hotplug_slot_info *info = NULL;
41035 - struct hotplug_slot_ops *ops = NULL;
41036 + hotplug_slot_ops_no_const *ops = NULL;
41037 char name[SLOT_NAME_SIZE];
41038 int retval = -ENOMEM;
41039
41040 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
41041 index 9c6e9bb..2916736 100644
41042 --- a/drivers/pci/pci-sysfs.c
41043 +++ b/drivers/pci/pci-sysfs.c
41044 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
41045 {
41046 /* allocate attribute structure, piggyback attribute name */
41047 int name_len = write_combine ? 13 : 10;
41048 - struct bin_attribute *res_attr;
41049 + bin_attribute_no_const *res_attr;
41050 int retval;
41051
41052 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
41053 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
41054 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
41055 {
41056 int retval;
41057 - struct bin_attribute *attr;
41058 + bin_attribute_no_const *attr;
41059
41060 /* If the device has VPD, try to expose it in sysfs. */
41061 if (dev->vpd) {
41062 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
41063 {
41064 int retval;
41065 int rom_size = 0;
41066 - struct bin_attribute *attr;
41067 + bin_attribute_no_const *attr;
41068
41069 if (!sysfs_initialized)
41070 return -EACCES;
41071 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
41072 index 7346ee6..41520eb 100644
41073 --- a/drivers/pci/pci.h
41074 +++ b/drivers/pci/pci.h
41075 @@ -93,7 +93,7 @@ struct pci_vpd_ops {
41076 struct pci_vpd {
41077 unsigned int len;
41078 const struct pci_vpd_ops *ops;
41079 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
41080 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
41081 };
41082
41083 extern int pci_vpd_pci22_init(struct pci_dev *dev);
41084 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
41085 index d320df6..ca9a8f6 100644
41086 --- a/drivers/pci/pcie/aspm.c
41087 +++ b/drivers/pci/pcie/aspm.c
41088 @@ -27,9 +27,9 @@
41089 #define MODULE_PARAM_PREFIX "pcie_aspm."
41090
41091 /* Note: those are not register definitions */
41092 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
41093 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
41094 -#define ASPM_STATE_L1 (4) /* L1 state */
41095 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
41096 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
41097 +#define ASPM_STATE_L1 (4U) /* L1 state */
41098 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
41099 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
41100
41101 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
41102 index 5427787..8df273b 100644
41103 --- a/drivers/pci/probe.c
41104 +++ b/drivers/pci/probe.c
41105 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
41106 struct pci_bus_region region;
41107 bool bar_too_big = false, bar_disabled = false;
41108
41109 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
41110 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
41111
41112 /* No printks while decoding is disabled! */
41113 if (!dev->mmio_always_on) {
41114 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
41115 index 0b00947..64f7c0a 100644
41116 --- a/drivers/pci/proc.c
41117 +++ b/drivers/pci/proc.c
41118 @@ -465,7 +465,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
41119 static int __init pci_proc_init(void)
41120 {
41121 struct pci_dev *dev = NULL;
41122 +
41123 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
41124 +#ifdef CONFIG_GRKERNSEC_PROC_USER
41125 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
41126 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
41127 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
41128 +#endif
41129 +#else
41130 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
41131 +#endif
41132 proc_create("devices", 0, proc_bus_pci_dir,
41133 &proc_bus_pci_dev_operations);
41134 proc_initialized = 1;
41135 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
41136 index 3e5b4497..dcdfb70 100644
41137 --- a/drivers/platform/x86/chromeos_laptop.c
41138 +++ b/drivers/platform/x86/chromeos_laptop.c
41139 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
41140 return 0;
41141 }
41142
41143 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
41144 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
41145 {
41146 .ident = "Samsung Series 5 550 - Touchpad",
41147 .matches = {
41148 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
41149 index 6b22938..bc9700e 100644
41150 --- a/drivers/platform/x86/msi-laptop.c
41151 +++ b/drivers/platform/x86/msi-laptop.c
41152 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
41153
41154 if (!quirks->ec_read_only) {
41155 /* allow userland write sysfs file */
41156 - dev_attr_bluetooth.store = store_bluetooth;
41157 - dev_attr_wlan.store = store_wlan;
41158 - dev_attr_threeg.store = store_threeg;
41159 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
41160 - dev_attr_wlan.attr.mode |= S_IWUSR;
41161 - dev_attr_threeg.attr.mode |= S_IWUSR;
41162 + pax_open_kernel();
41163 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
41164 + *(void **)&dev_attr_wlan.store = store_wlan;
41165 + *(void **)&dev_attr_threeg.store = store_threeg;
41166 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
41167 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
41168 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
41169 + pax_close_kernel();
41170 }
41171
41172 /* disable hardware control by fn key */
41173 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
41174 index 14d4dce..b129917 100644
41175 --- a/drivers/platform/x86/sony-laptop.c
41176 +++ b/drivers/platform/x86/sony-laptop.c
41177 @@ -2465,7 +2465,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
41178 }
41179
41180 /* High speed charging function */
41181 -static struct device_attribute *hsc_handle;
41182 +static device_attribute_no_const *hsc_handle;
41183
41184 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
41185 struct device_attribute *attr,
41186 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
41187 index edec135..59a24a3 100644
41188 --- a/drivers/platform/x86/thinkpad_acpi.c
41189 +++ b/drivers/platform/x86/thinkpad_acpi.c
41190 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
41191 return 0;
41192 }
41193
41194 -void static hotkey_mask_warn_incomplete_mask(void)
41195 +static void hotkey_mask_warn_incomplete_mask(void)
41196 {
41197 /* log only what the user can fix... */
41198 const u32 wantedmask = hotkey_driver_mask &
41199 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
41200 }
41201 }
41202
41203 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41204 - struct tp_nvram_state *newn,
41205 - const u32 event_mask)
41206 -{
41207 -
41208 #define TPACPI_COMPARE_KEY(__scancode, __member) \
41209 do { \
41210 if ((event_mask & (1 << __scancode)) && \
41211 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41212 tpacpi_hotkey_send_key(__scancode); \
41213 } while (0)
41214
41215 - void issue_volchange(const unsigned int oldvol,
41216 - const unsigned int newvol)
41217 - {
41218 - unsigned int i = oldvol;
41219 +static void issue_volchange(const unsigned int oldvol,
41220 + const unsigned int newvol,
41221 + const u32 event_mask)
41222 +{
41223 + unsigned int i = oldvol;
41224
41225 - while (i > newvol) {
41226 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41227 - i--;
41228 - }
41229 - while (i < newvol) {
41230 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41231 - i++;
41232 - }
41233 + while (i > newvol) {
41234 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41235 + i--;
41236 }
41237 + while (i < newvol) {
41238 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41239 + i++;
41240 + }
41241 +}
41242
41243 - void issue_brightnesschange(const unsigned int oldbrt,
41244 - const unsigned int newbrt)
41245 - {
41246 - unsigned int i = oldbrt;
41247 +static void issue_brightnesschange(const unsigned int oldbrt,
41248 + const unsigned int newbrt,
41249 + const u32 event_mask)
41250 +{
41251 + unsigned int i = oldbrt;
41252
41253 - while (i > newbrt) {
41254 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41255 - i--;
41256 - }
41257 - while (i < newbrt) {
41258 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41259 - i++;
41260 - }
41261 + while (i > newbrt) {
41262 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41263 + i--;
41264 + }
41265 + while (i < newbrt) {
41266 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41267 + i++;
41268 }
41269 +}
41270
41271 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41272 + struct tp_nvram_state *newn,
41273 + const u32 event_mask)
41274 +{
41275 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
41276 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
41277 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
41278 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41279 oldn->volume_level != newn->volume_level) {
41280 /* recently muted, or repeated mute keypress, or
41281 * multiple presses ending in mute */
41282 - issue_volchange(oldn->volume_level, newn->volume_level);
41283 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41284 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
41285 }
41286 } else {
41287 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41288 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41289 }
41290 if (oldn->volume_level != newn->volume_level) {
41291 - issue_volchange(oldn->volume_level, newn->volume_level);
41292 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41293 } else if (oldn->volume_toggle != newn->volume_toggle) {
41294 /* repeated vol up/down keypress at end of scale ? */
41295 if (newn->volume_level == 0)
41296 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41297 /* handle brightness */
41298 if (oldn->brightness_level != newn->brightness_level) {
41299 issue_brightnesschange(oldn->brightness_level,
41300 - newn->brightness_level);
41301 + newn->brightness_level,
41302 + event_mask);
41303 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
41304 /* repeated key presses that didn't change state */
41305 if (newn->brightness_level == 0)
41306 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41307 && !tp_features.bright_unkfw)
41308 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41309 }
41310 +}
41311
41312 #undef TPACPI_COMPARE_KEY
41313 #undef TPACPI_MAY_SEND_KEY
41314 -}
41315
41316 /*
41317 * Polling driver
41318 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
41319 index 769d265..a3a05ca 100644
41320 --- a/drivers/pnp/pnpbios/bioscalls.c
41321 +++ b/drivers/pnp/pnpbios/bioscalls.c
41322 @@ -58,7 +58,7 @@ do { \
41323 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
41324 } while(0)
41325
41326 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
41327 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
41328 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
41329
41330 /*
41331 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41332
41333 cpu = get_cpu();
41334 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
41335 +
41336 + pax_open_kernel();
41337 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
41338 + pax_close_kernel();
41339
41340 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
41341 spin_lock_irqsave(&pnp_bios_lock, flags);
41342 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41343 :"memory");
41344 spin_unlock_irqrestore(&pnp_bios_lock, flags);
41345
41346 + pax_open_kernel();
41347 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
41348 + pax_close_kernel();
41349 +
41350 put_cpu();
41351
41352 /* If we get here and this is set then the PnP BIOS faulted on us. */
41353 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
41354 return status;
41355 }
41356
41357 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
41358 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
41359 {
41360 int i;
41361
41362 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41363 pnp_bios_callpoint.offset = header->fields.pm16offset;
41364 pnp_bios_callpoint.segment = PNP_CS16;
41365
41366 + pax_open_kernel();
41367 +
41368 for_each_possible_cpu(i) {
41369 struct desc_struct *gdt = get_cpu_gdt_table(i);
41370 if (!gdt)
41371 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41372 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
41373 (unsigned long)__va(header->fields.pm16dseg));
41374 }
41375 +
41376 + pax_close_kernel();
41377 }
41378 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
41379 index 3e6db1c..1fbbdae 100644
41380 --- a/drivers/pnp/resource.c
41381 +++ b/drivers/pnp/resource.c
41382 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
41383 return 1;
41384
41385 /* check if the resource is valid */
41386 - if (*irq < 0 || *irq > 15)
41387 + if (*irq > 15)
41388 return 0;
41389
41390 /* check if the resource is reserved */
41391 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
41392 return 1;
41393
41394 /* check if the resource is valid */
41395 - if (*dma < 0 || *dma == 4 || *dma > 7)
41396 + if (*dma == 4 || *dma > 7)
41397 return 0;
41398
41399 /* check if the resource is reserved */
41400 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
41401 index 7df7c5f..bd48c47 100644
41402 --- a/drivers/power/pda_power.c
41403 +++ b/drivers/power/pda_power.c
41404 @@ -37,7 +37,11 @@ static int polling;
41405
41406 #ifdef CONFIG_USB_OTG_UTILS
41407 static struct usb_phy *transceiver;
41408 -static struct notifier_block otg_nb;
41409 +static int otg_handle_notification(struct notifier_block *nb,
41410 + unsigned long event, void *unused);
41411 +static struct notifier_block otg_nb = {
41412 + .notifier_call = otg_handle_notification
41413 +};
41414 #endif
41415
41416 static struct regulator *ac_draw;
41417 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
41418
41419 #ifdef CONFIG_USB_OTG_UTILS
41420 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
41421 - otg_nb.notifier_call = otg_handle_notification;
41422 ret = usb_register_notifier(transceiver, &otg_nb);
41423 if (ret) {
41424 dev_err(dev, "failure to register otg notifier\n");
41425 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
41426 index cc439fd..8fa30df 100644
41427 --- a/drivers/power/power_supply.h
41428 +++ b/drivers/power/power_supply.h
41429 @@ -16,12 +16,12 @@ struct power_supply;
41430
41431 #ifdef CONFIG_SYSFS
41432
41433 -extern void power_supply_init_attrs(struct device_type *dev_type);
41434 +extern void power_supply_init_attrs(void);
41435 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
41436
41437 #else
41438
41439 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
41440 +static inline void power_supply_init_attrs(void) {}
41441 #define power_supply_uevent NULL
41442
41443 #endif /* CONFIG_SYSFS */
41444 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
41445 index 5deac43..608c5ff 100644
41446 --- a/drivers/power/power_supply_core.c
41447 +++ b/drivers/power/power_supply_core.c
41448 @@ -24,7 +24,10 @@
41449 struct class *power_supply_class;
41450 EXPORT_SYMBOL_GPL(power_supply_class);
41451
41452 -static struct device_type power_supply_dev_type;
41453 +extern const struct attribute_group *power_supply_attr_groups[];
41454 +static struct device_type power_supply_dev_type = {
41455 + .groups = power_supply_attr_groups,
41456 +};
41457
41458 static int __power_supply_changed_work(struct device *dev, void *data)
41459 {
41460 @@ -393,7 +396,7 @@ static int __init power_supply_class_init(void)
41461 return PTR_ERR(power_supply_class);
41462
41463 power_supply_class->dev_uevent = power_supply_uevent;
41464 - power_supply_init_attrs(&power_supply_dev_type);
41465 + power_supply_init_attrs();
41466
41467 return 0;
41468 }
41469 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
41470 index 29178f7..c65f324 100644
41471 --- a/drivers/power/power_supply_sysfs.c
41472 +++ b/drivers/power/power_supply_sysfs.c
41473 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
41474 .is_visible = power_supply_attr_is_visible,
41475 };
41476
41477 -static const struct attribute_group *power_supply_attr_groups[] = {
41478 +const struct attribute_group *power_supply_attr_groups[] = {
41479 &power_supply_attr_group,
41480 NULL,
41481 };
41482
41483 -void power_supply_init_attrs(struct device_type *dev_type)
41484 +void power_supply_init_attrs(void)
41485 {
41486 int i;
41487
41488 - dev_type->groups = power_supply_attr_groups;
41489 -
41490 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
41491 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
41492 }
41493 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
41494 index 4d7c635..9860196 100644
41495 --- a/drivers/regulator/max8660.c
41496 +++ b/drivers/regulator/max8660.c
41497 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
41498 max8660->shadow_regs[MAX8660_OVER1] = 5;
41499 } else {
41500 /* Otherwise devices can be toggled via software */
41501 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
41502 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
41503 + pax_open_kernel();
41504 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
41505 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
41506 + pax_close_kernel();
41507 }
41508
41509 /*
41510 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
41511 index 9a8ea91..c483dd9 100644
41512 --- a/drivers/regulator/max8973-regulator.c
41513 +++ b/drivers/regulator/max8973-regulator.c
41514 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
41515 if (!pdata->enable_ext_control) {
41516 max->desc.enable_reg = MAX8973_VOUT;
41517 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
41518 - max8973_dcdc_ops.enable = regulator_enable_regmap;
41519 - max8973_dcdc_ops.disable = regulator_disable_regmap;
41520 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41521 + pax_open_kernel();
41522 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
41523 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
41524 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41525 + pax_close_kernel();
41526 }
41527
41528 max->enable_external_control = pdata->enable_ext_control;
41529 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
41530 index 9891aec..beb3083 100644
41531 --- a/drivers/regulator/mc13892-regulator.c
41532 +++ b/drivers/regulator/mc13892-regulator.c
41533 @@ -583,10 +583,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
41534 }
41535 mc13xxx_unlock(mc13892);
41536
41537 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41538 + pax_open_kernel();
41539 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41540 = mc13892_vcam_set_mode;
41541 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41542 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41543 = mc13892_vcam_get_mode;
41544 + pax_close_kernel();
41545
41546 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
41547 ARRAY_SIZE(mc13892_regulators),
41548 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
41549 index cc5bea9..689f7d9 100644
41550 --- a/drivers/rtc/rtc-cmos.c
41551 +++ b/drivers/rtc/rtc-cmos.c
41552 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
41553 hpet_rtc_timer_init();
41554
41555 /* export at least the first block of NVRAM */
41556 - nvram.size = address_space - NVRAM_OFFSET;
41557 + pax_open_kernel();
41558 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
41559 + pax_close_kernel();
41560 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
41561 if (retval < 0) {
41562 dev_dbg(dev, "can't create nvram file? %d\n", retval);
41563 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
41564 index d049393..bb20be0 100644
41565 --- a/drivers/rtc/rtc-dev.c
41566 +++ b/drivers/rtc/rtc-dev.c
41567 @@ -16,6 +16,7 @@
41568 #include <linux/module.h>
41569 #include <linux/rtc.h>
41570 #include <linux/sched.h>
41571 +#include <linux/grsecurity.h>
41572 #include "rtc-core.h"
41573
41574 static dev_t rtc_devt;
41575 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
41576 if (copy_from_user(&tm, uarg, sizeof(tm)))
41577 return -EFAULT;
41578
41579 + gr_log_timechange();
41580 +
41581 return rtc_set_time(rtc, &tm);
41582
41583 case RTC_PIE_ON:
41584 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
41585 index 970a236..3613169 100644
41586 --- a/drivers/rtc/rtc-ds1307.c
41587 +++ b/drivers/rtc/rtc-ds1307.c
41588 @@ -106,7 +106,7 @@ struct ds1307 {
41589 u8 offset; /* register's offset */
41590 u8 regs[11];
41591 u16 nvram_offset;
41592 - struct bin_attribute *nvram;
41593 + bin_attribute_no_const *nvram;
41594 enum ds_type type;
41595 unsigned long flags;
41596 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
41597 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
41598 index 130f29a..6179d03 100644
41599 --- a/drivers/rtc/rtc-m48t59.c
41600 +++ b/drivers/rtc/rtc-m48t59.c
41601 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
41602 goto out;
41603 }
41604
41605 - m48t59_nvram_attr.size = pdata->offset;
41606 + pax_open_kernel();
41607 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
41608 + pax_close_kernel();
41609
41610 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
41611 if (ret) {
41612 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
41613 index e693af6..2e525b6 100644
41614 --- a/drivers/scsi/bfa/bfa_fcpim.h
41615 +++ b/drivers/scsi/bfa/bfa_fcpim.h
41616 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
41617
41618 struct bfa_itn_s {
41619 bfa_isr_func_t isr;
41620 -};
41621 +} __no_const;
41622
41623 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
41624 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
41625 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
41626 index 23a90e7..9cf04ee 100644
41627 --- a/drivers/scsi/bfa/bfa_ioc.h
41628 +++ b/drivers/scsi/bfa/bfa_ioc.h
41629 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
41630 bfa_ioc_disable_cbfn_t disable_cbfn;
41631 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
41632 bfa_ioc_reset_cbfn_t reset_cbfn;
41633 -};
41634 +} __no_const;
41635
41636 /*
41637 * IOC event notification mechanism.
41638 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
41639 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
41640 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
41641 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
41642 -};
41643 +} __no_const;
41644
41645 /*
41646 * Queue element to wait for room in request queue. FIFO order is
41647 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
41648 index df0c3c7..b00e1d0 100644
41649 --- a/drivers/scsi/hosts.c
41650 +++ b/drivers/scsi/hosts.c
41651 @@ -42,7 +42,7 @@
41652 #include "scsi_logging.h"
41653
41654
41655 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41656 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41657
41658
41659 static void scsi_host_cls_release(struct device *dev)
41660 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
41661 * subtract one because we increment first then return, but we need to
41662 * know what the next host number was before increment
41663 */
41664 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
41665 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
41666 shost->dma_channel = 0xff;
41667
41668 /* These three are default values which can be overridden */
41669 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
41670 index 7f4f790..b75b92a 100644
41671 --- a/drivers/scsi/hpsa.c
41672 +++ b/drivers/scsi/hpsa.c
41673 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
41674 unsigned long flags;
41675
41676 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
41677 - return h->access.command_completed(h, q);
41678 + return h->access->command_completed(h, q);
41679
41680 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
41681 a = rq->head[rq->current_entry];
41682 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
41683 while (!list_empty(&h->reqQ)) {
41684 c = list_entry(h->reqQ.next, struct CommandList, list);
41685 /* can't do anything if fifo is full */
41686 - if ((h->access.fifo_full(h))) {
41687 + if ((h->access->fifo_full(h))) {
41688 dev_warn(&h->pdev->dev, "fifo full\n");
41689 break;
41690 }
41691 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
41692
41693 /* Tell the controller execute command */
41694 spin_unlock_irqrestore(&h->lock, flags);
41695 - h->access.submit_command(h, c);
41696 + h->access->submit_command(h, c);
41697 spin_lock_irqsave(&h->lock, flags);
41698 }
41699 spin_unlock_irqrestore(&h->lock, flags);
41700 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
41701
41702 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
41703 {
41704 - return h->access.command_completed(h, q);
41705 + return h->access->command_completed(h, q);
41706 }
41707
41708 static inline bool interrupt_pending(struct ctlr_info *h)
41709 {
41710 - return h->access.intr_pending(h);
41711 + return h->access->intr_pending(h);
41712 }
41713
41714 static inline long interrupt_not_for_us(struct ctlr_info *h)
41715 {
41716 - return (h->access.intr_pending(h) == 0) ||
41717 + return (h->access->intr_pending(h) == 0) ||
41718 (h->interrupts_enabled == 0);
41719 }
41720
41721 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
41722 if (prod_index < 0)
41723 return -ENODEV;
41724 h->product_name = products[prod_index].product_name;
41725 - h->access = *(products[prod_index].access);
41726 + h->access = products[prod_index].access;
41727
41728 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
41729 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
41730 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
41731
41732 assert_spin_locked(&lockup_detector_lock);
41733 remove_ctlr_from_lockup_detector_list(h);
41734 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41735 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41736 spin_lock_irqsave(&h->lock, flags);
41737 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
41738 spin_unlock_irqrestore(&h->lock, flags);
41739 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
41740 }
41741
41742 /* make sure the board interrupts are off */
41743 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41744 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41745
41746 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
41747 goto clean2;
41748 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
41749 * fake ones to scoop up any residual completions.
41750 */
41751 spin_lock_irqsave(&h->lock, flags);
41752 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41753 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41754 spin_unlock_irqrestore(&h->lock, flags);
41755 free_irqs(h);
41756 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
41757 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
41758 dev_info(&h->pdev->dev, "Board READY.\n");
41759 dev_info(&h->pdev->dev,
41760 "Waiting for stale completions to drain.\n");
41761 - h->access.set_intr_mask(h, HPSA_INTR_ON);
41762 + h->access->set_intr_mask(h, HPSA_INTR_ON);
41763 msleep(10000);
41764 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41765 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41766
41767 rc = controller_reset_failed(h->cfgtable);
41768 if (rc)
41769 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
41770 }
41771
41772 /* Turn the interrupts on so we can service requests */
41773 - h->access.set_intr_mask(h, HPSA_INTR_ON);
41774 + h->access->set_intr_mask(h, HPSA_INTR_ON);
41775
41776 hpsa_hba_inquiry(h);
41777 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
41778 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
41779 * To write all data in the battery backed cache to disks
41780 */
41781 hpsa_flush_cache(h);
41782 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41783 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41784 hpsa_free_irqs_and_disable_msix(h);
41785 }
41786
41787 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
41788 return;
41789 }
41790 /* Change the access methods to the performant access methods */
41791 - h->access = SA5_performant_access;
41792 + h->access = &SA5_performant_access;
41793 h->transMethod = CFGTBL_Trans_Performant;
41794 }
41795
41796 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
41797 index 9816479..c5d4e97 100644
41798 --- a/drivers/scsi/hpsa.h
41799 +++ b/drivers/scsi/hpsa.h
41800 @@ -79,7 +79,7 @@ struct ctlr_info {
41801 unsigned int msix_vector;
41802 unsigned int msi_vector;
41803 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
41804 - struct access_method access;
41805 + struct access_method *access;
41806
41807 /* queue and queue Info */
41808 struct list_head reqQ;
41809 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
41810 index c772d8d..35c362c 100644
41811 --- a/drivers/scsi/libfc/fc_exch.c
41812 +++ b/drivers/scsi/libfc/fc_exch.c
41813 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
41814 u16 pool_max_index;
41815
41816 struct {
41817 - atomic_t no_free_exch;
41818 - atomic_t no_free_exch_xid;
41819 - atomic_t xid_not_found;
41820 - atomic_t xid_busy;
41821 - atomic_t seq_not_found;
41822 - atomic_t non_bls_resp;
41823 + atomic_unchecked_t no_free_exch;
41824 + atomic_unchecked_t no_free_exch_xid;
41825 + atomic_unchecked_t xid_not_found;
41826 + atomic_unchecked_t xid_busy;
41827 + atomic_unchecked_t seq_not_found;
41828 + atomic_unchecked_t non_bls_resp;
41829 } stats;
41830 };
41831
41832 @@ -725,7 +725,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
41833 /* allocate memory for exchange */
41834 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
41835 if (!ep) {
41836 - atomic_inc(&mp->stats.no_free_exch);
41837 + atomic_inc_unchecked(&mp->stats.no_free_exch);
41838 goto out;
41839 }
41840 memset(ep, 0, sizeof(*ep));
41841 @@ -786,7 +786,7 @@ out:
41842 return ep;
41843 err:
41844 spin_unlock_bh(&pool->lock);
41845 - atomic_inc(&mp->stats.no_free_exch_xid);
41846 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
41847 mempool_free(ep, mp->ep_pool);
41848 return NULL;
41849 }
41850 @@ -929,7 +929,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41851 xid = ntohs(fh->fh_ox_id); /* we originated exch */
41852 ep = fc_exch_find(mp, xid);
41853 if (!ep) {
41854 - atomic_inc(&mp->stats.xid_not_found);
41855 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41856 reject = FC_RJT_OX_ID;
41857 goto out;
41858 }
41859 @@ -959,7 +959,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41860 ep = fc_exch_find(mp, xid);
41861 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
41862 if (ep) {
41863 - atomic_inc(&mp->stats.xid_busy);
41864 + atomic_inc_unchecked(&mp->stats.xid_busy);
41865 reject = FC_RJT_RX_ID;
41866 goto rel;
41867 }
41868 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41869 }
41870 xid = ep->xid; /* get our XID */
41871 } else if (!ep) {
41872 - atomic_inc(&mp->stats.xid_not_found);
41873 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41874 reject = FC_RJT_RX_ID; /* XID not found */
41875 goto out;
41876 }
41877 @@ -987,7 +987,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
41878 } else {
41879 sp = &ep->seq;
41880 if (sp->id != fh->fh_seq_id) {
41881 - atomic_inc(&mp->stats.seq_not_found);
41882 + atomic_inc_unchecked(&mp->stats.seq_not_found);
41883 if (f_ctl & FC_FC_END_SEQ) {
41884 /*
41885 * Update sequence_id based on incoming last
41886 @@ -1437,22 +1437,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41887
41888 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
41889 if (!ep) {
41890 - atomic_inc(&mp->stats.xid_not_found);
41891 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41892 goto out;
41893 }
41894 if (ep->esb_stat & ESB_ST_COMPLETE) {
41895 - atomic_inc(&mp->stats.xid_not_found);
41896 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41897 goto rel;
41898 }
41899 if (ep->rxid == FC_XID_UNKNOWN)
41900 ep->rxid = ntohs(fh->fh_rx_id);
41901 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
41902 - atomic_inc(&mp->stats.xid_not_found);
41903 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41904 goto rel;
41905 }
41906 if (ep->did != ntoh24(fh->fh_s_id) &&
41907 ep->did != FC_FID_FLOGI) {
41908 - atomic_inc(&mp->stats.xid_not_found);
41909 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41910 goto rel;
41911 }
41912 sof = fr_sof(fp);
41913 @@ -1461,7 +1461,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41914 sp->ssb_stat |= SSB_ST_RESP;
41915 sp->id = fh->fh_seq_id;
41916 } else if (sp->id != fh->fh_seq_id) {
41917 - atomic_inc(&mp->stats.seq_not_found);
41918 + atomic_inc_unchecked(&mp->stats.seq_not_found);
41919 goto rel;
41920 }
41921
41922 @@ -1525,9 +1525,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
41923 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
41924
41925 if (!sp)
41926 - atomic_inc(&mp->stats.xid_not_found);
41927 + atomic_inc_unchecked(&mp->stats.xid_not_found);
41928 else
41929 - atomic_inc(&mp->stats.non_bls_resp);
41930 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
41931
41932 fc_frame_free(fp);
41933 }
41934 @@ -2174,13 +2174,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
41935
41936 list_for_each_entry(ema, &lport->ema_list, ema_list) {
41937 mp = ema->mp;
41938 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
41939 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
41940 st->fc_no_free_exch_xid +=
41941 - atomic_read(&mp->stats.no_free_exch_xid);
41942 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
41943 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
41944 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
41945 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
41946 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
41947 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
41948 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
41949 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
41950 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
41951 }
41952 }
41953 EXPORT_SYMBOL(fc_exch_update_stats);
41954 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
41955 index bdb81cd..d3c7c2c 100644
41956 --- a/drivers/scsi/libsas/sas_ata.c
41957 +++ b/drivers/scsi/libsas/sas_ata.c
41958 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
41959 .postreset = ata_std_postreset,
41960 .error_handler = ata_std_error_handler,
41961 .post_internal_cmd = sas_ata_post_internal,
41962 - .qc_defer = ata_std_qc_defer,
41963 + .qc_defer = ata_std_qc_defer,
41964 .qc_prep = ata_noop_qc_prep,
41965 .qc_issue = sas_ata_qc_issue,
41966 .qc_fill_rtf = sas_ata_qc_fill_rtf,
41967 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
41968 index 7706c99..3b4fc0c 100644
41969 --- a/drivers/scsi/lpfc/lpfc.h
41970 +++ b/drivers/scsi/lpfc/lpfc.h
41971 @@ -424,7 +424,7 @@ struct lpfc_vport {
41972 struct dentry *debug_nodelist;
41973 struct dentry *vport_debugfs_root;
41974 struct lpfc_debugfs_trc *disc_trc;
41975 - atomic_t disc_trc_cnt;
41976 + atomic_unchecked_t disc_trc_cnt;
41977 #endif
41978 uint8_t stat_data_enabled;
41979 uint8_t stat_data_blocked;
41980 @@ -853,8 +853,8 @@ struct lpfc_hba {
41981 struct timer_list fabric_block_timer;
41982 unsigned long bit_flags;
41983 #define FABRIC_COMANDS_BLOCKED 0
41984 - atomic_t num_rsrc_err;
41985 - atomic_t num_cmd_success;
41986 + atomic_unchecked_t num_rsrc_err;
41987 + atomic_unchecked_t num_cmd_success;
41988 unsigned long last_rsrc_error_time;
41989 unsigned long last_ramp_down_time;
41990 unsigned long last_ramp_up_time;
41991 @@ -890,7 +890,7 @@ struct lpfc_hba {
41992
41993 struct dentry *debug_slow_ring_trc;
41994 struct lpfc_debugfs_trc *slow_ring_trc;
41995 - atomic_t slow_ring_trc_cnt;
41996 + atomic_unchecked_t slow_ring_trc_cnt;
41997 /* iDiag debugfs sub-directory */
41998 struct dentry *idiag_root;
41999 struct dentry *idiag_pci_cfg;
42000 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
42001 index f63f5ff..de29189 100644
42002 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
42003 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
42004 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
42005
42006 #include <linux/debugfs.h>
42007
42008 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42009 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42010 static unsigned long lpfc_debugfs_start_time = 0L;
42011
42012 /* iDiag */
42013 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
42014 lpfc_debugfs_enable = 0;
42015
42016 len = 0;
42017 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
42018 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
42019 (lpfc_debugfs_max_disc_trc - 1);
42020 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
42021 dtp = vport->disc_trc + i;
42022 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
42023 lpfc_debugfs_enable = 0;
42024
42025 len = 0;
42026 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
42027 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
42028 (lpfc_debugfs_max_slow_ring_trc - 1);
42029 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
42030 dtp = phba->slow_ring_trc + i;
42031 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
42032 !vport || !vport->disc_trc)
42033 return;
42034
42035 - index = atomic_inc_return(&vport->disc_trc_cnt) &
42036 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
42037 (lpfc_debugfs_max_disc_trc - 1);
42038 dtp = vport->disc_trc + index;
42039 dtp->fmt = fmt;
42040 dtp->data1 = data1;
42041 dtp->data2 = data2;
42042 dtp->data3 = data3;
42043 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42044 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42045 dtp->jif = jiffies;
42046 #endif
42047 return;
42048 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
42049 !phba || !phba->slow_ring_trc)
42050 return;
42051
42052 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
42053 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
42054 (lpfc_debugfs_max_slow_ring_trc - 1);
42055 dtp = phba->slow_ring_trc + index;
42056 dtp->fmt = fmt;
42057 dtp->data1 = data1;
42058 dtp->data2 = data2;
42059 dtp->data3 = data3;
42060 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42061 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42062 dtp->jif = jiffies;
42063 #endif
42064 return;
42065 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42066 "slow_ring buffer\n");
42067 goto debug_failed;
42068 }
42069 - atomic_set(&phba->slow_ring_trc_cnt, 0);
42070 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
42071 memset(phba->slow_ring_trc, 0,
42072 (sizeof(struct lpfc_debugfs_trc) *
42073 lpfc_debugfs_max_slow_ring_trc));
42074 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42075 "buffer\n");
42076 goto debug_failed;
42077 }
42078 - atomic_set(&vport->disc_trc_cnt, 0);
42079 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
42080
42081 snprintf(name, sizeof(name), "discovery_trace");
42082 vport->debug_disc_trc =
42083 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
42084 index 314b4f6..7005d10 100644
42085 --- a/drivers/scsi/lpfc/lpfc_init.c
42086 +++ b/drivers/scsi/lpfc/lpfc_init.c
42087 @@ -10551,8 +10551,10 @@ lpfc_init(void)
42088 "misc_register returned with status %d", error);
42089
42090 if (lpfc_enable_npiv) {
42091 - lpfc_transport_functions.vport_create = lpfc_vport_create;
42092 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42093 + pax_open_kernel();
42094 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
42095 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42096 + pax_close_kernel();
42097 }
42098 lpfc_transport_template =
42099 fc_attach_transport(&lpfc_transport_functions);
42100 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
42101 index 98af07c..7625fb5 100644
42102 --- a/drivers/scsi/lpfc/lpfc_scsi.c
42103 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
42104 @@ -325,7 +325,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
42105 uint32_t evt_posted;
42106
42107 spin_lock_irqsave(&phba->hbalock, flags);
42108 - atomic_inc(&phba->num_rsrc_err);
42109 + atomic_inc_unchecked(&phba->num_rsrc_err);
42110 phba->last_rsrc_error_time = jiffies;
42111
42112 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
42113 @@ -366,7 +366,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
42114 unsigned long flags;
42115 struct lpfc_hba *phba = vport->phba;
42116 uint32_t evt_posted;
42117 - atomic_inc(&phba->num_cmd_success);
42118 + atomic_inc_unchecked(&phba->num_cmd_success);
42119
42120 if (vport->cfg_lun_queue_depth <= queue_depth)
42121 return;
42122 @@ -410,8 +410,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42123 unsigned long num_rsrc_err, num_cmd_success;
42124 int i;
42125
42126 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
42127 - num_cmd_success = atomic_read(&phba->num_cmd_success);
42128 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
42129 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
42130
42131 /*
42132 * The error and success command counters are global per
42133 @@ -439,8 +439,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42134 }
42135 }
42136 lpfc_destroy_vport_work_array(phba, vports);
42137 - atomic_set(&phba->num_rsrc_err, 0);
42138 - atomic_set(&phba->num_cmd_success, 0);
42139 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42140 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42141 }
42142
42143 /**
42144 @@ -474,8 +474,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
42145 }
42146 }
42147 lpfc_destroy_vport_work_array(phba, vports);
42148 - atomic_set(&phba->num_rsrc_err, 0);
42149 - atomic_set(&phba->num_cmd_success, 0);
42150 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42151 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42152 }
42153
42154 /**
42155 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
42156 index b46f5e9..c4c4ccb 100644
42157 --- a/drivers/scsi/pmcraid.c
42158 +++ b/drivers/scsi/pmcraid.c
42159 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
42160 res->scsi_dev = scsi_dev;
42161 scsi_dev->hostdata = res;
42162 res->change_detected = 0;
42163 - atomic_set(&res->read_failures, 0);
42164 - atomic_set(&res->write_failures, 0);
42165 + atomic_set_unchecked(&res->read_failures, 0);
42166 + atomic_set_unchecked(&res->write_failures, 0);
42167 rc = 0;
42168 }
42169 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
42170 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
42171
42172 /* If this was a SCSI read/write command keep count of errors */
42173 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
42174 - atomic_inc(&res->read_failures);
42175 + atomic_inc_unchecked(&res->read_failures);
42176 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
42177 - atomic_inc(&res->write_failures);
42178 + atomic_inc_unchecked(&res->write_failures);
42179
42180 if (!RES_IS_GSCSI(res->cfg_entry) &&
42181 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
42182 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
42183 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42184 * hrrq_id assigned here in queuecommand
42185 */
42186 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42187 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42188 pinstance->num_hrrq;
42189 cmd->cmd_done = pmcraid_io_done;
42190
42191 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
42192 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42193 * hrrq_id assigned here in queuecommand
42194 */
42195 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42196 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42197 pinstance->num_hrrq;
42198
42199 if (request_size) {
42200 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
42201
42202 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
42203 /* add resources only after host is added into system */
42204 - if (!atomic_read(&pinstance->expose_resources))
42205 + if (!atomic_read_unchecked(&pinstance->expose_resources))
42206 return;
42207
42208 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
42209 @@ -5324,8 +5324,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
42210 init_waitqueue_head(&pinstance->reset_wait_q);
42211
42212 atomic_set(&pinstance->outstanding_cmds, 0);
42213 - atomic_set(&pinstance->last_message_id, 0);
42214 - atomic_set(&pinstance->expose_resources, 0);
42215 + atomic_set_unchecked(&pinstance->last_message_id, 0);
42216 + atomic_set_unchecked(&pinstance->expose_resources, 0);
42217
42218 INIT_LIST_HEAD(&pinstance->free_res_q);
42219 INIT_LIST_HEAD(&pinstance->used_res_q);
42220 @@ -6038,7 +6038,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
42221 /* Schedule worker thread to handle CCN and take care of adding and
42222 * removing devices to OS
42223 */
42224 - atomic_set(&pinstance->expose_resources, 1);
42225 + atomic_set_unchecked(&pinstance->expose_resources, 1);
42226 schedule_work(&pinstance->worker_q);
42227 return rc;
42228
42229 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
42230 index e1d150f..6c6df44 100644
42231 --- a/drivers/scsi/pmcraid.h
42232 +++ b/drivers/scsi/pmcraid.h
42233 @@ -748,7 +748,7 @@ struct pmcraid_instance {
42234 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
42235
42236 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
42237 - atomic_t last_message_id;
42238 + atomic_unchecked_t last_message_id;
42239
42240 /* configuration table */
42241 struct pmcraid_config_table *cfg_table;
42242 @@ -777,7 +777,7 @@ struct pmcraid_instance {
42243 atomic_t outstanding_cmds;
42244
42245 /* should add/delete resources to mid-layer now ?*/
42246 - atomic_t expose_resources;
42247 + atomic_unchecked_t expose_resources;
42248
42249
42250
42251 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
42252 struct pmcraid_config_table_entry_ext cfg_entry_ext;
42253 };
42254 struct scsi_device *scsi_dev; /* Link scsi_device structure */
42255 - atomic_t read_failures; /* count of failed READ commands */
42256 - atomic_t write_failures; /* count of failed WRITE commands */
42257 + atomic_unchecked_t read_failures; /* count of failed READ commands */
42258 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
42259
42260 /* To indicate add/delete/modify during CCN */
42261 u8 change_detected;
42262 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
42263 index b3db9dc..c3b1756 100644
42264 --- a/drivers/scsi/qla2xxx/qla_attr.c
42265 +++ b/drivers/scsi/qla2xxx/qla_attr.c
42266 @@ -1971,7 +1971,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
42267 return 0;
42268 }
42269
42270 -struct fc_function_template qla2xxx_transport_functions = {
42271 +fc_function_template_no_const qla2xxx_transport_functions = {
42272
42273 .show_host_node_name = 1,
42274 .show_host_port_name = 1,
42275 @@ -2018,7 +2018,7 @@ struct fc_function_template qla2xxx_transport_functions = {
42276 .bsg_timeout = qla24xx_bsg_timeout,
42277 };
42278
42279 -struct fc_function_template qla2xxx_transport_vport_functions = {
42280 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
42281
42282 .show_host_node_name = 1,
42283 .show_host_port_name = 1,
42284 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
42285 index b310fa9..b9b3944 100644
42286 --- a/drivers/scsi/qla2xxx/qla_gbl.h
42287 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
42288 @@ -523,8 +523,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
42289 struct device_attribute;
42290 extern struct device_attribute *qla2x00_host_attrs[];
42291 struct fc_function_template;
42292 -extern struct fc_function_template qla2xxx_transport_functions;
42293 -extern struct fc_function_template qla2xxx_transport_vport_functions;
42294 +extern fc_function_template_no_const qla2xxx_transport_functions;
42295 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
42296 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
42297 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
42298 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
42299 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
42300 index 2c6dd3d..e5ecd82 100644
42301 --- a/drivers/scsi/qla2xxx/qla_os.c
42302 +++ b/drivers/scsi/qla2xxx/qla_os.c
42303 @@ -1554,8 +1554,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
42304 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
42305 /* Ok, a 64bit DMA mask is applicable. */
42306 ha->flags.enable_64bit_addressing = 1;
42307 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42308 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42309 + pax_open_kernel();
42310 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42311 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42312 + pax_close_kernel();
42313 return;
42314 }
42315 }
42316 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
42317 index 129f5dd..ade53e8 100644
42318 --- a/drivers/scsi/qla4xxx/ql4_def.h
42319 +++ b/drivers/scsi/qla4xxx/ql4_def.h
42320 @@ -275,7 +275,7 @@ struct ddb_entry {
42321 * (4000 only) */
42322 atomic_t relogin_timer; /* Max Time to wait for
42323 * relogin to complete */
42324 - atomic_t relogin_retry_count; /* Num of times relogin has been
42325 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
42326 * retried */
42327 uint32_t default_time2wait; /* Default Min time between
42328 * relogins (+aens) */
42329 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
42330 index 6142729..b6a85c9 100644
42331 --- a/drivers/scsi/qla4xxx/ql4_os.c
42332 +++ b/drivers/scsi/qla4xxx/ql4_os.c
42333 @@ -2622,12 +2622,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
42334 */
42335 if (!iscsi_is_session_online(cls_sess)) {
42336 /* Reset retry relogin timer */
42337 - atomic_inc(&ddb_entry->relogin_retry_count);
42338 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
42339 DEBUG2(ql4_printk(KERN_INFO, ha,
42340 "%s: index[%d] relogin timed out-retrying"
42341 " relogin (%d), retry (%d)\n", __func__,
42342 ddb_entry->fw_ddb_index,
42343 - atomic_read(&ddb_entry->relogin_retry_count),
42344 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
42345 ddb_entry->default_time2wait + 4));
42346 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
42347 atomic_set(&ddb_entry->retry_relogin_timer,
42348 @@ -4742,7 +4742,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
42349
42350 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
42351 atomic_set(&ddb_entry->relogin_timer, 0);
42352 - atomic_set(&ddb_entry->relogin_retry_count, 0);
42353 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
42354 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
42355 ddb_entry->default_relogin_timeout =
42356 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
42357 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
42358 index 2c0d0ec..4e8681a 100644
42359 --- a/drivers/scsi/scsi.c
42360 +++ b/drivers/scsi/scsi.c
42361 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
42362 unsigned long timeout;
42363 int rtn = 0;
42364
42365 - atomic_inc(&cmd->device->iorequest_cnt);
42366 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42367
42368 /* check if the device is still usable */
42369 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
42370 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
42371 index c31187d..0ead8c3 100644
42372 --- a/drivers/scsi/scsi_lib.c
42373 +++ b/drivers/scsi/scsi_lib.c
42374 @@ -1459,7 +1459,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
42375 shost = sdev->host;
42376 scsi_init_cmd_errh(cmd);
42377 cmd->result = DID_NO_CONNECT << 16;
42378 - atomic_inc(&cmd->device->iorequest_cnt);
42379 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42380
42381 /*
42382 * SCSI request completion path will do scsi_device_unbusy(),
42383 @@ -1485,9 +1485,9 @@ static void scsi_softirq_done(struct request *rq)
42384
42385 INIT_LIST_HEAD(&cmd->eh_entry);
42386
42387 - atomic_inc(&cmd->device->iodone_cnt);
42388 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
42389 if (cmd->result)
42390 - atomic_inc(&cmd->device->ioerr_cnt);
42391 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
42392
42393 disposition = scsi_decide_disposition(cmd);
42394 if (disposition != SUCCESS &&
42395 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
42396 index 931a7d9..0c2a754 100644
42397 --- a/drivers/scsi/scsi_sysfs.c
42398 +++ b/drivers/scsi/scsi_sysfs.c
42399 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
42400 char *buf) \
42401 { \
42402 struct scsi_device *sdev = to_scsi_device(dev); \
42403 - unsigned long long count = atomic_read(&sdev->field); \
42404 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
42405 return snprintf(buf, 20, "0x%llx\n", count); \
42406 } \
42407 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
42408 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
42409 index 84a1fdf..693b0d6 100644
42410 --- a/drivers/scsi/scsi_tgt_lib.c
42411 +++ b/drivers/scsi/scsi_tgt_lib.c
42412 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
42413 int err;
42414
42415 dprintk("%lx %u\n", uaddr, len);
42416 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
42417 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
42418 if (err) {
42419 /*
42420 * TODO: need to fixup sg_tablesize, max_segment_size,
42421 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
42422 index e894ca7..de9d7660 100644
42423 --- a/drivers/scsi/scsi_transport_fc.c
42424 +++ b/drivers/scsi/scsi_transport_fc.c
42425 @@ -498,7 +498,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
42426 * Netlink Infrastructure
42427 */
42428
42429 -static atomic_t fc_event_seq;
42430 +static atomic_unchecked_t fc_event_seq;
42431
42432 /**
42433 * fc_get_event_number - Obtain the next sequential FC event number
42434 @@ -511,7 +511,7 @@ static atomic_t fc_event_seq;
42435 u32
42436 fc_get_event_number(void)
42437 {
42438 - return atomic_add_return(1, &fc_event_seq);
42439 + return atomic_add_return_unchecked(1, &fc_event_seq);
42440 }
42441 EXPORT_SYMBOL(fc_get_event_number);
42442
42443 @@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
42444 {
42445 int error;
42446
42447 - atomic_set(&fc_event_seq, 0);
42448 + atomic_set_unchecked(&fc_event_seq, 0);
42449
42450 error = transport_class_register(&fc_host_class);
42451 if (error)
42452 @@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
42453 char *cp;
42454
42455 *val = simple_strtoul(buf, &cp, 0);
42456 - if ((*cp && (*cp != '\n')) || (*val < 0))
42457 + if (*cp && (*cp != '\n'))
42458 return -EINVAL;
42459 /*
42460 * Check for overflow; dev_loss_tmo is u32
42461 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
42462 index 0a74b97..fa8d648 100644
42463 --- a/drivers/scsi/scsi_transport_iscsi.c
42464 +++ b/drivers/scsi/scsi_transport_iscsi.c
42465 @@ -79,7 +79,7 @@ struct iscsi_internal {
42466 struct transport_container session_cont;
42467 };
42468
42469 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
42470 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
42471 static struct workqueue_struct *iscsi_eh_timer_workq;
42472
42473 static DEFINE_IDA(iscsi_sess_ida);
42474 @@ -1064,7 +1064,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
42475 int err;
42476
42477 ihost = shost->shost_data;
42478 - session->sid = atomic_add_return(1, &iscsi_session_nr);
42479 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
42480
42481 if (target_id == ISCSI_MAX_TARGET) {
42482 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
42483 @@ -2955,7 +2955,7 @@ static __init int iscsi_transport_init(void)
42484 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
42485 ISCSI_TRANSPORT_VERSION);
42486
42487 - atomic_set(&iscsi_session_nr, 0);
42488 + atomic_set_unchecked(&iscsi_session_nr, 0);
42489
42490 err = class_register(&iscsi_transport_class);
42491 if (err)
42492 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
42493 index f379c7f..e8fc69c 100644
42494 --- a/drivers/scsi/scsi_transport_srp.c
42495 +++ b/drivers/scsi/scsi_transport_srp.c
42496 @@ -33,7 +33,7 @@
42497 #include "scsi_transport_srp_internal.h"
42498
42499 struct srp_host_attrs {
42500 - atomic_t next_port_id;
42501 + atomic_unchecked_t next_port_id;
42502 };
42503 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
42504
42505 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
42506 struct Scsi_Host *shost = dev_to_shost(dev);
42507 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
42508
42509 - atomic_set(&srp_host->next_port_id, 0);
42510 + atomic_set_unchecked(&srp_host->next_port_id, 0);
42511 return 0;
42512 }
42513
42514 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
42515 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
42516 rport->roles = ids->roles;
42517
42518 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
42519 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
42520 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
42521
42522 transport_setup_device(&rport->dev);
42523 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
42524 index 82910cc..7c350ad 100644
42525 --- a/drivers/scsi/sd.c
42526 +++ b/drivers/scsi/sd.c
42527 @@ -2929,7 +2929,7 @@ static int sd_probe(struct device *dev)
42528 sdkp->disk = gd;
42529 sdkp->index = index;
42530 atomic_set(&sdkp->openers, 0);
42531 - atomic_set(&sdkp->device->ioerr_cnt, 0);
42532 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
42533
42534 if (!sdp->request_queue->rq_timeout) {
42535 if (sdp->type != TYPE_MOD)
42536 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
42537 index 9f0c465..47194ee 100644
42538 --- a/drivers/scsi/sg.c
42539 +++ b/drivers/scsi/sg.c
42540 @@ -1101,7 +1101,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
42541 sdp->disk->disk_name,
42542 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
42543 NULL,
42544 - (char *)arg);
42545 + (char __user *)arg);
42546 case BLKTRACESTART:
42547 return blk_trace_startstop(sdp->device->request_queue, 1);
42548 case BLKTRACESTOP:
42549 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
42550 index 004b10f..7c98d51 100644
42551 --- a/drivers/spi/spi.c
42552 +++ b/drivers/spi/spi.c
42553 @@ -1620,7 +1620,7 @@ int spi_bus_unlock(struct spi_master *master)
42554 EXPORT_SYMBOL_GPL(spi_bus_unlock);
42555
42556 /* portable code must never pass more than 32 bytes */
42557 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
42558 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
42559
42560 static u8 *buf;
42561
42562 diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
42563 index 93af756..a4bc5bf 100644
42564 --- a/drivers/staging/iio/iio_hwmon.c
42565 +++ b/drivers/staging/iio/iio_hwmon.c
42566 @@ -67,7 +67,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
42567 {
42568 struct device *dev = &pdev->dev;
42569 struct iio_hwmon_state *st;
42570 - struct sensor_device_attribute *a;
42571 + sensor_device_attribute_no_const *a;
42572 int ret, i;
42573 int in_i = 1, temp_i = 1, curr_i = 1;
42574 enum iio_chan_type type;
42575 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
42576 index 34afc16..ffe44dd 100644
42577 --- a/drivers/staging/octeon/ethernet-rx.c
42578 +++ b/drivers/staging/octeon/ethernet-rx.c
42579 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42580 /* Increment RX stats for virtual ports */
42581 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
42582 #ifdef CONFIG_64BIT
42583 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
42584 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
42585 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
42586 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
42587 #else
42588 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
42589 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
42590 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
42591 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
42592 #endif
42593 }
42594 netif_receive_skb(skb);
42595 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42596 dev->name);
42597 */
42598 #ifdef CONFIG_64BIT
42599 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
42600 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42601 #else
42602 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
42603 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
42604 #endif
42605 dev_kfree_skb_irq(skb);
42606 }
42607 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
42608 index c3a90e7..023619a 100644
42609 --- a/drivers/staging/octeon/ethernet.c
42610 +++ b/drivers/staging/octeon/ethernet.c
42611 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
42612 * since the RX tasklet also increments it.
42613 */
42614 #ifdef CONFIG_64BIT
42615 - atomic64_add(rx_status.dropped_packets,
42616 - (atomic64_t *)&priv->stats.rx_dropped);
42617 + atomic64_add_unchecked(rx_status.dropped_packets,
42618 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42619 #else
42620 - atomic_add(rx_status.dropped_packets,
42621 - (atomic_t *)&priv->stats.rx_dropped);
42622 + atomic_add_unchecked(rx_status.dropped_packets,
42623 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
42624 #endif
42625 }
42626
42627 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
42628 index dc23395..cf7e9b1 100644
42629 --- a/drivers/staging/rtl8712/rtl871x_io.h
42630 +++ b/drivers/staging/rtl8712/rtl871x_io.h
42631 @@ -108,7 +108,7 @@ struct _io_ops {
42632 u8 *pmem);
42633 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
42634 u8 *pmem);
42635 -};
42636 +} __no_const;
42637
42638 struct io_req {
42639 struct list_head list;
42640 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
42641 index 1f5088b..0e59820 100644
42642 --- a/drivers/staging/sbe-2t3e3/netdev.c
42643 +++ b/drivers/staging/sbe-2t3e3/netdev.c
42644 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
42645 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
42646
42647 if (rlen)
42648 - if (copy_to_user(data, &resp, rlen))
42649 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
42650 return -EFAULT;
42651
42652 return 0;
42653 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
42654 index 5dddc4d..34fcb2f 100644
42655 --- a/drivers/staging/usbip/vhci.h
42656 +++ b/drivers/staging/usbip/vhci.h
42657 @@ -83,7 +83,7 @@ struct vhci_hcd {
42658 unsigned resuming:1;
42659 unsigned long re_timeout;
42660
42661 - atomic_t seqnum;
42662 + atomic_unchecked_t seqnum;
42663
42664 /*
42665 * NOTE:
42666 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
42667 index f1ca084..7b5c0c3 100644
42668 --- a/drivers/staging/usbip/vhci_hcd.c
42669 +++ b/drivers/staging/usbip/vhci_hcd.c
42670 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
42671
42672 spin_lock(&vdev->priv_lock);
42673
42674 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
42675 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
42676 if (priv->seqnum == 0xffff)
42677 dev_info(&urb->dev->dev, "seqnum max\n");
42678
42679 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
42680 return -ENOMEM;
42681 }
42682
42683 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
42684 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
42685 if (unlink->seqnum == 0xffff)
42686 pr_info("seqnum max\n");
42687
42688 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
42689 vdev->rhport = rhport;
42690 }
42691
42692 - atomic_set(&vhci->seqnum, 0);
42693 + atomic_set_unchecked(&vhci->seqnum, 0);
42694 spin_lock_init(&vhci->lock);
42695
42696 hcd->power_budget = 0; /* no limit */
42697 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
42698 index faf8e60..c46f8ab 100644
42699 --- a/drivers/staging/usbip/vhci_rx.c
42700 +++ b/drivers/staging/usbip/vhci_rx.c
42701 @@ -76,7 +76,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
42702 if (!urb) {
42703 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
42704 pr_info("max seqnum %d\n",
42705 - atomic_read(&the_controller->seqnum));
42706 + atomic_read_unchecked(&the_controller->seqnum));
42707 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
42708 return;
42709 }
42710 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
42711 index 5f13890..36a044b 100644
42712 --- a/drivers/staging/vt6655/hostap.c
42713 +++ b/drivers/staging/vt6655/hostap.c
42714 @@ -73,14 +73,13 @@ static int msglevel =MSG_LEVEL_INFO;
42715 *
42716 */
42717
42718 +static net_device_ops_no_const apdev_netdev_ops;
42719 +
42720 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42721 {
42722 PSDevice apdev_priv;
42723 struct net_device *dev = pDevice->dev;
42724 int ret;
42725 - const struct net_device_ops apdev_netdev_ops = {
42726 - .ndo_start_xmit = pDevice->tx_80211,
42727 - };
42728
42729 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
42730
42731 @@ -92,6 +91,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
42732 *apdev_priv = *pDevice;
42733 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
42734
42735 + /* only half broken now */
42736 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
42737 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
42738
42739 pDevice->apdev->type = ARPHRD_IEEE80211;
42740 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
42741 index bc5e9da..dacd556 100644
42742 --- a/drivers/staging/vt6656/hostap.c
42743 +++ b/drivers/staging/vt6656/hostap.c
42744 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
42745 *
42746 */
42747
42748 +static net_device_ops_no_const apdev_netdev_ops;
42749 +
42750 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
42751 {
42752 struct vnt_private *apdev_priv;
42753 struct net_device *dev = pDevice->dev;
42754 int ret;
42755 - const struct net_device_ops apdev_netdev_ops = {
42756 - .ndo_start_xmit = pDevice->tx_80211,
42757 - };
42758
42759 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
42760
42761 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
42762 *apdev_priv = *pDevice;
42763 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
42764
42765 + /* only half broken now */
42766 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
42767 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
42768
42769 pDevice->apdev->type = ARPHRD_IEEE80211;
42770 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
42771 index a2b7e03..9ff4bbd 100644
42772 --- a/drivers/staging/zcache/tmem.c
42773 +++ b/drivers/staging/zcache/tmem.c
42774 @@ -50,7 +50,7 @@
42775 * A tmem host implementation must use this function to register callbacks
42776 * for memory allocation.
42777 */
42778 -static struct tmem_hostops tmem_hostops;
42779 +static tmem_hostops_no_const tmem_hostops;
42780
42781 static void tmem_objnode_tree_init(void);
42782
42783 @@ -64,7 +64,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
42784 * A tmem host implementation must use this function to register
42785 * callbacks for a page-accessible memory (PAM) implementation.
42786 */
42787 -static struct tmem_pamops tmem_pamops;
42788 +static tmem_pamops_no_const tmem_pamops;
42789
42790 void tmem_register_pamops(struct tmem_pamops *m)
42791 {
42792 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
42793 index adbe5a8..d387359 100644
42794 --- a/drivers/staging/zcache/tmem.h
42795 +++ b/drivers/staging/zcache/tmem.h
42796 @@ -226,6 +226,7 @@ struct tmem_pamops {
42797 int (*replace_in_obj)(void *, struct tmem_obj *);
42798 #endif
42799 };
42800 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
42801 extern void tmem_register_pamops(struct tmem_pamops *m);
42802
42803 /* memory allocation methods provided by the host implementation */
42804 @@ -235,6 +236,7 @@ struct tmem_hostops {
42805 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
42806 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
42807 };
42808 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
42809 extern void tmem_register_hostops(struct tmem_hostops *m);
42810
42811 /* core tmem accessor functions */
42812 diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
42813 index ca2be40..93ae910 100644
42814 --- a/drivers/target/iscsi/iscsi_target_parameters.c
42815 +++ b/drivers/target/iscsi/iscsi_target_parameters.c
42816 @@ -712,9 +712,9 @@ static int iscsi_add_notunderstood_response(
42817 }
42818 INIT_LIST_HEAD(&extra_response->er_list);
42819
42820 - strncpy(extra_response->key, key, strlen(key) + 1);
42821 - strncpy(extra_response->value, NOTUNDERSTOOD,
42822 - strlen(NOTUNDERSTOOD) + 1);
42823 + strlcpy(extra_response->key, key, sizeof(extra_response->key));
42824 + strlcpy(extra_response->value, NOTUNDERSTOOD,
42825 + sizeof(extra_response->value));
42826
42827 list_add_tail(&extra_response->er_list,
42828 &param_list->extra_response_list);
42829 @@ -1583,8 +1583,6 @@ int iscsi_decode_text_input(
42830
42831 if (phase & PHASE_SECURITY) {
42832 if (iscsi_check_for_auth_key(key) > 0) {
42833 - char *tmpptr = key + strlen(key);
42834 - *tmpptr = '=';
42835 kfree(tmpbuf);
42836 return 1;
42837 }
42838 diff --git a/drivers/target/iscsi/iscsi_target_parameters.h b/drivers/target/iscsi/iscsi_target_parameters.h
42839 index 1e1b750..2c536a0 100644
42840 --- a/drivers/target/iscsi/iscsi_target_parameters.h
42841 +++ b/drivers/target/iscsi/iscsi_target_parameters.h
42842 @@ -1,8 +1,10 @@
42843 #ifndef ISCSI_PARAMETERS_H
42844 #define ISCSI_PARAMETERS_H
42845
42846 +#include <scsi/iscsi_proto.h>
42847 +
42848 struct iscsi_extra_response {
42849 - char key[64];
42850 + char key[KEY_MAXLEN];
42851 char value[32];
42852 struct list_head er_list;
42853 } ____cacheline_aligned;
42854 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
42855 index 2e4d655..fd72e68 100644
42856 --- a/drivers/target/target_core_device.c
42857 +++ b/drivers/target/target_core_device.c
42858 @@ -1414,7 +1414,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
42859 spin_lock_init(&dev->se_port_lock);
42860 spin_lock_init(&dev->se_tmr_lock);
42861 spin_lock_init(&dev->qf_cmd_lock);
42862 - atomic_set(&dev->dev_ordered_id, 0);
42863 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
42864 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
42865 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
42866 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
42867 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
42868 index 0d46276..f327cab5 100644
42869 --- a/drivers/target/target_core_transport.c
42870 +++ b/drivers/target/target_core_transport.c
42871 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
42872 * Used to determine when ORDERED commands should go from
42873 * Dormant to Active status.
42874 */
42875 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
42876 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
42877 smp_mb__after_atomic_inc();
42878 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
42879 cmd->se_ordered_id, cmd->sam_task_attr,
42880 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
42881 index 345bd0e..61d5375 100644
42882 --- a/drivers/tty/cyclades.c
42883 +++ b/drivers/tty/cyclades.c
42884 @@ -1576,10 +1576,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
42885 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
42886 info->port.count);
42887 #endif
42888 - info->port.count++;
42889 + atomic_inc(&info->port.count);
42890 #ifdef CY_DEBUG_COUNT
42891 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
42892 - current->pid, info->port.count);
42893 + current->pid, atomic_read(&info->port.count));
42894 #endif
42895
42896 /*
42897 @@ -3978,7 +3978,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
42898 for (j = 0; j < cy_card[i].nports; j++) {
42899 info = &cy_card[i].ports[j];
42900
42901 - if (info->port.count) {
42902 + if (atomic_read(&info->port.count)) {
42903 /* XXX is the ldisc num worth this? */
42904 struct tty_struct *tty;
42905 struct tty_ldisc *ld;
42906 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
42907 index eb255e8..f637a57 100644
42908 --- a/drivers/tty/hvc/hvc_console.c
42909 +++ b/drivers/tty/hvc/hvc_console.c
42910 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
42911
42912 spin_lock_irqsave(&hp->port.lock, flags);
42913 /* Check and then increment for fast path open. */
42914 - if (hp->port.count++ > 0) {
42915 + if (atomic_inc_return(&hp->port.count) > 1) {
42916 spin_unlock_irqrestore(&hp->port.lock, flags);
42917 hvc_kick();
42918 return 0;
42919 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
42920
42921 spin_lock_irqsave(&hp->port.lock, flags);
42922
42923 - if (--hp->port.count == 0) {
42924 + if (atomic_dec_return(&hp->port.count) == 0) {
42925 spin_unlock_irqrestore(&hp->port.lock, flags);
42926 /* We are done with the tty pointer now. */
42927 tty_port_tty_set(&hp->port, NULL);
42928 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
42929 */
42930 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
42931 } else {
42932 - if (hp->port.count < 0)
42933 + if (atomic_read(&hp->port.count) < 0)
42934 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
42935 - hp->vtermno, hp->port.count);
42936 + hp->vtermno, atomic_read(&hp->port.count));
42937 spin_unlock_irqrestore(&hp->port.lock, flags);
42938 }
42939 }
42940 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
42941 * open->hangup case this can be called after the final close so prevent
42942 * that from happening for now.
42943 */
42944 - if (hp->port.count <= 0) {
42945 + if (atomic_read(&hp->port.count) <= 0) {
42946 spin_unlock_irqrestore(&hp->port.lock, flags);
42947 return;
42948 }
42949
42950 - hp->port.count = 0;
42951 + atomic_set(&hp->port.count, 0);
42952 spin_unlock_irqrestore(&hp->port.lock, flags);
42953 tty_port_tty_set(&hp->port, NULL);
42954
42955 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
42956 return -EPIPE;
42957
42958 /* FIXME what's this (unprotected) check for? */
42959 - if (hp->port.count <= 0)
42960 + if (atomic_read(&hp->port.count) <= 0)
42961 return -EIO;
42962
42963 spin_lock_irqsave(&hp->lock, flags);
42964 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
42965 index 81e939e..95ead10 100644
42966 --- a/drivers/tty/hvc/hvcs.c
42967 +++ b/drivers/tty/hvc/hvcs.c
42968 @@ -83,6 +83,7 @@
42969 #include <asm/hvcserver.h>
42970 #include <asm/uaccess.h>
42971 #include <asm/vio.h>
42972 +#include <asm/local.h>
42973
42974 /*
42975 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
42976 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
42977
42978 spin_lock_irqsave(&hvcsd->lock, flags);
42979
42980 - if (hvcsd->port.count > 0) {
42981 + if (atomic_read(&hvcsd->port.count) > 0) {
42982 spin_unlock_irqrestore(&hvcsd->lock, flags);
42983 printk(KERN_INFO "HVCS: vterm state unchanged. "
42984 "The hvcs device node is still in use.\n");
42985 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
42986 }
42987 }
42988
42989 - hvcsd->port.count = 0;
42990 + atomic_set(&hvcsd->port.count, 0);
42991 hvcsd->port.tty = tty;
42992 tty->driver_data = hvcsd;
42993
42994 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
42995 unsigned long flags;
42996
42997 spin_lock_irqsave(&hvcsd->lock, flags);
42998 - hvcsd->port.count++;
42999 + atomic_inc(&hvcsd->port.count);
43000 hvcsd->todo_mask |= HVCS_SCHED_READ;
43001 spin_unlock_irqrestore(&hvcsd->lock, flags);
43002
43003 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43004 hvcsd = tty->driver_data;
43005
43006 spin_lock_irqsave(&hvcsd->lock, flags);
43007 - if (--hvcsd->port.count == 0) {
43008 + if (atomic_dec_and_test(&hvcsd->port.count)) {
43009
43010 vio_disable_interrupts(hvcsd->vdev);
43011
43012 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43013
43014 free_irq(irq, hvcsd);
43015 return;
43016 - } else if (hvcsd->port.count < 0) {
43017 + } else if (atomic_read(&hvcsd->port.count) < 0) {
43018 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
43019 " is missmanaged.\n",
43020 - hvcsd->vdev->unit_address, hvcsd->port.count);
43021 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
43022 }
43023
43024 spin_unlock_irqrestore(&hvcsd->lock, flags);
43025 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43026
43027 spin_lock_irqsave(&hvcsd->lock, flags);
43028 /* Preserve this so that we know how many kref refs to put */
43029 - temp_open_count = hvcsd->port.count;
43030 + temp_open_count = atomic_read(&hvcsd->port.count);
43031
43032 /*
43033 * Don't kref put inside the spinlock because the destruction
43034 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43035 tty->driver_data = NULL;
43036 hvcsd->port.tty = NULL;
43037
43038 - hvcsd->port.count = 0;
43039 + atomic_set(&hvcsd->port.count, 0);
43040
43041 /* This will drop any buffered data on the floor which is OK in a hangup
43042 * scenario. */
43043 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
43044 * the middle of a write operation? This is a crummy place to do this
43045 * but we want to keep it all in the spinlock.
43046 */
43047 - if (hvcsd->port.count <= 0) {
43048 + if (atomic_read(&hvcsd->port.count) <= 0) {
43049 spin_unlock_irqrestore(&hvcsd->lock, flags);
43050 return -ENODEV;
43051 }
43052 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
43053 {
43054 struct hvcs_struct *hvcsd = tty->driver_data;
43055
43056 - if (!hvcsd || hvcsd->port.count <= 0)
43057 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
43058 return 0;
43059
43060 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
43061 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
43062 index 8fd72ff..34a0bed 100644
43063 --- a/drivers/tty/ipwireless/tty.c
43064 +++ b/drivers/tty/ipwireless/tty.c
43065 @@ -29,6 +29,7 @@
43066 #include <linux/tty_driver.h>
43067 #include <linux/tty_flip.h>
43068 #include <linux/uaccess.h>
43069 +#include <asm/local.h>
43070
43071 #include "tty.h"
43072 #include "network.h"
43073 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43074 mutex_unlock(&tty->ipw_tty_mutex);
43075 return -ENODEV;
43076 }
43077 - if (tty->port.count == 0)
43078 + if (atomic_read(&tty->port.count) == 0)
43079 tty->tx_bytes_queued = 0;
43080
43081 - tty->port.count++;
43082 + atomic_inc(&tty->port.count);
43083
43084 tty->port.tty = linux_tty;
43085 linux_tty->driver_data = tty;
43086 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43087
43088 static void do_ipw_close(struct ipw_tty *tty)
43089 {
43090 - tty->port.count--;
43091 -
43092 - if (tty->port.count == 0) {
43093 + if (atomic_dec_return(&tty->port.count) == 0) {
43094 struct tty_struct *linux_tty = tty->port.tty;
43095
43096 if (linux_tty != NULL) {
43097 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
43098 return;
43099
43100 mutex_lock(&tty->ipw_tty_mutex);
43101 - if (tty->port.count == 0) {
43102 + if (atomic_read(&tty->port.count) == 0) {
43103 mutex_unlock(&tty->ipw_tty_mutex);
43104 return;
43105 }
43106 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
43107
43108 mutex_lock(&tty->ipw_tty_mutex);
43109
43110 - if (!tty->port.count) {
43111 + if (!atomic_read(&tty->port.count)) {
43112 mutex_unlock(&tty->ipw_tty_mutex);
43113 return;
43114 }
43115 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
43116 return -ENODEV;
43117
43118 mutex_lock(&tty->ipw_tty_mutex);
43119 - if (!tty->port.count) {
43120 + if (!atomic_read(&tty->port.count)) {
43121 mutex_unlock(&tty->ipw_tty_mutex);
43122 return -EINVAL;
43123 }
43124 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
43125 if (!tty)
43126 return -ENODEV;
43127
43128 - if (!tty->port.count)
43129 + if (!atomic_read(&tty->port.count))
43130 return -EINVAL;
43131
43132 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
43133 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
43134 if (!tty)
43135 return 0;
43136
43137 - if (!tty->port.count)
43138 + if (!atomic_read(&tty->port.count))
43139 return 0;
43140
43141 return tty->tx_bytes_queued;
43142 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
43143 if (!tty)
43144 return -ENODEV;
43145
43146 - if (!tty->port.count)
43147 + if (!atomic_read(&tty->port.count))
43148 return -EINVAL;
43149
43150 return get_control_lines(tty);
43151 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
43152 if (!tty)
43153 return -ENODEV;
43154
43155 - if (!tty->port.count)
43156 + if (!atomic_read(&tty->port.count))
43157 return -EINVAL;
43158
43159 return set_control_lines(tty, set, clear);
43160 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
43161 if (!tty)
43162 return -ENODEV;
43163
43164 - if (!tty->port.count)
43165 + if (!atomic_read(&tty->port.count))
43166 return -EINVAL;
43167
43168 /* FIXME: Exactly how is the tty object locked here .. */
43169 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
43170 * are gone */
43171 mutex_lock(&ttyj->ipw_tty_mutex);
43172 }
43173 - while (ttyj->port.count)
43174 + while (atomic_read(&ttyj->port.count))
43175 do_ipw_close(ttyj);
43176 ipwireless_disassociate_network_ttys(network,
43177 ttyj->channel_idx);
43178 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
43179 index adeac25..787a0a1 100644
43180 --- a/drivers/tty/moxa.c
43181 +++ b/drivers/tty/moxa.c
43182 @@ -1193,7 +1193,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
43183 }
43184
43185 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
43186 - ch->port.count++;
43187 + atomic_inc(&ch->port.count);
43188 tty->driver_data = ch;
43189 tty_port_tty_set(&ch->port, tty);
43190 mutex_lock(&ch->port.mutex);
43191 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
43192 index 4a43ef5d7..aa71f27 100644
43193 --- a/drivers/tty/n_gsm.c
43194 +++ b/drivers/tty/n_gsm.c
43195 @@ -1636,7 +1636,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
43196 spin_lock_init(&dlci->lock);
43197 mutex_init(&dlci->mutex);
43198 dlci->fifo = &dlci->_fifo;
43199 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
43200 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
43201 kfree(dlci);
43202 return NULL;
43203 }
43204 @@ -2936,7 +2936,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
43205 struct gsm_dlci *dlci = tty->driver_data;
43206 struct tty_port *port = &dlci->port;
43207
43208 - port->count++;
43209 + atomic_inc(&port->count);
43210 dlci_get(dlci);
43211 dlci_get(dlci->gsm->dlci[0]);
43212 mux_get(dlci->gsm);
43213 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
43214 index 05e72be..67f6a0f 100644
43215 --- a/drivers/tty/n_tty.c
43216 +++ b/drivers/tty/n_tty.c
43217 @@ -2197,6 +2197,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
43218 {
43219 *ops = tty_ldisc_N_TTY;
43220 ops->owner = NULL;
43221 - ops->refcount = ops->flags = 0;
43222 + atomic_set(&ops->refcount, 0);
43223 + ops->flags = 0;
43224 }
43225 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
43226 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
43227 index 125e0fd..8c50690 100644
43228 --- a/drivers/tty/pty.c
43229 +++ b/drivers/tty/pty.c
43230 @@ -800,8 +800,10 @@ static void __init unix98_pty_init(void)
43231 panic("Couldn't register Unix98 pts driver");
43232
43233 /* Now create the /dev/ptmx special device */
43234 + pax_open_kernel();
43235 tty_default_fops(&ptmx_fops);
43236 - ptmx_fops.open = ptmx_open;
43237 + *(void **)&ptmx_fops.open = ptmx_open;
43238 + pax_close_kernel();
43239
43240 cdev_init(&ptmx_cdev, &ptmx_fops);
43241 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
43242 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
43243 index 1d27003..959f452 100644
43244 --- a/drivers/tty/rocket.c
43245 +++ b/drivers/tty/rocket.c
43246 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43247 tty->driver_data = info;
43248 tty_port_tty_set(port, tty);
43249
43250 - if (port->count++ == 0) {
43251 + if (atomic_inc_return(&port->count) == 1) {
43252 atomic_inc(&rp_num_ports_open);
43253
43254 #ifdef ROCKET_DEBUG_OPEN
43255 @@ -932,7 +932,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43256 #endif
43257 }
43258 #ifdef ROCKET_DEBUG_OPEN
43259 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
43260 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
43261 #endif
43262
43263 /*
43264 @@ -1527,7 +1527,7 @@ static void rp_hangup(struct tty_struct *tty)
43265 spin_unlock_irqrestore(&info->port.lock, flags);
43266 return;
43267 }
43268 - if (info->port.count)
43269 + if (atomic_read(&info->port.count))
43270 atomic_dec(&rp_num_ports_open);
43271 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
43272 spin_unlock_irqrestore(&info->port.lock, flags);
43273 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
43274 index 1002054..dd644a8 100644
43275 --- a/drivers/tty/serial/kgdboc.c
43276 +++ b/drivers/tty/serial/kgdboc.c
43277 @@ -24,8 +24,9 @@
43278 #define MAX_CONFIG_LEN 40
43279
43280 static struct kgdb_io kgdboc_io_ops;
43281 +static struct kgdb_io kgdboc_io_ops_console;
43282
43283 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
43284 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
43285 static int configured = -1;
43286
43287 static char config[MAX_CONFIG_LEN];
43288 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
43289 kgdboc_unregister_kbd();
43290 if (configured == 1)
43291 kgdb_unregister_io_module(&kgdboc_io_ops);
43292 + else if (configured == 2)
43293 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
43294 }
43295
43296 static int configure_kgdboc(void)
43297 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
43298 int err;
43299 char *cptr = config;
43300 struct console *cons;
43301 + int is_console = 0;
43302
43303 err = kgdboc_option_setup(config);
43304 if (err || !strlen(config) || isspace(config[0]))
43305 goto noconfig;
43306
43307 err = -ENODEV;
43308 - kgdboc_io_ops.is_console = 0;
43309 kgdb_tty_driver = NULL;
43310
43311 kgdboc_use_kms = 0;
43312 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
43313 int idx;
43314 if (cons->device && cons->device(cons, &idx) == p &&
43315 idx == tty_line) {
43316 - kgdboc_io_ops.is_console = 1;
43317 + is_console = 1;
43318 break;
43319 }
43320 cons = cons->next;
43321 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
43322 kgdb_tty_line = tty_line;
43323
43324 do_register:
43325 - err = kgdb_register_io_module(&kgdboc_io_ops);
43326 + if (is_console) {
43327 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
43328 + configured = 2;
43329 + } else {
43330 + err = kgdb_register_io_module(&kgdboc_io_ops);
43331 + configured = 1;
43332 + }
43333 if (err)
43334 goto noconfig;
43335
43336 @@ -205,8 +214,6 @@ do_register:
43337 if (err)
43338 goto nmi_con_failed;
43339
43340 - configured = 1;
43341 -
43342 return 0;
43343
43344 nmi_con_failed:
43345 @@ -223,7 +230,7 @@ noconfig:
43346 static int __init init_kgdboc(void)
43347 {
43348 /* Already configured? */
43349 - if (configured == 1)
43350 + if (configured >= 1)
43351 return 0;
43352
43353 return configure_kgdboc();
43354 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
43355 if (config[len - 1] == '\n')
43356 config[len - 1] = '\0';
43357
43358 - if (configured == 1)
43359 + if (configured >= 1)
43360 cleanup_kgdboc();
43361
43362 /* Go and configure with the new params. */
43363 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43364 .post_exception = kgdboc_post_exp_handler,
43365 };
43366
43367 +static struct kgdb_io kgdboc_io_ops_console = {
43368 + .name = "kgdboc",
43369 + .read_char = kgdboc_get_char,
43370 + .write_char = kgdboc_put_char,
43371 + .pre_exception = kgdboc_pre_exp_handler,
43372 + .post_exception = kgdboc_post_exp_handler,
43373 + .is_console = 1
43374 +};
43375 +
43376 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43377 /* This is only available if kgdboc is a built in for early debugging */
43378 static int __init kgdboc_early_init(char *opt)
43379 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43380 index 2769a38..f3dbe48 100644
43381 --- a/drivers/tty/serial/samsung.c
43382 +++ b/drivers/tty/serial/samsung.c
43383 @@ -451,11 +451,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43384 }
43385 }
43386
43387 +static int s3c64xx_serial_startup(struct uart_port *port);
43388 static int s3c24xx_serial_startup(struct uart_port *port)
43389 {
43390 struct s3c24xx_uart_port *ourport = to_ourport(port);
43391 int ret;
43392
43393 + /* Startup sequence is different for s3c64xx and higher SoC's */
43394 + if (s3c24xx_serial_has_interrupt_mask(port))
43395 + return s3c64xx_serial_startup(port);
43396 +
43397 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43398 port->mapbase, port->membase);
43399
43400 @@ -1120,10 +1125,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43401 /* setup info for port */
43402 port->dev = &platdev->dev;
43403
43404 - /* Startup sequence is different for s3c64xx and higher SoC's */
43405 - if (s3c24xx_serial_has_interrupt_mask(port))
43406 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43407 -
43408 port->uartclk = 1;
43409
43410 if (cfg->uart_flags & UPF_CONS_FLOW) {
43411 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43412 index 8fbb6d2..822a9e6 100644
43413 --- a/drivers/tty/serial/serial_core.c
43414 +++ b/drivers/tty/serial/serial_core.c
43415 @@ -1454,7 +1454,7 @@ static void uart_hangup(struct tty_struct *tty)
43416 uart_flush_buffer(tty);
43417 uart_shutdown(tty, state);
43418 spin_lock_irqsave(&port->lock, flags);
43419 - port->count = 0;
43420 + atomic_set(&port->count, 0);
43421 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43422 spin_unlock_irqrestore(&port->lock, flags);
43423 tty_port_tty_set(port, NULL);
43424 @@ -1550,7 +1550,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43425 goto end;
43426 }
43427
43428 - port->count++;
43429 + atomic_inc(&port->count);
43430 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43431 retval = -ENXIO;
43432 goto err_dec_count;
43433 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43434 /*
43435 * Make sure the device is in D0 state.
43436 */
43437 - if (port->count == 1)
43438 + if (atomic_read(&port->count) == 1)
43439 uart_change_pm(state, UART_PM_STATE_ON);
43440
43441 /*
43442 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43443 end:
43444 return retval;
43445 err_dec_count:
43446 - port->count--;
43447 + atomic_inc(&port->count);
43448 mutex_unlock(&port->mutex);
43449 goto end;
43450 }
43451 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43452 index 8983276..72a4090 100644
43453 --- a/drivers/tty/synclink.c
43454 +++ b/drivers/tty/synclink.c
43455 @@ -3093,7 +3093,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43456
43457 if (debug_level >= DEBUG_LEVEL_INFO)
43458 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43459 - __FILE__,__LINE__, info->device_name, info->port.count);
43460 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43461
43462 if (tty_port_close_start(&info->port, tty, filp) == 0)
43463 goto cleanup;
43464 @@ -3111,7 +3111,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43465 cleanup:
43466 if (debug_level >= DEBUG_LEVEL_INFO)
43467 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43468 - tty->driver->name, info->port.count);
43469 + tty->driver->name, atomic_read(&info->port.count));
43470
43471 } /* end of mgsl_close() */
43472
43473 @@ -3210,8 +3210,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43474
43475 mgsl_flush_buffer(tty);
43476 shutdown(info);
43477 -
43478 - info->port.count = 0;
43479 +
43480 + atomic_set(&info->port.count, 0);
43481 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43482 info->port.tty = NULL;
43483
43484 @@ -3300,12 +3300,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43485
43486 if (debug_level >= DEBUG_LEVEL_INFO)
43487 printk("%s(%d):block_til_ready before block on %s count=%d\n",
43488 - __FILE__,__LINE__, tty->driver->name, port->count );
43489 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43490
43491 spin_lock_irqsave(&info->irq_spinlock, flags);
43492 if (!tty_hung_up_p(filp)) {
43493 extra_count = true;
43494 - port->count--;
43495 + atomic_dec(&port->count);
43496 }
43497 spin_unlock_irqrestore(&info->irq_spinlock, flags);
43498 port->blocked_open++;
43499 @@ -3334,7 +3334,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43500
43501 if (debug_level >= DEBUG_LEVEL_INFO)
43502 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
43503 - __FILE__,__LINE__, tty->driver->name, port->count );
43504 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43505
43506 tty_unlock(tty);
43507 schedule();
43508 @@ -3346,12 +3346,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43509
43510 /* FIXME: Racy on hangup during close wait */
43511 if (extra_count)
43512 - port->count++;
43513 + atomic_inc(&port->count);
43514 port->blocked_open--;
43515
43516 if (debug_level >= DEBUG_LEVEL_INFO)
43517 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
43518 - __FILE__,__LINE__, tty->driver->name, port->count );
43519 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43520
43521 if (!retval)
43522 port->flags |= ASYNC_NORMAL_ACTIVE;
43523 @@ -3403,7 +3403,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43524
43525 if (debug_level >= DEBUG_LEVEL_INFO)
43526 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
43527 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43528 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43529
43530 /* If port is closing, signal caller to try again */
43531 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43532 @@ -3422,10 +3422,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43533 spin_unlock_irqrestore(&info->netlock, flags);
43534 goto cleanup;
43535 }
43536 - info->port.count++;
43537 + atomic_inc(&info->port.count);
43538 spin_unlock_irqrestore(&info->netlock, flags);
43539
43540 - if (info->port.count == 1) {
43541 + if (atomic_read(&info->port.count) == 1) {
43542 /* 1st open on this device, init hardware */
43543 retval = startup(info);
43544 if (retval < 0)
43545 @@ -3449,8 +3449,8 @@ cleanup:
43546 if (retval) {
43547 if (tty->count == 1)
43548 info->port.tty = NULL; /* tty layer will release tty struct */
43549 - if(info->port.count)
43550 - info->port.count--;
43551 + if (atomic_read(&info->port.count))
43552 + atomic_dec(&info->port.count);
43553 }
43554
43555 return retval;
43556 @@ -7668,7 +7668,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43557 unsigned short new_crctype;
43558
43559 /* return error if TTY interface open */
43560 - if (info->port.count)
43561 + if (atomic_read(&info->port.count))
43562 return -EBUSY;
43563
43564 switch (encoding)
43565 @@ -7763,7 +7763,7 @@ static int hdlcdev_open(struct net_device *dev)
43566
43567 /* arbitrate between network and tty opens */
43568 spin_lock_irqsave(&info->netlock, flags);
43569 - if (info->port.count != 0 || info->netcount != 0) {
43570 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43571 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43572 spin_unlock_irqrestore(&info->netlock, flags);
43573 return -EBUSY;
43574 @@ -7849,7 +7849,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43575 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43576
43577 /* return error if TTY interface open */
43578 - if (info->port.count)
43579 + if (atomic_read(&info->port.count))
43580 return -EBUSY;
43581
43582 if (cmd != SIOCWANDEV)
43583 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
43584 index aa9eece..d8baaec 100644
43585 --- a/drivers/tty/synclink_gt.c
43586 +++ b/drivers/tty/synclink_gt.c
43587 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43588 tty->driver_data = info;
43589 info->port.tty = tty;
43590
43591 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
43592 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
43593
43594 /* If port is closing, signal caller to try again */
43595 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43596 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43597 mutex_unlock(&info->port.mutex);
43598 goto cleanup;
43599 }
43600 - info->port.count++;
43601 + atomic_inc(&info->port.count);
43602 spin_unlock_irqrestore(&info->netlock, flags);
43603
43604 - if (info->port.count == 1) {
43605 + if (atomic_read(&info->port.count) == 1) {
43606 /* 1st open on this device, init hardware */
43607 retval = startup(info);
43608 if (retval < 0) {
43609 @@ -715,8 +715,8 @@ cleanup:
43610 if (retval) {
43611 if (tty->count == 1)
43612 info->port.tty = NULL; /* tty layer will release tty struct */
43613 - if(info->port.count)
43614 - info->port.count--;
43615 + if(atomic_read(&info->port.count))
43616 + atomic_dec(&info->port.count);
43617 }
43618
43619 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
43620 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43621
43622 if (sanity_check(info, tty->name, "close"))
43623 return;
43624 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
43625 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
43626
43627 if (tty_port_close_start(&info->port, tty, filp) == 0)
43628 goto cleanup;
43629 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43630 tty_port_close_end(&info->port, tty);
43631 info->port.tty = NULL;
43632 cleanup:
43633 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
43634 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
43635 }
43636
43637 static void hangup(struct tty_struct *tty)
43638 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
43639 shutdown(info);
43640
43641 spin_lock_irqsave(&info->port.lock, flags);
43642 - info->port.count = 0;
43643 + atomic_set(&info->port.count, 0);
43644 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43645 info->port.tty = NULL;
43646 spin_unlock_irqrestore(&info->port.lock, flags);
43647 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43648 unsigned short new_crctype;
43649
43650 /* return error if TTY interface open */
43651 - if (info->port.count)
43652 + if (atomic_read(&info->port.count))
43653 return -EBUSY;
43654
43655 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
43656 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
43657
43658 /* arbitrate between network and tty opens */
43659 spin_lock_irqsave(&info->netlock, flags);
43660 - if (info->port.count != 0 || info->netcount != 0) {
43661 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43662 DBGINFO(("%s hdlc_open busy\n", dev->name));
43663 spin_unlock_irqrestore(&info->netlock, flags);
43664 return -EBUSY;
43665 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43666 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
43667
43668 /* return error if TTY interface open */
43669 - if (info->port.count)
43670 + if (atomic_read(&info->port.count))
43671 return -EBUSY;
43672
43673 if (cmd != SIOCWANDEV)
43674 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
43675 if (port == NULL)
43676 continue;
43677 spin_lock(&port->lock);
43678 - if ((port->port.count || port->netcount) &&
43679 + if ((atomic_read(&port->port.count) || port->netcount) &&
43680 port->pending_bh && !port->bh_running &&
43681 !port->bh_requested) {
43682 DBGISR(("%s bh queued\n", port->device_name));
43683 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43684 spin_lock_irqsave(&info->lock, flags);
43685 if (!tty_hung_up_p(filp)) {
43686 extra_count = true;
43687 - port->count--;
43688 + atomic_dec(&port->count);
43689 }
43690 spin_unlock_irqrestore(&info->lock, flags);
43691 port->blocked_open++;
43692 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43693 remove_wait_queue(&port->open_wait, &wait);
43694
43695 if (extra_count)
43696 - port->count++;
43697 + atomic_inc(&port->count);
43698 port->blocked_open--;
43699
43700 if (!retval)
43701 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
43702 index 6d5780c..aa4d8cd 100644
43703 --- a/drivers/tty/synclinkmp.c
43704 +++ b/drivers/tty/synclinkmp.c
43705 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43706
43707 if (debug_level >= DEBUG_LEVEL_INFO)
43708 printk("%s(%d):%s open(), old ref count = %d\n",
43709 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43710 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43711
43712 /* If port is closing, signal caller to try again */
43713 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43714 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43715 spin_unlock_irqrestore(&info->netlock, flags);
43716 goto cleanup;
43717 }
43718 - info->port.count++;
43719 + atomic_inc(&info->port.count);
43720 spin_unlock_irqrestore(&info->netlock, flags);
43721
43722 - if (info->port.count == 1) {
43723 + if (atomic_read(&info->port.count) == 1) {
43724 /* 1st open on this device, init hardware */
43725 retval = startup(info);
43726 if (retval < 0)
43727 @@ -796,8 +796,8 @@ cleanup:
43728 if (retval) {
43729 if (tty->count == 1)
43730 info->port.tty = NULL; /* tty layer will release tty struct */
43731 - if(info->port.count)
43732 - info->port.count--;
43733 + if(atomic_read(&info->port.count))
43734 + atomic_dec(&info->port.count);
43735 }
43736
43737 return retval;
43738 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43739
43740 if (debug_level >= DEBUG_LEVEL_INFO)
43741 printk("%s(%d):%s close() entry, count=%d\n",
43742 - __FILE__,__LINE__, info->device_name, info->port.count);
43743 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43744
43745 if (tty_port_close_start(&info->port, tty, filp) == 0)
43746 goto cleanup;
43747 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43748 cleanup:
43749 if (debug_level >= DEBUG_LEVEL_INFO)
43750 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
43751 - tty->driver->name, info->port.count);
43752 + tty->driver->name, atomic_read(&info->port.count));
43753 }
43754
43755 /* Called by tty_hangup() when a hangup is signaled.
43756 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
43757 shutdown(info);
43758
43759 spin_lock_irqsave(&info->port.lock, flags);
43760 - info->port.count = 0;
43761 + atomic_set(&info->port.count, 0);
43762 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43763 info->port.tty = NULL;
43764 spin_unlock_irqrestore(&info->port.lock, flags);
43765 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43766 unsigned short new_crctype;
43767
43768 /* return error if TTY interface open */
43769 - if (info->port.count)
43770 + if (atomic_read(&info->port.count))
43771 return -EBUSY;
43772
43773 switch (encoding)
43774 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
43775
43776 /* arbitrate between network and tty opens */
43777 spin_lock_irqsave(&info->netlock, flags);
43778 - if (info->port.count != 0 || info->netcount != 0) {
43779 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43780 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43781 spin_unlock_irqrestore(&info->netlock, flags);
43782 return -EBUSY;
43783 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43784 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43785
43786 /* return error if TTY interface open */
43787 - if (info->port.count)
43788 + if (atomic_read(&info->port.count))
43789 return -EBUSY;
43790
43791 if (cmd != SIOCWANDEV)
43792 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
43793 * do not request bottom half processing if the
43794 * device is not open in a normal mode.
43795 */
43796 - if ( port && (port->port.count || port->netcount) &&
43797 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
43798 port->pending_bh && !port->bh_running &&
43799 !port->bh_requested ) {
43800 if ( debug_level >= DEBUG_LEVEL_ISR )
43801 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43802
43803 if (debug_level >= DEBUG_LEVEL_INFO)
43804 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
43805 - __FILE__,__LINE__, tty->driver->name, port->count );
43806 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43807
43808 spin_lock_irqsave(&info->lock, flags);
43809 if (!tty_hung_up_p(filp)) {
43810 extra_count = true;
43811 - port->count--;
43812 + atomic_dec(&port->count);
43813 }
43814 spin_unlock_irqrestore(&info->lock, flags);
43815 port->blocked_open++;
43816 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43817
43818 if (debug_level >= DEBUG_LEVEL_INFO)
43819 printk("%s(%d):%s block_til_ready() count=%d\n",
43820 - __FILE__,__LINE__, tty->driver->name, port->count );
43821 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43822
43823 tty_unlock(tty);
43824 schedule();
43825 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
43826 remove_wait_queue(&port->open_wait, &wait);
43827
43828 if (extra_count)
43829 - port->count++;
43830 + atomic_inc(&port->count);
43831 port->blocked_open--;
43832
43833 if (debug_level >= DEBUG_LEVEL_INFO)
43834 printk("%s(%d):%s block_til_ready() after, count=%d\n",
43835 - __FILE__,__LINE__, tty->driver->name, port->count );
43836 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43837
43838 if (!retval)
43839 port->flags |= ASYNC_NORMAL_ACTIVE;
43840 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
43841 index 3687f0c..6b9b808 100644
43842 --- a/drivers/tty/sysrq.c
43843 +++ b/drivers/tty/sysrq.c
43844 @@ -995,7 +995,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
43845 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
43846 size_t count, loff_t *ppos)
43847 {
43848 - if (count) {
43849 + if (count && capable(CAP_SYS_ADMIN)) {
43850 char c;
43851
43852 if (get_user(c, buf))
43853 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
43854 index a9cd0b9..47b9336 100644
43855 --- a/drivers/tty/tty_io.c
43856 +++ b/drivers/tty/tty_io.c
43857 @@ -3398,7 +3398,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
43858
43859 void tty_default_fops(struct file_operations *fops)
43860 {
43861 - *fops = tty_fops;
43862 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
43863 }
43864
43865 /*
43866 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
43867 index d794087..e4f49e5 100644
43868 --- a/drivers/tty/tty_ldisc.c
43869 +++ b/drivers/tty/tty_ldisc.c
43870 @@ -56,7 +56,7 @@ static void put_ldisc(struct tty_ldisc *ld)
43871 if (atomic_dec_and_test(&ld->users)) {
43872 struct tty_ldisc_ops *ldo = ld->ops;
43873
43874 - ldo->refcount--;
43875 + atomic_dec(&ldo->refcount);
43876 module_put(ldo->owner);
43877 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43878
43879 @@ -93,7 +93,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
43880 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43881 tty_ldiscs[disc] = new_ldisc;
43882 new_ldisc->num = disc;
43883 - new_ldisc->refcount = 0;
43884 + atomic_set(&new_ldisc->refcount, 0);
43885 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43886
43887 return ret;
43888 @@ -121,7 +121,7 @@ int tty_unregister_ldisc(int disc)
43889 return -EINVAL;
43890
43891 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43892 - if (tty_ldiscs[disc]->refcount)
43893 + if (atomic_read(&tty_ldiscs[disc]->refcount))
43894 ret = -EBUSY;
43895 else
43896 tty_ldiscs[disc] = NULL;
43897 @@ -142,7 +142,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
43898 if (ldops) {
43899 ret = ERR_PTR(-EAGAIN);
43900 if (try_module_get(ldops->owner)) {
43901 - ldops->refcount++;
43902 + atomic_inc(&ldops->refcount);
43903 ret = ldops;
43904 }
43905 }
43906 @@ -155,7 +155,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
43907 unsigned long flags;
43908
43909 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
43910 - ldops->refcount--;
43911 + atomic_dec(&ldops->refcount);
43912 module_put(ldops->owner);
43913 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
43914 }
43915 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
43916 index b7ff59d..7c6105e 100644
43917 --- a/drivers/tty/tty_port.c
43918 +++ b/drivers/tty/tty_port.c
43919 @@ -218,7 +218,7 @@ void tty_port_hangup(struct tty_port *port)
43920 unsigned long flags;
43921
43922 spin_lock_irqsave(&port->lock, flags);
43923 - port->count = 0;
43924 + atomic_set(&port->count, 0);
43925 port->flags &= ~ASYNC_NORMAL_ACTIVE;
43926 if (port->tty) {
43927 set_bit(TTY_IO_ERROR, &port->tty->flags);
43928 @@ -344,7 +344,7 @@ int tty_port_block_til_ready(struct tty_port *port,
43929 /* The port lock protects the port counts */
43930 spin_lock_irqsave(&port->lock, flags);
43931 if (!tty_hung_up_p(filp))
43932 - port->count--;
43933 + atomic_dec(&port->count);
43934 port->blocked_open++;
43935 spin_unlock_irqrestore(&port->lock, flags);
43936
43937 @@ -386,7 +386,7 @@ int tty_port_block_til_ready(struct tty_port *port,
43938 we must not mess that up further */
43939 spin_lock_irqsave(&port->lock, flags);
43940 if (!tty_hung_up_p(filp))
43941 - port->count++;
43942 + atomic_inc(&port->count);
43943 port->blocked_open--;
43944 if (retval == 0)
43945 port->flags |= ASYNC_NORMAL_ACTIVE;
43946 @@ -406,19 +406,19 @@ int tty_port_close_start(struct tty_port *port,
43947 return 0;
43948 }
43949
43950 - if (tty->count == 1 && port->count != 1) {
43951 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
43952 printk(KERN_WARNING
43953 "tty_port_close_start: tty->count = 1 port count = %d.\n",
43954 - port->count);
43955 - port->count = 1;
43956 + atomic_read(&port->count));
43957 + atomic_set(&port->count, 1);
43958 }
43959 - if (--port->count < 0) {
43960 + if (atomic_dec_return(&port->count) < 0) {
43961 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
43962 - port->count);
43963 - port->count = 0;
43964 + atomic_read(&port->count));
43965 + atomic_set(&port->count, 0);
43966 }
43967
43968 - if (port->count) {
43969 + if (atomic_read(&port->count)) {
43970 spin_unlock_irqrestore(&port->lock, flags);
43971 if (port->ops->drop)
43972 port->ops->drop(port);
43973 @@ -516,7 +516,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
43974 {
43975 spin_lock_irq(&port->lock);
43976 if (!tty_hung_up_p(filp))
43977 - ++port->count;
43978 + atomic_inc(&port->count);
43979 spin_unlock_irq(&port->lock);
43980 tty_port_tty_set(port, tty);
43981
43982 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
43983 index a9af1b9a..1e08e7f 100644
43984 --- a/drivers/tty/vt/keyboard.c
43985 +++ b/drivers/tty/vt/keyboard.c
43986 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
43987 kbd->kbdmode == VC_OFF) &&
43988 value != KVAL(K_SAK))
43989 return; /* SAK is allowed even in raw mode */
43990 +
43991 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
43992 + {
43993 + void *func = fn_handler[value];
43994 + if (func == fn_show_state || func == fn_show_ptregs ||
43995 + func == fn_show_mem)
43996 + return;
43997 + }
43998 +#endif
43999 +
44000 fn_handler[value](vc);
44001 }
44002
44003 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44004 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
44005 return -EFAULT;
44006
44007 - if (!capable(CAP_SYS_TTY_CONFIG))
44008 - perm = 0;
44009 -
44010 switch (cmd) {
44011 case KDGKBENT:
44012 /* Ensure another thread doesn't free it under us */
44013 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44014 spin_unlock_irqrestore(&kbd_event_lock, flags);
44015 return put_user(val, &user_kbe->kb_value);
44016 case KDSKBENT:
44017 + if (!capable(CAP_SYS_TTY_CONFIG))
44018 + perm = 0;
44019 +
44020 if (!perm)
44021 return -EPERM;
44022 if (!i && v == K_NOSUCHMAP) {
44023 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44024 int i, j, k;
44025 int ret;
44026
44027 - if (!capable(CAP_SYS_TTY_CONFIG))
44028 - perm = 0;
44029 -
44030 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
44031 if (!kbs) {
44032 ret = -ENOMEM;
44033 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44034 kfree(kbs);
44035 return ((p && *p) ? -EOVERFLOW : 0);
44036 case KDSKBSENT:
44037 + if (!capable(CAP_SYS_TTY_CONFIG))
44038 + perm = 0;
44039 +
44040 if (!perm) {
44041 ret = -EPERM;
44042 goto reterr;
44043 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
44044 index c8b9262..7e824e6 100644
44045 --- a/drivers/uio/uio.c
44046 +++ b/drivers/uio/uio.c
44047 @@ -25,6 +25,7 @@
44048 #include <linux/kobject.h>
44049 #include <linux/cdev.h>
44050 #include <linux/uio_driver.h>
44051 +#include <asm/local.h>
44052
44053 #define UIO_MAX_DEVICES (1U << MINORBITS)
44054
44055 @@ -32,10 +33,10 @@ struct uio_device {
44056 struct module *owner;
44057 struct device *dev;
44058 int minor;
44059 - atomic_t event;
44060 + atomic_unchecked_t event;
44061 struct fasync_struct *async_queue;
44062 wait_queue_head_t wait;
44063 - int vma_count;
44064 + local_t vma_count;
44065 struct uio_info *info;
44066 struct kobject *map_dir;
44067 struct kobject *portio_dir;
44068 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
44069 struct device_attribute *attr, char *buf)
44070 {
44071 struct uio_device *idev = dev_get_drvdata(dev);
44072 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
44073 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
44074 }
44075
44076 static struct device_attribute uio_class_attributes[] = {
44077 @@ -397,7 +398,7 @@ void uio_event_notify(struct uio_info *info)
44078 {
44079 struct uio_device *idev = info->uio_dev;
44080
44081 - atomic_inc(&idev->event);
44082 + atomic_inc_unchecked(&idev->event);
44083 wake_up_interruptible(&idev->wait);
44084 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
44085 }
44086 @@ -450,7 +451,7 @@ static int uio_open(struct inode *inode, struct file *filep)
44087 }
44088
44089 listener->dev = idev;
44090 - listener->event_count = atomic_read(&idev->event);
44091 + listener->event_count = atomic_read_unchecked(&idev->event);
44092 filep->private_data = listener;
44093
44094 if (idev->info->open) {
44095 @@ -501,7 +502,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
44096 return -EIO;
44097
44098 poll_wait(filep, &idev->wait, wait);
44099 - if (listener->event_count != atomic_read(&idev->event))
44100 + if (listener->event_count != atomic_read_unchecked(&idev->event))
44101 return POLLIN | POLLRDNORM;
44102 return 0;
44103 }
44104 @@ -526,7 +527,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
44105 do {
44106 set_current_state(TASK_INTERRUPTIBLE);
44107
44108 - event_count = atomic_read(&idev->event);
44109 + event_count = atomic_read_unchecked(&idev->event);
44110 if (event_count != listener->event_count) {
44111 if (copy_to_user(buf, &event_count, count))
44112 retval = -EFAULT;
44113 @@ -595,13 +596,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
44114 static void uio_vma_open(struct vm_area_struct *vma)
44115 {
44116 struct uio_device *idev = vma->vm_private_data;
44117 - idev->vma_count++;
44118 + local_inc(&idev->vma_count);
44119 }
44120
44121 static void uio_vma_close(struct vm_area_struct *vma)
44122 {
44123 struct uio_device *idev = vma->vm_private_data;
44124 - idev->vma_count--;
44125 + local_dec(&idev->vma_count);
44126 }
44127
44128 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
44129 @@ -808,7 +809,7 @@ int __uio_register_device(struct module *owner,
44130 idev->owner = owner;
44131 idev->info = info;
44132 init_waitqueue_head(&idev->wait);
44133 - atomic_set(&idev->event, 0);
44134 + atomic_set_unchecked(&idev->event, 0);
44135
44136 ret = uio_get_minor(idev);
44137 if (ret)
44138 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
44139 index b7eb86a..c00402f 100644
44140 --- a/drivers/usb/atm/cxacru.c
44141 +++ b/drivers/usb/atm/cxacru.c
44142 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
44143 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
44144 if (ret < 2)
44145 return -EINVAL;
44146 - if (index < 0 || index > 0x7f)
44147 + if (index > 0x7f)
44148 return -EINVAL;
44149 pos += tmp;
44150
44151 @@ -686,7 +686,8 @@ static int cxacru_cm_get_array(struct cxacru_data *instance, enum cxacru_cm_requ
44152 {
44153 int ret, len;
44154 __le32 *buf;
44155 - int offb, offd;
44156 + int offb;
44157 + unsigned int offd;
44158 const int stride = CMD_PACKET_SIZE / (4 * 2) - 1;
44159 int buflen = ((size - 1) / stride + 1 + size * 2) * 4;
44160
44161 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
44162 index 35f10bf..6a38a0b 100644
44163 --- a/drivers/usb/atm/usbatm.c
44164 +++ b/drivers/usb/atm/usbatm.c
44165 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44166 if (printk_ratelimit())
44167 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
44168 __func__, vpi, vci);
44169 - atomic_inc(&vcc->stats->rx_err);
44170 + atomic_inc_unchecked(&vcc->stats->rx_err);
44171 return;
44172 }
44173
44174 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44175 if (length > ATM_MAX_AAL5_PDU) {
44176 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
44177 __func__, length, vcc);
44178 - atomic_inc(&vcc->stats->rx_err);
44179 + atomic_inc_unchecked(&vcc->stats->rx_err);
44180 goto out;
44181 }
44182
44183 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44184 if (sarb->len < pdu_length) {
44185 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
44186 __func__, pdu_length, sarb->len, vcc);
44187 - atomic_inc(&vcc->stats->rx_err);
44188 + atomic_inc_unchecked(&vcc->stats->rx_err);
44189 goto out;
44190 }
44191
44192 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
44193 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
44194 __func__, vcc);
44195 - atomic_inc(&vcc->stats->rx_err);
44196 + atomic_inc_unchecked(&vcc->stats->rx_err);
44197 goto out;
44198 }
44199
44200 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44201 if (printk_ratelimit())
44202 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
44203 __func__, length);
44204 - atomic_inc(&vcc->stats->rx_drop);
44205 + atomic_inc_unchecked(&vcc->stats->rx_drop);
44206 goto out;
44207 }
44208
44209 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44210
44211 vcc->push(vcc, skb);
44212
44213 - atomic_inc(&vcc->stats->rx);
44214 + atomic_inc_unchecked(&vcc->stats->rx);
44215 out:
44216 skb_trim(sarb, 0);
44217 }
44218 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
44219 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
44220
44221 usbatm_pop(vcc, skb);
44222 - atomic_inc(&vcc->stats->tx);
44223 + atomic_inc_unchecked(&vcc->stats->tx);
44224
44225 skb = skb_dequeue(&instance->sndqueue);
44226 }
44227 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
44228 if (!left--)
44229 return sprintf(page,
44230 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
44231 - atomic_read(&atm_dev->stats.aal5.tx),
44232 - atomic_read(&atm_dev->stats.aal5.tx_err),
44233 - atomic_read(&atm_dev->stats.aal5.rx),
44234 - atomic_read(&atm_dev->stats.aal5.rx_err),
44235 - atomic_read(&atm_dev->stats.aal5.rx_drop));
44236 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
44237 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
44238 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
44239 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
44240 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
44241
44242 if (!left--) {
44243 if (instance->disconnected)
44244 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
44245 index 2a3bbdf..91d72cf 100644
44246 --- a/drivers/usb/core/devices.c
44247 +++ b/drivers/usb/core/devices.c
44248 @@ -126,7 +126,7 @@ static const char format_endpt[] =
44249 * time it gets called.
44250 */
44251 static struct device_connect_event {
44252 - atomic_t count;
44253 + atomic_unchecked_t count;
44254 wait_queue_head_t wait;
44255 } device_event = {
44256 .count = ATOMIC_INIT(1),
44257 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
44258
44259 void usbfs_conn_disc_event(void)
44260 {
44261 - atomic_add(2, &device_event.count);
44262 + atomic_add_unchecked(2, &device_event.count);
44263 wake_up(&device_event.wait);
44264 }
44265
44266 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
44267
44268 poll_wait(file, &device_event.wait, wait);
44269
44270 - event_count = atomic_read(&device_event.count);
44271 + event_count = atomic_read_unchecked(&device_event.count);
44272 if (file->f_version != event_count) {
44273 file->f_version = event_count;
44274 return POLLIN | POLLRDNORM;
44275 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
44276 index f9ec44c..eb5779f 100644
44277 --- a/drivers/usb/core/hcd.c
44278 +++ b/drivers/usb/core/hcd.c
44279 @@ -1526,7 +1526,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44280 */
44281 usb_get_urb(urb);
44282 atomic_inc(&urb->use_count);
44283 - atomic_inc(&urb->dev->urbnum);
44284 + atomic_inc_unchecked(&urb->dev->urbnum);
44285 usbmon_urb_submit(&hcd->self, urb);
44286
44287 /* NOTE requirements on root-hub callers (usbfs and the hub
44288 @@ -1553,7 +1553,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44289 urb->hcpriv = NULL;
44290 INIT_LIST_HEAD(&urb->urb_list);
44291 atomic_dec(&urb->use_count);
44292 - atomic_dec(&urb->dev->urbnum);
44293 + atomic_dec_unchecked(&urb->dev->urbnum);
44294 if (atomic_read(&urb->reject))
44295 wake_up(&usb_kill_urb_queue);
44296 usb_put_urb(urb);
44297 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
44298 index 444d30e..f15c850 100644
44299 --- a/drivers/usb/core/message.c
44300 +++ b/drivers/usb/core/message.c
44301 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
44302 * method can wait for it to complete. Since you don't have a handle on the
44303 * URB used, you can't cancel the request.
44304 */
44305 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44306 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44307 __u8 requesttype, __u16 value, __u16 index, void *data,
44308 __u16 size, int timeout)
44309 {
44310 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
44311 index 3f81a3d..a3aa993 100644
44312 --- a/drivers/usb/core/sysfs.c
44313 +++ b/drivers/usb/core/sysfs.c
44314 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
44315 struct usb_device *udev;
44316
44317 udev = to_usb_device(dev);
44318 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
44319 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
44320 }
44321 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
44322
44323 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
44324 index f81b925..78d22ec 100644
44325 --- a/drivers/usb/core/usb.c
44326 +++ b/drivers/usb/core/usb.c
44327 @@ -388,7 +388,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
44328 set_dev_node(&dev->dev, dev_to_node(bus->controller));
44329 dev->state = USB_STATE_ATTACHED;
44330 dev->lpm_disable_count = 1;
44331 - atomic_set(&dev->urbnum, 0);
44332 + atomic_set_unchecked(&dev->urbnum, 0);
44333
44334 INIT_LIST_HEAD(&dev->ep0.urb_list);
44335 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
44336 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
44337 index 5e29dde..eca992f 100644
44338 --- a/drivers/usb/early/ehci-dbgp.c
44339 +++ b/drivers/usb/early/ehci-dbgp.c
44340 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
44341
44342 #ifdef CONFIG_KGDB
44343 static struct kgdb_io kgdbdbgp_io_ops;
44344 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
44345 +static struct kgdb_io kgdbdbgp_io_ops_console;
44346 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
44347 #else
44348 #define dbgp_kgdb_mode (0)
44349 #endif
44350 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
44351 .write_char = kgdbdbgp_write_char,
44352 };
44353
44354 +static struct kgdb_io kgdbdbgp_io_ops_console = {
44355 + .name = "kgdbdbgp",
44356 + .read_char = kgdbdbgp_read_char,
44357 + .write_char = kgdbdbgp_write_char,
44358 + .is_console = 1
44359 +};
44360 +
44361 static int kgdbdbgp_wait_time;
44362
44363 static int __init kgdbdbgp_parse_config(char *str)
44364 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
44365 ptr++;
44366 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
44367 }
44368 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44369 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44370 + if (early_dbgp_console.index != -1)
44371 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44372 + else
44373 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44374
44375 return 0;
44376 }
44377 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44378 index b369292..9f3ba40 100644
44379 --- a/drivers/usb/gadget/u_serial.c
44380 +++ b/drivers/usb/gadget/u_serial.c
44381 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44382 spin_lock_irq(&port->port_lock);
44383
44384 /* already open? Great. */
44385 - if (port->port.count) {
44386 + if (atomic_read(&port->port.count)) {
44387 status = 0;
44388 - port->port.count++;
44389 + atomic_inc(&port->port.count);
44390
44391 /* currently opening/closing? wait ... */
44392 } else if (port->openclose) {
44393 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44394 tty->driver_data = port;
44395 port->port.tty = tty;
44396
44397 - port->port.count = 1;
44398 + atomic_set(&port->port.count, 1);
44399 port->openclose = false;
44400
44401 /* if connected, start the I/O stream */
44402 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44403
44404 spin_lock_irq(&port->port_lock);
44405
44406 - if (port->port.count != 1) {
44407 - if (port->port.count == 0)
44408 + if (atomic_read(&port->port.count) != 1) {
44409 + if (atomic_read(&port->port.count) == 0)
44410 WARN_ON(1);
44411 else
44412 - --port->port.count;
44413 + atomic_dec(&port->port.count);
44414 goto exit;
44415 }
44416
44417 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44418 * and sleep if necessary
44419 */
44420 port->openclose = true;
44421 - port->port.count = 0;
44422 + atomic_set(&port->port.count, 0);
44423
44424 gser = port->port_usb;
44425 if (gser && gser->disconnect)
44426 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
44427 int cond;
44428
44429 spin_lock_irq(&port->port_lock);
44430 - cond = (port->port.count == 0) && !port->openclose;
44431 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44432 spin_unlock_irq(&port->port_lock);
44433 return cond;
44434 }
44435 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44436 /* if it's already open, start I/O ... and notify the serial
44437 * protocol about open/close status (connect/disconnect).
44438 */
44439 - if (port->port.count) {
44440 + if (atomic_read(&port->port.count)) {
44441 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44442 gs_start_io(port);
44443 if (gser->connect)
44444 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
44445
44446 port->port_usb = NULL;
44447 gser->ioport = NULL;
44448 - if (port->port.count > 0 || port->openclose) {
44449 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44450 wake_up_interruptible(&port->drain_wait);
44451 if (port->port.tty)
44452 tty_hangup(port->port.tty);
44453 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
44454
44455 /* finally, free any unused/unusable I/O buffers */
44456 spin_lock_irqsave(&port->port_lock, flags);
44457 - if (port->port.count == 0 && !port->openclose)
44458 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44459 gs_buf_free(&port->port_write_buf);
44460 gs_free_requests(gser->out, &port->read_pool, NULL);
44461 gs_free_requests(gser->out, &port->read_queue, NULL);
44462 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44463 index 5f3bcd3..bfca43f 100644
44464 --- a/drivers/usb/serial/console.c
44465 +++ b/drivers/usb/serial/console.c
44466 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44467
44468 info->port = port;
44469
44470 - ++port->port.count;
44471 + atomic_inc(&port->port.count);
44472 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44473 if (serial->type->set_termios) {
44474 /*
44475 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44476 }
44477 /* Now that any required fake tty operations are completed restore
44478 * the tty port count */
44479 - --port->port.count;
44480 + atomic_dec(&port->port.count);
44481 /* The console is special in terms of closing the device so
44482 * indicate this port is now acting as a system console. */
44483 port->port.console = 1;
44484 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44485 free_tty:
44486 kfree(tty);
44487 reset_open_count:
44488 - port->port.count = 0;
44489 + atomic_set(&port->port.count, 0);
44490 usb_autopm_put_interface(serial->interface);
44491 error_get_interface:
44492 usb_serial_put(serial);
44493 diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
44494 index 6c3586a..a94e621 100644
44495 --- a/drivers/usb/storage/realtek_cr.c
44496 +++ b/drivers/usb/storage/realtek_cr.c
44497 @@ -429,7 +429,7 @@ static int rts51x_read_status(struct us_data *us,
44498
44499 buf = kmalloc(len, GFP_NOIO);
44500 if (buf == NULL)
44501 - return USB_STOR_TRANSPORT_ERROR;
44502 + return -ENOMEM;
44503
44504 US_DEBUGP("%s, lun = %d\n", __func__, lun);
44505
44506 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
44507 index 75f70f0..d467e1a 100644
44508 --- a/drivers/usb/storage/usb.h
44509 +++ b/drivers/usb/storage/usb.h
44510 @@ -63,7 +63,7 @@ struct us_unusual_dev {
44511 __u8 useProtocol;
44512 __u8 useTransport;
44513 int (*initFunction)(struct us_data *);
44514 -};
44515 +} __do_const;
44516
44517
44518 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
44519 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
44520 index d6bea3e..60b250e 100644
44521 --- a/drivers/usb/wusbcore/wa-hc.h
44522 +++ b/drivers/usb/wusbcore/wa-hc.h
44523 @@ -192,7 +192,7 @@ struct wahc {
44524 struct list_head xfer_delayed_list;
44525 spinlock_t xfer_list_lock;
44526 struct work_struct xfer_work;
44527 - atomic_t xfer_id_count;
44528 + atomic_unchecked_t xfer_id_count;
44529 };
44530
44531
44532 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
44533 INIT_LIST_HEAD(&wa->xfer_delayed_list);
44534 spin_lock_init(&wa->xfer_list_lock);
44535 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
44536 - atomic_set(&wa->xfer_id_count, 1);
44537 + atomic_set_unchecked(&wa->xfer_id_count, 1);
44538 }
44539
44540 /**
44541 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
44542 index 6ef94bc..1b41265 100644
44543 --- a/drivers/usb/wusbcore/wa-xfer.c
44544 +++ b/drivers/usb/wusbcore/wa-xfer.c
44545 @@ -296,7 +296,7 @@ out:
44546 */
44547 static void wa_xfer_id_init(struct wa_xfer *xfer)
44548 {
44549 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
44550 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
44551 }
44552
44553 /*
44554 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
44555 index 8c55011..eed4ae1a 100644
44556 --- a/drivers/video/aty/aty128fb.c
44557 +++ b/drivers/video/aty/aty128fb.c
44558 @@ -149,7 +149,7 @@ enum {
44559 };
44560
44561 /* Must match above enum */
44562 -static char * const r128_family[] = {
44563 +static const char * const r128_family[] = {
44564 "AGP",
44565 "PCI",
44566 "PRO AGP",
44567 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
44568 index 4f27fdc..d3537e6 100644
44569 --- a/drivers/video/aty/atyfb_base.c
44570 +++ b/drivers/video/aty/atyfb_base.c
44571 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
44572 par->accel_flags = var->accel_flags; /* hack */
44573
44574 if (var->accel_flags) {
44575 - info->fbops->fb_sync = atyfb_sync;
44576 + pax_open_kernel();
44577 + *(void **)&info->fbops->fb_sync = atyfb_sync;
44578 + pax_close_kernel();
44579 info->flags &= ~FBINFO_HWACCEL_DISABLED;
44580 } else {
44581 - info->fbops->fb_sync = NULL;
44582 + pax_open_kernel();
44583 + *(void **)&info->fbops->fb_sync = NULL;
44584 + pax_close_kernel();
44585 info->flags |= FBINFO_HWACCEL_DISABLED;
44586 }
44587
44588 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
44589 index 95ec042..e6affdd 100644
44590 --- a/drivers/video/aty/mach64_cursor.c
44591 +++ b/drivers/video/aty/mach64_cursor.c
44592 @@ -7,6 +7,7 @@
44593 #include <linux/string.h>
44594
44595 #include <asm/io.h>
44596 +#include <asm/pgtable.h>
44597
44598 #ifdef __sparc__
44599 #include <asm/fbio.h>
44600 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
44601 info->sprite.buf_align = 16; /* and 64 lines tall. */
44602 info->sprite.flags = FB_PIXMAP_IO;
44603
44604 - info->fbops->fb_cursor = atyfb_cursor;
44605 + pax_open_kernel();
44606 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
44607 + pax_close_kernel();
44608
44609 return 0;
44610 }
44611 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
44612 index 6c5ed6b..b727c88 100644
44613 --- a/drivers/video/backlight/kb3886_bl.c
44614 +++ b/drivers/video/backlight/kb3886_bl.c
44615 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
44616 static unsigned long kb3886bl_flags;
44617 #define KB3886BL_SUSPENDED 0x01
44618
44619 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
44620 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
44621 {
44622 .ident = "Sahara Touch-iT",
44623 .matches = {
44624 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
44625 index 900aa4e..6d49418 100644
44626 --- a/drivers/video/fb_defio.c
44627 +++ b/drivers/video/fb_defio.c
44628 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
44629
44630 BUG_ON(!fbdefio);
44631 mutex_init(&fbdefio->lock);
44632 - info->fbops->fb_mmap = fb_deferred_io_mmap;
44633 + pax_open_kernel();
44634 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
44635 + pax_close_kernel();
44636 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
44637 INIT_LIST_HEAD(&fbdefio->pagelist);
44638 if (fbdefio->delay == 0) /* set a default of 1 s */
44639 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
44640 page->mapping = NULL;
44641 }
44642
44643 - info->fbops->fb_mmap = NULL;
44644 + *(void **)&info->fbops->fb_mmap = NULL;
44645 mutex_destroy(&fbdefio->lock);
44646 }
44647 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
44648 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
44649 index 5c3960d..15cf8fc 100644
44650 --- a/drivers/video/fbcmap.c
44651 +++ b/drivers/video/fbcmap.c
44652 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
44653 rc = -ENODEV;
44654 goto out;
44655 }
44656 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
44657 - !info->fbops->fb_setcmap)) {
44658 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
44659 rc = -EINVAL;
44660 goto out1;
44661 }
44662 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
44663 index 86291dc..7cc5962 100644
44664 --- a/drivers/video/fbmem.c
44665 +++ b/drivers/video/fbmem.c
44666 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44667 image->dx += image->width + 8;
44668 }
44669 } else if (rotate == FB_ROTATE_UD) {
44670 - for (x = 0; x < num && image->dx >= 0; x++) {
44671 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
44672 info->fbops->fb_imageblit(info, image);
44673 image->dx -= image->width + 8;
44674 }
44675 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
44676 image->dy += image->height + 8;
44677 }
44678 } else if (rotate == FB_ROTATE_CCW) {
44679 - for (x = 0; x < num && image->dy >= 0; x++) {
44680 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
44681 info->fbops->fb_imageblit(info, image);
44682 image->dy -= image->height + 8;
44683 }
44684 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
44685 return -EFAULT;
44686 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
44687 return -EINVAL;
44688 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
44689 + if (con2fb.framebuffer >= FB_MAX)
44690 return -EINVAL;
44691 if (!registered_fb[con2fb.framebuffer])
44692 request_module("fb%d", con2fb.framebuffer);
44693 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
44694 index 7672d2e..b56437f 100644
44695 --- a/drivers/video/i810/i810_accel.c
44696 +++ b/drivers/video/i810/i810_accel.c
44697 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
44698 }
44699 }
44700 printk("ringbuffer lockup!!!\n");
44701 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
44702 i810_report_error(mmio);
44703 par->dev_flags |= LOCKUP;
44704 info->pixmap.scan_align = 1;
44705 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
44706 index 3c14e43..eafa544 100644
44707 --- a/drivers/video/logo/logo_linux_clut224.ppm
44708 +++ b/drivers/video/logo/logo_linux_clut224.ppm
44709 @@ -1,1604 +1,1123 @@
44710 P3
44711 -# Standard 224-color Linux logo
44712 80 80
44713 255
44714 - 0 0 0 0 0 0 0 0 0 0 0 0
44715 - 0 0 0 0 0 0 0 0 0 0 0 0
44716 - 0 0 0 0 0 0 0 0 0 0 0 0
44717 - 0 0 0 0 0 0 0 0 0 0 0 0
44718 - 0 0 0 0 0 0 0 0 0 0 0 0
44719 - 0 0 0 0 0 0 0 0 0 0 0 0
44720 - 0 0 0 0 0 0 0 0 0 0 0 0
44721 - 0 0 0 0 0 0 0 0 0 0 0 0
44722 - 0 0 0 0 0 0 0 0 0 0 0 0
44723 - 6 6 6 6 6 6 10 10 10 10 10 10
44724 - 10 10 10 6 6 6 6 6 6 6 6 6
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 0 0 0 0 0 0
44732 - 0 0 0 0 0 0 0 0 0 0 0 0
44733 - 0 0 0 0 0 0 0 0 0 0 0 0
44734 - 0 0 0 0 0 0 0 0 0 0 0 0
44735 - 0 0 0 0 0 0 0 0 0 0 0 0
44736 - 0 0 0 0 0 0 0 0 0 0 0 0
44737 - 0 0 0 0 0 0 0 0 0 0 0 0
44738 - 0 0 0 0 0 0 0 0 0 0 0 0
44739 - 0 0 0 0 0 0 0 0 0 0 0 0
44740 - 0 0 0 0 0 0 0 0 0 0 0 0
44741 - 0 0 0 0 0 0 0 0 0 0 0 0
44742 - 0 0 0 6 6 6 10 10 10 14 14 14
44743 - 22 22 22 26 26 26 30 30 30 34 34 34
44744 - 30 30 30 30 30 30 26 26 26 18 18 18
44745 - 14 14 14 10 10 10 6 6 6 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 0 0 0 0 0 0 0 0 0
44752 - 0 0 0 0 0 0 0 0 0 0 0 0
44753 - 0 0 0 0 0 0 0 0 0 0 0 0
44754 - 0 0 0 0 0 0 0 0 0 0 0 0
44755 - 0 0 0 0 0 1 0 0 1 0 0 0
44756 - 0 0 0 0 0 0 0 0 0 0 0 0
44757 - 0 0 0 0 0 0 0 0 0 0 0 0
44758 - 0 0 0 0 0 0 0 0 0 0 0 0
44759 - 0 0 0 0 0 0 0 0 0 0 0 0
44760 - 0 0 0 0 0 0 0 0 0 0 0 0
44761 - 0 0 0 0 0 0 0 0 0 0 0 0
44762 - 6 6 6 14 14 14 26 26 26 42 42 42
44763 - 54 54 54 66 66 66 78 78 78 78 78 78
44764 - 78 78 78 74 74 74 66 66 66 54 54 54
44765 - 42 42 42 26 26 26 18 18 18 10 10 10
44766 - 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
44772 - 0 0 0 0 0 0 0 0 0 0 0 0
44773 - 0 0 0 0 0 0 0 0 0 0 0 0
44774 - 0 0 0 0 0 0 0 0 0 0 0 0
44775 - 0 0 1 0 0 0 0 0 0 0 0 0
44776 - 0 0 0 0 0 0 0 0 0 0 0 0
44777 - 0 0 0 0 0 0 0 0 0 0 0 0
44778 - 0 0 0 0 0 0 0 0 0 0 0 0
44779 - 0 0 0 0 0 0 0 0 0 0 0 0
44780 - 0 0 0 0 0 0 0 0 0 0 0 0
44781 - 0 0 0 0 0 0 0 0 0 10 10 10
44782 - 22 22 22 42 42 42 66 66 66 86 86 86
44783 - 66 66 66 38 38 38 38 38 38 22 22 22
44784 - 26 26 26 34 34 34 54 54 54 66 66 66
44785 - 86 86 86 70 70 70 46 46 46 26 26 26
44786 - 14 14 14 6 6 6 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 0 0 0
44791 - 0 0 0 0 0 0 0 0 0 0 0 0
44792 - 0 0 0 0 0 0 0 0 0 0 0 0
44793 - 0 0 0 0 0 0 0 0 0 0 0 0
44794 - 0 0 0 0 0 0 0 0 0 0 0 0
44795 - 0 0 1 0 0 1 0 0 1 0 0 0
44796 - 0 0 0 0 0 0 0 0 0 0 0 0
44797 - 0 0 0 0 0 0 0 0 0 0 0 0
44798 - 0 0 0 0 0 0 0 0 0 0 0 0
44799 - 0 0 0 0 0 0 0 0 0 0 0 0
44800 - 0 0 0 0 0 0 0 0 0 0 0 0
44801 - 0 0 0 0 0 0 10 10 10 26 26 26
44802 - 50 50 50 82 82 82 58 58 58 6 6 6
44803 - 2 2 6 2 2 6 2 2 6 2 2 6
44804 - 2 2 6 2 2 6 2 2 6 2 2 6
44805 - 6 6 6 54 54 54 86 86 86 66 66 66
44806 - 38 38 38 18 18 18 6 6 6 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 0 0 0
44811 - 0 0 0 0 0 0 0 0 0 0 0 0
44812 - 0 0 0 0 0 0 0 0 0 0 0 0
44813 - 0 0 0 0 0 0 0 0 0 0 0 0
44814 - 0 0 0 0 0 0 0 0 0 0 0 0
44815 - 0 0 0 0 0 0 0 0 0 0 0 0
44816 - 0 0 0 0 0 0 0 0 0 0 0 0
44817 - 0 0 0 0 0 0 0 0 0 0 0 0
44818 - 0 0 0 0 0 0 0 0 0 0 0 0
44819 - 0 0 0 0 0 0 0 0 0 0 0 0
44820 - 0 0 0 0 0 0 0 0 0 0 0 0
44821 - 0 0 0 6 6 6 22 22 22 50 50 50
44822 - 78 78 78 34 34 34 2 2 6 2 2 6
44823 - 2 2 6 2 2 6 2 2 6 2 2 6
44824 - 2 2 6 2 2 6 2 2 6 2 2 6
44825 - 2 2 6 2 2 6 6 6 6 70 70 70
44826 - 78 78 78 46 46 46 22 22 22 6 6 6
44827 - 0 0 0 0 0 0 0 0 0 0 0 0
44828 - 0 0 0 0 0 0 0 0 0 0 0 0
44829 - 0 0 0 0 0 0 0 0 0 0 0 0
44830 - 0 0 0 0 0 0 0 0 0 0 0 0
44831 - 0 0 0 0 0 0 0 0 0 0 0 0
44832 - 0 0 0 0 0 0 0 0 0 0 0 0
44833 - 0 0 0 0 0 0 0 0 0 0 0 0
44834 - 0 0 0 0 0 0 0 0 0 0 0 0
44835 - 0 0 1 0 0 1 0 0 1 0 0 0
44836 - 0 0 0 0 0 0 0 0 0 0 0 0
44837 - 0 0 0 0 0 0 0 0 0 0 0 0
44838 - 0 0 0 0 0 0 0 0 0 0 0 0
44839 - 0 0 0 0 0 0 0 0 0 0 0 0
44840 - 0 0 0 0 0 0 0 0 0 0 0 0
44841 - 6 6 6 18 18 18 42 42 42 82 82 82
44842 - 26 26 26 2 2 6 2 2 6 2 2 6
44843 - 2 2 6 2 2 6 2 2 6 2 2 6
44844 - 2 2 6 2 2 6 2 2 6 14 14 14
44845 - 46 46 46 34 34 34 6 6 6 2 2 6
44846 - 42 42 42 78 78 78 42 42 42 18 18 18
44847 - 6 6 6 0 0 0 0 0 0 0 0 0
44848 - 0 0 0 0 0 0 0 0 0 0 0 0
44849 - 0 0 0 0 0 0 0 0 0 0 0 0
44850 - 0 0 0 0 0 0 0 0 0 0 0 0
44851 - 0 0 0 0 0 0 0 0 0 0 0 0
44852 - 0 0 0 0 0 0 0 0 0 0 0 0
44853 - 0 0 0 0 0 0 0 0 0 0 0 0
44854 - 0 0 0 0 0 0 0 0 0 0 0 0
44855 - 0 0 1 0 0 0 0 0 1 0 0 0
44856 - 0 0 0 0 0 0 0 0 0 0 0 0
44857 - 0 0 0 0 0 0 0 0 0 0 0 0
44858 - 0 0 0 0 0 0 0 0 0 0 0 0
44859 - 0 0 0 0 0 0 0 0 0 0 0 0
44860 - 0 0 0 0 0 0 0 0 0 0 0 0
44861 - 10 10 10 30 30 30 66 66 66 58 58 58
44862 - 2 2 6 2 2 6 2 2 6 2 2 6
44863 - 2 2 6 2 2 6 2 2 6 2 2 6
44864 - 2 2 6 2 2 6 2 2 6 26 26 26
44865 - 86 86 86 101 101 101 46 46 46 10 10 10
44866 - 2 2 6 58 58 58 70 70 70 34 34 34
44867 - 10 10 10 0 0 0 0 0 0 0 0 0
44868 - 0 0 0 0 0 0 0 0 0 0 0 0
44869 - 0 0 0 0 0 0 0 0 0 0 0 0
44870 - 0 0 0 0 0 0 0 0 0 0 0 0
44871 - 0 0 0 0 0 0 0 0 0 0 0 0
44872 - 0 0 0 0 0 0 0 0 0 0 0 0
44873 - 0 0 0 0 0 0 0 0 0 0 0 0
44874 - 0 0 0 0 0 0 0 0 0 0 0 0
44875 - 0 0 1 0 0 1 0 0 1 0 0 0
44876 - 0 0 0 0 0 0 0 0 0 0 0 0
44877 - 0 0 0 0 0 0 0 0 0 0 0 0
44878 - 0 0 0 0 0 0 0 0 0 0 0 0
44879 - 0 0 0 0 0 0 0 0 0 0 0 0
44880 - 0 0 0 0 0 0 0 0 0 0 0 0
44881 - 14 14 14 42 42 42 86 86 86 10 10 10
44882 - 2 2 6 2 2 6 2 2 6 2 2 6
44883 - 2 2 6 2 2 6 2 2 6 2 2 6
44884 - 2 2 6 2 2 6 2 2 6 30 30 30
44885 - 94 94 94 94 94 94 58 58 58 26 26 26
44886 - 2 2 6 6 6 6 78 78 78 54 54 54
44887 - 22 22 22 6 6 6 0 0 0 0 0 0
44888 - 0 0 0 0 0 0 0 0 0 0 0 0
44889 - 0 0 0 0 0 0 0 0 0 0 0 0
44890 - 0 0 0 0 0 0 0 0 0 0 0 0
44891 - 0 0 0 0 0 0 0 0 0 0 0 0
44892 - 0 0 0 0 0 0 0 0 0 0 0 0
44893 - 0 0 0 0 0 0 0 0 0 0 0 0
44894 - 0 0 0 0 0 0 0 0 0 0 0 0
44895 - 0 0 0 0 0 0 0 0 0 0 0 0
44896 - 0 0 0 0 0 0 0 0 0 0 0 0
44897 - 0 0 0 0 0 0 0 0 0 0 0 0
44898 - 0 0 0 0 0 0 0 0 0 0 0 0
44899 - 0 0 0 0 0 0 0 0 0 0 0 0
44900 - 0 0 0 0 0 0 0 0 0 6 6 6
44901 - 22 22 22 62 62 62 62 62 62 2 2 6
44902 - 2 2 6 2 2 6 2 2 6 2 2 6
44903 - 2 2 6 2 2 6 2 2 6 2 2 6
44904 - 2 2 6 2 2 6 2 2 6 26 26 26
44905 - 54 54 54 38 38 38 18 18 18 10 10 10
44906 - 2 2 6 2 2 6 34 34 34 82 82 82
44907 - 38 38 38 14 14 14 0 0 0 0 0 0
44908 - 0 0 0 0 0 0 0 0 0 0 0 0
44909 - 0 0 0 0 0 0 0 0 0 0 0 0
44910 - 0 0 0 0 0 0 0 0 0 0 0 0
44911 - 0 0 0 0 0 0 0 0 0 0 0 0
44912 - 0 0 0 0 0 0 0 0 0 0 0 0
44913 - 0 0 0 0 0 0 0 0 0 0 0 0
44914 - 0 0 0 0 0 0 0 0 0 0 0 0
44915 - 0 0 0 0 0 1 0 0 1 0 0 0
44916 - 0 0 0 0 0 0 0 0 0 0 0 0
44917 - 0 0 0 0 0 0 0 0 0 0 0 0
44918 - 0 0 0 0 0 0 0 0 0 0 0 0
44919 - 0 0 0 0 0 0 0 0 0 0 0 0
44920 - 0 0 0 0 0 0 0 0 0 6 6 6
44921 - 30 30 30 78 78 78 30 30 30 2 2 6
44922 - 2 2 6 2 2 6 2 2 6 2 2 6
44923 - 2 2 6 2 2 6 2 2 6 2 2 6
44924 - 2 2 6 2 2 6 2 2 6 10 10 10
44925 - 10 10 10 2 2 6 2 2 6 2 2 6
44926 - 2 2 6 2 2 6 2 2 6 78 78 78
44927 - 50 50 50 18 18 18 6 6 6 0 0 0
44928 - 0 0 0 0 0 0 0 0 0 0 0 0
44929 - 0 0 0 0 0 0 0 0 0 0 0 0
44930 - 0 0 0 0 0 0 0 0 0 0 0 0
44931 - 0 0 0 0 0 0 0 0 0 0 0 0
44932 - 0 0 0 0 0 0 0 0 0 0 0 0
44933 - 0 0 0 0 0 0 0 0 0 0 0 0
44934 - 0 0 0 0 0 0 0 0 0 0 0 0
44935 - 0 0 1 0 0 0 0 0 0 0 0 0
44936 - 0 0 0 0 0 0 0 0 0 0 0 0
44937 - 0 0 0 0 0 0 0 0 0 0 0 0
44938 - 0 0 0 0 0 0 0 0 0 0 0 0
44939 - 0 0 0 0 0 0 0 0 0 0 0 0
44940 - 0 0 0 0 0 0 0 0 0 10 10 10
44941 - 38 38 38 86 86 86 14 14 14 2 2 6
44942 - 2 2 6 2 2 6 2 2 6 2 2 6
44943 - 2 2 6 2 2 6 2 2 6 2 2 6
44944 - 2 2 6 2 2 6 2 2 6 2 2 6
44945 - 2 2 6 2 2 6 2 2 6 2 2 6
44946 - 2 2 6 2 2 6 2 2 6 54 54 54
44947 - 66 66 66 26 26 26 6 6 6 0 0 0
44948 - 0 0 0 0 0 0 0 0 0 0 0 0
44949 - 0 0 0 0 0 0 0 0 0 0 0 0
44950 - 0 0 0 0 0 0 0 0 0 0 0 0
44951 - 0 0 0 0 0 0 0 0 0 0 0 0
44952 - 0 0 0 0 0 0 0 0 0 0 0 0
44953 - 0 0 0 0 0 0 0 0 0 0 0 0
44954 - 0 0 0 0 0 0 0 0 0 0 0 0
44955 - 0 0 0 0 0 1 0 0 1 0 0 0
44956 - 0 0 0 0 0 0 0 0 0 0 0 0
44957 - 0 0 0 0 0 0 0 0 0 0 0 0
44958 - 0 0 0 0 0 0 0 0 0 0 0 0
44959 - 0 0 0 0 0 0 0 0 0 0 0 0
44960 - 0 0 0 0 0 0 0 0 0 14 14 14
44961 - 42 42 42 82 82 82 2 2 6 2 2 6
44962 - 2 2 6 6 6 6 10 10 10 2 2 6
44963 - 2 2 6 2 2 6 2 2 6 2 2 6
44964 - 2 2 6 2 2 6 2 2 6 6 6 6
44965 - 14 14 14 10 10 10 2 2 6 2 2 6
44966 - 2 2 6 2 2 6 2 2 6 18 18 18
44967 - 82 82 82 34 34 34 10 10 10 0 0 0
44968 - 0 0 0 0 0 0 0 0 0 0 0 0
44969 - 0 0 0 0 0 0 0 0 0 0 0 0
44970 - 0 0 0 0 0 0 0 0 0 0 0 0
44971 - 0 0 0 0 0 0 0 0 0 0 0 0
44972 - 0 0 0 0 0 0 0 0 0 0 0 0
44973 - 0 0 0 0 0 0 0 0 0 0 0 0
44974 - 0 0 0 0 0 0 0 0 0 0 0 0
44975 - 0 0 1 0 0 0 0 0 0 0 0 0
44976 - 0 0 0 0 0 0 0 0 0 0 0 0
44977 - 0 0 0 0 0 0 0 0 0 0 0 0
44978 - 0 0 0 0 0 0 0 0 0 0 0 0
44979 - 0 0 0 0 0 0 0 0 0 0 0 0
44980 - 0 0 0 0 0 0 0 0 0 14 14 14
44981 - 46 46 46 86 86 86 2 2 6 2 2 6
44982 - 6 6 6 6 6 6 22 22 22 34 34 34
44983 - 6 6 6 2 2 6 2 2 6 2 2 6
44984 - 2 2 6 2 2 6 18 18 18 34 34 34
44985 - 10 10 10 50 50 50 22 22 22 2 2 6
44986 - 2 2 6 2 2 6 2 2 6 10 10 10
44987 - 86 86 86 42 42 42 14 14 14 0 0 0
44988 - 0 0 0 0 0 0 0 0 0 0 0 0
44989 - 0 0 0 0 0 0 0 0 0 0 0 0
44990 - 0 0 0 0 0 0 0 0 0 0 0 0
44991 - 0 0 0 0 0 0 0 0 0 0 0 0
44992 - 0 0 0 0 0 0 0 0 0 0 0 0
44993 - 0 0 0 0 0 0 0 0 0 0 0 0
44994 - 0 0 0 0 0 0 0 0 0 0 0 0
44995 - 0 0 1 0 0 1 0 0 1 0 0 0
44996 - 0 0 0 0 0 0 0 0 0 0 0 0
44997 - 0 0 0 0 0 0 0 0 0 0 0 0
44998 - 0 0 0 0 0 0 0 0 0 0 0 0
44999 - 0 0 0 0 0 0 0 0 0 0 0 0
45000 - 0 0 0 0 0 0 0 0 0 14 14 14
45001 - 46 46 46 86 86 86 2 2 6 2 2 6
45002 - 38 38 38 116 116 116 94 94 94 22 22 22
45003 - 22 22 22 2 2 6 2 2 6 2 2 6
45004 - 14 14 14 86 86 86 138 138 138 162 162 162
45005 -154 154 154 38 38 38 26 26 26 6 6 6
45006 - 2 2 6 2 2 6 2 2 6 2 2 6
45007 - 86 86 86 46 46 46 14 14 14 0 0 0
45008 - 0 0 0 0 0 0 0 0 0 0 0 0
45009 - 0 0 0 0 0 0 0 0 0 0 0 0
45010 - 0 0 0 0 0 0 0 0 0 0 0 0
45011 - 0 0 0 0 0 0 0 0 0 0 0 0
45012 - 0 0 0 0 0 0 0 0 0 0 0 0
45013 - 0 0 0 0 0 0 0 0 0 0 0 0
45014 - 0 0 0 0 0 0 0 0 0 0 0 0
45015 - 0 0 0 0 0 0 0 0 0 0 0 0
45016 - 0 0 0 0 0 0 0 0 0 0 0 0
45017 - 0 0 0 0 0 0 0 0 0 0 0 0
45018 - 0 0 0 0 0 0 0 0 0 0 0 0
45019 - 0 0 0 0 0 0 0 0 0 0 0 0
45020 - 0 0 0 0 0 0 0 0 0 14 14 14
45021 - 46 46 46 86 86 86 2 2 6 14 14 14
45022 -134 134 134 198 198 198 195 195 195 116 116 116
45023 - 10 10 10 2 2 6 2 2 6 6 6 6
45024 -101 98 89 187 187 187 210 210 210 218 218 218
45025 -214 214 214 134 134 134 14 14 14 6 6 6
45026 - 2 2 6 2 2 6 2 2 6 2 2 6
45027 - 86 86 86 50 50 50 18 18 18 6 6 6
45028 - 0 0 0 0 0 0 0 0 0 0 0 0
45029 - 0 0 0 0 0 0 0 0 0 0 0 0
45030 - 0 0 0 0 0 0 0 0 0 0 0 0
45031 - 0 0 0 0 0 0 0 0 0 0 0 0
45032 - 0 0 0 0 0 0 0 0 0 0 0 0
45033 - 0 0 0 0 0 0 0 0 0 0 0 0
45034 - 0 0 0 0 0 0 0 0 1 0 0 0
45035 - 0 0 1 0 0 1 0 0 1 0 0 0
45036 - 0 0 0 0 0 0 0 0 0 0 0 0
45037 - 0 0 0 0 0 0 0 0 0 0 0 0
45038 - 0 0 0 0 0 0 0 0 0 0 0 0
45039 - 0 0 0 0 0 0 0 0 0 0 0 0
45040 - 0 0 0 0 0 0 0 0 0 14 14 14
45041 - 46 46 46 86 86 86 2 2 6 54 54 54
45042 -218 218 218 195 195 195 226 226 226 246 246 246
45043 - 58 58 58 2 2 6 2 2 6 30 30 30
45044 -210 210 210 253 253 253 174 174 174 123 123 123
45045 -221 221 221 234 234 234 74 74 74 2 2 6
45046 - 2 2 6 2 2 6 2 2 6 2 2 6
45047 - 70 70 70 58 58 58 22 22 22 6 6 6
45048 - 0 0 0 0 0 0 0 0 0 0 0 0
45049 - 0 0 0 0 0 0 0 0 0 0 0 0
45050 - 0 0 0 0 0 0 0 0 0 0 0 0
45051 - 0 0 0 0 0 0 0 0 0 0 0 0
45052 - 0 0 0 0 0 0 0 0 0 0 0 0
45053 - 0 0 0 0 0 0 0 0 0 0 0 0
45054 - 0 0 0 0 0 0 0 0 0 0 0 0
45055 - 0 0 0 0 0 0 0 0 0 0 0 0
45056 - 0 0 0 0 0 0 0 0 0 0 0 0
45057 - 0 0 0 0 0 0 0 0 0 0 0 0
45058 - 0 0 0 0 0 0 0 0 0 0 0 0
45059 - 0 0 0 0 0 0 0 0 0 0 0 0
45060 - 0 0 0 0 0 0 0 0 0 14 14 14
45061 - 46 46 46 82 82 82 2 2 6 106 106 106
45062 -170 170 170 26 26 26 86 86 86 226 226 226
45063 -123 123 123 10 10 10 14 14 14 46 46 46
45064 -231 231 231 190 190 190 6 6 6 70 70 70
45065 - 90 90 90 238 238 238 158 158 158 2 2 6
45066 - 2 2 6 2 2 6 2 2 6 2 2 6
45067 - 70 70 70 58 58 58 22 22 22 6 6 6
45068 - 0 0 0 0 0 0 0 0 0 0 0 0
45069 - 0 0 0 0 0 0 0 0 0 0 0 0
45070 - 0 0 0 0 0 0 0 0 0 0 0 0
45071 - 0 0 0 0 0 0 0 0 0 0 0 0
45072 - 0 0 0 0 0 0 0 0 0 0 0 0
45073 - 0 0 0 0 0 0 0 0 0 0 0 0
45074 - 0 0 0 0 0 0 0 0 1 0 0 0
45075 - 0 0 1 0 0 1 0 0 1 0 0 0
45076 - 0 0 0 0 0 0 0 0 0 0 0 0
45077 - 0 0 0 0 0 0 0 0 0 0 0 0
45078 - 0 0 0 0 0 0 0 0 0 0 0 0
45079 - 0 0 0 0 0 0 0 0 0 0 0 0
45080 - 0 0 0 0 0 0 0 0 0 14 14 14
45081 - 42 42 42 86 86 86 6 6 6 116 116 116
45082 -106 106 106 6 6 6 70 70 70 149 149 149
45083 -128 128 128 18 18 18 38 38 38 54 54 54
45084 -221 221 221 106 106 106 2 2 6 14 14 14
45085 - 46 46 46 190 190 190 198 198 198 2 2 6
45086 - 2 2 6 2 2 6 2 2 6 2 2 6
45087 - 74 74 74 62 62 62 22 22 22 6 6 6
45088 - 0 0 0 0 0 0 0 0 0 0 0 0
45089 - 0 0 0 0 0 0 0 0 0 0 0 0
45090 - 0 0 0 0 0 0 0 0 0 0 0 0
45091 - 0 0 0 0 0 0 0 0 0 0 0 0
45092 - 0 0 0 0 0 0 0 0 0 0 0 0
45093 - 0 0 0 0 0 0 0 0 0 0 0 0
45094 - 0 0 0 0 0 0 0 0 1 0 0 0
45095 - 0 0 1 0 0 0 0 0 1 0 0 0
45096 - 0 0 0 0 0 0 0 0 0 0 0 0
45097 - 0 0 0 0 0 0 0 0 0 0 0 0
45098 - 0 0 0 0 0 0 0 0 0 0 0 0
45099 - 0 0 0 0 0 0 0 0 0 0 0 0
45100 - 0 0 0 0 0 0 0 0 0 14 14 14
45101 - 42 42 42 94 94 94 14 14 14 101 101 101
45102 -128 128 128 2 2 6 18 18 18 116 116 116
45103 -118 98 46 121 92 8 121 92 8 98 78 10
45104 -162 162 162 106 106 106 2 2 6 2 2 6
45105 - 2 2 6 195 195 195 195 195 195 6 6 6
45106 - 2 2 6 2 2 6 2 2 6 2 2 6
45107 - 74 74 74 62 62 62 22 22 22 6 6 6
45108 - 0 0 0 0 0 0 0 0 0 0 0 0
45109 - 0 0 0 0 0 0 0 0 0 0 0 0
45110 - 0 0 0 0 0 0 0 0 0 0 0 0
45111 - 0 0 0 0 0 0 0 0 0 0 0 0
45112 - 0 0 0 0 0 0 0 0 0 0 0 0
45113 - 0 0 0 0 0 0 0 0 0 0 0 0
45114 - 0 0 0 0 0 0 0 0 1 0 0 1
45115 - 0 0 1 0 0 0 0 0 1 0 0 0
45116 - 0 0 0 0 0 0 0 0 0 0 0 0
45117 - 0 0 0 0 0 0 0 0 0 0 0 0
45118 - 0 0 0 0 0 0 0 0 0 0 0 0
45119 - 0 0 0 0 0 0 0 0 0 0 0 0
45120 - 0 0 0 0 0 0 0 0 0 10 10 10
45121 - 38 38 38 90 90 90 14 14 14 58 58 58
45122 -210 210 210 26 26 26 54 38 6 154 114 10
45123 -226 170 11 236 186 11 225 175 15 184 144 12
45124 -215 174 15 175 146 61 37 26 9 2 2 6
45125 - 70 70 70 246 246 246 138 138 138 2 2 6
45126 - 2 2 6 2 2 6 2 2 6 2 2 6
45127 - 70 70 70 66 66 66 26 26 26 6 6 6
45128 - 0 0 0 0 0 0 0 0 0 0 0 0
45129 - 0 0 0 0 0 0 0 0 0 0 0 0
45130 - 0 0 0 0 0 0 0 0 0 0 0 0
45131 - 0 0 0 0 0 0 0 0 0 0 0 0
45132 - 0 0 0 0 0 0 0 0 0 0 0 0
45133 - 0 0 0 0 0 0 0 0 0 0 0 0
45134 - 0 0 0 0 0 0 0 0 0 0 0 0
45135 - 0 0 0 0 0 0 0 0 0 0 0 0
45136 - 0 0 0 0 0 0 0 0 0 0 0 0
45137 - 0 0 0 0 0 0 0 0 0 0 0 0
45138 - 0 0 0 0 0 0 0 0 0 0 0 0
45139 - 0 0 0 0 0 0 0 0 0 0 0 0
45140 - 0 0 0 0 0 0 0 0 0 10 10 10
45141 - 38 38 38 86 86 86 14 14 14 10 10 10
45142 -195 195 195 188 164 115 192 133 9 225 175 15
45143 -239 182 13 234 190 10 232 195 16 232 200 30
45144 -245 207 45 241 208 19 232 195 16 184 144 12
45145 -218 194 134 211 206 186 42 42 42 2 2 6
45146 - 2 2 6 2 2 6 2 2 6 2 2 6
45147 - 50 50 50 74 74 74 30 30 30 6 6 6
45148 - 0 0 0 0 0 0 0 0 0 0 0 0
45149 - 0 0 0 0 0 0 0 0 0 0 0 0
45150 - 0 0 0 0 0 0 0 0 0 0 0 0
45151 - 0 0 0 0 0 0 0 0 0 0 0 0
45152 - 0 0 0 0 0 0 0 0 0 0 0 0
45153 - 0 0 0 0 0 0 0 0 0 0 0 0
45154 - 0 0 0 0 0 0 0 0 0 0 0 0
45155 - 0 0 0 0 0 0 0 0 0 0 0 0
45156 - 0 0 0 0 0 0 0 0 0 0 0 0
45157 - 0 0 0 0 0 0 0 0 0 0 0 0
45158 - 0 0 0 0 0 0 0 0 0 0 0 0
45159 - 0 0 0 0 0 0 0 0 0 0 0 0
45160 - 0 0 0 0 0 0 0 0 0 10 10 10
45161 - 34 34 34 86 86 86 14 14 14 2 2 6
45162 -121 87 25 192 133 9 219 162 10 239 182 13
45163 -236 186 11 232 195 16 241 208 19 244 214 54
45164 -246 218 60 246 218 38 246 215 20 241 208 19
45165 -241 208 19 226 184 13 121 87 25 2 2 6
45166 - 2 2 6 2 2 6 2 2 6 2 2 6
45167 - 50 50 50 82 82 82 34 34 34 10 10 10
45168 - 0 0 0 0 0 0 0 0 0 0 0 0
45169 - 0 0 0 0 0 0 0 0 0 0 0 0
45170 - 0 0 0 0 0 0 0 0 0 0 0 0
45171 - 0 0 0 0 0 0 0 0 0 0 0 0
45172 - 0 0 0 0 0 0 0 0 0 0 0 0
45173 - 0 0 0 0 0 0 0 0 0 0 0 0
45174 - 0 0 0 0 0 0 0 0 0 0 0 0
45175 - 0 0 0 0 0 0 0 0 0 0 0 0
45176 - 0 0 0 0 0 0 0 0 0 0 0 0
45177 - 0 0 0 0 0 0 0 0 0 0 0 0
45178 - 0 0 0 0 0 0 0 0 0 0 0 0
45179 - 0 0 0 0 0 0 0 0 0 0 0 0
45180 - 0 0 0 0 0 0 0 0 0 10 10 10
45181 - 34 34 34 82 82 82 30 30 30 61 42 6
45182 -180 123 7 206 145 10 230 174 11 239 182 13
45183 -234 190 10 238 202 15 241 208 19 246 218 74
45184 -246 218 38 246 215 20 246 215 20 246 215 20
45185 -226 184 13 215 174 15 184 144 12 6 6 6
45186 - 2 2 6 2 2 6 2 2 6 2 2 6
45187 - 26 26 26 94 94 94 42 42 42 14 14 14
45188 - 0 0 0 0 0 0 0 0 0 0 0 0
45189 - 0 0 0 0 0 0 0 0 0 0 0 0
45190 - 0 0 0 0 0 0 0 0 0 0 0 0
45191 - 0 0 0 0 0 0 0 0 0 0 0 0
45192 - 0 0 0 0 0 0 0 0 0 0 0 0
45193 - 0 0 0 0 0 0 0 0 0 0 0 0
45194 - 0 0 0 0 0 0 0 0 0 0 0 0
45195 - 0 0 0 0 0 0 0 0 0 0 0 0
45196 - 0 0 0 0 0 0 0 0 0 0 0 0
45197 - 0 0 0 0 0 0 0 0 0 0 0 0
45198 - 0 0 0 0 0 0 0 0 0 0 0 0
45199 - 0 0 0 0 0 0 0 0 0 0 0 0
45200 - 0 0 0 0 0 0 0 0 0 10 10 10
45201 - 30 30 30 78 78 78 50 50 50 104 69 6
45202 -192 133 9 216 158 10 236 178 12 236 186 11
45203 -232 195 16 241 208 19 244 214 54 245 215 43
45204 -246 215 20 246 215 20 241 208 19 198 155 10
45205 -200 144 11 216 158 10 156 118 10 2 2 6
45206 - 2 2 6 2 2 6 2 2 6 2 2 6
45207 - 6 6 6 90 90 90 54 54 54 18 18 18
45208 - 6 6 6 0 0 0 0 0 0 0 0 0
45209 - 0 0 0 0 0 0 0 0 0 0 0 0
45210 - 0 0 0 0 0 0 0 0 0 0 0 0
45211 - 0 0 0 0 0 0 0 0 0 0 0 0
45212 - 0 0 0 0 0 0 0 0 0 0 0 0
45213 - 0 0 0 0 0 0 0 0 0 0 0 0
45214 - 0 0 0 0 0 0 0 0 0 0 0 0
45215 - 0 0 0 0 0 0 0 0 0 0 0 0
45216 - 0 0 0 0 0 0 0 0 0 0 0 0
45217 - 0 0 0 0 0 0 0 0 0 0 0 0
45218 - 0 0 0 0 0 0 0 0 0 0 0 0
45219 - 0 0 0 0 0 0 0 0 0 0 0 0
45220 - 0 0 0 0 0 0 0 0 0 10 10 10
45221 - 30 30 30 78 78 78 46 46 46 22 22 22
45222 -137 92 6 210 162 10 239 182 13 238 190 10
45223 -238 202 15 241 208 19 246 215 20 246 215 20
45224 -241 208 19 203 166 17 185 133 11 210 150 10
45225 -216 158 10 210 150 10 102 78 10 2 2 6
45226 - 6 6 6 54 54 54 14 14 14 2 2 6
45227 - 2 2 6 62 62 62 74 74 74 30 30 30
45228 - 10 10 10 0 0 0 0 0 0 0 0 0
45229 - 0 0 0 0 0 0 0 0 0 0 0 0
45230 - 0 0 0 0 0 0 0 0 0 0 0 0
45231 - 0 0 0 0 0 0 0 0 0 0 0 0
45232 - 0 0 0 0 0 0 0 0 0 0 0 0
45233 - 0 0 0 0 0 0 0 0 0 0 0 0
45234 - 0 0 0 0 0 0 0 0 0 0 0 0
45235 - 0 0 0 0 0 0 0 0 0 0 0 0
45236 - 0 0 0 0 0 0 0 0 0 0 0 0
45237 - 0 0 0 0 0 0 0 0 0 0 0 0
45238 - 0 0 0 0 0 0 0 0 0 0 0 0
45239 - 0 0 0 0 0 0 0 0 0 0 0 0
45240 - 0 0 0 0 0 0 0 0 0 10 10 10
45241 - 34 34 34 78 78 78 50 50 50 6 6 6
45242 - 94 70 30 139 102 15 190 146 13 226 184 13
45243 -232 200 30 232 195 16 215 174 15 190 146 13
45244 -168 122 10 192 133 9 210 150 10 213 154 11
45245 -202 150 34 182 157 106 101 98 89 2 2 6
45246 - 2 2 6 78 78 78 116 116 116 58 58 58
45247 - 2 2 6 22 22 22 90 90 90 46 46 46
45248 - 18 18 18 6 6 6 0 0 0 0 0 0
45249 - 0 0 0 0 0 0 0 0 0 0 0 0
45250 - 0 0 0 0 0 0 0 0 0 0 0 0
45251 - 0 0 0 0 0 0 0 0 0 0 0 0
45252 - 0 0 0 0 0 0 0 0 0 0 0 0
45253 - 0 0 0 0 0 0 0 0 0 0 0 0
45254 - 0 0 0 0 0 0 0 0 0 0 0 0
45255 - 0 0 0 0 0 0 0 0 0 0 0 0
45256 - 0 0 0 0 0 0 0 0 0 0 0 0
45257 - 0 0 0 0 0 0 0 0 0 0 0 0
45258 - 0 0 0 0 0 0 0 0 0 0 0 0
45259 - 0 0 0 0 0 0 0 0 0 0 0 0
45260 - 0 0 0 0 0 0 0 0 0 10 10 10
45261 - 38 38 38 86 86 86 50 50 50 6 6 6
45262 -128 128 128 174 154 114 156 107 11 168 122 10
45263 -198 155 10 184 144 12 197 138 11 200 144 11
45264 -206 145 10 206 145 10 197 138 11 188 164 115
45265 -195 195 195 198 198 198 174 174 174 14 14 14
45266 - 2 2 6 22 22 22 116 116 116 116 116 116
45267 - 22 22 22 2 2 6 74 74 74 70 70 70
45268 - 30 30 30 10 10 10 0 0 0 0 0 0
45269 - 0 0 0 0 0 0 0 0 0 0 0 0
45270 - 0 0 0 0 0 0 0 0 0 0 0 0
45271 - 0 0 0 0 0 0 0 0 0 0 0 0
45272 - 0 0 0 0 0 0 0 0 0 0 0 0
45273 - 0 0 0 0 0 0 0 0 0 0 0 0
45274 - 0 0 0 0 0 0 0 0 0 0 0 0
45275 - 0 0 0 0 0 0 0 0 0 0 0 0
45276 - 0 0 0 0 0 0 0 0 0 0 0 0
45277 - 0 0 0 0 0 0 0 0 0 0 0 0
45278 - 0 0 0 0 0 0 0 0 0 0 0 0
45279 - 0 0 0 0 0 0 0 0 0 0 0 0
45280 - 0 0 0 0 0 0 6 6 6 18 18 18
45281 - 50 50 50 101 101 101 26 26 26 10 10 10
45282 -138 138 138 190 190 190 174 154 114 156 107 11
45283 -197 138 11 200 144 11 197 138 11 192 133 9
45284 -180 123 7 190 142 34 190 178 144 187 187 187
45285 -202 202 202 221 221 221 214 214 214 66 66 66
45286 - 2 2 6 2 2 6 50 50 50 62 62 62
45287 - 6 6 6 2 2 6 10 10 10 90 90 90
45288 - 50 50 50 18 18 18 6 6 6 0 0 0
45289 - 0 0 0 0 0 0 0 0 0 0 0 0
45290 - 0 0 0 0 0 0 0 0 0 0 0 0
45291 - 0 0 0 0 0 0 0 0 0 0 0 0
45292 - 0 0 0 0 0 0 0 0 0 0 0 0
45293 - 0 0 0 0 0 0 0 0 0 0 0 0
45294 - 0 0 0 0 0 0 0 0 0 0 0 0
45295 - 0 0 0 0 0 0 0 0 0 0 0 0
45296 - 0 0 0 0 0 0 0 0 0 0 0 0
45297 - 0 0 0 0 0 0 0 0 0 0 0 0
45298 - 0 0 0 0 0 0 0 0 0 0 0 0
45299 - 0 0 0 0 0 0 0 0 0 0 0 0
45300 - 0 0 0 0 0 0 10 10 10 34 34 34
45301 - 74 74 74 74 74 74 2 2 6 6 6 6
45302 -144 144 144 198 198 198 190 190 190 178 166 146
45303 -154 121 60 156 107 11 156 107 11 168 124 44
45304 -174 154 114 187 187 187 190 190 190 210 210 210
45305 -246 246 246 253 253 253 253 253 253 182 182 182
45306 - 6 6 6 2 2 6 2 2 6 2 2 6
45307 - 2 2 6 2 2 6 2 2 6 62 62 62
45308 - 74 74 74 34 34 34 14 14 14 0 0 0
45309 - 0 0 0 0 0 0 0 0 0 0 0 0
45310 - 0 0 0 0 0 0 0 0 0 0 0 0
45311 - 0 0 0 0 0 0 0 0 0 0 0 0
45312 - 0 0 0 0 0 0 0 0 0 0 0 0
45313 - 0 0 0 0 0 0 0 0 0 0 0 0
45314 - 0 0 0 0 0 0 0 0 0 0 0 0
45315 - 0 0 0 0 0 0 0 0 0 0 0 0
45316 - 0 0 0 0 0 0 0 0 0 0 0 0
45317 - 0 0 0 0 0 0 0 0 0 0 0 0
45318 - 0 0 0 0 0 0 0 0 0 0 0 0
45319 - 0 0 0 0 0 0 0 0 0 0 0 0
45320 - 0 0 0 10 10 10 22 22 22 54 54 54
45321 - 94 94 94 18 18 18 2 2 6 46 46 46
45322 -234 234 234 221 221 221 190 190 190 190 190 190
45323 -190 190 190 187 187 187 187 187 187 190 190 190
45324 -190 190 190 195 195 195 214 214 214 242 242 242
45325 -253 253 253 253 253 253 253 253 253 253 253 253
45326 - 82 82 82 2 2 6 2 2 6 2 2 6
45327 - 2 2 6 2 2 6 2 2 6 14 14 14
45328 - 86 86 86 54 54 54 22 22 22 6 6 6
45329 - 0 0 0 0 0 0 0 0 0 0 0 0
45330 - 0 0 0 0 0 0 0 0 0 0 0 0
45331 - 0 0 0 0 0 0 0 0 0 0 0 0
45332 - 0 0 0 0 0 0 0 0 0 0 0 0
45333 - 0 0 0 0 0 0 0 0 0 0 0 0
45334 - 0 0 0 0 0 0 0 0 0 0 0 0
45335 - 0 0 0 0 0 0 0 0 0 0 0 0
45336 - 0 0 0 0 0 0 0 0 0 0 0 0
45337 - 0 0 0 0 0 0 0 0 0 0 0 0
45338 - 0 0 0 0 0 0 0 0 0 0 0 0
45339 - 0 0 0 0 0 0 0 0 0 0 0 0
45340 - 6 6 6 18 18 18 46 46 46 90 90 90
45341 - 46 46 46 18 18 18 6 6 6 182 182 182
45342 -253 253 253 246 246 246 206 206 206 190 190 190
45343 -190 190 190 190 190 190 190 190 190 190 190 190
45344 -206 206 206 231 231 231 250 250 250 253 253 253
45345 -253 253 253 253 253 253 253 253 253 253 253 253
45346 -202 202 202 14 14 14 2 2 6 2 2 6
45347 - 2 2 6 2 2 6 2 2 6 2 2 6
45348 - 42 42 42 86 86 86 42 42 42 18 18 18
45349 - 6 6 6 0 0 0 0 0 0 0 0 0
45350 - 0 0 0 0 0 0 0 0 0 0 0 0
45351 - 0 0 0 0 0 0 0 0 0 0 0 0
45352 - 0 0 0 0 0 0 0 0 0 0 0 0
45353 - 0 0 0 0 0 0 0 0 0 0 0 0
45354 - 0 0 0 0 0 0 0 0 0 0 0 0
45355 - 0 0 0 0 0 0 0 0 0 0 0 0
45356 - 0 0 0 0 0 0 0 0 0 0 0 0
45357 - 0 0 0 0 0 0 0 0 0 0 0 0
45358 - 0 0 0 0 0 0 0 0 0 0 0 0
45359 - 0 0 0 0 0 0 0 0 0 6 6 6
45360 - 14 14 14 38 38 38 74 74 74 66 66 66
45361 - 2 2 6 6 6 6 90 90 90 250 250 250
45362 -253 253 253 253 253 253 238 238 238 198 198 198
45363 -190 190 190 190 190 190 195 195 195 221 221 221
45364 -246 246 246 253 253 253 253 253 253 253 253 253
45365 -253 253 253 253 253 253 253 253 253 253 253 253
45366 -253 253 253 82 82 82 2 2 6 2 2 6
45367 - 2 2 6 2 2 6 2 2 6 2 2 6
45368 - 2 2 6 78 78 78 70 70 70 34 34 34
45369 - 14 14 14 6 6 6 0 0 0 0 0 0
45370 - 0 0 0 0 0 0 0 0 0 0 0 0
45371 - 0 0 0 0 0 0 0 0 0 0 0 0
45372 - 0 0 0 0 0 0 0 0 0 0 0 0
45373 - 0 0 0 0 0 0 0 0 0 0 0 0
45374 - 0 0 0 0 0 0 0 0 0 0 0 0
45375 - 0 0 0 0 0 0 0 0 0 0 0 0
45376 - 0 0 0 0 0 0 0 0 0 0 0 0
45377 - 0 0 0 0 0 0 0 0 0 0 0 0
45378 - 0 0 0 0 0 0 0 0 0 0 0 0
45379 - 0 0 0 0 0 0 0 0 0 14 14 14
45380 - 34 34 34 66 66 66 78 78 78 6 6 6
45381 - 2 2 6 18 18 18 218 218 218 253 253 253
45382 -253 253 253 253 253 253 253 253 253 246 246 246
45383 -226 226 226 231 231 231 246 246 246 253 253 253
45384 -253 253 253 253 253 253 253 253 253 253 253 253
45385 -253 253 253 253 253 253 253 253 253 253 253 253
45386 -253 253 253 178 178 178 2 2 6 2 2 6
45387 - 2 2 6 2 2 6 2 2 6 2 2 6
45388 - 2 2 6 18 18 18 90 90 90 62 62 62
45389 - 30 30 30 10 10 10 0 0 0 0 0 0
45390 - 0 0 0 0 0 0 0 0 0 0 0 0
45391 - 0 0 0 0 0 0 0 0 0 0 0 0
45392 - 0 0 0 0 0 0 0 0 0 0 0 0
45393 - 0 0 0 0 0 0 0 0 0 0 0 0
45394 - 0 0 0 0 0 0 0 0 0 0 0 0
45395 - 0 0 0 0 0 0 0 0 0 0 0 0
45396 - 0 0 0 0 0 0 0 0 0 0 0 0
45397 - 0 0 0 0 0 0 0 0 0 0 0 0
45398 - 0 0 0 0 0 0 0 0 0 0 0 0
45399 - 0 0 0 0 0 0 10 10 10 26 26 26
45400 - 58 58 58 90 90 90 18 18 18 2 2 6
45401 - 2 2 6 110 110 110 253 253 253 253 253 253
45402 -253 253 253 253 253 253 253 253 253 253 253 253
45403 -250 250 250 253 253 253 253 253 253 253 253 253
45404 -253 253 253 253 253 253 253 253 253 253 253 253
45405 -253 253 253 253 253 253 253 253 253 253 253 253
45406 -253 253 253 231 231 231 18 18 18 2 2 6
45407 - 2 2 6 2 2 6 2 2 6 2 2 6
45408 - 2 2 6 2 2 6 18 18 18 94 94 94
45409 - 54 54 54 26 26 26 10 10 10 0 0 0
45410 - 0 0 0 0 0 0 0 0 0 0 0 0
45411 - 0 0 0 0 0 0 0 0 0 0 0 0
45412 - 0 0 0 0 0 0 0 0 0 0 0 0
45413 - 0 0 0 0 0 0 0 0 0 0 0 0
45414 - 0 0 0 0 0 0 0 0 0 0 0 0
45415 - 0 0 0 0 0 0 0 0 0 0 0 0
45416 - 0 0 0 0 0 0 0 0 0 0 0 0
45417 - 0 0 0 0 0 0 0 0 0 0 0 0
45418 - 0 0 0 0 0 0 0 0 0 0 0 0
45419 - 0 0 0 6 6 6 22 22 22 50 50 50
45420 - 90 90 90 26 26 26 2 2 6 2 2 6
45421 - 14 14 14 195 195 195 250 250 250 253 253 253
45422 -253 253 253 253 253 253 253 253 253 253 253 253
45423 -253 253 253 253 253 253 253 253 253 253 253 253
45424 -253 253 253 253 253 253 253 253 253 253 253 253
45425 -253 253 253 253 253 253 253 253 253 253 253 253
45426 -250 250 250 242 242 242 54 54 54 2 2 6
45427 - 2 2 6 2 2 6 2 2 6 2 2 6
45428 - 2 2 6 2 2 6 2 2 6 38 38 38
45429 - 86 86 86 50 50 50 22 22 22 6 6 6
45430 - 0 0 0 0 0 0 0 0 0 0 0 0
45431 - 0 0 0 0 0 0 0 0 0 0 0 0
45432 - 0 0 0 0 0 0 0 0 0 0 0 0
45433 - 0 0 0 0 0 0 0 0 0 0 0 0
45434 - 0 0 0 0 0 0 0 0 0 0 0 0
45435 - 0 0 0 0 0 0 0 0 0 0 0 0
45436 - 0 0 0 0 0 0 0 0 0 0 0 0
45437 - 0 0 0 0 0 0 0 0 0 0 0 0
45438 - 0 0 0 0 0 0 0 0 0 0 0 0
45439 - 6 6 6 14 14 14 38 38 38 82 82 82
45440 - 34 34 34 2 2 6 2 2 6 2 2 6
45441 - 42 42 42 195 195 195 246 246 246 253 253 253
45442 -253 253 253 253 253 253 253 253 253 250 250 250
45443 -242 242 242 242 242 242 250 250 250 253 253 253
45444 -253 253 253 253 253 253 253 253 253 253 253 253
45445 -253 253 253 250 250 250 246 246 246 238 238 238
45446 -226 226 226 231 231 231 101 101 101 6 6 6
45447 - 2 2 6 2 2 6 2 2 6 2 2 6
45448 - 2 2 6 2 2 6 2 2 6 2 2 6
45449 - 38 38 38 82 82 82 42 42 42 14 14 14
45450 - 6 6 6 0 0 0 0 0 0 0 0 0
45451 - 0 0 0 0 0 0 0 0 0 0 0 0
45452 - 0 0 0 0 0 0 0 0 0 0 0 0
45453 - 0 0 0 0 0 0 0 0 0 0 0 0
45454 - 0 0 0 0 0 0 0 0 0 0 0 0
45455 - 0 0 0 0 0 0 0 0 0 0 0 0
45456 - 0 0 0 0 0 0 0 0 0 0 0 0
45457 - 0 0 0 0 0 0 0 0 0 0 0 0
45458 - 0 0 0 0 0 0 0 0 0 0 0 0
45459 - 10 10 10 26 26 26 62 62 62 66 66 66
45460 - 2 2 6 2 2 6 2 2 6 6 6 6
45461 - 70 70 70 170 170 170 206 206 206 234 234 234
45462 -246 246 246 250 250 250 250 250 250 238 238 238
45463 -226 226 226 231 231 231 238 238 238 250 250 250
45464 -250 250 250 250 250 250 246 246 246 231 231 231
45465 -214 214 214 206 206 206 202 202 202 202 202 202
45466 -198 198 198 202 202 202 182 182 182 18 18 18
45467 - 2 2 6 2 2 6 2 2 6 2 2 6
45468 - 2 2 6 2 2 6 2 2 6 2 2 6
45469 - 2 2 6 62 62 62 66 66 66 30 30 30
45470 - 10 10 10 0 0 0 0 0 0 0 0 0
45471 - 0 0 0 0 0 0 0 0 0 0 0 0
45472 - 0 0 0 0 0 0 0 0 0 0 0 0
45473 - 0 0 0 0 0 0 0 0 0 0 0 0
45474 - 0 0 0 0 0 0 0 0 0 0 0 0
45475 - 0 0 0 0 0 0 0 0 0 0 0 0
45476 - 0 0 0 0 0 0 0 0 0 0 0 0
45477 - 0 0 0 0 0 0 0 0 0 0 0 0
45478 - 0 0 0 0 0 0 0 0 0 0 0 0
45479 - 14 14 14 42 42 42 82 82 82 18 18 18
45480 - 2 2 6 2 2 6 2 2 6 10 10 10
45481 - 94 94 94 182 182 182 218 218 218 242 242 242
45482 -250 250 250 253 253 253 253 253 253 250 250 250
45483 -234 234 234 253 253 253 253 253 253 253 253 253
45484 -253 253 253 253 253 253 253 253 253 246 246 246
45485 -238 238 238 226 226 226 210 210 210 202 202 202
45486 -195 195 195 195 195 195 210 210 210 158 158 158
45487 - 6 6 6 14 14 14 50 50 50 14 14 14
45488 - 2 2 6 2 2 6 2 2 6 2 2 6
45489 - 2 2 6 6 6 6 86 86 86 46 46 46
45490 - 18 18 18 6 6 6 0 0 0 0 0 0
45491 - 0 0 0 0 0 0 0 0 0 0 0 0
45492 - 0 0 0 0 0 0 0 0 0 0 0 0
45493 - 0 0 0 0 0 0 0 0 0 0 0 0
45494 - 0 0 0 0 0 0 0 0 0 0 0 0
45495 - 0 0 0 0 0 0 0 0 0 0 0 0
45496 - 0 0 0 0 0 0 0 0 0 0 0 0
45497 - 0 0 0 0 0 0 0 0 0 0 0 0
45498 - 0 0 0 0 0 0 0 0 0 6 6 6
45499 - 22 22 22 54 54 54 70 70 70 2 2 6
45500 - 2 2 6 10 10 10 2 2 6 22 22 22
45501 -166 166 166 231 231 231 250 250 250 253 253 253
45502 -253 253 253 253 253 253 253 253 253 250 250 250
45503 -242 242 242 253 253 253 253 253 253 253 253 253
45504 -253 253 253 253 253 253 253 253 253 253 253 253
45505 -253 253 253 253 253 253 253 253 253 246 246 246
45506 -231 231 231 206 206 206 198 198 198 226 226 226
45507 - 94 94 94 2 2 6 6 6 6 38 38 38
45508 - 30 30 30 2 2 6 2 2 6 2 2 6
45509 - 2 2 6 2 2 6 62 62 62 66 66 66
45510 - 26 26 26 10 10 10 0 0 0 0 0 0
45511 - 0 0 0 0 0 0 0 0 0 0 0 0
45512 - 0 0 0 0 0 0 0 0 0 0 0 0
45513 - 0 0 0 0 0 0 0 0 0 0 0 0
45514 - 0 0 0 0 0 0 0 0 0 0 0 0
45515 - 0 0 0 0 0 0 0 0 0 0 0 0
45516 - 0 0 0 0 0 0 0 0 0 0 0 0
45517 - 0 0 0 0 0 0 0 0 0 0 0 0
45518 - 0 0 0 0 0 0 0 0 0 10 10 10
45519 - 30 30 30 74 74 74 50 50 50 2 2 6
45520 - 26 26 26 26 26 26 2 2 6 106 106 106
45521 -238 238 238 253 253 253 253 253 253 253 253 253
45522 -253 253 253 253 253 253 253 253 253 253 253 253
45523 -253 253 253 253 253 253 253 253 253 253 253 253
45524 -253 253 253 253 253 253 253 253 253 253 253 253
45525 -253 253 253 253 253 253 253 253 253 253 253 253
45526 -253 253 253 246 246 246 218 218 218 202 202 202
45527 -210 210 210 14 14 14 2 2 6 2 2 6
45528 - 30 30 30 22 22 22 2 2 6 2 2 6
45529 - 2 2 6 2 2 6 18 18 18 86 86 86
45530 - 42 42 42 14 14 14 0 0 0 0 0 0
45531 - 0 0 0 0 0 0 0 0 0 0 0 0
45532 - 0 0 0 0 0 0 0 0 0 0 0 0
45533 - 0 0 0 0 0 0 0 0 0 0 0 0
45534 - 0 0 0 0 0 0 0 0 0 0 0 0
45535 - 0 0 0 0 0 0 0 0 0 0 0 0
45536 - 0 0 0 0 0 0 0 0 0 0 0 0
45537 - 0 0 0 0 0 0 0 0 0 0 0 0
45538 - 0 0 0 0 0 0 0 0 0 14 14 14
45539 - 42 42 42 90 90 90 22 22 22 2 2 6
45540 - 42 42 42 2 2 6 18 18 18 218 218 218
45541 -253 253 253 253 253 253 253 253 253 253 253 253
45542 -253 253 253 253 253 253 253 253 253 253 253 253
45543 -253 253 253 253 253 253 253 253 253 253 253 253
45544 -253 253 253 253 253 253 253 253 253 253 253 253
45545 -253 253 253 253 253 253 253 253 253 253 253 253
45546 -253 253 253 253 253 253 250 250 250 221 221 221
45547 -218 218 218 101 101 101 2 2 6 14 14 14
45548 - 18 18 18 38 38 38 10 10 10 2 2 6
45549 - 2 2 6 2 2 6 2 2 6 78 78 78
45550 - 58 58 58 22 22 22 6 6 6 0 0 0
45551 - 0 0 0 0 0 0 0 0 0 0 0 0
45552 - 0 0 0 0 0 0 0 0 0 0 0 0
45553 - 0 0 0 0 0 0 0 0 0 0 0 0
45554 - 0 0 0 0 0 0 0 0 0 0 0 0
45555 - 0 0 0 0 0 0 0 0 0 0 0 0
45556 - 0 0 0 0 0 0 0 0 0 0 0 0
45557 - 0 0 0 0 0 0 0 0 0 0 0 0
45558 - 0 0 0 0 0 0 6 6 6 18 18 18
45559 - 54 54 54 82 82 82 2 2 6 26 26 26
45560 - 22 22 22 2 2 6 123 123 123 253 253 253
45561 -253 253 253 253 253 253 253 253 253 253 253 253
45562 -253 253 253 253 253 253 253 253 253 253 253 253
45563 -253 253 253 253 253 253 253 253 253 253 253 253
45564 -253 253 253 253 253 253 253 253 253 253 253 253
45565 -253 253 253 253 253 253 253 253 253 253 253 253
45566 -253 253 253 253 253 253 253 253 253 250 250 250
45567 -238 238 238 198 198 198 6 6 6 38 38 38
45568 - 58 58 58 26 26 26 38 38 38 2 2 6
45569 - 2 2 6 2 2 6 2 2 6 46 46 46
45570 - 78 78 78 30 30 30 10 10 10 0 0 0
45571 - 0 0 0 0 0 0 0 0 0 0 0 0
45572 - 0 0 0 0 0 0 0 0 0 0 0 0
45573 - 0 0 0 0 0 0 0 0 0 0 0 0
45574 - 0 0 0 0 0 0 0 0 0 0 0 0
45575 - 0 0 0 0 0 0 0 0 0 0 0 0
45576 - 0 0 0 0 0 0 0 0 0 0 0 0
45577 - 0 0 0 0 0 0 0 0 0 0 0 0
45578 - 0 0 0 0 0 0 10 10 10 30 30 30
45579 - 74 74 74 58 58 58 2 2 6 42 42 42
45580 - 2 2 6 22 22 22 231 231 231 253 253 253
45581 -253 253 253 253 253 253 253 253 253 253 253 253
45582 -253 253 253 253 253 253 253 253 253 250 250 250
45583 -253 253 253 253 253 253 253 253 253 253 253 253
45584 -253 253 253 253 253 253 253 253 253 253 253 253
45585 -253 253 253 253 253 253 253 253 253 253 253 253
45586 -253 253 253 253 253 253 253 253 253 253 253 253
45587 -253 253 253 246 246 246 46 46 46 38 38 38
45588 - 42 42 42 14 14 14 38 38 38 14 14 14
45589 - 2 2 6 2 2 6 2 2 6 6 6 6
45590 - 86 86 86 46 46 46 14 14 14 0 0 0
45591 - 0 0 0 0 0 0 0 0 0 0 0 0
45592 - 0 0 0 0 0 0 0 0 0 0 0 0
45593 - 0 0 0 0 0 0 0 0 0 0 0 0
45594 - 0 0 0 0 0 0 0 0 0 0 0 0
45595 - 0 0 0 0 0 0 0 0 0 0 0 0
45596 - 0 0 0 0 0 0 0 0 0 0 0 0
45597 - 0 0 0 0 0 0 0 0 0 0 0 0
45598 - 0 0 0 6 6 6 14 14 14 42 42 42
45599 - 90 90 90 18 18 18 18 18 18 26 26 26
45600 - 2 2 6 116 116 116 253 253 253 253 253 253
45601 -253 253 253 253 253 253 253 253 253 253 253 253
45602 -253 253 253 253 253 253 250 250 250 238 238 238
45603 -253 253 253 253 253 253 253 253 253 253 253 253
45604 -253 253 253 253 253 253 253 253 253 253 253 253
45605 -253 253 253 253 253 253 253 253 253 253 253 253
45606 -253 253 253 253 253 253 253 253 253 253 253 253
45607 -253 253 253 253 253 253 94 94 94 6 6 6
45608 - 2 2 6 2 2 6 10 10 10 34 34 34
45609 - 2 2 6 2 2 6 2 2 6 2 2 6
45610 - 74 74 74 58 58 58 22 22 22 6 6 6
45611 - 0 0 0 0 0 0 0 0 0 0 0 0
45612 - 0 0 0 0 0 0 0 0 0 0 0 0
45613 - 0 0 0 0 0 0 0 0 0 0 0 0
45614 - 0 0 0 0 0 0 0 0 0 0 0 0
45615 - 0 0 0 0 0 0 0 0 0 0 0 0
45616 - 0 0 0 0 0 0 0 0 0 0 0 0
45617 - 0 0 0 0 0 0 0 0 0 0 0 0
45618 - 0 0 0 10 10 10 26 26 26 66 66 66
45619 - 82 82 82 2 2 6 38 38 38 6 6 6
45620 - 14 14 14 210 210 210 253 253 253 253 253 253
45621 -253 253 253 253 253 253 253 253 253 253 253 253
45622 -253 253 253 253 253 253 246 246 246 242 242 242
45623 -253 253 253 253 253 253 253 253 253 253 253 253
45624 -253 253 253 253 253 253 253 253 253 253 253 253
45625 -253 253 253 253 253 253 253 253 253 253 253 253
45626 -253 253 253 253 253 253 253 253 253 253 253 253
45627 -253 253 253 253 253 253 144 144 144 2 2 6
45628 - 2 2 6 2 2 6 2 2 6 46 46 46
45629 - 2 2 6 2 2 6 2 2 6 2 2 6
45630 - 42 42 42 74 74 74 30 30 30 10 10 10
45631 - 0 0 0 0 0 0 0 0 0 0 0 0
45632 - 0 0 0 0 0 0 0 0 0 0 0 0
45633 - 0 0 0 0 0 0 0 0 0 0 0 0
45634 - 0 0 0 0 0 0 0 0 0 0 0 0
45635 - 0 0 0 0 0 0 0 0 0 0 0 0
45636 - 0 0 0 0 0 0 0 0 0 0 0 0
45637 - 0 0 0 0 0 0 0 0 0 0 0 0
45638 - 6 6 6 14 14 14 42 42 42 90 90 90
45639 - 26 26 26 6 6 6 42 42 42 2 2 6
45640 - 74 74 74 250 250 250 253 253 253 253 253 253
45641 -253 253 253 253 253 253 253 253 253 253 253 253
45642 -253 253 253 253 253 253 242 242 242 242 242 242
45643 -253 253 253 253 253 253 253 253 253 253 253 253
45644 -253 253 253 253 253 253 253 253 253 253 253 253
45645 -253 253 253 253 253 253 253 253 253 253 253 253
45646 -253 253 253 253 253 253 253 253 253 253 253 253
45647 -253 253 253 253 253 253 182 182 182 2 2 6
45648 - 2 2 6 2 2 6 2 2 6 46 46 46
45649 - 2 2 6 2 2 6 2 2 6 2 2 6
45650 - 10 10 10 86 86 86 38 38 38 10 10 10
45651 - 0 0 0 0 0 0 0 0 0 0 0 0
45652 - 0 0 0 0 0 0 0 0 0 0 0 0
45653 - 0 0 0 0 0 0 0 0 0 0 0 0
45654 - 0 0 0 0 0 0 0 0 0 0 0 0
45655 - 0 0 0 0 0 0 0 0 0 0 0 0
45656 - 0 0 0 0 0 0 0 0 0 0 0 0
45657 - 0 0 0 0 0 0 0 0 0 0 0 0
45658 - 10 10 10 26 26 26 66 66 66 82 82 82
45659 - 2 2 6 22 22 22 18 18 18 2 2 6
45660 -149 149 149 253 253 253 253 253 253 253 253 253
45661 -253 253 253 253 253 253 253 253 253 253 253 253
45662 -253 253 253 253 253 253 234 234 234 242 242 242
45663 -253 253 253 253 253 253 253 253 253 253 253 253
45664 -253 253 253 253 253 253 253 253 253 253 253 253
45665 -253 253 253 253 253 253 253 253 253 253 253 253
45666 -253 253 253 253 253 253 253 253 253 253 253 253
45667 -253 253 253 253 253 253 206 206 206 2 2 6
45668 - 2 2 6 2 2 6 2 2 6 38 38 38
45669 - 2 2 6 2 2 6 2 2 6 2 2 6
45670 - 6 6 6 86 86 86 46 46 46 14 14 14
45671 - 0 0 0 0 0 0 0 0 0 0 0 0
45672 - 0 0 0 0 0 0 0 0 0 0 0 0
45673 - 0 0 0 0 0 0 0 0 0 0 0 0
45674 - 0 0 0 0 0 0 0 0 0 0 0 0
45675 - 0 0 0 0 0 0 0 0 0 0 0 0
45676 - 0 0 0 0 0 0 0 0 0 0 0 0
45677 - 0 0 0 0 0 0 0 0 0 6 6 6
45678 - 18 18 18 46 46 46 86 86 86 18 18 18
45679 - 2 2 6 34 34 34 10 10 10 6 6 6
45680 -210 210 210 253 253 253 253 253 253 253 253 253
45681 -253 253 253 253 253 253 253 253 253 253 253 253
45682 -253 253 253 253 253 253 234 234 234 242 242 242
45683 -253 253 253 253 253 253 253 253 253 253 253 253
45684 -253 253 253 253 253 253 253 253 253 253 253 253
45685 -253 253 253 253 253 253 253 253 253 253 253 253
45686 -253 253 253 253 253 253 253 253 253 253 253 253
45687 -253 253 253 253 253 253 221 221 221 6 6 6
45688 - 2 2 6 2 2 6 6 6 6 30 30 30
45689 - 2 2 6 2 2 6 2 2 6 2 2 6
45690 - 2 2 6 82 82 82 54 54 54 18 18 18
45691 - 6 6 6 0 0 0 0 0 0 0 0 0
45692 - 0 0 0 0 0 0 0 0 0 0 0 0
45693 - 0 0 0 0 0 0 0 0 0 0 0 0
45694 - 0 0 0 0 0 0 0 0 0 0 0 0
45695 - 0 0 0 0 0 0 0 0 0 0 0 0
45696 - 0 0 0 0 0 0 0 0 0 0 0 0
45697 - 0 0 0 0 0 0 0 0 0 10 10 10
45698 - 26 26 26 66 66 66 62 62 62 2 2 6
45699 - 2 2 6 38 38 38 10 10 10 26 26 26
45700 -238 238 238 253 253 253 253 253 253 253 253 253
45701 -253 253 253 253 253 253 253 253 253 253 253 253
45702 -253 253 253 253 253 253 231 231 231 238 238 238
45703 -253 253 253 253 253 253 253 253 253 253 253 253
45704 -253 253 253 253 253 253 253 253 253 253 253 253
45705 -253 253 253 253 253 253 253 253 253 253 253 253
45706 -253 253 253 253 253 253 253 253 253 253 253 253
45707 -253 253 253 253 253 253 231 231 231 6 6 6
45708 - 2 2 6 2 2 6 10 10 10 30 30 30
45709 - 2 2 6 2 2 6 2 2 6 2 2 6
45710 - 2 2 6 66 66 66 58 58 58 22 22 22
45711 - 6 6 6 0 0 0 0 0 0 0 0 0
45712 - 0 0 0 0 0 0 0 0 0 0 0 0
45713 - 0 0 0 0 0 0 0 0 0 0 0 0
45714 - 0 0 0 0 0 0 0 0 0 0 0 0
45715 - 0 0 0 0 0 0 0 0 0 0 0 0
45716 - 0 0 0 0 0 0 0 0 0 0 0 0
45717 - 0 0 0 0 0 0 0 0 0 10 10 10
45718 - 38 38 38 78 78 78 6 6 6 2 2 6
45719 - 2 2 6 46 46 46 14 14 14 42 42 42
45720 -246 246 246 253 253 253 253 253 253 253 253 253
45721 -253 253 253 253 253 253 253 253 253 253 253 253
45722 -253 253 253 253 253 253 231 231 231 242 242 242
45723 -253 253 253 253 253 253 253 253 253 253 253 253
45724 -253 253 253 253 253 253 253 253 253 253 253 253
45725 -253 253 253 253 253 253 253 253 253 253 253 253
45726 -253 253 253 253 253 253 253 253 253 253 253 253
45727 -253 253 253 253 253 253 234 234 234 10 10 10
45728 - 2 2 6 2 2 6 22 22 22 14 14 14
45729 - 2 2 6 2 2 6 2 2 6 2 2 6
45730 - 2 2 6 66 66 66 62 62 62 22 22 22
45731 - 6 6 6 0 0 0 0 0 0 0 0 0
45732 - 0 0 0 0 0 0 0 0 0 0 0 0
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 6 6 6 18 18 18
45738 - 50 50 50 74 74 74 2 2 6 2 2 6
45739 - 14 14 14 70 70 70 34 34 34 62 62 62
45740 -250 250 250 253 253 253 253 253 253 253 253 253
45741 -253 253 253 253 253 253 253 253 253 253 253 253
45742 -253 253 253 253 253 253 231 231 231 246 246 246
45743 -253 253 253 253 253 253 253 253 253 253 253 253
45744 -253 253 253 253 253 253 253 253 253 253 253 253
45745 -253 253 253 253 253 253 253 253 253 253 253 253
45746 -253 253 253 253 253 253 253 253 253 253 253 253
45747 -253 253 253 253 253 253 234 234 234 14 14 14
45748 - 2 2 6 2 2 6 30 30 30 2 2 6
45749 - 2 2 6 2 2 6 2 2 6 2 2 6
45750 - 2 2 6 66 66 66 62 62 62 22 22 22
45751 - 6 6 6 0 0 0 0 0 0 0 0 0
45752 - 0 0 0 0 0 0 0 0 0 0 0 0
45753 - 0 0 0 0 0 0 0 0 0 0 0 0
45754 - 0 0 0 0 0 0 0 0 0 0 0 0
45755 - 0 0 0 0 0 0 0 0 0 0 0 0
45756 - 0 0 0 0 0 0 0 0 0 0 0 0
45757 - 0 0 0 0 0 0 6 6 6 18 18 18
45758 - 54 54 54 62 62 62 2 2 6 2 2 6
45759 - 2 2 6 30 30 30 46 46 46 70 70 70
45760 -250 250 250 253 253 253 253 253 253 253 253 253
45761 -253 253 253 253 253 253 253 253 253 253 253 253
45762 -253 253 253 253 253 253 231 231 231 246 246 246
45763 -253 253 253 253 253 253 253 253 253 253 253 253
45764 -253 253 253 253 253 253 253 253 253 253 253 253
45765 -253 253 253 253 253 253 253 253 253 253 253 253
45766 -253 253 253 253 253 253 253 253 253 253 253 253
45767 -253 253 253 253 253 253 226 226 226 10 10 10
45768 - 2 2 6 6 6 6 30 30 30 2 2 6
45769 - 2 2 6 2 2 6 2 2 6 2 2 6
45770 - 2 2 6 66 66 66 58 58 58 22 22 22
45771 - 6 6 6 0 0 0 0 0 0 0 0 0
45772 - 0 0 0 0 0 0 0 0 0 0 0 0
45773 - 0 0 0 0 0 0 0 0 0 0 0 0
45774 - 0 0 0 0 0 0 0 0 0 0 0 0
45775 - 0 0 0 0 0 0 0 0 0 0 0 0
45776 - 0 0 0 0 0 0 0 0 0 0 0 0
45777 - 0 0 0 0 0 0 6 6 6 22 22 22
45778 - 58 58 58 62 62 62 2 2 6 2 2 6
45779 - 2 2 6 2 2 6 30 30 30 78 78 78
45780 -250 250 250 253 253 253 253 253 253 253 253 253
45781 -253 253 253 253 253 253 253 253 253 253 253 253
45782 -253 253 253 253 253 253 231 231 231 246 246 246
45783 -253 253 253 253 253 253 253 253 253 253 253 253
45784 -253 253 253 253 253 253 253 253 253 253 253 253
45785 -253 253 253 253 253 253 253 253 253 253 253 253
45786 -253 253 253 253 253 253 253 253 253 253 253 253
45787 -253 253 253 253 253 253 206 206 206 2 2 6
45788 - 22 22 22 34 34 34 18 14 6 22 22 22
45789 - 26 26 26 18 18 18 6 6 6 2 2 6
45790 - 2 2 6 82 82 82 54 54 54 18 18 18
45791 - 6 6 6 0 0 0 0 0 0 0 0 0
45792 - 0 0 0 0 0 0 0 0 0 0 0 0
45793 - 0 0 0 0 0 0 0 0 0 0 0 0
45794 - 0 0 0 0 0 0 0 0 0 0 0 0
45795 - 0 0 0 0 0 0 0 0 0 0 0 0
45796 - 0 0 0 0 0 0 0 0 0 0 0 0
45797 - 0 0 0 0 0 0 6 6 6 26 26 26
45798 - 62 62 62 106 106 106 74 54 14 185 133 11
45799 -210 162 10 121 92 8 6 6 6 62 62 62
45800 -238 238 238 253 253 253 253 253 253 253 253 253
45801 -253 253 253 253 253 253 253 253 253 253 253 253
45802 -253 253 253 253 253 253 231 231 231 246 246 246
45803 -253 253 253 253 253 253 253 253 253 253 253 253
45804 -253 253 253 253 253 253 253 253 253 253 253 253
45805 -253 253 253 253 253 253 253 253 253 253 253 253
45806 -253 253 253 253 253 253 253 253 253 253 253 253
45807 -253 253 253 253 253 253 158 158 158 18 18 18
45808 - 14 14 14 2 2 6 2 2 6 2 2 6
45809 - 6 6 6 18 18 18 66 66 66 38 38 38
45810 - 6 6 6 94 94 94 50 50 50 18 18 18
45811 - 6 6 6 0 0 0 0 0 0 0 0 0
45812 - 0 0 0 0 0 0 0 0 0 0 0 0
45813 - 0 0 0 0 0 0 0 0 0 0 0 0
45814 - 0 0 0 0 0 0 0 0 0 0 0 0
45815 - 0 0 0 0 0 0 0 0 0 0 0 0
45816 - 0 0 0 0 0 0 0 0 0 6 6 6
45817 - 10 10 10 10 10 10 18 18 18 38 38 38
45818 - 78 78 78 142 134 106 216 158 10 242 186 14
45819 -246 190 14 246 190 14 156 118 10 10 10 10
45820 - 90 90 90 238 238 238 253 253 253 253 253 253
45821 -253 253 253 253 253 253 253 253 253 253 253 253
45822 -253 253 253 253 253 253 231 231 231 250 250 250
45823 -253 253 253 253 253 253 253 253 253 253 253 253
45824 -253 253 253 253 253 253 253 253 253 253 253 253
45825 -253 253 253 253 253 253 253 253 253 253 253 253
45826 -253 253 253 253 253 253 253 253 253 246 230 190
45827 -238 204 91 238 204 91 181 142 44 37 26 9
45828 - 2 2 6 2 2 6 2 2 6 2 2 6
45829 - 2 2 6 2 2 6 38 38 38 46 46 46
45830 - 26 26 26 106 106 106 54 54 54 18 18 18
45831 - 6 6 6 0 0 0 0 0 0 0 0 0
45832 - 0 0 0 0 0 0 0 0 0 0 0 0
45833 - 0 0 0 0 0 0 0 0 0 0 0 0
45834 - 0 0 0 0 0 0 0 0 0 0 0 0
45835 - 0 0 0 0 0 0 0 0 0 0 0 0
45836 - 0 0 0 6 6 6 14 14 14 22 22 22
45837 - 30 30 30 38 38 38 50 50 50 70 70 70
45838 -106 106 106 190 142 34 226 170 11 242 186 14
45839 -246 190 14 246 190 14 246 190 14 154 114 10
45840 - 6 6 6 74 74 74 226 226 226 253 253 253
45841 -253 253 253 253 253 253 253 253 253 253 253 253
45842 -253 253 253 253 253 253 231 231 231 250 250 250
45843 -253 253 253 253 253 253 253 253 253 253 253 253
45844 -253 253 253 253 253 253 253 253 253 253 253 253
45845 -253 253 253 253 253 253 253 253 253 253 253 253
45846 -253 253 253 253 253 253 253 253 253 228 184 62
45847 -241 196 14 241 208 19 232 195 16 38 30 10
45848 - 2 2 6 2 2 6 2 2 6 2 2 6
45849 - 2 2 6 6 6 6 30 30 30 26 26 26
45850 -203 166 17 154 142 90 66 66 66 26 26 26
45851 - 6 6 6 0 0 0 0 0 0 0 0 0
45852 - 0 0 0 0 0 0 0 0 0 0 0 0
45853 - 0 0 0 0 0 0 0 0 0 0 0 0
45854 - 0 0 0 0 0 0 0 0 0 0 0 0
45855 - 0 0 0 0 0 0 0 0 0 0 0 0
45856 - 6 6 6 18 18 18 38 38 38 58 58 58
45857 - 78 78 78 86 86 86 101 101 101 123 123 123
45858 -175 146 61 210 150 10 234 174 13 246 186 14
45859 -246 190 14 246 190 14 246 190 14 238 190 10
45860 -102 78 10 2 2 6 46 46 46 198 198 198
45861 -253 253 253 253 253 253 253 253 253 253 253 253
45862 -253 253 253 253 253 253 234 234 234 242 242 242
45863 -253 253 253 253 253 253 253 253 253 253 253 253
45864 -253 253 253 253 253 253 253 253 253 253 253 253
45865 -253 253 253 253 253 253 253 253 253 253 253 253
45866 -253 253 253 253 253 253 253 253 253 224 178 62
45867 -242 186 14 241 196 14 210 166 10 22 18 6
45868 - 2 2 6 2 2 6 2 2 6 2 2 6
45869 - 2 2 6 2 2 6 6 6 6 121 92 8
45870 -238 202 15 232 195 16 82 82 82 34 34 34
45871 - 10 10 10 0 0 0 0 0 0 0 0 0
45872 - 0 0 0 0 0 0 0 0 0 0 0 0
45873 - 0 0 0 0 0 0 0 0 0 0 0 0
45874 - 0 0 0 0 0 0 0 0 0 0 0 0
45875 - 0 0 0 0 0 0 0 0 0 0 0 0
45876 - 14 14 14 38 38 38 70 70 70 154 122 46
45877 -190 142 34 200 144 11 197 138 11 197 138 11
45878 -213 154 11 226 170 11 242 186 14 246 190 14
45879 -246 190 14 246 190 14 246 190 14 246 190 14
45880 -225 175 15 46 32 6 2 2 6 22 22 22
45881 -158 158 158 250 250 250 253 253 253 253 253 253
45882 -253 253 253 253 253 253 253 253 253 253 253 253
45883 -253 253 253 253 253 253 253 253 253 253 253 253
45884 -253 253 253 253 253 253 253 253 253 253 253 253
45885 -253 253 253 253 253 253 253 253 253 253 253 253
45886 -253 253 253 250 250 250 242 242 242 224 178 62
45887 -239 182 13 236 186 11 213 154 11 46 32 6
45888 - 2 2 6 2 2 6 2 2 6 2 2 6
45889 - 2 2 6 2 2 6 61 42 6 225 175 15
45890 -238 190 10 236 186 11 112 100 78 42 42 42
45891 - 14 14 14 0 0 0 0 0 0 0 0 0
45892 - 0 0 0 0 0 0 0 0 0 0 0 0
45893 - 0 0 0 0 0 0 0 0 0 0 0 0
45894 - 0 0 0 0 0 0 0 0 0 0 0 0
45895 - 0 0 0 0 0 0 0 0 0 6 6 6
45896 - 22 22 22 54 54 54 154 122 46 213 154 11
45897 -226 170 11 230 174 11 226 170 11 226 170 11
45898 -236 178 12 242 186 14 246 190 14 246 190 14
45899 -246 190 14 246 190 14 246 190 14 246 190 14
45900 -241 196 14 184 144 12 10 10 10 2 2 6
45901 - 6 6 6 116 116 116 242 242 242 253 253 253
45902 -253 253 253 253 253 253 253 253 253 253 253 253
45903 -253 253 253 253 253 253 253 253 253 253 253 253
45904 -253 253 253 253 253 253 253 253 253 253 253 253
45905 -253 253 253 253 253 253 253 253 253 253 253 253
45906 -253 253 253 231 231 231 198 198 198 214 170 54
45907 -236 178 12 236 178 12 210 150 10 137 92 6
45908 - 18 14 6 2 2 6 2 2 6 2 2 6
45909 - 6 6 6 70 47 6 200 144 11 236 178 12
45910 -239 182 13 239 182 13 124 112 88 58 58 58
45911 - 22 22 22 6 6 6 0 0 0 0 0 0
45912 - 0 0 0 0 0 0 0 0 0 0 0 0
45913 - 0 0 0 0 0 0 0 0 0 0 0 0
45914 - 0 0 0 0 0 0 0 0 0 0 0 0
45915 - 0 0 0 0 0 0 0 0 0 10 10 10
45916 - 30 30 30 70 70 70 180 133 36 226 170 11
45917 -239 182 13 242 186 14 242 186 14 246 186 14
45918 -246 190 14 246 190 14 246 190 14 246 190 14
45919 -246 190 14 246 190 14 246 190 14 246 190 14
45920 -246 190 14 232 195 16 98 70 6 2 2 6
45921 - 2 2 6 2 2 6 66 66 66 221 221 221
45922 -253 253 253 253 253 253 253 253 253 253 253 253
45923 -253 253 253 253 253 253 253 253 253 253 253 253
45924 -253 253 253 253 253 253 253 253 253 253 253 253
45925 -253 253 253 253 253 253 253 253 253 253 253 253
45926 -253 253 253 206 206 206 198 198 198 214 166 58
45927 -230 174 11 230 174 11 216 158 10 192 133 9
45928 -163 110 8 116 81 8 102 78 10 116 81 8
45929 -167 114 7 197 138 11 226 170 11 239 182 13
45930 -242 186 14 242 186 14 162 146 94 78 78 78
45931 - 34 34 34 14 14 14 6 6 6 0 0 0
45932 - 0 0 0 0 0 0 0 0 0 0 0 0
45933 - 0 0 0 0 0 0 0 0 0 0 0 0
45934 - 0 0 0 0 0 0 0 0 0 0 0 0
45935 - 0 0 0 0 0 0 0 0 0 6 6 6
45936 - 30 30 30 78 78 78 190 142 34 226 170 11
45937 -239 182 13 246 190 14 246 190 14 246 190 14
45938 -246 190 14 246 190 14 246 190 14 246 190 14
45939 -246 190 14 246 190 14 246 190 14 246 190 14
45940 -246 190 14 241 196 14 203 166 17 22 18 6
45941 - 2 2 6 2 2 6 2 2 6 38 38 38
45942 -218 218 218 253 253 253 253 253 253 253 253 253
45943 -253 253 253 253 253 253 253 253 253 253 253 253
45944 -253 253 253 253 253 253 253 253 253 253 253 253
45945 -253 253 253 253 253 253 253 253 253 253 253 253
45946 -250 250 250 206 206 206 198 198 198 202 162 69
45947 -226 170 11 236 178 12 224 166 10 210 150 10
45948 -200 144 11 197 138 11 192 133 9 197 138 11
45949 -210 150 10 226 170 11 242 186 14 246 190 14
45950 -246 190 14 246 186 14 225 175 15 124 112 88
45951 - 62 62 62 30 30 30 14 14 14 6 6 6
45952 - 0 0 0 0 0 0 0 0 0 0 0 0
45953 - 0 0 0 0 0 0 0 0 0 0 0 0
45954 - 0 0 0 0 0 0 0 0 0 0 0 0
45955 - 0 0 0 0 0 0 0 0 0 10 10 10
45956 - 30 30 30 78 78 78 174 135 50 224 166 10
45957 -239 182 13 246 190 14 246 190 14 246 190 14
45958 -246 190 14 246 190 14 246 190 14 246 190 14
45959 -246 190 14 246 190 14 246 190 14 246 190 14
45960 -246 190 14 246 190 14 241 196 14 139 102 15
45961 - 2 2 6 2 2 6 2 2 6 2 2 6
45962 - 78 78 78 250 250 250 253 253 253 253 253 253
45963 -253 253 253 253 253 253 253 253 253 253 253 253
45964 -253 253 253 253 253 253 253 253 253 253 253 253
45965 -253 253 253 253 253 253 253 253 253 253 253 253
45966 -250 250 250 214 214 214 198 198 198 190 150 46
45967 -219 162 10 236 178 12 234 174 13 224 166 10
45968 -216 158 10 213 154 11 213 154 11 216 158 10
45969 -226 170 11 239 182 13 246 190 14 246 190 14
45970 -246 190 14 246 190 14 242 186 14 206 162 42
45971 -101 101 101 58 58 58 30 30 30 14 14 14
45972 - 6 6 6 0 0 0 0 0 0 0 0 0
45973 - 0 0 0 0 0 0 0 0 0 0 0 0
45974 - 0 0 0 0 0 0 0 0 0 0 0 0
45975 - 0 0 0 0 0 0 0 0 0 10 10 10
45976 - 30 30 30 74 74 74 174 135 50 216 158 10
45977 -236 178 12 246 190 14 246 190 14 246 190 14
45978 -246 190 14 246 190 14 246 190 14 246 190 14
45979 -246 190 14 246 190 14 246 190 14 246 190 14
45980 -246 190 14 246 190 14 241 196 14 226 184 13
45981 - 61 42 6 2 2 6 2 2 6 2 2 6
45982 - 22 22 22 238 238 238 253 253 253 253 253 253
45983 -253 253 253 253 253 253 253 253 253 253 253 253
45984 -253 253 253 253 253 253 253 253 253 253 253 253
45985 -253 253 253 253 253 253 253 253 253 253 253 253
45986 -253 253 253 226 226 226 187 187 187 180 133 36
45987 -216 158 10 236 178 12 239 182 13 236 178 12
45988 -230 174 11 226 170 11 226 170 11 230 174 11
45989 -236 178 12 242 186 14 246 190 14 246 190 14
45990 -246 190 14 246 190 14 246 186 14 239 182 13
45991 -206 162 42 106 106 106 66 66 66 34 34 34
45992 - 14 14 14 6 6 6 0 0 0 0 0 0
45993 - 0 0 0 0 0 0 0 0 0 0 0 0
45994 - 0 0 0 0 0 0 0 0 0 0 0 0
45995 - 0 0 0 0 0 0 0 0 0 6 6 6
45996 - 26 26 26 70 70 70 163 133 67 213 154 11
45997 -236 178 12 246 190 14 246 190 14 246 190 14
45998 -246 190 14 246 190 14 246 190 14 246 190 14
45999 -246 190 14 246 190 14 246 190 14 246 190 14
46000 -246 190 14 246 190 14 246 190 14 241 196 14
46001 -190 146 13 18 14 6 2 2 6 2 2 6
46002 - 46 46 46 246 246 246 253 253 253 253 253 253
46003 -253 253 253 253 253 253 253 253 253 253 253 253
46004 -253 253 253 253 253 253 253 253 253 253 253 253
46005 -253 253 253 253 253 253 253 253 253 253 253 253
46006 -253 253 253 221 221 221 86 86 86 156 107 11
46007 -216 158 10 236 178 12 242 186 14 246 186 14
46008 -242 186 14 239 182 13 239 182 13 242 186 14
46009 -242 186 14 246 186 14 246 190 14 246 190 14
46010 -246 190 14 246 190 14 246 190 14 246 190 14
46011 -242 186 14 225 175 15 142 122 72 66 66 66
46012 - 30 30 30 10 10 10 0 0 0 0 0 0
46013 - 0 0 0 0 0 0 0 0 0 0 0 0
46014 - 0 0 0 0 0 0 0 0 0 0 0 0
46015 - 0 0 0 0 0 0 0 0 0 6 6 6
46016 - 26 26 26 70 70 70 163 133 67 210 150 10
46017 -236 178 12 246 190 14 246 190 14 246 190 14
46018 -246 190 14 246 190 14 246 190 14 246 190 14
46019 -246 190 14 246 190 14 246 190 14 246 190 14
46020 -246 190 14 246 190 14 246 190 14 246 190 14
46021 -232 195 16 121 92 8 34 34 34 106 106 106
46022 -221 221 221 253 253 253 253 253 253 253 253 253
46023 -253 253 253 253 253 253 253 253 253 253 253 253
46024 -253 253 253 253 253 253 253 253 253 253 253 253
46025 -253 253 253 253 253 253 253 253 253 253 253 253
46026 -242 242 242 82 82 82 18 14 6 163 110 8
46027 -216 158 10 236 178 12 242 186 14 246 190 14
46028 -246 190 14 246 190 14 246 190 14 246 190 14
46029 -246 190 14 246 190 14 246 190 14 246 190 14
46030 -246 190 14 246 190 14 246 190 14 246 190 14
46031 -246 190 14 246 190 14 242 186 14 163 133 67
46032 - 46 46 46 18 18 18 6 6 6 0 0 0
46033 - 0 0 0 0 0 0 0 0 0 0 0 0
46034 - 0 0 0 0 0 0 0 0 0 0 0 0
46035 - 0 0 0 0 0 0 0 0 0 10 10 10
46036 - 30 30 30 78 78 78 163 133 67 210 150 10
46037 -236 178 12 246 186 14 246 190 14 246 190 14
46038 -246 190 14 246 190 14 246 190 14 246 190 14
46039 -246 190 14 246 190 14 246 190 14 246 190 14
46040 -246 190 14 246 190 14 246 190 14 246 190 14
46041 -241 196 14 215 174 15 190 178 144 253 253 253
46042 -253 253 253 253 253 253 253 253 253 253 253 253
46043 -253 253 253 253 253 253 253 253 253 253 253 253
46044 -253 253 253 253 253 253 253 253 253 253 253 253
46045 -253 253 253 253 253 253 253 253 253 218 218 218
46046 - 58 58 58 2 2 6 22 18 6 167 114 7
46047 -216 158 10 236 178 12 246 186 14 246 190 14
46048 -246 190 14 246 190 14 246 190 14 246 190 14
46049 -246 190 14 246 190 14 246 190 14 246 190 14
46050 -246 190 14 246 190 14 246 190 14 246 190 14
46051 -246 190 14 246 186 14 242 186 14 190 150 46
46052 - 54 54 54 22 22 22 6 6 6 0 0 0
46053 - 0 0 0 0 0 0 0 0 0 0 0 0
46054 - 0 0 0 0 0 0 0 0 0 0 0 0
46055 - 0 0 0 0 0 0 0 0 0 14 14 14
46056 - 38 38 38 86 86 86 180 133 36 213 154 11
46057 -236 178 12 246 186 14 246 190 14 246 190 14
46058 -246 190 14 246 190 14 246 190 14 246 190 14
46059 -246 190 14 246 190 14 246 190 14 246 190 14
46060 -246 190 14 246 190 14 246 190 14 246 190 14
46061 -246 190 14 232 195 16 190 146 13 214 214 214
46062 -253 253 253 253 253 253 253 253 253 253 253 253
46063 -253 253 253 253 253 253 253 253 253 253 253 253
46064 -253 253 253 253 253 253 253 253 253 253 253 253
46065 -253 253 253 250 250 250 170 170 170 26 26 26
46066 - 2 2 6 2 2 6 37 26 9 163 110 8
46067 -219 162 10 239 182 13 246 186 14 246 190 14
46068 -246 190 14 246 190 14 246 190 14 246 190 14
46069 -246 190 14 246 190 14 246 190 14 246 190 14
46070 -246 190 14 246 190 14 246 190 14 246 190 14
46071 -246 186 14 236 178 12 224 166 10 142 122 72
46072 - 46 46 46 18 18 18 6 6 6 0 0 0
46073 - 0 0 0 0 0 0 0 0 0 0 0 0
46074 - 0 0 0 0 0 0 0 0 0 0 0 0
46075 - 0 0 0 0 0 0 6 6 6 18 18 18
46076 - 50 50 50 109 106 95 192 133 9 224 166 10
46077 -242 186 14 246 190 14 246 190 14 246 190 14
46078 -246 190 14 246 190 14 246 190 14 246 190 14
46079 -246 190 14 246 190 14 246 190 14 246 190 14
46080 -246 190 14 246 190 14 246 190 14 246 190 14
46081 -242 186 14 226 184 13 210 162 10 142 110 46
46082 -226 226 226 253 253 253 253 253 253 253 253 253
46083 -253 253 253 253 253 253 253 253 253 253 253 253
46084 -253 253 253 253 253 253 253 253 253 253 253 253
46085 -198 198 198 66 66 66 2 2 6 2 2 6
46086 - 2 2 6 2 2 6 50 34 6 156 107 11
46087 -219 162 10 239 182 13 246 186 14 246 190 14
46088 -246 190 14 246 190 14 246 190 14 246 190 14
46089 -246 190 14 246 190 14 246 190 14 246 190 14
46090 -246 190 14 246 190 14 246 190 14 242 186 14
46091 -234 174 13 213 154 11 154 122 46 66 66 66
46092 - 30 30 30 10 10 10 0 0 0 0 0 0
46093 - 0 0 0 0 0 0 0 0 0 0 0 0
46094 - 0 0 0 0 0 0 0 0 0 0 0 0
46095 - 0 0 0 0 0 0 6 6 6 22 22 22
46096 - 58 58 58 154 121 60 206 145 10 234 174 13
46097 -242 186 14 246 186 14 246 190 14 246 190 14
46098 -246 190 14 246 190 14 246 190 14 246 190 14
46099 -246 190 14 246 190 14 246 190 14 246 190 14
46100 -246 190 14 246 190 14 246 190 14 246 190 14
46101 -246 186 14 236 178 12 210 162 10 163 110 8
46102 - 61 42 6 138 138 138 218 218 218 250 250 250
46103 -253 253 253 253 253 253 253 253 253 250 250 250
46104 -242 242 242 210 210 210 144 144 144 66 66 66
46105 - 6 6 6 2 2 6 2 2 6 2 2 6
46106 - 2 2 6 2 2 6 61 42 6 163 110 8
46107 -216 158 10 236 178 12 246 190 14 246 190 14
46108 -246 190 14 246 190 14 246 190 14 246 190 14
46109 -246 190 14 246 190 14 246 190 14 246 190 14
46110 -246 190 14 239 182 13 230 174 11 216 158 10
46111 -190 142 34 124 112 88 70 70 70 38 38 38
46112 - 18 18 18 6 6 6 0 0 0 0 0 0
46113 - 0 0 0 0 0 0 0 0 0 0 0 0
46114 - 0 0 0 0 0 0 0 0 0 0 0 0
46115 - 0 0 0 0 0 0 6 6 6 22 22 22
46116 - 62 62 62 168 124 44 206 145 10 224 166 10
46117 -236 178 12 239 182 13 242 186 14 242 186 14
46118 -246 186 14 246 190 14 246 190 14 246 190 14
46119 -246 190 14 246 190 14 246 190 14 246 190 14
46120 -246 190 14 246 190 14 246 190 14 246 190 14
46121 -246 190 14 236 178 12 216 158 10 175 118 6
46122 - 80 54 7 2 2 6 6 6 6 30 30 30
46123 - 54 54 54 62 62 62 50 50 50 38 38 38
46124 - 14 14 14 2 2 6 2 2 6 2 2 6
46125 - 2 2 6 2 2 6 2 2 6 2 2 6
46126 - 2 2 6 6 6 6 80 54 7 167 114 7
46127 -213 154 11 236 178 12 246 190 14 246 190 14
46128 -246 190 14 246 190 14 246 190 14 246 190 14
46129 -246 190 14 242 186 14 239 182 13 239 182 13
46130 -230 174 11 210 150 10 174 135 50 124 112 88
46131 - 82 82 82 54 54 54 34 34 34 18 18 18
46132 - 6 6 6 0 0 0 0 0 0 0 0 0
46133 - 0 0 0 0 0 0 0 0 0 0 0 0
46134 - 0 0 0 0 0 0 0 0 0 0 0 0
46135 - 0 0 0 0 0 0 6 6 6 18 18 18
46136 - 50 50 50 158 118 36 192 133 9 200 144 11
46137 -216 158 10 219 162 10 224 166 10 226 170 11
46138 -230 174 11 236 178 12 239 182 13 239 182 13
46139 -242 186 14 246 186 14 246 190 14 246 190 14
46140 -246 190 14 246 190 14 246 190 14 246 190 14
46141 -246 186 14 230 174 11 210 150 10 163 110 8
46142 -104 69 6 10 10 10 2 2 6 2 2 6
46143 - 2 2 6 2 2 6 2 2 6 2 2 6
46144 - 2 2 6 2 2 6 2 2 6 2 2 6
46145 - 2 2 6 2 2 6 2 2 6 2 2 6
46146 - 2 2 6 6 6 6 91 60 6 167 114 7
46147 -206 145 10 230 174 11 242 186 14 246 190 14
46148 -246 190 14 246 190 14 246 186 14 242 186 14
46149 -239 182 13 230 174 11 224 166 10 213 154 11
46150 -180 133 36 124 112 88 86 86 86 58 58 58
46151 - 38 38 38 22 22 22 10 10 10 6 6 6
46152 - 0 0 0 0 0 0 0 0 0 0 0 0
46153 - 0 0 0 0 0 0 0 0 0 0 0 0
46154 - 0 0 0 0 0 0 0 0 0 0 0 0
46155 - 0 0 0 0 0 0 0 0 0 14 14 14
46156 - 34 34 34 70 70 70 138 110 50 158 118 36
46157 -167 114 7 180 123 7 192 133 9 197 138 11
46158 -200 144 11 206 145 10 213 154 11 219 162 10
46159 -224 166 10 230 174 11 239 182 13 242 186 14
46160 -246 186 14 246 186 14 246 186 14 246 186 14
46161 -239 182 13 216 158 10 185 133 11 152 99 6
46162 -104 69 6 18 14 6 2 2 6 2 2 6
46163 - 2 2 6 2 2 6 2 2 6 2 2 6
46164 - 2 2 6 2 2 6 2 2 6 2 2 6
46165 - 2 2 6 2 2 6 2 2 6 2 2 6
46166 - 2 2 6 6 6 6 80 54 7 152 99 6
46167 -192 133 9 219 162 10 236 178 12 239 182 13
46168 -246 186 14 242 186 14 239 182 13 236 178 12
46169 -224 166 10 206 145 10 192 133 9 154 121 60
46170 - 94 94 94 62 62 62 42 42 42 22 22 22
46171 - 14 14 14 6 6 6 0 0 0 0 0 0
46172 - 0 0 0 0 0 0 0 0 0 0 0 0
46173 - 0 0 0 0 0 0 0 0 0 0 0 0
46174 - 0 0 0 0 0 0 0 0 0 0 0 0
46175 - 0 0 0 0 0 0 0 0 0 6 6 6
46176 - 18 18 18 34 34 34 58 58 58 78 78 78
46177 -101 98 89 124 112 88 142 110 46 156 107 11
46178 -163 110 8 167 114 7 175 118 6 180 123 7
46179 -185 133 11 197 138 11 210 150 10 219 162 10
46180 -226 170 11 236 178 12 236 178 12 234 174 13
46181 -219 162 10 197 138 11 163 110 8 130 83 6
46182 - 91 60 6 10 10 10 2 2 6 2 2 6
46183 - 18 18 18 38 38 38 38 38 38 38 38 38
46184 - 38 38 38 38 38 38 38 38 38 38 38 38
46185 - 38 38 38 38 38 38 26 26 26 2 2 6
46186 - 2 2 6 6 6 6 70 47 6 137 92 6
46187 -175 118 6 200 144 11 219 162 10 230 174 11
46188 -234 174 13 230 174 11 219 162 10 210 150 10
46189 -192 133 9 163 110 8 124 112 88 82 82 82
46190 - 50 50 50 30 30 30 14 14 14 6 6 6
46191 - 0 0 0 0 0 0 0 0 0 0 0 0
46192 - 0 0 0 0 0 0 0 0 0 0 0 0
46193 - 0 0 0 0 0 0 0 0 0 0 0 0
46194 - 0 0 0 0 0 0 0 0 0 0 0 0
46195 - 0 0 0 0 0 0 0 0 0 0 0 0
46196 - 6 6 6 14 14 14 22 22 22 34 34 34
46197 - 42 42 42 58 58 58 74 74 74 86 86 86
46198 -101 98 89 122 102 70 130 98 46 121 87 25
46199 -137 92 6 152 99 6 163 110 8 180 123 7
46200 -185 133 11 197 138 11 206 145 10 200 144 11
46201 -180 123 7 156 107 11 130 83 6 104 69 6
46202 - 50 34 6 54 54 54 110 110 110 101 98 89
46203 - 86 86 86 82 82 82 78 78 78 78 78 78
46204 - 78 78 78 78 78 78 78 78 78 78 78 78
46205 - 78 78 78 82 82 82 86 86 86 94 94 94
46206 -106 106 106 101 101 101 86 66 34 124 80 6
46207 -156 107 11 180 123 7 192 133 9 200 144 11
46208 -206 145 10 200 144 11 192 133 9 175 118 6
46209 -139 102 15 109 106 95 70 70 70 42 42 42
46210 - 22 22 22 10 10 10 0 0 0 0 0 0
46211 - 0 0 0 0 0 0 0 0 0 0 0 0
46212 - 0 0 0 0 0 0 0 0 0 0 0 0
46213 - 0 0 0 0 0 0 0 0 0 0 0 0
46214 - 0 0 0 0 0 0 0 0 0 0 0 0
46215 - 0 0 0 0 0 0 0 0 0 0 0 0
46216 - 0 0 0 0 0 0 6 6 6 10 10 10
46217 - 14 14 14 22 22 22 30 30 30 38 38 38
46218 - 50 50 50 62 62 62 74 74 74 90 90 90
46219 -101 98 89 112 100 78 121 87 25 124 80 6
46220 -137 92 6 152 99 6 152 99 6 152 99 6
46221 -138 86 6 124 80 6 98 70 6 86 66 30
46222 -101 98 89 82 82 82 58 58 58 46 46 46
46223 - 38 38 38 34 34 34 34 34 34 34 34 34
46224 - 34 34 34 34 34 34 34 34 34 34 34 34
46225 - 34 34 34 34 34 34 38 38 38 42 42 42
46226 - 54 54 54 82 82 82 94 86 76 91 60 6
46227 -134 86 6 156 107 11 167 114 7 175 118 6
46228 -175 118 6 167 114 7 152 99 6 121 87 25
46229 -101 98 89 62 62 62 34 34 34 18 18 18
46230 - 6 6 6 0 0 0 0 0 0 0 0 0
46231 - 0 0 0 0 0 0 0 0 0 0 0 0
46232 - 0 0 0 0 0 0 0 0 0 0 0 0
46233 - 0 0 0 0 0 0 0 0 0 0 0 0
46234 - 0 0 0 0 0 0 0 0 0 0 0 0
46235 - 0 0 0 0 0 0 0 0 0 0 0 0
46236 - 0 0 0 0 0 0 0 0 0 0 0 0
46237 - 0 0 0 6 6 6 6 6 6 10 10 10
46238 - 18 18 18 22 22 22 30 30 30 42 42 42
46239 - 50 50 50 66 66 66 86 86 86 101 98 89
46240 -106 86 58 98 70 6 104 69 6 104 69 6
46241 -104 69 6 91 60 6 82 62 34 90 90 90
46242 - 62 62 62 38 38 38 22 22 22 14 14 14
46243 - 10 10 10 10 10 10 10 10 10 10 10 10
46244 - 10 10 10 10 10 10 6 6 6 10 10 10
46245 - 10 10 10 10 10 10 10 10 10 14 14 14
46246 - 22 22 22 42 42 42 70 70 70 89 81 66
46247 - 80 54 7 104 69 6 124 80 6 137 92 6
46248 -134 86 6 116 81 8 100 82 52 86 86 86
46249 - 58 58 58 30 30 30 14 14 14 6 6 6
46250 - 0 0 0 0 0 0 0 0 0 0 0 0
46251 - 0 0 0 0 0 0 0 0 0 0 0 0
46252 - 0 0 0 0 0 0 0 0 0 0 0 0
46253 - 0 0 0 0 0 0 0 0 0 0 0 0
46254 - 0 0 0 0 0 0 0 0 0 0 0 0
46255 - 0 0 0 0 0 0 0 0 0 0 0 0
46256 - 0 0 0 0 0 0 0 0 0 0 0 0
46257 - 0 0 0 0 0 0 0 0 0 0 0 0
46258 - 0 0 0 6 6 6 10 10 10 14 14 14
46259 - 18 18 18 26 26 26 38 38 38 54 54 54
46260 - 70 70 70 86 86 86 94 86 76 89 81 66
46261 - 89 81 66 86 86 86 74 74 74 50 50 50
46262 - 30 30 30 14 14 14 6 6 6 0 0 0
46263 - 0 0 0 0 0 0 0 0 0 0 0 0
46264 - 0 0 0 0 0 0 0 0 0 0 0 0
46265 - 0 0 0 0 0 0 0 0 0 0 0 0
46266 - 6 6 6 18 18 18 34 34 34 58 58 58
46267 - 82 82 82 89 81 66 89 81 66 89 81 66
46268 - 94 86 66 94 86 76 74 74 74 50 50 50
46269 - 26 26 26 14 14 14 6 6 6 0 0 0
46270 - 0 0 0 0 0 0 0 0 0 0 0 0
46271 - 0 0 0 0 0 0 0 0 0 0 0 0
46272 - 0 0 0 0 0 0 0 0 0 0 0 0
46273 - 0 0 0 0 0 0 0 0 0 0 0 0
46274 - 0 0 0 0 0 0 0 0 0 0 0 0
46275 - 0 0 0 0 0 0 0 0 0 0 0 0
46276 - 0 0 0 0 0 0 0 0 0 0 0 0
46277 - 0 0 0 0 0 0 0 0 0 0 0 0
46278 - 0 0 0 0 0 0 0 0 0 0 0 0
46279 - 6 6 6 6 6 6 14 14 14 18 18 18
46280 - 30 30 30 38 38 38 46 46 46 54 54 54
46281 - 50 50 50 42 42 42 30 30 30 18 18 18
46282 - 10 10 10 0 0 0 0 0 0 0 0 0
46283 - 0 0 0 0 0 0 0 0 0 0 0 0
46284 - 0 0 0 0 0 0 0 0 0 0 0 0
46285 - 0 0 0 0 0 0 0 0 0 0 0 0
46286 - 0 0 0 6 6 6 14 14 14 26 26 26
46287 - 38 38 38 50 50 50 58 58 58 58 58 58
46288 - 54 54 54 42 42 42 30 30 30 18 18 18
46289 - 10 10 10 0 0 0 0 0 0 0 0 0
46290 - 0 0 0 0 0 0 0 0 0 0 0 0
46291 - 0 0 0 0 0 0 0 0 0 0 0 0
46292 - 0 0 0 0 0 0 0 0 0 0 0 0
46293 - 0 0 0 0 0 0 0 0 0 0 0 0
46294 - 0 0 0 0 0 0 0 0 0 0 0 0
46295 - 0 0 0 0 0 0 0 0 0 0 0 0
46296 - 0 0 0 0 0 0 0 0 0 0 0 0
46297 - 0 0 0 0 0 0 0 0 0 0 0 0
46298 - 0 0 0 0 0 0 0 0 0 0 0 0
46299 - 0 0 0 0 0 0 0 0 0 6 6 6
46300 - 6 6 6 10 10 10 14 14 14 18 18 18
46301 - 18 18 18 14 14 14 10 10 10 6 6 6
46302 - 0 0 0 0 0 0 0 0 0 0 0 0
46303 - 0 0 0 0 0 0 0 0 0 0 0 0
46304 - 0 0 0 0 0 0 0 0 0 0 0 0
46305 - 0 0 0 0 0 0 0 0 0 0 0 0
46306 - 0 0 0 0 0 0 0 0 0 6 6 6
46307 - 14 14 14 18 18 18 22 22 22 22 22 22
46308 - 18 18 18 14 14 14 10 10 10 6 6 6
46309 - 0 0 0 0 0 0 0 0 0 0 0 0
46310 - 0 0 0 0 0 0 0 0 0 0 0 0
46311 - 0 0 0 0 0 0 0 0 0 0 0 0
46312 - 0 0 0 0 0 0 0 0 0 0 0 0
46313 - 0 0 0 0 0 0 0 0 0 0 0 0
46314 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46315 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46316 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46317 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46318 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46319 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46320 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46321 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46322 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46323 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46324 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46325 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46326 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46327 +4 4 4 4 4 4
46328 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46329 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46330 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46331 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46332 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46333 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46334 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46335 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46336 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46337 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46338 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46339 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46340 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46341 +4 4 4 4 4 4
46342 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46343 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46344 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46345 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46346 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46347 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46348 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46349 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46350 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46351 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46352 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46353 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46354 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46355 +4 4 4 4 4 4
46356 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46357 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46358 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46359 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46360 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46361 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46362 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46363 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46364 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46365 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46366 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46367 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46368 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46369 +4 4 4 4 4 4
46370 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46371 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46372 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46373 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46374 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46375 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46376 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46377 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46378 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46379 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46380 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46381 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46382 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46383 +4 4 4 4 4 4
46384 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46385 +4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
46389 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46390 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46391 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46392 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46393 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46394 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46395 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46396 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46397 +4 4 4 4 4 4
46398 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46399 +4 4 4 4 4 4 4 4 4 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 4 4 4 3 3 3 0 0 0 0 0 0
46403 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
46404 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46405 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46406 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46407 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
46408 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46409 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
46410 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46411 +4 4 4 4 4 4
46412 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46413 +4 4 4 4 4 4 4 4 4 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 2 2 2 0 0 0 3 4 3 26 28 28
46417 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46418 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46419 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46420 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46421 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
46422 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46423 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46424 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46425 +4 4 4 4 4 4
46426 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46427 +4 4 4 4 4 4 4 4 4 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 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46431 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46432 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46433 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46434 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46435 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
46436 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46437 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46438 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46439 +4 4 4 4 4 4
46440 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46441 +4 4 4 4 4 4 4 4 4 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 5 5 5 5 5 5 2 2 2 0 0 0
46444 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46445 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46446 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
46447 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46448 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46449 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46450 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46451 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46452 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
46453 +4 4 4 4 4 4
46454 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46455 +4 4 4 4 4 4 4 4 4 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 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46458 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46459 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46460 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46461 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46462 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46463 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46464 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46465 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46466 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
46467 +4 4 4 4 4 4
46468 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46469 +4 4 4 4 4 4 4 4 4 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 5 5 5
46471 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46472 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46473 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46474 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46475 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46476 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46477 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46478 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46479 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46480 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
46481 +4 4 4 4 4 4
46482 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46483 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46484 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
46485 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
46486 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
46487 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
46488 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
46489 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
46490 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
46491 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
46492 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
46493 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
46494 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
46495 +4 4 4 4 4 4
46496 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46497 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46498 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
46499 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
46500 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
46501 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
46502 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
46503 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
46504 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
46505 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
46506 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
46507 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
46508 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
46509 +4 4 4 4 4 4
46510 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46511 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46512 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
46513 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
46514 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
46515 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
46516 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
46517 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
46518 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
46519 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
46520 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
46521 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
46522 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46523 +4 4 4 4 4 4
46524 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46525 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46526 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
46527 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
46528 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
46529 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
46530 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
46531 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
46532 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
46533 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
46534 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
46535 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
46536 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
46537 +4 4 4 4 4 4
46538 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46539 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
46540 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
46541 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
46542 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
46543 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
46544 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
46545 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
46546 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
46547 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
46548 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
46549 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
46550 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
46551 +4 4 4 4 4 4
46552 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46553 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
46554 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
46555 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
46556 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
46557 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
46558 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
46559 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
46560 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
46561 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
46562 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
46563 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
46564 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
46565 +0 0 0 4 4 4
46566 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46567 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
46568 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
46569 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
46570 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
46571 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
46572 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
46573 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
46574 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
46575 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
46576 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
46577 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
46578 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
46579 +2 0 0 0 0 0
46580 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
46581 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
46582 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
46583 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
46584 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
46585 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
46586 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
46587 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
46588 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
46589 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
46590 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
46591 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
46592 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
46593 +37 38 37 0 0 0
46594 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46595 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
46596 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
46597 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
46598 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
46599 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
46600 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
46601 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
46602 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
46603 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
46604 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
46605 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
46606 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
46607 +85 115 134 4 0 0
46608 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
46609 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
46610 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
46611 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
46612 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
46613 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
46614 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
46615 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
46616 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
46617 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
46618 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
46619 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
46620 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
46621 +60 73 81 4 0 0
46622 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
46623 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
46624 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
46625 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
46626 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
46627 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
46628 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
46629 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
46630 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
46631 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
46632 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
46633 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
46634 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
46635 +16 19 21 4 0 0
46636 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
46637 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
46638 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
46639 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
46640 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
46641 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
46642 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
46643 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
46644 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
46645 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
46646 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
46647 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
46648 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
46649 +4 0 0 4 3 3
46650 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
46651 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
46652 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
46653 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
46654 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
46655 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
46656 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
46657 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
46658 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
46659 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
46660 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
46661 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
46662 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
46663 +3 2 2 4 4 4
46664 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
46665 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
46666 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
46667 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46668 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
46669 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
46670 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
46671 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
46672 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
46673 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
46674 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
46675 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
46676 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
46677 +4 4 4 4 4 4
46678 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
46679 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
46680 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
46681 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
46682 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
46683 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
46684 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
46685 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
46686 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
46687 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
46688 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
46689 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
46690 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
46691 +4 4 4 4 4 4
46692 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
46693 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
46694 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
46695 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
46696 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
46697 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
46698 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
46699 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
46700 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
46701 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
46702 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
46703 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
46704 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
46705 +5 5 5 5 5 5
46706 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
46707 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
46708 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
46709 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
46710 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
46711 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46712 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
46713 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
46714 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
46715 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
46716 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
46717 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
46718 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
46719 +5 5 5 4 4 4
46720 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
46721 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
46722 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
46723 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
46724 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46725 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
46726 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
46727 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
46728 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
46729 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
46730 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
46731 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
46732 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46733 +4 4 4 4 4 4
46734 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
46735 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
46736 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
46737 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
46738 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
46739 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46740 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46741 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
46742 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
46743 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
46744 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
46745 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
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
46748 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
46749 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
46750 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
46751 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
46752 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46753 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
46754 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
46755 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
46756 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
46757 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
46758 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
46759 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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
46762 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
46763 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
46764 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
46765 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
46766 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46767 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46768 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
46769 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
46770 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
46771 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
46772 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
46773 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 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
46776 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
46777 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
46778 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
46779 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
46780 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46781 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
46782 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
46783 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
46784 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
46785 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
46786 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46787 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 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
46790 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
46791 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
46792 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
46793 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
46794 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
46795 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
46796 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
46797 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
46798 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
46799 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
46800 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
46801 +4 4 4 4 4 4 4 4 4 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
46804 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
46805 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
46806 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
46807 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
46808 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
46809 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
46810 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
46811 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
46812 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
46813 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
46814 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
46815 +4 4 4 4 4 4 4 4 4 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
46818 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
46819 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
46820 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
46821 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
46822 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
46823 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
46824 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
46825 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
46826 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
46827 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
46828 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46829 +4 4 4 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
46832 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
46833 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
46834 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
46835 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
46836 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46837 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
46838 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
46839 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
46840 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
46841 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
46842 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
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
46846 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
46847 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
46848 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
46849 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
46850 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46851 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
46852 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
46853 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
46854 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
46855 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
46856 +4 0 0 3 3 3 5 5 5 4 4 4 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
46860 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
46861 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
46862 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
46863 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
46864 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46865 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
46866 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
46867 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
46868 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
46869 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46870 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46871 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46872 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46873 +4 4 4 4 4 4
46874 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
46875 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
46876 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
46877 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
46878 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
46879 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
46880 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
46881 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
46882 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46883 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46884 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46885 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46886 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46887 +4 4 4 4 4 4
46888 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
46889 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
46890 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
46891 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
46892 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46893 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
46894 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
46895 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
46896 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46897 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46898 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46899 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46900 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46901 +4 4 4 4 4 4
46902 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
46903 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
46904 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
46905 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
46906 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
46907 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
46908 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
46909 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
46910 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46911 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46912 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46913 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46914 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46915 +4 4 4 4 4 4
46916 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
46917 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
46918 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46919 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
46920 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
46921 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
46922 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
46923 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
46924 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
46925 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46926 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46927 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46928 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46929 +4 4 4 4 4 4
46930 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
46931 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
46932 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
46933 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
46934 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
46935 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
46936 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
46937 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
46938 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46939 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46940 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46941 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46942 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46943 +4 4 4 4 4 4
46944 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
46945 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
46946 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46947 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
46948 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
46949 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
46950 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
46951 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
46952 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
46953 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46954 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46955 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46956 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46957 +4 4 4 4 4 4
46958 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
46959 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
46960 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
46961 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
46962 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
46963 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
46964 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
46965 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
46966 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46967 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46968 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46969 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46970 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46971 +4 4 4 4 4 4
46972 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
46973 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
46974 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
46975 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
46976 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
46977 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
46978 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
46979 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
46980 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
46981 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46982 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46983 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46984 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46985 +4 4 4 4 4 4
46986 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
46987 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
46988 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
46989 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
46990 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
46991 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
46992 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
46993 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
46994 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
46995 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
46996 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
46997 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46998 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46999 +4 4 4 4 4 4
47000 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47001 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
47002 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
47003 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47004 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
47005 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
47006 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47007 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
47008 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47009 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47010 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47011 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47012 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47013 +4 4 4 4 4 4
47014 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47015 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
47016 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
47017 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
47018 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
47019 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
47020 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
47021 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
47022 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
47023 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47024 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47025 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47026 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47027 +4 4 4 4 4 4
47028 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47029 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
47030 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
47031 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
47032 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
47033 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
47034 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
47035 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
47036 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
47037 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47038 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47039 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47040 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47041 +4 4 4 4 4 4
47042 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
47043 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
47044 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
47045 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
47046 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47047 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
47048 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
47049 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
47050 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
47051 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47052 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47053 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47054 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47055 +4 4 4 4 4 4
47056 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47057 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
47058 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
47059 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
47060 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
47061 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
47062 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
47063 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
47064 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
47065 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47066 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47067 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47068 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47069 +4 4 4 4 4 4
47070 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
47071 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
47072 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
47073 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
47074 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
47075 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
47076 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
47077 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
47078 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
47079 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
47080 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47081 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47082 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47083 +4 4 4 4 4 4
47084 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
47085 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47086 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
47087 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
47088 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
47089 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
47090 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
47091 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
47092 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
47093 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
47094 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47095 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47096 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47097 +4 4 4 4 4 4
47098 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
47099 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47100 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
47101 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
47102 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
47103 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
47104 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47105 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
47106 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
47107 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
47108 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47109 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47110 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47111 +4 4 4 4 4 4
47112 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
47113 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
47114 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
47115 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
47116 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
47117 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
47118 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
47119 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
47120 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
47121 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
47122 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47123 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47124 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47125 +4 4 4 4 4 4
47126 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
47127 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
47128 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47129 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
47130 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
47131 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
47132 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
47133 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
47134 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
47135 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
47136 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47137 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47138 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47139 +4 4 4 4 4 4
47140 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47141 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
47142 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
47143 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
47144 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
47145 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
47146 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
47147 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
47148 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
47149 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47150 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47151 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47152 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47153 +4 4 4 4 4 4
47154 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
47155 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
47156 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
47157 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
47158 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
47159 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
47160 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
47161 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
47162 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
47163 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47164 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47165 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47166 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47167 +4 4 4 4 4 4
47168 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
47169 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
47170 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
47171 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
47172 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
47173 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
47174 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
47175 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
47176 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47177 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47178 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47179 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47180 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47181 +4 4 4 4 4 4
47182 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
47183 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47184 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
47185 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47186 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
47187 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
47188 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
47189 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
47190 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
47191 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47192 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47193 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47194 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47195 +4 4 4 4 4 4
47196 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
47197 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
47198 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
47199 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
47200 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
47201 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
47202 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
47203 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
47204 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
47205 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47206 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47207 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47208 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47209 +4 4 4 4 4 4
47210 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47211 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
47212 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
47213 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
47214 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
47215 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
47216 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
47217 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
47218 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47219 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47220 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47221 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47222 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47223 +4 4 4 4 4 4
47224 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
47225 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
47226 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47227 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
47228 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
47229 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
47230 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
47231 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
47232 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47233 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47234 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47235 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47236 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47237 +4 4 4 4 4 4
47238 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47239 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
47240 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
47241 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
47242 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
47243 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
47244 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
47245 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47246 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47247 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47248 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47249 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47250 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47251 +4 4 4 4 4 4
47252 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47253 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
47254 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47255 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
47256 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
47257 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
47258 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
47259 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
47260 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47261 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47262 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47263 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47264 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47265 +4 4 4 4 4 4
47266 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47267 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
47268 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
47269 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
47270 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
47271 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
47272 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
47273 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
47274 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47275 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47276 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47277 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47278 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47279 +4 4 4 4 4 4
47280 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47281 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47282 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
47283 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47284 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
47285 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
47286 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
47287 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47288 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47289 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47290 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47291 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47292 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47293 +4 4 4 4 4 4
47294 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47295 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47296 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47297 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
47298 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
47299 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
47300 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
47301 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47302 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47303 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47304 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47305 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47306 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47307 +4 4 4 4 4 4
47308 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47309 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47310 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47311 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47312 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
47313 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
47314 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
47315 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47316 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47317 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47318 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47319 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47320 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47321 +4 4 4 4 4 4
47322 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47323 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47324 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47325 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47326 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47327 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
47328 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
47329 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47330 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47331 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47332 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47333 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47334 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47335 +4 4 4 4 4 4
47336 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47337 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47338 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47339 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47340 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47341 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47342 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
47343 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47344 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47345 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47346 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47347 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47348 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47349 +4 4 4 4 4 4
47350 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47351 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47352 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47353 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
47354 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
47355 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
47356 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
47357 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47358 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47359 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47360 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47361 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47362 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47363 +4 4 4 4 4 4
47364 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47365 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47366 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47367 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47368 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
47369 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47370 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47371 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47372 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47373 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47374 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47375 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47376 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47377 +4 4 4 4 4 4
47378 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47379 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47380 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47381 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47382 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47383 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47384 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
47385 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47386 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47387 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47388 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47389 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47390 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47391 +4 4 4 4 4 4
47392 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47393 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47394 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47395 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47396 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47397 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47398 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47399 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47400 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47401 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47402 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47403 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47404 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47405 +4 4 4 4 4 4
47406 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47407 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47408 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47409 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47410 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
47411 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
47412 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47413 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47414 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47415 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47416 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47417 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47418 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47419 +4 4 4 4 4 4
47420 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47421 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47422 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47423 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47424 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47425 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
47426 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47427 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47428 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47429 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47430 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47431 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47432 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47433 +4 4 4 4 4 4
47434 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47435 index fe92eed..106e085 100644
47436 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47437 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47438 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47439 struct mb862xxfb_par *par = info->par;
47440
47441 if (info->var.bits_per_pixel == 32) {
47442 - info->fbops->fb_fillrect = cfb_fillrect;
47443 - info->fbops->fb_copyarea = cfb_copyarea;
47444 - info->fbops->fb_imageblit = cfb_imageblit;
47445 + pax_open_kernel();
47446 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47447 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47448 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47449 + pax_close_kernel();
47450 } else {
47451 outreg(disp, GC_L0EM, 3);
47452 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47453 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47454 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47455 + pax_open_kernel();
47456 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47457 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47458 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47459 + pax_close_kernel();
47460 }
47461 outreg(draw, GDC_REG_DRAW_BASE, 0);
47462 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47463 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47464 index ff22871..b129bed 100644
47465 --- a/drivers/video/nvidia/nvidia.c
47466 +++ b/drivers/video/nvidia/nvidia.c
47467 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47468 info->fix.line_length = (info->var.xres_virtual *
47469 info->var.bits_per_pixel) >> 3;
47470 if (info->var.accel_flags) {
47471 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47472 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47473 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47474 - info->fbops->fb_sync = nvidiafb_sync;
47475 + pax_open_kernel();
47476 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47477 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47478 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47479 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47480 + pax_close_kernel();
47481 info->pixmap.scan_align = 4;
47482 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47483 info->flags |= FBINFO_READS_FAST;
47484 NVResetGraphics(info);
47485 } else {
47486 - info->fbops->fb_imageblit = cfb_imageblit;
47487 - info->fbops->fb_fillrect = cfb_fillrect;
47488 - info->fbops->fb_copyarea = cfb_copyarea;
47489 - info->fbops->fb_sync = NULL;
47490 + pax_open_kernel();
47491 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47492 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47493 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47494 + *(void **)&info->fbops->fb_sync = NULL;
47495 + pax_close_kernel();
47496 info->pixmap.scan_align = 1;
47497 info->flags |= FBINFO_HWACCEL_DISABLED;
47498 info->flags &= ~FBINFO_READS_FAST;
47499 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
47500 info->pixmap.size = 8 * 1024;
47501 info->pixmap.flags = FB_PIXMAP_SYSTEM;
47502
47503 - if (!hwcur)
47504 - info->fbops->fb_cursor = NULL;
47505 + if (!hwcur) {
47506 + pax_open_kernel();
47507 + *(void **)&info->fbops->fb_cursor = NULL;
47508 + pax_close_kernel();
47509 + }
47510
47511 info->var.accel_flags = (!noaccel);
47512
47513 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
47514 index 76d9053..dec2bfd 100644
47515 --- a/drivers/video/s1d13xxxfb.c
47516 +++ b/drivers/video/s1d13xxxfb.c
47517 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
47518
47519 switch(prod_id) {
47520 case S1D13506_PROD_ID: /* activate acceleration */
47521 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47522 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47523 + pax_open_kernel();
47524 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47525 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47526 + pax_close_kernel();
47527 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
47528 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
47529 break;
47530 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
47531 index 97bd662..39fab85 100644
47532 --- a/drivers/video/smscufx.c
47533 +++ b/drivers/video/smscufx.c
47534 @@ -1171,7 +1171,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
47535 fb_deferred_io_cleanup(info);
47536 kfree(info->fbdefio);
47537 info->fbdefio = NULL;
47538 - info->fbops->fb_mmap = ufx_ops_mmap;
47539 + pax_open_kernel();
47540 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
47541 + pax_close_kernel();
47542 }
47543
47544 pr_debug("released /dev/fb%d user=%d count=%d",
47545 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
47546 index 86d449e..8e04dc5 100644
47547 --- a/drivers/video/udlfb.c
47548 +++ b/drivers/video/udlfb.c
47549 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
47550 dlfb_urb_completion(urb);
47551
47552 error:
47553 - atomic_add(bytes_sent, &dev->bytes_sent);
47554 - atomic_add(bytes_identical, &dev->bytes_identical);
47555 - atomic_add(width*height*2, &dev->bytes_rendered);
47556 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47557 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47558 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
47559 end_cycles = get_cycles();
47560 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47561 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47562 >> 10)), /* Kcycles */
47563 &dev->cpu_kcycles_used);
47564
47565 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
47566 dlfb_urb_completion(urb);
47567
47568 error:
47569 - atomic_add(bytes_sent, &dev->bytes_sent);
47570 - atomic_add(bytes_identical, &dev->bytes_identical);
47571 - atomic_add(bytes_rendered, &dev->bytes_rendered);
47572 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47573 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47574 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
47575 end_cycles = get_cycles();
47576 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47577 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47578 >> 10)), /* Kcycles */
47579 &dev->cpu_kcycles_used);
47580 }
47581 @@ -989,7 +989,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
47582 fb_deferred_io_cleanup(info);
47583 kfree(info->fbdefio);
47584 info->fbdefio = NULL;
47585 - info->fbops->fb_mmap = dlfb_ops_mmap;
47586 + pax_open_kernel();
47587 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
47588 + pax_close_kernel();
47589 }
47590
47591 pr_warn("released /dev/fb%d user=%d count=%d\n",
47592 @@ -1372,7 +1374,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
47593 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47594 struct dlfb_data *dev = fb_info->par;
47595 return snprintf(buf, PAGE_SIZE, "%u\n",
47596 - atomic_read(&dev->bytes_rendered));
47597 + atomic_read_unchecked(&dev->bytes_rendered));
47598 }
47599
47600 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47601 @@ -1380,7 +1382,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47602 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47603 struct dlfb_data *dev = fb_info->par;
47604 return snprintf(buf, PAGE_SIZE, "%u\n",
47605 - atomic_read(&dev->bytes_identical));
47606 + atomic_read_unchecked(&dev->bytes_identical));
47607 }
47608
47609 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47610 @@ -1388,7 +1390,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47611 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47612 struct dlfb_data *dev = fb_info->par;
47613 return snprintf(buf, PAGE_SIZE, "%u\n",
47614 - atomic_read(&dev->bytes_sent));
47615 + atomic_read_unchecked(&dev->bytes_sent));
47616 }
47617
47618 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47619 @@ -1396,7 +1398,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47620 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47621 struct dlfb_data *dev = fb_info->par;
47622 return snprintf(buf, PAGE_SIZE, "%u\n",
47623 - atomic_read(&dev->cpu_kcycles_used));
47624 + atomic_read_unchecked(&dev->cpu_kcycles_used));
47625 }
47626
47627 static ssize_t edid_show(
47628 @@ -1456,10 +1458,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
47629 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47630 struct dlfb_data *dev = fb_info->par;
47631
47632 - atomic_set(&dev->bytes_rendered, 0);
47633 - atomic_set(&dev->bytes_identical, 0);
47634 - atomic_set(&dev->bytes_sent, 0);
47635 - atomic_set(&dev->cpu_kcycles_used, 0);
47636 + atomic_set_unchecked(&dev->bytes_rendered, 0);
47637 + atomic_set_unchecked(&dev->bytes_identical, 0);
47638 + atomic_set_unchecked(&dev->bytes_sent, 0);
47639 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
47640
47641 return count;
47642 }
47643 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
47644 index d428445..79a78df 100644
47645 --- a/drivers/video/uvesafb.c
47646 +++ b/drivers/video/uvesafb.c
47647 @@ -19,6 +19,7 @@
47648 #include <linux/io.h>
47649 #include <linux/mutex.h>
47650 #include <linux/slab.h>
47651 +#include <linux/moduleloader.h>
47652 #include <video/edid.h>
47653 #include <video/uvesafb.h>
47654 #ifdef CONFIG_X86
47655 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
47656 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
47657 par->pmi_setpal = par->ypan = 0;
47658 } else {
47659 +
47660 +#ifdef CONFIG_PAX_KERNEXEC
47661 +#ifdef CONFIG_MODULES
47662 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
47663 +#endif
47664 + if (!par->pmi_code) {
47665 + par->pmi_setpal = par->ypan = 0;
47666 + return 0;
47667 + }
47668 +#endif
47669 +
47670 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
47671 + task->t.regs.edi);
47672 +
47673 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47674 + pax_open_kernel();
47675 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
47676 + pax_close_kernel();
47677 +
47678 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
47679 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
47680 +#else
47681 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
47682 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
47683 +#endif
47684 +
47685 printk(KERN_INFO "uvesafb: protected mode interface info at "
47686 "%04x:%04x\n",
47687 (u16)task->t.regs.es, (u16)task->t.regs.edi);
47688 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
47689 par->ypan = ypan;
47690
47691 if (par->pmi_setpal || par->ypan) {
47692 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
47693 if (__supported_pte_mask & _PAGE_NX) {
47694 par->pmi_setpal = par->ypan = 0;
47695 printk(KERN_WARNING "uvesafb: NX protection is actively."
47696 "We have better not to use the PMI.\n");
47697 - } else {
47698 + } else
47699 +#endif
47700 uvesafb_vbe_getpmi(task, par);
47701 - }
47702 }
47703 #else
47704 /* The protected mode interface is not available on non-x86. */
47705 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
47706 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
47707
47708 /* Disable blanking if the user requested so. */
47709 - if (!blank)
47710 - info->fbops->fb_blank = NULL;
47711 + if (!blank) {
47712 + pax_open_kernel();
47713 + *(void **)&info->fbops->fb_blank = NULL;
47714 + pax_close_kernel();
47715 + }
47716
47717 /*
47718 * Find out how much IO memory is required for the mode with
47719 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
47720 info->flags = FBINFO_FLAG_DEFAULT |
47721 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
47722
47723 - if (!par->ypan)
47724 - info->fbops->fb_pan_display = NULL;
47725 + if (!par->ypan) {
47726 + pax_open_kernel();
47727 + *(void **)&info->fbops->fb_pan_display = NULL;
47728 + pax_close_kernel();
47729 + }
47730 }
47731
47732 static void uvesafb_init_mtrr(struct fb_info *info)
47733 @@ -1836,6 +1866,11 @@ out:
47734 if (par->vbe_modes)
47735 kfree(par->vbe_modes);
47736
47737 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47738 + if (par->pmi_code)
47739 + module_free_exec(NULL, par->pmi_code);
47740 +#endif
47741 +
47742 framebuffer_release(info);
47743 return err;
47744 }
47745 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
47746 kfree(par->vbe_state_orig);
47747 if (par->vbe_state_saved)
47748 kfree(par->vbe_state_saved);
47749 +
47750 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47751 + if (par->pmi_code)
47752 + module_free_exec(NULL, par->pmi_code);
47753 +#endif
47754 +
47755 }
47756
47757 framebuffer_release(info);
47758 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
47759 index 501b340..d80aa17 100644
47760 --- a/drivers/video/vesafb.c
47761 +++ b/drivers/video/vesafb.c
47762 @@ -9,6 +9,7 @@
47763 */
47764
47765 #include <linux/module.h>
47766 +#include <linux/moduleloader.h>
47767 #include <linux/kernel.h>
47768 #include <linux/errno.h>
47769 #include <linux/string.h>
47770 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
47771 static int vram_total __initdata; /* Set total amount of memory */
47772 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
47773 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
47774 -static void (*pmi_start)(void) __read_mostly;
47775 -static void (*pmi_pal) (void) __read_mostly;
47776 +static void (*pmi_start)(void) __read_only;
47777 +static void (*pmi_pal) (void) __read_only;
47778 static int depth __read_mostly;
47779 static int vga_compat __read_mostly;
47780 /* --------------------------------------------------------------------- */
47781 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
47782 unsigned int size_vmode;
47783 unsigned int size_remap;
47784 unsigned int size_total;
47785 + void *pmi_code = NULL;
47786
47787 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
47788 return -ENODEV;
47789 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
47790 size_remap = size_total;
47791 vesafb_fix.smem_len = size_remap;
47792
47793 -#ifndef __i386__
47794 - screen_info.vesapm_seg = 0;
47795 -#endif
47796 -
47797 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
47798 printk(KERN_WARNING
47799 "vesafb: cannot reserve video memory at 0x%lx\n",
47800 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
47801 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
47802 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
47803
47804 +#ifdef __i386__
47805 +
47806 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47807 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
47808 + if (!pmi_code)
47809 +#elif !defined(CONFIG_PAX_KERNEXEC)
47810 + if (0)
47811 +#endif
47812 +
47813 +#endif
47814 + screen_info.vesapm_seg = 0;
47815 +
47816 if (screen_info.vesapm_seg) {
47817 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
47818 - screen_info.vesapm_seg,screen_info.vesapm_off);
47819 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
47820 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
47821 }
47822
47823 if (screen_info.vesapm_seg < 0xc000)
47824 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
47825
47826 if (ypan || pmi_setpal) {
47827 unsigned short *pmi_base;
47828 +
47829 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
47830 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
47831 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
47832 +
47833 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47834 + pax_open_kernel();
47835 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
47836 +#else
47837 + pmi_code = pmi_base;
47838 +#endif
47839 +
47840 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
47841 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
47842 +
47843 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47844 + pmi_start = ktva_ktla(pmi_start);
47845 + pmi_pal = ktva_ktla(pmi_pal);
47846 + pax_close_kernel();
47847 +#endif
47848 +
47849 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
47850 if (pmi_base[3]) {
47851 printk(KERN_INFO "vesafb: pmi: ports = ");
47852 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
47853 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
47854 (ypan ? FBINFO_HWACCEL_YPAN : 0);
47855
47856 - if (!ypan)
47857 - info->fbops->fb_pan_display = NULL;
47858 + if (!ypan) {
47859 + pax_open_kernel();
47860 + *(void **)&info->fbops->fb_pan_display = NULL;
47861 + pax_close_kernel();
47862 + }
47863
47864 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
47865 err = -ENOMEM;
47866 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
47867 info->node, info->fix.id);
47868 return 0;
47869 err:
47870 +
47871 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
47872 + module_free_exec(NULL, pmi_code);
47873 +#endif
47874 +
47875 if (info->screen_base)
47876 iounmap(info->screen_base);
47877 framebuffer_release(info);
47878 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
47879 index 88714ae..16c2e11 100644
47880 --- a/drivers/video/via/via_clock.h
47881 +++ b/drivers/video/via/via_clock.h
47882 @@ -56,7 +56,7 @@ struct via_clock {
47883
47884 void (*set_engine_pll_state)(u8 state);
47885 void (*set_engine_pll)(struct via_pll_config config);
47886 -};
47887 +} __no_const;
47888
47889
47890 static inline u32 get_pll_internal_frequency(u32 ref_freq,
47891 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
47892 index fef20db..d28b1ab 100644
47893 --- a/drivers/xen/xenfs/xenstored.c
47894 +++ b/drivers/xen/xenfs/xenstored.c
47895 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
47896 static int xsd_kva_open(struct inode *inode, struct file *file)
47897 {
47898 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
47899 +#ifdef CONFIG_GRKERNSEC_HIDESYM
47900 + NULL);
47901 +#else
47902 xen_store_interface);
47903 +#endif
47904 +
47905 if (!file->private_data)
47906 return -ENOMEM;
47907 return 0;
47908 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
47909 index 0ad61c6..f198bd7 100644
47910 --- a/fs/9p/vfs_addr.c
47911 +++ b/fs/9p/vfs_addr.c
47912 @@ -185,7 +185,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
47913
47914 retval = v9fs_file_write_internal(inode,
47915 v9inode->writeback_fid,
47916 - (__force const char __user *)buffer,
47917 + (const char __force_user *)buffer,
47918 len, &offset, 0);
47919 if (retval > 0)
47920 retval = 0;
47921 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
47922 index d86edc8..40ff2fb 100644
47923 --- a/fs/9p/vfs_inode.c
47924 +++ b/fs/9p/vfs_inode.c
47925 @@ -1314,7 +1314,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
47926 void
47927 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
47928 {
47929 - char *s = nd_get_link(nd);
47930 + const char *s = nd_get_link(nd);
47931
47932 p9_debug(P9_DEBUG_VFS, " %s %s\n",
47933 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
47934 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
47935 index 0efd152..b5802ad 100644
47936 --- a/fs/Kconfig.binfmt
47937 +++ b/fs/Kconfig.binfmt
47938 @@ -89,7 +89,7 @@ config HAVE_AOUT
47939
47940 config BINFMT_AOUT
47941 tristate "Kernel support for a.out and ECOFF binaries"
47942 - depends on HAVE_AOUT
47943 + depends on HAVE_AOUT && BROKEN
47944 ---help---
47945 A.out (Assembler.OUTput) is a set of formats for libraries and
47946 executables used in the earliest versions of UNIX. Linux used
47947 diff --git a/fs/aio.c b/fs/aio.c
47948 index 1dc8786..d3b29e8 100644
47949 --- a/fs/aio.c
47950 +++ b/fs/aio.c
47951 @@ -111,7 +111,7 @@ static int aio_setup_ring(struct kioctx *ctx)
47952 size += sizeof(struct io_event) * nr_events;
47953 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
47954
47955 - if (nr_pages < 0)
47956 + if (nr_pages <= 0)
47957 return -EINVAL;
47958
47959 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
47960 @@ -1375,18 +1375,19 @@ static ssize_t aio_fsync(struct kiocb *iocb)
47961 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
47962 {
47963 ssize_t ret;
47964 + struct iovec iovstack;
47965
47966 #ifdef CONFIG_COMPAT
47967 if (compat)
47968 ret = compat_rw_copy_check_uvector(type,
47969 (struct compat_iovec __user *)kiocb->ki_buf,
47970 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
47971 + kiocb->ki_nbytes, 1, &iovstack,
47972 &kiocb->ki_iovec);
47973 else
47974 #endif
47975 ret = rw_copy_check_uvector(type,
47976 (struct iovec __user *)kiocb->ki_buf,
47977 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
47978 + kiocb->ki_nbytes, 1, &iovstack,
47979 &kiocb->ki_iovec);
47980 if (ret < 0)
47981 goto out;
47982 @@ -1395,6 +1396,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
47983 if (ret < 0)
47984 goto out;
47985
47986 + if (kiocb->ki_iovec == &iovstack) {
47987 + kiocb->ki_inline_vec = iovstack;
47988 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
47989 + }
47990 kiocb->ki_nr_segs = kiocb->ki_nbytes;
47991 kiocb->ki_cur_seg = 0;
47992 /* ki_nbytes/left now reflect bytes instead of segs */
47993 diff --git a/fs/attr.c b/fs/attr.c
47994 index 1449adb..a2038c2 100644
47995 --- a/fs/attr.c
47996 +++ b/fs/attr.c
47997 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
47998 unsigned long limit;
47999
48000 limit = rlimit(RLIMIT_FSIZE);
48001 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
48002 if (limit != RLIM_INFINITY && offset > limit)
48003 goto out_sig;
48004 if (offset > inode->i_sb->s_maxbytes)
48005 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
48006 index 3db70da..7aeec5b 100644
48007 --- a/fs/autofs4/waitq.c
48008 +++ b/fs/autofs4/waitq.c
48009 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
48010 {
48011 unsigned long sigpipe, flags;
48012 mm_segment_t fs;
48013 - const char *data = (const char *)addr;
48014 + const char __user *data = (const char __force_user *)addr;
48015 ssize_t wr = 0;
48016
48017 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
48018 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
48019 return 1;
48020 }
48021
48022 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48023 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
48024 +#endif
48025 +
48026 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48027 enum autofs_notify notify)
48028 {
48029 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48030
48031 /* If this is a direct mount request create a dummy name */
48032 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
48033 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48034 + /* this name does get written to userland via autofs4_write() */
48035 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
48036 +#else
48037 qstr.len = sprintf(name, "%p", dentry);
48038 +#endif
48039 else {
48040 qstr.len = autofs4_getpath(sbi, dentry, &name);
48041 if (!qstr.len) {
48042 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
48043 index 2722387..c8dd2a7 100644
48044 --- a/fs/befs/endian.h
48045 +++ b/fs/befs/endian.h
48046 @@ -11,7 +11,7 @@
48047
48048 #include <asm/byteorder.h>
48049
48050 -static inline u64
48051 +static inline u64 __intentional_overflow(-1)
48052 fs64_to_cpu(const struct super_block *sb, fs64 n)
48053 {
48054 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48055 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
48056 return (__force fs64)cpu_to_be64(n);
48057 }
48058
48059 -static inline u32
48060 +static inline u32 __intentional_overflow(-1)
48061 fs32_to_cpu(const struct super_block *sb, fs32 n)
48062 {
48063 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48064 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
48065 index 8615ee8..388ed68 100644
48066 --- a/fs/befs/linuxvfs.c
48067 +++ b/fs/befs/linuxvfs.c
48068 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48069 {
48070 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
48071 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
48072 - char *link = nd_get_link(nd);
48073 + const char *link = nd_get_link(nd);
48074 if (!IS_ERR(link))
48075 kfree(link);
48076 }
48077 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
48078 index bbc8f88..7c7ac97 100644
48079 --- a/fs/binfmt_aout.c
48080 +++ b/fs/binfmt_aout.c
48081 @@ -16,6 +16,7 @@
48082 #include <linux/string.h>
48083 #include <linux/fs.h>
48084 #include <linux/file.h>
48085 +#include <linux/security.h>
48086 #include <linux/stat.h>
48087 #include <linux/fcntl.h>
48088 #include <linux/ptrace.h>
48089 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
48090 #endif
48091 # define START_STACK(u) ((void __user *)u.start_stack)
48092
48093 + memset(&dump, 0, sizeof(dump));
48094 +
48095 fs = get_fs();
48096 set_fs(KERNEL_DS);
48097 has_dumped = 1;
48098 @@ -70,10 +73,12 @@ static int aout_core_dump(struct coredump_params *cprm)
48099
48100 /* If the size of the dump file exceeds the rlimit, then see what would happen
48101 if we wrote the stack, but not the data area. */
48102 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
48103 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
48104 dump.u_dsize = 0;
48105
48106 /* Make sure we have enough room to write the stack and data areas. */
48107 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
48108 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
48109 dump.u_ssize = 0;
48110
48111 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
48112 rlim = rlimit(RLIMIT_DATA);
48113 if (rlim >= RLIM_INFINITY)
48114 rlim = ~0;
48115 +
48116 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
48117 if (ex.a_data + ex.a_bss > rlim)
48118 return -ENOMEM;
48119
48120 @@ -268,6 +275,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
48121
48122 install_exec_creds(bprm);
48123
48124 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48125 + current->mm->pax_flags = 0UL;
48126 +#endif
48127 +
48128 +#ifdef CONFIG_PAX_PAGEEXEC
48129 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
48130 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
48131 +
48132 +#ifdef CONFIG_PAX_EMUTRAMP
48133 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
48134 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
48135 +#endif
48136 +
48137 +#ifdef CONFIG_PAX_MPROTECT
48138 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
48139 + current->mm->pax_flags |= MF_PAX_MPROTECT;
48140 +#endif
48141 +
48142 + }
48143 +#endif
48144 +
48145 if (N_MAGIC(ex) == OMAGIC) {
48146 unsigned long text_addr, map_size;
48147 loff_t pos;
48148 @@ -333,7 +361,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
48149 }
48150
48151 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
48152 - PROT_READ | PROT_WRITE | PROT_EXEC,
48153 + PROT_READ | PROT_WRITE,
48154 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
48155 fd_offset + ex.a_text);
48156 if (error != N_DATADDR(ex)) {
48157 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
48158 index 86af964..5d53bf6 100644
48159 --- a/fs/binfmt_elf.c
48160 +++ b/fs/binfmt_elf.c
48161 @@ -34,6 +34,7 @@
48162 #include <linux/utsname.h>
48163 #include <linux/coredump.h>
48164 #include <linux/sched.h>
48165 +#include <linux/xattr.h>
48166 #include <asm/uaccess.h>
48167 #include <asm/param.h>
48168 #include <asm/page.h>
48169 @@ -60,6 +61,10 @@ static int elf_core_dump(struct coredump_params *cprm);
48170 #define elf_core_dump NULL
48171 #endif
48172
48173 +#ifdef CONFIG_PAX_MPROTECT
48174 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
48175 +#endif
48176 +
48177 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
48178 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
48179 #else
48180 @@ -79,6 +84,11 @@ static struct linux_binfmt elf_format = {
48181 .load_binary = load_elf_binary,
48182 .load_shlib = load_elf_library,
48183 .core_dump = elf_core_dump,
48184 +
48185 +#ifdef CONFIG_PAX_MPROTECT
48186 + .handle_mprotect= elf_handle_mprotect,
48187 +#endif
48188 +
48189 .min_coredump = ELF_EXEC_PAGESIZE,
48190 };
48191
48192 @@ -86,6 +96,8 @@ static struct linux_binfmt elf_format = {
48193
48194 static int set_brk(unsigned long start, unsigned long end)
48195 {
48196 + unsigned long e = end;
48197 +
48198 start = ELF_PAGEALIGN(start);
48199 end = ELF_PAGEALIGN(end);
48200 if (end > start) {
48201 @@ -94,7 +106,7 @@ static int set_brk(unsigned long start, unsigned long end)
48202 if (BAD_ADDR(addr))
48203 return addr;
48204 }
48205 - current->mm->start_brk = current->mm->brk = end;
48206 + current->mm->start_brk = current->mm->brk = e;
48207 return 0;
48208 }
48209
48210 @@ -155,12 +167,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48211 elf_addr_t __user *u_rand_bytes;
48212 const char *k_platform = ELF_PLATFORM;
48213 const char *k_base_platform = ELF_BASE_PLATFORM;
48214 - unsigned char k_rand_bytes[16];
48215 + u32 k_rand_bytes[4];
48216 int items;
48217 elf_addr_t *elf_info;
48218 int ei_index = 0;
48219 const struct cred *cred = current_cred();
48220 struct vm_area_struct *vma;
48221 + unsigned long saved_auxv[AT_VECTOR_SIZE];
48222
48223 /*
48224 * In some cases (e.g. Hyper-Threading), we want to avoid L1
48225 @@ -202,8 +215,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48226 * Generate 16 random bytes for userspace PRNG seeding.
48227 */
48228 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
48229 - u_rand_bytes = (elf_addr_t __user *)
48230 - STACK_ALLOC(p, sizeof(k_rand_bytes));
48231 + srandom32(k_rand_bytes[0] ^ random32());
48232 + srandom32(k_rand_bytes[1] ^ random32());
48233 + srandom32(k_rand_bytes[2] ^ random32());
48234 + srandom32(k_rand_bytes[3] ^ random32());
48235 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
48236 + u_rand_bytes = (elf_addr_t __user *) p;
48237 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
48238 return -EFAULT;
48239
48240 @@ -315,9 +332,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48241 return -EFAULT;
48242 current->mm->env_end = p;
48243
48244 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
48245 +
48246 /* Put the elf_info on the stack in the right place. */
48247 sp = (elf_addr_t __user *)envp + 1;
48248 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
48249 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
48250 return -EFAULT;
48251 return 0;
48252 }
48253 @@ -385,15 +404,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
48254 an ELF header */
48255
48256 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48257 - struct file *interpreter, unsigned long *interp_map_addr,
48258 - unsigned long no_base)
48259 + struct file *interpreter, unsigned long no_base)
48260 {
48261 struct elf_phdr *elf_phdata;
48262 struct elf_phdr *eppnt;
48263 - unsigned long load_addr = 0;
48264 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
48265 int load_addr_set = 0;
48266 unsigned long last_bss = 0, elf_bss = 0;
48267 - unsigned long error = ~0UL;
48268 + unsigned long error = -EINVAL;
48269 unsigned long total_size;
48270 int retval, i, size;
48271
48272 @@ -439,6 +457,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48273 goto out_close;
48274 }
48275
48276 +#ifdef CONFIG_PAX_SEGMEXEC
48277 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
48278 + pax_task_size = SEGMEXEC_TASK_SIZE;
48279 +#endif
48280 +
48281 eppnt = elf_phdata;
48282 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
48283 if (eppnt->p_type == PT_LOAD) {
48284 @@ -462,8 +485,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48285 map_addr = elf_map(interpreter, load_addr + vaddr,
48286 eppnt, elf_prot, elf_type, total_size);
48287 total_size = 0;
48288 - if (!*interp_map_addr)
48289 - *interp_map_addr = map_addr;
48290 error = map_addr;
48291 if (BAD_ADDR(map_addr))
48292 goto out_close;
48293 @@ -482,8 +503,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48294 k = load_addr + eppnt->p_vaddr;
48295 if (BAD_ADDR(k) ||
48296 eppnt->p_filesz > eppnt->p_memsz ||
48297 - eppnt->p_memsz > TASK_SIZE ||
48298 - TASK_SIZE - eppnt->p_memsz < k) {
48299 + eppnt->p_memsz > pax_task_size ||
48300 + pax_task_size - eppnt->p_memsz < k) {
48301 error = -ENOMEM;
48302 goto out_close;
48303 }
48304 @@ -535,6 +556,315 @@ out:
48305 return error;
48306 }
48307
48308 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48309 +#ifdef CONFIG_PAX_SOFTMODE
48310 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
48311 +{
48312 + unsigned long pax_flags = 0UL;
48313 +
48314 +#ifdef CONFIG_PAX_PAGEEXEC
48315 + if (elf_phdata->p_flags & PF_PAGEEXEC)
48316 + pax_flags |= MF_PAX_PAGEEXEC;
48317 +#endif
48318 +
48319 +#ifdef CONFIG_PAX_SEGMEXEC
48320 + if (elf_phdata->p_flags & PF_SEGMEXEC)
48321 + pax_flags |= MF_PAX_SEGMEXEC;
48322 +#endif
48323 +
48324 +#ifdef CONFIG_PAX_EMUTRAMP
48325 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48326 + pax_flags |= MF_PAX_EMUTRAMP;
48327 +#endif
48328 +
48329 +#ifdef CONFIG_PAX_MPROTECT
48330 + if (elf_phdata->p_flags & PF_MPROTECT)
48331 + pax_flags |= MF_PAX_MPROTECT;
48332 +#endif
48333 +
48334 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48335 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
48336 + pax_flags |= MF_PAX_RANDMMAP;
48337 +#endif
48338 +
48339 + return pax_flags;
48340 +}
48341 +#endif
48342 +
48343 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
48344 +{
48345 + unsigned long pax_flags = 0UL;
48346 +
48347 +#ifdef CONFIG_PAX_PAGEEXEC
48348 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
48349 + pax_flags |= MF_PAX_PAGEEXEC;
48350 +#endif
48351 +
48352 +#ifdef CONFIG_PAX_SEGMEXEC
48353 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
48354 + pax_flags |= MF_PAX_SEGMEXEC;
48355 +#endif
48356 +
48357 +#ifdef CONFIG_PAX_EMUTRAMP
48358 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
48359 + pax_flags |= MF_PAX_EMUTRAMP;
48360 +#endif
48361 +
48362 +#ifdef CONFIG_PAX_MPROTECT
48363 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
48364 + pax_flags |= MF_PAX_MPROTECT;
48365 +#endif
48366 +
48367 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48368 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
48369 + pax_flags |= MF_PAX_RANDMMAP;
48370 +#endif
48371 +
48372 + return pax_flags;
48373 +}
48374 +#endif
48375 +
48376 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48377 +#ifdef CONFIG_PAX_SOFTMODE
48378 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
48379 +{
48380 + unsigned long pax_flags = 0UL;
48381 +
48382 +#ifdef CONFIG_PAX_PAGEEXEC
48383 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
48384 + pax_flags |= MF_PAX_PAGEEXEC;
48385 +#endif
48386 +
48387 +#ifdef CONFIG_PAX_SEGMEXEC
48388 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48389 + pax_flags |= MF_PAX_SEGMEXEC;
48390 +#endif
48391 +
48392 +#ifdef CONFIG_PAX_EMUTRAMP
48393 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48394 + pax_flags |= MF_PAX_EMUTRAMP;
48395 +#endif
48396 +
48397 +#ifdef CONFIG_PAX_MPROTECT
48398 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48399 + pax_flags |= MF_PAX_MPROTECT;
48400 +#endif
48401 +
48402 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48403 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48404 + pax_flags |= MF_PAX_RANDMMAP;
48405 +#endif
48406 +
48407 + return pax_flags;
48408 +}
48409 +#endif
48410 +
48411 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48412 +{
48413 + unsigned long pax_flags = 0UL;
48414 +
48415 +#ifdef CONFIG_PAX_PAGEEXEC
48416 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48417 + pax_flags |= MF_PAX_PAGEEXEC;
48418 +#endif
48419 +
48420 +#ifdef CONFIG_PAX_SEGMEXEC
48421 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48422 + pax_flags |= MF_PAX_SEGMEXEC;
48423 +#endif
48424 +
48425 +#ifdef CONFIG_PAX_EMUTRAMP
48426 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48427 + pax_flags |= MF_PAX_EMUTRAMP;
48428 +#endif
48429 +
48430 +#ifdef CONFIG_PAX_MPROTECT
48431 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48432 + pax_flags |= MF_PAX_MPROTECT;
48433 +#endif
48434 +
48435 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48436 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48437 + pax_flags |= MF_PAX_RANDMMAP;
48438 +#endif
48439 +
48440 + return pax_flags;
48441 +}
48442 +#endif
48443 +
48444 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48445 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48446 +{
48447 + unsigned long pax_flags = 0UL;
48448 +
48449 +#ifdef CONFIG_PAX_EI_PAX
48450 +
48451 +#ifdef CONFIG_PAX_PAGEEXEC
48452 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48453 + pax_flags |= MF_PAX_PAGEEXEC;
48454 +#endif
48455 +
48456 +#ifdef CONFIG_PAX_SEGMEXEC
48457 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48458 + pax_flags |= MF_PAX_SEGMEXEC;
48459 +#endif
48460 +
48461 +#ifdef CONFIG_PAX_EMUTRAMP
48462 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48463 + pax_flags |= MF_PAX_EMUTRAMP;
48464 +#endif
48465 +
48466 +#ifdef CONFIG_PAX_MPROTECT
48467 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
48468 + pax_flags |= MF_PAX_MPROTECT;
48469 +#endif
48470 +
48471 +#ifdef CONFIG_PAX_ASLR
48472 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
48473 + pax_flags |= MF_PAX_RANDMMAP;
48474 +#endif
48475 +
48476 +#else
48477 +
48478 +#ifdef CONFIG_PAX_PAGEEXEC
48479 + pax_flags |= MF_PAX_PAGEEXEC;
48480 +#endif
48481 +
48482 +#ifdef CONFIG_PAX_SEGMEXEC
48483 + pax_flags |= MF_PAX_SEGMEXEC;
48484 +#endif
48485 +
48486 +#ifdef CONFIG_PAX_MPROTECT
48487 + pax_flags |= MF_PAX_MPROTECT;
48488 +#endif
48489 +
48490 +#ifdef CONFIG_PAX_RANDMMAP
48491 + if (randomize_va_space)
48492 + pax_flags |= MF_PAX_RANDMMAP;
48493 +#endif
48494 +
48495 +#endif
48496 +
48497 + return pax_flags;
48498 +}
48499 +
48500 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
48501 +{
48502 +
48503 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48504 + unsigned long i;
48505 +
48506 + for (i = 0UL; i < elf_ex->e_phnum; i++)
48507 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
48508 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
48509 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
48510 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
48511 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
48512 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
48513 + return ~0UL;
48514 +
48515 +#ifdef CONFIG_PAX_SOFTMODE
48516 + if (pax_softmode)
48517 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
48518 + else
48519 +#endif
48520 +
48521 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
48522 + break;
48523 + }
48524 +#endif
48525 +
48526 + return ~0UL;
48527 +}
48528 +
48529 +static unsigned long pax_parse_xattr_pax(struct file * const file)
48530 +{
48531 +
48532 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48533 + ssize_t xattr_size, i;
48534 + unsigned char xattr_value[sizeof("pemrs") - 1];
48535 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
48536 +
48537 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
48538 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
48539 + return ~0UL;
48540 +
48541 + for (i = 0; i < xattr_size; i++)
48542 + switch (xattr_value[i]) {
48543 + default:
48544 + return ~0UL;
48545 +
48546 +#define parse_flag(option1, option2, flag) \
48547 + case option1: \
48548 + if (pax_flags_hardmode & MF_PAX_##flag) \
48549 + return ~0UL; \
48550 + pax_flags_hardmode |= MF_PAX_##flag; \
48551 + break; \
48552 + case option2: \
48553 + if (pax_flags_softmode & MF_PAX_##flag) \
48554 + return ~0UL; \
48555 + pax_flags_softmode |= MF_PAX_##flag; \
48556 + break;
48557 +
48558 + parse_flag('p', 'P', PAGEEXEC);
48559 + parse_flag('e', 'E', EMUTRAMP);
48560 + parse_flag('m', 'M', MPROTECT);
48561 + parse_flag('r', 'R', RANDMMAP);
48562 + parse_flag('s', 'S', SEGMEXEC);
48563 +
48564 +#undef parse_flag
48565 + }
48566 +
48567 + if (pax_flags_hardmode & pax_flags_softmode)
48568 + return ~0UL;
48569 +
48570 +#ifdef CONFIG_PAX_SOFTMODE
48571 + if (pax_softmode)
48572 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
48573 + else
48574 +#endif
48575 +
48576 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
48577 +#else
48578 + return ~0UL;
48579 +#endif
48580 +
48581 +}
48582 +
48583 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
48584 +{
48585 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
48586 +
48587 + pax_flags = pax_parse_ei_pax(elf_ex);
48588 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
48589 + xattr_pax_flags = pax_parse_xattr_pax(file);
48590 +
48591 + if (pt_pax_flags == ~0UL)
48592 + pt_pax_flags = xattr_pax_flags;
48593 + else if (xattr_pax_flags == ~0UL)
48594 + xattr_pax_flags = pt_pax_flags;
48595 + if (pt_pax_flags != xattr_pax_flags)
48596 + return -EINVAL;
48597 + if (pt_pax_flags != ~0UL)
48598 + pax_flags = pt_pax_flags;
48599 +
48600 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
48601 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48602 + if ((__supported_pte_mask & _PAGE_NX))
48603 + pax_flags &= ~MF_PAX_SEGMEXEC;
48604 + else
48605 + pax_flags &= ~MF_PAX_PAGEEXEC;
48606 + }
48607 +#endif
48608 +
48609 + if (0 > pax_check_flags(&pax_flags))
48610 + return -EINVAL;
48611 +
48612 + current->mm->pax_flags = pax_flags;
48613 + return 0;
48614 +}
48615 +#endif
48616 +
48617 /*
48618 * These are the functions used to load ELF style executables and shared
48619 * libraries. There is no binary dependent code anywhere else.
48620 @@ -551,6 +881,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
48621 {
48622 unsigned int random_variable = 0;
48623
48624 +#ifdef CONFIG_PAX_RANDUSTACK
48625 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
48626 + return stack_top - current->mm->delta_stack;
48627 +#endif
48628 +
48629 if ((current->flags & PF_RANDOMIZE) &&
48630 !(current->personality & ADDR_NO_RANDOMIZE)) {
48631 random_variable = get_random_int() & STACK_RND_MASK;
48632 @@ -569,7 +904,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
48633 unsigned long load_addr = 0, load_bias = 0;
48634 int load_addr_set = 0;
48635 char * elf_interpreter = NULL;
48636 - unsigned long error;
48637 + unsigned long error = 0;
48638 struct elf_phdr *elf_ppnt, *elf_phdata;
48639 unsigned long elf_bss, elf_brk;
48640 int retval, i;
48641 @@ -579,12 +914,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
48642 unsigned long start_code, end_code, start_data, end_data;
48643 unsigned long reloc_func_desc __maybe_unused = 0;
48644 int executable_stack = EXSTACK_DEFAULT;
48645 - unsigned long def_flags = 0;
48646 struct pt_regs *regs = current_pt_regs();
48647 struct {
48648 struct elfhdr elf_ex;
48649 struct elfhdr interp_elf_ex;
48650 } *loc;
48651 + unsigned long pax_task_size = TASK_SIZE;
48652
48653 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
48654 if (!loc) {
48655 @@ -720,11 +1055,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
48656 goto out_free_dentry;
48657
48658 /* OK, This is the point of no return */
48659 - current->mm->def_flags = def_flags;
48660 +
48661 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48662 + current->mm->pax_flags = 0UL;
48663 +#endif
48664 +
48665 +#ifdef CONFIG_PAX_DLRESOLVE
48666 + current->mm->call_dl_resolve = 0UL;
48667 +#endif
48668 +
48669 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
48670 + current->mm->call_syscall = 0UL;
48671 +#endif
48672 +
48673 +#ifdef CONFIG_PAX_ASLR
48674 + current->mm->delta_mmap = 0UL;
48675 + current->mm->delta_stack = 0UL;
48676 +#endif
48677 +
48678 + current->mm->def_flags = 0;
48679 +
48680 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48681 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
48682 + send_sig(SIGKILL, current, 0);
48683 + goto out_free_dentry;
48684 + }
48685 +#endif
48686 +
48687 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
48688 + pax_set_initial_flags(bprm);
48689 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
48690 + if (pax_set_initial_flags_func)
48691 + (pax_set_initial_flags_func)(bprm);
48692 +#endif
48693 +
48694 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
48695 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
48696 + current->mm->context.user_cs_limit = PAGE_SIZE;
48697 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
48698 + }
48699 +#endif
48700 +
48701 +#ifdef CONFIG_PAX_SEGMEXEC
48702 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
48703 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
48704 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
48705 + pax_task_size = SEGMEXEC_TASK_SIZE;
48706 + current->mm->def_flags |= VM_NOHUGEPAGE;
48707 + }
48708 +#endif
48709 +
48710 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
48711 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48712 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
48713 + put_cpu();
48714 + }
48715 +#endif
48716
48717 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
48718 may depend on the personality. */
48719 SET_PERSONALITY(loc->elf_ex);
48720 +
48721 +#ifdef CONFIG_PAX_ASLR
48722 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
48723 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
48724 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
48725 + }
48726 +#endif
48727 +
48728 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
48729 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48730 + executable_stack = EXSTACK_DISABLE_X;
48731 + current->personality &= ~READ_IMPLIES_EXEC;
48732 + } else
48733 +#endif
48734 +
48735 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
48736 current->personality |= READ_IMPLIES_EXEC;
48737
48738 @@ -815,6 +1220,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
48739 #else
48740 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
48741 #endif
48742 +
48743 +#ifdef CONFIG_PAX_RANDMMAP
48744 + /* PaX: randomize base address at the default exe base if requested */
48745 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
48746 +#ifdef CONFIG_SPARC64
48747 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
48748 +#else
48749 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
48750 +#endif
48751 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
48752 + elf_flags |= MAP_FIXED;
48753 + }
48754 +#endif
48755 +
48756 }
48757
48758 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
48759 @@ -847,9 +1266,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
48760 * allowed task size. Note that p_filesz must always be
48761 * <= p_memsz so it is only necessary to check p_memsz.
48762 */
48763 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
48764 - elf_ppnt->p_memsz > TASK_SIZE ||
48765 - TASK_SIZE - elf_ppnt->p_memsz < k) {
48766 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
48767 + elf_ppnt->p_memsz > pax_task_size ||
48768 + pax_task_size - elf_ppnt->p_memsz < k) {
48769 /* set_brk can never work. Avoid overflows. */
48770 send_sig(SIGKILL, current, 0);
48771 retval = -EINVAL;
48772 @@ -888,17 +1307,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
48773 goto out_free_dentry;
48774 }
48775 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
48776 - send_sig(SIGSEGV, current, 0);
48777 - retval = -EFAULT; /* Nobody gets to see this, but.. */
48778 - goto out_free_dentry;
48779 + /*
48780 + * This bss-zeroing can fail if the ELF
48781 + * file specifies odd protections. So
48782 + * we don't check the return value
48783 + */
48784 }
48785
48786 +#ifdef CONFIG_PAX_RANDMMAP
48787 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
48788 + unsigned long start, size, flags;
48789 + vm_flags_t vm_flags;
48790 +
48791 + start = ELF_PAGEALIGN(elf_brk);
48792 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
48793 + flags = MAP_FIXED | MAP_PRIVATE;
48794 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
48795 +
48796 + down_write(&current->mm->mmap_sem);
48797 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
48798 + retval = -ENOMEM;
48799 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
48800 +// if (current->personality & ADDR_NO_RANDOMIZE)
48801 +// vm_flags |= VM_READ | VM_MAYREAD;
48802 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
48803 + retval = IS_ERR_VALUE(start) ? start : 0;
48804 + }
48805 + up_write(&current->mm->mmap_sem);
48806 + if (retval == 0)
48807 + retval = set_brk(start + size, start + size + PAGE_SIZE);
48808 + if (retval < 0) {
48809 + send_sig(SIGKILL, current, 0);
48810 + goto out_free_dentry;
48811 + }
48812 + }
48813 +#endif
48814 +
48815 if (elf_interpreter) {
48816 - unsigned long interp_map_addr = 0;
48817 -
48818 elf_entry = load_elf_interp(&loc->interp_elf_ex,
48819 interpreter,
48820 - &interp_map_addr,
48821 load_bias);
48822 if (!IS_ERR((void *)elf_entry)) {
48823 /*
48824 @@ -1120,7 +1567,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
48825 * Decide what to dump of a segment, part, all or none.
48826 */
48827 static unsigned long vma_dump_size(struct vm_area_struct *vma,
48828 - unsigned long mm_flags)
48829 + unsigned long mm_flags, long signr)
48830 {
48831 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
48832
48833 @@ -1158,7 +1605,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
48834 if (vma->vm_file == NULL)
48835 return 0;
48836
48837 - if (FILTER(MAPPED_PRIVATE))
48838 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
48839 goto whole;
48840
48841 /*
48842 @@ -1383,9 +1830,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
48843 {
48844 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
48845 int i = 0;
48846 - do
48847 + do {
48848 i += 2;
48849 - while (auxv[i - 2] != AT_NULL);
48850 + } while (auxv[i - 2] != AT_NULL);
48851 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
48852 }
48853
48854 @@ -1394,7 +1841,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
48855 {
48856 mm_segment_t old_fs = get_fs();
48857 set_fs(KERNEL_DS);
48858 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
48859 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
48860 set_fs(old_fs);
48861 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
48862 }
48863 @@ -2015,14 +2462,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
48864 }
48865
48866 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
48867 - unsigned long mm_flags)
48868 + struct coredump_params *cprm)
48869 {
48870 struct vm_area_struct *vma;
48871 size_t size = 0;
48872
48873 for (vma = first_vma(current, gate_vma); vma != NULL;
48874 vma = next_vma(vma, gate_vma))
48875 - size += vma_dump_size(vma, mm_flags);
48876 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48877 return size;
48878 }
48879
48880 @@ -2116,7 +2563,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48881
48882 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
48883
48884 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
48885 + offset += elf_core_vma_data_size(gate_vma, cprm);
48886 offset += elf_core_extra_data_size();
48887 e_shoff = offset;
48888
48889 @@ -2130,10 +2577,12 @@ static int elf_core_dump(struct coredump_params *cprm)
48890 offset = dataoff;
48891
48892 size += sizeof(*elf);
48893 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48894 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
48895 goto end_coredump;
48896
48897 size += sizeof(*phdr4note);
48898 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48899 if (size > cprm->limit
48900 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
48901 goto end_coredump;
48902 @@ -2147,7 +2596,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48903 phdr.p_offset = offset;
48904 phdr.p_vaddr = vma->vm_start;
48905 phdr.p_paddr = 0;
48906 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
48907 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48908 phdr.p_memsz = vma->vm_end - vma->vm_start;
48909 offset += phdr.p_filesz;
48910 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
48911 @@ -2158,6 +2607,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48912 phdr.p_align = ELF_EXEC_PAGESIZE;
48913
48914 size += sizeof(phdr);
48915 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48916 if (size > cprm->limit
48917 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
48918 goto end_coredump;
48919 @@ -2182,7 +2632,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48920 unsigned long addr;
48921 unsigned long end;
48922
48923 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
48924 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
48925
48926 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
48927 struct page *page;
48928 @@ -2191,6 +2641,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48929 page = get_dump_page(addr);
48930 if (page) {
48931 void *kaddr = kmap(page);
48932 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
48933 stop = ((size += PAGE_SIZE) > cprm->limit) ||
48934 !dump_write(cprm->file, kaddr,
48935 PAGE_SIZE);
48936 @@ -2208,6 +2659,7 @@ static int elf_core_dump(struct coredump_params *cprm)
48937
48938 if (e_phnum == PN_XNUM) {
48939 size += sizeof(*shdr4extnum);
48940 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
48941 if (size > cprm->limit
48942 || !dump_write(cprm->file, shdr4extnum,
48943 sizeof(*shdr4extnum)))
48944 @@ -2228,6 +2680,97 @@ out:
48945
48946 #endif /* CONFIG_ELF_CORE */
48947
48948 +#ifdef CONFIG_PAX_MPROTECT
48949 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
48950 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
48951 + * we'll remove VM_MAYWRITE for good on RELRO segments.
48952 + *
48953 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
48954 + * basis because we want to allow the common case and not the special ones.
48955 + */
48956 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
48957 +{
48958 + struct elfhdr elf_h;
48959 + struct elf_phdr elf_p;
48960 + unsigned long i;
48961 + unsigned long oldflags;
48962 + bool is_textrel_rw, is_textrel_rx, is_relro;
48963 +
48964 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
48965 + return;
48966 +
48967 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
48968 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
48969 +
48970 +#ifdef CONFIG_PAX_ELFRELOCS
48971 + /* possible TEXTREL */
48972 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
48973 + 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);
48974 +#else
48975 + is_textrel_rw = false;
48976 + is_textrel_rx = false;
48977 +#endif
48978 +
48979 + /* possible RELRO */
48980 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
48981 +
48982 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
48983 + return;
48984 +
48985 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
48986 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
48987 +
48988 +#ifdef CONFIG_PAX_ETEXECRELOCS
48989 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
48990 +#else
48991 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
48992 +#endif
48993 +
48994 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
48995 + !elf_check_arch(&elf_h) ||
48996 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
48997 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
48998 + return;
48999 +
49000 + for (i = 0UL; i < elf_h.e_phnum; i++) {
49001 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
49002 + return;
49003 + switch (elf_p.p_type) {
49004 + case PT_DYNAMIC:
49005 + if (!is_textrel_rw && !is_textrel_rx)
49006 + continue;
49007 + i = 0UL;
49008 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
49009 + elf_dyn dyn;
49010 +
49011 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
49012 + return;
49013 + if (dyn.d_tag == DT_NULL)
49014 + return;
49015 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
49016 + gr_log_textrel(vma);
49017 + if (is_textrel_rw)
49018 + vma->vm_flags |= VM_MAYWRITE;
49019 + else
49020 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
49021 + vma->vm_flags &= ~VM_MAYWRITE;
49022 + return;
49023 + }
49024 + i++;
49025 + }
49026 + return;
49027 +
49028 + case PT_GNU_RELRO:
49029 + if (!is_relro)
49030 + continue;
49031 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
49032 + vma->vm_flags &= ~VM_MAYWRITE;
49033 + return;
49034 + }
49035 + }
49036 +}
49037 +#endif
49038 +
49039 static int __init init_elf_binfmt(void)
49040 {
49041 register_binfmt(&elf_format);
49042 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
49043 index 2036d21..b0430d0 100644
49044 --- a/fs/binfmt_flat.c
49045 +++ b/fs/binfmt_flat.c
49046 @@ -562,7 +562,9 @@ static int load_flat_file(struct linux_binprm * bprm,
49047 realdatastart = (unsigned long) -ENOMEM;
49048 printk("Unable to allocate RAM for process data, errno %d\n",
49049 (int)-realdatastart);
49050 + down_write(&current->mm->mmap_sem);
49051 vm_munmap(textpos, text_len);
49052 + up_write(&current->mm->mmap_sem);
49053 ret = realdatastart;
49054 goto err;
49055 }
49056 @@ -586,8 +588,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49057 }
49058 if (IS_ERR_VALUE(result)) {
49059 printk("Unable to read data+bss, errno %d\n", (int)-result);
49060 + down_write(&current->mm->mmap_sem);
49061 vm_munmap(textpos, text_len);
49062 vm_munmap(realdatastart, len);
49063 + up_write(&current->mm->mmap_sem);
49064 ret = result;
49065 goto err;
49066 }
49067 @@ -654,8 +658,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49068 }
49069 if (IS_ERR_VALUE(result)) {
49070 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
49071 + down_write(&current->mm->mmap_sem);
49072 vm_munmap(textpos, text_len + data_len + extra +
49073 MAX_SHARED_LIBS * sizeof(unsigned long));
49074 + up_write(&current->mm->mmap_sem);
49075 ret = result;
49076 goto err;
49077 }
49078 diff --git a/fs/bio.c b/fs/bio.c
49079 index b96fc6c..431d628 100644
49080 --- a/fs/bio.c
49081 +++ b/fs/bio.c
49082 @@ -818,7 +818,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
49083 /*
49084 * Overflow, abort
49085 */
49086 - if (end < start)
49087 + if (end < start || end - start > INT_MAX - nr_pages)
49088 return ERR_PTR(-EINVAL);
49089
49090 nr_pages += end - start;
49091 @@ -952,7 +952,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
49092 /*
49093 * Overflow, abort
49094 */
49095 - if (end < start)
49096 + if (end < start || end - start > INT_MAX - nr_pages)
49097 return ERR_PTR(-EINVAL);
49098
49099 nr_pages += end - start;
49100 @@ -1214,7 +1214,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
49101 const int read = bio_data_dir(bio) == READ;
49102 struct bio_map_data *bmd = bio->bi_private;
49103 int i;
49104 - char *p = bmd->sgvecs[0].iov_base;
49105 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
49106
49107 __bio_for_each_segment(bvec, bio, i, 0) {
49108 char *addr = page_address(bvec->bv_page);
49109 diff --git a/fs/block_dev.c b/fs/block_dev.c
49110 index aae187a..fd790ba 100644
49111 --- a/fs/block_dev.c
49112 +++ b/fs/block_dev.c
49113 @@ -652,7 +652,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
49114 else if (bdev->bd_contains == bdev)
49115 return true; /* is a whole device which isn't held */
49116
49117 - else if (whole->bd_holder == bd_may_claim)
49118 + else if (whole->bd_holder == (void *)bd_may_claim)
49119 return true; /* is a partition of a device that is being partitioned */
49120 else if (whole->bd_holder != NULL)
49121 return false; /* is a partition of a held device */
49122 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
49123 index ca9d8f1..8c0142d 100644
49124 --- a/fs/btrfs/ctree.c
49125 +++ b/fs/btrfs/ctree.c
49126 @@ -1036,9 +1036,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
49127 free_extent_buffer(buf);
49128 add_root_to_dirty_list(root);
49129 } else {
49130 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
49131 - parent_start = parent->start;
49132 - else
49133 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
49134 + if (parent)
49135 + parent_start = parent->start;
49136 + else
49137 + parent_start = 0;
49138 + } else
49139 parent_start = 0;
49140
49141 WARN_ON(trans->transid != btrfs_header_generation(parent));
49142 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
49143 index f49b62f..07834ab 100644
49144 --- a/fs/btrfs/ioctl.c
49145 +++ b/fs/btrfs/ioctl.c
49146 @@ -3077,9 +3077,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49147 for (i = 0; i < num_types; i++) {
49148 struct btrfs_space_info *tmp;
49149
49150 + /* Don't copy in more than we allocated */
49151 if (!slot_count)
49152 break;
49153
49154 + slot_count--;
49155 +
49156 info = NULL;
49157 rcu_read_lock();
49158 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
49159 @@ -3101,10 +3104,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49160 memcpy(dest, &space, sizeof(space));
49161 dest++;
49162 space_args.total_spaces++;
49163 - slot_count--;
49164 }
49165 - if (!slot_count)
49166 - break;
49167 }
49168 up_read(&info->groups_sem);
49169 }
49170 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
49171 index f6b8859..54fe8c5 100644
49172 --- a/fs/btrfs/super.c
49173 +++ b/fs/btrfs/super.c
49174 @@ -266,7 +266,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
49175 function, line, errstr);
49176 return;
49177 }
49178 - ACCESS_ONCE(trans->transaction->aborted) = errno;
49179 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
49180 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
49181 }
49182 /*
49183 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
49184 index 622f469..e8d2d55 100644
49185 --- a/fs/cachefiles/bind.c
49186 +++ b/fs/cachefiles/bind.c
49187 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
49188 args);
49189
49190 /* start by checking things over */
49191 - ASSERT(cache->fstop_percent >= 0 &&
49192 - cache->fstop_percent < cache->fcull_percent &&
49193 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
49194 cache->fcull_percent < cache->frun_percent &&
49195 cache->frun_percent < 100);
49196
49197 - ASSERT(cache->bstop_percent >= 0 &&
49198 - cache->bstop_percent < cache->bcull_percent &&
49199 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
49200 cache->bcull_percent < cache->brun_percent &&
49201 cache->brun_percent < 100);
49202
49203 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
49204 index 0a1467b..6a53245 100644
49205 --- a/fs/cachefiles/daemon.c
49206 +++ b/fs/cachefiles/daemon.c
49207 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
49208 if (n > buflen)
49209 return -EMSGSIZE;
49210
49211 - if (copy_to_user(_buffer, buffer, n) != 0)
49212 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
49213 return -EFAULT;
49214
49215 return n;
49216 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
49217 if (test_bit(CACHEFILES_DEAD, &cache->flags))
49218 return -EIO;
49219
49220 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
49221 + if (datalen > PAGE_SIZE - 1)
49222 return -EOPNOTSUPP;
49223
49224 /* drag the command string into the kernel so we can parse it */
49225 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
49226 if (args[0] != '%' || args[1] != '\0')
49227 return -EINVAL;
49228
49229 - if (fstop < 0 || fstop >= cache->fcull_percent)
49230 + if (fstop >= cache->fcull_percent)
49231 return cachefiles_daemon_range_error(cache, args);
49232
49233 cache->fstop_percent = fstop;
49234 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
49235 if (args[0] != '%' || args[1] != '\0')
49236 return -EINVAL;
49237
49238 - if (bstop < 0 || bstop >= cache->bcull_percent)
49239 + if (bstop >= cache->bcull_percent)
49240 return cachefiles_daemon_range_error(cache, args);
49241
49242 cache->bstop_percent = bstop;
49243 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
49244 index 4938251..7e01445 100644
49245 --- a/fs/cachefiles/internal.h
49246 +++ b/fs/cachefiles/internal.h
49247 @@ -59,7 +59,7 @@ struct cachefiles_cache {
49248 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
49249 struct rb_root active_nodes; /* active nodes (can't be culled) */
49250 rwlock_t active_lock; /* lock for active_nodes */
49251 - atomic_t gravecounter; /* graveyard uniquifier */
49252 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
49253 unsigned frun_percent; /* when to stop culling (% files) */
49254 unsigned fcull_percent; /* when to start culling (% files) */
49255 unsigned fstop_percent; /* when to stop allocating (% files) */
49256 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
49257 * proc.c
49258 */
49259 #ifdef CONFIG_CACHEFILES_HISTOGRAM
49260 -extern atomic_t cachefiles_lookup_histogram[HZ];
49261 -extern atomic_t cachefiles_mkdir_histogram[HZ];
49262 -extern atomic_t cachefiles_create_histogram[HZ];
49263 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49264 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49265 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
49266
49267 extern int __init cachefiles_proc_init(void);
49268 extern void cachefiles_proc_cleanup(void);
49269 static inline
49270 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
49271 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
49272 {
49273 unsigned long jif = jiffies - start_jif;
49274 if (jif >= HZ)
49275 jif = HZ - 1;
49276 - atomic_inc(&histogram[jif]);
49277 + atomic_inc_unchecked(&histogram[jif]);
49278 }
49279
49280 #else
49281 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
49282 index 8c01c5fc..15f982e 100644
49283 --- a/fs/cachefiles/namei.c
49284 +++ b/fs/cachefiles/namei.c
49285 @@ -317,7 +317,7 @@ try_again:
49286 /* first step is to make up a grave dentry in the graveyard */
49287 sprintf(nbuffer, "%08x%08x",
49288 (uint32_t) get_seconds(),
49289 - (uint32_t) atomic_inc_return(&cache->gravecounter));
49290 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
49291
49292 /* do the multiway lock magic */
49293 trap = lock_rename(cache->graveyard, dir);
49294 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
49295 index eccd339..4c1d995 100644
49296 --- a/fs/cachefiles/proc.c
49297 +++ b/fs/cachefiles/proc.c
49298 @@ -14,9 +14,9 @@
49299 #include <linux/seq_file.h>
49300 #include "internal.h"
49301
49302 -atomic_t cachefiles_lookup_histogram[HZ];
49303 -atomic_t cachefiles_mkdir_histogram[HZ];
49304 -atomic_t cachefiles_create_histogram[HZ];
49305 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49306 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49307 +atomic_unchecked_t cachefiles_create_histogram[HZ];
49308
49309 /*
49310 * display the latency histogram
49311 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
49312 return 0;
49313 default:
49314 index = (unsigned long) v - 3;
49315 - x = atomic_read(&cachefiles_lookup_histogram[index]);
49316 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
49317 - z = atomic_read(&cachefiles_create_histogram[index]);
49318 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
49319 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
49320 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
49321 if (x == 0 && y == 0 && z == 0)
49322 return 0;
49323
49324 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
49325 index 4809922..aab2c39 100644
49326 --- a/fs/cachefiles/rdwr.c
49327 +++ b/fs/cachefiles/rdwr.c
49328 @@ -965,7 +965,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
49329 old_fs = get_fs();
49330 set_fs(KERNEL_DS);
49331 ret = file->f_op->write(
49332 - file, (const void __user *) data, len, &pos);
49333 + file, (const void __force_user *) data, len, &pos);
49334 set_fs(old_fs);
49335 kunmap(page);
49336 if (ret != len)
49337 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
49338 index 6d797f4..0ace2e5 100644
49339 --- a/fs/ceph/dir.c
49340 +++ b/fs/ceph/dir.c
49341 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
49342 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
49343 struct ceph_mds_client *mdsc = fsc->mdsc;
49344 unsigned frag = fpos_frag(filp->f_pos);
49345 - int off = fpos_off(filp->f_pos);
49346 + unsigned int off = fpos_off(filp->f_pos);
49347 int err;
49348 u32 ftype;
49349 struct ceph_mds_reply_info_parsed *rinfo;
49350 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
49351 index d9ea6ed..1e6c8ac 100644
49352 --- a/fs/cifs/cifs_debug.c
49353 +++ b/fs/cifs/cifs_debug.c
49354 @@ -267,8 +267,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49355
49356 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
49357 #ifdef CONFIG_CIFS_STATS2
49358 - atomic_set(&totBufAllocCount, 0);
49359 - atomic_set(&totSmBufAllocCount, 0);
49360 + atomic_set_unchecked(&totBufAllocCount, 0);
49361 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49362 #endif /* CONFIG_CIFS_STATS2 */
49363 spin_lock(&cifs_tcp_ses_lock);
49364 list_for_each(tmp1, &cifs_tcp_ses_list) {
49365 @@ -281,7 +281,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49366 tcon = list_entry(tmp3,
49367 struct cifs_tcon,
49368 tcon_list);
49369 - atomic_set(&tcon->num_smbs_sent, 0);
49370 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
49371 if (server->ops->clear_stats)
49372 server->ops->clear_stats(tcon);
49373 }
49374 @@ -313,8 +313,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49375 smBufAllocCount.counter, cifs_min_small);
49376 #ifdef CONFIG_CIFS_STATS2
49377 seq_printf(m, "Total Large %d Small %d Allocations\n",
49378 - atomic_read(&totBufAllocCount),
49379 - atomic_read(&totSmBufAllocCount));
49380 + atomic_read_unchecked(&totBufAllocCount),
49381 + atomic_read_unchecked(&totSmBufAllocCount));
49382 #endif /* CONFIG_CIFS_STATS2 */
49383
49384 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
49385 @@ -343,7 +343,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49386 if (tcon->need_reconnect)
49387 seq_puts(m, "\tDISCONNECTED ");
49388 seq_printf(m, "\nSMBs: %d",
49389 - atomic_read(&tcon->num_smbs_sent));
49390 + atomic_read_unchecked(&tcon->num_smbs_sent));
49391 if (server->ops->print_stats)
49392 server->ops->print_stats(m, tcon);
49393 }
49394 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
49395 index 345fc89..b2acae5 100644
49396 --- a/fs/cifs/cifsfs.c
49397 +++ b/fs/cifs/cifsfs.c
49398 @@ -1033,7 +1033,7 @@ cifs_init_request_bufs(void)
49399 /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
49400 cifs_req_cachep = kmem_cache_create("cifs_request",
49401 CIFSMaxBufSize + max_hdr_size, 0,
49402 - SLAB_HWCACHE_ALIGN, NULL);
49403 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
49404 if (cifs_req_cachep == NULL)
49405 return -ENOMEM;
49406
49407 @@ -1060,7 +1060,7 @@ cifs_init_request_bufs(void)
49408 efficient to alloc 1 per page off the slab compared to 17K (5page)
49409 alloc of large cifs buffers even when page debugging is on */
49410 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
49411 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
49412 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
49413 NULL);
49414 if (cifs_sm_req_cachep == NULL) {
49415 mempool_destroy(cifs_req_poolp);
49416 @@ -1145,8 +1145,8 @@ init_cifs(void)
49417 atomic_set(&bufAllocCount, 0);
49418 atomic_set(&smBufAllocCount, 0);
49419 #ifdef CONFIG_CIFS_STATS2
49420 - atomic_set(&totBufAllocCount, 0);
49421 - atomic_set(&totSmBufAllocCount, 0);
49422 + atomic_set_unchecked(&totBufAllocCount, 0);
49423 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49424 #endif /* CONFIG_CIFS_STATS2 */
49425
49426 atomic_set(&midCount, 0);
49427 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
49428 index 4f07f6f..55de8ce 100644
49429 --- a/fs/cifs/cifsglob.h
49430 +++ b/fs/cifs/cifsglob.h
49431 @@ -751,35 +751,35 @@ struct cifs_tcon {
49432 __u16 Flags; /* optional support bits */
49433 enum statusEnum tidStatus;
49434 #ifdef CONFIG_CIFS_STATS
49435 - atomic_t num_smbs_sent;
49436 + atomic_unchecked_t num_smbs_sent;
49437 union {
49438 struct {
49439 - atomic_t num_writes;
49440 - atomic_t num_reads;
49441 - atomic_t num_flushes;
49442 - atomic_t num_oplock_brks;
49443 - atomic_t num_opens;
49444 - atomic_t num_closes;
49445 - atomic_t num_deletes;
49446 - atomic_t num_mkdirs;
49447 - atomic_t num_posixopens;
49448 - atomic_t num_posixmkdirs;
49449 - atomic_t num_rmdirs;
49450 - atomic_t num_renames;
49451 - atomic_t num_t2renames;
49452 - atomic_t num_ffirst;
49453 - atomic_t num_fnext;
49454 - atomic_t num_fclose;
49455 - atomic_t num_hardlinks;
49456 - atomic_t num_symlinks;
49457 - atomic_t num_locks;
49458 - atomic_t num_acl_get;
49459 - atomic_t num_acl_set;
49460 + atomic_unchecked_t num_writes;
49461 + atomic_unchecked_t num_reads;
49462 + atomic_unchecked_t num_flushes;
49463 + atomic_unchecked_t num_oplock_brks;
49464 + atomic_unchecked_t num_opens;
49465 + atomic_unchecked_t num_closes;
49466 + atomic_unchecked_t num_deletes;
49467 + atomic_unchecked_t num_mkdirs;
49468 + atomic_unchecked_t num_posixopens;
49469 + atomic_unchecked_t num_posixmkdirs;
49470 + atomic_unchecked_t num_rmdirs;
49471 + atomic_unchecked_t num_renames;
49472 + atomic_unchecked_t num_t2renames;
49473 + atomic_unchecked_t num_ffirst;
49474 + atomic_unchecked_t num_fnext;
49475 + atomic_unchecked_t num_fclose;
49476 + atomic_unchecked_t num_hardlinks;
49477 + atomic_unchecked_t num_symlinks;
49478 + atomic_unchecked_t num_locks;
49479 + atomic_unchecked_t num_acl_get;
49480 + atomic_unchecked_t num_acl_set;
49481 } cifs_stats;
49482 #ifdef CONFIG_CIFS_SMB2
49483 struct {
49484 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49485 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49486 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49487 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49488 } smb2_stats;
49489 #endif /* CONFIG_CIFS_SMB2 */
49490 } stats;
49491 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
49492 }
49493
49494 #ifdef CONFIG_CIFS_STATS
49495 -#define cifs_stats_inc atomic_inc
49496 +#define cifs_stats_inc atomic_inc_unchecked
49497
49498 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
49499 unsigned int bytes)
49500 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
49501 /* Various Debug counters */
49502 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
49503 #ifdef CONFIG_CIFS_STATS2
49504 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
49505 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
49506 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
49507 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
49508 #endif
49509 GLOBAL_EXTERN atomic_t smBufAllocCount;
49510 GLOBAL_EXTERN atomic_t midCount;
49511 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
49512 index 9f6c4c4..8de307a 100644
49513 --- a/fs/cifs/link.c
49514 +++ b/fs/cifs/link.c
49515 @@ -616,7 +616,7 @@ symlink_exit:
49516
49517 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
49518 {
49519 - char *p = nd_get_link(nd);
49520 + const char *p = nd_get_link(nd);
49521 if (!IS_ERR(p))
49522 kfree(p);
49523 }
49524 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
49525 index 1b15bf8..1ce489e 100644
49526 --- a/fs/cifs/misc.c
49527 +++ b/fs/cifs/misc.c
49528 @@ -169,7 +169,7 @@ cifs_buf_get(void)
49529 memset(ret_buf, 0, buf_size + 3);
49530 atomic_inc(&bufAllocCount);
49531 #ifdef CONFIG_CIFS_STATS2
49532 - atomic_inc(&totBufAllocCount);
49533 + atomic_inc_unchecked(&totBufAllocCount);
49534 #endif /* CONFIG_CIFS_STATS2 */
49535 }
49536
49537 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
49538 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
49539 atomic_inc(&smBufAllocCount);
49540 #ifdef CONFIG_CIFS_STATS2
49541 - atomic_inc(&totSmBufAllocCount);
49542 + atomic_inc_unchecked(&totSmBufAllocCount);
49543 #endif /* CONFIG_CIFS_STATS2 */
49544
49545 }
49546 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
49547 index 47bc5a8..10decbe 100644
49548 --- a/fs/cifs/smb1ops.c
49549 +++ b/fs/cifs/smb1ops.c
49550 @@ -586,27 +586,27 @@ static void
49551 cifs_clear_stats(struct cifs_tcon *tcon)
49552 {
49553 #ifdef CONFIG_CIFS_STATS
49554 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
49555 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
49556 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
49557 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49558 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
49559 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
49560 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49561 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
49562 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
49563 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
49564 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
49565 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
49566 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
49567 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
49568 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
49569 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
49570 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
49571 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
49572 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
49573 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
49574 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
49575 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
49576 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
49577 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
49578 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49579 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
49580 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
49581 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49582 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
49583 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
49584 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
49585 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
49586 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
49587 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
49588 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
49589 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
49590 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
49591 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
49592 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
49593 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
49594 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
49595 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
49596 #endif
49597 }
49598
49599 @@ -615,36 +615,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49600 {
49601 #ifdef CONFIG_CIFS_STATS
49602 seq_printf(m, " Oplocks breaks: %d",
49603 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
49604 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
49605 seq_printf(m, "\nReads: %d Bytes: %llu",
49606 - atomic_read(&tcon->stats.cifs_stats.num_reads),
49607 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
49608 (long long)(tcon->bytes_read));
49609 seq_printf(m, "\nWrites: %d Bytes: %llu",
49610 - atomic_read(&tcon->stats.cifs_stats.num_writes),
49611 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
49612 (long long)(tcon->bytes_written));
49613 seq_printf(m, "\nFlushes: %d",
49614 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
49615 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
49616 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
49617 - atomic_read(&tcon->stats.cifs_stats.num_locks),
49618 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
49619 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
49620 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
49621 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
49622 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
49623 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
49624 - atomic_read(&tcon->stats.cifs_stats.num_opens),
49625 - atomic_read(&tcon->stats.cifs_stats.num_closes),
49626 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
49627 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
49628 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
49629 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
49630 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
49631 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
49632 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
49633 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
49634 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
49635 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
49636 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
49637 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
49638 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
49639 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
49640 seq_printf(m, "\nRenames: %d T2 Renames %d",
49641 - atomic_read(&tcon->stats.cifs_stats.num_renames),
49642 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
49643 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
49644 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
49645 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
49646 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
49647 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
49648 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
49649 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
49650 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
49651 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
49652 #endif
49653 }
49654
49655 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
49656 index bceffe7..cd1ae59 100644
49657 --- a/fs/cifs/smb2ops.c
49658 +++ b/fs/cifs/smb2ops.c
49659 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
49660 #ifdef CONFIG_CIFS_STATS
49661 int i;
49662 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
49663 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49664 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49665 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
49666 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
49667 }
49668 #endif
49669 }
49670 @@ -284,66 +284,66 @@ static void
49671 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49672 {
49673 #ifdef CONFIG_CIFS_STATS
49674 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49675 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49676 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
49677 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
49678 seq_printf(m, "\nNegotiates: %d sent %d failed",
49679 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
49680 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
49681 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
49682 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
49683 seq_printf(m, "\nSessionSetups: %d sent %d failed",
49684 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
49685 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
49686 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
49687 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
49688 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
49689 seq_printf(m, "\nLogoffs: %d sent %d failed",
49690 - atomic_read(&sent[SMB2_LOGOFF_HE]),
49691 - atomic_read(&failed[SMB2_LOGOFF_HE]));
49692 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
49693 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
49694 seq_printf(m, "\nTreeConnects: %d sent %d failed",
49695 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
49696 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
49697 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
49698 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
49699 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
49700 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
49701 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
49702 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
49703 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
49704 seq_printf(m, "\nCreates: %d sent %d failed",
49705 - atomic_read(&sent[SMB2_CREATE_HE]),
49706 - atomic_read(&failed[SMB2_CREATE_HE]));
49707 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
49708 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
49709 seq_printf(m, "\nCloses: %d sent %d failed",
49710 - atomic_read(&sent[SMB2_CLOSE_HE]),
49711 - atomic_read(&failed[SMB2_CLOSE_HE]));
49712 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
49713 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
49714 seq_printf(m, "\nFlushes: %d sent %d failed",
49715 - atomic_read(&sent[SMB2_FLUSH_HE]),
49716 - atomic_read(&failed[SMB2_FLUSH_HE]));
49717 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
49718 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
49719 seq_printf(m, "\nReads: %d sent %d failed",
49720 - atomic_read(&sent[SMB2_READ_HE]),
49721 - atomic_read(&failed[SMB2_READ_HE]));
49722 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
49723 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
49724 seq_printf(m, "\nWrites: %d sent %d failed",
49725 - atomic_read(&sent[SMB2_WRITE_HE]),
49726 - atomic_read(&failed[SMB2_WRITE_HE]));
49727 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
49728 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
49729 seq_printf(m, "\nLocks: %d sent %d failed",
49730 - atomic_read(&sent[SMB2_LOCK_HE]),
49731 - atomic_read(&failed[SMB2_LOCK_HE]));
49732 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
49733 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
49734 seq_printf(m, "\nIOCTLs: %d sent %d failed",
49735 - atomic_read(&sent[SMB2_IOCTL_HE]),
49736 - atomic_read(&failed[SMB2_IOCTL_HE]));
49737 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
49738 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
49739 seq_printf(m, "\nCancels: %d sent %d failed",
49740 - atomic_read(&sent[SMB2_CANCEL_HE]),
49741 - atomic_read(&failed[SMB2_CANCEL_HE]));
49742 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
49743 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
49744 seq_printf(m, "\nEchos: %d sent %d failed",
49745 - atomic_read(&sent[SMB2_ECHO_HE]),
49746 - atomic_read(&failed[SMB2_ECHO_HE]));
49747 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
49748 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
49749 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
49750 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
49751 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
49752 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
49753 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
49754 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
49755 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
49756 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
49757 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
49758 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
49759 seq_printf(m, "\nQueryInfos: %d sent %d failed",
49760 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
49761 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
49762 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
49763 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
49764 seq_printf(m, "\nSetInfos: %d sent %d failed",
49765 - atomic_read(&sent[SMB2_SET_INFO_HE]),
49766 - atomic_read(&failed[SMB2_SET_INFO_HE]));
49767 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
49768 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
49769 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
49770 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
49771 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
49772 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
49773 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
49774 #endif
49775 }
49776
49777 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
49778 index 41d9d07..dbb4772 100644
49779 --- a/fs/cifs/smb2pdu.c
49780 +++ b/fs/cifs/smb2pdu.c
49781 @@ -1761,8 +1761,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
49782 default:
49783 cERROR(1, "info level %u isn't supported",
49784 srch_inf->info_level);
49785 - rc = -EINVAL;
49786 - goto qdir_exit;
49787 + return -EINVAL;
49788 }
49789
49790 req->FileIndex = cpu_to_le32(index);
49791 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
49792 index 1da168c..8bc7ff6 100644
49793 --- a/fs/coda/cache.c
49794 +++ b/fs/coda/cache.c
49795 @@ -24,7 +24,7 @@
49796 #include "coda_linux.h"
49797 #include "coda_cache.h"
49798
49799 -static atomic_t permission_epoch = ATOMIC_INIT(0);
49800 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
49801
49802 /* replace or extend an acl cache hit */
49803 void coda_cache_enter(struct inode *inode, int mask)
49804 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
49805 struct coda_inode_info *cii = ITOC(inode);
49806
49807 spin_lock(&cii->c_lock);
49808 - cii->c_cached_epoch = atomic_read(&permission_epoch);
49809 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
49810 if (!uid_eq(cii->c_uid, current_fsuid())) {
49811 cii->c_uid = current_fsuid();
49812 cii->c_cached_perm = mask;
49813 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
49814 {
49815 struct coda_inode_info *cii = ITOC(inode);
49816 spin_lock(&cii->c_lock);
49817 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
49818 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
49819 spin_unlock(&cii->c_lock);
49820 }
49821
49822 /* remove all acl caches */
49823 void coda_cache_clear_all(struct super_block *sb)
49824 {
49825 - atomic_inc(&permission_epoch);
49826 + atomic_inc_unchecked(&permission_epoch);
49827 }
49828
49829
49830 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
49831 spin_lock(&cii->c_lock);
49832 hit = (mask & cii->c_cached_perm) == mask &&
49833 uid_eq(cii->c_uid, current_fsuid()) &&
49834 - cii->c_cached_epoch == atomic_read(&permission_epoch);
49835 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
49836 spin_unlock(&cii->c_lock);
49837
49838 return hit;
49839 diff --git a/fs/compat.c b/fs/compat.c
49840 index d487985..c9e04b1 100644
49841 --- a/fs/compat.c
49842 +++ b/fs/compat.c
49843 @@ -54,7 +54,7 @@
49844 #include <asm/ioctls.h>
49845 #include "internal.h"
49846
49847 -int compat_log = 1;
49848 +int compat_log = 0;
49849
49850 int compat_printk(const char *fmt, ...)
49851 {
49852 @@ -490,7 +490,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
49853
49854 set_fs(KERNEL_DS);
49855 /* The __user pointer cast is valid because of the set_fs() */
49856 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
49857 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
49858 set_fs(oldfs);
49859 /* truncating is ok because it's a user address */
49860 if (!ret)
49861 @@ -548,7 +548,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
49862 goto out;
49863
49864 ret = -EINVAL;
49865 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
49866 + if (nr_segs > UIO_MAXIOV)
49867 goto out;
49868 if (nr_segs > fast_segs) {
49869 ret = -ENOMEM;
49870 @@ -835,6 +835,7 @@ struct compat_old_linux_dirent {
49871
49872 struct compat_readdir_callback {
49873 struct compat_old_linux_dirent __user *dirent;
49874 + struct file * file;
49875 int result;
49876 };
49877
49878 @@ -852,6 +853,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
49879 buf->result = -EOVERFLOW;
49880 return -EOVERFLOW;
49881 }
49882 +
49883 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49884 + return 0;
49885 +
49886 buf->result++;
49887 dirent = buf->dirent;
49888 if (!access_ok(VERIFY_WRITE, dirent,
49889 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
49890
49891 buf.result = 0;
49892 buf.dirent = dirent;
49893 + buf.file = f.file;
49894
49895 error = vfs_readdir(f.file, compat_fillonedir, &buf);
49896 if (buf.result)
49897 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
49898 struct compat_getdents_callback {
49899 struct compat_linux_dirent __user *current_dir;
49900 struct compat_linux_dirent __user *previous;
49901 + struct file * file;
49902 int count;
49903 int error;
49904 };
49905 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
49906 buf->error = -EOVERFLOW;
49907 return -EOVERFLOW;
49908 }
49909 +
49910 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49911 + return 0;
49912 +
49913 dirent = buf->previous;
49914 if (dirent) {
49915 if (__put_user(offset, &dirent->d_off))
49916 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
49917 buf.previous = NULL;
49918 buf.count = count;
49919 buf.error = 0;
49920 + buf.file = f.file;
49921
49922 error = vfs_readdir(f.file, compat_filldir, &buf);
49923 if (error >= 0)
49924 @@ -987,6 +999,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
49925 struct compat_getdents_callback64 {
49926 struct linux_dirent64 __user *current_dir;
49927 struct linux_dirent64 __user *previous;
49928 + struct file * file;
49929 int count;
49930 int error;
49931 };
49932 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
49933 buf->error = -EINVAL; /* only used if we fail.. */
49934 if (reclen > buf->count)
49935 return -EINVAL;
49936 +
49937 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
49938 + return 0;
49939 +
49940 dirent = buf->previous;
49941
49942 if (dirent) {
49943 @@ -1052,13 +1069,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
49944 buf.previous = NULL;
49945 buf.count = count;
49946 buf.error = 0;
49947 + buf.file = f.file;
49948
49949 error = vfs_readdir(f.file, compat_filldir64, &buf);
49950 if (error >= 0)
49951 error = buf.error;
49952 lastdirent = buf.previous;
49953 if (lastdirent) {
49954 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
49955 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
49956 if (__put_user_unaligned(d_off, &lastdirent->d_off))
49957 error = -EFAULT;
49958 else
49959 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
49960 index a81147e..20bf2b5 100644
49961 --- a/fs/compat_binfmt_elf.c
49962 +++ b/fs/compat_binfmt_elf.c
49963 @@ -30,11 +30,13 @@
49964 #undef elf_phdr
49965 #undef elf_shdr
49966 #undef elf_note
49967 +#undef elf_dyn
49968 #undef elf_addr_t
49969 #define elfhdr elf32_hdr
49970 #define elf_phdr elf32_phdr
49971 #define elf_shdr elf32_shdr
49972 #define elf_note elf32_note
49973 +#define elf_dyn Elf32_Dyn
49974 #define elf_addr_t Elf32_Addr
49975
49976 /*
49977 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
49978 index 3ced75f..b28d192 100644
49979 --- a/fs/compat_ioctl.c
49980 +++ b/fs/compat_ioctl.c
49981 @@ -623,7 +623,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
49982 return -EFAULT;
49983 if (__get_user(udata, &ss32->iomem_base))
49984 return -EFAULT;
49985 - ss.iomem_base = compat_ptr(udata);
49986 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
49987 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
49988 __get_user(ss.port_high, &ss32->port_high))
49989 return -EFAULT;
49990 @@ -704,8 +704,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
49991 for (i = 0; i < nmsgs; i++) {
49992 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
49993 return -EFAULT;
49994 - if (get_user(datap, &umsgs[i].buf) ||
49995 - put_user(compat_ptr(datap), &tmsgs[i].buf))
49996 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
49997 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
49998 return -EFAULT;
49999 }
50000 return sys_ioctl(fd, cmd, (unsigned long)tdata);
50001 @@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
50002 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
50003 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
50004 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
50005 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50006 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50007 return -EFAULT;
50008
50009 return ioctl_preallocate(file, p);
50010 @@ -1620,8 +1620,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
50011 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
50012 {
50013 unsigned int a, b;
50014 - a = *(unsigned int *)p;
50015 - b = *(unsigned int *)q;
50016 + a = *(const unsigned int *)p;
50017 + b = *(const unsigned int *)q;
50018 if (a > b)
50019 return 1;
50020 if (a < b)
50021 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
50022 index 7aabc6a..34c1197 100644
50023 --- a/fs/configfs/dir.c
50024 +++ b/fs/configfs/dir.c
50025 @@ -1565,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50026 }
50027 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
50028 struct configfs_dirent *next;
50029 - const char * name;
50030 + const unsigned char * name;
50031 + char d_name[sizeof(next->s_dentry->d_iname)];
50032 int len;
50033 struct inode *inode = NULL;
50034
50035 @@ -1575,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50036 continue;
50037
50038 name = configfs_get_name(next);
50039 - len = strlen(name);
50040 + if (next->s_dentry && name == next->s_dentry->d_iname) {
50041 + len = next->s_dentry->d_name.len;
50042 + memcpy(d_name, name, len);
50043 + name = d_name;
50044 + } else
50045 + len = strlen(name);
50046
50047 /*
50048 * We'll have a dentry and an inode for
50049 diff --git a/fs/coredump.c b/fs/coredump.c
50050 index c647965..a77bff3 100644
50051 --- a/fs/coredump.c
50052 +++ b/fs/coredump.c
50053 @@ -52,7 +52,7 @@ struct core_name {
50054 char *corename;
50055 int used, size;
50056 };
50057 -static atomic_t call_count = ATOMIC_INIT(1);
50058 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
50059
50060 /* The maximal length of core_pattern is also specified in sysctl.c */
50061
50062 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
50063 {
50064 char *old_corename = cn->corename;
50065
50066 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
50067 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
50068 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
50069
50070 if (!cn->corename) {
50071 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
50072 int pid_in_pattern = 0;
50073 int err = 0;
50074
50075 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
50076 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
50077 cn->corename = kmalloc(cn->size, GFP_KERNEL);
50078 cn->used = 0;
50079
50080 @@ -414,17 +414,17 @@ static void wait_for_dump_helpers(struct file *file)
50081 pipe = file_inode(file)->i_pipe;
50082
50083 pipe_lock(pipe);
50084 - pipe->readers++;
50085 - pipe->writers--;
50086 + atomic_inc(&pipe->readers);
50087 + atomic_dec(&pipe->writers);
50088
50089 - while ((pipe->readers > 1) && (!signal_pending(current))) {
50090 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
50091 wake_up_interruptible_sync(&pipe->wait);
50092 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
50093 pipe_wait(pipe);
50094 }
50095
50096 - pipe->readers--;
50097 - pipe->writers++;
50098 + atomic_dec(&pipe->readers);
50099 + atomic_inc(&pipe->writers);
50100 pipe_unlock(pipe);
50101
50102 }
50103 @@ -471,7 +471,8 @@ void do_coredump(siginfo_t *siginfo)
50104 int ispipe;
50105 struct files_struct *displaced;
50106 bool need_nonrelative = false;
50107 - static atomic_t core_dump_count = ATOMIC_INIT(0);
50108 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
50109 + long signr = siginfo->si_signo;
50110 struct coredump_params cprm = {
50111 .siginfo = siginfo,
50112 .regs = signal_pt_regs(),
50113 @@ -484,7 +485,10 @@ void do_coredump(siginfo_t *siginfo)
50114 .mm_flags = mm->flags,
50115 };
50116
50117 - audit_core_dumps(siginfo->si_signo);
50118 + audit_core_dumps(signr);
50119 +
50120 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
50121 + gr_handle_brute_attach(cprm.mm_flags);
50122
50123 binfmt = mm->binfmt;
50124 if (!binfmt || !binfmt->core_dump)
50125 @@ -508,7 +512,7 @@ void do_coredump(siginfo_t *siginfo)
50126 need_nonrelative = true;
50127 }
50128
50129 - retval = coredump_wait(siginfo->si_signo, &core_state);
50130 + retval = coredump_wait(signr, &core_state);
50131 if (retval < 0)
50132 goto fail_creds;
50133
50134 @@ -556,7 +560,7 @@ void do_coredump(siginfo_t *siginfo)
50135 }
50136 cprm.limit = RLIM_INFINITY;
50137
50138 - dump_count = atomic_inc_return(&core_dump_count);
50139 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
50140 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
50141 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
50142 task_tgid_vnr(current), current->comm);
50143 @@ -583,6 +587,8 @@ void do_coredump(siginfo_t *siginfo)
50144 } else {
50145 struct inode *inode;
50146
50147 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
50148 +
50149 if (cprm.limit < binfmt->min_coredump)
50150 goto fail_unlock;
50151
50152 @@ -640,7 +646,7 @@ close_fail:
50153 filp_close(cprm.file, NULL);
50154 fail_dropcount:
50155 if (ispipe)
50156 - atomic_dec(&core_dump_count);
50157 + atomic_dec_unchecked(&core_dump_count);
50158 fail_unlock:
50159 kfree(cn.corename);
50160 fail_corename:
50161 @@ -659,7 +665,7 @@ fail:
50162 */
50163 int dump_write(struct file *file, const void *addr, int nr)
50164 {
50165 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
50166 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
50167 }
50168 EXPORT_SYMBOL(dump_write);
50169
50170 diff --git a/fs/dcache.c b/fs/dcache.c
50171 index e689268..f36956e 100644
50172 --- a/fs/dcache.c
50173 +++ b/fs/dcache.c
50174 @@ -3100,7 +3100,7 @@ void __init vfs_caches_init(unsigned long mempages)
50175 mempages -= reserve;
50176
50177 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
50178 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
50179 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
50180
50181 dcache_init();
50182 inode_init();
50183 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
50184 index 4888cb3..e0f7cf8 100644
50185 --- a/fs/debugfs/inode.c
50186 +++ b/fs/debugfs/inode.c
50187 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
50188 */
50189 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
50190 {
50191 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
50192 + return __create_file(name, S_IFDIR | S_IRWXU,
50193 +#else
50194 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
50195 +#endif
50196 parent, NULL, NULL);
50197 }
50198 EXPORT_SYMBOL_GPL(debugfs_create_dir);
50199 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
50200 index 5eab400..810a3f5 100644
50201 --- a/fs/ecryptfs/inode.c
50202 +++ b/fs/ecryptfs/inode.c
50203 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
50204 old_fs = get_fs();
50205 set_fs(get_ds());
50206 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
50207 - (char __user *)lower_buf,
50208 + (char __force_user *)lower_buf,
50209 PATH_MAX);
50210 set_fs(old_fs);
50211 if (rc < 0)
50212 @@ -706,7 +706,7 @@ out:
50213 static void
50214 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
50215 {
50216 - char *buf = nd_get_link(nd);
50217 + const char *buf = nd_get_link(nd);
50218 if (!IS_ERR(buf)) {
50219 /* Free the char* */
50220 kfree(buf);
50221 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
50222 index e4141f2..d8263e8 100644
50223 --- a/fs/ecryptfs/miscdev.c
50224 +++ b/fs/ecryptfs/miscdev.c
50225 @@ -304,7 +304,7 @@ check_list:
50226 goto out_unlock_msg_ctx;
50227 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
50228 if (msg_ctx->msg) {
50229 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
50230 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
50231 goto out_unlock_msg_ctx;
50232 i += packet_length_size;
50233 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
50234 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
50235 index 6a16053..2155147 100644
50236 --- a/fs/ecryptfs/read_write.c
50237 +++ b/fs/ecryptfs/read_write.c
50238 @@ -240,7 +240,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
50239 return -EIO;
50240 fs_save = get_fs();
50241 set_fs(get_ds());
50242 - rc = vfs_read(lower_file, data, size, &offset);
50243 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
50244 set_fs(fs_save);
50245 return rc;
50246 }
50247 diff --git a/fs/exec.c b/fs/exec.c
50248 index 6d56ff2..3bc6638 100644
50249 --- a/fs/exec.c
50250 +++ b/fs/exec.c
50251 @@ -55,8 +55,20 @@
50252 #include <linux/pipe_fs_i.h>
50253 #include <linux/oom.h>
50254 #include <linux/compat.h>
50255 +#include <linux/random.h>
50256 +#include <linux/seq_file.h>
50257 +#include <linux/coredump.h>
50258 +#include <linux/mman.h>
50259 +
50260 +#ifdef CONFIG_PAX_REFCOUNT
50261 +#include <linux/kallsyms.h>
50262 +#include <linux/kdebug.h>
50263 +#endif
50264 +
50265 +#include <trace/events/fs.h>
50266
50267 #include <asm/uaccess.h>
50268 +#include <asm/sections.h>
50269 #include <asm/mmu_context.h>
50270 #include <asm/tlb.h>
50271
50272 @@ -66,6 +78,18 @@
50273
50274 #include <trace/events/sched.h>
50275
50276 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
50277 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
50278 +{
50279 + 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");
50280 +}
50281 +#endif
50282 +
50283 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
50284 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
50285 +EXPORT_SYMBOL(pax_set_initial_flags_func);
50286 +#endif
50287 +
50288 int suid_dumpable = 0;
50289
50290 static LIST_HEAD(formats);
50291 @@ -75,8 +99,8 @@ void __register_binfmt(struct linux_binfmt * fmt, int insert)
50292 {
50293 BUG_ON(!fmt);
50294 write_lock(&binfmt_lock);
50295 - insert ? list_add(&fmt->lh, &formats) :
50296 - list_add_tail(&fmt->lh, &formats);
50297 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
50298 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
50299 write_unlock(&binfmt_lock);
50300 }
50301
50302 @@ -85,7 +109,7 @@ EXPORT_SYMBOL(__register_binfmt);
50303 void unregister_binfmt(struct linux_binfmt * fmt)
50304 {
50305 write_lock(&binfmt_lock);
50306 - list_del(&fmt->lh);
50307 + pax_list_del((struct list_head *)&fmt->lh);
50308 write_unlock(&binfmt_lock);
50309 }
50310
50311 @@ -180,18 +204,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50312 int write)
50313 {
50314 struct page *page;
50315 - int ret;
50316
50317 -#ifdef CONFIG_STACK_GROWSUP
50318 - if (write) {
50319 - ret = expand_downwards(bprm->vma, pos);
50320 - if (ret < 0)
50321 - return NULL;
50322 - }
50323 -#endif
50324 - ret = get_user_pages(current, bprm->mm, pos,
50325 - 1, write, 1, &page, NULL);
50326 - if (ret <= 0)
50327 + if (0 > expand_downwards(bprm->vma, pos))
50328 + return NULL;
50329 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
50330 return NULL;
50331
50332 if (write) {
50333 @@ -207,6 +223,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50334 if (size <= ARG_MAX)
50335 return page;
50336
50337 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50338 + // only allow 512KB for argv+env on suid/sgid binaries
50339 + // to prevent easy ASLR exhaustion
50340 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
50341 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
50342 + (size > (512 * 1024))) {
50343 + put_page(page);
50344 + return NULL;
50345 + }
50346 +#endif
50347 +
50348 /*
50349 * Limit to 1/4-th the stack size for the argv+env strings.
50350 * This ensures that:
50351 @@ -266,6 +293,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50352 vma->vm_end = STACK_TOP_MAX;
50353 vma->vm_start = vma->vm_end - PAGE_SIZE;
50354 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
50355 +
50356 +#ifdef CONFIG_PAX_SEGMEXEC
50357 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
50358 +#endif
50359 +
50360 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
50361 INIT_LIST_HEAD(&vma->anon_vma_chain);
50362
50363 @@ -276,6 +308,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50364 mm->stack_vm = mm->total_vm = 1;
50365 up_write(&mm->mmap_sem);
50366 bprm->p = vma->vm_end - sizeof(void *);
50367 +
50368 +#ifdef CONFIG_PAX_RANDUSTACK
50369 + if (randomize_va_space)
50370 + bprm->p ^= random32() & ~PAGE_MASK;
50371 +#endif
50372 +
50373 return 0;
50374 err:
50375 up_write(&mm->mmap_sem);
50376 @@ -396,7 +434,7 @@ struct user_arg_ptr {
50377 } ptr;
50378 };
50379
50380 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50381 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50382 {
50383 const char __user *native;
50384
50385 @@ -405,14 +443,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50386 compat_uptr_t compat;
50387
50388 if (get_user(compat, argv.ptr.compat + nr))
50389 - return ERR_PTR(-EFAULT);
50390 + return (const char __force_user *)ERR_PTR(-EFAULT);
50391
50392 return compat_ptr(compat);
50393 }
50394 #endif
50395
50396 if (get_user(native, argv.ptr.native + nr))
50397 - return ERR_PTR(-EFAULT);
50398 + return (const char __force_user *)ERR_PTR(-EFAULT);
50399
50400 return native;
50401 }
50402 @@ -431,7 +469,7 @@ static int count(struct user_arg_ptr argv, int max)
50403 if (!p)
50404 break;
50405
50406 - if (IS_ERR(p))
50407 + if (IS_ERR((const char __force_kernel *)p))
50408 return -EFAULT;
50409
50410 if (i >= max)
50411 @@ -466,7 +504,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
50412
50413 ret = -EFAULT;
50414 str = get_user_arg_ptr(argv, argc);
50415 - if (IS_ERR(str))
50416 + if (IS_ERR((const char __force_kernel *)str))
50417 goto out;
50418
50419 len = strnlen_user(str, MAX_ARG_STRLEN);
50420 @@ -548,7 +586,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
50421 int r;
50422 mm_segment_t oldfs = get_fs();
50423 struct user_arg_ptr argv = {
50424 - .ptr.native = (const char __user *const __user *)__argv,
50425 + .ptr.native = (const char __force_user * const __force_user *)__argv,
50426 };
50427
50428 set_fs(KERNEL_DS);
50429 @@ -583,7 +621,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50430 unsigned long new_end = old_end - shift;
50431 struct mmu_gather tlb;
50432
50433 - BUG_ON(new_start > new_end);
50434 + if (new_start >= new_end || new_start < mmap_min_addr)
50435 + return -ENOMEM;
50436
50437 /*
50438 * ensure there are no vmas between where we want to go
50439 @@ -592,6 +631,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50440 if (vma != find_vma(mm, new_start))
50441 return -EFAULT;
50442
50443 +#ifdef CONFIG_PAX_SEGMEXEC
50444 + BUG_ON(pax_find_mirror_vma(vma));
50445 +#endif
50446 +
50447 /*
50448 * cover the whole range: [new_start, old_end)
50449 */
50450 @@ -672,10 +715,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50451 stack_top = arch_align_stack(stack_top);
50452 stack_top = PAGE_ALIGN(stack_top);
50453
50454 - if (unlikely(stack_top < mmap_min_addr) ||
50455 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
50456 - return -ENOMEM;
50457 -
50458 stack_shift = vma->vm_end - stack_top;
50459
50460 bprm->p -= stack_shift;
50461 @@ -687,8 +726,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
50462 bprm->exec -= stack_shift;
50463
50464 down_write(&mm->mmap_sem);
50465 +
50466 + /* Move stack pages down in memory. */
50467 + if (stack_shift) {
50468 + ret = shift_arg_pages(vma, stack_shift);
50469 + if (ret)
50470 + goto out_unlock;
50471 + }
50472 +
50473 vm_flags = VM_STACK_FLAGS;
50474
50475 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50476 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
50477 + vm_flags &= ~VM_EXEC;
50478 +
50479 +#ifdef CONFIG_PAX_MPROTECT
50480 + if (mm->pax_flags & MF_PAX_MPROTECT)
50481 + vm_flags &= ~VM_MAYEXEC;
50482 +#endif
50483 +
50484 + }
50485 +#endif
50486 +
50487 /*
50488 * Adjust stack execute permissions; explicitly enable for
50489 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
50490 @@ -707,13 +766,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50491 goto out_unlock;
50492 BUG_ON(prev != vma);
50493
50494 - /* Move stack pages down in memory. */
50495 - if (stack_shift) {
50496 - ret = shift_arg_pages(vma, stack_shift);
50497 - if (ret)
50498 - goto out_unlock;
50499 - }
50500 -
50501 /* mprotect_fixup is overkill to remove the temporary stack flags */
50502 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
50503
50504 @@ -737,6 +789,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
50505 #endif
50506 current->mm->start_stack = bprm->p;
50507 ret = expand_stack(vma, stack_base);
50508 +
50509 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
50510 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
50511 + unsigned long size;
50512 + vm_flags_t vm_flags;
50513 +
50514 + size = STACK_TOP - vma->vm_end;
50515 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
50516 +
50517 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
50518 +
50519 +#ifdef CONFIG_X86
50520 + if (!ret) {
50521 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
50522 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
50523 + }
50524 +#endif
50525 +
50526 + }
50527 +#endif
50528 +
50529 if (ret)
50530 ret = -EFAULT;
50531
50532 @@ -772,6 +845,8 @@ struct file *open_exec(const char *name)
50533
50534 fsnotify_open(file);
50535
50536 + trace_open_exec(name);
50537 +
50538 err = deny_write_access(file);
50539 if (err)
50540 goto exit;
50541 @@ -795,7 +870,7 @@ int kernel_read(struct file *file, loff_t offset,
50542 old_fs = get_fs();
50543 set_fs(get_ds());
50544 /* The cast to a user pointer is valid due to the set_fs() */
50545 - result = vfs_read(file, (void __user *)addr, count, &pos);
50546 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
50547 set_fs(old_fs);
50548 return result;
50549 }
50550 @@ -1250,7 +1325,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
50551 }
50552 rcu_read_unlock();
50553
50554 - if (p->fs->users > n_fs) {
50555 + if (atomic_read(&p->fs->users) > n_fs) {
50556 bprm->unsafe |= LSM_UNSAFE_SHARE;
50557 } else {
50558 res = -EAGAIN;
50559 @@ -1450,6 +1525,31 @@ int search_binary_handler(struct linux_binprm *bprm)
50560
50561 EXPORT_SYMBOL(search_binary_handler);
50562
50563 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50564 +static DEFINE_PER_CPU(u64, exec_counter);
50565 +static int __init init_exec_counters(void)
50566 +{
50567 + unsigned int cpu;
50568 +
50569 + for_each_possible_cpu(cpu) {
50570 + per_cpu(exec_counter, cpu) = (u64)cpu;
50571 + }
50572 +
50573 + return 0;
50574 +}
50575 +early_initcall(init_exec_counters);
50576 +static inline void increment_exec_counter(void)
50577 +{
50578 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
50579 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
50580 +}
50581 +#else
50582 +static inline void increment_exec_counter(void) {}
50583 +#endif
50584 +
50585 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
50586 + struct user_arg_ptr argv);
50587 +
50588 /*
50589 * sys_execve() executes a new program.
50590 */
50591 @@ -1457,6 +1557,11 @@ static int do_execve_common(const char *filename,
50592 struct user_arg_ptr argv,
50593 struct user_arg_ptr envp)
50594 {
50595 +#ifdef CONFIG_GRKERNSEC
50596 + struct file *old_exec_file;
50597 + struct acl_subject_label *old_acl;
50598 + struct rlimit old_rlim[RLIM_NLIMITS];
50599 +#endif
50600 struct linux_binprm *bprm;
50601 struct file *file;
50602 struct files_struct *displaced;
50603 @@ -1464,6 +1569,8 @@ static int do_execve_common(const char *filename,
50604 int retval;
50605 const struct cred *cred = current_cred();
50606
50607 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&cred->user->processes), 1);
50608 +
50609 /*
50610 * We move the actual failure in case of RLIMIT_NPROC excess from
50611 * set*uid() to execve() because too many poorly written programs
50612 @@ -1504,12 +1611,27 @@ static int do_execve_common(const char *filename,
50613 if (IS_ERR(file))
50614 goto out_unmark;
50615
50616 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
50617 + retval = -EPERM;
50618 + goto out_file;
50619 + }
50620 +
50621 sched_exec();
50622
50623 bprm->file = file;
50624 bprm->filename = filename;
50625 bprm->interp = filename;
50626
50627 + if (gr_process_user_ban()) {
50628 + retval = -EPERM;
50629 + goto out_file;
50630 + }
50631 +
50632 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
50633 + retval = -EACCES;
50634 + goto out_file;
50635 + }
50636 +
50637 retval = bprm_mm_init(bprm);
50638 if (retval)
50639 goto out_file;
50640 @@ -1526,24 +1648,65 @@ static int do_execve_common(const char *filename,
50641 if (retval < 0)
50642 goto out;
50643
50644 +#ifdef CONFIG_GRKERNSEC
50645 + old_acl = current->acl;
50646 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
50647 + old_exec_file = current->exec_file;
50648 + get_file(file);
50649 + current->exec_file = file;
50650 +#endif
50651 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50652 + /* limit suid stack to 8MB
50653 + * we saved the old limits above and will restore them if this exec fails
50654 + */
50655 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
50656 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
50657 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
50658 +#endif
50659 +
50660 + if (!gr_tpe_allow(file)) {
50661 + retval = -EACCES;
50662 + goto out_fail;
50663 + }
50664 +
50665 + if (gr_check_crash_exec(file)) {
50666 + retval = -EACCES;
50667 + goto out_fail;
50668 + }
50669 +
50670 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
50671 + bprm->unsafe);
50672 + if (retval < 0)
50673 + goto out_fail;
50674 +
50675 retval = copy_strings_kernel(1, &bprm->filename, bprm);
50676 if (retval < 0)
50677 - goto out;
50678 + goto out_fail;
50679
50680 bprm->exec = bprm->p;
50681 retval = copy_strings(bprm->envc, envp, bprm);
50682 if (retval < 0)
50683 - goto out;
50684 + goto out_fail;
50685
50686 retval = copy_strings(bprm->argc, argv, bprm);
50687 if (retval < 0)
50688 - goto out;
50689 + goto out_fail;
50690 +
50691 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
50692 +
50693 + gr_handle_exec_args(bprm, argv);
50694
50695 retval = search_binary_handler(bprm);
50696 if (retval < 0)
50697 - goto out;
50698 + goto out_fail;
50699 +#ifdef CONFIG_GRKERNSEC
50700 + if (old_exec_file)
50701 + fput(old_exec_file);
50702 +#endif
50703
50704 /* execve succeeded */
50705 +
50706 + increment_exec_counter();
50707 current->fs->in_exec = 0;
50708 current->in_execve = 0;
50709 acct_update_integrals(current);
50710 @@ -1552,6 +1715,14 @@ static int do_execve_common(const char *filename,
50711 put_files_struct(displaced);
50712 return retval;
50713
50714 +out_fail:
50715 +#ifdef CONFIG_GRKERNSEC
50716 + current->acl = old_acl;
50717 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
50718 + fput(current->exec_file);
50719 + current->exec_file = old_exec_file;
50720 +#endif
50721 +
50722 out:
50723 if (bprm->mm) {
50724 acct_arg_size(bprm, 0);
50725 @@ -1700,3 +1871,283 @@ asmlinkage long compat_sys_execve(const char __user * filename,
50726 return error;
50727 }
50728 #endif
50729 +
50730 +int pax_check_flags(unsigned long *flags)
50731 +{
50732 + int retval = 0;
50733 +
50734 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
50735 + if (*flags & MF_PAX_SEGMEXEC)
50736 + {
50737 + *flags &= ~MF_PAX_SEGMEXEC;
50738 + retval = -EINVAL;
50739 + }
50740 +#endif
50741 +
50742 + if ((*flags & MF_PAX_PAGEEXEC)
50743 +
50744 +#ifdef CONFIG_PAX_PAGEEXEC
50745 + && (*flags & MF_PAX_SEGMEXEC)
50746 +#endif
50747 +
50748 + )
50749 + {
50750 + *flags &= ~MF_PAX_PAGEEXEC;
50751 + retval = -EINVAL;
50752 + }
50753 +
50754 + if ((*flags & MF_PAX_MPROTECT)
50755 +
50756 +#ifdef CONFIG_PAX_MPROTECT
50757 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
50758 +#endif
50759 +
50760 + )
50761 + {
50762 + *flags &= ~MF_PAX_MPROTECT;
50763 + retval = -EINVAL;
50764 + }
50765 +
50766 + if ((*flags & MF_PAX_EMUTRAMP)
50767 +
50768 +#ifdef CONFIG_PAX_EMUTRAMP
50769 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
50770 +#endif
50771 +
50772 + )
50773 + {
50774 + *flags &= ~MF_PAX_EMUTRAMP;
50775 + retval = -EINVAL;
50776 + }
50777 +
50778 + return retval;
50779 +}
50780 +
50781 +EXPORT_SYMBOL(pax_check_flags);
50782 +
50783 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50784 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
50785 +{
50786 + struct task_struct *tsk = current;
50787 + struct mm_struct *mm = current->mm;
50788 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
50789 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
50790 + char *path_exec = NULL;
50791 + char *path_fault = NULL;
50792 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
50793 + siginfo_t info = { };
50794 +
50795 + if (buffer_exec && buffer_fault) {
50796 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
50797 +
50798 + down_read(&mm->mmap_sem);
50799 + vma = mm->mmap;
50800 + while (vma && (!vma_exec || !vma_fault)) {
50801 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
50802 + vma_exec = vma;
50803 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
50804 + vma_fault = vma;
50805 + vma = vma->vm_next;
50806 + }
50807 + if (vma_exec) {
50808 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
50809 + if (IS_ERR(path_exec))
50810 + path_exec = "<path too long>";
50811 + else {
50812 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
50813 + if (path_exec) {
50814 + *path_exec = 0;
50815 + path_exec = buffer_exec;
50816 + } else
50817 + path_exec = "<path too long>";
50818 + }
50819 + }
50820 + if (vma_fault) {
50821 + start = vma_fault->vm_start;
50822 + end = vma_fault->vm_end;
50823 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
50824 + if (vma_fault->vm_file) {
50825 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
50826 + if (IS_ERR(path_fault))
50827 + path_fault = "<path too long>";
50828 + else {
50829 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
50830 + if (path_fault) {
50831 + *path_fault = 0;
50832 + path_fault = buffer_fault;
50833 + } else
50834 + path_fault = "<path too long>";
50835 + }
50836 + } else
50837 + path_fault = "<anonymous mapping>";
50838 + }
50839 + up_read(&mm->mmap_sem);
50840 + }
50841 + if (tsk->signal->curr_ip)
50842 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
50843 + else
50844 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
50845 + 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),
50846 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
50847 + free_page((unsigned long)buffer_exec);
50848 + free_page((unsigned long)buffer_fault);
50849 + pax_report_insns(regs, pc, sp);
50850 + info.si_signo = SIGKILL;
50851 + info.si_errno = 0;
50852 + info.si_code = SI_KERNEL;
50853 + info.si_pid = 0;
50854 + info.si_uid = 0;
50855 + do_coredump(&info);
50856 +}
50857 +#endif
50858 +
50859 +#ifdef CONFIG_PAX_REFCOUNT
50860 +void pax_report_refcount_overflow(struct pt_regs *regs)
50861 +{
50862 + if (current->signal->curr_ip)
50863 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
50864 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
50865 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
50866 + else
50867 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
50868 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
50869 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
50870 + show_regs(regs);
50871 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
50872 +}
50873 +#endif
50874 +
50875 +#ifdef CONFIG_PAX_USERCOPY
50876 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
50877 +static noinline int check_stack_object(const void *obj, unsigned long len)
50878 +{
50879 + const void * const stack = task_stack_page(current);
50880 + const void * const stackend = stack + THREAD_SIZE;
50881 +
50882 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
50883 + const void *frame = NULL;
50884 + const void *oldframe;
50885 +#endif
50886 +
50887 + if (obj + len < obj)
50888 + return -1;
50889 +
50890 + if (obj + len <= stack || stackend <= obj)
50891 + return 0;
50892 +
50893 + if (obj < stack || stackend < obj + len)
50894 + return -1;
50895 +
50896 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
50897 + oldframe = __builtin_frame_address(1);
50898 + if (oldframe)
50899 + frame = __builtin_frame_address(2);
50900 + /*
50901 + low ----------------------------------------------> high
50902 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
50903 + ^----------------^
50904 + allow copies only within here
50905 + */
50906 + while (stack <= frame && frame < stackend) {
50907 + /* if obj + len extends past the last frame, this
50908 + check won't pass and the next frame will be 0,
50909 + causing us to bail out and correctly report
50910 + the copy as invalid
50911 + */
50912 + if (obj + len <= frame)
50913 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
50914 + oldframe = frame;
50915 + frame = *(const void * const *)frame;
50916 + }
50917 + return -1;
50918 +#else
50919 + return 1;
50920 +#endif
50921 +}
50922 +
50923 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
50924 +{
50925 + if (current->signal->curr_ip)
50926 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
50927 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
50928 + else
50929 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
50930 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
50931 + dump_stack();
50932 + gr_handle_kernel_exploit();
50933 + do_group_exit(SIGKILL);
50934 +}
50935 +#endif
50936 +
50937 +#ifdef CONFIG_PAX_USERCOPY
50938 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
50939 +{
50940 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
50941 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
50942 +#ifdef CONFIG_MODULES
50943 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
50944 +#else
50945 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
50946 +#endif
50947 +
50948 +#else
50949 + unsigned long textlow = (unsigned long)_stext;
50950 + unsigned long texthigh = (unsigned long)_etext;
50951 +#endif
50952 +
50953 + if (high <= textlow || low > texthigh)
50954 + return false;
50955 + else
50956 + return true;
50957 +}
50958 +#endif
50959 +
50960 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
50961 +{
50962 +
50963 +#ifdef CONFIG_PAX_USERCOPY
50964 + const char *type;
50965 +
50966 + if (!n)
50967 + return;
50968 +
50969 + type = check_heap_object(ptr, n);
50970 + if (!type) {
50971 + int ret = check_stack_object(ptr, n);
50972 + if (ret == 1 || ret == 2)
50973 + return;
50974 + if (ret == 0) {
50975 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
50976 + type = "<kernel text>";
50977 + else
50978 + return;
50979 + } else
50980 + type = "<process stack>";
50981 + }
50982 +
50983 + pax_report_usercopy(ptr, n, to_user, type);
50984 +#endif
50985 +
50986 +}
50987 +EXPORT_SYMBOL(__check_object_size);
50988 +
50989 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
50990 +void pax_track_stack(void)
50991 +{
50992 + unsigned long sp = (unsigned long)&sp;
50993 + if (sp < current_thread_info()->lowest_stack &&
50994 + sp > (unsigned long)task_stack_page(current))
50995 + current_thread_info()->lowest_stack = sp;
50996 +}
50997 +EXPORT_SYMBOL(pax_track_stack);
50998 +#endif
50999 +
51000 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
51001 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
51002 +{
51003 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
51004 + dump_stack();
51005 + do_group_exit(SIGKILL);
51006 +}
51007 +EXPORT_SYMBOL(report_size_overflow);
51008 +#endif
51009 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
51010 index 9f9992b..8b59411 100644
51011 --- a/fs/ext2/balloc.c
51012 +++ b/fs/ext2/balloc.c
51013 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
51014
51015 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51016 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51017 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51018 + if (free_blocks < root_blocks + 1 &&
51019 !uid_eq(sbi->s_resuid, current_fsuid()) &&
51020 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51021 - !in_group_p (sbi->s_resgid))) {
51022 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51023 return 0;
51024 }
51025 return 1;
51026 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
51027 index 22548f5..41521d8 100644
51028 --- a/fs/ext3/balloc.c
51029 +++ b/fs/ext3/balloc.c
51030 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
51031
51032 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51033 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51034 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51035 + if (free_blocks < root_blocks + 1 &&
51036 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
51037 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51038 - !in_group_p (sbi->s_resgid))) {
51039 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51040 return 0;
51041 }
51042 return 1;
51043 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
51044 index 92e68b3..115d987 100644
51045 --- a/fs/ext4/balloc.c
51046 +++ b/fs/ext4/balloc.c
51047 @@ -505,8 +505,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
51048 /* Hm, nope. Are (enough) root reserved clusters available? */
51049 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
51050 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
51051 - capable(CAP_SYS_RESOURCE) ||
51052 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
51053 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
51054 + capable_nolog(CAP_SYS_RESOURCE)) {
51055
51056 if (free_clusters >= (nclusters + dirty_clusters))
51057 return 1;
51058 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
51059 index 3b83cd6..0f34dcd 100644
51060 --- a/fs/ext4/ext4.h
51061 +++ b/fs/ext4/ext4.h
51062 @@ -1254,19 +1254,19 @@ struct ext4_sb_info {
51063 unsigned long s_mb_last_start;
51064
51065 /* stats for buddy allocator */
51066 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
51067 - atomic_t s_bal_success; /* we found long enough chunks */
51068 - atomic_t s_bal_allocated; /* in blocks */
51069 - atomic_t s_bal_ex_scanned; /* total extents scanned */
51070 - atomic_t s_bal_goals; /* goal hits */
51071 - atomic_t s_bal_breaks; /* too long searches */
51072 - atomic_t s_bal_2orders; /* 2^order hits */
51073 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
51074 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
51075 + atomic_unchecked_t s_bal_allocated; /* in blocks */
51076 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
51077 + atomic_unchecked_t s_bal_goals; /* goal hits */
51078 + atomic_unchecked_t s_bal_breaks; /* too long searches */
51079 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
51080 spinlock_t s_bal_lock;
51081 unsigned long s_mb_buddies_generated;
51082 unsigned long long s_mb_generation_time;
51083 - atomic_t s_mb_lost_chunks;
51084 - atomic_t s_mb_preallocated;
51085 - atomic_t s_mb_discarded;
51086 + atomic_unchecked_t s_mb_lost_chunks;
51087 + atomic_unchecked_t s_mb_preallocated;
51088 + atomic_unchecked_t s_mb_discarded;
51089 atomic_t s_lock_busy;
51090
51091 /* locality groups */
51092 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
51093 index f3190ab..84ffb21 100644
51094 --- a/fs/ext4/mballoc.c
51095 +++ b/fs/ext4/mballoc.c
51096 @@ -1754,7 +1754,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
51097 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
51098
51099 if (EXT4_SB(sb)->s_mb_stats)
51100 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
51101 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
51102
51103 break;
51104 }
51105 @@ -2059,7 +2059,7 @@ repeat:
51106 ac->ac_status = AC_STATUS_CONTINUE;
51107 ac->ac_flags |= EXT4_MB_HINT_FIRST;
51108 cr = 3;
51109 - atomic_inc(&sbi->s_mb_lost_chunks);
51110 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
51111 goto repeat;
51112 }
51113 }
51114 @@ -2567,25 +2567,25 @@ int ext4_mb_release(struct super_block *sb)
51115 if (sbi->s_mb_stats) {
51116 ext4_msg(sb, KERN_INFO,
51117 "mballoc: %u blocks %u reqs (%u success)",
51118 - atomic_read(&sbi->s_bal_allocated),
51119 - atomic_read(&sbi->s_bal_reqs),
51120 - atomic_read(&sbi->s_bal_success));
51121 + atomic_read_unchecked(&sbi->s_bal_allocated),
51122 + atomic_read_unchecked(&sbi->s_bal_reqs),
51123 + atomic_read_unchecked(&sbi->s_bal_success));
51124 ext4_msg(sb, KERN_INFO,
51125 "mballoc: %u extents scanned, %u goal hits, "
51126 "%u 2^N hits, %u breaks, %u lost",
51127 - atomic_read(&sbi->s_bal_ex_scanned),
51128 - atomic_read(&sbi->s_bal_goals),
51129 - atomic_read(&sbi->s_bal_2orders),
51130 - atomic_read(&sbi->s_bal_breaks),
51131 - atomic_read(&sbi->s_mb_lost_chunks));
51132 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
51133 + atomic_read_unchecked(&sbi->s_bal_goals),
51134 + atomic_read_unchecked(&sbi->s_bal_2orders),
51135 + atomic_read_unchecked(&sbi->s_bal_breaks),
51136 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
51137 ext4_msg(sb, KERN_INFO,
51138 "mballoc: %lu generated and it took %Lu",
51139 sbi->s_mb_buddies_generated,
51140 sbi->s_mb_generation_time);
51141 ext4_msg(sb, KERN_INFO,
51142 "mballoc: %u preallocated, %u discarded",
51143 - atomic_read(&sbi->s_mb_preallocated),
51144 - atomic_read(&sbi->s_mb_discarded));
51145 + atomic_read_unchecked(&sbi->s_mb_preallocated),
51146 + atomic_read_unchecked(&sbi->s_mb_discarded));
51147 }
51148
51149 free_percpu(sbi->s_locality_groups);
51150 @@ -3039,16 +3039,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
51151 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
51152
51153 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
51154 - atomic_inc(&sbi->s_bal_reqs);
51155 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51156 + atomic_inc_unchecked(&sbi->s_bal_reqs);
51157 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51158 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
51159 - atomic_inc(&sbi->s_bal_success);
51160 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
51161 + atomic_inc_unchecked(&sbi->s_bal_success);
51162 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
51163 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
51164 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
51165 - atomic_inc(&sbi->s_bal_goals);
51166 + atomic_inc_unchecked(&sbi->s_bal_goals);
51167 if (ac->ac_found > sbi->s_mb_max_to_scan)
51168 - atomic_inc(&sbi->s_bal_breaks);
51169 + atomic_inc_unchecked(&sbi->s_bal_breaks);
51170 }
51171
51172 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
51173 @@ -3448,7 +3448,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
51174 trace_ext4_mb_new_inode_pa(ac, pa);
51175
51176 ext4_mb_use_inode_pa(ac, pa);
51177 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
51178 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
51179
51180 ei = EXT4_I(ac->ac_inode);
51181 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51182 @@ -3508,7 +3508,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
51183 trace_ext4_mb_new_group_pa(ac, pa);
51184
51185 ext4_mb_use_group_pa(ac, pa);
51186 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51187 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51188
51189 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51190 lg = ac->ac_lg;
51191 @@ -3597,7 +3597,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
51192 * from the bitmap and continue.
51193 */
51194 }
51195 - atomic_add(free, &sbi->s_mb_discarded);
51196 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
51197
51198 return err;
51199 }
51200 @@ -3615,7 +3615,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
51201 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
51202 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
51203 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
51204 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51205 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51206 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
51207
51208 return 0;
51209 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
51210 index febbe0e..782c4fd 100644
51211 --- a/fs/ext4/super.c
51212 +++ b/fs/ext4/super.c
51213 @@ -2380,7 +2380,7 @@ struct ext4_attr {
51214 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
51215 const char *, size_t);
51216 int offset;
51217 -};
51218 +} __do_const;
51219
51220 static int parse_strtoul(const char *buf,
51221 unsigned long max, unsigned long *value)
51222 diff --git a/fs/fat/inode.c b/fs/fat/inode.c
51223 index acf6e47..e7a7fde 100644
51224 --- a/fs/fat/inode.c
51225 +++ b/fs/fat/inode.c
51226 @@ -1223,6 +1223,19 @@ static int fat_read_root(struct inode *inode)
51227 return 0;
51228 }
51229
51230 +static unsigned long calc_fat_clusters(struct super_block *sb)
51231 +{
51232 + struct msdos_sb_info *sbi = MSDOS_SB(sb);
51233 +
51234 + /* Divide first to avoid overflow */
51235 + if (sbi->fat_bits != 12) {
51236 + unsigned long ent_per_sec = sb->s_blocksize * 8 / sbi->fat_bits;
51237 + return ent_per_sec * sbi->fat_length;
51238 + }
51239 +
51240 + return sbi->fat_length * sb->s_blocksize * 8 / sbi->fat_bits;
51241 +}
51242 +
51243 /*
51244 * Read the super block of an MS-DOS FS.
51245 */
51246 @@ -1427,7 +1440,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
51247 sbi->dirty = b->fat16.state & FAT_STATE_DIRTY;
51248
51249 /* check that FAT table does not overflow */
51250 - fat_clusters = sbi->fat_length * sb->s_blocksize * 8 / sbi->fat_bits;
51251 + fat_clusters = calc_fat_clusters(sb);
51252 total_clusters = min(total_clusters, fat_clusters - FAT_START_ENT);
51253 if (total_clusters > MAX_FAT(sb)) {
51254 if (!silent)
51255 diff --git a/fs/fcntl.c b/fs/fcntl.c
51256 index 6599222..e7bf0de 100644
51257 --- a/fs/fcntl.c
51258 +++ b/fs/fcntl.c
51259 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
51260 if (err)
51261 return err;
51262
51263 + if (gr_handle_chroot_fowner(pid, type))
51264 + return -ENOENT;
51265 + if (gr_check_protected_task_fowner(pid, type))
51266 + return -EACCES;
51267 +
51268 f_modown(filp, pid, type, force);
51269 return 0;
51270 }
51271 diff --git a/fs/fhandle.c b/fs/fhandle.c
51272 index 999ff5c..41f4109 100644
51273 --- a/fs/fhandle.c
51274 +++ b/fs/fhandle.c
51275 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
51276 } else
51277 retval = 0;
51278 /* copy the mount id */
51279 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
51280 - sizeof(*mnt_id)) ||
51281 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
51282 copy_to_user(ufh, handle,
51283 sizeof(struct file_handle) + handle_bytes))
51284 retval = -EFAULT;
51285 diff --git a/fs/fifo.c b/fs/fifo.c
51286 index cf6f434..3d7942c 100644
51287 --- a/fs/fifo.c
51288 +++ b/fs/fifo.c
51289 @@ -59,10 +59,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
51290 */
51291 filp->f_op = &read_pipefifo_fops;
51292 pipe->r_counter++;
51293 - if (pipe->readers++ == 0)
51294 + if (atomic_inc_return(&pipe->readers) == 1)
51295 wake_up_partner(inode);
51296
51297 - if (!pipe->writers) {
51298 + if (!atomic_read(&pipe->writers)) {
51299 if ((filp->f_flags & O_NONBLOCK)) {
51300 /* suppress POLLHUP until we have
51301 * seen a writer */
51302 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
51303 * errno=ENXIO when there is no process reading the FIFO.
51304 */
51305 ret = -ENXIO;
51306 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
51307 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
51308 goto err;
51309
51310 filp->f_op = &write_pipefifo_fops;
51311 pipe->w_counter++;
51312 - if (!pipe->writers++)
51313 + if (atomic_inc_return(&pipe->writers) == 1)
51314 wake_up_partner(inode);
51315
51316 - if (!pipe->readers) {
51317 + if (!atomic_read(&pipe->readers)) {
51318 if (wait_for_partner(inode, &pipe->r_counter))
51319 goto err_wr;
51320 }
51321 @@ -104,11 +104,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
51322 */
51323 filp->f_op = &rdwr_pipefifo_fops;
51324
51325 - pipe->readers++;
51326 - pipe->writers++;
51327 + atomic_inc(&pipe->readers);
51328 + atomic_inc(&pipe->writers);
51329 pipe->r_counter++;
51330 pipe->w_counter++;
51331 - if (pipe->readers == 1 || pipe->writers == 1)
51332 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
51333 wake_up_partner(inode);
51334 break;
51335
51336 @@ -122,19 +122,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
51337 return 0;
51338
51339 err_rd:
51340 - if (!--pipe->readers)
51341 + if (atomic_dec_and_test(&pipe->readers))
51342 wake_up_interruptible(&pipe->wait);
51343 ret = -ERESTARTSYS;
51344 goto err;
51345
51346 err_wr:
51347 - if (!--pipe->writers)
51348 + if (atomic_dec_and_test(&pipe->writers))
51349 wake_up_interruptible(&pipe->wait);
51350 ret = -ERESTARTSYS;
51351 goto err;
51352
51353 err:
51354 - if (!pipe->readers && !pipe->writers)
51355 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
51356 free_pipe_info(inode);
51357
51358 err_nocleanup:
51359 diff --git a/fs/file.c b/fs/file.c
51360 index 3906d95..5fe379b 100644
51361 --- a/fs/file.c
51362 +++ b/fs/file.c
51363 @@ -16,6 +16,7 @@
51364 #include <linux/slab.h>
51365 #include <linux/vmalloc.h>
51366 #include <linux/file.h>
51367 +#include <linux/security.h>
51368 #include <linux/fdtable.h>
51369 #include <linux/bitops.h>
51370 #include <linux/interrupt.h>
51371 @@ -892,6 +893,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
51372 if (!file)
51373 return __close_fd(files, fd);
51374
51375 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
51376 if (fd >= rlimit(RLIMIT_NOFILE))
51377 return -EBADF;
51378
51379 @@ -918,6 +920,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
51380 if (unlikely(oldfd == newfd))
51381 return -EINVAL;
51382
51383 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
51384 if (newfd >= rlimit(RLIMIT_NOFILE))
51385 return -EBADF;
51386
51387 @@ -973,6 +976,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
51388 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
51389 {
51390 int err;
51391 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
51392 if (from >= rlimit(RLIMIT_NOFILE))
51393 return -EINVAL;
51394 err = alloc_fd(from, flags);
51395 diff --git a/fs/filesystems.c b/fs/filesystems.c
51396 index 92567d9..fcd8cbf 100644
51397 --- a/fs/filesystems.c
51398 +++ b/fs/filesystems.c
51399 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
51400 int len = dot ? dot - name : strlen(name);
51401
51402 fs = __get_fs_type(name, len);
51403 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
51404 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
51405 +#else
51406 if (!fs && (request_module("fs-%.*s", len, name) == 0))
51407 +#endif
51408 fs = __get_fs_type(name, len);
51409
51410 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
51411 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
51412 index d8ac61d..79a36f0 100644
51413 --- a/fs/fs_struct.c
51414 +++ b/fs/fs_struct.c
51415 @@ -4,6 +4,7 @@
51416 #include <linux/path.h>
51417 #include <linux/slab.h>
51418 #include <linux/fs_struct.h>
51419 +#include <linux/grsecurity.h>
51420 #include "internal.h"
51421
51422 /*
51423 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
51424 write_seqcount_begin(&fs->seq);
51425 old_root = fs->root;
51426 fs->root = *path;
51427 + gr_set_chroot_entries(current, path);
51428 write_seqcount_end(&fs->seq);
51429 spin_unlock(&fs->lock);
51430 if (old_root.dentry)
51431 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
51432 int hits = 0;
51433 spin_lock(&fs->lock);
51434 write_seqcount_begin(&fs->seq);
51435 + /* this root replacement is only done by pivot_root,
51436 + leave grsec's chroot tagging alone for this task
51437 + so that a pivoted root isn't treated as a chroot
51438 + */
51439 hits += replace_path(&fs->root, old_root, new_root);
51440 hits += replace_path(&fs->pwd, old_root, new_root);
51441 write_seqcount_end(&fs->seq);
51442 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
51443 task_lock(tsk);
51444 spin_lock(&fs->lock);
51445 tsk->fs = NULL;
51446 - kill = !--fs->users;
51447 + gr_clear_chroot_entries(tsk);
51448 + kill = !atomic_dec_return(&fs->users);
51449 spin_unlock(&fs->lock);
51450 task_unlock(tsk);
51451 if (kill)
51452 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51453 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
51454 /* We don't need to lock fs - think why ;-) */
51455 if (fs) {
51456 - fs->users = 1;
51457 + atomic_set(&fs->users, 1);
51458 fs->in_exec = 0;
51459 spin_lock_init(&fs->lock);
51460 seqcount_init(&fs->seq);
51461 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51462 spin_lock(&old->lock);
51463 fs->root = old->root;
51464 path_get(&fs->root);
51465 + /* instead of calling gr_set_chroot_entries here,
51466 + we call it from every caller of this function
51467 + */
51468 fs->pwd = old->pwd;
51469 path_get(&fs->pwd);
51470 spin_unlock(&old->lock);
51471 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
51472
51473 task_lock(current);
51474 spin_lock(&fs->lock);
51475 - kill = !--fs->users;
51476 + kill = !atomic_dec_return(&fs->users);
51477 current->fs = new_fs;
51478 + gr_set_chroot_entries(current, &new_fs->root);
51479 spin_unlock(&fs->lock);
51480 task_unlock(current);
51481
51482 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
51483
51484 int current_umask(void)
51485 {
51486 - return current->fs->umask;
51487 + return current->fs->umask | gr_acl_umask();
51488 }
51489 EXPORT_SYMBOL(current_umask);
51490
51491 /* to be mentioned only in INIT_TASK */
51492 struct fs_struct init_fs = {
51493 - .users = 1,
51494 + .users = ATOMIC_INIT(1),
51495 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
51496 .seq = SEQCNT_ZERO,
51497 .umask = 0022,
51498 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
51499 index e2cba1f..17a25bb 100644
51500 --- a/fs/fscache/cookie.c
51501 +++ b/fs/fscache/cookie.c
51502 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
51503 parent ? (char *) parent->def->name : "<no-parent>",
51504 def->name, netfs_data);
51505
51506 - fscache_stat(&fscache_n_acquires);
51507 + fscache_stat_unchecked(&fscache_n_acquires);
51508
51509 /* if there's no parent cookie, then we don't create one here either */
51510 if (!parent) {
51511 - fscache_stat(&fscache_n_acquires_null);
51512 + fscache_stat_unchecked(&fscache_n_acquires_null);
51513 _leave(" [no parent]");
51514 return NULL;
51515 }
51516 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
51517 /* allocate and initialise a cookie */
51518 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
51519 if (!cookie) {
51520 - fscache_stat(&fscache_n_acquires_oom);
51521 + fscache_stat_unchecked(&fscache_n_acquires_oom);
51522 _leave(" [ENOMEM]");
51523 return NULL;
51524 }
51525 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51526
51527 switch (cookie->def->type) {
51528 case FSCACHE_COOKIE_TYPE_INDEX:
51529 - fscache_stat(&fscache_n_cookie_index);
51530 + fscache_stat_unchecked(&fscache_n_cookie_index);
51531 break;
51532 case FSCACHE_COOKIE_TYPE_DATAFILE:
51533 - fscache_stat(&fscache_n_cookie_data);
51534 + fscache_stat_unchecked(&fscache_n_cookie_data);
51535 break;
51536 default:
51537 - fscache_stat(&fscache_n_cookie_special);
51538 + fscache_stat_unchecked(&fscache_n_cookie_special);
51539 break;
51540 }
51541
51542 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51543 if (fscache_acquire_non_index_cookie(cookie) < 0) {
51544 atomic_dec(&parent->n_children);
51545 __fscache_cookie_put(cookie);
51546 - fscache_stat(&fscache_n_acquires_nobufs);
51547 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
51548 _leave(" = NULL");
51549 return NULL;
51550 }
51551 }
51552
51553 - fscache_stat(&fscache_n_acquires_ok);
51554 + fscache_stat_unchecked(&fscache_n_acquires_ok);
51555 _leave(" = %p", cookie);
51556 return cookie;
51557 }
51558 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
51559 cache = fscache_select_cache_for_object(cookie->parent);
51560 if (!cache) {
51561 up_read(&fscache_addremove_sem);
51562 - fscache_stat(&fscache_n_acquires_no_cache);
51563 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
51564 _leave(" = -ENOMEDIUM [no cache]");
51565 return -ENOMEDIUM;
51566 }
51567 @@ -255,12 +255,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
51568 object = cache->ops->alloc_object(cache, cookie);
51569 fscache_stat_d(&fscache_n_cop_alloc_object);
51570 if (IS_ERR(object)) {
51571 - fscache_stat(&fscache_n_object_no_alloc);
51572 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
51573 ret = PTR_ERR(object);
51574 goto error;
51575 }
51576
51577 - fscache_stat(&fscache_n_object_alloc);
51578 + fscache_stat_unchecked(&fscache_n_object_alloc);
51579
51580 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
51581
51582 @@ -376,7 +376,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
51583
51584 _enter("{%s}", cookie->def->name);
51585
51586 - fscache_stat(&fscache_n_invalidates);
51587 + fscache_stat_unchecked(&fscache_n_invalidates);
51588
51589 /* Only permit invalidation of data files. Invalidating an index will
51590 * require the caller to release all its attachments to the tree rooted
51591 @@ -434,10 +434,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
51592 {
51593 struct fscache_object *object;
51594
51595 - fscache_stat(&fscache_n_updates);
51596 + fscache_stat_unchecked(&fscache_n_updates);
51597
51598 if (!cookie) {
51599 - fscache_stat(&fscache_n_updates_null);
51600 + fscache_stat_unchecked(&fscache_n_updates_null);
51601 _leave(" [no cookie]");
51602 return;
51603 }
51604 @@ -471,12 +471,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51605 struct fscache_object *object;
51606 unsigned long event;
51607
51608 - fscache_stat(&fscache_n_relinquishes);
51609 + fscache_stat_unchecked(&fscache_n_relinquishes);
51610 if (retire)
51611 - fscache_stat(&fscache_n_relinquishes_retire);
51612 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
51613
51614 if (!cookie) {
51615 - fscache_stat(&fscache_n_relinquishes_null);
51616 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
51617 _leave(" [no cookie]");
51618 return;
51619 }
51620 @@ -492,7 +492,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51621
51622 /* wait for the cookie to finish being instantiated (or to fail) */
51623 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
51624 - fscache_stat(&fscache_n_relinquishes_waitcrt);
51625 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
51626 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
51627 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
51628 }
51629 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
51630 index ee38fef..0a326d4 100644
51631 --- a/fs/fscache/internal.h
51632 +++ b/fs/fscache/internal.h
51633 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
51634 * stats.c
51635 */
51636 #ifdef CONFIG_FSCACHE_STATS
51637 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51638 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51639 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51640 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51641
51642 -extern atomic_t fscache_n_op_pend;
51643 -extern atomic_t fscache_n_op_run;
51644 -extern atomic_t fscache_n_op_enqueue;
51645 -extern atomic_t fscache_n_op_deferred_release;
51646 -extern atomic_t fscache_n_op_release;
51647 -extern atomic_t fscache_n_op_gc;
51648 -extern atomic_t fscache_n_op_cancelled;
51649 -extern atomic_t fscache_n_op_rejected;
51650 +extern atomic_unchecked_t fscache_n_op_pend;
51651 +extern atomic_unchecked_t fscache_n_op_run;
51652 +extern atomic_unchecked_t fscache_n_op_enqueue;
51653 +extern atomic_unchecked_t fscache_n_op_deferred_release;
51654 +extern atomic_unchecked_t fscache_n_op_release;
51655 +extern atomic_unchecked_t fscache_n_op_gc;
51656 +extern atomic_unchecked_t fscache_n_op_cancelled;
51657 +extern atomic_unchecked_t fscache_n_op_rejected;
51658
51659 -extern atomic_t fscache_n_attr_changed;
51660 -extern atomic_t fscache_n_attr_changed_ok;
51661 -extern atomic_t fscache_n_attr_changed_nobufs;
51662 -extern atomic_t fscache_n_attr_changed_nomem;
51663 -extern atomic_t fscache_n_attr_changed_calls;
51664 +extern atomic_unchecked_t fscache_n_attr_changed;
51665 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
51666 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
51667 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
51668 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
51669
51670 -extern atomic_t fscache_n_allocs;
51671 -extern atomic_t fscache_n_allocs_ok;
51672 -extern atomic_t fscache_n_allocs_wait;
51673 -extern atomic_t fscache_n_allocs_nobufs;
51674 -extern atomic_t fscache_n_allocs_intr;
51675 -extern atomic_t fscache_n_allocs_object_dead;
51676 -extern atomic_t fscache_n_alloc_ops;
51677 -extern atomic_t fscache_n_alloc_op_waits;
51678 +extern atomic_unchecked_t fscache_n_allocs;
51679 +extern atomic_unchecked_t fscache_n_allocs_ok;
51680 +extern atomic_unchecked_t fscache_n_allocs_wait;
51681 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
51682 +extern atomic_unchecked_t fscache_n_allocs_intr;
51683 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
51684 +extern atomic_unchecked_t fscache_n_alloc_ops;
51685 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
51686
51687 -extern atomic_t fscache_n_retrievals;
51688 -extern atomic_t fscache_n_retrievals_ok;
51689 -extern atomic_t fscache_n_retrievals_wait;
51690 -extern atomic_t fscache_n_retrievals_nodata;
51691 -extern atomic_t fscache_n_retrievals_nobufs;
51692 -extern atomic_t fscache_n_retrievals_intr;
51693 -extern atomic_t fscache_n_retrievals_nomem;
51694 -extern atomic_t fscache_n_retrievals_object_dead;
51695 -extern atomic_t fscache_n_retrieval_ops;
51696 -extern atomic_t fscache_n_retrieval_op_waits;
51697 +extern atomic_unchecked_t fscache_n_retrievals;
51698 +extern atomic_unchecked_t fscache_n_retrievals_ok;
51699 +extern atomic_unchecked_t fscache_n_retrievals_wait;
51700 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
51701 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
51702 +extern atomic_unchecked_t fscache_n_retrievals_intr;
51703 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
51704 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
51705 +extern atomic_unchecked_t fscache_n_retrieval_ops;
51706 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
51707
51708 -extern atomic_t fscache_n_stores;
51709 -extern atomic_t fscache_n_stores_ok;
51710 -extern atomic_t fscache_n_stores_again;
51711 -extern atomic_t fscache_n_stores_nobufs;
51712 -extern atomic_t fscache_n_stores_oom;
51713 -extern atomic_t fscache_n_store_ops;
51714 -extern atomic_t fscache_n_store_calls;
51715 -extern atomic_t fscache_n_store_pages;
51716 -extern atomic_t fscache_n_store_radix_deletes;
51717 -extern atomic_t fscache_n_store_pages_over_limit;
51718 +extern atomic_unchecked_t fscache_n_stores;
51719 +extern atomic_unchecked_t fscache_n_stores_ok;
51720 +extern atomic_unchecked_t fscache_n_stores_again;
51721 +extern atomic_unchecked_t fscache_n_stores_nobufs;
51722 +extern atomic_unchecked_t fscache_n_stores_oom;
51723 +extern atomic_unchecked_t fscache_n_store_ops;
51724 +extern atomic_unchecked_t fscache_n_store_calls;
51725 +extern atomic_unchecked_t fscache_n_store_pages;
51726 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
51727 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
51728
51729 -extern atomic_t fscache_n_store_vmscan_not_storing;
51730 -extern atomic_t fscache_n_store_vmscan_gone;
51731 -extern atomic_t fscache_n_store_vmscan_busy;
51732 -extern atomic_t fscache_n_store_vmscan_cancelled;
51733 -extern atomic_t fscache_n_store_vmscan_wait;
51734 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
51735 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
51736 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
51737 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
51738 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
51739
51740 -extern atomic_t fscache_n_marks;
51741 -extern atomic_t fscache_n_uncaches;
51742 +extern atomic_unchecked_t fscache_n_marks;
51743 +extern atomic_unchecked_t fscache_n_uncaches;
51744
51745 -extern atomic_t fscache_n_acquires;
51746 -extern atomic_t fscache_n_acquires_null;
51747 -extern atomic_t fscache_n_acquires_no_cache;
51748 -extern atomic_t fscache_n_acquires_ok;
51749 -extern atomic_t fscache_n_acquires_nobufs;
51750 -extern atomic_t fscache_n_acquires_oom;
51751 +extern atomic_unchecked_t fscache_n_acquires;
51752 +extern atomic_unchecked_t fscache_n_acquires_null;
51753 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
51754 +extern atomic_unchecked_t fscache_n_acquires_ok;
51755 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
51756 +extern atomic_unchecked_t fscache_n_acquires_oom;
51757
51758 -extern atomic_t fscache_n_invalidates;
51759 -extern atomic_t fscache_n_invalidates_run;
51760 +extern atomic_unchecked_t fscache_n_invalidates;
51761 +extern atomic_unchecked_t fscache_n_invalidates_run;
51762
51763 -extern atomic_t fscache_n_updates;
51764 -extern atomic_t fscache_n_updates_null;
51765 -extern atomic_t fscache_n_updates_run;
51766 +extern atomic_unchecked_t fscache_n_updates;
51767 +extern atomic_unchecked_t fscache_n_updates_null;
51768 +extern atomic_unchecked_t fscache_n_updates_run;
51769
51770 -extern atomic_t fscache_n_relinquishes;
51771 -extern atomic_t fscache_n_relinquishes_null;
51772 -extern atomic_t fscache_n_relinquishes_waitcrt;
51773 -extern atomic_t fscache_n_relinquishes_retire;
51774 +extern atomic_unchecked_t fscache_n_relinquishes;
51775 +extern atomic_unchecked_t fscache_n_relinquishes_null;
51776 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
51777 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
51778
51779 -extern atomic_t fscache_n_cookie_index;
51780 -extern atomic_t fscache_n_cookie_data;
51781 -extern atomic_t fscache_n_cookie_special;
51782 +extern atomic_unchecked_t fscache_n_cookie_index;
51783 +extern atomic_unchecked_t fscache_n_cookie_data;
51784 +extern atomic_unchecked_t fscache_n_cookie_special;
51785
51786 -extern atomic_t fscache_n_object_alloc;
51787 -extern atomic_t fscache_n_object_no_alloc;
51788 -extern atomic_t fscache_n_object_lookups;
51789 -extern atomic_t fscache_n_object_lookups_negative;
51790 -extern atomic_t fscache_n_object_lookups_positive;
51791 -extern atomic_t fscache_n_object_lookups_timed_out;
51792 -extern atomic_t fscache_n_object_created;
51793 -extern atomic_t fscache_n_object_avail;
51794 -extern atomic_t fscache_n_object_dead;
51795 +extern atomic_unchecked_t fscache_n_object_alloc;
51796 +extern atomic_unchecked_t fscache_n_object_no_alloc;
51797 +extern atomic_unchecked_t fscache_n_object_lookups;
51798 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
51799 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
51800 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
51801 +extern atomic_unchecked_t fscache_n_object_created;
51802 +extern atomic_unchecked_t fscache_n_object_avail;
51803 +extern atomic_unchecked_t fscache_n_object_dead;
51804
51805 -extern atomic_t fscache_n_checkaux_none;
51806 -extern atomic_t fscache_n_checkaux_okay;
51807 -extern atomic_t fscache_n_checkaux_update;
51808 -extern atomic_t fscache_n_checkaux_obsolete;
51809 +extern atomic_unchecked_t fscache_n_checkaux_none;
51810 +extern atomic_unchecked_t fscache_n_checkaux_okay;
51811 +extern atomic_unchecked_t fscache_n_checkaux_update;
51812 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
51813
51814 extern atomic_t fscache_n_cop_alloc_object;
51815 extern atomic_t fscache_n_cop_lookup_object;
51816 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
51817 atomic_inc(stat);
51818 }
51819
51820 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
51821 +{
51822 + atomic_inc_unchecked(stat);
51823 +}
51824 +
51825 static inline void fscache_stat_d(atomic_t *stat)
51826 {
51827 atomic_dec(stat);
51828 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
51829
51830 #define __fscache_stat(stat) (NULL)
51831 #define fscache_stat(stat) do {} while (0)
51832 +#define fscache_stat_unchecked(stat) do {} while (0)
51833 #define fscache_stat_d(stat) do {} while (0)
51834 #endif
51835
51836 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
51837 index 50d41c1..10ee117 100644
51838 --- a/fs/fscache/object.c
51839 +++ b/fs/fscache/object.c
51840 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51841 /* Invalidate an object on disk */
51842 case FSCACHE_OBJECT_INVALIDATING:
51843 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
51844 - fscache_stat(&fscache_n_invalidates_run);
51845 + fscache_stat_unchecked(&fscache_n_invalidates_run);
51846 fscache_stat(&fscache_n_cop_invalidate_object);
51847 fscache_invalidate_object(object);
51848 fscache_stat_d(&fscache_n_cop_invalidate_object);
51849 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51850 /* update the object metadata on disk */
51851 case FSCACHE_OBJECT_UPDATING:
51852 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
51853 - fscache_stat(&fscache_n_updates_run);
51854 + fscache_stat_unchecked(&fscache_n_updates_run);
51855 fscache_stat(&fscache_n_cop_update_object);
51856 object->cache->ops->update_object(object);
51857 fscache_stat_d(&fscache_n_cop_update_object);
51858 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51859 spin_lock(&object->lock);
51860 object->state = FSCACHE_OBJECT_DEAD;
51861 spin_unlock(&object->lock);
51862 - fscache_stat(&fscache_n_object_dead);
51863 + fscache_stat_unchecked(&fscache_n_object_dead);
51864 goto terminal_transit;
51865
51866 /* handle the parent cache of this object being withdrawn from
51867 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
51868 spin_lock(&object->lock);
51869 object->state = FSCACHE_OBJECT_DEAD;
51870 spin_unlock(&object->lock);
51871 - fscache_stat(&fscache_n_object_dead);
51872 + fscache_stat_unchecked(&fscache_n_object_dead);
51873 goto terminal_transit;
51874
51875 /* complain about the object being woken up once it is
51876 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
51877 parent->cookie->def->name, cookie->def->name,
51878 object->cache->tag->name);
51879
51880 - fscache_stat(&fscache_n_object_lookups);
51881 + fscache_stat_unchecked(&fscache_n_object_lookups);
51882 fscache_stat(&fscache_n_cop_lookup_object);
51883 ret = object->cache->ops->lookup_object(object);
51884 fscache_stat_d(&fscache_n_cop_lookup_object);
51885 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
51886 if (ret == -ETIMEDOUT) {
51887 /* probably stuck behind another object, so move this one to
51888 * the back of the queue */
51889 - fscache_stat(&fscache_n_object_lookups_timed_out);
51890 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
51891 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
51892 }
51893
51894 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
51895
51896 spin_lock(&object->lock);
51897 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
51898 - fscache_stat(&fscache_n_object_lookups_negative);
51899 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
51900
51901 /* transit here to allow write requests to begin stacking up
51902 * and read requests to begin returning ENODATA */
51903 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
51904 * result, in which case there may be data available */
51905 spin_lock(&object->lock);
51906 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
51907 - fscache_stat(&fscache_n_object_lookups_positive);
51908 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
51909
51910 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
51911
51912 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
51913 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
51914 } else {
51915 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
51916 - fscache_stat(&fscache_n_object_created);
51917 + fscache_stat_unchecked(&fscache_n_object_created);
51918
51919 object->state = FSCACHE_OBJECT_AVAILABLE;
51920 spin_unlock(&object->lock);
51921 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
51922 fscache_enqueue_dependents(object);
51923
51924 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
51925 - fscache_stat(&fscache_n_object_avail);
51926 + fscache_stat_unchecked(&fscache_n_object_avail);
51927
51928 _leave("");
51929 }
51930 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
51931 enum fscache_checkaux result;
51932
51933 if (!object->cookie->def->check_aux) {
51934 - fscache_stat(&fscache_n_checkaux_none);
51935 + fscache_stat_unchecked(&fscache_n_checkaux_none);
51936 return FSCACHE_CHECKAUX_OKAY;
51937 }
51938
51939 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
51940 switch (result) {
51941 /* entry okay as is */
51942 case FSCACHE_CHECKAUX_OKAY:
51943 - fscache_stat(&fscache_n_checkaux_okay);
51944 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
51945 break;
51946
51947 /* entry requires update */
51948 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
51949 - fscache_stat(&fscache_n_checkaux_update);
51950 + fscache_stat_unchecked(&fscache_n_checkaux_update);
51951 break;
51952
51953 /* entry requires deletion */
51954 case FSCACHE_CHECKAUX_OBSOLETE:
51955 - fscache_stat(&fscache_n_checkaux_obsolete);
51956 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
51957 break;
51958
51959 default:
51960 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
51961 index 762a9ec..2023284 100644
51962 --- a/fs/fscache/operation.c
51963 +++ b/fs/fscache/operation.c
51964 @@ -17,7 +17,7 @@
51965 #include <linux/slab.h>
51966 #include "internal.h"
51967
51968 -atomic_t fscache_op_debug_id;
51969 +atomic_unchecked_t fscache_op_debug_id;
51970 EXPORT_SYMBOL(fscache_op_debug_id);
51971
51972 /**
51973 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
51974 ASSERTCMP(atomic_read(&op->usage), >, 0);
51975 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
51976
51977 - fscache_stat(&fscache_n_op_enqueue);
51978 + fscache_stat_unchecked(&fscache_n_op_enqueue);
51979 switch (op->flags & FSCACHE_OP_TYPE) {
51980 case FSCACHE_OP_ASYNC:
51981 _debug("queue async");
51982 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
51983 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
51984 if (op->processor)
51985 fscache_enqueue_operation(op);
51986 - fscache_stat(&fscache_n_op_run);
51987 + fscache_stat_unchecked(&fscache_n_op_run);
51988 }
51989
51990 /*
51991 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
51992 if (object->n_in_progress > 0) {
51993 atomic_inc(&op->usage);
51994 list_add_tail(&op->pend_link, &object->pending_ops);
51995 - fscache_stat(&fscache_n_op_pend);
51996 + fscache_stat_unchecked(&fscache_n_op_pend);
51997 } else if (!list_empty(&object->pending_ops)) {
51998 atomic_inc(&op->usage);
51999 list_add_tail(&op->pend_link, &object->pending_ops);
52000 - fscache_stat(&fscache_n_op_pend);
52001 + fscache_stat_unchecked(&fscache_n_op_pend);
52002 fscache_start_operations(object);
52003 } else {
52004 ASSERTCMP(object->n_in_progress, ==, 0);
52005 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52006 object->n_exclusive++; /* reads and writes must wait */
52007 atomic_inc(&op->usage);
52008 list_add_tail(&op->pend_link, &object->pending_ops);
52009 - fscache_stat(&fscache_n_op_pend);
52010 + fscache_stat_unchecked(&fscache_n_op_pend);
52011 ret = 0;
52012 } else {
52013 /* If we're in any other state, there must have been an I/O
52014 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
52015 if (object->n_exclusive > 0) {
52016 atomic_inc(&op->usage);
52017 list_add_tail(&op->pend_link, &object->pending_ops);
52018 - fscache_stat(&fscache_n_op_pend);
52019 + fscache_stat_unchecked(&fscache_n_op_pend);
52020 } else if (!list_empty(&object->pending_ops)) {
52021 atomic_inc(&op->usage);
52022 list_add_tail(&op->pend_link, &object->pending_ops);
52023 - fscache_stat(&fscache_n_op_pend);
52024 + fscache_stat_unchecked(&fscache_n_op_pend);
52025 fscache_start_operations(object);
52026 } else {
52027 ASSERTCMP(object->n_exclusive, ==, 0);
52028 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
52029 object->n_ops++;
52030 atomic_inc(&op->usage);
52031 list_add_tail(&op->pend_link, &object->pending_ops);
52032 - fscache_stat(&fscache_n_op_pend);
52033 + fscache_stat_unchecked(&fscache_n_op_pend);
52034 ret = 0;
52035 } else if (object->state == FSCACHE_OBJECT_DYING ||
52036 object->state == FSCACHE_OBJECT_LC_DYING ||
52037 object->state == FSCACHE_OBJECT_WITHDRAWING) {
52038 - fscache_stat(&fscache_n_op_rejected);
52039 + fscache_stat_unchecked(&fscache_n_op_rejected);
52040 op->state = FSCACHE_OP_ST_CANCELLED;
52041 ret = -ENOBUFS;
52042 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
52043 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
52044 ret = -EBUSY;
52045 if (op->state == FSCACHE_OP_ST_PENDING) {
52046 ASSERT(!list_empty(&op->pend_link));
52047 - fscache_stat(&fscache_n_op_cancelled);
52048 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52049 list_del_init(&op->pend_link);
52050 if (do_cancel)
52051 do_cancel(op);
52052 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
52053 while (!list_empty(&object->pending_ops)) {
52054 op = list_entry(object->pending_ops.next,
52055 struct fscache_operation, pend_link);
52056 - fscache_stat(&fscache_n_op_cancelled);
52057 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52058 list_del_init(&op->pend_link);
52059
52060 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
52061 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
52062 op->state, ==, FSCACHE_OP_ST_CANCELLED);
52063 op->state = FSCACHE_OP_ST_DEAD;
52064
52065 - fscache_stat(&fscache_n_op_release);
52066 + fscache_stat_unchecked(&fscache_n_op_release);
52067
52068 if (op->release) {
52069 op->release(op);
52070 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
52071 * lock, and defer it otherwise */
52072 if (!spin_trylock(&object->lock)) {
52073 _debug("defer put");
52074 - fscache_stat(&fscache_n_op_deferred_release);
52075 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
52076
52077 cache = object->cache;
52078 spin_lock(&cache->op_gc_list_lock);
52079 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
52080
52081 _debug("GC DEFERRED REL OBJ%x OP%x",
52082 object->debug_id, op->debug_id);
52083 - fscache_stat(&fscache_n_op_gc);
52084 + fscache_stat_unchecked(&fscache_n_op_gc);
52085
52086 ASSERTCMP(atomic_read(&op->usage), ==, 0);
52087 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
52088 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
52089 index ff000e5..c44ec6d 100644
52090 --- a/fs/fscache/page.c
52091 +++ b/fs/fscache/page.c
52092 @@ -61,7 +61,7 @@ try_again:
52093 val = radix_tree_lookup(&cookie->stores, page->index);
52094 if (!val) {
52095 rcu_read_unlock();
52096 - fscache_stat(&fscache_n_store_vmscan_not_storing);
52097 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
52098 __fscache_uncache_page(cookie, page);
52099 return true;
52100 }
52101 @@ -91,11 +91,11 @@ try_again:
52102 spin_unlock(&cookie->stores_lock);
52103
52104 if (xpage) {
52105 - fscache_stat(&fscache_n_store_vmscan_cancelled);
52106 - fscache_stat(&fscache_n_store_radix_deletes);
52107 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
52108 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52109 ASSERTCMP(xpage, ==, page);
52110 } else {
52111 - fscache_stat(&fscache_n_store_vmscan_gone);
52112 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
52113 }
52114
52115 wake_up_bit(&cookie->flags, 0);
52116 @@ -110,11 +110,11 @@ page_busy:
52117 * sleeping on memory allocation, so we may need to impose a timeout
52118 * too. */
52119 if (!(gfp & __GFP_WAIT)) {
52120 - fscache_stat(&fscache_n_store_vmscan_busy);
52121 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
52122 return false;
52123 }
52124
52125 - fscache_stat(&fscache_n_store_vmscan_wait);
52126 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
52127 __fscache_wait_on_page_write(cookie, page);
52128 gfp &= ~__GFP_WAIT;
52129 goto try_again;
52130 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
52131 FSCACHE_COOKIE_STORING_TAG);
52132 if (!radix_tree_tag_get(&cookie->stores, page->index,
52133 FSCACHE_COOKIE_PENDING_TAG)) {
52134 - fscache_stat(&fscache_n_store_radix_deletes);
52135 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52136 xpage = radix_tree_delete(&cookie->stores, page->index);
52137 }
52138 spin_unlock(&cookie->stores_lock);
52139 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
52140
52141 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
52142
52143 - fscache_stat(&fscache_n_attr_changed_calls);
52144 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
52145
52146 if (fscache_object_is_active(object)) {
52147 fscache_stat(&fscache_n_cop_attr_changed);
52148 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52149
52150 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52151
52152 - fscache_stat(&fscache_n_attr_changed);
52153 + fscache_stat_unchecked(&fscache_n_attr_changed);
52154
52155 op = kzalloc(sizeof(*op), GFP_KERNEL);
52156 if (!op) {
52157 - fscache_stat(&fscache_n_attr_changed_nomem);
52158 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
52159 _leave(" = -ENOMEM");
52160 return -ENOMEM;
52161 }
52162 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52163 if (fscache_submit_exclusive_op(object, op) < 0)
52164 goto nobufs;
52165 spin_unlock(&cookie->lock);
52166 - fscache_stat(&fscache_n_attr_changed_ok);
52167 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
52168 fscache_put_operation(op);
52169 _leave(" = 0");
52170 return 0;
52171 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52172 nobufs:
52173 spin_unlock(&cookie->lock);
52174 kfree(op);
52175 - fscache_stat(&fscache_n_attr_changed_nobufs);
52176 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
52177 _leave(" = %d", -ENOBUFS);
52178 return -ENOBUFS;
52179 }
52180 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
52181 /* allocate a retrieval operation and attempt to submit it */
52182 op = kzalloc(sizeof(*op), GFP_NOIO);
52183 if (!op) {
52184 - fscache_stat(&fscache_n_retrievals_nomem);
52185 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52186 return NULL;
52187 }
52188
52189 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
52190 return 0;
52191 }
52192
52193 - fscache_stat(&fscache_n_retrievals_wait);
52194 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
52195
52196 jif = jiffies;
52197 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
52198 fscache_wait_bit_interruptible,
52199 TASK_INTERRUPTIBLE) != 0) {
52200 - fscache_stat(&fscache_n_retrievals_intr);
52201 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52202 _leave(" = -ERESTARTSYS");
52203 return -ERESTARTSYS;
52204 }
52205 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
52206 */
52207 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52208 struct fscache_retrieval *op,
52209 - atomic_t *stat_op_waits,
52210 - atomic_t *stat_object_dead)
52211 + atomic_unchecked_t *stat_op_waits,
52212 + atomic_unchecked_t *stat_object_dead)
52213 {
52214 int ret;
52215
52216 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52217 goto check_if_dead;
52218
52219 _debug(">>> WT");
52220 - fscache_stat(stat_op_waits);
52221 + fscache_stat_unchecked(stat_op_waits);
52222 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
52223 fscache_wait_bit_interruptible,
52224 TASK_INTERRUPTIBLE) != 0) {
52225 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52226
52227 check_if_dead:
52228 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
52229 - fscache_stat(stat_object_dead);
52230 + fscache_stat_unchecked(stat_object_dead);
52231 _leave(" = -ENOBUFS [cancelled]");
52232 return -ENOBUFS;
52233 }
52234 if (unlikely(fscache_object_is_dead(object))) {
52235 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
52236 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
52237 - fscache_stat(stat_object_dead);
52238 + fscache_stat_unchecked(stat_object_dead);
52239 return -ENOBUFS;
52240 }
52241 return 0;
52242 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52243
52244 _enter("%p,%p,,,", cookie, page);
52245
52246 - fscache_stat(&fscache_n_retrievals);
52247 + fscache_stat_unchecked(&fscache_n_retrievals);
52248
52249 if (hlist_empty(&cookie->backing_objects))
52250 goto nobufs;
52251 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52252 goto nobufs_unlock_dec;
52253 spin_unlock(&cookie->lock);
52254
52255 - fscache_stat(&fscache_n_retrieval_ops);
52256 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52257
52258 /* pin the netfs read context in case we need to do the actual netfs
52259 * read because we've encountered a cache read failure */
52260 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52261
52262 error:
52263 if (ret == -ENOMEM)
52264 - fscache_stat(&fscache_n_retrievals_nomem);
52265 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52266 else if (ret == -ERESTARTSYS)
52267 - fscache_stat(&fscache_n_retrievals_intr);
52268 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52269 else if (ret == -ENODATA)
52270 - fscache_stat(&fscache_n_retrievals_nodata);
52271 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52272 else if (ret < 0)
52273 - fscache_stat(&fscache_n_retrievals_nobufs);
52274 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52275 else
52276 - fscache_stat(&fscache_n_retrievals_ok);
52277 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52278
52279 fscache_put_retrieval(op);
52280 _leave(" = %d", ret);
52281 @@ -467,7 +467,7 @@ nobufs_unlock:
52282 spin_unlock(&cookie->lock);
52283 kfree(op);
52284 nobufs:
52285 - fscache_stat(&fscache_n_retrievals_nobufs);
52286 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52287 _leave(" = -ENOBUFS");
52288 return -ENOBUFS;
52289 }
52290 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52291
52292 _enter("%p,,%d,,,", cookie, *nr_pages);
52293
52294 - fscache_stat(&fscache_n_retrievals);
52295 + fscache_stat_unchecked(&fscache_n_retrievals);
52296
52297 if (hlist_empty(&cookie->backing_objects))
52298 goto nobufs;
52299 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52300 goto nobufs_unlock_dec;
52301 spin_unlock(&cookie->lock);
52302
52303 - fscache_stat(&fscache_n_retrieval_ops);
52304 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52305
52306 /* pin the netfs read context in case we need to do the actual netfs
52307 * read because we've encountered a cache read failure */
52308 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52309
52310 error:
52311 if (ret == -ENOMEM)
52312 - fscache_stat(&fscache_n_retrievals_nomem);
52313 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52314 else if (ret == -ERESTARTSYS)
52315 - fscache_stat(&fscache_n_retrievals_intr);
52316 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52317 else if (ret == -ENODATA)
52318 - fscache_stat(&fscache_n_retrievals_nodata);
52319 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52320 else if (ret < 0)
52321 - fscache_stat(&fscache_n_retrievals_nobufs);
52322 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52323 else
52324 - fscache_stat(&fscache_n_retrievals_ok);
52325 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52326
52327 fscache_put_retrieval(op);
52328 _leave(" = %d", ret);
52329 @@ -591,7 +591,7 @@ nobufs_unlock:
52330 spin_unlock(&cookie->lock);
52331 kfree(op);
52332 nobufs:
52333 - fscache_stat(&fscache_n_retrievals_nobufs);
52334 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52335 _leave(" = -ENOBUFS");
52336 return -ENOBUFS;
52337 }
52338 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52339
52340 _enter("%p,%p,,,", cookie, page);
52341
52342 - fscache_stat(&fscache_n_allocs);
52343 + fscache_stat_unchecked(&fscache_n_allocs);
52344
52345 if (hlist_empty(&cookie->backing_objects))
52346 goto nobufs;
52347 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52348 goto nobufs_unlock;
52349 spin_unlock(&cookie->lock);
52350
52351 - fscache_stat(&fscache_n_alloc_ops);
52352 + fscache_stat_unchecked(&fscache_n_alloc_ops);
52353
52354 ret = fscache_wait_for_retrieval_activation(
52355 object, op,
52356 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52357
52358 error:
52359 if (ret == -ERESTARTSYS)
52360 - fscache_stat(&fscache_n_allocs_intr);
52361 + fscache_stat_unchecked(&fscache_n_allocs_intr);
52362 else if (ret < 0)
52363 - fscache_stat(&fscache_n_allocs_nobufs);
52364 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52365 else
52366 - fscache_stat(&fscache_n_allocs_ok);
52367 + fscache_stat_unchecked(&fscache_n_allocs_ok);
52368
52369 fscache_put_retrieval(op);
52370 _leave(" = %d", ret);
52371 @@ -677,7 +677,7 @@ nobufs_unlock:
52372 spin_unlock(&cookie->lock);
52373 kfree(op);
52374 nobufs:
52375 - fscache_stat(&fscache_n_allocs_nobufs);
52376 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52377 _leave(" = -ENOBUFS");
52378 return -ENOBUFS;
52379 }
52380 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52381
52382 spin_lock(&cookie->stores_lock);
52383
52384 - fscache_stat(&fscache_n_store_calls);
52385 + fscache_stat_unchecked(&fscache_n_store_calls);
52386
52387 /* find a page to store */
52388 page = NULL;
52389 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52390 page = results[0];
52391 _debug("gang %d [%lx]", n, page->index);
52392 if (page->index > op->store_limit) {
52393 - fscache_stat(&fscache_n_store_pages_over_limit);
52394 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
52395 goto superseded;
52396 }
52397
52398 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52399 spin_unlock(&cookie->stores_lock);
52400 spin_unlock(&object->lock);
52401
52402 - fscache_stat(&fscache_n_store_pages);
52403 + fscache_stat_unchecked(&fscache_n_store_pages);
52404 fscache_stat(&fscache_n_cop_write_page);
52405 ret = object->cache->ops->write_page(op, page);
52406 fscache_stat_d(&fscache_n_cop_write_page);
52407 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52408 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52409 ASSERT(PageFsCache(page));
52410
52411 - fscache_stat(&fscache_n_stores);
52412 + fscache_stat_unchecked(&fscache_n_stores);
52413
52414 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
52415 _leave(" = -ENOBUFS [invalidating]");
52416 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52417 spin_unlock(&cookie->stores_lock);
52418 spin_unlock(&object->lock);
52419
52420 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
52421 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
52422 op->store_limit = object->store_limit;
52423
52424 if (fscache_submit_op(object, &op->op) < 0)
52425 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52426
52427 spin_unlock(&cookie->lock);
52428 radix_tree_preload_end();
52429 - fscache_stat(&fscache_n_store_ops);
52430 - fscache_stat(&fscache_n_stores_ok);
52431 + fscache_stat_unchecked(&fscache_n_store_ops);
52432 + fscache_stat_unchecked(&fscache_n_stores_ok);
52433
52434 /* the work queue now carries its own ref on the object */
52435 fscache_put_operation(&op->op);
52436 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52437 return 0;
52438
52439 already_queued:
52440 - fscache_stat(&fscache_n_stores_again);
52441 + fscache_stat_unchecked(&fscache_n_stores_again);
52442 already_pending:
52443 spin_unlock(&cookie->stores_lock);
52444 spin_unlock(&object->lock);
52445 spin_unlock(&cookie->lock);
52446 radix_tree_preload_end();
52447 kfree(op);
52448 - fscache_stat(&fscache_n_stores_ok);
52449 + fscache_stat_unchecked(&fscache_n_stores_ok);
52450 _leave(" = 0");
52451 return 0;
52452
52453 @@ -959,14 +959,14 @@ nobufs:
52454 spin_unlock(&cookie->lock);
52455 radix_tree_preload_end();
52456 kfree(op);
52457 - fscache_stat(&fscache_n_stores_nobufs);
52458 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
52459 _leave(" = -ENOBUFS");
52460 return -ENOBUFS;
52461
52462 nomem_free:
52463 kfree(op);
52464 nomem:
52465 - fscache_stat(&fscache_n_stores_oom);
52466 + fscache_stat_unchecked(&fscache_n_stores_oom);
52467 _leave(" = -ENOMEM");
52468 return -ENOMEM;
52469 }
52470 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
52471 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52472 ASSERTCMP(page, !=, NULL);
52473
52474 - fscache_stat(&fscache_n_uncaches);
52475 + fscache_stat_unchecked(&fscache_n_uncaches);
52476
52477 /* cache withdrawal may beat us to it */
52478 if (!PageFsCache(page))
52479 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
52480 struct fscache_cookie *cookie = op->op.object->cookie;
52481
52482 #ifdef CONFIG_FSCACHE_STATS
52483 - atomic_inc(&fscache_n_marks);
52484 + atomic_inc_unchecked(&fscache_n_marks);
52485 #endif
52486
52487 _debug("- mark %p{%lx}", page, page->index);
52488 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
52489 index 40d13c7..ddf52b9 100644
52490 --- a/fs/fscache/stats.c
52491 +++ b/fs/fscache/stats.c
52492 @@ -18,99 +18,99 @@
52493 /*
52494 * operation counters
52495 */
52496 -atomic_t fscache_n_op_pend;
52497 -atomic_t fscache_n_op_run;
52498 -atomic_t fscache_n_op_enqueue;
52499 -atomic_t fscache_n_op_requeue;
52500 -atomic_t fscache_n_op_deferred_release;
52501 -atomic_t fscache_n_op_release;
52502 -atomic_t fscache_n_op_gc;
52503 -atomic_t fscache_n_op_cancelled;
52504 -atomic_t fscache_n_op_rejected;
52505 +atomic_unchecked_t fscache_n_op_pend;
52506 +atomic_unchecked_t fscache_n_op_run;
52507 +atomic_unchecked_t fscache_n_op_enqueue;
52508 +atomic_unchecked_t fscache_n_op_requeue;
52509 +atomic_unchecked_t fscache_n_op_deferred_release;
52510 +atomic_unchecked_t fscache_n_op_release;
52511 +atomic_unchecked_t fscache_n_op_gc;
52512 +atomic_unchecked_t fscache_n_op_cancelled;
52513 +atomic_unchecked_t fscache_n_op_rejected;
52514
52515 -atomic_t fscache_n_attr_changed;
52516 -atomic_t fscache_n_attr_changed_ok;
52517 -atomic_t fscache_n_attr_changed_nobufs;
52518 -atomic_t fscache_n_attr_changed_nomem;
52519 -atomic_t fscache_n_attr_changed_calls;
52520 +atomic_unchecked_t fscache_n_attr_changed;
52521 +atomic_unchecked_t fscache_n_attr_changed_ok;
52522 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
52523 +atomic_unchecked_t fscache_n_attr_changed_nomem;
52524 +atomic_unchecked_t fscache_n_attr_changed_calls;
52525
52526 -atomic_t fscache_n_allocs;
52527 -atomic_t fscache_n_allocs_ok;
52528 -atomic_t fscache_n_allocs_wait;
52529 -atomic_t fscache_n_allocs_nobufs;
52530 -atomic_t fscache_n_allocs_intr;
52531 -atomic_t fscache_n_allocs_object_dead;
52532 -atomic_t fscache_n_alloc_ops;
52533 -atomic_t fscache_n_alloc_op_waits;
52534 +atomic_unchecked_t fscache_n_allocs;
52535 +atomic_unchecked_t fscache_n_allocs_ok;
52536 +atomic_unchecked_t fscache_n_allocs_wait;
52537 +atomic_unchecked_t fscache_n_allocs_nobufs;
52538 +atomic_unchecked_t fscache_n_allocs_intr;
52539 +atomic_unchecked_t fscache_n_allocs_object_dead;
52540 +atomic_unchecked_t fscache_n_alloc_ops;
52541 +atomic_unchecked_t fscache_n_alloc_op_waits;
52542
52543 -atomic_t fscache_n_retrievals;
52544 -atomic_t fscache_n_retrievals_ok;
52545 -atomic_t fscache_n_retrievals_wait;
52546 -atomic_t fscache_n_retrievals_nodata;
52547 -atomic_t fscache_n_retrievals_nobufs;
52548 -atomic_t fscache_n_retrievals_intr;
52549 -atomic_t fscache_n_retrievals_nomem;
52550 -atomic_t fscache_n_retrievals_object_dead;
52551 -atomic_t fscache_n_retrieval_ops;
52552 -atomic_t fscache_n_retrieval_op_waits;
52553 +atomic_unchecked_t fscache_n_retrievals;
52554 +atomic_unchecked_t fscache_n_retrievals_ok;
52555 +atomic_unchecked_t fscache_n_retrievals_wait;
52556 +atomic_unchecked_t fscache_n_retrievals_nodata;
52557 +atomic_unchecked_t fscache_n_retrievals_nobufs;
52558 +atomic_unchecked_t fscache_n_retrievals_intr;
52559 +atomic_unchecked_t fscache_n_retrievals_nomem;
52560 +atomic_unchecked_t fscache_n_retrievals_object_dead;
52561 +atomic_unchecked_t fscache_n_retrieval_ops;
52562 +atomic_unchecked_t fscache_n_retrieval_op_waits;
52563
52564 -atomic_t fscache_n_stores;
52565 -atomic_t fscache_n_stores_ok;
52566 -atomic_t fscache_n_stores_again;
52567 -atomic_t fscache_n_stores_nobufs;
52568 -atomic_t fscache_n_stores_oom;
52569 -atomic_t fscache_n_store_ops;
52570 -atomic_t fscache_n_store_calls;
52571 -atomic_t fscache_n_store_pages;
52572 -atomic_t fscache_n_store_radix_deletes;
52573 -atomic_t fscache_n_store_pages_over_limit;
52574 +atomic_unchecked_t fscache_n_stores;
52575 +atomic_unchecked_t fscache_n_stores_ok;
52576 +atomic_unchecked_t fscache_n_stores_again;
52577 +atomic_unchecked_t fscache_n_stores_nobufs;
52578 +atomic_unchecked_t fscache_n_stores_oom;
52579 +atomic_unchecked_t fscache_n_store_ops;
52580 +atomic_unchecked_t fscache_n_store_calls;
52581 +atomic_unchecked_t fscache_n_store_pages;
52582 +atomic_unchecked_t fscache_n_store_radix_deletes;
52583 +atomic_unchecked_t fscache_n_store_pages_over_limit;
52584
52585 -atomic_t fscache_n_store_vmscan_not_storing;
52586 -atomic_t fscache_n_store_vmscan_gone;
52587 -atomic_t fscache_n_store_vmscan_busy;
52588 -atomic_t fscache_n_store_vmscan_cancelled;
52589 -atomic_t fscache_n_store_vmscan_wait;
52590 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52591 +atomic_unchecked_t fscache_n_store_vmscan_gone;
52592 +atomic_unchecked_t fscache_n_store_vmscan_busy;
52593 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52594 +atomic_unchecked_t fscache_n_store_vmscan_wait;
52595
52596 -atomic_t fscache_n_marks;
52597 -atomic_t fscache_n_uncaches;
52598 +atomic_unchecked_t fscache_n_marks;
52599 +atomic_unchecked_t fscache_n_uncaches;
52600
52601 -atomic_t fscache_n_acquires;
52602 -atomic_t fscache_n_acquires_null;
52603 -atomic_t fscache_n_acquires_no_cache;
52604 -atomic_t fscache_n_acquires_ok;
52605 -atomic_t fscache_n_acquires_nobufs;
52606 -atomic_t fscache_n_acquires_oom;
52607 +atomic_unchecked_t fscache_n_acquires;
52608 +atomic_unchecked_t fscache_n_acquires_null;
52609 +atomic_unchecked_t fscache_n_acquires_no_cache;
52610 +atomic_unchecked_t fscache_n_acquires_ok;
52611 +atomic_unchecked_t fscache_n_acquires_nobufs;
52612 +atomic_unchecked_t fscache_n_acquires_oom;
52613
52614 -atomic_t fscache_n_invalidates;
52615 -atomic_t fscache_n_invalidates_run;
52616 +atomic_unchecked_t fscache_n_invalidates;
52617 +atomic_unchecked_t fscache_n_invalidates_run;
52618
52619 -atomic_t fscache_n_updates;
52620 -atomic_t fscache_n_updates_null;
52621 -atomic_t fscache_n_updates_run;
52622 +atomic_unchecked_t fscache_n_updates;
52623 +atomic_unchecked_t fscache_n_updates_null;
52624 +atomic_unchecked_t fscache_n_updates_run;
52625
52626 -atomic_t fscache_n_relinquishes;
52627 -atomic_t fscache_n_relinquishes_null;
52628 -atomic_t fscache_n_relinquishes_waitcrt;
52629 -atomic_t fscache_n_relinquishes_retire;
52630 +atomic_unchecked_t fscache_n_relinquishes;
52631 +atomic_unchecked_t fscache_n_relinquishes_null;
52632 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52633 +atomic_unchecked_t fscache_n_relinquishes_retire;
52634
52635 -atomic_t fscache_n_cookie_index;
52636 -atomic_t fscache_n_cookie_data;
52637 -atomic_t fscache_n_cookie_special;
52638 +atomic_unchecked_t fscache_n_cookie_index;
52639 +atomic_unchecked_t fscache_n_cookie_data;
52640 +atomic_unchecked_t fscache_n_cookie_special;
52641
52642 -atomic_t fscache_n_object_alloc;
52643 -atomic_t fscache_n_object_no_alloc;
52644 -atomic_t fscache_n_object_lookups;
52645 -atomic_t fscache_n_object_lookups_negative;
52646 -atomic_t fscache_n_object_lookups_positive;
52647 -atomic_t fscache_n_object_lookups_timed_out;
52648 -atomic_t fscache_n_object_created;
52649 -atomic_t fscache_n_object_avail;
52650 -atomic_t fscache_n_object_dead;
52651 +atomic_unchecked_t fscache_n_object_alloc;
52652 +atomic_unchecked_t fscache_n_object_no_alloc;
52653 +atomic_unchecked_t fscache_n_object_lookups;
52654 +atomic_unchecked_t fscache_n_object_lookups_negative;
52655 +atomic_unchecked_t fscache_n_object_lookups_positive;
52656 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
52657 +atomic_unchecked_t fscache_n_object_created;
52658 +atomic_unchecked_t fscache_n_object_avail;
52659 +atomic_unchecked_t fscache_n_object_dead;
52660
52661 -atomic_t fscache_n_checkaux_none;
52662 -atomic_t fscache_n_checkaux_okay;
52663 -atomic_t fscache_n_checkaux_update;
52664 -atomic_t fscache_n_checkaux_obsolete;
52665 +atomic_unchecked_t fscache_n_checkaux_none;
52666 +atomic_unchecked_t fscache_n_checkaux_okay;
52667 +atomic_unchecked_t fscache_n_checkaux_update;
52668 +atomic_unchecked_t fscache_n_checkaux_obsolete;
52669
52670 atomic_t fscache_n_cop_alloc_object;
52671 atomic_t fscache_n_cop_lookup_object;
52672 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
52673 seq_puts(m, "FS-Cache statistics\n");
52674
52675 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
52676 - atomic_read(&fscache_n_cookie_index),
52677 - atomic_read(&fscache_n_cookie_data),
52678 - atomic_read(&fscache_n_cookie_special));
52679 + atomic_read_unchecked(&fscache_n_cookie_index),
52680 + atomic_read_unchecked(&fscache_n_cookie_data),
52681 + atomic_read_unchecked(&fscache_n_cookie_special));
52682
52683 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
52684 - atomic_read(&fscache_n_object_alloc),
52685 - atomic_read(&fscache_n_object_no_alloc),
52686 - atomic_read(&fscache_n_object_avail),
52687 - atomic_read(&fscache_n_object_dead));
52688 + atomic_read_unchecked(&fscache_n_object_alloc),
52689 + atomic_read_unchecked(&fscache_n_object_no_alloc),
52690 + atomic_read_unchecked(&fscache_n_object_avail),
52691 + atomic_read_unchecked(&fscache_n_object_dead));
52692 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
52693 - atomic_read(&fscache_n_checkaux_none),
52694 - atomic_read(&fscache_n_checkaux_okay),
52695 - atomic_read(&fscache_n_checkaux_update),
52696 - atomic_read(&fscache_n_checkaux_obsolete));
52697 + atomic_read_unchecked(&fscache_n_checkaux_none),
52698 + atomic_read_unchecked(&fscache_n_checkaux_okay),
52699 + atomic_read_unchecked(&fscache_n_checkaux_update),
52700 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
52701
52702 seq_printf(m, "Pages : mrk=%u unc=%u\n",
52703 - atomic_read(&fscache_n_marks),
52704 - atomic_read(&fscache_n_uncaches));
52705 + atomic_read_unchecked(&fscache_n_marks),
52706 + atomic_read_unchecked(&fscache_n_uncaches));
52707
52708 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
52709 " oom=%u\n",
52710 - atomic_read(&fscache_n_acquires),
52711 - atomic_read(&fscache_n_acquires_null),
52712 - atomic_read(&fscache_n_acquires_no_cache),
52713 - atomic_read(&fscache_n_acquires_ok),
52714 - atomic_read(&fscache_n_acquires_nobufs),
52715 - atomic_read(&fscache_n_acquires_oom));
52716 + atomic_read_unchecked(&fscache_n_acquires),
52717 + atomic_read_unchecked(&fscache_n_acquires_null),
52718 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
52719 + atomic_read_unchecked(&fscache_n_acquires_ok),
52720 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
52721 + atomic_read_unchecked(&fscache_n_acquires_oom));
52722
52723 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
52724 - atomic_read(&fscache_n_object_lookups),
52725 - atomic_read(&fscache_n_object_lookups_negative),
52726 - atomic_read(&fscache_n_object_lookups_positive),
52727 - atomic_read(&fscache_n_object_created),
52728 - atomic_read(&fscache_n_object_lookups_timed_out));
52729 + atomic_read_unchecked(&fscache_n_object_lookups),
52730 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
52731 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
52732 + atomic_read_unchecked(&fscache_n_object_created),
52733 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
52734
52735 seq_printf(m, "Invals : n=%u run=%u\n",
52736 - atomic_read(&fscache_n_invalidates),
52737 - atomic_read(&fscache_n_invalidates_run));
52738 + atomic_read_unchecked(&fscache_n_invalidates),
52739 + atomic_read_unchecked(&fscache_n_invalidates_run));
52740
52741 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
52742 - atomic_read(&fscache_n_updates),
52743 - atomic_read(&fscache_n_updates_null),
52744 - atomic_read(&fscache_n_updates_run));
52745 + atomic_read_unchecked(&fscache_n_updates),
52746 + atomic_read_unchecked(&fscache_n_updates_null),
52747 + atomic_read_unchecked(&fscache_n_updates_run));
52748
52749 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
52750 - atomic_read(&fscache_n_relinquishes),
52751 - atomic_read(&fscache_n_relinquishes_null),
52752 - atomic_read(&fscache_n_relinquishes_waitcrt),
52753 - atomic_read(&fscache_n_relinquishes_retire));
52754 + atomic_read_unchecked(&fscache_n_relinquishes),
52755 + atomic_read_unchecked(&fscache_n_relinquishes_null),
52756 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
52757 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
52758
52759 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
52760 - atomic_read(&fscache_n_attr_changed),
52761 - atomic_read(&fscache_n_attr_changed_ok),
52762 - atomic_read(&fscache_n_attr_changed_nobufs),
52763 - atomic_read(&fscache_n_attr_changed_nomem),
52764 - atomic_read(&fscache_n_attr_changed_calls));
52765 + atomic_read_unchecked(&fscache_n_attr_changed),
52766 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
52767 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
52768 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
52769 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
52770
52771 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
52772 - atomic_read(&fscache_n_allocs),
52773 - atomic_read(&fscache_n_allocs_ok),
52774 - atomic_read(&fscache_n_allocs_wait),
52775 - atomic_read(&fscache_n_allocs_nobufs),
52776 - atomic_read(&fscache_n_allocs_intr));
52777 + atomic_read_unchecked(&fscache_n_allocs),
52778 + atomic_read_unchecked(&fscache_n_allocs_ok),
52779 + atomic_read_unchecked(&fscache_n_allocs_wait),
52780 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
52781 + atomic_read_unchecked(&fscache_n_allocs_intr));
52782 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
52783 - atomic_read(&fscache_n_alloc_ops),
52784 - atomic_read(&fscache_n_alloc_op_waits),
52785 - atomic_read(&fscache_n_allocs_object_dead));
52786 + atomic_read_unchecked(&fscache_n_alloc_ops),
52787 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
52788 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
52789
52790 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
52791 " int=%u oom=%u\n",
52792 - atomic_read(&fscache_n_retrievals),
52793 - atomic_read(&fscache_n_retrievals_ok),
52794 - atomic_read(&fscache_n_retrievals_wait),
52795 - atomic_read(&fscache_n_retrievals_nodata),
52796 - atomic_read(&fscache_n_retrievals_nobufs),
52797 - atomic_read(&fscache_n_retrievals_intr),
52798 - atomic_read(&fscache_n_retrievals_nomem));
52799 + atomic_read_unchecked(&fscache_n_retrievals),
52800 + atomic_read_unchecked(&fscache_n_retrievals_ok),
52801 + atomic_read_unchecked(&fscache_n_retrievals_wait),
52802 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
52803 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
52804 + atomic_read_unchecked(&fscache_n_retrievals_intr),
52805 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
52806 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
52807 - atomic_read(&fscache_n_retrieval_ops),
52808 - atomic_read(&fscache_n_retrieval_op_waits),
52809 - atomic_read(&fscache_n_retrievals_object_dead));
52810 + atomic_read_unchecked(&fscache_n_retrieval_ops),
52811 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
52812 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
52813
52814 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
52815 - atomic_read(&fscache_n_stores),
52816 - atomic_read(&fscache_n_stores_ok),
52817 - atomic_read(&fscache_n_stores_again),
52818 - atomic_read(&fscache_n_stores_nobufs),
52819 - atomic_read(&fscache_n_stores_oom));
52820 + atomic_read_unchecked(&fscache_n_stores),
52821 + atomic_read_unchecked(&fscache_n_stores_ok),
52822 + atomic_read_unchecked(&fscache_n_stores_again),
52823 + atomic_read_unchecked(&fscache_n_stores_nobufs),
52824 + atomic_read_unchecked(&fscache_n_stores_oom));
52825 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
52826 - atomic_read(&fscache_n_store_ops),
52827 - atomic_read(&fscache_n_store_calls),
52828 - atomic_read(&fscache_n_store_pages),
52829 - atomic_read(&fscache_n_store_radix_deletes),
52830 - atomic_read(&fscache_n_store_pages_over_limit));
52831 + atomic_read_unchecked(&fscache_n_store_ops),
52832 + atomic_read_unchecked(&fscache_n_store_calls),
52833 + atomic_read_unchecked(&fscache_n_store_pages),
52834 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
52835 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
52836
52837 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
52838 - atomic_read(&fscache_n_store_vmscan_not_storing),
52839 - atomic_read(&fscache_n_store_vmscan_gone),
52840 - atomic_read(&fscache_n_store_vmscan_busy),
52841 - atomic_read(&fscache_n_store_vmscan_cancelled),
52842 - atomic_read(&fscache_n_store_vmscan_wait));
52843 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
52844 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
52845 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
52846 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
52847 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
52848
52849 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
52850 - atomic_read(&fscache_n_op_pend),
52851 - atomic_read(&fscache_n_op_run),
52852 - atomic_read(&fscache_n_op_enqueue),
52853 - atomic_read(&fscache_n_op_cancelled),
52854 - atomic_read(&fscache_n_op_rejected));
52855 + atomic_read_unchecked(&fscache_n_op_pend),
52856 + atomic_read_unchecked(&fscache_n_op_run),
52857 + atomic_read_unchecked(&fscache_n_op_enqueue),
52858 + atomic_read_unchecked(&fscache_n_op_cancelled),
52859 + atomic_read_unchecked(&fscache_n_op_rejected));
52860 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
52861 - atomic_read(&fscache_n_op_deferred_release),
52862 - atomic_read(&fscache_n_op_release),
52863 - atomic_read(&fscache_n_op_gc));
52864 + atomic_read_unchecked(&fscache_n_op_deferred_release),
52865 + atomic_read_unchecked(&fscache_n_op_release),
52866 + atomic_read_unchecked(&fscache_n_op_gc));
52867
52868 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
52869 atomic_read(&fscache_n_cop_alloc_object),
52870 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
52871 index 6f96a8d..6019bb9 100644
52872 --- a/fs/fuse/cuse.c
52873 +++ b/fs/fuse/cuse.c
52874 @@ -597,10 +597,12 @@ static int __init cuse_init(void)
52875 INIT_LIST_HEAD(&cuse_conntbl[i]);
52876
52877 /* inherit and extend fuse_dev_operations */
52878 - cuse_channel_fops = fuse_dev_operations;
52879 - cuse_channel_fops.owner = THIS_MODULE;
52880 - cuse_channel_fops.open = cuse_channel_open;
52881 - cuse_channel_fops.release = cuse_channel_release;
52882 + pax_open_kernel();
52883 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
52884 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
52885 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
52886 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
52887 + pax_close_kernel();
52888
52889 cuse_class = class_create(THIS_MODULE, "cuse");
52890 if (IS_ERR(cuse_class))
52891 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
52892 index 11dfa0c..6f64416 100644
52893 --- a/fs/fuse/dev.c
52894 +++ b/fs/fuse/dev.c
52895 @@ -1294,7 +1294,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
52896 ret = 0;
52897 pipe_lock(pipe);
52898
52899 - if (!pipe->readers) {
52900 + if (!atomic_read(&pipe->readers)) {
52901 send_sig(SIGPIPE, current, 0);
52902 if (!ret)
52903 ret = -EPIPE;
52904 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
52905 index ff15522..092a0f6 100644
52906 --- a/fs/fuse/dir.c
52907 +++ b/fs/fuse/dir.c
52908 @@ -1409,7 +1409,7 @@ static char *read_link(struct dentry *dentry)
52909 return link;
52910 }
52911
52912 -static void free_link(char *link)
52913 +static void free_link(const char *link)
52914 {
52915 if (!IS_ERR(link))
52916 free_page((unsigned long) link);
52917 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
52918 index cc00bd1..3edb692 100644
52919 --- a/fs/gfs2/inode.c
52920 +++ b/fs/gfs2/inode.c
52921 @@ -1500,7 +1500,7 @@ out:
52922
52923 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52924 {
52925 - char *s = nd_get_link(nd);
52926 + const char *s = nd_get_link(nd);
52927 if (!IS_ERR(s))
52928 kfree(s);
52929 }
52930 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
52931 index a3f868a..bb308ae 100644
52932 --- a/fs/hugetlbfs/inode.c
52933 +++ b/fs/hugetlbfs/inode.c
52934 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
52935 struct mm_struct *mm = current->mm;
52936 struct vm_area_struct *vma;
52937 struct hstate *h = hstate_file(file);
52938 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
52939 struct vm_unmapped_area_info info;
52940
52941 if (len & ~huge_page_mask(h))
52942 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
52943 return addr;
52944 }
52945
52946 +#ifdef CONFIG_PAX_RANDMMAP
52947 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
52948 +#endif
52949 +
52950 if (addr) {
52951 addr = ALIGN(addr, huge_page_size(h));
52952 vma = find_vma(mm, addr);
52953 - if (TASK_SIZE - len >= addr &&
52954 - (!vma || addr + len <= vma->vm_start))
52955 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
52956 return addr;
52957 }
52958
52959 info.flags = 0;
52960 info.length = len;
52961 info.low_limit = TASK_UNMAPPED_BASE;
52962 +
52963 +#ifdef CONFIG_PAX_RANDMMAP
52964 + if (mm->pax_flags & MF_PAX_RANDMMAP)
52965 + info.low_limit += mm->delta_mmap;
52966 +#endif
52967 +
52968 info.high_limit = TASK_SIZE;
52969 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
52970 info.align_offset = 0;
52971 @@ -898,7 +908,7 @@ static struct file_system_type hugetlbfs_fs_type = {
52972 };
52973 MODULE_ALIAS_FS("hugetlbfs");
52974
52975 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
52976 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
52977
52978 static int can_do_hugetlb_shm(void)
52979 {
52980 diff --git a/fs/inode.c b/fs/inode.c
52981 index a898b3d..9b5a214 100644
52982 --- a/fs/inode.c
52983 +++ b/fs/inode.c
52984 @@ -878,8 +878,8 @@ unsigned int get_next_ino(void)
52985
52986 #ifdef CONFIG_SMP
52987 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
52988 - static atomic_t shared_last_ino;
52989 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
52990 + static atomic_unchecked_t shared_last_ino;
52991 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
52992
52993 res = next - LAST_INO_BATCH;
52994 }
52995 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
52996 index 4a6cf28..d3a29d3 100644
52997 --- a/fs/jffs2/erase.c
52998 +++ b/fs/jffs2/erase.c
52999 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
53000 struct jffs2_unknown_node marker = {
53001 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
53002 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53003 - .totlen = cpu_to_je32(c->cleanmarker_size)
53004 + .totlen = cpu_to_je32(c->cleanmarker_size),
53005 + .hdr_crc = cpu_to_je32(0)
53006 };
53007
53008 jffs2_prealloc_raw_node_refs(c, jeb, 1);
53009 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
53010 index a6597d6..41b30ec 100644
53011 --- a/fs/jffs2/wbuf.c
53012 +++ b/fs/jffs2/wbuf.c
53013 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
53014 {
53015 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
53016 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53017 - .totlen = constant_cpu_to_je32(8)
53018 + .totlen = constant_cpu_to_je32(8),
53019 + .hdr_crc = constant_cpu_to_je32(0)
53020 };
53021
53022 /*
53023 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
53024 index 2003e83..40db287 100644
53025 --- a/fs/jfs/super.c
53026 +++ b/fs/jfs/super.c
53027 @@ -856,7 +856,7 @@ static int __init init_jfs_fs(void)
53028
53029 jfs_inode_cachep =
53030 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
53031 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
53032 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
53033 init_once);
53034 if (jfs_inode_cachep == NULL)
53035 return -ENOMEM;
53036 diff --git a/fs/libfs.c b/fs/libfs.c
53037 index 916da8c..1588998 100644
53038 --- a/fs/libfs.c
53039 +++ b/fs/libfs.c
53040 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53041
53042 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
53043 struct dentry *next;
53044 + char d_name[sizeof(next->d_iname)];
53045 + const unsigned char *name;
53046 +
53047 next = list_entry(p, struct dentry, d_u.d_child);
53048 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
53049 if (!simple_positive(next)) {
53050 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53051
53052 spin_unlock(&next->d_lock);
53053 spin_unlock(&dentry->d_lock);
53054 - if (filldir(dirent, next->d_name.name,
53055 + name = next->d_name.name;
53056 + if (name == next->d_iname) {
53057 + memcpy(d_name, name, next->d_name.len);
53058 + name = d_name;
53059 + }
53060 + if (filldir(dirent, name,
53061 next->d_name.len, filp->f_pos,
53062 next->d_inode->i_ino,
53063 dt_type(next->d_inode)) < 0)
53064 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
53065 index 9760ecb..9b838ef 100644
53066 --- a/fs/lockd/clntproc.c
53067 +++ b/fs/lockd/clntproc.c
53068 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
53069 /*
53070 * Cookie counter for NLM requests
53071 */
53072 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
53073 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
53074
53075 void nlmclnt_next_cookie(struct nlm_cookie *c)
53076 {
53077 - u32 cookie = atomic_inc_return(&nlm_cookie);
53078 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
53079
53080 memcpy(c->data, &cookie, 4);
53081 c->len=4;
53082 diff --git a/fs/locks.c b/fs/locks.c
53083 index cb424a4..850e4dd 100644
53084 --- a/fs/locks.c
53085 +++ b/fs/locks.c
53086 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
53087 return;
53088
53089 if (filp->f_op && filp->f_op->flock) {
53090 - struct file_lock fl = {
53091 + struct file_lock flock = {
53092 .fl_pid = current->tgid,
53093 .fl_file = filp,
53094 .fl_flags = FL_FLOCK,
53095 .fl_type = F_UNLCK,
53096 .fl_end = OFFSET_MAX,
53097 };
53098 - filp->f_op->flock(filp, F_SETLKW, &fl);
53099 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
53100 - fl.fl_ops->fl_release_private(&fl);
53101 + filp->f_op->flock(filp, F_SETLKW, &flock);
53102 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
53103 + flock.fl_ops->fl_release_private(&flock);
53104 }
53105
53106 lock_flocks();
53107 diff --git a/fs/namei.c b/fs/namei.c
53108 index 85e40d1..b66744e 100644
53109 --- a/fs/namei.c
53110 +++ b/fs/namei.c
53111 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
53112 if (ret != -EACCES)
53113 return ret;
53114
53115 +#ifdef CONFIG_GRKERNSEC
53116 + /* we'll block if we have to log due to a denied capability use */
53117 + if (mask & MAY_NOT_BLOCK)
53118 + return -ECHILD;
53119 +#endif
53120 +
53121 if (S_ISDIR(inode->i_mode)) {
53122 /* DACs are overridable for directories */
53123 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
53124 - return 0;
53125 if (!(mask & MAY_WRITE))
53126 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53127 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53128 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53129 return 0;
53130 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
53131 + return 0;
53132 return -EACCES;
53133 }
53134 /*
53135 + * Searching includes executable on directories, else just read.
53136 + */
53137 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53138 + if (mask == MAY_READ)
53139 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53140 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53141 + return 0;
53142 +
53143 + /*
53144 * Read/write DACs are always overridable.
53145 * Executable DACs are overridable when there is
53146 * at least one exec bit set.
53147 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
53148 if (inode_capable(inode, CAP_DAC_OVERRIDE))
53149 return 0;
53150
53151 - /*
53152 - * Searching includes executable on directories, else just read.
53153 - */
53154 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53155 - if (mask == MAY_READ)
53156 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53157 - return 0;
53158 -
53159 return -EACCES;
53160 }
53161
53162 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53163 {
53164 struct dentry *dentry = link->dentry;
53165 int error;
53166 - char *s;
53167 + const char *s;
53168
53169 BUG_ON(nd->flags & LOOKUP_RCU);
53170
53171 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53172 if (error)
53173 goto out_put_nd_path;
53174
53175 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
53176 + dentry->d_inode, dentry, nd->path.mnt)) {
53177 + error = -EACCES;
53178 + goto out_put_nd_path;
53179 + }
53180 +
53181 nd->last_type = LAST_BIND;
53182 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
53183 error = PTR_ERR(*p);
53184 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
53185 if (res)
53186 break;
53187 res = walk_component(nd, path, LOOKUP_FOLLOW);
53188 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
53189 + res = -EACCES;
53190 put_link(nd, &link, cookie);
53191 } while (res > 0);
53192
53193 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
53194 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
53195 {
53196 unsigned long a, b, adata, bdata, mask, hash, len;
53197 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53198 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53199
53200 hash = a = 0;
53201 len = -sizeof(unsigned long);
53202 @@ -1968,6 +1984,8 @@ static int path_lookupat(int dfd, const char *name,
53203 if (err)
53204 break;
53205 err = lookup_last(nd, &path);
53206 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
53207 + err = -EACCES;
53208 put_link(nd, &link, cookie);
53209 }
53210 }
53211 @@ -1975,6 +1993,13 @@ static int path_lookupat(int dfd, const char *name,
53212 if (!err)
53213 err = complete_walk(nd);
53214
53215 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
53216 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53217 + path_put(&nd->path);
53218 + err = -ENOENT;
53219 + }
53220 + }
53221 +
53222 if (!err && nd->flags & LOOKUP_DIRECTORY) {
53223 if (!nd->inode->i_op->lookup) {
53224 path_put(&nd->path);
53225 @@ -2002,8 +2027,15 @@ static int filename_lookup(int dfd, struct filename *name,
53226 retval = path_lookupat(dfd, name->name,
53227 flags | LOOKUP_REVAL, nd);
53228
53229 - if (likely(!retval))
53230 + if (likely(!retval)) {
53231 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
53232 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
53233 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
53234 + path_put(&nd->path);
53235 + return -ENOENT;
53236 + }
53237 + }
53238 + }
53239 return retval;
53240 }
53241
53242 @@ -2381,6 +2413,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
53243 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
53244 return -EPERM;
53245
53246 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
53247 + return -EPERM;
53248 + if (gr_handle_rawio(inode))
53249 + return -EPERM;
53250 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
53251 + return -EACCES;
53252 +
53253 return 0;
53254 }
53255
53256 @@ -2602,7 +2641,7 @@ looked_up:
53257 * cleared otherwise prior to returning.
53258 */
53259 static int lookup_open(struct nameidata *nd, struct path *path,
53260 - struct file *file,
53261 + struct path *link, struct file *file,
53262 const struct open_flags *op,
53263 bool got_write, int *opened)
53264 {
53265 @@ -2637,6 +2676,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53266 /* Negative dentry, just create the file */
53267 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
53268 umode_t mode = op->mode;
53269 +
53270 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
53271 + error = -EACCES;
53272 + goto out_dput;
53273 + }
53274 +
53275 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
53276 + error = -EACCES;
53277 + goto out_dput;
53278 + }
53279 +
53280 if (!IS_POSIXACL(dir->d_inode))
53281 mode &= ~current_umask();
53282 /*
53283 @@ -2658,6 +2708,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53284 nd->flags & LOOKUP_EXCL);
53285 if (error)
53286 goto out_dput;
53287 + else
53288 + gr_handle_create(dentry, nd->path.mnt);
53289 }
53290 out_no_open:
53291 path->dentry = dentry;
53292 @@ -2672,7 +2724,7 @@ out_dput:
53293 /*
53294 * Handle the last step of open()
53295 */
53296 -static int do_last(struct nameidata *nd, struct path *path,
53297 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
53298 struct file *file, const struct open_flags *op,
53299 int *opened, struct filename *name)
53300 {
53301 @@ -2701,16 +2753,32 @@ static int do_last(struct nameidata *nd, struct path *path,
53302 error = complete_walk(nd);
53303 if (error)
53304 return error;
53305 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53306 + error = -ENOENT;
53307 + goto out;
53308 + }
53309 audit_inode(name, nd->path.dentry, 0);
53310 if (open_flag & O_CREAT) {
53311 error = -EISDIR;
53312 goto out;
53313 }
53314 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53315 + error = -EACCES;
53316 + goto out;
53317 + }
53318 goto finish_open;
53319 case LAST_BIND:
53320 error = complete_walk(nd);
53321 if (error)
53322 return error;
53323 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
53324 + error = -ENOENT;
53325 + goto out;
53326 + }
53327 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53328 + error = -EACCES;
53329 + goto out;
53330 + }
53331 audit_inode(name, dir, 0);
53332 goto finish_open;
53333 }
53334 @@ -2759,7 +2827,7 @@ retry_lookup:
53335 */
53336 }
53337 mutex_lock(&dir->d_inode->i_mutex);
53338 - error = lookup_open(nd, path, file, op, got_write, opened);
53339 + error = lookup_open(nd, path, link, file, op, got_write, opened);
53340 mutex_unlock(&dir->d_inode->i_mutex);
53341
53342 if (error <= 0) {
53343 @@ -2783,11 +2851,28 @@ retry_lookup:
53344 goto finish_open_created;
53345 }
53346
53347 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
53348 + error = -ENOENT;
53349 + goto exit_dput;
53350 + }
53351 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53352 + error = -EACCES;
53353 + goto exit_dput;
53354 + }
53355 +
53356 /*
53357 * create/update audit record if it already exists.
53358 */
53359 - if (path->dentry->d_inode)
53360 + if (path->dentry->d_inode) {
53361 + /* only check if O_CREAT is specified, all other checks need to go
53362 + into may_open */
53363 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53364 + error = -EACCES;
53365 + goto exit_dput;
53366 + }
53367 +
53368 audit_inode(name, path->dentry, 0);
53369 + }
53370
53371 /*
53372 * If atomic_open() acquired write access it is dropped now due to
53373 @@ -2828,6 +2913,11 @@ finish_lookup:
53374 }
53375 }
53376 BUG_ON(inode != path->dentry->d_inode);
53377 + /* if we're resolving a symlink to another symlink */
53378 + if (link && gr_handle_symlink_owner(link, inode)) {
53379 + error = -EACCES;
53380 + goto out;
53381 + }
53382 return 1;
53383 }
53384
53385 @@ -2837,7 +2927,6 @@ finish_lookup:
53386 save_parent.dentry = nd->path.dentry;
53387 save_parent.mnt = mntget(path->mnt);
53388 nd->path.dentry = path->dentry;
53389 -
53390 }
53391 nd->inode = inode;
53392 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
53393 @@ -2846,6 +2935,16 @@ finish_lookup:
53394 path_put(&save_parent);
53395 return error;
53396 }
53397 +
53398 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53399 + error = -ENOENT;
53400 + goto out;
53401 + }
53402 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53403 + error = -EACCES;
53404 + goto out;
53405 + }
53406 +
53407 error = -EISDIR;
53408 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
53409 goto out;
53410 @@ -2944,7 +3043,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53411 if (unlikely(error))
53412 goto out;
53413
53414 - error = do_last(nd, &path, file, op, &opened, pathname);
53415 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
53416 while (unlikely(error > 0)) { /* trailing symlink */
53417 struct path link = path;
53418 void *cookie;
53419 @@ -2962,7 +3061,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53420 error = follow_link(&link, nd, &cookie);
53421 if (unlikely(error))
53422 break;
53423 - error = do_last(nd, &path, file, op, &opened, pathname);
53424 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
53425 put_link(nd, &link, cookie);
53426 }
53427 out:
53428 @@ -3062,8 +3161,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
53429 goto unlock;
53430
53431 error = -EEXIST;
53432 - if (dentry->d_inode)
53433 + if (dentry->d_inode) {
53434 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
53435 + error = -ENOENT;
53436 + }
53437 goto fail;
53438 + }
53439 /*
53440 * Special case - lookup gave negative, but... we had foo/bar/
53441 * From the vfs_mknod() POV we just have a negative dentry -
53442 @@ -3115,6 +3218,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
53443 }
53444 EXPORT_SYMBOL(user_path_create);
53445
53446 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
53447 +{
53448 + struct filename *tmp = getname(pathname);
53449 + struct dentry *res;
53450 + if (IS_ERR(tmp))
53451 + return ERR_CAST(tmp);
53452 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
53453 + if (IS_ERR(res))
53454 + putname(tmp);
53455 + else
53456 + *to = tmp;
53457 + return res;
53458 +}
53459 +
53460 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
53461 {
53462 int error = may_create(dir, dentry);
53463 @@ -3177,6 +3294,17 @@ retry:
53464
53465 if (!IS_POSIXACL(path.dentry->d_inode))
53466 mode &= ~current_umask();
53467 +
53468 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
53469 + error = -EPERM;
53470 + goto out;
53471 + }
53472 +
53473 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
53474 + error = -EACCES;
53475 + goto out;
53476 + }
53477 +
53478 error = security_path_mknod(&path, dentry, mode, dev);
53479 if (error)
53480 goto out;
53481 @@ -3193,6 +3321,8 @@ retry:
53482 break;
53483 }
53484 out:
53485 + if (!error)
53486 + gr_handle_create(dentry, path.mnt);
53487 done_path_create(&path, dentry);
53488 if (retry_estale(error, lookup_flags)) {
53489 lookup_flags |= LOOKUP_REVAL;
53490 @@ -3245,9 +3375,16 @@ retry:
53491
53492 if (!IS_POSIXACL(path.dentry->d_inode))
53493 mode &= ~current_umask();
53494 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
53495 + error = -EACCES;
53496 + goto out;
53497 + }
53498 error = security_path_mkdir(&path, dentry, mode);
53499 if (!error)
53500 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
53501 + if (!error)
53502 + gr_handle_create(dentry, path.mnt);
53503 +out:
53504 done_path_create(&path, dentry);
53505 if (retry_estale(error, lookup_flags)) {
53506 lookup_flags |= LOOKUP_REVAL;
53507 @@ -3328,6 +3465,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
53508 struct filename *name;
53509 struct dentry *dentry;
53510 struct nameidata nd;
53511 + ino_t saved_ino = 0;
53512 + dev_t saved_dev = 0;
53513 unsigned int lookup_flags = 0;
53514 retry:
53515 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53516 @@ -3360,10 +3499,21 @@ retry:
53517 error = -ENOENT;
53518 goto exit3;
53519 }
53520 +
53521 + saved_ino = dentry->d_inode->i_ino;
53522 + saved_dev = gr_get_dev_from_dentry(dentry);
53523 +
53524 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
53525 + error = -EACCES;
53526 + goto exit3;
53527 + }
53528 +
53529 error = security_path_rmdir(&nd.path, dentry);
53530 if (error)
53531 goto exit3;
53532 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
53533 + if (!error && (saved_dev || saved_ino))
53534 + gr_handle_delete(saved_ino, saved_dev);
53535 exit3:
53536 dput(dentry);
53537 exit2:
53538 @@ -3429,6 +3579,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
53539 struct dentry *dentry;
53540 struct nameidata nd;
53541 struct inode *inode = NULL;
53542 + ino_t saved_ino = 0;
53543 + dev_t saved_dev = 0;
53544 unsigned int lookup_flags = 0;
53545 retry:
53546 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53547 @@ -3455,10 +3607,22 @@ retry:
53548 if (!inode)
53549 goto slashes;
53550 ihold(inode);
53551 +
53552 + if (inode->i_nlink <= 1) {
53553 + saved_ino = inode->i_ino;
53554 + saved_dev = gr_get_dev_from_dentry(dentry);
53555 + }
53556 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
53557 + error = -EACCES;
53558 + goto exit2;
53559 + }
53560 +
53561 error = security_path_unlink(&nd.path, dentry);
53562 if (error)
53563 goto exit2;
53564 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
53565 + if (!error && (saved_ino || saved_dev))
53566 + gr_handle_delete(saved_ino, saved_dev);
53567 exit2:
53568 dput(dentry);
53569 }
53570 @@ -3536,9 +3700,17 @@ retry:
53571 if (IS_ERR(dentry))
53572 goto out_putname;
53573
53574 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
53575 + error = -EACCES;
53576 + goto out;
53577 + }
53578 +
53579 error = security_path_symlink(&path, dentry, from->name);
53580 if (!error)
53581 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
53582 + if (!error)
53583 + gr_handle_create(dentry, path.mnt);
53584 +out:
53585 done_path_create(&path, dentry);
53586 if (retry_estale(error, lookup_flags)) {
53587 lookup_flags |= LOOKUP_REVAL;
53588 @@ -3612,6 +3784,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
53589 {
53590 struct dentry *new_dentry;
53591 struct path old_path, new_path;
53592 + struct filename *to = NULL;
53593 int how = 0;
53594 int error;
53595
53596 @@ -3635,7 +3808,7 @@ retry:
53597 if (error)
53598 return error;
53599
53600 - new_dentry = user_path_create(newdfd, newname, &new_path,
53601 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
53602 (how & LOOKUP_REVAL));
53603 error = PTR_ERR(new_dentry);
53604 if (IS_ERR(new_dentry))
53605 @@ -3647,11 +3820,28 @@ retry:
53606 error = may_linkat(&old_path);
53607 if (unlikely(error))
53608 goto out_dput;
53609 +
53610 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
53611 + old_path.dentry->d_inode,
53612 + old_path.dentry->d_inode->i_mode, to)) {
53613 + error = -EACCES;
53614 + goto out_dput;
53615 + }
53616 +
53617 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
53618 + old_path.dentry, old_path.mnt, to)) {
53619 + error = -EACCES;
53620 + goto out_dput;
53621 + }
53622 +
53623 error = security_path_link(old_path.dentry, &new_path, new_dentry);
53624 if (error)
53625 goto out_dput;
53626 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
53627 + if (!error)
53628 + gr_handle_create(new_dentry, new_path.mnt);
53629 out_dput:
53630 + putname(to);
53631 done_path_create(&new_path, new_dentry);
53632 if (retry_estale(error, how)) {
53633 how |= LOOKUP_REVAL;
53634 @@ -3897,12 +4087,21 @@ retry:
53635 if (new_dentry == trap)
53636 goto exit5;
53637
53638 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
53639 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
53640 + to);
53641 + if (error)
53642 + goto exit5;
53643 +
53644 error = security_path_rename(&oldnd.path, old_dentry,
53645 &newnd.path, new_dentry);
53646 if (error)
53647 goto exit5;
53648 error = vfs_rename(old_dir->d_inode, old_dentry,
53649 new_dir->d_inode, new_dentry);
53650 + if (!error)
53651 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
53652 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
53653 exit5:
53654 dput(new_dentry);
53655 exit4:
53656 @@ -3934,6 +4133,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
53657
53658 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
53659 {
53660 + char tmpbuf[64];
53661 + const char *newlink;
53662 int len;
53663
53664 len = PTR_ERR(link);
53665 @@ -3943,7 +4144,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
53666 len = strlen(link);
53667 if (len > (unsigned) buflen)
53668 len = buflen;
53669 - if (copy_to_user(buffer, link, len))
53670 +
53671 + if (len < sizeof(tmpbuf)) {
53672 + memcpy(tmpbuf, link, len);
53673 + newlink = tmpbuf;
53674 + } else
53675 + newlink = link;
53676 +
53677 + if (copy_to_user(buffer, newlink, len))
53678 len = -EFAULT;
53679 out:
53680 return len;
53681 diff --git a/fs/namespace.c b/fs/namespace.c
53682 index e945b81..fc018e2 100644
53683 --- a/fs/namespace.c
53684 +++ b/fs/namespace.c
53685 @@ -1219,6 +1219,9 @@ static int do_umount(struct mount *mnt, int flags)
53686 if (!(sb->s_flags & MS_RDONLY))
53687 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
53688 up_write(&sb->s_umount);
53689 +
53690 + gr_log_remount(mnt->mnt_devname, retval);
53691 +
53692 return retval;
53693 }
53694
53695 @@ -1238,6 +1241,9 @@ static int do_umount(struct mount *mnt, int flags)
53696 br_write_unlock(&vfsmount_lock);
53697 up_write(&namespace_sem);
53698 release_mounts(&umount_list);
53699 +
53700 + gr_log_unmount(mnt->mnt_devname, retval);
53701 +
53702 return retval;
53703 }
53704
53705 @@ -1257,7 +1263,7 @@ static inline bool may_mount(void)
53706 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
53707 */
53708
53709 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
53710 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
53711 {
53712 struct path path;
53713 struct mount *mnt;
53714 @@ -1297,7 +1303,7 @@ out:
53715 /*
53716 * The 2.0 compatible umount. No flags.
53717 */
53718 -SYSCALL_DEFINE1(oldumount, char __user *, name)
53719 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
53720 {
53721 return sys_umount(name, 0);
53722 }
53723 @@ -2267,6 +2273,16 @@ long do_mount(const char *dev_name, const char *dir_name,
53724 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
53725 MS_STRICTATIME);
53726
53727 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
53728 + retval = -EPERM;
53729 + goto dput_out;
53730 + }
53731 +
53732 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
53733 + retval = -EPERM;
53734 + goto dput_out;
53735 + }
53736 +
53737 if (flags & MS_REMOUNT)
53738 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
53739 data_page);
53740 @@ -2281,6 +2297,9 @@ long do_mount(const char *dev_name, const char *dir_name,
53741 dev_name, data_page);
53742 dput_out:
53743 path_put(&path);
53744 +
53745 + gr_log_mount(dev_name, dir_name, retval);
53746 +
53747 return retval;
53748 }
53749
53750 @@ -2454,8 +2473,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
53751 }
53752 EXPORT_SYMBOL(mount_subtree);
53753
53754 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
53755 - char __user *, type, unsigned long, flags, void __user *, data)
53756 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
53757 + const char __user *, type, unsigned long, flags, void __user *, data)
53758 {
53759 int ret;
53760 char *kernel_type;
53761 @@ -2567,6 +2586,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
53762 if (error)
53763 goto out2;
53764
53765 + if (gr_handle_chroot_pivot()) {
53766 + error = -EPERM;
53767 + goto out2;
53768 + }
53769 +
53770 get_fs_root(current->fs, &root);
53771 error = lock_mount(&old);
53772 if (error)
53773 @@ -2815,7 +2839,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
53774 !nsown_capable(CAP_SYS_ADMIN))
53775 return -EPERM;
53776
53777 - if (fs->users != 1)
53778 + if (atomic_read(&fs->users) != 1)
53779 return -EINVAL;
53780
53781 get_mnt_ns(mnt_ns);
53782 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
53783 index 59461c9..b17c57e 100644
53784 --- a/fs/nfs/callback_xdr.c
53785 +++ b/fs/nfs/callback_xdr.c
53786 @@ -51,7 +51,7 @@ struct callback_op {
53787 callback_decode_arg_t decode_args;
53788 callback_encode_res_t encode_res;
53789 long res_maxsize;
53790 -};
53791 +} __do_const;
53792
53793 static struct callback_op callback_ops[];
53794
53795 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
53796 index 1f94167..79c4ce4 100644
53797 --- a/fs/nfs/inode.c
53798 +++ b/fs/nfs/inode.c
53799 @@ -1041,16 +1041,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
53800 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
53801 }
53802
53803 -static atomic_long_t nfs_attr_generation_counter;
53804 +static atomic_long_unchecked_t nfs_attr_generation_counter;
53805
53806 static unsigned long nfs_read_attr_generation_counter(void)
53807 {
53808 - return atomic_long_read(&nfs_attr_generation_counter);
53809 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
53810 }
53811
53812 unsigned long nfs_inc_attr_generation_counter(void)
53813 {
53814 - return atomic_long_inc_return(&nfs_attr_generation_counter);
53815 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
53816 }
53817
53818 void nfs_fattr_init(struct nfs_fattr *fattr)
53819 diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
53820 index 0086401..261e9b9 100644
53821 --- a/fs/nfs/nfs4proc.c
53822 +++ b/fs/nfs/nfs4proc.c
53823 @@ -1022,7 +1022,7 @@ static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata)
53824 struct nfs4_state *state = opendata->state;
53825 struct nfs_inode *nfsi = NFS_I(state->inode);
53826 struct nfs_delegation *delegation;
53827 - int open_mode = opendata->o_arg.open_flags & (O_EXCL|O_TRUNC);
53828 + int open_mode = opendata->o_arg.open_flags;
53829 fmode_t fmode = opendata->o_arg.fmode;
53830 nfs4_stateid stateid;
53831 int ret = -EAGAIN;
53832 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
53833 index d401d01..10b3e62 100644
53834 --- a/fs/nfsd/nfs4proc.c
53835 +++ b/fs/nfsd/nfs4proc.c
53836 @@ -1109,7 +1109,7 @@ struct nfsd4_operation {
53837 nfsd4op_rsize op_rsize_bop;
53838 stateid_getter op_get_currentstateid;
53839 stateid_setter op_set_currentstateid;
53840 -};
53841 +} __do_const;
53842
53843 static struct nfsd4_operation nfsd4_ops[];
53844
53845 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
53846 index 6eb0dc5..29067a9 100644
53847 --- a/fs/nfsd/nfs4xdr.c
53848 +++ b/fs/nfsd/nfs4xdr.c
53849 @@ -1457,7 +1457,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
53850
53851 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
53852
53853 -static nfsd4_dec nfsd4_dec_ops[] = {
53854 +static const nfsd4_dec nfsd4_dec_ops[] = {
53855 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
53856 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
53857 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
53858 @@ -1497,7 +1497,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
53859 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
53860 };
53861
53862 -static nfsd4_dec nfsd41_dec_ops[] = {
53863 +static const nfsd4_dec nfsd41_dec_ops[] = {
53864 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
53865 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
53866 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
53867 @@ -1559,7 +1559,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
53868 };
53869
53870 struct nfsd4_minorversion_ops {
53871 - nfsd4_dec *decoders;
53872 + const nfsd4_dec *decoders;
53873 int nops;
53874 };
53875
53876 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
53877 index ca05f6d..411a576 100644
53878 --- a/fs/nfsd/nfscache.c
53879 +++ b/fs/nfsd/nfscache.c
53880 @@ -461,13 +461,15 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
53881 {
53882 struct svc_cacherep *rp = rqstp->rq_cacherep;
53883 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
53884 - int len;
53885 + long len;
53886
53887 if (!rp)
53888 return;
53889
53890 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
53891 - len >>= 2;
53892 + if (statp) {
53893 + len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
53894 + len >>= 2;
53895 + }
53896
53897 /* Don't cache excessive amounts of data and XDR failures */
53898 if (!statp || len > (256 >> 2)) {
53899 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
53900 index 2b2e239..c915b48 100644
53901 --- a/fs/nfsd/vfs.c
53902 +++ b/fs/nfsd/vfs.c
53903 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
53904 } else {
53905 oldfs = get_fs();
53906 set_fs(KERNEL_DS);
53907 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
53908 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
53909 set_fs(oldfs);
53910 }
53911
53912 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
53913
53914 /* Write the data. */
53915 oldfs = get_fs(); set_fs(KERNEL_DS);
53916 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
53917 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
53918 set_fs(oldfs);
53919 if (host_err < 0)
53920 goto out_nfserr;
53921 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
53922 */
53923
53924 oldfs = get_fs(); set_fs(KERNEL_DS);
53925 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
53926 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
53927 set_fs(oldfs);
53928
53929 if (host_err < 0)
53930 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
53931 index fea6bd5..8ee9d81 100644
53932 --- a/fs/nls/nls_base.c
53933 +++ b/fs/nls/nls_base.c
53934 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
53935
53936 int register_nls(struct nls_table * nls)
53937 {
53938 - struct nls_table ** tmp = &tables;
53939 + struct nls_table *tmp = tables;
53940
53941 if (nls->next)
53942 return -EBUSY;
53943
53944 spin_lock(&nls_lock);
53945 - while (*tmp) {
53946 - if (nls == *tmp) {
53947 + while (tmp) {
53948 + if (nls == tmp) {
53949 spin_unlock(&nls_lock);
53950 return -EBUSY;
53951 }
53952 - tmp = &(*tmp)->next;
53953 + tmp = tmp->next;
53954 }
53955 - nls->next = tables;
53956 + pax_open_kernel();
53957 + *(struct nls_table **)&nls->next = tables;
53958 + pax_close_kernel();
53959 tables = nls;
53960 spin_unlock(&nls_lock);
53961 return 0;
53962 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
53963
53964 int unregister_nls(struct nls_table * nls)
53965 {
53966 - struct nls_table ** tmp = &tables;
53967 + struct nls_table * const * tmp = &tables;
53968
53969 spin_lock(&nls_lock);
53970 while (*tmp) {
53971 if (nls == *tmp) {
53972 - *tmp = nls->next;
53973 + pax_open_kernel();
53974 + *(struct nls_table **)tmp = nls->next;
53975 + pax_close_kernel();
53976 spin_unlock(&nls_lock);
53977 return 0;
53978 }
53979 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
53980 index 7424929..35f6be5 100644
53981 --- a/fs/nls/nls_euc-jp.c
53982 +++ b/fs/nls/nls_euc-jp.c
53983 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
53984 p_nls = load_nls("cp932");
53985
53986 if (p_nls) {
53987 - table.charset2upper = p_nls->charset2upper;
53988 - table.charset2lower = p_nls->charset2lower;
53989 + pax_open_kernel();
53990 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
53991 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
53992 + pax_close_kernel();
53993 return register_nls(&table);
53994 }
53995
53996 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
53997 index e7bc1d7..06bd4bb 100644
53998 --- a/fs/nls/nls_koi8-ru.c
53999 +++ b/fs/nls/nls_koi8-ru.c
54000 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
54001 p_nls = load_nls("koi8-u");
54002
54003 if (p_nls) {
54004 - table.charset2upper = p_nls->charset2upper;
54005 - table.charset2lower = p_nls->charset2lower;
54006 + pax_open_kernel();
54007 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54008 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54009 + pax_close_kernel();
54010 return register_nls(&table);
54011 }
54012
54013 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
54014 index 5d84442..bf24453 100644
54015 --- a/fs/notify/fanotify/fanotify_user.c
54016 +++ b/fs/notify/fanotify/fanotify_user.c
54017 @@ -251,8 +251,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
54018
54019 fd = fanotify_event_metadata.fd;
54020 ret = -EFAULT;
54021 - if (copy_to_user(buf, &fanotify_event_metadata,
54022 - fanotify_event_metadata.event_len))
54023 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
54024 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
54025 goto out_close_fd;
54026
54027 ret = prepare_for_access_response(group, event, fd);
54028 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
54029 index 7b51b05..5ea5ef6 100644
54030 --- a/fs/notify/notification.c
54031 +++ b/fs/notify/notification.c
54032 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
54033 * get set to 0 so it will never get 'freed'
54034 */
54035 static struct fsnotify_event *q_overflow_event;
54036 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54037 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54038
54039 /**
54040 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
54041 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54042 */
54043 u32 fsnotify_get_cookie(void)
54044 {
54045 - return atomic_inc_return(&fsnotify_sync_cookie);
54046 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
54047 }
54048 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
54049
54050 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
54051 index aa411c3..c260a84 100644
54052 --- a/fs/ntfs/dir.c
54053 +++ b/fs/ntfs/dir.c
54054 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
54055 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
54056 ~(s64)(ndir->itype.index.block_size - 1)));
54057 /* Bounds checks. */
54058 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54059 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54060 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
54061 "inode 0x%lx or driver bug.", vdir->i_ino);
54062 goto err_out;
54063 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
54064 index 5b2d4f0..c6de396 100644
54065 --- a/fs/ntfs/file.c
54066 +++ b/fs/ntfs/file.c
54067 @@ -2242,6 +2242,6 @@ const struct inode_operations ntfs_file_inode_ops = {
54068 #endif /* NTFS_RW */
54069 };
54070
54071 -const struct file_operations ntfs_empty_file_ops = {};
54072 +const struct file_operations ntfs_empty_file_ops __read_only;
54073
54074 -const struct inode_operations ntfs_empty_inode_ops = {};
54075 +const struct inode_operations ntfs_empty_inode_ops __read_only;
54076 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
54077 index aebeacd..0dcdd26 100644
54078 --- a/fs/ocfs2/localalloc.c
54079 +++ b/fs/ocfs2/localalloc.c
54080 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
54081 goto bail;
54082 }
54083
54084 - atomic_inc(&osb->alloc_stats.moves);
54085 + atomic_inc_unchecked(&osb->alloc_stats.moves);
54086
54087 bail:
54088 if (handle)
54089 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
54090 index d355e6e..578d905 100644
54091 --- a/fs/ocfs2/ocfs2.h
54092 +++ b/fs/ocfs2/ocfs2.h
54093 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
54094
54095 struct ocfs2_alloc_stats
54096 {
54097 - atomic_t moves;
54098 - atomic_t local_data;
54099 - atomic_t bitmap_data;
54100 - atomic_t bg_allocs;
54101 - atomic_t bg_extends;
54102 + atomic_unchecked_t moves;
54103 + atomic_unchecked_t local_data;
54104 + atomic_unchecked_t bitmap_data;
54105 + atomic_unchecked_t bg_allocs;
54106 + atomic_unchecked_t bg_extends;
54107 };
54108
54109 enum ocfs2_local_alloc_state
54110 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
54111 index b7e74b5..19c6536 100644
54112 --- a/fs/ocfs2/suballoc.c
54113 +++ b/fs/ocfs2/suballoc.c
54114 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
54115 mlog_errno(status);
54116 goto bail;
54117 }
54118 - atomic_inc(&osb->alloc_stats.bg_extends);
54119 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
54120
54121 /* You should never ask for this much metadata */
54122 BUG_ON(bits_wanted >
54123 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
54124 mlog_errno(status);
54125 goto bail;
54126 }
54127 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54128 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54129
54130 *suballoc_loc = res.sr_bg_blkno;
54131 *suballoc_bit_start = res.sr_bit_offset;
54132 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
54133 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
54134 res->sr_bits);
54135
54136 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54137 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54138
54139 BUG_ON(res->sr_bits != 1);
54140
54141 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
54142 mlog_errno(status);
54143 goto bail;
54144 }
54145 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54146 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54147
54148 BUG_ON(res.sr_bits != 1);
54149
54150 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54151 cluster_start,
54152 num_clusters);
54153 if (!status)
54154 - atomic_inc(&osb->alloc_stats.local_data);
54155 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
54156 } else {
54157 if (min_clusters > (osb->bitmap_cpg - 1)) {
54158 /* The only paths asking for contiguousness
54159 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54160 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
54161 res.sr_bg_blkno,
54162 res.sr_bit_offset);
54163 - atomic_inc(&osb->alloc_stats.bitmap_data);
54164 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
54165 *num_clusters = res.sr_bits;
54166 }
54167 }
54168 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
54169 index 01b8516..579c4df 100644
54170 --- a/fs/ocfs2/super.c
54171 +++ b/fs/ocfs2/super.c
54172 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
54173 "%10s => GlobalAllocs: %d LocalAllocs: %d "
54174 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
54175 "Stats",
54176 - atomic_read(&osb->alloc_stats.bitmap_data),
54177 - atomic_read(&osb->alloc_stats.local_data),
54178 - atomic_read(&osb->alloc_stats.bg_allocs),
54179 - atomic_read(&osb->alloc_stats.moves),
54180 - atomic_read(&osb->alloc_stats.bg_extends));
54181 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
54182 + atomic_read_unchecked(&osb->alloc_stats.local_data),
54183 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
54184 + atomic_read_unchecked(&osb->alloc_stats.moves),
54185 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
54186
54187 out += snprintf(buf + out, len - out,
54188 "%10s => State: %u Descriptor: %llu Size: %u bits "
54189 @@ -2122,11 +2122,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
54190 spin_lock_init(&osb->osb_xattr_lock);
54191 ocfs2_init_steal_slots(osb);
54192
54193 - atomic_set(&osb->alloc_stats.moves, 0);
54194 - atomic_set(&osb->alloc_stats.local_data, 0);
54195 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
54196 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
54197 - atomic_set(&osb->alloc_stats.bg_extends, 0);
54198 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
54199 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
54200 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
54201 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
54202 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
54203
54204 /* Copy the blockcheck stats from the superblock probe */
54205 osb->osb_ecc_stats = *stats;
54206 diff --git a/fs/open.c b/fs/open.c
54207 index 6835446..eadf09f 100644
54208 --- a/fs/open.c
54209 +++ b/fs/open.c
54210 @@ -32,6 +32,8 @@
54211 #include <linux/dnotify.h>
54212 #include <linux/compat.h>
54213
54214 +#define CREATE_TRACE_POINTS
54215 +#include <trace/events/fs.h>
54216 #include "internal.h"
54217
54218 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
54219 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
54220 error = locks_verify_truncate(inode, NULL, length);
54221 if (!error)
54222 error = security_path_truncate(path);
54223 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
54224 + error = -EACCES;
54225 if (!error)
54226 error = do_truncate(path->dentry, length, 0, NULL);
54227
54228 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
54229 error = locks_verify_truncate(inode, f.file, length);
54230 if (!error)
54231 error = security_path_truncate(&f.file->f_path);
54232 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
54233 + error = -EACCES;
54234 if (!error)
54235 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
54236 sb_end_write(inode->i_sb);
54237 @@ -388,6 +394,9 @@ retry:
54238 if (__mnt_is_readonly(path.mnt))
54239 res = -EROFS;
54240
54241 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
54242 + res = -EACCES;
54243 +
54244 out_path_release:
54245 path_put(&path);
54246 if (retry_estale(res, lookup_flags)) {
54247 @@ -419,6 +428,8 @@ retry:
54248 if (error)
54249 goto dput_and_out;
54250
54251 + gr_log_chdir(path.dentry, path.mnt);
54252 +
54253 set_fs_pwd(current->fs, &path);
54254
54255 dput_and_out:
54256 @@ -448,6 +459,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
54257 goto out_putf;
54258
54259 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
54260 +
54261 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
54262 + error = -EPERM;
54263 +
54264 + if (!error)
54265 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
54266 +
54267 if (!error)
54268 set_fs_pwd(current->fs, &f.file->f_path);
54269 out_putf:
54270 @@ -477,7 +495,13 @@ retry:
54271 if (error)
54272 goto dput_and_out;
54273
54274 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
54275 + goto dput_and_out;
54276 +
54277 set_fs_root(current->fs, &path);
54278 +
54279 + gr_handle_chroot_chdir(&path);
54280 +
54281 error = 0;
54282 dput_and_out:
54283 path_put(&path);
54284 @@ -499,6 +523,16 @@ static int chmod_common(struct path *path, umode_t mode)
54285 if (error)
54286 return error;
54287 mutex_lock(&inode->i_mutex);
54288 +
54289 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
54290 + error = -EACCES;
54291 + goto out_unlock;
54292 + }
54293 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
54294 + error = -EACCES;
54295 + goto out_unlock;
54296 + }
54297 +
54298 error = security_path_chmod(path, mode);
54299 if (error)
54300 goto out_unlock;
54301 @@ -559,6 +593,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
54302 uid = make_kuid(current_user_ns(), user);
54303 gid = make_kgid(current_user_ns(), group);
54304
54305 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
54306 + return -EACCES;
54307 +
54308 newattrs.ia_valid = ATTR_CTIME;
54309 if (user != (uid_t) -1) {
54310 if (!uid_valid(uid))
54311 @@ -974,6 +1011,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
54312 } else {
54313 fsnotify_open(f);
54314 fd_install(fd, f);
54315 + trace_do_sys_open(tmp->name, flags, mode);
54316 }
54317 }
54318 putname(tmp);
54319 diff --git a/fs/pipe.c b/fs/pipe.c
54320 index 2234f3f..f9083a1 100644
54321 --- a/fs/pipe.c
54322 +++ b/fs/pipe.c
54323 @@ -438,9 +438,9 @@ redo:
54324 }
54325 if (bufs) /* More to do? */
54326 continue;
54327 - if (!pipe->writers)
54328 + if (!atomic_read(&pipe->writers))
54329 break;
54330 - if (!pipe->waiting_writers) {
54331 + if (!atomic_read(&pipe->waiting_writers)) {
54332 /* syscall merging: Usually we must not sleep
54333 * if O_NONBLOCK is set, or if we got some data.
54334 * But if a writer sleeps in kernel space, then
54335 @@ -504,7 +504,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
54336 mutex_lock(&inode->i_mutex);
54337 pipe = inode->i_pipe;
54338
54339 - if (!pipe->readers) {
54340 + if (!atomic_read(&pipe->readers)) {
54341 send_sig(SIGPIPE, current, 0);
54342 ret = -EPIPE;
54343 goto out;
54344 @@ -553,7 +553,7 @@ redo1:
54345 for (;;) {
54346 int bufs;
54347
54348 - if (!pipe->readers) {
54349 + if (!atomic_read(&pipe->readers)) {
54350 send_sig(SIGPIPE, current, 0);
54351 if (!ret)
54352 ret = -EPIPE;
54353 @@ -644,9 +644,9 @@ redo2:
54354 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54355 do_wakeup = 0;
54356 }
54357 - pipe->waiting_writers++;
54358 + atomic_inc(&pipe->waiting_writers);
54359 pipe_wait(pipe);
54360 - pipe->waiting_writers--;
54361 + atomic_dec(&pipe->waiting_writers);
54362 }
54363 out:
54364 mutex_unlock(&inode->i_mutex);
54365 @@ -716,7 +716,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54366 mask = 0;
54367 if (filp->f_mode & FMODE_READ) {
54368 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
54369 - if (!pipe->writers && filp->f_version != pipe->w_counter)
54370 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
54371 mask |= POLLHUP;
54372 }
54373
54374 @@ -726,7 +726,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54375 * Most Unices do not set POLLERR for FIFOs but on Linux they
54376 * behave exactly like pipes for poll().
54377 */
54378 - if (!pipe->readers)
54379 + if (!atomic_read(&pipe->readers))
54380 mask |= POLLERR;
54381 }
54382
54383 @@ -740,10 +740,10 @@ pipe_release(struct inode *inode, int decr, int decw)
54384
54385 mutex_lock(&inode->i_mutex);
54386 pipe = inode->i_pipe;
54387 - pipe->readers -= decr;
54388 - pipe->writers -= decw;
54389 + atomic_sub(decr, &pipe->readers);
54390 + atomic_sub(decw, &pipe->writers);
54391
54392 - if (!pipe->readers && !pipe->writers) {
54393 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
54394 free_pipe_info(inode);
54395 } else {
54396 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
54397 @@ -833,7 +833,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
54398
54399 if (inode->i_pipe) {
54400 ret = 0;
54401 - inode->i_pipe->readers++;
54402 + atomic_inc(&inode->i_pipe->readers);
54403 }
54404
54405 mutex_unlock(&inode->i_mutex);
54406 @@ -850,7 +850,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
54407
54408 if (inode->i_pipe) {
54409 ret = 0;
54410 - inode->i_pipe->writers++;
54411 + atomic_inc(&inode->i_pipe->writers);
54412 }
54413
54414 mutex_unlock(&inode->i_mutex);
54415 @@ -871,9 +871,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
54416 if (inode->i_pipe) {
54417 ret = 0;
54418 if (filp->f_mode & FMODE_READ)
54419 - inode->i_pipe->readers++;
54420 + atomic_inc(&inode->i_pipe->readers);
54421 if (filp->f_mode & FMODE_WRITE)
54422 - inode->i_pipe->writers++;
54423 + atomic_inc(&inode->i_pipe->writers);
54424 }
54425
54426 mutex_unlock(&inode->i_mutex);
54427 @@ -965,7 +965,7 @@ void free_pipe_info(struct inode *inode)
54428 inode->i_pipe = NULL;
54429 }
54430
54431 -static struct vfsmount *pipe_mnt __read_mostly;
54432 +struct vfsmount *pipe_mnt __read_mostly;
54433
54434 /*
54435 * pipefs_dname() is called from d_path().
54436 @@ -995,7 +995,8 @@ static struct inode * get_pipe_inode(void)
54437 goto fail_iput;
54438 inode->i_pipe = pipe;
54439
54440 - pipe->readers = pipe->writers = 1;
54441 + atomic_set(&pipe->readers, 1);
54442 + atomic_set(&pipe->writers, 1);
54443 inode->i_fop = &rdwr_pipefifo_fops;
54444
54445 /*
54446 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
54447 index 15af622..0e9f4467 100644
54448 --- a/fs/proc/Kconfig
54449 +++ b/fs/proc/Kconfig
54450 @@ -30,12 +30,12 @@ config PROC_FS
54451
54452 config PROC_KCORE
54453 bool "/proc/kcore support" if !ARM
54454 - depends on PROC_FS && MMU
54455 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
54456
54457 config PROC_VMCORE
54458 bool "/proc/vmcore support"
54459 - depends on PROC_FS && CRASH_DUMP
54460 - default y
54461 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
54462 + default n
54463 help
54464 Exports the dump image of crashed kernel in ELF format.
54465
54466 @@ -59,8 +59,8 @@ config PROC_SYSCTL
54467 limited in memory.
54468
54469 config PROC_PAGE_MONITOR
54470 - default y
54471 - depends on PROC_FS && MMU
54472 + default n
54473 + depends on PROC_FS && MMU && !GRKERNSEC
54474 bool "Enable /proc page monitoring" if EXPERT
54475 help
54476 Various /proc files exist to monitor process memory utilization:
54477 diff --git a/fs/proc/array.c b/fs/proc/array.c
54478 index cbd0f1b..adec3f0 100644
54479 --- a/fs/proc/array.c
54480 +++ b/fs/proc/array.c
54481 @@ -60,6 +60,7 @@
54482 #include <linux/tty.h>
54483 #include <linux/string.h>
54484 #include <linux/mman.h>
54485 +#include <linux/grsecurity.h>
54486 #include <linux/proc_fs.h>
54487 #include <linux/ioport.h>
54488 #include <linux/uaccess.h>
54489 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
54490 seq_putc(m, '\n');
54491 }
54492
54493 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54494 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
54495 +{
54496 + if (p->mm)
54497 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
54498 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
54499 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
54500 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
54501 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
54502 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
54503 + else
54504 + seq_printf(m, "PaX:\t-----\n");
54505 +}
54506 +#endif
54507 +
54508 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54509 struct pid *pid, struct task_struct *task)
54510 {
54511 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54512 task_cpus_allowed(m, task);
54513 cpuset_task_status_allowed(m, task);
54514 task_context_switch_counts(m, task);
54515 +
54516 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54517 + task_pax(m, task);
54518 +#endif
54519 +
54520 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
54521 + task_grsec_rbac(m, task);
54522 +#endif
54523 +
54524 return 0;
54525 }
54526
54527 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54528 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54529 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54530 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54531 +#endif
54532 +
54533 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54534 struct pid *pid, struct task_struct *task, int whole)
54535 {
54536 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54537 char tcomm[sizeof(task->comm)];
54538 unsigned long flags;
54539
54540 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54541 + if (current->exec_id != m->exec_id) {
54542 + gr_log_badprocpid("stat");
54543 + return 0;
54544 + }
54545 +#endif
54546 +
54547 state = *get_task_state(task);
54548 vsize = eip = esp = 0;
54549 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54550 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54551 gtime = task_gtime(task);
54552 }
54553
54554 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54555 + if (PAX_RAND_FLAGS(mm)) {
54556 + eip = 0;
54557 + esp = 0;
54558 + wchan = 0;
54559 + }
54560 +#endif
54561 +#ifdef CONFIG_GRKERNSEC_HIDESYM
54562 + wchan = 0;
54563 + eip =0;
54564 + esp =0;
54565 +#endif
54566 +
54567 /* scale priority and nice values from timeslices to -20..20 */
54568 /* to make it look like a "normal" Unix priority/nice value */
54569 priority = task_prio(task);
54570 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54571 seq_put_decimal_ull(m, ' ', vsize);
54572 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
54573 seq_put_decimal_ull(m, ' ', rsslim);
54574 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54575 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
54576 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
54577 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
54578 +#else
54579 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
54580 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
54581 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
54582 +#endif
54583 seq_put_decimal_ull(m, ' ', esp);
54584 seq_put_decimal_ull(m, ' ', eip);
54585 /* The signal information here is obsolete.
54586 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54587 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
54588 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
54589
54590 - if (mm && permitted) {
54591 + if (mm && permitted
54592 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54593 + && !PAX_RAND_FLAGS(mm)
54594 +#endif
54595 + ) {
54596 seq_put_decimal_ull(m, ' ', mm->start_data);
54597 seq_put_decimal_ull(m, ' ', mm->end_data);
54598 seq_put_decimal_ull(m, ' ', mm->start_brk);
54599 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54600 struct pid *pid, struct task_struct *task)
54601 {
54602 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
54603 - struct mm_struct *mm = get_task_mm(task);
54604 + struct mm_struct *mm;
54605
54606 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54607 + if (current->exec_id != m->exec_id) {
54608 + gr_log_badprocpid("statm");
54609 + return 0;
54610 + }
54611 +#endif
54612 + mm = get_task_mm(task);
54613 if (mm) {
54614 size = task_statm(mm, &shared, &text, &data, &resident);
54615 mmput(mm);
54616 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
54617 return 0;
54618 }
54619
54620 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54621 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
54622 +{
54623 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
54624 +}
54625 +#endif
54626 +
54627 #ifdef CONFIG_CHECKPOINT_RESTORE
54628 static struct pid *
54629 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
54630 diff --git a/fs/proc/base.c b/fs/proc/base.c
54631 index 69078c7..3e12a75 100644
54632 --- a/fs/proc/base.c
54633 +++ b/fs/proc/base.c
54634 @@ -112,6 +112,14 @@ struct pid_entry {
54635 union proc_op op;
54636 };
54637
54638 +struct getdents_callback {
54639 + struct linux_dirent __user * current_dir;
54640 + struct linux_dirent __user * previous;
54641 + struct file * file;
54642 + int count;
54643 + int error;
54644 +};
54645 +
54646 #define NOD(NAME, MODE, IOP, FOP, OP) { \
54647 .name = (NAME), \
54648 .len = sizeof(NAME) - 1, \
54649 @@ -209,6 +217,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
54650 if (!mm->arg_end)
54651 goto out_mm; /* Shh! No looking before we're done */
54652
54653 + if (gr_acl_handle_procpidmem(task))
54654 + goto out_mm;
54655 +
54656 len = mm->arg_end - mm->arg_start;
54657
54658 if (len > PAGE_SIZE)
54659 @@ -236,12 +247,28 @@ out:
54660 return res;
54661 }
54662
54663 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54664 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54665 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54666 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54667 +#endif
54668 +
54669 static int proc_pid_auxv(struct task_struct *task, char *buffer)
54670 {
54671 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
54672 int res = PTR_ERR(mm);
54673 if (mm && !IS_ERR(mm)) {
54674 unsigned int nwords = 0;
54675 +
54676 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54677 + /* allow if we're currently ptracing this task */
54678 + if (PAX_RAND_FLAGS(mm) &&
54679 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
54680 + mmput(mm);
54681 + return 0;
54682 + }
54683 +#endif
54684 +
54685 do {
54686 nwords += 2;
54687 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
54688 @@ -255,7 +282,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
54689 }
54690
54691
54692 -#ifdef CONFIG_KALLSYMS
54693 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54694 /*
54695 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
54696 * Returns the resolved symbol. If that fails, simply return the address.
54697 @@ -294,7 +321,7 @@ static void unlock_trace(struct task_struct *task)
54698 mutex_unlock(&task->signal->cred_guard_mutex);
54699 }
54700
54701 -#ifdef CONFIG_STACKTRACE
54702 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54703
54704 #define MAX_STACK_TRACE_DEPTH 64
54705
54706 @@ -486,7 +513,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
54707 return count;
54708 }
54709
54710 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54711 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54712 static int proc_pid_syscall(struct task_struct *task, char *buffer)
54713 {
54714 long nr;
54715 @@ -515,7 +542,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
54716 /************************************************************************/
54717
54718 /* permission checks */
54719 -static int proc_fd_access_allowed(struct inode *inode)
54720 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
54721 {
54722 struct task_struct *task;
54723 int allowed = 0;
54724 @@ -525,7 +552,10 @@ static int proc_fd_access_allowed(struct inode *inode)
54725 */
54726 task = get_proc_task(inode);
54727 if (task) {
54728 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
54729 + if (log)
54730 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
54731 + else
54732 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54733 put_task_struct(task);
54734 }
54735 return allowed;
54736 @@ -556,10 +586,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
54737 struct task_struct *task,
54738 int hide_pid_min)
54739 {
54740 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54741 + return false;
54742 +
54743 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54744 + rcu_read_lock();
54745 + {
54746 + const struct cred *tmpcred = current_cred();
54747 + const struct cred *cred = __task_cred(task);
54748 +
54749 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
54750 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54751 + || in_group_p(grsec_proc_gid)
54752 +#endif
54753 + ) {
54754 + rcu_read_unlock();
54755 + return true;
54756 + }
54757 + }
54758 + rcu_read_unlock();
54759 +
54760 + if (!pid->hide_pid)
54761 + return false;
54762 +#endif
54763 +
54764 if (pid->hide_pid < hide_pid_min)
54765 return true;
54766 if (in_group_p(pid->pid_gid))
54767 return true;
54768 +
54769 return ptrace_may_access(task, PTRACE_MODE_READ);
54770 }
54771
54772 @@ -577,7 +632,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
54773 put_task_struct(task);
54774
54775 if (!has_perms) {
54776 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54777 + {
54778 +#else
54779 if (pid->hide_pid == 2) {
54780 +#endif
54781 /*
54782 * Let's make getdents(), stat(), and open()
54783 * consistent with each other. If a process
54784 @@ -675,6 +734,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
54785 if (!task)
54786 return -ESRCH;
54787
54788 + if (gr_acl_handle_procpidmem(task)) {
54789 + put_task_struct(task);
54790 + return -EPERM;
54791 + }
54792 +
54793 mm = mm_access(task, mode);
54794 put_task_struct(task);
54795
54796 @@ -690,6 +754,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
54797
54798 file->private_data = mm;
54799
54800 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54801 + file->f_version = current->exec_id;
54802 +#endif
54803 +
54804 return 0;
54805 }
54806
54807 @@ -711,6 +779,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
54808 ssize_t copied;
54809 char *page;
54810
54811 +#ifdef CONFIG_GRKERNSEC
54812 + if (write)
54813 + return -EPERM;
54814 +#endif
54815 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54816 + if (file->f_version != current->exec_id) {
54817 + gr_log_badprocpid("mem");
54818 + return 0;
54819 + }
54820 +#endif
54821 +
54822 if (!mm)
54823 return 0;
54824
54825 @@ -723,7 +802,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
54826 goto free;
54827
54828 while (count > 0) {
54829 - int this_len = min_t(int, count, PAGE_SIZE);
54830 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
54831
54832 if (write && copy_from_user(page, buf, this_len)) {
54833 copied = -EFAULT;
54834 @@ -815,6 +894,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
54835 if (!mm)
54836 return 0;
54837
54838 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54839 + if (file->f_version != current->exec_id) {
54840 + gr_log_badprocpid("environ");
54841 + return 0;
54842 + }
54843 +#endif
54844 +
54845 page = (char *)__get_free_page(GFP_TEMPORARY);
54846 if (!page)
54847 return -ENOMEM;
54848 @@ -824,7 +910,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
54849 goto free;
54850 while (count > 0) {
54851 size_t this_len, max_len;
54852 - int retval;
54853 + ssize_t retval;
54854
54855 if (src >= (mm->env_end - mm->env_start))
54856 break;
54857 @@ -1430,7 +1516,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
54858 int error = -EACCES;
54859
54860 /* Are we allowed to snoop on the tasks file descriptors? */
54861 - if (!proc_fd_access_allowed(inode))
54862 + if (!proc_fd_access_allowed(inode, 0))
54863 goto out;
54864
54865 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
54866 @@ -1474,8 +1560,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
54867 struct path path;
54868
54869 /* Are we allowed to snoop on the tasks file descriptors? */
54870 - if (!proc_fd_access_allowed(inode))
54871 - goto out;
54872 + /* logging this is needed for learning on chromium to work properly,
54873 + but we don't want to flood the logs from 'ps' which does a readlink
54874 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
54875 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
54876 + */
54877 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
54878 + if (!proc_fd_access_allowed(inode,0))
54879 + goto out;
54880 + } else {
54881 + if (!proc_fd_access_allowed(inode,1))
54882 + goto out;
54883 + }
54884
54885 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
54886 if (error)
54887 @@ -1525,7 +1621,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
54888 rcu_read_lock();
54889 cred = __task_cred(task);
54890 inode->i_uid = cred->euid;
54891 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54892 + inode->i_gid = grsec_proc_gid;
54893 +#else
54894 inode->i_gid = cred->egid;
54895 +#endif
54896 rcu_read_unlock();
54897 }
54898 security_task_to_inode(task, inode);
54899 @@ -1561,10 +1661,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
54900 return -ENOENT;
54901 }
54902 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
54903 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54904 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
54905 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54906 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
54907 +#endif
54908 task_dumpable(task)) {
54909 cred = __task_cred(task);
54910 stat->uid = cred->euid;
54911 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54912 + stat->gid = grsec_proc_gid;
54913 +#else
54914 stat->gid = cred->egid;
54915 +#endif
54916 }
54917 }
54918 rcu_read_unlock();
54919 @@ -1602,11 +1711,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
54920
54921 if (task) {
54922 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
54923 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54924 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
54925 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54926 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
54927 +#endif
54928 task_dumpable(task)) {
54929 rcu_read_lock();
54930 cred = __task_cred(task);
54931 inode->i_uid = cred->euid;
54932 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
54933 + inode->i_gid = grsec_proc_gid;
54934 +#else
54935 inode->i_gid = cred->egid;
54936 +#endif
54937 rcu_read_unlock();
54938 } else {
54939 inode->i_uid = GLOBAL_ROOT_UID;
54940 @@ -2059,6 +2177,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
54941 if (!task)
54942 goto out_no_task;
54943
54944 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54945 + goto out;
54946 +
54947 /*
54948 * Yes, it does not scale. And it should not. Don't add
54949 * new entries into /proc/<tgid>/ without very good reasons.
54950 @@ -2103,6 +2224,9 @@ static int proc_pident_readdir(struct file *filp,
54951 if (!task)
54952 goto out_no_task;
54953
54954 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
54955 + goto out;
54956 +
54957 ret = 0;
54958 i = filp->f_pos;
54959 switch (i) {
54960 @@ -2516,7 +2640,7 @@ static const struct pid_entry tgid_base_stuff[] = {
54961 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
54962 #endif
54963 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
54964 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
54965 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
54966 INF("syscall", S_IRUGO, proc_pid_syscall),
54967 #endif
54968 INF("cmdline", S_IRUGO, proc_pid_cmdline),
54969 @@ -2541,10 +2665,10 @@ static const struct pid_entry tgid_base_stuff[] = {
54970 #ifdef CONFIG_SECURITY
54971 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
54972 #endif
54973 -#ifdef CONFIG_KALLSYMS
54974 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54975 INF("wchan", S_IRUGO, proc_pid_wchan),
54976 #endif
54977 -#ifdef CONFIG_STACKTRACE
54978 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
54979 ONE("stack", S_IRUGO, proc_pid_stack),
54980 #endif
54981 #ifdef CONFIG_SCHEDSTATS
54982 @@ -2578,6 +2702,9 @@ static const struct pid_entry tgid_base_stuff[] = {
54983 #ifdef CONFIG_HARDWALL
54984 INF("hardwall", S_IRUGO, proc_pid_hardwall),
54985 #endif
54986 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
54987 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
54988 +#endif
54989 #ifdef CONFIG_USER_NS
54990 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
54991 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
54992 @@ -2707,7 +2834,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
54993 if (!inode)
54994 goto out;
54995
54996 +#ifdef CONFIG_GRKERNSEC_PROC_USER
54997 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
54998 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
54999 + inode->i_gid = grsec_proc_gid;
55000 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
55001 +#else
55002 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
55003 +#endif
55004 inode->i_op = &proc_tgid_base_inode_operations;
55005 inode->i_fop = &proc_tgid_base_operations;
55006 inode->i_flags|=S_IMMUTABLE;
55007 @@ -2745,7 +2879,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
55008 if (!task)
55009 goto out;
55010
55011 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55012 + goto out_put_task;
55013 +
55014 result = proc_pid_instantiate(dir, dentry, task, NULL);
55015 +out_put_task:
55016 put_task_struct(task);
55017 out:
55018 return result;
55019 @@ -2808,6 +2946,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
55020 static int fake_filldir(void *buf, const char *name, int namelen,
55021 loff_t offset, u64 ino, unsigned d_type)
55022 {
55023 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
55024 + __buf->error = -EINVAL;
55025 return 0;
55026 }
55027
55028 @@ -2859,7 +2999,7 @@ static const struct pid_entry tid_base_stuff[] = {
55029 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
55030 #endif
55031 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55032 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55033 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55034 INF("syscall", S_IRUGO, proc_pid_syscall),
55035 #endif
55036 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55037 @@ -2886,10 +3026,10 @@ static const struct pid_entry tid_base_stuff[] = {
55038 #ifdef CONFIG_SECURITY
55039 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55040 #endif
55041 -#ifdef CONFIG_KALLSYMS
55042 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55043 INF("wchan", S_IRUGO, proc_pid_wchan),
55044 #endif
55045 -#ifdef CONFIG_STACKTRACE
55046 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55047 ONE("stack", S_IRUGO, proc_pid_stack),
55048 #endif
55049 #ifdef CONFIG_SCHEDSTATS
55050 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
55051 index 82676e3..5f8518a 100644
55052 --- a/fs/proc/cmdline.c
55053 +++ b/fs/proc/cmdline.c
55054 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
55055
55056 static int __init proc_cmdline_init(void)
55057 {
55058 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55059 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
55060 +#else
55061 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
55062 +#endif
55063 return 0;
55064 }
55065 module_init(proc_cmdline_init);
55066 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
55067 index b143471..bb105e5 100644
55068 --- a/fs/proc/devices.c
55069 +++ b/fs/proc/devices.c
55070 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
55071
55072 static int __init proc_devices_init(void)
55073 {
55074 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55075 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
55076 +#else
55077 proc_create("devices", 0, NULL, &proc_devinfo_operations);
55078 +#endif
55079 return 0;
55080 }
55081 module_init(proc_devices_init);
55082 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
55083 index d7a4a28..0201742 100644
55084 --- a/fs/proc/fd.c
55085 +++ b/fs/proc/fd.c
55086 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
55087 if (!task)
55088 return -ENOENT;
55089
55090 - files = get_files_struct(task);
55091 + if (!gr_acl_handle_procpidmem(task))
55092 + files = get_files_struct(task);
55093 put_task_struct(task);
55094
55095 if (files) {
55096 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
55097 */
55098 int proc_fd_permission(struct inode *inode, int mask)
55099 {
55100 + struct task_struct *task;
55101 int rv = generic_permission(inode, mask);
55102 - if (rv == 0)
55103 - return 0;
55104 +
55105 if (task_pid(current) == proc_pid(inode))
55106 rv = 0;
55107 +
55108 + task = get_proc_task(inode);
55109 + if (task == NULL)
55110 + return rv;
55111 +
55112 + if (gr_acl_handle_procpidmem(task))
55113 + rv = -EACCES;
55114 +
55115 + put_task_struct(task);
55116 +
55117 return rv;
55118 }
55119
55120 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
55121 index 869116c..820cb27 100644
55122 --- a/fs/proc/inode.c
55123 +++ b/fs/proc/inode.c
55124 @@ -22,11 +22,17 @@
55125 #include <linux/seq_file.h>
55126 #include <linux/slab.h>
55127 #include <linux/mount.h>
55128 +#include <linux/grsecurity.h>
55129
55130 #include <asm/uaccess.h>
55131
55132 #include "internal.h"
55133
55134 +#ifdef CONFIG_PROC_SYSCTL
55135 +extern const struct inode_operations proc_sys_inode_operations;
55136 +extern const struct inode_operations proc_sys_dir_operations;
55137 +#endif
55138 +
55139 static void proc_evict_inode(struct inode *inode)
55140 {
55141 struct proc_dir_entry *de;
55142 @@ -54,6 +60,13 @@ static void proc_evict_inode(struct inode *inode)
55143 ns = PROC_I(inode)->ns;
55144 if (ns_ops && ns)
55145 ns_ops->put(ns);
55146 +
55147 +#ifdef CONFIG_PROC_SYSCTL
55148 + if (inode->i_op == &proc_sys_inode_operations ||
55149 + inode->i_op == &proc_sys_dir_operations)
55150 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
55151 +#endif
55152 +
55153 }
55154
55155 static struct kmem_cache * proc_inode_cachep;
55156 @@ -456,7 +469,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
55157 if (de->mode) {
55158 inode->i_mode = de->mode;
55159 inode->i_uid = de->uid;
55160 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55161 + inode->i_gid = grsec_proc_gid;
55162 +#else
55163 inode->i_gid = de->gid;
55164 +#endif
55165 }
55166 if (de->size)
55167 inode->i_size = de->size;
55168 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
55169 index 85ff3a4..a512bd8 100644
55170 --- a/fs/proc/internal.h
55171 +++ b/fs/proc/internal.h
55172 @@ -56,6 +56,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55173 struct pid *pid, struct task_struct *task);
55174 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55175 struct pid *pid, struct task_struct *task);
55176 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55177 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
55178 +#endif
55179 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
55180
55181 extern const struct file_operations proc_tid_children_operations;
55182 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
55183 index eda6f01..006ae24 100644
55184 --- a/fs/proc/kcore.c
55185 +++ b/fs/proc/kcore.c
55186 @@ -481,9 +481,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55187 * the addresses in the elf_phdr on our list.
55188 */
55189 start = kc_offset_to_vaddr(*fpos - elf_buflen);
55190 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
55191 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
55192 + if (tsz > buflen)
55193 tsz = buflen;
55194 -
55195 +
55196 while (buflen) {
55197 struct kcore_list *m;
55198
55199 @@ -512,20 +513,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55200 kfree(elf_buf);
55201 } else {
55202 if (kern_addr_valid(start)) {
55203 - unsigned long n;
55204 + char *elf_buf;
55205 + mm_segment_t oldfs;
55206
55207 - n = copy_to_user(buffer, (char *)start, tsz);
55208 - /*
55209 - * We cannot distinguish between fault on source
55210 - * and fault on destination. When this happens
55211 - * we clear too and hope it will trigger the
55212 - * EFAULT again.
55213 - */
55214 - if (n) {
55215 - if (clear_user(buffer + tsz - n,
55216 - n))
55217 + elf_buf = kmalloc(tsz, GFP_KERNEL);
55218 + if (!elf_buf)
55219 + return -ENOMEM;
55220 + oldfs = get_fs();
55221 + set_fs(KERNEL_DS);
55222 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
55223 + set_fs(oldfs);
55224 + if (copy_to_user(buffer, elf_buf, tsz)) {
55225 + kfree(elf_buf);
55226 return -EFAULT;
55227 + }
55228 }
55229 + set_fs(oldfs);
55230 + kfree(elf_buf);
55231 } else {
55232 if (clear_user(buffer, tsz))
55233 return -EFAULT;
55234 @@ -545,6 +549,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55235
55236 static int open_kcore(struct inode *inode, struct file *filp)
55237 {
55238 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
55239 + return -EPERM;
55240 +#endif
55241 if (!capable(CAP_SYS_RAWIO))
55242 return -EPERM;
55243 if (kcore_need_update)
55244 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
55245 index 1efaaa1..834e49a 100644
55246 --- a/fs/proc/meminfo.c
55247 +++ b/fs/proc/meminfo.c
55248 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
55249 vmi.used >> 10,
55250 vmi.largest_chunk >> 10
55251 #ifdef CONFIG_MEMORY_FAILURE
55252 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
55253 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
55254 #endif
55255 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
55256 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
55257 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
55258 index ccfd99b..1b7e255 100644
55259 --- a/fs/proc/nommu.c
55260 +++ b/fs/proc/nommu.c
55261 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
55262 if (len < 1)
55263 len = 1;
55264 seq_printf(m, "%*c", len, ' ');
55265 - seq_path(m, &file->f_path, "");
55266 + seq_path(m, &file->f_path, "\n\\");
55267 }
55268
55269 seq_putc(m, '\n');
55270 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
55271 index b4ac657..0842bd2 100644
55272 --- a/fs/proc/proc_net.c
55273 +++ b/fs/proc/proc_net.c
55274 @@ -23,6 +23,7 @@
55275 #include <linux/nsproxy.h>
55276 #include <net/net_namespace.h>
55277 #include <linux/seq_file.h>
55278 +#include <linux/grsecurity.h>
55279
55280 #include "internal.h"
55281
55282 @@ -105,6 +106,17 @@ static struct net *get_proc_task_net(struct inode *dir)
55283 struct task_struct *task;
55284 struct nsproxy *ns;
55285 struct net *net = NULL;
55286 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55287 + const struct cred *cred = current_cred();
55288 +#endif
55289 +
55290 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55291 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
55292 + return net;
55293 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55294 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
55295 + return net;
55296 +#endif
55297
55298 rcu_read_lock();
55299 task = pid_task(proc_pid(dir), PIDTYPE_PID);
55300 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
55301 index ac05f33..1e6dc7e 100644
55302 --- a/fs/proc/proc_sysctl.c
55303 +++ b/fs/proc/proc_sysctl.c
55304 @@ -13,11 +13,15 @@
55305 #include <linux/module.h>
55306 #include "internal.h"
55307
55308 +extern int gr_handle_chroot_sysctl(const int op);
55309 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
55310 + const int op);
55311 +
55312 static const struct dentry_operations proc_sys_dentry_operations;
55313 static const struct file_operations proc_sys_file_operations;
55314 -static const struct inode_operations proc_sys_inode_operations;
55315 +const struct inode_operations proc_sys_inode_operations;
55316 static const struct file_operations proc_sys_dir_file_operations;
55317 -static const struct inode_operations proc_sys_dir_operations;
55318 +const struct inode_operations proc_sys_dir_operations;
55319
55320 void proc_sys_poll_notify(struct ctl_table_poll *poll)
55321 {
55322 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
55323
55324 err = NULL;
55325 d_set_d_op(dentry, &proc_sys_dentry_operations);
55326 +
55327 + gr_handle_proc_create(dentry, inode);
55328 +
55329 d_add(dentry, inode);
55330
55331 out:
55332 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55333 struct inode *inode = file_inode(filp);
55334 struct ctl_table_header *head = grab_header(inode);
55335 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
55336 + int op = write ? MAY_WRITE : MAY_READ;
55337 ssize_t error;
55338 size_t res;
55339
55340 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55341 * and won't be until we finish.
55342 */
55343 error = -EPERM;
55344 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
55345 + if (sysctl_perm(head, table, op))
55346 goto out;
55347
55348 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
55349 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55350 if (!table->proc_handler)
55351 goto out;
55352
55353 +#ifdef CONFIG_GRKERNSEC
55354 + error = -EPERM;
55355 + if (gr_handle_chroot_sysctl(op))
55356 + goto out;
55357 + dget(filp->f_path.dentry);
55358 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
55359 + dput(filp->f_path.dentry);
55360 + goto out;
55361 + }
55362 + dput(filp->f_path.dentry);
55363 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
55364 + goto out;
55365 + if (write && !capable(CAP_SYS_ADMIN))
55366 + goto out;
55367 +#endif
55368 +
55369 /* careful: calling conventions are nasty here */
55370 res = count;
55371 error = table->proc_handler(table, write, buf, &res, ppos);
55372 @@ -598,6 +622,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
55373 return -ENOMEM;
55374 } else {
55375 d_set_d_op(child, &proc_sys_dentry_operations);
55376 +
55377 + gr_handle_proc_create(child, inode);
55378 +
55379 d_add(child, inode);
55380 }
55381 } else {
55382 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
55383 if ((*pos)++ < file->f_pos)
55384 return 0;
55385
55386 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
55387 + return 0;
55388 +
55389 if (unlikely(S_ISLNK(table->mode)))
55390 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
55391 else
55392 @@ -751,6 +781,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
55393 if (IS_ERR(head))
55394 return PTR_ERR(head);
55395
55396 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
55397 + return -ENOENT;
55398 +
55399 generic_fillattr(inode, stat);
55400 if (table)
55401 stat->mode = (stat->mode & S_IFMT) | table->mode;
55402 @@ -773,13 +806,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
55403 .llseek = generic_file_llseek,
55404 };
55405
55406 -static const struct inode_operations proc_sys_inode_operations = {
55407 +const struct inode_operations proc_sys_inode_operations = {
55408 .permission = proc_sys_permission,
55409 .setattr = proc_sys_setattr,
55410 .getattr = proc_sys_getattr,
55411 };
55412
55413 -static const struct inode_operations proc_sys_dir_operations = {
55414 +const struct inode_operations proc_sys_dir_operations = {
55415 .lookup = proc_sys_lookup,
55416 .permission = proc_sys_permission,
55417 .setattr = proc_sys_setattr,
55418 @@ -855,7 +888,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
55419 static struct ctl_dir *new_dir(struct ctl_table_set *set,
55420 const char *name, int namelen)
55421 {
55422 - struct ctl_table *table;
55423 + ctl_table_no_const *table;
55424 struct ctl_dir *new;
55425 struct ctl_node *node;
55426 char *new_name;
55427 @@ -867,7 +900,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
55428 return NULL;
55429
55430 node = (struct ctl_node *)(new + 1);
55431 - table = (struct ctl_table *)(node + 1);
55432 + table = (ctl_table_no_const *)(node + 1);
55433 new_name = (char *)(table + 2);
55434 memcpy(new_name, name, namelen);
55435 new_name[namelen] = '\0';
55436 @@ -1036,7 +1069,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
55437 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
55438 struct ctl_table_root *link_root)
55439 {
55440 - struct ctl_table *link_table, *entry, *link;
55441 + ctl_table_no_const *link_table, *link;
55442 + struct ctl_table *entry;
55443 struct ctl_table_header *links;
55444 struct ctl_node *node;
55445 char *link_name;
55446 @@ -1059,7 +1093,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
55447 return NULL;
55448
55449 node = (struct ctl_node *)(links + 1);
55450 - link_table = (struct ctl_table *)(node + nr_entries);
55451 + link_table = (ctl_table_no_const *)(node + nr_entries);
55452 link_name = (char *)&link_table[nr_entries + 1];
55453
55454 for (link = link_table, entry = table; entry->procname; link++, entry++) {
55455 @@ -1307,8 +1341,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55456 struct ctl_table_header ***subheader, struct ctl_table_set *set,
55457 struct ctl_table *table)
55458 {
55459 - struct ctl_table *ctl_table_arg = NULL;
55460 - struct ctl_table *entry, *files;
55461 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
55462 + struct ctl_table *entry;
55463 int nr_files = 0;
55464 int nr_dirs = 0;
55465 int err = -ENOMEM;
55466 @@ -1320,10 +1354,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55467 nr_files++;
55468 }
55469
55470 - files = table;
55471 /* If there are mixed files and directories we need a new table */
55472 if (nr_dirs && nr_files) {
55473 - struct ctl_table *new;
55474 + ctl_table_no_const *new;
55475 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
55476 GFP_KERNEL);
55477 if (!files)
55478 @@ -1341,7 +1374,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55479 /* Register everything except a directory full of subdirectories */
55480 if (nr_files || !nr_dirs) {
55481 struct ctl_table_header *header;
55482 - header = __register_sysctl_table(set, path, files);
55483 + header = __register_sysctl_table(set, path, files ? files : table);
55484 if (!header) {
55485 kfree(ctl_table_arg);
55486 goto out;
55487 diff --git a/fs/proc/root.c b/fs/proc/root.c
55488 index 9c7fab1..ed1c8e0 100644
55489 --- a/fs/proc/root.c
55490 +++ b/fs/proc/root.c
55491 @@ -180,7 +180,15 @@ void __init proc_root_init(void)
55492 #ifdef CONFIG_PROC_DEVICETREE
55493 proc_device_tree_init();
55494 #endif
55495 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55496 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55497 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
55498 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55499 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
55500 +#endif
55501 +#else
55502 proc_mkdir("bus", NULL);
55503 +#endif
55504 proc_sys_init();
55505 }
55506
55507 diff --git a/fs/proc/self.c b/fs/proc/self.c
55508 index aa5cc3b..c91a5d0 100644
55509 --- a/fs/proc/self.c
55510 +++ b/fs/proc/self.c
55511 @@ -37,7 +37,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
55512 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
55513 void *cookie)
55514 {
55515 - char *s = nd_get_link(nd);
55516 + const char *s = nd_get_link(nd);
55517 if (!IS_ERR(s))
55518 kfree(s);
55519 }
55520 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
55521 index 3e636d8..83e3b71 100644
55522 --- a/fs/proc/task_mmu.c
55523 +++ b/fs/proc/task_mmu.c
55524 @@ -11,12 +11,19 @@
55525 #include <linux/rmap.h>
55526 #include <linux/swap.h>
55527 #include <linux/swapops.h>
55528 +#include <linux/grsecurity.h>
55529
55530 #include <asm/elf.h>
55531 #include <asm/uaccess.h>
55532 #include <asm/tlbflush.h>
55533 #include "internal.h"
55534
55535 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55536 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55537 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55538 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55539 +#endif
55540 +
55541 void task_mem(struct seq_file *m, struct mm_struct *mm)
55542 {
55543 unsigned long data, text, lib, swap;
55544 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55545 "VmExe:\t%8lu kB\n"
55546 "VmLib:\t%8lu kB\n"
55547 "VmPTE:\t%8lu kB\n"
55548 - "VmSwap:\t%8lu kB\n",
55549 - hiwater_vm << (PAGE_SHIFT-10),
55550 + "VmSwap:\t%8lu kB\n"
55551 +
55552 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55553 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
55554 +#endif
55555 +
55556 + ,hiwater_vm << (PAGE_SHIFT-10),
55557 total_vm << (PAGE_SHIFT-10),
55558 mm->locked_vm << (PAGE_SHIFT-10),
55559 mm->pinned_vm << (PAGE_SHIFT-10),
55560 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55561 data << (PAGE_SHIFT-10),
55562 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
55563 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
55564 - swap << (PAGE_SHIFT-10));
55565 + swap << (PAGE_SHIFT-10)
55566 +
55567 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55568 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55569 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
55570 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
55571 +#else
55572 + , mm->context.user_cs_base
55573 + , mm->context.user_cs_limit
55574 +#endif
55575 +#endif
55576 +
55577 + );
55578 }
55579
55580 unsigned long task_vsize(struct mm_struct *mm)
55581 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55582 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
55583 }
55584
55585 - /* We don't show the stack guard page in /proc/maps */
55586 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55587 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
55588 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
55589 +#else
55590 start = vma->vm_start;
55591 - if (stack_guard_page_start(vma, start))
55592 - start += PAGE_SIZE;
55593 end = vma->vm_end;
55594 - if (stack_guard_page_end(vma, end))
55595 - end -= PAGE_SIZE;
55596 +#endif
55597
55598 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
55599 start,
55600 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55601 flags & VM_WRITE ? 'w' : '-',
55602 flags & VM_EXEC ? 'x' : '-',
55603 flags & VM_MAYSHARE ? 's' : 'p',
55604 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55605 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
55606 +#else
55607 pgoff,
55608 +#endif
55609 MAJOR(dev), MINOR(dev), ino, &len);
55610
55611 /*
55612 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55613 */
55614 if (file) {
55615 pad_len_spaces(m, len);
55616 - seq_path(m, &file->f_path, "\n");
55617 + seq_path(m, &file->f_path, "\n\\");
55618 goto done;
55619 }
55620
55621 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55622 * Thread stack in /proc/PID/task/TID/maps or
55623 * the main process stack.
55624 */
55625 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
55626 - vma->vm_end >= mm->start_stack)) {
55627 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
55628 + (vma->vm_start <= mm->start_stack &&
55629 + vma->vm_end >= mm->start_stack)) {
55630 name = "[stack]";
55631 } else {
55632 /* Thread stack in /proc/PID/maps */
55633 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
55634 struct proc_maps_private *priv = m->private;
55635 struct task_struct *task = priv->task;
55636
55637 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55638 + if (current->exec_id != m->exec_id) {
55639 + gr_log_badprocpid("maps");
55640 + return 0;
55641 + }
55642 +#endif
55643 +
55644 show_map_vma(m, vma, is_pid);
55645
55646 if (m->count < m->size) /* vma is copied successfully */
55647 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
55648 .private = &mss,
55649 };
55650
55651 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55652 + if (current->exec_id != m->exec_id) {
55653 + gr_log_badprocpid("smaps");
55654 + return 0;
55655 + }
55656 +#endif
55657 memset(&mss, 0, sizeof mss);
55658 - mss.vma = vma;
55659 - /* mmap_sem is held in m_start */
55660 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
55661 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
55662 -
55663 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55664 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
55665 +#endif
55666 + mss.vma = vma;
55667 + /* mmap_sem is held in m_start */
55668 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
55669 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
55670 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55671 + }
55672 +#endif
55673 show_map_vma(m, vma, is_pid);
55674
55675 seq_printf(m,
55676 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
55677 "KernelPageSize: %8lu kB\n"
55678 "MMUPageSize: %8lu kB\n"
55679 "Locked: %8lu kB\n",
55680 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55681 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
55682 +#else
55683 (vma->vm_end - vma->vm_start) >> 10,
55684 +#endif
55685 mss.resident >> 10,
55686 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
55687 mss.shared_clean >> 10,
55688 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
55689 int n;
55690 char buffer[50];
55691
55692 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55693 + if (current->exec_id != m->exec_id) {
55694 + gr_log_badprocpid("numa_maps");
55695 + return 0;
55696 + }
55697 +#endif
55698 +
55699 if (!mm)
55700 return 0;
55701
55702 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
55703 mpol_to_str(buffer, sizeof(buffer), pol);
55704 mpol_cond_put(pol);
55705
55706 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55707 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
55708 +#else
55709 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
55710 +#endif
55711
55712 if (file) {
55713 seq_printf(m, " file=");
55714 - seq_path(m, &file->f_path, "\n\t= ");
55715 + seq_path(m, &file->f_path, "\n\t\\= ");
55716 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
55717 seq_printf(m, " heap");
55718 } else {
55719 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
55720 index 56123a6..5a2f6ec 100644
55721 --- a/fs/proc/task_nommu.c
55722 +++ b/fs/proc/task_nommu.c
55723 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55724 else
55725 bytes += kobjsize(mm);
55726
55727 - if (current->fs && current->fs->users > 1)
55728 + if (current->fs && atomic_read(&current->fs->users) > 1)
55729 sbytes += kobjsize(current->fs);
55730 else
55731 bytes += kobjsize(current->fs);
55732 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
55733
55734 if (file) {
55735 pad_len_spaces(m, len);
55736 - seq_path(m, &file->f_path, "");
55737 + seq_path(m, &file->f_path, "\n\\");
55738 } else if (mm) {
55739 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
55740
55741 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
55742 index b870f74..e9048df 100644
55743 --- a/fs/proc/vmcore.c
55744 +++ b/fs/proc/vmcore.c
55745 @@ -98,9 +98,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
55746 nr_bytes = count;
55747
55748 /* If pfn is not ram, return zeros for sparse dump files */
55749 - if (pfn_is_ram(pfn) == 0)
55750 - memset(buf, 0, nr_bytes);
55751 - else {
55752 + if (pfn_is_ram(pfn) == 0) {
55753 + if (userbuf) {
55754 + if (clear_user((char __force_user *)buf, nr_bytes))
55755 + return -EFAULT;
55756 + } else
55757 + memset(buf, 0, nr_bytes);
55758 + } else {
55759 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
55760 offset, userbuf);
55761 if (tmp < 0)
55762 @@ -185,7 +189,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
55763 if (tsz > nr_bytes)
55764 tsz = nr_bytes;
55765
55766 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
55767 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
55768 if (tmp < 0)
55769 return tmp;
55770 buflen -= tsz;
55771 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
55772 index b00fcc9..e0c6381 100644
55773 --- a/fs/qnx6/qnx6.h
55774 +++ b/fs/qnx6/qnx6.h
55775 @@ -74,7 +74,7 @@ enum {
55776 BYTESEX_BE,
55777 };
55778
55779 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
55780 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
55781 {
55782 if (sbi->s_bytesex == BYTESEX_LE)
55783 return le64_to_cpu((__force __le64)n);
55784 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
55785 return (__force __fs64)cpu_to_be64(n);
55786 }
55787
55788 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
55789 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
55790 {
55791 if (sbi->s_bytesex == BYTESEX_LE)
55792 return le32_to_cpu((__force __le32)n);
55793 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
55794 index 16e8abb..2dcf914 100644
55795 --- a/fs/quota/netlink.c
55796 +++ b/fs/quota/netlink.c
55797 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
55798 void quota_send_warning(struct kqid qid, dev_t dev,
55799 const char warntype)
55800 {
55801 - static atomic_t seq;
55802 + static atomic_unchecked_t seq;
55803 struct sk_buff *skb;
55804 void *msg_head;
55805 int ret;
55806 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
55807 "VFS: Not enough memory to send quota warning.\n");
55808 return;
55809 }
55810 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
55811 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
55812 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
55813 if (!msg_head) {
55814 printk(KERN_ERR
55815 diff --git a/fs/read_write.c b/fs/read_write.c
55816 index e6ddc8d..9155227 100644
55817 --- a/fs/read_write.c
55818 +++ b/fs/read_write.c
55819 @@ -429,7 +429,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
55820
55821 old_fs = get_fs();
55822 set_fs(get_ds());
55823 - p = (__force const char __user *)buf;
55824 + p = (const char __force_user *)buf;
55825 if (count > MAX_RW_COUNT)
55826 count = MAX_RW_COUNT;
55827 if (file->f_op->write)
55828 diff --git a/fs/readdir.c b/fs/readdir.c
55829 index fee38e0..12fdf47 100644
55830 --- a/fs/readdir.c
55831 +++ b/fs/readdir.c
55832 @@ -17,6 +17,7 @@
55833 #include <linux/security.h>
55834 #include <linux/syscalls.h>
55835 #include <linux/unistd.h>
55836 +#include <linux/namei.h>
55837
55838 #include <asm/uaccess.h>
55839
55840 @@ -67,6 +68,7 @@ struct old_linux_dirent {
55841
55842 struct readdir_callback {
55843 struct old_linux_dirent __user * dirent;
55844 + struct file * file;
55845 int result;
55846 };
55847
55848 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
55849 buf->result = -EOVERFLOW;
55850 return -EOVERFLOW;
55851 }
55852 +
55853 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55854 + return 0;
55855 +
55856 buf->result++;
55857 dirent = buf->dirent;
55858 if (!access_ok(VERIFY_WRITE, dirent,
55859 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
55860
55861 buf.result = 0;
55862 buf.dirent = dirent;
55863 + buf.file = f.file;
55864
55865 error = vfs_readdir(f.file, fillonedir, &buf);
55866 if (buf.result)
55867 @@ -139,6 +146,7 @@ struct linux_dirent {
55868 struct getdents_callback {
55869 struct linux_dirent __user * current_dir;
55870 struct linux_dirent __user * previous;
55871 + struct file * file;
55872 int count;
55873 int error;
55874 };
55875 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
55876 buf->error = -EOVERFLOW;
55877 return -EOVERFLOW;
55878 }
55879 +
55880 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55881 + return 0;
55882 +
55883 dirent = buf->previous;
55884 if (dirent) {
55885 if (__put_user(offset, &dirent->d_off))
55886 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
55887 buf.previous = NULL;
55888 buf.count = count;
55889 buf.error = 0;
55890 + buf.file = f.file;
55891
55892 error = vfs_readdir(f.file, filldir, &buf);
55893 if (error >= 0)
55894 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
55895 struct getdents_callback64 {
55896 struct linux_dirent64 __user * current_dir;
55897 struct linux_dirent64 __user * previous;
55898 + struct file *file;
55899 int count;
55900 int error;
55901 };
55902 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
55903 buf->error = -EINVAL; /* only used if we fail.. */
55904 if (reclen > buf->count)
55905 return -EINVAL;
55906 +
55907 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55908 + return 0;
55909 +
55910 dirent = buf->previous;
55911 if (dirent) {
55912 if (__put_user(offset, &dirent->d_off))
55913 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
55914
55915 buf.current_dir = dirent;
55916 buf.previous = NULL;
55917 + buf.file = f.file;
55918 buf.count = count;
55919 buf.error = 0;
55920
55921 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
55922 error = buf.error;
55923 lastdirent = buf.previous;
55924 if (lastdirent) {
55925 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
55926 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
55927 if (__put_user(d_off, &lastdirent->d_off))
55928 error = -EFAULT;
55929 else
55930 diff --git a/fs/reiserfs/dir.c b/fs/reiserfs/dir.c
55931 index 66c53b6..6c2d136 100644
55932 --- a/fs/reiserfs/dir.c
55933 +++ b/fs/reiserfs/dir.c
55934 @@ -204,6 +204,8 @@ int reiserfs_readdir_dentry(struct dentry *dentry, void *dirent,
55935 next_pos = deh_offset(deh) + 1;
55936
55937 if (item_moved(&tmp_ih, &path_to_entry)) {
55938 + set_cpu_key_k_offset(&pos_key,
55939 + next_pos);
55940 goto research;
55941 }
55942 } /* for */
55943 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
55944 index 2b7882b..1c5ef48 100644
55945 --- a/fs/reiserfs/do_balan.c
55946 +++ b/fs/reiserfs/do_balan.c
55947 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
55948 return;
55949 }
55950
55951 - atomic_inc(&(fs_generation(tb->tb_sb)));
55952 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
55953 do_balance_starts(tb);
55954
55955 /* balance leaf returns 0 except if combining L R and S into
55956 diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
55957 index ea5061f..c3a9de6 100644
55958 --- a/fs/reiserfs/inode.c
55959 +++ b/fs/reiserfs/inode.c
55960 @@ -1810,11 +1810,16 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
55961 TYPE_STAT_DATA, SD_SIZE, MAX_US_INT);
55962 memcpy(INODE_PKEY(inode), &(ih.ih_key), KEY_SIZE);
55963 args.dirid = le32_to_cpu(ih.ih_key.k_dir_id);
55964 - if (insert_inode_locked4(inode, args.objectid,
55965 - reiserfs_find_actor, &args) < 0) {
55966 +
55967 + reiserfs_write_unlock(inode->i_sb);
55968 + err = insert_inode_locked4(inode, args.objectid,
55969 + reiserfs_find_actor, &args);
55970 + reiserfs_write_lock(inode->i_sb);
55971 + if (err) {
55972 err = -EINVAL;
55973 goto out_bad_inode;
55974 }
55975 +
55976 if (old_format_only(sb))
55977 /* not a perfect generation count, as object ids can be reused, but
55978 ** this is as good as reiserfs can do right now.
55979 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
55980 index 9cc0740a..46bf953 100644
55981 --- a/fs/reiserfs/procfs.c
55982 +++ b/fs/reiserfs/procfs.c
55983 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
55984 "SMALL_TAILS " : "NO_TAILS ",
55985 replay_only(sb) ? "REPLAY_ONLY " : "",
55986 convert_reiserfs(sb) ? "CONV " : "",
55987 - atomic_read(&r->s_generation_counter),
55988 + atomic_read_unchecked(&r->s_generation_counter),
55989 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
55990 SF(s_do_balance), SF(s_unneeded_left_neighbor),
55991 SF(s_good_search_by_key_reada), SF(s_bmaps),
55992 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
55993 index 157e474..65a6114 100644
55994 --- a/fs/reiserfs/reiserfs.h
55995 +++ b/fs/reiserfs/reiserfs.h
55996 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
55997 /* Comment? -Hans */
55998 wait_queue_head_t s_wait;
55999 /* To be obsoleted soon by per buffer seals.. -Hans */
56000 - atomic_t s_generation_counter; // increased by one every time the
56001 + atomic_unchecked_t s_generation_counter; // increased by one every time the
56002 // tree gets re-balanced
56003 unsigned long s_properties; /* File system properties. Currently holds
56004 on-disk FS format */
56005 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
56006 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
56007
56008 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
56009 -#define get_generation(s) atomic_read (&fs_generation(s))
56010 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
56011 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
56012 #define __fs_changed(gen,s) (gen != get_generation (s))
56013 #define fs_changed(gen,s) \
56014 diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
56015 index 4cce1d9..821bcf7 100644
56016 --- a/fs/reiserfs/xattr.c
56017 +++ b/fs/reiserfs/xattr.c
56018 @@ -318,7 +318,19 @@ static int delete_one_xattr(struct dentry *dentry, void *data)
56019 static int chown_one_xattr(struct dentry *dentry, void *data)
56020 {
56021 struct iattr *attrs = data;
56022 - return reiserfs_setattr(dentry, attrs);
56023 + int ia_valid = attrs->ia_valid;
56024 + int err;
56025 +
56026 + /*
56027 + * We only want the ownership bits. Otherwise, we'll do
56028 + * things like change a directory to a regular file if
56029 + * ATTR_MODE is set.
56030 + */
56031 + attrs->ia_valid &= (ATTR_UID|ATTR_GID);
56032 + err = reiserfs_setattr(dentry, attrs);
56033 + attrs->ia_valid = ia_valid;
56034 +
56035 + return err;
56036 }
56037
56038 /* No i_mutex, but the inode is unconnected. */
56039 diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c
56040 index d7c01ef..6c8767f 100644
56041 --- a/fs/reiserfs/xattr_acl.c
56042 +++ b/fs/reiserfs/xattr_acl.c
56043 @@ -443,6 +443,9 @@ int reiserfs_acl_chmod(struct inode *inode)
56044 int depth;
56045 int error;
56046
56047 + if (IS_PRIVATE(inode))
56048 + return 0;
56049 +
56050 if (S_ISLNK(inode->i_mode))
56051 return -EOPNOTSUPP;
56052
56053 diff --git a/fs/select.c b/fs/select.c
56054 index 8c1c96c..a0f9b6d 100644
56055 --- a/fs/select.c
56056 +++ b/fs/select.c
56057 @@ -20,6 +20,7 @@
56058 #include <linux/export.h>
56059 #include <linux/slab.h>
56060 #include <linux/poll.h>
56061 +#include <linux/security.h>
56062 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
56063 #include <linux/file.h>
56064 #include <linux/fdtable.h>
56065 @@ -827,6 +828,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
56066 struct poll_list *walk = head;
56067 unsigned long todo = nfds;
56068
56069 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
56070 if (nfds > rlimit(RLIMIT_NOFILE))
56071 return -EINVAL;
56072
56073 diff --git a/fs/seq_file.c b/fs/seq_file.c
56074 index 38bb59f..a304f9d 100644
56075 --- a/fs/seq_file.c
56076 +++ b/fs/seq_file.c
56077 @@ -10,6 +10,7 @@
56078 #include <linux/seq_file.h>
56079 #include <linux/slab.h>
56080 #include <linux/cred.h>
56081 +#include <linux/sched.h>
56082
56083 #include <asm/uaccess.h>
56084 #include <asm/page.h>
56085 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
56086 #ifdef CONFIG_USER_NS
56087 p->user_ns = file->f_cred->user_ns;
56088 #endif
56089 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56090 + p->exec_id = current->exec_id;
56091 +#endif
56092
56093 /*
56094 * Wrappers around seq_open(e.g. swaps_open) need to be
56095 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56096 return 0;
56097 }
56098 if (!m->buf) {
56099 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56100 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56101 if (!m->buf)
56102 return -ENOMEM;
56103 }
56104 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56105 Eoverflow:
56106 m->op->stop(m, p);
56107 kfree(m->buf);
56108 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56109 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56110 return !m->buf ? -ENOMEM : -EAGAIN;
56111 }
56112
56113 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56114
56115 /* grab buffer if we didn't have one */
56116 if (!m->buf) {
56117 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56118 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56119 if (!m->buf)
56120 goto Enomem;
56121 }
56122 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56123 goto Fill;
56124 m->op->stop(m, p);
56125 kfree(m->buf);
56126 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56127 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56128 if (!m->buf)
56129 goto Enomem;
56130 m->count = 0;
56131 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
56132 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
56133 void *data)
56134 {
56135 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
56136 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
56137 int res = -ENOMEM;
56138
56139 if (op) {
56140 diff --git a/fs/splice.c b/fs/splice.c
56141 index 29e394e..b13c247 100644
56142 --- a/fs/splice.c
56143 +++ b/fs/splice.c
56144 @@ -195,7 +195,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56145 pipe_lock(pipe);
56146
56147 for (;;) {
56148 - if (!pipe->readers) {
56149 + if (!atomic_read(&pipe->readers)) {
56150 send_sig(SIGPIPE, current, 0);
56151 if (!ret)
56152 ret = -EPIPE;
56153 @@ -249,9 +249,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56154 do_wakeup = 0;
56155 }
56156
56157 - pipe->waiting_writers++;
56158 + atomic_inc(&pipe->waiting_writers);
56159 pipe_wait(pipe);
56160 - pipe->waiting_writers--;
56161 + atomic_dec(&pipe->waiting_writers);
56162 }
56163
56164 pipe_unlock(pipe);
56165 @@ -564,7 +564,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
56166 old_fs = get_fs();
56167 set_fs(get_ds());
56168 /* The cast to a user pointer is valid due to the set_fs() */
56169 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
56170 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
56171 set_fs(old_fs);
56172
56173 return res;
56174 @@ -579,7 +579,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
56175 old_fs = get_fs();
56176 set_fs(get_ds());
56177 /* The cast to a user pointer is valid due to the set_fs() */
56178 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
56179 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
56180 set_fs(old_fs);
56181
56182 return res;
56183 @@ -632,7 +632,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
56184 goto err;
56185
56186 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
56187 - vec[i].iov_base = (void __user *) page_address(page);
56188 + vec[i].iov_base = (void __force_user *) page_address(page);
56189 vec[i].iov_len = this_len;
56190 spd.pages[i] = page;
56191 spd.nr_pages++;
56192 @@ -853,10 +853,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
56193 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
56194 {
56195 while (!pipe->nrbufs) {
56196 - if (!pipe->writers)
56197 + if (!atomic_read(&pipe->writers))
56198 return 0;
56199
56200 - if (!pipe->waiting_writers && sd->num_spliced)
56201 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
56202 return 0;
56203
56204 if (sd->flags & SPLICE_F_NONBLOCK)
56205 @@ -1192,7 +1192,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
56206 * out of the pipe right after the splice_to_pipe(). So set
56207 * PIPE_READERS appropriately.
56208 */
56209 - pipe->readers = 1;
56210 + atomic_set(&pipe->readers, 1);
56211
56212 current->splice_pipe = pipe;
56213 }
56214 @@ -1741,9 +1741,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56215 ret = -ERESTARTSYS;
56216 break;
56217 }
56218 - if (!pipe->writers)
56219 + if (!atomic_read(&pipe->writers))
56220 break;
56221 - if (!pipe->waiting_writers) {
56222 + if (!atomic_read(&pipe->waiting_writers)) {
56223 if (flags & SPLICE_F_NONBLOCK) {
56224 ret = -EAGAIN;
56225 break;
56226 @@ -1775,7 +1775,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56227 pipe_lock(pipe);
56228
56229 while (pipe->nrbufs >= pipe->buffers) {
56230 - if (!pipe->readers) {
56231 + if (!atomic_read(&pipe->readers)) {
56232 send_sig(SIGPIPE, current, 0);
56233 ret = -EPIPE;
56234 break;
56235 @@ -1788,9 +1788,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56236 ret = -ERESTARTSYS;
56237 break;
56238 }
56239 - pipe->waiting_writers++;
56240 + atomic_inc(&pipe->waiting_writers);
56241 pipe_wait(pipe);
56242 - pipe->waiting_writers--;
56243 + atomic_dec(&pipe->waiting_writers);
56244 }
56245
56246 pipe_unlock(pipe);
56247 @@ -1826,14 +1826,14 @@ retry:
56248 pipe_double_lock(ipipe, opipe);
56249
56250 do {
56251 - if (!opipe->readers) {
56252 + if (!atomic_read(&opipe->readers)) {
56253 send_sig(SIGPIPE, current, 0);
56254 if (!ret)
56255 ret = -EPIPE;
56256 break;
56257 }
56258
56259 - if (!ipipe->nrbufs && !ipipe->writers)
56260 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
56261 break;
56262
56263 /*
56264 @@ -1930,7 +1930,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56265 pipe_double_lock(ipipe, opipe);
56266
56267 do {
56268 - if (!opipe->readers) {
56269 + if (!atomic_read(&opipe->readers)) {
56270 send_sig(SIGPIPE, current, 0);
56271 if (!ret)
56272 ret = -EPIPE;
56273 @@ -1975,7 +1975,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56274 * return EAGAIN if we have the potential of some data in the
56275 * future, otherwise just return 0
56276 */
56277 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
56278 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
56279 ret = -EAGAIN;
56280
56281 pipe_unlock(ipipe);
56282 diff --git a/fs/stat.c b/fs/stat.c
56283 index 04ce1ac..a13dd1e 100644
56284 --- a/fs/stat.c
56285 +++ b/fs/stat.c
56286 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
56287 stat->gid = inode->i_gid;
56288 stat->rdev = inode->i_rdev;
56289 stat->size = i_size_read(inode);
56290 - stat->atime = inode->i_atime;
56291 - stat->mtime = inode->i_mtime;
56292 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56293 + stat->atime = inode->i_ctime;
56294 + stat->mtime = inode->i_ctime;
56295 + } else {
56296 + stat->atime = inode->i_atime;
56297 + stat->mtime = inode->i_mtime;
56298 + }
56299 stat->ctime = inode->i_ctime;
56300 stat->blksize = (1 << inode->i_blkbits);
56301 stat->blocks = inode->i_blocks;
56302 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
56303 if (retval)
56304 return retval;
56305
56306 - if (inode->i_op->getattr)
56307 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
56308 + if (inode->i_op->getattr) {
56309 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
56310 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56311 + stat->atime = stat->ctime;
56312 + stat->mtime = stat->ctime;
56313 + }
56314 + return retval;
56315 + }
56316
56317 generic_fillattr(inode, stat);
56318 return 0;
56319 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
56320 index 15c68f9..36a8b3e 100644
56321 --- a/fs/sysfs/bin.c
56322 +++ b/fs/sysfs/bin.c
56323 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
56324 return ret;
56325 }
56326
56327 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
56328 - void *buf, int len, int write)
56329 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
56330 + void *buf, size_t len, int write)
56331 {
56332 struct file *file = vma->vm_file;
56333 struct bin_buffer *bb = file->private_data;
56334 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
56335 - int ret;
56336 + ssize_t ret;
56337
56338 if (!bb->vm_ops)
56339 return -EINVAL;
56340 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
56341 index 6f31590..3c87c8a 100644
56342 --- a/fs/sysfs/dir.c
56343 +++ b/fs/sysfs/dir.c
56344 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
56345 *
56346 * Returns 31 bit hash of ns + name (so it fits in an off_t )
56347 */
56348 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
56349 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
56350 {
56351 unsigned long hash = init_name_hash();
56352 unsigned int len = strlen(name);
56353 @@ -685,6 +685,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
56354 struct sysfs_dirent *sd;
56355 int rc;
56356
56357 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
56358 + const char *parent_name = parent_sd->s_name;
56359 +
56360 + mode = S_IFDIR | S_IRWXU;
56361 +
56362 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
56363 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
56364 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
56365 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
56366 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
56367 +#endif
56368 +
56369 /* allocate */
56370 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
56371 if (!sd)
56372 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
56373 index 602f56d..6853db8 100644
56374 --- a/fs/sysfs/file.c
56375 +++ b/fs/sysfs/file.c
56376 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
56377
56378 struct sysfs_open_dirent {
56379 atomic_t refcnt;
56380 - atomic_t event;
56381 + atomic_unchecked_t event;
56382 wait_queue_head_t poll;
56383 struct list_head buffers; /* goes through sysfs_buffer.list */
56384 };
56385 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
56386 if (!sysfs_get_active(attr_sd))
56387 return -ENODEV;
56388
56389 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
56390 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
56391 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
56392
56393 sysfs_put_active(attr_sd);
56394 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
56395 return -ENOMEM;
56396
56397 atomic_set(&new_od->refcnt, 0);
56398 - atomic_set(&new_od->event, 1);
56399 + atomic_set_unchecked(&new_od->event, 1);
56400 init_waitqueue_head(&new_od->poll);
56401 INIT_LIST_HEAD(&new_od->buffers);
56402 goto retry;
56403 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
56404
56405 sysfs_put_active(attr_sd);
56406
56407 - if (buffer->event != atomic_read(&od->event))
56408 + if (buffer->event != atomic_read_unchecked(&od->event))
56409 goto trigger;
56410
56411 return DEFAULT_POLLMASK;
56412 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
56413
56414 od = sd->s_attr.open;
56415 if (od) {
56416 - atomic_inc(&od->event);
56417 + atomic_inc_unchecked(&od->event);
56418 wake_up_interruptible(&od->poll);
56419 }
56420
56421 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
56422 index 8c940df..25b733e 100644
56423 --- a/fs/sysfs/symlink.c
56424 +++ b/fs/sysfs/symlink.c
56425 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
56426
56427 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
56428 {
56429 - char *page = nd_get_link(nd);
56430 + const char *page = nd_get_link(nd);
56431 if (!IS_ERR(page))
56432 free_page((unsigned long)page);
56433 }
56434 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
56435 index 69d4889..a810bd4 100644
56436 --- a/fs/sysv/sysv.h
56437 +++ b/fs/sysv/sysv.h
56438 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
56439 #endif
56440 }
56441
56442 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56443 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56444 {
56445 if (sbi->s_bytesex == BYTESEX_PDP)
56446 return PDP_swab((__force __u32)n);
56447 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
56448 index e18b988..f1d4ad0f 100644
56449 --- a/fs/ubifs/io.c
56450 +++ b/fs/ubifs/io.c
56451 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
56452 return err;
56453 }
56454
56455 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56456 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56457 {
56458 int err;
56459
56460 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
56461 index c175b4d..8f36a16 100644
56462 --- a/fs/udf/misc.c
56463 +++ b/fs/udf/misc.c
56464 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
56465
56466 u8 udf_tag_checksum(const struct tag *t)
56467 {
56468 - u8 *data = (u8 *)t;
56469 + const u8 *data = (const u8 *)t;
56470 u8 checksum = 0;
56471 int i;
56472 for (i = 0; i < sizeof(struct tag); ++i)
56473 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
56474 index 8d974c4..b82f6ec 100644
56475 --- a/fs/ufs/swab.h
56476 +++ b/fs/ufs/swab.h
56477 @@ -22,7 +22,7 @@ enum {
56478 BYTESEX_BE
56479 };
56480
56481 -static inline u64
56482 +static inline u64 __intentional_overflow(-1)
56483 fs64_to_cpu(struct super_block *sbp, __fs64 n)
56484 {
56485 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56486 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
56487 return (__force __fs64)cpu_to_be64(n);
56488 }
56489
56490 -static inline u32
56491 +static inline u32 __intentional_overflow(-1)
56492 fs32_to_cpu(struct super_block *sbp, __fs32 n)
56493 {
56494 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56495 diff --git a/fs/utimes.c b/fs/utimes.c
56496 index f4fb7ec..3fe03c0 100644
56497 --- a/fs/utimes.c
56498 +++ b/fs/utimes.c
56499 @@ -1,6 +1,7 @@
56500 #include <linux/compiler.h>
56501 #include <linux/file.h>
56502 #include <linux/fs.h>
56503 +#include <linux/security.h>
56504 #include <linux/linkage.h>
56505 #include <linux/mount.h>
56506 #include <linux/namei.h>
56507 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
56508 goto mnt_drop_write_and_out;
56509 }
56510 }
56511 +
56512 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
56513 + error = -EACCES;
56514 + goto mnt_drop_write_and_out;
56515 + }
56516 +
56517 mutex_lock(&inode->i_mutex);
56518 error = notify_change(path->dentry, &newattrs);
56519 mutex_unlock(&inode->i_mutex);
56520 diff --git a/fs/xattr.c b/fs/xattr.c
56521 index 3377dff..4d074d9 100644
56522 --- a/fs/xattr.c
56523 +++ b/fs/xattr.c
56524 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
56525 return rc;
56526 }
56527
56528 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
56529 +ssize_t
56530 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
56531 +{
56532 + struct inode *inode = dentry->d_inode;
56533 + ssize_t error;
56534 +
56535 + error = inode_permission(inode, MAY_EXEC);
56536 + if (error)
56537 + return error;
56538 +
56539 + if (inode->i_op->getxattr)
56540 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
56541 + else
56542 + error = -EOPNOTSUPP;
56543 +
56544 + return error;
56545 +}
56546 +EXPORT_SYMBOL(pax_getxattr);
56547 +#endif
56548 +
56549 ssize_t
56550 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
56551 {
56552 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
56553 * Extended attribute SET operations
56554 */
56555 static long
56556 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
56557 +setxattr(struct path *path, const char __user *name, const void __user *value,
56558 size_t size, int flags)
56559 {
56560 int error;
56561 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
56562 posix_acl_fix_xattr_from_user(kvalue, size);
56563 }
56564
56565 - error = vfs_setxattr(d, kname, kvalue, size, flags);
56566 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
56567 + error = -EACCES;
56568 + goto out;
56569 + }
56570 +
56571 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
56572 out:
56573 if (vvalue)
56574 vfree(vvalue);
56575 @@ -377,7 +403,7 @@ retry:
56576 return error;
56577 error = mnt_want_write(path.mnt);
56578 if (!error) {
56579 - error = setxattr(path.dentry, name, value, size, flags);
56580 + error = setxattr(&path, name, value, size, flags);
56581 mnt_drop_write(path.mnt);
56582 }
56583 path_put(&path);
56584 @@ -401,7 +427,7 @@ retry:
56585 return error;
56586 error = mnt_want_write(path.mnt);
56587 if (!error) {
56588 - error = setxattr(path.dentry, name, value, size, flags);
56589 + error = setxattr(&path, name, value, size, flags);
56590 mnt_drop_write(path.mnt);
56591 }
56592 path_put(&path);
56593 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
56594 const void __user *,value, size_t, size, int, flags)
56595 {
56596 struct fd f = fdget(fd);
56597 - struct dentry *dentry;
56598 int error = -EBADF;
56599
56600 if (!f.file)
56601 return error;
56602 - dentry = f.file->f_path.dentry;
56603 - audit_inode(NULL, dentry, 0);
56604 + audit_inode(NULL, f.file->f_path.dentry, 0);
56605 error = mnt_want_write_file(f.file);
56606 if (!error) {
56607 - error = setxattr(dentry, name, value, size, flags);
56608 + error = setxattr(&f.file->f_path, name, value, size, flags);
56609 mnt_drop_write_file(f.file);
56610 }
56611 fdput(f);
56612 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
56613 index 9fbea87..6b19972 100644
56614 --- a/fs/xattr_acl.c
56615 +++ b/fs/xattr_acl.c
56616 @@ -76,8 +76,8 @@ struct posix_acl *
56617 posix_acl_from_xattr(struct user_namespace *user_ns,
56618 const void *value, size_t size)
56619 {
56620 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
56621 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
56622 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
56623 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
56624 int count;
56625 struct posix_acl *acl;
56626 struct posix_acl_entry *acl_e;
56627 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
56628 index b44af92..06073da 100644
56629 --- a/fs/xfs/xfs_bmap.c
56630 +++ b/fs/xfs/xfs_bmap.c
56631 @@ -192,7 +192,7 @@ xfs_bmap_validate_ret(
56632 int nmap,
56633 int ret_nmap);
56634 #else
56635 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
56636 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
56637 #endif /* DEBUG */
56638
56639 STATIC int
56640 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
56641 index 1b9fc3e..e1bdde0 100644
56642 --- a/fs/xfs/xfs_dir2_sf.c
56643 +++ b/fs/xfs/xfs_dir2_sf.c
56644 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
56645 }
56646
56647 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
56648 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56649 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
56650 + char name[sfep->namelen];
56651 + memcpy(name, sfep->name, sfep->namelen);
56652 + if (filldir(dirent, name, sfep->namelen,
56653 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
56654 + *offset = off & 0x7fffffff;
56655 + return 0;
56656 + }
56657 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56658 off & 0x7fffffff, ino, DT_UNKNOWN)) {
56659 *offset = off & 0x7fffffff;
56660 return 0;
56661 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
56662 index d681e34..2a3f5ab 100644
56663 --- a/fs/xfs/xfs_ioctl.c
56664 +++ b/fs/xfs/xfs_ioctl.c
56665 @@ -127,7 +127,7 @@ xfs_find_handle(
56666 }
56667
56668 error = -EFAULT;
56669 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
56670 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
56671 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
56672 goto out_put;
56673
56674 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
56675 index d82efaa..60100c7 100644
56676 --- a/fs/xfs/xfs_iops.c
56677 +++ b/fs/xfs/xfs_iops.c
56678 @@ -395,7 +395,7 @@ xfs_vn_put_link(
56679 struct nameidata *nd,
56680 void *p)
56681 {
56682 - char *s = nd_get_link(nd);
56683 + const char *s = nd_get_link(nd);
56684
56685 if (!IS_ERR(s))
56686 kfree(s);
56687 @@ -455,6 +455,28 @@ xfs_vn_getattr(
56688 return 0;
56689 }
56690
56691 +static void
56692 +xfs_setattr_mode(
56693 + struct xfs_trans *tp,
56694 + struct xfs_inode *ip,
56695 + struct iattr *iattr)
56696 +{
56697 + struct inode *inode = VFS_I(ip);
56698 + umode_t mode = iattr->ia_mode;
56699 +
56700 + ASSERT(tp);
56701 + ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
56702 +
56703 + if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
56704 + mode &= ~S_ISGID;
56705 +
56706 + ip->i_d.di_mode &= S_IFMT;
56707 + ip->i_d.di_mode |= mode & ~S_IFMT;
56708 +
56709 + inode->i_mode &= S_IFMT;
56710 + inode->i_mode |= mode & ~S_IFMT;
56711 +}
56712 +
56713 int
56714 xfs_setattr_nonsize(
56715 struct xfs_inode *ip,
56716 @@ -606,18 +628,8 @@ xfs_setattr_nonsize(
56717 /*
56718 * Change file access modes.
56719 */
56720 - if (mask & ATTR_MODE) {
56721 - umode_t mode = iattr->ia_mode;
56722 -
56723 - if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
56724 - mode &= ~S_ISGID;
56725 -
56726 - ip->i_d.di_mode &= S_IFMT;
56727 - ip->i_d.di_mode |= mode & ~S_IFMT;
56728 -
56729 - inode->i_mode &= S_IFMT;
56730 - inode->i_mode |= mode & ~S_IFMT;
56731 - }
56732 + if (mask & ATTR_MODE)
56733 + xfs_setattr_mode(tp, ip, iattr);
56734
56735 /*
56736 * Change file access or modified times.
56737 @@ -714,9 +726,8 @@ xfs_setattr_size(
56738 return XFS_ERROR(error);
56739
56740 ASSERT(S_ISREG(ip->i_d.di_mode));
56741 - ASSERT((mask & (ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_ATIME_SET|
56742 - ATTR_MTIME_SET|ATTR_KILL_SUID|ATTR_KILL_SGID|
56743 - ATTR_KILL_PRIV|ATTR_TIMES_SET)) == 0);
56744 + ASSERT((mask & (ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_ATIME_SET|
56745 + ATTR_MTIME_SET|ATTR_KILL_PRIV|ATTR_TIMES_SET)) == 0);
56746
56747 if (!(flags & XFS_ATTR_NOLOCK)) {
56748 lock_flags |= XFS_IOLOCK_EXCL;
56749 @@ -860,6 +871,12 @@ xfs_setattr_size(
56750 xfs_inode_clear_eofblocks_tag(ip);
56751 }
56752
56753 + /*
56754 + * Change file access modes.
56755 + */
56756 + if (mask & ATTR_MODE)
56757 + xfs_setattr_mode(tp, ip, iattr);
56758 +
56759 if (mask & ATTR_CTIME) {
56760 inode->i_ctime = iattr->ia_ctime;
56761 ip->i_d.di_ctime.t_sec = iattr->ia_ctime.tv_sec;
56762 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
56763 new file mode 100644
56764 index 0000000..ba9c5e3
56765 --- /dev/null
56766 +++ b/grsecurity/Kconfig
56767 @@ -0,0 +1,1053 @@
56768 +#
56769 +# grecurity configuration
56770 +#
56771 +menu "Memory Protections"
56772 +depends on GRKERNSEC
56773 +
56774 +config GRKERNSEC_KMEM
56775 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
56776 + default y if GRKERNSEC_CONFIG_AUTO
56777 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
56778 + help
56779 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
56780 + be written to or read from to modify or leak the contents of the running
56781 + kernel. /dev/port will also not be allowed to be opened and support
56782 + for /dev/cpu/*/msr will be removed. If you have module
56783 + support disabled, enabling this will close up five ways that are
56784 + currently used to insert malicious code into the running kernel.
56785 +
56786 + Even with all these features enabled, we still highly recommend that
56787 + you use the RBAC system, as it is still possible for an attacker to
56788 + modify the running kernel through privileged I/O granted by ioperm/iopl.
56789 +
56790 + If you are not using XFree86, you may be able to stop this additional
56791 + case by enabling the 'Disable privileged I/O' option. Though nothing
56792 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
56793 + but only to video memory, which is the only writing we allow in this
56794 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
56795 + not be allowed to mprotect it with PROT_WRITE later.
56796 + Enabling this feature will prevent the "cpupower" and "powertop" tools
56797 + from working.
56798 +
56799 + It is highly recommended that you say Y here if you meet all the
56800 + conditions above.
56801 +
56802 +config GRKERNSEC_VM86
56803 + bool "Restrict VM86 mode"
56804 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56805 + depends on X86_32
56806 +
56807 + help
56808 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
56809 + make use of a special execution mode on 32bit x86 processors called
56810 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
56811 + video cards and will still work with this option enabled. The purpose
56812 + of the option is to prevent exploitation of emulation errors in
56813 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
56814 + Nearly all users should be able to enable this option.
56815 +
56816 +config GRKERNSEC_IO
56817 + bool "Disable privileged I/O"
56818 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56819 + depends on X86
56820 + select RTC_CLASS
56821 + select RTC_INTF_DEV
56822 + select RTC_DRV_CMOS
56823 +
56824 + help
56825 + If you say Y here, all ioperm and iopl calls will return an error.
56826 + Ioperm and iopl can be used to modify the running kernel.
56827 + Unfortunately, some programs need this access to operate properly,
56828 + the most notable of which are XFree86 and hwclock. hwclock can be
56829 + remedied by having RTC support in the kernel, so real-time
56830 + clock support is enabled if this option is enabled, to ensure
56831 + that hwclock operates correctly. XFree86 still will not
56832 + operate correctly with this option enabled, so DO NOT CHOOSE Y
56833 + IF YOU USE XFree86. If you use XFree86 and you still want to
56834 + protect your kernel against modification, use the RBAC system.
56835 +
56836 +config GRKERNSEC_JIT_HARDEN
56837 + bool "Harden BPF JIT against spray attacks"
56838 + default y if GRKERNSEC_CONFIG_AUTO
56839 + depends on BPF_JIT
56840 + help
56841 + If you say Y here, the native code generated by the kernel's Berkeley
56842 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
56843 + attacks that attempt to fit attacker-beneficial instructions in
56844 + 32bit immediate fields of JIT-generated native instructions. The
56845 + attacker will generally aim to cause an unintended instruction sequence
56846 + of JIT-generated native code to execute by jumping into the middle of
56847 + a generated instruction. This feature effectively randomizes the 32bit
56848 + immediate constants present in the generated code to thwart such attacks.
56849 +
56850 + If you're using KERNEXEC, it's recommended that you enable this option
56851 + to supplement the hardening of the kernel.
56852 +
56853 +config GRKERNSEC_PERF_HARDEN
56854 + bool "Disable unprivileged PERF_EVENTS usage by default"
56855 + default y if GRKERNSEC_CONFIG_AUTO
56856 + depends on PERF_EVENTS
56857 + help
56858 + If you say Y here, the range of acceptable values for the
56859 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
56860 + default to a new value: 3. When the sysctl is set to this value, no
56861 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
56862 +
56863 + Though PERF_EVENTS can be used legitimately for performance monitoring
56864 + and low-level application profiling, it is forced on regardless of
56865 + configuration, has been at fault for several vulnerabilities, and
56866 + creates new opportunities for side channels and other information leaks.
56867 +
56868 + This feature puts PERF_EVENTS into a secure default state and permits
56869 + the administrator to change out of it temporarily if unprivileged
56870 + application profiling is needed.
56871 +
56872 +config GRKERNSEC_RAND_THREADSTACK
56873 + bool "Insert random gaps between thread stacks"
56874 + default y if GRKERNSEC_CONFIG_AUTO
56875 + depends on PAX_RANDMMAP && !PPC && BROKEN
56876 + help
56877 + If you say Y here, a random-sized gap will be enforced between allocated
56878 + thread stacks. Glibc's NPTL and other threading libraries that
56879 + pass MAP_STACK to the kernel for thread stack allocation are supported.
56880 + The implementation currently provides 8 bits of entropy for the gap.
56881 +
56882 + Many distributions do not compile threaded remote services with the
56883 + -fstack-check argument to GCC, causing the variable-sized stack-based
56884 + allocator, alloca(), to not probe the stack on allocation. This
56885 + permits an unbounded alloca() to skip over any guard page and potentially
56886 + modify another thread's stack reliably. An enforced random gap
56887 + reduces the reliability of such an attack and increases the chance
56888 + that such a read/write to another thread's stack instead lands in
56889 + an unmapped area, causing a crash and triggering grsecurity's
56890 + anti-bruteforcing logic.
56891 +
56892 +config GRKERNSEC_PROC_MEMMAP
56893 + bool "Harden ASLR against information leaks and entropy reduction"
56894 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
56895 + depends on PAX_NOEXEC || PAX_ASLR
56896 + help
56897 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
56898 + give no information about the addresses of its mappings if
56899 + PaX features that rely on random addresses are enabled on the task.
56900 + In addition to sanitizing this information and disabling other
56901 + dangerous sources of information, this option causes reads of sensitive
56902 + /proc/<pid> entries where the file descriptor was opened in a different
56903 + task than the one performing the read. Such attempts are logged.
56904 + This option also limits argv/env strings for suid/sgid binaries
56905 + to 512KB to prevent a complete exhaustion of the stack entropy provided
56906 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
56907 + binaries to prevent alternative mmap layouts from being abused.
56908 +
56909 + If you use PaX it is essential that you say Y here as it closes up
56910 + several holes that make full ASLR useless locally.
56911 +
56912 +config GRKERNSEC_BRUTE
56913 + bool "Deter exploit bruteforcing"
56914 + default y if GRKERNSEC_CONFIG_AUTO
56915 + help
56916 + If you say Y here, attempts to bruteforce exploits against forking
56917 + daemons such as apache or sshd, as well as against suid/sgid binaries
56918 + will be deterred. When a child of a forking daemon is killed by PaX
56919 + or crashes due to an illegal instruction or other suspicious signal,
56920 + the parent process will be delayed 30 seconds upon every subsequent
56921 + fork until the administrator is able to assess the situation and
56922 + restart the daemon.
56923 + In the suid/sgid case, the attempt is logged, the user has all their
56924 + processes terminated, and they are prevented from executing any further
56925 + processes for 15 minutes.
56926 + It is recommended that you also enable signal logging in the auditing
56927 + section so that logs are generated when a process triggers a suspicious
56928 + signal.
56929 + If the sysctl option is enabled, a sysctl option with name
56930 + "deter_bruteforce" is created.
56931 +
56932 +
56933 +config GRKERNSEC_MODHARDEN
56934 + bool "Harden module auto-loading"
56935 + default y if GRKERNSEC_CONFIG_AUTO
56936 + depends on MODULES
56937 + help
56938 + If you say Y here, module auto-loading in response to use of some
56939 + feature implemented by an unloaded module will be restricted to
56940 + root users. Enabling this option helps defend against attacks
56941 + by unprivileged users who abuse the auto-loading behavior to
56942 + cause a vulnerable module to load that is then exploited.
56943 +
56944 + If this option prevents a legitimate use of auto-loading for a
56945 + non-root user, the administrator can execute modprobe manually
56946 + with the exact name of the module mentioned in the alert log.
56947 + Alternatively, the administrator can add the module to the list
56948 + of modules loaded at boot by modifying init scripts.
56949 +
56950 + Modification of init scripts will most likely be needed on
56951 + Ubuntu servers with encrypted home directory support enabled,
56952 + as the first non-root user logging in will cause the ecb(aes),
56953 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
56954 +
56955 +config GRKERNSEC_HIDESYM
56956 + bool "Hide kernel symbols"
56957 + default y if GRKERNSEC_CONFIG_AUTO
56958 + select PAX_USERCOPY_SLABS
56959 + help
56960 + If you say Y here, getting information on loaded modules, and
56961 + displaying all kernel symbols through a syscall will be restricted
56962 + to users with CAP_SYS_MODULE. For software compatibility reasons,
56963 + /proc/kallsyms will be restricted to the root user. The RBAC
56964 + system can hide that entry even from root.
56965 +
56966 + This option also prevents leaking of kernel addresses through
56967 + several /proc entries.
56968 +
56969 + Note that this option is only effective provided the following
56970 + conditions are met:
56971 + 1) The kernel using grsecurity is not precompiled by some distribution
56972 + 2) You have also enabled GRKERNSEC_DMESG
56973 + 3) You are using the RBAC system and hiding other files such as your
56974 + kernel image and System.map. Alternatively, enabling this option
56975 + causes the permissions on /boot, /lib/modules, and the kernel
56976 + source directory to change at compile time to prevent
56977 + reading by non-root users.
56978 + If the above conditions are met, this option will aid in providing a
56979 + useful protection against local kernel exploitation of overflows
56980 + and arbitrary read/write vulnerabilities.
56981 +
56982 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
56983 + in addition to this feature.
56984 +
56985 +config GRKERNSEC_KERN_LOCKOUT
56986 + bool "Active kernel exploit response"
56987 + default y if GRKERNSEC_CONFIG_AUTO
56988 + depends on X86 || ARM || PPC || SPARC
56989 + help
56990 + If you say Y here, when a PaX alert is triggered due to suspicious
56991 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
56992 + or an OOPS occurs due to bad memory accesses, instead of just
56993 + terminating the offending process (and potentially allowing
56994 + a subsequent exploit from the same user), we will take one of two
56995 + actions:
56996 + If the user was root, we will panic the system
56997 + If the user was non-root, we will log the attempt, terminate
56998 + all processes owned by the user, then prevent them from creating
56999 + any new processes until the system is restarted
57000 + This deters repeated kernel exploitation/bruteforcing attempts
57001 + and is useful for later forensics.
57002 +
57003 +endmenu
57004 +menu "Role Based Access Control Options"
57005 +depends on GRKERNSEC
57006 +
57007 +config GRKERNSEC_RBAC_DEBUG
57008 + bool
57009 +
57010 +config GRKERNSEC_NO_RBAC
57011 + bool "Disable RBAC system"
57012 + help
57013 + If you say Y here, the /dev/grsec device will be removed from the kernel,
57014 + preventing the RBAC system from being enabled. You should only say Y
57015 + here if you have no intention of using the RBAC system, so as to prevent
57016 + an attacker with root access from misusing the RBAC system to hide files
57017 + and processes when loadable module support and /dev/[k]mem have been
57018 + locked down.
57019 +
57020 +config GRKERNSEC_ACL_HIDEKERN
57021 + bool "Hide kernel processes"
57022 + help
57023 + If you say Y here, all kernel threads will be hidden to all
57024 + processes but those whose subject has the "view hidden processes"
57025 + flag.
57026 +
57027 +config GRKERNSEC_ACL_MAXTRIES
57028 + int "Maximum tries before password lockout"
57029 + default 3
57030 + help
57031 + This option enforces the maximum number of times a user can attempt
57032 + to authorize themselves with the grsecurity RBAC system before being
57033 + denied the ability to attempt authorization again for a specified time.
57034 + The lower the number, the harder it will be to brute-force a password.
57035 +
57036 +config GRKERNSEC_ACL_TIMEOUT
57037 + int "Time to wait after max password tries, in seconds"
57038 + default 30
57039 + help
57040 + This option specifies the time the user must wait after attempting to
57041 + authorize to the RBAC system with the maximum number of invalid
57042 + passwords. The higher the number, the harder it will be to brute-force
57043 + a password.
57044 +
57045 +endmenu
57046 +menu "Filesystem Protections"
57047 +depends on GRKERNSEC
57048 +
57049 +config GRKERNSEC_PROC
57050 + bool "Proc restrictions"
57051 + default y if GRKERNSEC_CONFIG_AUTO
57052 + help
57053 + If you say Y here, the permissions of the /proc filesystem
57054 + will be altered to enhance system security and privacy. You MUST
57055 + choose either a user only restriction or a user and group restriction.
57056 + Depending upon the option you choose, you can either restrict users to
57057 + see only the processes they themselves run, or choose a group that can
57058 + view all processes and files normally restricted to root if you choose
57059 + the "restrict to user only" option. NOTE: If you're running identd or
57060 + ntpd as a non-root user, you will have to run it as the group you
57061 + specify here.
57062 +
57063 +config GRKERNSEC_PROC_USER
57064 + bool "Restrict /proc to user only"
57065 + depends on GRKERNSEC_PROC
57066 + help
57067 + If you say Y here, non-root users will only be able to view their own
57068 + processes, and restricts them from viewing network-related information,
57069 + and viewing kernel symbol and module information.
57070 +
57071 +config GRKERNSEC_PROC_USERGROUP
57072 + bool "Allow special group"
57073 + default y if GRKERNSEC_CONFIG_AUTO
57074 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
57075 + help
57076 + If you say Y here, you will be able to select a group that will be
57077 + able to view all processes and network-related information. If you've
57078 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
57079 + remain hidden. This option is useful if you want to run identd as
57080 + a non-root user. The group you select may also be chosen at boot time
57081 + via "grsec_proc_gid=" on the kernel commandline.
57082 +
57083 +config GRKERNSEC_PROC_GID
57084 + int "GID for special group"
57085 + depends on GRKERNSEC_PROC_USERGROUP
57086 + default 1001
57087 +
57088 +config GRKERNSEC_PROC_ADD
57089 + bool "Additional restrictions"
57090 + default y if GRKERNSEC_CONFIG_AUTO
57091 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
57092 + help
57093 + If you say Y here, additional restrictions will be placed on
57094 + /proc that keep normal users from viewing device information and
57095 + slabinfo information that could be useful for exploits.
57096 +
57097 +config GRKERNSEC_LINK
57098 + bool "Linking restrictions"
57099 + default y if GRKERNSEC_CONFIG_AUTO
57100 + help
57101 + If you say Y here, /tmp race exploits will be prevented, since users
57102 + will no longer be able to follow symlinks owned by other users in
57103 + world-writable +t directories (e.g. /tmp), unless the owner of the
57104 + symlink is the owner of the directory. users will also not be
57105 + able to hardlink to files they do not own. If the sysctl option is
57106 + enabled, a sysctl option with name "linking_restrictions" is created.
57107 +
57108 +config GRKERNSEC_SYMLINKOWN
57109 + bool "Kernel-enforced SymlinksIfOwnerMatch"
57110 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57111 + help
57112 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
57113 + that prevents it from being used as a security feature. As Apache
57114 + verifies the symlink by performing a stat() against the target of
57115 + the symlink before it is followed, an attacker can setup a symlink
57116 + to point to a same-owned file, then replace the symlink with one
57117 + that targets another user's file just after Apache "validates" the
57118 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
57119 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
57120 + will be in place for the group you specify. If the sysctl option
57121 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
57122 + created.
57123 +
57124 +config GRKERNSEC_SYMLINKOWN_GID
57125 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
57126 + depends on GRKERNSEC_SYMLINKOWN
57127 + default 1006
57128 + help
57129 + Setting this GID determines what group kernel-enforced
57130 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
57131 + is enabled, a sysctl option with name "symlinkown_gid" is created.
57132 +
57133 +config GRKERNSEC_FIFO
57134 + bool "FIFO restrictions"
57135 + default y if GRKERNSEC_CONFIG_AUTO
57136 + help
57137 + If you say Y here, users will not be able to write to FIFOs they don't
57138 + own in world-writable +t directories (e.g. /tmp), unless the owner of
57139 + the FIFO is the same owner of the directory it's held in. If the sysctl
57140 + option is enabled, a sysctl option with name "fifo_restrictions" is
57141 + created.
57142 +
57143 +config GRKERNSEC_SYSFS_RESTRICT
57144 + bool "Sysfs/debugfs restriction"
57145 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57146 + depends on SYSFS
57147 + help
57148 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
57149 + any filesystem normally mounted under it (e.g. debugfs) will be
57150 + mostly accessible only by root. These filesystems generally provide access
57151 + to hardware and debug information that isn't appropriate for unprivileged
57152 + users of the system. Sysfs and debugfs have also become a large source
57153 + of new vulnerabilities, ranging from infoleaks to local compromise.
57154 + There has been very little oversight with an eye toward security involved
57155 + in adding new exporters of information to these filesystems, so their
57156 + use is discouraged.
57157 + For reasons of compatibility, a few directories have been whitelisted
57158 + for access by non-root users:
57159 + /sys/fs/selinux
57160 + /sys/fs/fuse
57161 + /sys/devices/system/cpu
57162 +
57163 +config GRKERNSEC_ROFS
57164 + bool "Runtime read-only mount protection"
57165 + help
57166 + If you say Y here, a sysctl option with name "romount_protect" will
57167 + be created. By setting this option to 1 at runtime, filesystems
57168 + will be protected in the following ways:
57169 + * No new writable mounts will be allowed
57170 + * Existing read-only mounts won't be able to be remounted read/write
57171 + * Write operations will be denied on all block devices
57172 + This option acts independently of grsec_lock: once it is set to 1,
57173 + it cannot be turned off. Therefore, please be mindful of the resulting
57174 + behavior if this option is enabled in an init script on a read-only
57175 + filesystem. This feature is mainly intended for secure embedded systems.
57176 +
57177 +config GRKERNSEC_DEVICE_SIDECHANNEL
57178 + bool "Eliminate stat/notify-based device sidechannels"
57179 + default y if GRKERNSEC_CONFIG_AUTO
57180 + help
57181 + If you say Y here, timing analyses on block or character
57182 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
57183 + will be thwarted for unprivileged users. If a process without
57184 + CAP_MKNOD stats such a device, the last access and last modify times
57185 + will match the device's create time. No access or modify events
57186 + will be triggered through inotify/dnotify/fanotify for such devices.
57187 + This feature will prevent attacks that may at a minimum
57188 + allow an attacker to determine the administrator's password length.
57189 +
57190 +config GRKERNSEC_CHROOT
57191 + bool "Chroot jail restrictions"
57192 + default y if GRKERNSEC_CONFIG_AUTO
57193 + help
57194 + If you say Y here, you will be able to choose several options that will
57195 + make breaking out of a chrooted jail much more difficult. If you
57196 + encounter no software incompatibilities with the following options, it
57197 + is recommended that you enable each one.
57198 +
57199 +config GRKERNSEC_CHROOT_MOUNT
57200 + bool "Deny mounts"
57201 + default y if GRKERNSEC_CONFIG_AUTO
57202 + depends on GRKERNSEC_CHROOT
57203 + help
57204 + If you say Y here, processes inside a chroot will not be able to
57205 + mount or remount filesystems. If the sysctl option is enabled, a
57206 + sysctl option with name "chroot_deny_mount" is created.
57207 +
57208 +config GRKERNSEC_CHROOT_DOUBLE
57209 + bool "Deny double-chroots"
57210 + default y if GRKERNSEC_CONFIG_AUTO
57211 + depends on GRKERNSEC_CHROOT
57212 + help
57213 + If you say Y here, processes inside a chroot will not be able to chroot
57214 + again outside the chroot. This is a widely used method of breaking
57215 + out of a chroot jail and should not be allowed. If the sysctl
57216 + option is enabled, a sysctl option with name
57217 + "chroot_deny_chroot" is created.
57218 +
57219 +config GRKERNSEC_CHROOT_PIVOT
57220 + bool "Deny pivot_root in chroot"
57221 + default y if GRKERNSEC_CONFIG_AUTO
57222 + depends on GRKERNSEC_CHROOT
57223 + help
57224 + If you say Y here, processes inside a chroot will not be able to use
57225 + a function called pivot_root() that was introduced in Linux 2.3.41. It
57226 + works similar to chroot in that it changes the root filesystem. This
57227 + function could be misused in a chrooted process to attempt to break out
57228 + of the chroot, and therefore should not be allowed. If the sysctl
57229 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
57230 + created.
57231 +
57232 +config GRKERNSEC_CHROOT_CHDIR
57233 + bool "Enforce chdir(\"/\") on all chroots"
57234 + default y if GRKERNSEC_CONFIG_AUTO
57235 + depends on GRKERNSEC_CHROOT
57236 + help
57237 + If you say Y here, the current working directory of all newly-chrooted
57238 + applications will be set to the the root directory of the chroot.
57239 + The man page on chroot(2) states:
57240 + Note that this call does not change the current working
57241 + directory, so that `.' can be outside the tree rooted at
57242 + `/'. In particular, the super-user can escape from a
57243 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
57244 +
57245 + It is recommended that you say Y here, since it's not known to break
57246 + any software. If the sysctl option is enabled, a sysctl option with
57247 + name "chroot_enforce_chdir" is created.
57248 +
57249 +config GRKERNSEC_CHROOT_CHMOD
57250 + bool "Deny (f)chmod +s"
57251 + default y if GRKERNSEC_CONFIG_AUTO
57252 + depends on GRKERNSEC_CHROOT
57253 + help
57254 + If you say Y here, processes inside a chroot will not be able to chmod
57255 + or fchmod files to make them have suid or sgid bits. This protects
57256 + against another published method of breaking a chroot. If the sysctl
57257 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
57258 + created.
57259 +
57260 +config GRKERNSEC_CHROOT_FCHDIR
57261 + bool "Deny fchdir out of chroot"
57262 + default y if GRKERNSEC_CONFIG_AUTO
57263 + depends on GRKERNSEC_CHROOT
57264 + help
57265 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
57266 + to a file descriptor of the chrooting process that points to a directory
57267 + outside the filesystem will be stopped. If the sysctl option
57268 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
57269 +
57270 +config GRKERNSEC_CHROOT_MKNOD
57271 + bool "Deny mknod"
57272 + default y if GRKERNSEC_CONFIG_AUTO
57273 + depends on GRKERNSEC_CHROOT
57274 + help
57275 + If you say Y here, processes inside a chroot will not be allowed to
57276 + mknod. The problem with using mknod inside a chroot is that it
57277 + would allow an attacker to create a device entry that is the same
57278 + as one on the physical root of your system, which could range from
57279 + anything from the console device to a device for your harddrive (which
57280 + they could then use to wipe the drive or steal data). It is recommended
57281 + that you say Y here, unless you run into software incompatibilities.
57282 + If the sysctl option is enabled, a sysctl option with name
57283 + "chroot_deny_mknod" is created.
57284 +
57285 +config GRKERNSEC_CHROOT_SHMAT
57286 + bool "Deny shmat() out of chroot"
57287 + default y if GRKERNSEC_CONFIG_AUTO
57288 + depends on GRKERNSEC_CHROOT
57289 + help
57290 + If you say Y here, processes inside a chroot will not be able to attach
57291 + to shared memory segments that were created outside of the chroot jail.
57292 + It is recommended that you say Y here. If the sysctl option is enabled,
57293 + a sysctl option with name "chroot_deny_shmat" is created.
57294 +
57295 +config GRKERNSEC_CHROOT_UNIX
57296 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
57297 + default y if GRKERNSEC_CONFIG_AUTO
57298 + depends on GRKERNSEC_CHROOT
57299 + help
57300 + If you say Y here, processes inside a chroot will not be able to
57301 + connect to abstract (meaning not belonging to a filesystem) Unix
57302 + domain sockets that were bound outside of a chroot. It is recommended
57303 + that you say Y here. If the sysctl option is enabled, a sysctl option
57304 + with name "chroot_deny_unix" is created.
57305 +
57306 +config GRKERNSEC_CHROOT_FINDTASK
57307 + bool "Protect outside processes"
57308 + default y if GRKERNSEC_CONFIG_AUTO
57309 + depends on GRKERNSEC_CHROOT
57310 + help
57311 + If you say Y here, processes inside a chroot will not be able to
57312 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
57313 + getsid, or view any process outside of the chroot. If the sysctl
57314 + option is enabled, a sysctl option with name "chroot_findtask" is
57315 + created.
57316 +
57317 +config GRKERNSEC_CHROOT_NICE
57318 + bool "Restrict priority changes"
57319 + default y if GRKERNSEC_CONFIG_AUTO
57320 + depends on GRKERNSEC_CHROOT
57321 + help
57322 + If you say Y here, processes inside a chroot will not be able to raise
57323 + the priority of processes in the chroot, or alter the priority of
57324 + processes outside the chroot. This provides more security than simply
57325 + removing CAP_SYS_NICE from the process' capability set. If the
57326 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
57327 + is created.
57328 +
57329 +config GRKERNSEC_CHROOT_SYSCTL
57330 + bool "Deny sysctl writes"
57331 + default y if GRKERNSEC_CONFIG_AUTO
57332 + depends on GRKERNSEC_CHROOT
57333 + help
57334 + If you say Y here, an attacker in a chroot will not be able to
57335 + write to sysctl entries, either by sysctl(2) or through a /proc
57336 + interface. It is strongly recommended that you say Y here. If the
57337 + sysctl option is enabled, a sysctl option with name
57338 + "chroot_deny_sysctl" is created.
57339 +
57340 +config GRKERNSEC_CHROOT_CAPS
57341 + bool "Capability restrictions"
57342 + default y if GRKERNSEC_CONFIG_AUTO
57343 + depends on GRKERNSEC_CHROOT
57344 + help
57345 + If you say Y here, the capabilities on all processes within a
57346 + chroot jail will be lowered to stop module insertion, raw i/o,
57347 + system and net admin tasks, rebooting the system, modifying immutable
57348 + files, modifying IPC owned by another, and changing the system time.
57349 + This is left an option because it can break some apps. Disable this
57350 + if your chrooted apps are having problems performing those kinds of
57351 + tasks. If the sysctl option is enabled, a sysctl option with
57352 + name "chroot_caps" is created.
57353 +
57354 +config GRKERNSEC_CHROOT_INITRD
57355 + bool "Exempt initrd tasks from restrictions"
57356 + default y if GRKERNSEC_CONFIG_AUTO
57357 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
57358 + help
57359 + If you say Y here, tasks started prior to init will be exempted from
57360 + grsecurity's chroot restrictions. This option is mainly meant to
57361 + resolve Plymouth's performing privileged operations unnecessarily
57362 + in a chroot.
57363 +
57364 +endmenu
57365 +menu "Kernel Auditing"
57366 +depends on GRKERNSEC
57367 +
57368 +config GRKERNSEC_AUDIT_GROUP
57369 + bool "Single group for auditing"
57370 + help
57371 + If you say Y here, the exec and chdir logging features will only operate
57372 + on a group you specify. This option is recommended if you only want to
57373 + watch certain users instead of having a large amount of logs from the
57374 + entire system. If the sysctl option is enabled, a sysctl option with
57375 + name "audit_group" is created.
57376 +
57377 +config GRKERNSEC_AUDIT_GID
57378 + int "GID for auditing"
57379 + depends on GRKERNSEC_AUDIT_GROUP
57380 + default 1007
57381 +
57382 +config GRKERNSEC_EXECLOG
57383 + bool "Exec logging"
57384 + help
57385 + If you say Y here, all execve() calls will be logged (since the
57386 + other exec*() calls are frontends to execve(), all execution
57387 + will be logged). Useful for shell-servers that like to keep track
57388 + of their users. If the sysctl option is enabled, a sysctl option with
57389 + name "exec_logging" is created.
57390 + WARNING: This option when enabled will produce a LOT of logs, especially
57391 + on an active system.
57392 +
57393 +config GRKERNSEC_RESLOG
57394 + bool "Resource logging"
57395 + default y if GRKERNSEC_CONFIG_AUTO
57396 + help
57397 + If you say Y here, all attempts to overstep resource limits will
57398 + be logged with the resource name, the requested size, and the current
57399 + limit. It is highly recommended that you say Y here. If the sysctl
57400 + option is enabled, a sysctl option with name "resource_logging" is
57401 + created. If the RBAC system is enabled, the sysctl value is ignored.
57402 +
57403 +config GRKERNSEC_CHROOT_EXECLOG
57404 + bool "Log execs within chroot"
57405 + help
57406 + If you say Y here, all executions inside a chroot jail will be logged
57407 + to syslog. This can cause a large amount of logs if certain
57408 + applications (eg. djb's daemontools) are installed on the system, and
57409 + is therefore left as an option. If the sysctl option is enabled, a
57410 + sysctl option with name "chroot_execlog" is created.
57411 +
57412 +config GRKERNSEC_AUDIT_PTRACE
57413 + bool "Ptrace logging"
57414 + help
57415 + If you say Y here, all attempts to attach to a process via ptrace
57416 + will be logged. If the sysctl option is enabled, a sysctl option
57417 + with name "audit_ptrace" is created.
57418 +
57419 +config GRKERNSEC_AUDIT_CHDIR
57420 + bool "Chdir logging"
57421 + help
57422 + If you say Y here, all chdir() calls will be logged. If the sysctl
57423 + option is enabled, a sysctl option with name "audit_chdir" is created.
57424 +
57425 +config GRKERNSEC_AUDIT_MOUNT
57426 + bool "(Un)Mount logging"
57427 + help
57428 + If you say Y here, all mounts and unmounts will be logged. If the
57429 + sysctl option is enabled, a sysctl option with name "audit_mount" is
57430 + created.
57431 +
57432 +config GRKERNSEC_SIGNAL
57433 + bool "Signal logging"
57434 + default y if GRKERNSEC_CONFIG_AUTO
57435 + help
57436 + If you say Y here, certain important signals will be logged, such as
57437 + SIGSEGV, which will as a result inform you of when a error in a program
57438 + occurred, which in some cases could mean a possible exploit attempt.
57439 + If the sysctl option is enabled, a sysctl option with name
57440 + "signal_logging" is created.
57441 +
57442 +config GRKERNSEC_FORKFAIL
57443 + bool "Fork failure logging"
57444 + help
57445 + If you say Y here, all failed fork() attempts will be logged.
57446 + This could suggest a fork bomb, or someone attempting to overstep
57447 + their process limit. If the sysctl option is enabled, a sysctl option
57448 + with name "forkfail_logging" is created.
57449 +
57450 +config GRKERNSEC_TIME
57451 + bool "Time change logging"
57452 + default y if GRKERNSEC_CONFIG_AUTO
57453 + help
57454 + If you say Y here, any changes of the system clock will be logged.
57455 + If the sysctl option is enabled, a sysctl option with name
57456 + "timechange_logging" is created.
57457 +
57458 +config GRKERNSEC_PROC_IPADDR
57459 + bool "/proc/<pid>/ipaddr support"
57460 + default y if GRKERNSEC_CONFIG_AUTO
57461 + help
57462 + If you say Y here, a new entry will be added to each /proc/<pid>
57463 + directory that contains the IP address of the person using the task.
57464 + The IP is carried across local TCP and AF_UNIX stream sockets.
57465 + This information can be useful for IDS/IPSes to perform remote response
57466 + to a local attack. The entry is readable by only the owner of the
57467 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
57468 + the RBAC system), and thus does not create privacy concerns.
57469 +
57470 +config GRKERNSEC_RWXMAP_LOG
57471 + bool 'Denied RWX mmap/mprotect logging'
57472 + default y if GRKERNSEC_CONFIG_AUTO
57473 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
57474 + help
57475 + If you say Y here, calls to mmap() and mprotect() with explicit
57476 + usage of PROT_WRITE and PROT_EXEC together will be logged when
57477 + denied by the PAX_MPROTECT feature. If the sysctl option is
57478 + enabled, a sysctl option with name "rwxmap_logging" is created.
57479 +
57480 +config GRKERNSEC_AUDIT_TEXTREL
57481 + bool 'ELF text relocations logging (READ HELP)'
57482 + depends on PAX_MPROTECT
57483 + help
57484 + If you say Y here, text relocations will be logged with the filename
57485 + of the offending library or binary. The purpose of the feature is
57486 + to help Linux distribution developers get rid of libraries and
57487 + binaries that need text relocations which hinder the future progress
57488 + of PaX. Only Linux distribution developers should say Y here, and
57489 + never on a production machine, as this option creates an information
57490 + leak that could aid an attacker in defeating the randomization of
57491 + a single memory region. If the sysctl option is enabled, a sysctl
57492 + option with name "audit_textrel" is created.
57493 +
57494 +endmenu
57495 +
57496 +menu "Executable Protections"
57497 +depends on GRKERNSEC
57498 +
57499 +config GRKERNSEC_DMESG
57500 + bool "Dmesg(8) restriction"
57501 + default y if GRKERNSEC_CONFIG_AUTO
57502 + help
57503 + If you say Y here, non-root users will not be able to use dmesg(8)
57504 + to view the contents of the kernel's circular log buffer.
57505 + The kernel's log buffer often contains kernel addresses and other
57506 + identifying information useful to an attacker in fingerprinting a
57507 + system for a targeted exploit.
57508 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
57509 + created.
57510 +
57511 +config GRKERNSEC_HARDEN_PTRACE
57512 + bool "Deter ptrace-based process snooping"
57513 + default y if GRKERNSEC_CONFIG_AUTO
57514 + help
57515 + If you say Y here, TTY sniffers and other malicious monitoring
57516 + programs implemented through ptrace will be defeated. If you
57517 + have been using the RBAC system, this option has already been
57518 + enabled for several years for all users, with the ability to make
57519 + fine-grained exceptions.
57520 +
57521 + This option only affects the ability of non-root users to ptrace
57522 + processes that are not a descendent of the ptracing process.
57523 + This means that strace ./binary and gdb ./binary will still work,
57524 + but attaching to arbitrary processes will not. If the sysctl
57525 + option is enabled, a sysctl option with name "harden_ptrace" is
57526 + created.
57527 +
57528 +config GRKERNSEC_PTRACE_READEXEC
57529 + bool "Require read access to ptrace sensitive binaries"
57530 + default y if GRKERNSEC_CONFIG_AUTO
57531 + help
57532 + If you say Y here, unprivileged users will not be able to ptrace unreadable
57533 + binaries. This option is useful in environments that
57534 + remove the read bits (e.g. file mode 4711) from suid binaries to
57535 + prevent infoleaking of their contents. This option adds
57536 + consistency to the use of that file mode, as the binary could normally
57537 + be read out when run without privileges while ptracing.
57538 +
57539 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
57540 + is created.
57541 +
57542 +config GRKERNSEC_SETXID
57543 + bool "Enforce consistent multithreaded privileges"
57544 + default y if GRKERNSEC_CONFIG_AUTO
57545 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
57546 + help
57547 + If you say Y here, a change from a root uid to a non-root uid
57548 + in a multithreaded application will cause the resulting uids,
57549 + gids, supplementary groups, and capabilities in that thread
57550 + to be propagated to the other threads of the process. In most
57551 + cases this is unnecessary, as glibc will emulate this behavior
57552 + on behalf of the application. Other libcs do not act in the
57553 + same way, allowing the other threads of the process to continue
57554 + running with root privileges. If the sysctl option is enabled,
57555 + a sysctl option with name "consistent_setxid" is created.
57556 +
57557 +config GRKERNSEC_TPE
57558 + bool "Trusted Path Execution (TPE)"
57559 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57560 + help
57561 + If you say Y here, you will be able to choose a gid to add to the
57562 + supplementary groups of users you want to mark as "untrusted."
57563 + These users will not be able to execute any files that are not in
57564 + root-owned directories writable only by root. If the sysctl option
57565 + is enabled, a sysctl option with name "tpe" is created.
57566 +
57567 +config GRKERNSEC_TPE_ALL
57568 + bool "Partially restrict all non-root users"
57569 + depends on GRKERNSEC_TPE
57570 + help
57571 + If you say Y here, all non-root users will be covered under
57572 + a weaker TPE restriction. This is separate from, and in addition to,
57573 + the main TPE options that you have selected elsewhere. Thus, if a
57574 + "trusted" GID is chosen, this restriction applies to even that GID.
57575 + Under this restriction, all non-root users will only be allowed to
57576 + execute files in directories they own that are not group or
57577 + world-writable, or in directories owned by root and writable only by
57578 + root. If the sysctl option is enabled, a sysctl option with name
57579 + "tpe_restrict_all" is created.
57580 +
57581 +config GRKERNSEC_TPE_INVERT
57582 + bool "Invert GID option"
57583 + depends on GRKERNSEC_TPE
57584 + help
57585 + If you say Y here, the group you specify in the TPE configuration will
57586 + decide what group TPE restrictions will be *disabled* for. This
57587 + option is useful if you want TPE restrictions to be applied to most
57588 + users on the system. If the sysctl option is enabled, a sysctl option
57589 + with name "tpe_invert" is created. Unlike other sysctl options, this
57590 + entry will default to on for backward-compatibility.
57591 +
57592 +config GRKERNSEC_TPE_GID
57593 + int
57594 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
57595 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
57596 +
57597 +config GRKERNSEC_TPE_UNTRUSTED_GID
57598 + int "GID for TPE-untrusted users"
57599 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
57600 + default 1005
57601 + help
57602 + Setting this GID determines what group TPE restrictions will be
57603 + *enabled* for. If the sysctl option is enabled, a sysctl option
57604 + with name "tpe_gid" is created.
57605 +
57606 +config GRKERNSEC_TPE_TRUSTED_GID
57607 + int "GID for TPE-trusted users"
57608 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
57609 + default 1005
57610 + help
57611 + Setting this GID determines what group TPE restrictions will be
57612 + *disabled* for. If the sysctl option is enabled, a sysctl option
57613 + with name "tpe_gid" is created.
57614 +
57615 +endmenu
57616 +menu "Network Protections"
57617 +depends on GRKERNSEC
57618 +
57619 +config GRKERNSEC_RANDNET
57620 + bool "Larger entropy pools"
57621 + default y if GRKERNSEC_CONFIG_AUTO
57622 + help
57623 + If you say Y here, the entropy pools used for many features of Linux
57624 + and grsecurity will be doubled in size. Since several grsecurity
57625 + features use additional randomness, it is recommended that you say Y
57626 + here. Saying Y here has a similar effect as modifying
57627 + /proc/sys/kernel/random/poolsize.
57628 +
57629 +config GRKERNSEC_BLACKHOLE
57630 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
57631 + default y if GRKERNSEC_CONFIG_AUTO
57632 + depends on NET
57633 + help
57634 + If you say Y here, neither TCP resets nor ICMP
57635 + destination-unreachable packets will be sent in response to packets
57636 + sent to ports for which no associated listening process exists.
57637 + This feature supports both IPV4 and IPV6 and exempts the
57638 + loopback interface from blackholing. Enabling this feature
57639 + makes a host more resilient to DoS attacks and reduces network
57640 + visibility against scanners.
57641 +
57642 + The blackhole feature as-implemented is equivalent to the FreeBSD
57643 + blackhole feature, as it prevents RST responses to all packets, not
57644 + just SYNs. Under most application behavior this causes no
57645 + problems, but applications (like haproxy) may not close certain
57646 + connections in a way that cleanly terminates them on the remote
57647 + end, leaving the remote host in LAST_ACK state. Because of this
57648 + side-effect and to prevent intentional LAST_ACK DoSes, this
57649 + feature also adds automatic mitigation against such attacks.
57650 + The mitigation drastically reduces the amount of time a socket
57651 + can spend in LAST_ACK state. If you're using haproxy and not
57652 + all servers it connects to have this option enabled, consider
57653 + disabling this feature on the haproxy host.
57654 +
57655 + If the sysctl option is enabled, two sysctl options with names
57656 + "ip_blackhole" and "lastack_retries" will be created.
57657 + While "ip_blackhole" takes the standard zero/non-zero on/off
57658 + toggle, "lastack_retries" uses the same kinds of values as
57659 + "tcp_retries1" and "tcp_retries2". The default value of 4
57660 + prevents a socket from lasting more than 45 seconds in LAST_ACK
57661 + state.
57662 +
57663 +config GRKERNSEC_NO_SIMULT_CONNECT
57664 + bool "Disable TCP Simultaneous Connect"
57665 + default y if GRKERNSEC_CONFIG_AUTO
57666 + depends on NET
57667 + help
57668 + If you say Y here, a feature by Willy Tarreau will be enabled that
57669 + removes a weakness in Linux's strict implementation of TCP that
57670 + allows two clients to connect to each other without either entering
57671 + a listening state. The weakness allows an attacker to easily prevent
57672 + a client from connecting to a known server provided the source port
57673 + for the connection is guessed correctly.
57674 +
57675 + As the weakness could be used to prevent an antivirus or IPS from
57676 + fetching updates, or prevent an SSL gateway from fetching a CRL,
57677 + it should be eliminated by enabling this option. Though Linux is
57678 + one of few operating systems supporting simultaneous connect, it
57679 + has no legitimate use in practice and is rarely supported by firewalls.
57680 +
57681 +config GRKERNSEC_SOCKET
57682 + bool "Socket restrictions"
57683 + depends on NET
57684 + help
57685 + If you say Y here, you will be able to choose from several options.
57686 + If you assign a GID on your system and add it to the supplementary
57687 + groups of users you want to restrict socket access to, this patch
57688 + will perform up to three things, based on the option(s) you choose.
57689 +
57690 +config GRKERNSEC_SOCKET_ALL
57691 + bool "Deny any sockets to group"
57692 + depends on GRKERNSEC_SOCKET
57693 + help
57694 + If you say Y here, you will be able to choose a GID of whose users will
57695 + be unable to connect to other hosts from your machine or run server
57696 + applications from your machine. If the sysctl option is enabled, a
57697 + sysctl option with name "socket_all" is created.
57698 +
57699 +config GRKERNSEC_SOCKET_ALL_GID
57700 + int "GID to deny all sockets for"
57701 + depends on GRKERNSEC_SOCKET_ALL
57702 + default 1004
57703 + help
57704 + Here you can choose the GID to disable socket access for. Remember to
57705 + add the users you want socket access disabled for to the GID
57706 + specified here. If the sysctl option is enabled, a sysctl option
57707 + with name "socket_all_gid" is created.
57708 +
57709 +config GRKERNSEC_SOCKET_CLIENT
57710 + bool "Deny client sockets to group"
57711 + depends on GRKERNSEC_SOCKET
57712 + help
57713 + If you say Y here, you will be able to choose a GID of whose users will
57714 + be unable to connect to other hosts from your machine, but will be
57715 + able to run servers. If this option is enabled, all users in the group
57716 + you specify will have to use passive mode when initiating ftp transfers
57717 + from the shell on your machine. If the sysctl option is enabled, a
57718 + sysctl option with name "socket_client" is created.
57719 +
57720 +config GRKERNSEC_SOCKET_CLIENT_GID
57721 + int "GID to deny client sockets for"
57722 + depends on GRKERNSEC_SOCKET_CLIENT
57723 + default 1003
57724 + help
57725 + Here you can choose the GID to disable client socket access for.
57726 + Remember to add the users you want client socket access disabled for to
57727 + the GID specified here. If the sysctl option is enabled, a sysctl
57728 + option with name "socket_client_gid" is created.
57729 +
57730 +config GRKERNSEC_SOCKET_SERVER
57731 + bool "Deny server sockets to group"
57732 + depends on GRKERNSEC_SOCKET
57733 + help
57734 + If you say Y here, you will be able to choose a GID of whose users will
57735 + be unable to run server applications from your machine. If the sysctl
57736 + option is enabled, a sysctl option with name "socket_server" is created.
57737 +
57738 +config GRKERNSEC_SOCKET_SERVER_GID
57739 + int "GID to deny server sockets for"
57740 + depends on GRKERNSEC_SOCKET_SERVER
57741 + default 1002
57742 + help
57743 + Here you can choose the GID to disable server socket access for.
57744 + Remember to add the users you want server socket access disabled for to
57745 + the GID specified here. If the sysctl option is enabled, a sysctl
57746 + option with name "socket_server_gid" is created.
57747 +
57748 +endmenu
57749 +menu "Sysctl Support"
57750 +depends on GRKERNSEC && SYSCTL
57751 +
57752 +config GRKERNSEC_SYSCTL
57753 + bool "Sysctl support"
57754 + default y if GRKERNSEC_CONFIG_AUTO
57755 + help
57756 + If you say Y here, you will be able to change the options that
57757 + grsecurity runs with at bootup, without having to recompile your
57758 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
57759 + to enable (1) or disable (0) various features. All the sysctl entries
57760 + are mutable until the "grsec_lock" entry is set to a non-zero value.
57761 + All features enabled in the kernel configuration are disabled at boot
57762 + if you do not say Y to the "Turn on features by default" option.
57763 + All options should be set at startup, and the grsec_lock entry should
57764 + be set to a non-zero value after all the options are set.
57765 + *THIS IS EXTREMELY IMPORTANT*
57766 +
57767 +config GRKERNSEC_SYSCTL_DISTRO
57768 + bool "Extra sysctl support for distro makers (READ HELP)"
57769 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
57770 + help
57771 + If you say Y here, additional sysctl options will be created
57772 + for features that affect processes running as root. Therefore,
57773 + it is critical when using this option that the grsec_lock entry be
57774 + enabled after boot. Only distros with prebuilt kernel packages
57775 + with this option enabled that can ensure grsec_lock is enabled
57776 + after boot should use this option.
57777 + *Failure to set grsec_lock after boot makes all grsec features
57778 + this option covers useless*
57779 +
57780 + Currently this option creates the following sysctl entries:
57781 + "Disable Privileged I/O": "disable_priv_io"
57782 +
57783 +config GRKERNSEC_SYSCTL_ON
57784 + bool "Turn on features by default"
57785 + default y if GRKERNSEC_CONFIG_AUTO
57786 + depends on GRKERNSEC_SYSCTL
57787 + help
57788 + If you say Y here, instead of having all features enabled in the
57789 + kernel configuration disabled at boot time, the features will be
57790 + enabled at boot time. It is recommended you say Y here unless
57791 + there is some reason you would want all sysctl-tunable features to
57792 + be disabled by default. As mentioned elsewhere, it is important
57793 + to enable the grsec_lock entry once you have finished modifying
57794 + the sysctl entries.
57795 +
57796 +endmenu
57797 +menu "Logging Options"
57798 +depends on GRKERNSEC
57799 +
57800 +config GRKERNSEC_FLOODTIME
57801 + int "Seconds in between log messages (minimum)"
57802 + default 10
57803 + help
57804 + This option allows you to enforce the number of seconds between
57805 + grsecurity log messages. The default should be suitable for most
57806 + people, however, if you choose to change it, choose a value small enough
57807 + to allow informative logs to be produced, but large enough to
57808 + prevent flooding.
57809 +
57810 +config GRKERNSEC_FLOODBURST
57811 + int "Number of messages in a burst (maximum)"
57812 + default 6
57813 + help
57814 + This option allows you to choose the maximum number of messages allowed
57815 + within the flood time interval you chose in a separate option. The
57816 + default should be suitable for most people, however if you find that
57817 + many of your logs are being interpreted as flooding, you may want to
57818 + raise this value.
57819 +
57820 +endmenu
57821 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
57822 new file mode 100644
57823 index 0000000..1b9afa9
57824 --- /dev/null
57825 +++ b/grsecurity/Makefile
57826 @@ -0,0 +1,38 @@
57827 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
57828 +# during 2001-2009 it has been completely redesigned by Brad Spengler
57829 +# into an RBAC system
57830 +#
57831 +# All code in this directory and various hooks inserted throughout the kernel
57832 +# are copyright Brad Spengler - Open Source Security, Inc., and released
57833 +# under the GPL v2 or higher
57834 +
57835 +KBUILD_CFLAGS += -Werror
57836 +
57837 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
57838 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
57839 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
57840 +
57841 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
57842 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
57843 + gracl_learn.o grsec_log.o
57844 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
57845 +
57846 +ifdef CONFIG_NET
57847 +obj-y += grsec_sock.o
57848 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
57849 +endif
57850 +
57851 +ifndef CONFIG_GRKERNSEC
57852 +obj-y += grsec_disabled.o
57853 +endif
57854 +
57855 +ifdef CONFIG_GRKERNSEC_HIDESYM
57856 +extra-y := grsec_hidesym.o
57857 +$(obj)/grsec_hidesym.o:
57858 + @-chmod -f 500 /boot
57859 + @-chmod -f 500 /lib/modules
57860 + @-chmod -f 500 /lib64/modules
57861 + @-chmod -f 500 /lib32/modules
57862 + @-chmod -f 700 .
57863 + @echo ' grsec: protected kernel image paths'
57864 +endif
57865 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
57866 new file mode 100644
57867 index 0000000..1248ee0
57868 --- /dev/null
57869 +++ b/grsecurity/gracl.c
57870 @@ -0,0 +1,4073 @@
57871 +#include <linux/kernel.h>
57872 +#include <linux/module.h>
57873 +#include <linux/sched.h>
57874 +#include <linux/mm.h>
57875 +#include <linux/file.h>
57876 +#include <linux/fs.h>
57877 +#include <linux/namei.h>
57878 +#include <linux/mount.h>
57879 +#include <linux/tty.h>
57880 +#include <linux/proc_fs.h>
57881 +#include <linux/lglock.h>
57882 +#include <linux/slab.h>
57883 +#include <linux/vmalloc.h>
57884 +#include <linux/types.h>
57885 +#include <linux/sysctl.h>
57886 +#include <linux/netdevice.h>
57887 +#include <linux/ptrace.h>
57888 +#include <linux/gracl.h>
57889 +#include <linux/gralloc.h>
57890 +#include <linux/security.h>
57891 +#include <linux/grinternal.h>
57892 +#include <linux/pid_namespace.h>
57893 +#include <linux/stop_machine.h>
57894 +#include <linux/fdtable.h>
57895 +#include <linux/percpu.h>
57896 +#include <linux/lglock.h>
57897 +#include <linux/hugetlb.h>
57898 +#include <linux/posix-timers.h>
57899 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
57900 +#include <linux/magic.h>
57901 +#include <linux/pagemap.h>
57902 +#include "../fs/btrfs/async-thread.h"
57903 +#include "../fs/btrfs/ctree.h"
57904 +#include "../fs/btrfs/btrfs_inode.h"
57905 +#endif
57906 +#include "../fs/mount.h"
57907 +
57908 +#include <asm/uaccess.h>
57909 +#include <asm/errno.h>
57910 +#include <asm/mman.h>
57911 +
57912 +extern struct lglock vfsmount_lock;
57913 +
57914 +static struct acl_role_db acl_role_set;
57915 +static struct name_db name_set;
57916 +static struct inodev_db inodev_set;
57917 +
57918 +/* for keeping track of userspace pointers used for subjects, so we
57919 + can share references in the kernel as well
57920 +*/
57921 +
57922 +static struct path real_root;
57923 +
57924 +static struct acl_subj_map_db subj_map_set;
57925 +
57926 +static struct acl_role_label *default_role;
57927 +
57928 +static struct acl_role_label *role_list;
57929 +
57930 +static u16 acl_sp_role_value;
57931 +
57932 +extern char *gr_shared_page[4];
57933 +static DEFINE_MUTEX(gr_dev_mutex);
57934 +DEFINE_RWLOCK(gr_inode_lock);
57935 +
57936 +struct gr_arg *gr_usermode;
57937 +
57938 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
57939 +
57940 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
57941 +extern void gr_clear_learn_entries(void);
57942 +
57943 +unsigned char *gr_system_salt;
57944 +unsigned char *gr_system_sum;
57945 +
57946 +static struct sprole_pw **acl_special_roles = NULL;
57947 +static __u16 num_sprole_pws = 0;
57948 +
57949 +static struct acl_role_label *kernel_role = NULL;
57950 +
57951 +static unsigned int gr_auth_attempts = 0;
57952 +static unsigned long gr_auth_expires = 0UL;
57953 +
57954 +#ifdef CONFIG_NET
57955 +extern struct vfsmount *sock_mnt;
57956 +#endif
57957 +
57958 +extern struct vfsmount *pipe_mnt;
57959 +extern struct vfsmount *shm_mnt;
57960 +
57961 +#ifdef CONFIG_HUGETLBFS
57962 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57963 +#endif
57964 +
57965 +static struct acl_object_label *fakefs_obj_rw;
57966 +static struct acl_object_label *fakefs_obj_rwx;
57967 +
57968 +extern int gr_init_uidset(void);
57969 +extern void gr_free_uidset(void);
57970 +extern void gr_remove_uid(uid_t uid);
57971 +extern int gr_find_uid(uid_t uid);
57972 +
57973 +__inline__ int
57974 +gr_acl_is_enabled(void)
57975 +{
57976 + return (gr_status & GR_READY);
57977 +}
57978 +
57979 +static inline dev_t __get_dev(const struct dentry *dentry)
57980 +{
57981 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
57982 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
57983 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
57984 + else
57985 +#endif
57986 + return dentry->d_sb->s_dev;
57987 +}
57988 +
57989 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
57990 +{
57991 + return __get_dev(dentry);
57992 +}
57993 +
57994 +static char gr_task_roletype_to_char(struct task_struct *task)
57995 +{
57996 + switch (task->role->roletype &
57997 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
57998 + GR_ROLE_SPECIAL)) {
57999 + case GR_ROLE_DEFAULT:
58000 + return 'D';
58001 + case GR_ROLE_USER:
58002 + return 'U';
58003 + case GR_ROLE_GROUP:
58004 + return 'G';
58005 + case GR_ROLE_SPECIAL:
58006 + return 'S';
58007 + }
58008 +
58009 + return 'X';
58010 +}
58011 +
58012 +char gr_roletype_to_char(void)
58013 +{
58014 + return gr_task_roletype_to_char(current);
58015 +}
58016 +
58017 +__inline__ int
58018 +gr_acl_tpe_check(void)
58019 +{
58020 + if (unlikely(!(gr_status & GR_READY)))
58021 + return 0;
58022 + if (current->role->roletype & GR_ROLE_TPE)
58023 + return 1;
58024 + else
58025 + return 0;
58026 +}
58027 +
58028 +int
58029 +gr_handle_rawio(const struct inode *inode)
58030 +{
58031 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
58032 + if (inode && S_ISBLK(inode->i_mode) &&
58033 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
58034 + !capable(CAP_SYS_RAWIO))
58035 + return 1;
58036 +#endif
58037 + return 0;
58038 +}
58039 +
58040 +static int
58041 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
58042 +{
58043 + if (likely(lena != lenb))
58044 + return 0;
58045 +
58046 + return !memcmp(a, b, lena);
58047 +}
58048 +
58049 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
58050 +{
58051 + *buflen -= namelen;
58052 + if (*buflen < 0)
58053 + return -ENAMETOOLONG;
58054 + *buffer -= namelen;
58055 + memcpy(*buffer, str, namelen);
58056 + return 0;
58057 +}
58058 +
58059 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
58060 +{
58061 + return prepend(buffer, buflen, name->name, name->len);
58062 +}
58063 +
58064 +static int prepend_path(const struct path *path, struct path *root,
58065 + char **buffer, int *buflen)
58066 +{
58067 + struct dentry *dentry = path->dentry;
58068 + struct vfsmount *vfsmnt = path->mnt;
58069 + struct mount *mnt = real_mount(vfsmnt);
58070 + bool slash = false;
58071 + int error = 0;
58072 +
58073 + while (dentry != root->dentry || vfsmnt != root->mnt) {
58074 + struct dentry * parent;
58075 +
58076 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
58077 + /* Global root? */
58078 + if (!mnt_has_parent(mnt)) {
58079 + goto out;
58080 + }
58081 + dentry = mnt->mnt_mountpoint;
58082 + mnt = mnt->mnt_parent;
58083 + vfsmnt = &mnt->mnt;
58084 + continue;
58085 + }
58086 + parent = dentry->d_parent;
58087 + prefetch(parent);
58088 + spin_lock(&dentry->d_lock);
58089 + error = prepend_name(buffer, buflen, &dentry->d_name);
58090 + spin_unlock(&dentry->d_lock);
58091 + if (!error)
58092 + error = prepend(buffer, buflen, "/", 1);
58093 + if (error)
58094 + break;
58095 +
58096 + slash = true;
58097 + dentry = parent;
58098 + }
58099 +
58100 +out:
58101 + if (!error && !slash)
58102 + error = prepend(buffer, buflen, "/", 1);
58103 +
58104 + return error;
58105 +}
58106 +
58107 +/* this must be called with vfsmount_lock and rename_lock held */
58108 +
58109 +static char *__our_d_path(const struct path *path, struct path *root,
58110 + char *buf, int buflen)
58111 +{
58112 + char *res = buf + buflen;
58113 + int error;
58114 +
58115 + prepend(&res, &buflen, "\0", 1);
58116 + error = prepend_path(path, root, &res, &buflen);
58117 + if (error)
58118 + return ERR_PTR(error);
58119 +
58120 + return res;
58121 +}
58122 +
58123 +static char *
58124 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
58125 +{
58126 + char *retval;
58127 +
58128 + retval = __our_d_path(path, root, buf, buflen);
58129 + if (unlikely(IS_ERR(retval)))
58130 + retval = strcpy(buf, "<path too long>");
58131 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
58132 + retval[1] = '\0';
58133 +
58134 + return retval;
58135 +}
58136 +
58137 +static char *
58138 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58139 + char *buf, int buflen)
58140 +{
58141 + struct path path;
58142 + char *res;
58143 +
58144 + path.dentry = (struct dentry *)dentry;
58145 + path.mnt = (struct vfsmount *)vfsmnt;
58146 +
58147 + /* we can use real_root.dentry, real_root.mnt, because this is only called
58148 + by the RBAC system */
58149 + res = gen_full_path(&path, &real_root, buf, buflen);
58150 +
58151 + return res;
58152 +}
58153 +
58154 +static char *
58155 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58156 + char *buf, int buflen)
58157 +{
58158 + char *res;
58159 + struct path path;
58160 + struct path root;
58161 + struct task_struct *reaper = init_pid_ns.child_reaper;
58162 +
58163 + path.dentry = (struct dentry *)dentry;
58164 + path.mnt = (struct vfsmount *)vfsmnt;
58165 +
58166 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
58167 + get_fs_root(reaper->fs, &root);
58168 +
58169 + br_read_lock(&vfsmount_lock);
58170 + write_seqlock(&rename_lock);
58171 + res = gen_full_path(&path, &root, buf, buflen);
58172 + write_sequnlock(&rename_lock);
58173 + br_read_unlock(&vfsmount_lock);
58174 +
58175 + path_put(&root);
58176 + return res;
58177 +}
58178 +
58179 +static char *
58180 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58181 +{
58182 + char *ret;
58183 + br_read_lock(&vfsmount_lock);
58184 + write_seqlock(&rename_lock);
58185 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58186 + PAGE_SIZE);
58187 + write_sequnlock(&rename_lock);
58188 + br_read_unlock(&vfsmount_lock);
58189 + return ret;
58190 +}
58191 +
58192 +static char *
58193 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58194 +{
58195 + char *ret;
58196 + char *buf;
58197 + int buflen;
58198 +
58199 + br_read_lock(&vfsmount_lock);
58200 + write_seqlock(&rename_lock);
58201 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
58202 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
58203 + buflen = (int)(ret - buf);
58204 + if (buflen >= 5)
58205 + prepend(&ret, &buflen, "/proc", 5);
58206 + else
58207 + ret = strcpy(buf, "<path too long>");
58208 + write_sequnlock(&rename_lock);
58209 + br_read_unlock(&vfsmount_lock);
58210 + return ret;
58211 +}
58212 +
58213 +char *
58214 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
58215 +{
58216 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58217 + PAGE_SIZE);
58218 +}
58219 +
58220 +char *
58221 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
58222 +{
58223 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
58224 + PAGE_SIZE);
58225 +}
58226 +
58227 +char *
58228 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
58229 +{
58230 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
58231 + PAGE_SIZE);
58232 +}
58233 +
58234 +char *
58235 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
58236 +{
58237 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
58238 + PAGE_SIZE);
58239 +}
58240 +
58241 +char *
58242 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
58243 +{
58244 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
58245 + PAGE_SIZE);
58246 +}
58247 +
58248 +__inline__ __u32
58249 +to_gr_audit(const __u32 reqmode)
58250 +{
58251 + /* masks off auditable permission flags, then shifts them to create
58252 + auditing flags, and adds the special case of append auditing if
58253 + we're requesting write */
58254 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
58255 +}
58256 +
58257 +struct acl_subject_label *
58258 +lookup_subject_map(const struct acl_subject_label *userp)
58259 +{
58260 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
58261 + struct subject_map *match;
58262 +
58263 + match = subj_map_set.s_hash[index];
58264 +
58265 + while (match && match->user != userp)
58266 + match = match->next;
58267 +
58268 + if (match != NULL)
58269 + return match->kernel;
58270 + else
58271 + return NULL;
58272 +}
58273 +
58274 +static void
58275 +insert_subj_map_entry(struct subject_map *subjmap)
58276 +{
58277 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
58278 + struct subject_map **curr;
58279 +
58280 + subjmap->prev = NULL;
58281 +
58282 + curr = &subj_map_set.s_hash[index];
58283 + if (*curr != NULL)
58284 + (*curr)->prev = subjmap;
58285 +
58286 + subjmap->next = *curr;
58287 + *curr = subjmap;
58288 +
58289 + return;
58290 +}
58291 +
58292 +static struct acl_role_label *
58293 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
58294 + const gid_t gid)
58295 +{
58296 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
58297 + struct acl_role_label *match;
58298 + struct role_allowed_ip *ipp;
58299 + unsigned int x;
58300 + u32 curr_ip = task->signal->curr_ip;
58301 +
58302 + task->signal->saved_ip = curr_ip;
58303 +
58304 + match = acl_role_set.r_hash[index];
58305 +
58306 + while (match) {
58307 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
58308 + for (x = 0; x < match->domain_child_num; x++) {
58309 + if (match->domain_children[x] == uid)
58310 + goto found;
58311 + }
58312 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
58313 + break;
58314 + match = match->next;
58315 + }
58316 +found:
58317 + if (match == NULL) {
58318 + try_group:
58319 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
58320 + match = acl_role_set.r_hash[index];
58321 +
58322 + while (match) {
58323 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
58324 + for (x = 0; x < match->domain_child_num; x++) {
58325 + if (match->domain_children[x] == gid)
58326 + goto found2;
58327 + }
58328 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
58329 + break;
58330 + match = match->next;
58331 + }
58332 +found2:
58333 + if (match == NULL)
58334 + match = default_role;
58335 + if (match->allowed_ips == NULL)
58336 + return match;
58337 + else {
58338 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58339 + if (likely
58340 + ((ntohl(curr_ip) & ipp->netmask) ==
58341 + (ntohl(ipp->addr) & ipp->netmask)))
58342 + return match;
58343 + }
58344 + match = default_role;
58345 + }
58346 + } else if (match->allowed_ips == NULL) {
58347 + return match;
58348 + } else {
58349 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58350 + if (likely
58351 + ((ntohl(curr_ip) & ipp->netmask) ==
58352 + (ntohl(ipp->addr) & ipp->netmask)))
58353 + return match;
58354 + }
58355 + goto try_group;
58356 + }
58357 +
58358 + return match;
58359 +}
58360 +
58361 +struct acl_subject_label *
58362 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
58363 + const struct acl_role_label *role)
58364 +{
58365 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58366 + struct acl_subject_label *match;
58367 +
58368 + match = role->subj_hash[index];
58369 +
58370 + while (match && (match->inode != ino || match->device != dev ||
58371 + (match->mode & GR_DELETED))) {
58372 + match = match->next;
58373 + }
58374 +
58375 + if (match && !(match->mode & GR_DELETED))
58376 + return match;
58377 + else
58378 + return NULL;
58379 +}
58380 +
58381 +struct acl_subject_label *
58382 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
58383 + const struct acl_role_label *role)
58384 +{
58385 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58386 + struct acl_subject_label *match;
58387 +
58388 + match = role->subj_hash[index];
58389 +
58390 + while (match && (match->inode != ino || match->device != dev ||
58391 + !(match->mode & GR_DELETED))) {
58392 + match = match->next;
58393 + }
58394 +
58395 + if (match && (match->mode & GR_DELETED))
58396 + return match;
58397 + else
58398 + return NULL;
58399 +}
58400 +
58401 +static struct acl_object_label *
58402 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
58403 + const struct acl_subject_label *subj)
58404 +{
58405 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58406 + struct acl_object_label *match;
58407 +
58408 + match = subj->obj_hash[index];
58409 +
58410 + while (match && (match->inode != ino || match->device != dev ||
58411 + (match->mode & GR_DELETED))) {
58412 + match = match->next;
58413 + }
58414 +
58415 + if (match && !(match->mode & GR_DELETED))
58416 + return match;
58417 + else
58418 + return NULL;
58419 +}
58420 +
58421 +static struct acl_object_label *
58422 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
58423 + const struct acl_subject_label *subj)
58424 +{
58425 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58426 + struct acl_object_label *match;
58427 +
58428 + match = subj->obj_hash[index];
58429 +
58430 + while (match && (match->inode != ino || match->device != dev ||
58431 + !(match->mode & GR_DELETED))) {
58432 + match = match->next;
58433 + }
58434 +
58435 + if (match && (match->mode & GR_DELETED))
58436 + return match;
58437 +
58438 + match = subj->obj_hash[index];
58439 +
58440 + while (match && (match->inode != ino || match->device != dev ||
58441 + (match->mode & GR_DELETED))) {
58442 + match = match->next;
58443 + }
58444 +
58445 + if (match && !(match->mode & GR_DELETED))
58446 + return match;
58447 + else
58448 + return NULL;
58449 +}
58450 +
58451 +static struct name_entry *
58452 +lookup_name_entry(const char *name)
58453 +{
58454 + unsigned int len = strlen(name);
58455 + unsigned int key = full_name_hash(name, len);
58456 + unsigned int index = key % name_set.n_size;
58457 + struct name_entry *match;
58458 +
58459 + match = name_set.n_hash[index];
58460 +
58461 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
58462 + match = match->next;
58463 +
58464 + return match;
58465 +}
58466 +
58467 +static struct name_entry *
58468 +lookup_name_entry_create(const char *name)
58469 +{
58470 + unsigned int len = strlen(name);
58471 + unsigned int key = full_name_hash(name, len);
58472 + unsigned int index = key % name_set.n_size;
58473 + struct name_entry *match;
58474 +
58475 + match = name_set.n_hash[index];
58476 +
58477 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58478 + !match->deleted))
58479 + match = match->next;
58480 +
58481 + if (match && match->deleted)
58482 + return match;
58483 +
58484 + match = name_set.n_hash[index];
58485 +
58486 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58487 + match->deleted))
58488 + match = match->next;
58489 +
58490 + if (match && !match->deleted)
58491 + return match;
58492 + else
58493 + return NULL;
58494 +}
58495 +
58496 +static struct inodev_entry *
58497 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
58498 +{
58499 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
58500 + struct inodev_entry *match;
58501 +
58502 + match = inodev_set.i_hash[index];
58503 +
58504 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
58505 + match = match->next;
58506 +
58507 + return match;
58508 +}
58509 +
58510 +static void
58511 +insert_inodev_entry(struct inodev_entry *entry)
58512 +{
58513 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
58514 + inodev_set.i_size);
58515 + struct inodev_entry **curr;
58516 +
58517 + entry->prev = NULL;
58518 +
58519 + curr = &inodev_set.i_hash[index];
58520 + if (*curr != NULL)
58521 + (*curr)->prev = entry;
58522 +
58523 + entry->next = *curr;
58524 + *curr = entry;
58525 +
58526 + return;
58527 +}
58528 +
58529 +static void
58530 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
58531 +{
58532 + unsigned int index =
58533 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
58534 + struct acl_role_label **curr;
58535 + struct acl_role_label *tmp, *tmp2;
58536 +
58537 + curr = &acl_role_set.r_hash[index];
58538 +
58539 + /* simple case, slot is empty, just set it to our role */
58540 + if (*curr == NULL) {
58541 + *curr = role;
58542 + } else {
58543 + /* example:
58544 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
58545 + 2 -> 3
58546 + */
58547 + /* first check to see if we can already be reached via this slot */
58548 + tmp = *curr;
58549 + while (tmp && tmp != role)
58550 + tmp = tmp->next;
58551 + if (tmp == role) {
58552 + /* we don't need to add ourselves to this slot's chain */
58553 + return;
58554 + }
58555 + /* we need to add ourselves to this chain, two cases */
58556 + if (role->next == NULL) {
58557 + /* simple case, append the current chain to our role */
58558 + role->next = *curr;
58559 + *curr = role;
58560 + } else {
58561 + /* 1 -> 2 -> 3 -> 4
58562 + 2 -> 3 -> 4
58563 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
58564 + */
58565 + /* trickier case: walk our role's chain until we find
58566 + the role for the start of the current slot's chain */
58567 + tmp = role;
58568 + tmp2 = *curr;
58569 + while (tmp->next && tmp->next != tmp2)
58570 + tmp = tmp->next;
58571 + if (tmp->next == tmp2) {
58572 + /* from example above, we found 3, so just
58573 + replace this slot's chain with ours */
58574 + *curr = role;
58575 + } else {
58576 + /* we didn't find a subset of our role's chain
58577 + in the current slot's chain, so append their
58578 + chain to ours, and set us as the first role in
58579 + the slot's chain
58580 +
58581 + we could fold this case with the case above,
58582 + but making it explicit for clarity
58583 + */
58584 + tmp->next = tmp2;
58585 + *curr = role;
58586 + }
58587 + }
58588 + }
58589 +
58590 + return;
58591 +}
58592 +
58593 +static void
58594 +insert_acl_role_label(struct acl_role_label *role)
58595 +{
58596 + int i;
58597 +
58598 + if (role_list == NULL) {
58599 + role_list = role;
58600 + role->prev = NULL;
58601 + } else {
58602 + role->prev = role_list;
58603 + role_list = role;
58604 + }
58605 +
58606 + /* used for hash chains */
58607 + role->next = NULL;
58608 +
58609 + if (role->roletype & GR_ROLE_DOMAIN) {
58610 + for (i = 0; i < role->domain_child_num; i++)
58611 + __insert_acl_role_label(role, role->domain_children[i]);
58612 + } else
58613 + __insert_acl_role_label(role, role->uidgid);
58614 +}
58615 +
58616 +static int
58617 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
58618 +{
58619 + struct name_entry **curr, *nentry;
58620 + struct inodev_entry *ientry;
58621 + unsigned int len = strlen(name);
58622 + unsigned int key = full_name_hash(name, len);
58623 + unsigned int index = key % name_set.n_size;
58624 +
58625 + curr = &name_set.n_hash[index];
58626 +
58627 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
58628 + curr = &((*curr)->next);
58629 +
58630 + if (*curr != NULL)
58631 + return 1;
58632 +
58633 + nentry = acl_alloc(sizeof (struct name_entry));
58634 + if (nentry == NULL)
58635 + return 0;
58636 + ientry = acl_alloc(sizeof (struct inodev_entry));
58637 + if (ientry == NULL)
58638 + return 0;
58639 + ientry->nentry = nentry;
58640 +
58641 + nentry->key = key;
58642 + nentry->name = name;
58643 + nentry->inode = inode;
58644 + nentry->device = device;
58645 + nentry->len = len;
58646 + nentry->deleted = deleted;
58647 +
58648 + nentry->prev = NULL;
58649 + curr = &name_set.n_hash[index];
58650 + if (*curr != NULL)
58651 + (*curr)->prev = nentry;
58652 + nentry->next = *curr;
58653 + *curr = nentry;
58654 +
58655 + /* insert us into the table searchable by inode/dev */
58656 + insert_inodev_entry(ientry);
58657 +
58658 + return 1;
58659 +}
58660 +
58661 +static void
58662 +insert_acl_obj_label(struct acl_object_label *obj,
58663 + struct acl_subject_label *subj)
58664 +{
58665 + unsigned int index =
58666 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
58667 + struct acl_object_label **curr;
58668 +
58669 +
58670 + obj->prev = NULL;
58671 +
58672 + curr = &subj->obj_hash[index];
58673 + if (*curr != NULL)
58674 + (*curr)->prev = obj;
58675 +
58676 + obj->next = *curr;
58677 + *curr = obj;
58678 +
58679 + return;
58680 +}
58681 +
58682 +static void
58683 +insert_acl_subj_label(struct acl_subject_label *obj,
58684 + struct acl_role_label *role)
58685 +{
58686 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
58687 + struct acl_subject_label **curr;
58688 +
58689 + obj->prev = NULL;
58690 +
58691 + curr = &role->subj_hash[index];
58692 + if (*curr != NULL)
58693 + (*curr)->prev = obj;
58694 +
58695 + obj->next = *curr;
58696 + *curr = obj;
58697 +
58698 + return;
58699 +}
58700 +
58701 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
58702 +
58703 +static void *
58704 +create_table(__u32 * len, int elementsize)
58705 +{
58706 + unsigned int table_sizes[] = {
58707 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
58708 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
58709 + 4194301, 8388593, 16777213, 33554393, 67108859
58710 + };
58711 + void *newtable = NULL;
58712 + unsigned int pwr = 0;
58713 +
58714 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
58715 + table_sizes[pwr] <= *len)
58716 + pwr++;
58717 +
58718 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
58719 + return newtable;
58720 +
58721 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
58722 + newtable =
58723 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
58724 + else
58725 + newtable = vmalloc(table_sizes[pwr] * elementsize);
58726 +
58727 + *len = table_sizes[pwr];
58728 +
58729 + return newtable;
58730 +}
58731 +
58732 +static int
58733 +init_variables(const struct gr_arg *arg)
58734 +{
58735 + struct task_struct *reaper = init_pid_ns.child_reaper;
58736 + unsigned int stacksize;
58737 +
58738 + subj_map_set.s_size = arg->role_db.num_subjects;
58739 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
58740 + name_set.n_size = arg->role_db.num_objects;
58741 + inodev_set.i_size = arg->role_db.num_objects;
58742 +
58743 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
58744 + !name_set.n_size || !inodev_set.i_size)
58745 + return 1;
58746 +
58747 + if (!gr_init_uidset())
58748 + return 1;
58749 +
58750 + /* set up the stack that holds allocation info */
58751 +
58752 + stacksize = arg->role_db.num_pointers + 5;
58753 +
58754 + if (!acl_alloc_stack_init(stacksize))
58755 + return 1;
58756 +
58757 + /* grab reference for the real root dentry and vfsmount */
58758 + get_fs_root(reaper->fs, &real_root);
58759 +
58760 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
58761 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
58762 +#endif
58763 +
58764 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
58765 + if (fakefs_obj_rw == NULL)
58766 + return 1;
58767 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
58768 +
58769 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
58770 + if (fakefs_obj_rwx == NULL)
58771 + return 1;
58772 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
58773 +
58774 + subj_map_set.s_hash =
58775 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
58776 + acl_role_set.r_hash =
58777 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
58778 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
58779 + inodev_set.i_hash =
58780 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
58781 +
58782 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
58783 + !name_set.n_hash || !inodev_set.i_hash)
58784 + return 1;
58785 +
58786 + memset(subj_map_set.s_hash, 0,
58787 + sizeof(struct subject_map *) * subj_map_set.s_size);
58788 + memset(acl_role_set.r_hash, 0,
58789 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
58790 + memset(name_set.n_hash, 0,
58791 + sizeof (struct name_entry *) * name_set.n_size);
58792 + memset(inodev_set.i_hash, 0,
58793 + sizeof (struct inodev_entry *) * inodev_set.i_size);
58794 +
58795 + return 0;
58796 +}
58797 +
58798 +/* free information not needed after startup
58799 + currently contains user->kernel pointer mappings for subjects
58800 +*/
58801 +
58802 +static void
58803 +free_init_variables(void)
58804 +{
58805 + __u32 i;
58806 +
58807 + if (subj_map_set.s_hash) {
58808 + for (i = 0; i < subj_map_set.s_size; i++) {
58809 + if (subj_map_set.s_hash[i]) {
58810 + kfree(subj_map_set.s_hash[i]);
58811 + subj_map_set.s_hash[i] = NULL;
58812 + }
58813 + }
58814 +
58815 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
58816 + PAGE_SIZE)
58817 + kfree(subj_map_set.s_hash);
58818 + else
58819 + vfree(subj_map_set.s_hash);
58820 + }
58821 +
58822 + return;
58823 +}
58824 +
58825 +static void
58826 +free_variables(void)
58827 +{
58828 + struct acl_subject_label *s;
58829 + struct acl_role_label *r;
58830 + struct task_struct *task, *task2;
58831 + unsigned int x;
58832 +
58833 + gr_clear_learn_entries();
58834 +
58835 + read_lock(&tasklist_lock);
58836 + do_each_thread(task2, task) {
58837 + task->acl_sp_role = 0;
58838 + task->acl_role_id = 0;
58839 + task->acl = NULL;
58840 + task->role = NULL;
58841 + } while_each_thread(task2, task);
58842 + read_unlock(&tasklist_lock);
58843 +
58844 + /* release the reference to the real root dentry and vfsmount */
58845 + path_put(&real_root);
58846 + memset(&real_root, 0, sizeof(real_root));
58847 +
58848 + /* free all object hash tables */
58849 +
58850 + FOR_EACH_ROLE_START(r)
58851 + if (r->subj_hash == NULL)
58852 + goto next_role;
58853 + FOR_EACH_SUBJECT_START(r, s, x)
58854 + if (s->obj_hash == NULL)
58855 + break;
58856 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
58857 + kfree(s->obj_hash);
58858 + else
58859 + vfree(s->obj_hash);
58860 + FOR_EACH_SUBJECT_END(s, x)
58861 + FOR_EACH_NESTED_SUBJECT_START(r, s)
58862 + if (s->obj_hash == NULL)
58863 + break;
58864 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
58865 + kfree(s->obj_hash);
58866 + else
58867 + vfree(s->obj_hash);
58868 + FOR_EACH_NESTED_SUBJECT_END(s)
58869 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
58870 + kfree(r->subj_hash);
58871 + else
58872 + vfree(r->subj_hash);
58873 + r->subj_hash = NULL;
58874 +next_role:
58875 + FOR_EACH_ROLE_END(r)
58876 +
58877 + acl_free_all();
58878 +
58879 + if (acl_role_set.r_hash) {
58880 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
58881 + PAGE_SIZE)
58882 + kfree(acl_role_set.r_hash);
58883 + else
58884 + vfree(acl_role_set.r_hash);
58885 + }
58886 + if (name_set.n_hash) {
58887 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
58888 + PAGE_SIZE)
58889 + kfree(name_set.n_hash);
58890 + else
58891 + vfree(name_set.n_hash);
58892 + }
58893 +
58894 + if (inodev_set.i_hash) {
58895 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
58896 + PAGE_SIZE)
58897 + kfree(inodev_set.i_hash);
58898 + else
58899 + vfree(inodev_set.i_hash);
58900 + }
58901 +
58902 + gr_free_uidset();
58903 +
58904 + memset(&name_set, 0, sizeof (struct name_db));
58905 + memset(&inodev_set, 0, sizeof (struct inodev_db));
58906 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
58907 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
58908 +
58909 + default_role = NULL;
58910 + kernel_role = NULL;
58911 + role_list = NULL;
58912 +
58913 + return;
58914 +}
58915 +
58916 +static __u32
58917 +count_user_objs(struct acl_object_label *userp)
58918 +{
58919 + struct acl_object_label o_tmp;
58920 + __u32 num = 0;
58921 +
58922 + while (userp) {
58923 + if (copy_from_user(&o_tmp, userp,
58924 + sizeof (struct acl_object_label)))
58925 + break;
58926 +
58927 + userp = o_tmp.prev;
58928 + num++;
58929 + }
58930 +
58931 + return num;
58932 +}
58933 +
58934 +static struct acl_subject_label *
58935 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
58936 +
58937 +static int
58938 +copy_user_glob(struct acl_object_label *obj)
58939 +{
58940 + struct acl_object_label *g_tmp, **guser;
58941 + unsigned int len;
58942 + char *tmp;
58943 +
58944 + if (obj->globbed == NULL)
58945 + return 0;
58946 +
58947 + guser = &obj->globbed;
58948 + while (*guser) {
58949 + g_tmp = (struct acl_object_label *)
58950 + acl_alloc(sizeof (struct acl_object_label));
58951 + if (g_tmp == NULL)
58952 + return -ENOMEM;
58953 +
58954 + if (copy_from_user(g_tmp, *guser,
58955 + sizeof (struct acl_object_label)))
58956 + return -EFAULT;
58957 +
58958 + len = strnlen_user(g_tmp->filename, PATH_MAX);
58959 +
58960 + if (!len || len >= PATH_MAX)
58961 + return -EINVAL;
58962 +
58963 + if ((tmp = (char *) acl_alloc(len)) == NULL)
58964 + return -ENOMEM;
58965 +
58966 + if (copy_from_user(tmp, g_tmp->filename, len))
58967 + return -EFAULT;
58968 + tmp[len-1] = '\0';
58969 + g_tmp->filename = tmp;
58970 +
58971 + *guser = g_tmp;
58972 + guser = &(g_tmp->next);
58973 + }
58974 +
58975 + return 0;
58976 +}
58977 +
58978 +static int
58979 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
58980 + struct acl_role_label *role)
58981 +{
58982 + struct acl_object_label *o_tmp;
58983 + unsigned int len;
58984 + int ret;
58985 + char *tmp;
58986 +
58987 + while (userp) {
58988 + if ((o_tmp = (struct acl_object_label *)
58989 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
58990 + return -ENOMEM;
58991 +
58992 + if (copy_from_user(o_tmp, userp,
58993 + sizeof (struct acl_object_label)))
58994 + return -EFAULT;
58995 +
58996 + userp = o_tmp->prev;
58997 +
58998 + len = strnlen_user(o_tmp->filename, PATH_MAX);
58999 +
59000 + if (!len || len >= PATH_MAX)
59001 + return -EINVAL;
59002 +
59003 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59004 + return -ENOMEM;
59005 +
59006 + if (copy_from_user(tmp, o_tmp->filename, len))
59007 + return -EFAULT;
59008 + tmp[len-1] = '\0';
59009 + o_tmp->filename = tmp;
59010 +
59011 + insert_acl_obj_label(o_tmp, subj);
59012 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
59013 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
59014 + return -ENOMEM;
59015 +
59016 + ret = copy_user_glob(o_tmp);
59017 + if (ret)
59018 + return ret;
59019 +
59020 + if (o_tmp->nested) {
59021 + int already_copied;
59022 +
59023 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
59024 + if (IS_ERR(o_tmp->nested))
59025 + return PTR_ERR(o_tmp->nested);
59026 +
59027 + /* insert into nested subject list if we haven't copied this one yet
59028 + to prevent duplicate entries */
59029 + if (!already_copied) {
59030 + o_tmp->nested->next = role->hash->first;
59031 + role->hash->first = o_tmp->nested;
59032 + }
59033 + }
59034 + }
59035 +
59036 + return 0;
59037 +}
59038 +
59039 +static __u32
59040 +count_user_subjs(struct acl_subject_label *userp)
59041 +{
59042 + struct acl_subject_label s_tmp;
59043 + __u32 num = 0;
59044 +
59045 + while (userp) {
59046 + if (copy_from_user(&s_tmp, userp,
59047 + sizeof (struct acl_subject_label)))
59048 + break;
59049 +
59050 + userp = s_tmp.prev;
59051 + }
59052 +
59053 + return num;
59054 +}
59055 +
59056 +static int
59057 +copy_user_allowedips(struct acl_role_label *rolep)
59058 +{
59059 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
59060 +
59061 + ruserip = rolep->allowed_ips;
59062 +
59063 + while (ruserip) {
59064 + rlast = rtmp;
59065 +
59066 + if ((rtmp = (struct role_allowed_ip *)
59067 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
59068 + return -ENOMEM;
59069 +
59070 + if (copy_from_user(rtmp, ruserip,
59071 + sizeof (struct role_allowed_ip)))
59072 + return -EFAULT;
59073 +
59074 + ruserip = rtmp->prev;
59075 +
59076 + if (!rlast) {
59077 + rtmp->prev = NULL;
59078 + rolep->allowed_ips = rtmp;
59079 + } else {
59080 + rlast->next = rtmp;
59081 + rtmp->prev = rlast;
59082 + }
59083 +
59084 + if (!ruserip)
59085 + rtmp->next = NULL;
59086 + }
59087 +
59088 + return 0;
59089 +}
59090 +
59091 +static int
59092 +copy_user_transitions(struct acl_role_label *rolep)
59093 +{
59094 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
59095 +
59096 + unsigned int len;
59097 + char *tmp;
59098 +
59099 + rusertp = rolep->transitions;
59100 +
59101 + while (rusertp) {
59102 + rlast = rtmp;
59103 +
59104 + if ((rtmp = (struct role_transition *)
59105 + acl_alloc(sizeof (struct role_transition))) == NULL)
59106 + return -ENOMEM;
59107 +
59108 + if (copy_from_user(rtmp, rusertp,
59109 + sizeof (struct role_transition)))
59110 + return -EFAULT;
59111 +
59112 + rusertp = rtmp->prev;
59113 +
59114 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
59115 +
59116 + if (!len || len >= GR_SPROLE_LEN)
59117 + return -EINVAL;
59118 +
59119 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59120 + return -ENOMEM;
59121 +
59122 + if (copy_from_user(tmp, rtmp->rolename, len))
59123 + return -EFAULT;
59124 + tmp[len-1] = '\0';
59125 + rtmp->rolename = tmp;
59126 +
59127 + if (!rlast) {
59128 + rtmp->prev = NULL;
59129 + rolep->transitions = rtmp;
59130 + } else {
59131 + rlast->next = rtmp;
59132 + rtmp->prev = rlast;
59133 + }
59134 +
59135 + if (!rusertp)
59136 + rtmp->next = NULL;
59137 + }
59138 +
59139 + return 0;
59140 +}
59141 +
59142 +static struct acl_subject_label *
59143 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
59144 +{
59145 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
59146 + unsigned int len;
59147 + char *tmp;
59148 + __u32 num_objs;
59149 + struct acl_ip_label **i_tmp, *i_utmp2;
59150 + struct gr_hash_struct ghash;
59151 + struct subject_map *subjmap;
59152 + unsigned int i_num;
59153 + int err;
59154 +
59155 + if (already_copied != NULL)
59156 + *already_copied = 0;
59157 +
59158 + s_tmp = lookup_subject_map(userp);
59159 +
59160 + /* we've already copied this subject into the kernel, just return
59161 + the reference to it, and don't copy it over again
59162 + */
59163 + if (s_tmp) {
59164 + if (already_copied != NULL)
59165 + *already_copied = 1;
59166 + return(s_tmp);
59167 + }
59168 +
59169 + if ((s_tmp = (struct acl_subject_label *)
59170 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
59171 + return ERR_PTR(-ENOMEM);
59172 +
59173 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
59174 + if (subjmap == NULL)
59175 + return ERR_PTR(-ENOMEM);
59176 +
59177 + subjmap->user = userp;
59178 + subjmap->kernel = s_tmp;
59179 + insert_subj_map_entry(subjmap);
59180 +
59181 + if (copy_from_user(s_tmp, userp,
59182 + sizeof (struct acl_subject_label)))
59183 + return ERR_PTR(-EFAULT);
59184 +
59185 + len = strnlen_user(s_tmp->filename, PATH_MAX);
59186 +
59187 + if (!len || len >= PATH_MAX)
59188 + return ERR_PTR(-EINVAL);
59189 +
59190 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59191 + return ERR_PTR(-ENOMEM);
59192 +
59193 + if (copy_from_user(tmp, s_tmp->filename, len))
59194 + return ERR_PTR(-EFAULT);
59195 + tmp[len-1] = '\0';
59196 + s_tmp->filename = tmp;
59197 +
59198 + if (!strcmp(s_tmp->filename, "/"))
59199 + role->root_label = s_tmp;
59200 +
59201 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
59202 + return ERR_PTR(-EFAULT);
59203 +
59204 + /* copy user and group transition tables */
59205 +
59206 + if (s_tmp->user_trans_num) {
59207 + uid_t *uidlist;
59208 +
59209 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
59210 + if (uidlist == NULL)
59211 + return ERR_PTR(-ENOMEM);
59212 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
59213 + return ERR_PTR(-EFAULT);
59214 +
59215 + s_tmp->user_transitions = uidlist;
59216 + }
59217 +
59218 + if (s_tmp->group_trans_num) {
59219 + gid_t *gidlist;
59220 +
59221 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
59222 + if (gidlist == NULL)
59223 + return ERR_PTR(-ENOMEM);
59224 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
59225 + return ERR_PTR(-EFAULT);
59226 +
59227 + s_tmp->group_transitions = gidlist;
59228 + }
59229 +
59230 + /* set up object hash table */
59231 + num_objs = count_user_objs(ghash.first);
59232 +
59233 + s_tmp->obj_hash_size = num_objs;
59234 + s_tmp->obj_hash =
59235 + (struct acl_object_label **)
59236 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
59237 +
59238 + if (!s_tmp->obj_hash)
59239 + return ERR_PTR(-ENOMEM);
59240 +
59241 + memset(s_tmp->obj_hash, 0,
59242 + s_tmp->obj_hash_size *
59243 + sizeof (struct acl_object_label *));
59244 +
59245 + /* add in objects */
59246 + err = copy_user_objs(ghash.first, s_tmp, role);
59247 +
59248 + if (err)
59249 + return ERR_PTR(err);
59250 +
59251 + /* set pointer for parent subject */
59252 + if (s_tmp->parent_subject) {
59253 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
59254 +
59255 + if (IS_ERR(s_tmp2))
59256 + return s_tmp2;
59257 +
59258 + s_tmp->parent_subject = s_tmp2;
59259 + }
59260 +
59261 + /* add in ip acls */
59262 +
59263 + if (!s_tmp->ip_num) {
59264 + s_tmp->ips = NULL;
59265 + goto insert;
59266 + }
59267 +
59268 + i_tmp =
59269 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
59270 + sizeof (struct acl_ip_label *));
59271 +
59272 + if (!i_tmp)
59273 + return ERR_PTR(-ENOMEM);
59274 +
59275 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
59276 + *(i_tmp + i_num) =
59277 + (struct acl_ip_label *)
59278 + acl_alloc(sizeof (struct acl_ip_label));
59279 + if (!*(i_tmp + i_num))
59280 + return ERR_PTR(-ENOMEM);
59281 +
59282 + if (copy_from_user
59283 + (&i_utmp2, s_tmp->ips + i_num,
59284 + sizeof (struct acl_ip_label *)))
59285 + return ERR_PTR(-EFAULT);
59286 +
59287 + if (copy_from_user
59288 + (*(i_tmp + i_num), i_utmp2,
59289 + sizeof (struct acl_ip_label)))
59290 + return ERR_PTR(-EFAULT);
59291 +
59292 + if ((*(i_tmp + i_num))->iface == NULL)
59293 + continue;
59294 +
59295 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
59296 + if (!len || len >= IFNAMSIZ)
59297 + return ERR_PTR(-EINVAL);
59298 + tmp = acl_alloc(len);
59299 + if (tmp == NULL)
59300 + return ERR_PTR(-ENOMEM);
59301 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
59302 + return ERR_PTR(-EFAULT);
59303 + (*(i_tmp + i_num))->iface = tmp;
59304 + }
59305 +
59306 + s_tmp->ips = i_tmp;
59307 +
59308 +insert:
59309 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
59310 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
59311 + return ERR_PTR(-ENOMEM);
59312 +
59313 + return s_tmp;
59314 +}
59315 +
59316 +static int
59317 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
59318 +{
59319 + struct acl_subject_label s_pre;
59320 + struct acl_subject_label * ret;
59321 + int err;
59322 +
59323 + while (userp) {
59324 + if (copy_from_user(&s_pre, userp,
59325 + sizeof (struct acl_subject_label)))
59326 + return -EFAULT;
59327 +
59328 + ret = do_copy_user_subj(userp, role, NULL);
59329 +
59330 + err = PTR_ERR(ret);
59331 + if (IS_ERR(ret))
59332 + return err;
59333 +
59334 + insert_acl_subj_label(ret, role);
59335 +
59336 + userp = s_pre.prev;
59337 + }
59338 +
59339 + return 0;
59340 +}
59341 +
59342 +static int
59343 +copy_user_acl(struct gr_arg *arg)
59344 +{
59345 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
59346 + struct acl_subject_label *subj_list;
59347 + struct sprole_pw *sptmp;
59348 + struct gr_hash_struct *ghash;
59349 + uid_t *domainlist;
59350 + unsigned int r_num;
59351 + unsigned int len;
59352 + char *tmp;
59353 + int err = 0;
59354 + __u16 i;
59355 + __u32 num_subjs;
59356 +
59357 + /* we need a default and kernel role */
59358 + if (arg->role_db.num_roles < 2)
59359 + return -EINVAL;
59360 +
59361 + /* copy special role authentication info from userspace */
59362 +
59363 + num_sprole_pws = arg->num_sprole_pws;
59364 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
59365 +
59366 + if (!acl_special_roles && num_sprole_pws)
59367 + return -ENOMEM;
59368 +
59369 + for (i = 0; i < num_sprole_pws; i++) {
59370 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
59371 + if (!sptmp)
59372 + return -ENOMEM;
59373 + if (copy_from_user(sptmp, arg->sprole_pws + i,
59374 + sizeof (struct sprole_pw)))
59375 + return -EFAULT;
59376 +
59377 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
59378 +
59379 + if (!len || len >= GR_SPROLE_LEN)
59380 + return -EINVAL;
59381 +
59382 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59383 + return -ENOMEM;
59384 +
59385 + if (copy_from_user(tmp, sptmp->rolename, len))
59386 + return -EFAULT;
59387 +
59388 + tmp[len-1] = '\0';
59389 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59390 + printk(KERN_ALERT "Copying special role %s\n", tmp);
59391 +#endif
59392 + sptmp->rolename = tmp;
59393 + acl_special_roles[i] = sptmp;
59394 + }
59395 +
59396 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
59397 +
59398 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
59399 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
59400 +
59401 + if (!r_tmp)
59402 + return -ENOMEM;
59403 +
59404 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
59405 + sizeof (struct acl_role_label *)))
59406 + return -EFAULT;
59407 +
59408 + if (copy_from_user(r_tmp, r_utmp2,
59409 + sizeof (struct acl_role_label)))
59410 + return -EFAULT;
59411 +
59412 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
59413 +
59414 + if (!len || len >= PATH_MAX)
59415 + return -EINVAL;
59416 +
59417 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59418 + return -ENOMEM;
59419 +
59420 + if (copy_from_user(tmp, r_tmp->rolename, len))
59421 + return -EFAULT;
59422 +
59423 + tmp[len-1] = '\0';
59424 + r_tmp->rolename = tmp;
59425 +
59426 + if (!strcmp(r_tmp->rolename, "default")
59427 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
59428 + default_role = r_tmp;
59429 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
59430 + kernel_role = r_tmp;
59431 + }
59432 +
59433 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
59434 + return -ENOMEM;
59435 +
59436 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
59437 + return -EFAULT;
59438 +
59439 + r_tmp->hash = ghash;
59440 +
59441 + num_subjs = count_user_subjs(r_tmp->hash->first);
59442 +
59443 + r_tmp->subj_hash_size = num_subjs;
59444 + r_tmp->subj_hash =
59445 + (struct acl_subject_label **)
59446 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
59447 +
59448 + if (!r_tmp->subj_hash)
59449 + return -ENOMEM;
59450 +
59451 + err = copy_user_allowedips(r_tmp);
59452 + if (err)
59453 + return err;
59454 +
59455 + /* copy domain info */
59456 + if (r_tmp->domain_children != NULL) {
59457 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
59458 + if (domainlist == NULL)
59459 + return -ENOMEM;
59460 +
59461 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
59462 + return -EFAULT;
59463 +
59464 + r_tmp->domain_children = domainlist;
59465 + }
59466 +
59467 + err = copy_user_transitions(r_tmp);
59468 + if (err)
59469 + return err;
59470 +
59471 + memset(r_tmp->subj_hash, 0,
59472 + r_tmp->subj_hash_size *
59473 + sizeof (struct acl_subject_label *));
59474 +
59475 + /* acquire the list of subjects, then NULL out
59476 + the list prior to parsing the subjects for this role,
59477 + as during this parsing the list is replaced with a list
59478 + of *nested* subjects for the role
59479 + */
59480 + subj_list = r_tmp->hash->first;
59481 +
59482 + /* set nested subject list to null */
59483 + r_tmp->hash->first = NULL;
59484 +
59485 + err = copy_user_subjs(subj_list, r_tmp);
59486 +
59487 + if (err)
59488 + return err;
59489 +
59490 + insert_acl_role_label(r_tmp);
59491 + }
59492 +
59493 + if (default_role == NULL || kernel_role == NULL)
59494 + return -EINVAL;
59495 +
59496 + return err;
59497 +}
59498 +
59499 +static int
59500 +gracl_init(struct gr_arg *args)
59501 +{
59502 + int error = 0;
59503 +
59504 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
59505 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
59506 +
59507 + if (init_variables(args)) {
59508 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
59509 + error = -ENOMEM;
59510 + free_variables();
59511 + goto out;
59512 + }
59513 +
59514 + error = copy_user_acl(args);
59515 + free_init_variables();
59516 + if (error) {
59517 + free_variables();
59518 + goto out;
59519 + }
59520 +
59521 + if ((error = gr_set_acls(0))) {
59522 + free_variables();
59523 + goto out;
59524 + }
59525 +
59526 + pax_open_kernel();
59527 + gr_status |= GR_READY;
59528 + pax_close_kernel();
59529 +
59530 + out:
59531 + return error;
59532 +}
59533 +
59534 +/* derived from glibc fnmatch() 0: match, 1: no match*/
59535 +
59536 +static int
59537 +glob_match(const char *p, const char *n)
59538 +{
59539 + char c;
59540 +
59541 + while ((c = *p++) != '\0') {
59542 + switch (c) {
59543 + case '?':
59544 + if (*n == '\0')
59545 + return 1;
59546 + else if (*n == '/')
59547 + return 1;
59548 + break;
59549 + case '\\':
59550 + if (*n != c)
59551 + return 1;
59552 + break;
59553 + case '*':
59554 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
59555 + if (*n == '/')
59556 + return 1;
59557 + else if (c == '?') {
59558 + if (*n == '\0')
59559 + return 1;
59560 + else
59561 + ++n;
59562 + }
59563 + }
59564 + if (c == '\0') {
59565 + return 0;
59566 + } else {
59567 + const char *endp;
59568 +
59569 + if ((endp = strchr(n, '/')) == NULL)
59570 + endp = n + strlen(n);
59571 +
59572 + if (c == '[') {
59573 + for (--p; n < endp; ++n)
59574 + if (!glob_match(p, n))
59575 + return 0;
59576 + } else if (c == '/') {
59577 + while (*n != '\0' && *n != '/')
59578 + ++n;
59579 + if (*n == '/' && !glob_match(p, n + 1))
59580 + return 0;
59581 + } else {
59582 + for (--p; n < endp; ++n)
59583 + if (*n == c && !glob_match(p, n))
59584 + return 0;
59585 + }
59586 +
59587 + return 1;
59588 + }
59589 + case '[':
59590 + {
59591 + int not;
59592 + char cold;
59593 +
59594 + if (*n == '\0' || *n == '/')
59595 + return 1;
59596 +
59597 + not = (*p == '!' || *p == '^');
59598 + if (not)
59599 + ++p;
59600 +
59601 + c = *p++;
59602 + for (;;) {
59603 + unsigned char fn = (unsigned char)*n;
59604 +
59605 + if (c == '\0')
59606 + return 1;
59607 + else {
59608 + if (c == fn)
59609 + goto matched;
59610 + cold = c;
59611 + c = *p++;
59612 +
59613 + if (c == '-' && *p != ']') {
59614 + unsigned char cend = *p++;
59615 +
59616 + if (cend == '\0')
59617 + return 1;
59618 +
59619 + if (cold <= fn && fn <= cend)
59620 + goto matched;
59621 +
59622 + c = *p++;
59623 + }
59624 + }
59625 +
59626 + if (c == ']')
59627 + break;
59628 + }
59629 + if (!not)
59630 + return 1;
59631 + break;
59632 + matched:
59633 + while (c != ']') {
59634 + if (c == '\0')
59635 + return 1;
59636 +
59637 + c = *p++;
59638 + }
59639 + if (not)
59640 + return 1;
59641 + }
59642 + break;
59643 + default:
59644 + if (c != *n)
59645 + return 1;
59646 + }
59647 +
59648 + ++n;
59649 + }
59650 +
59651 + if (*n == '\0')
59652 + return 0;
59653 +
59654 + if (*n == '/')
59655 + return 0;
59656 +
59657 + return 1;
59658 +}
59659 +
59660 +static struct acl_object_label *
59661 +chk_glob_label(struct acl_object_label *globbed,
59662 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
59663 +{
59664 + struct acl_object_label *tmp;
59665 +
59666 + if (*path == NULL)
59667 + *path = gr_to_filename_nolock(dentry, mnt);
59668 +
59669 + tmp = globbed;
59670 +
59671 + while (tmp) {
59672 + if (!glob_match(tmp->filename, *path))
59673 + return tmp;
59674 + tmp = tmp->next;
59675 + }
59676 +
59677 + return NULL;
59678 +}
59679 +
59680 +static struct acl_object_label *
59681 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59682 + const ino_t curr_ino, const dev_t curr_dev,
59683 + const struct acl_subject_label *subj, char **path, const int checkglob)
59684 +{
59685 + struct acl_subject_label *tmpsubj;
59686 + struct acl_object_label *retval;
59687 + struct acl_object_label *retval2;
59688 +
59689 + tmpsubj = (struct acl_subject_label *) subj;
59690 + read_lock(&gr_inode_lock);
59691 + do {
59692 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
59693 + if (retval) {
59694 + if (checkglob && retval->globbed) {
59695 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
59696 + if (retval2)
59697 + retval = retval2;
59698 + }
59699 + break;
59700 + }
59701 + } while ((tmpsubj = tmpsubj->parent_subject));
59702 + read_unlock(&gr_inode_lock);
59703 +
59704 + return retval;
59705 +}
59706 +
59707 +static __inline__ struct acl_object_label *
59708 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59709 + struct dentry *curr_dentry,
59710 + const struct acl_subject_label *subj, char **path, const int checkglob)
59711 +{
59712 + int newglob = checkglob;
59713 + ino_t inode;
59714 + dev_t device;
59715 +
59716 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
59717 + as we don't want a / * rule to match instead of the / object
59718 + don't do this for create lookups that call this function though, since they're looking up
59719 + on the parent and thus need globbing checks on all paths
59720 + */
59721 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
59722 + newglob = GR_NO_GLOB;
59723 +
59724 + spin_lock(&curr_dentry->d_lock);
59725 + inode = curr_dentry->d_inode->i_ino;
59726 + device = __get_dev(curr_dentry);
59727 + spin_unlock(&curr_dentry->d_lock);
59728 +
59729 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
59730 +}
59731 +
59732 +#ifdef CONFIG_HUGETLBFS
59733 +static inline bool
59734 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
59735 +{
59736 + int i;
59737 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
59738 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
59739 + return true;
59740 + }
59741 +
59742 + return false;
59743 +}
59744 +#endif
59745 +
59746 +static struct acl_object_label *
59747 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59748 + const struct acl_subject_label *subj, char *path, const int checkglob)
59749 +{
59750 + struct dentry *dentry = (struct dentry *) l_dentry;
59751 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59752 + struct mount *real_mnt = real_mount(mnt);
59753 + struct acl_object_label *retval;
59754 + struct dentry *parent;
59755 +
59756 + br_read_lock(&vfsmount_lock);
59757 + write_seqlock(&rename_lock);
59758 +
59759 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
59760 +#ifdef CONFIG_NET
59761 + mnt == sock_mnt ||
59762 +#endif
59763 +#ifdef CONFIG_HUGETLBFS
59764 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
59765 +#endif
59766 + /* ignore Eric Biederman */
59767 + IS_PRIVATE(l_dentry->d_inode))) {
59768 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
59769 + goto out;
59770 + }
59771 +
59772 + for (;;) {
59773 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59774 + break;
59775 +
59776 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59777 + if (!mnt_has_parent(real_mnt))
59778 + break;
59779 +
59780 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59781 + if (retval != NULL)
59782 + goto out;
59783 +
59784 + dentry = real_mnt->mnt_mountpoint;
59785 + real_mnt = real_mnt->mnt_parent;
59786 + mnt = &real_mnt->mnt;
59787 + continue;
59788 + }
59789 +
59790 + parent = dentry->d_parent;
59791 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59792 + if (retval != NULL)
59793 + goto out;
59794 +
59795 + dentry = parent;
59796 + }
59797 +
59798 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59799 +
59800 + /* real_root is pinned so we don't have to hold a reference */
59801 + if (retval == NULL)
59802 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
59803 +out:
59804 + write_sequnlock(&rename_lock);
59805 + br_read_unlock(&vfsmount_lock);
59806 +
59807 + BUG_ON(retval == NULL);
59808 +
59809 + return retval;
59810 +}
59811 +
59812 +static __inline__ struct acl_object_label *
59813 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59814 + const struct acl_subject_label *subj)
59815 +{
59816 + char *path = NULL;
59817 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
59818 +}
59819 +
59820 +static __inline__ struct acl_object_label *
59821 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59822 + const struct acl_subject_label *subj)
59823 +{
59824 + char *path = NULL;
59825 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
59826 +}
59827 +
59828 +static __inline__ struct acl_object_label *
59829 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59830 + const struct acl_subject_label *subj, char *path)
59831 +{
59832 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
59833 +}
59834 +
59835 +static struct acl_subject_label *
59836 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59837 + const struct acl_role_label *role)
59838 +{
59839 + struct dentry *dentry = (struct dentry *) l_dentry;
59840 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59841 + struct mount *real_mnt = real_mount(mnt);
59842 + struct acl_subject_label *retval;
59843 + struct dentry *parent;
59844 +
59845 + br_read_lock(&vfsmount_lock);
59846 + write_seqlock(&rename_lock);
59847 +
59848 + for (;;) {
59849 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59850 + break;
59851 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59852 + if (!mnt_has_parent(real_mnt))
59853 + break;
59854 +
59855 + spin_lock(&dentry->d_lock);
59856 + read_lock(&gr_inode_lock);
59857 + retval =
59858 + lookup_acl_subj_label(dentry->d_inode->i_ino,
59859 + __get_dev(dentry), role);
59860 + read_unlock(&gr_inode_lock);
59861 + spin_unlock(&dentry->d_lock);
59862 + if (retval != NULL)
59863 + goto out;
59864 +
59865 + dentry = real_mnt->mnt_mountpoint;
59866 + real_mnt = real_mnt->mnt_parent;
59867 + mnt = &real_mnt->mnt;
59868 + continue;
59869 + }
59870 +
59871 + spin_lock(&dentry->d_lock);
59872 + read_lock(&gr_inode_lock);
59873 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
59874 + __get_dev(dentry), role);
59875 + read_unlock(&gr_inode_lock);
59876 + parent = dentry->d_parent;
59877 + spin_unlock(&dentry->d_lock);
59878 +
59879 + if (retval != NULL)
59880 + goto out;
59881 +
59882 + dentry = parent;
59883 + }
59884 +
59885 + spin_lock(&dentry->d_lock);
59886 + read_lock(&gr_inode_lock);
59887 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
59888 + __get_dev(dentry), role);
59889 + read_unlock(&gr_inode_lock);
59890 + spin_unlock(&dentry->d_lock);
59891 +
59892 + if (unlikely(retval == NULL)) {
59893 + /* real_root is pinned, we don't need to hold a reference */
59894 + read_lock(&gr_inode_lock);
59895 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
59896 + __get_dev(real_root.dentry), role);
59897 + read_unlock(&gr_inode_lock);
59898 + }
59899 +out:
59900 + write_sequnlock(&rename_lock);
59901 + br_read_unlock(&vfsmount_lock);
59902 +
59903 + BUG_ON(retval == NULL);
59904 +
59905 + return retval;
59906 +}
59907 +
59908 +static void
59909 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
59910 +{
59911 + struct task_struct *task = current;
59912 + const struct cred *cred = current_cred();
59913 +
59914 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
59915 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59916 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59917 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
59918 +
59919 + return;
59920 +}
59921 +
59922 +static void
59923 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
59924 +{
59925 + struct task_struct *task = current;
59926 + const struct cred *cred = current_cred();
59927 +
59928 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
59929 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59930 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59931 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
59932 +
59933 + return;
59934 +}
59935 +
59936 +static void
59937 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
59938 +{
59939 + struct task_struct *task = current;
59940 + const struct cred *cred = current_cred();
59941 +
59942 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
59943 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
59944 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
59945 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
59946 +
59947 + return;
59948 +}
59949 +
59950 +__u32
59951 +gr_search_file(const struct dentry * dentry, const __u32 mode,
59952 + const struct vfsmount * mnt)
59953 +{
59954 + __u32 retval = mode;
59955 + struct acl_subject_label *curracl;
59956 + struct acl_object_label *currobj;
59957 +
59958 + if (unlikely(!(gr_status & GR_READY)))
59959 + return (mode & ~GR_AUDITS);
59960 +
59961 + curracl = current->acl;
59962 +
59963 + currobj = chk_obj_label(dentry, mnt, curracl);
59964 + retval = currobj->mode & mode;
59965 +
59966 + /* if we're opening a specified transfer file for writing
59967 + (e.g. /dev/initctl), then transfer our role to init
59968 + */
59969 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
59970 + current->role->roletype & GR_ROLE_PERSIST)) {
59971 + struct task_struct *task = init_pid_ns.child_reaper;
59972 +
59973 + if (task->role != current->role) {
59974 + task->acl_sp_role = 0;
59975 + task->acl_role_id = current->acl_role_id;
59976 + task->role = current->role;
59977 + rcu_read_lock();
59978 + read_lock(&grsec_exec_file_lock);
59979 + gr_apply_subject_to_task(task);
59980 + read_unlock(&grsec_exec_file_lock);
59981 + rcu_read_unlock();
59982 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
59983 + }
59984 + }
59985 +
59986 + if (unlikely
59987 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
59988 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
59989 + __u32 new_mode = mode;
59990 +
59991 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
59992 +
59993 + retval = new_mode;
59994 +
59995 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
59996 + new_mode |= GR_INHERIT;
59997 +
59998 + if (!(mode & GR_NOLEARN))
59999 + gr_log_learn(dentry, mnt, new_mode);
60000 + }
60001 +
60002 + return retval;
60003 +}
60004 +
60005 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
60006 + const struct dentry *parent,
60007 + const struct vfsmount *mnt)
60008 +{
60009 + struct name_entry *match;
60010 + struct acl_object_label *matchpo;
60011 + struct acl_subject_label *curracl;
60012 + char *path;
60013 +
60014 + if (unlikely(!(gr_status & GR_READY)))
60015 + return NULL;
60016 +
60017 + preempt_disable();
60018 + path = gr_to_filename_rbac(new_dentry, mnt);
60019 + match = lookup_name_entry_create(path);
60020 +
60021 + curracl = current->acl;
60022 +
60023 + if (match) {
60024 + read_lock(&gr_inode_lock);
60025 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
60026 + read_unlock(&gr_inode_lock);
60027 +
60028 + if (matchpo) {
60029 + preempt_enable();
60030 + return matchpo;
60031 + }
60032 + }
60033 +
60034 + // lookup parent
60035 +
60036 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
60037 +
60038 + preempt_enable();
60039 + return matchpo;
60040 +}
60041 +
60042 +__u32
60043 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
60044 + const struct vfsmount * mnt, const __u32 mode)
60045 +{
60046 + struct acl_object_label *matchpo;
60047 + __u32 retval;
60048 +
60049 + if (unlikely(!(gr_status & GR_READY)))
60050 + return (mode & ~GR_AUDITS);
60051 +
60052 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
60053 +
60054 + retval = matchpo->mode & mode;
60055 +
60056 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
60057 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60058 + __u32 new_mode = mode;
60059 +
60060 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60061 +
60062 + gr_log_learn(new_dentry, mnt, new_mode);
60063 + return new_mode;
60064 + }
60065 +
60066 + return retval;
60067 +}
60068 +
60069 +__u32
60070 +gr_check_link(const struct dentry * new_dentry,
60071 + const struct dentry * parent_dentry,
60072 + const struct vfsmount * parent_mnt,
60073 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
60074 +{
60075 + struct acl_object_label *obj;
60076 + __u32 oldmode, newmode;
60077 + __u32 needmode;
60078 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
60079 + GR_DELETE | GR_INHERIT;
60080 +
60081 + if (unlikely(!(gr_status & GR_READY)))
60082 + return (GR_CREATE | GR_LINK);
60083 +
60084 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
60085 + oldmode = obj->mode;
60086 +
60087 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
60088 + newmode = obj->mode;
60089 +
60090 + needmode = newmode & checkmodes;
60091 +
60092 + // old name for hardlink must have at least the permissions of the new name
60093 + if ((oldmode & needmode) != needmode)
60094 + goto bad;
60095 +
60096 + // if old name had restrictions/auditing, make sure the new name does as well
60097 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
60098 +
60099 + // don't allow hardlinking of suid/sgid/fcapped files without permission
60100 + if (is_privileged_binary(old_dentry))
60101 + needmode |= GR_SETID;
60102 +
60103 + if ((newmode & needmode) != needmode)
60104 + goto bad;
60105 +
60106 + // enforce minimum permissions
60107 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
60108 + return newmode;
60109 +bad:
60110 + needmode = oldmode;
60111 + if (is_privileged_binary(old_dentry))
60112 + needmode |= GR_SETID;
60113 +
60114 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
60115 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
60116 + return (GR_CREATE | GR_LINK);
60117 + } else if (newmode & GR_SUPPRESS)
60118 + return GR_SUPPRESS;
60119 + else
60120 + return 0;
60121 +}
60122 +
60123 +int
60124 +gr_check_hidden_task(const struct task_struct *task)
60125 +{
60126 + if (unlikely(!(gr_status & GR_READY)))
60127 + return 0;
60128 +
60129 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
60130 + return 1;
60131 +
60132 + return 0;
60133 +}
60134 +
60135 +int
60136 +gr_check_protected_task(const struct task_struct *task)
60137 +{
60138 + if (unlikely(!(gr_status & GR_READY) || !task))
60139 + return 0;
60140 +
60141 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60142 + task->acl != current->acl)
60143 + return 1;
60144 +
60145 + return 0;
60146 +}
60147 +
60148 +int
60149 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
60150 +{
60151 + struct task_struct *p;
60152 + int ret = 0;
60153 +
60154 + if (unlikely(!(gr_status & GR_READY) || !pid))
60155 + return ret;
60156 +
60157 + read_lock(&tasklist_lock);
60158 + do_each_pid_task(pid, type, p) {
60159 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60160 + p->acl != current->acl) {
60161 + ret = 1;
60162 + goto out;
60163 + }
60164 + } while_each_pid_task(pid, type, p);
60165 +out:
60166 + read_unlock(&tasklist_lock);
60167 +
60168 + return ret;
60169 +}
60170 +
60171 +void
60172 +gr_copy_label(struct task_struct *tsk)
60173 +{
60174 + tsk->signal->used_accept = 0;
60175 + tsk->acl_sp_role = 0;
60176 + tsk->acl_role_id = current->acl_role_id;
60177 + tsk->acl = current->acl;
60178 + tsk->role = current->role;
60179 + tsk->signal->curr_ip = current->signal->curr_ip;
60180 + tsk->signal->saved_ip = current->signal->saved_ip;
60181 + if (current->exec_file)
60182 + get_file(current->exec_file);
60183 + tsk->exec_file = current->exec_file;
60184 + tsk->is_writable = current->is_writable;
60185 + if (unlikely(current->signal->used_accept)) {
60186 + current->signal->curr_ip = 0;
60187 + current->signal->saved_ip = 0;
60188 + }
60189 +
60190 + return;
60191 +}
60192 +
60193 +static void
60194 +gr_set_proc_res(struct task_struct *task)
60195 +{
60196 + struct acl_subject_label *proc;
60197 + unsigned short i;
60198 +
60199 + proc = task->acl;
60200 +
60201 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
60202 + return;
60203 +
60204 + for (i = 0; i < RLIM_NLIMITS; i++) {
60205 + if (!(proc->resmask & (1U << i)))
60206 + continue;
60207 +
60208 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
60209 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
60210 +
60211 + if (i == RLIMIT_CPU)
60212 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
60213 + }
60214 +
60215 + return;
60216 +}
60217 +
60218 +extern int __gr_process_user_ban(struct user_struct *user);
60219 +
60220 +int
60221 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
60222 +{
60223 + unsigned int i;
60224 + __u16 num;
60225 + uid_t *uidlist;
60226 + uid_t curuid;
60227 + int realok = 0;
60228 + int effectiveok = 0;
60229 + int fsok = 0;
60230 + uid_t globalreal, globaleffective, globalfs;
60231 +
60232 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
60233 + struct user_struct *user;
60234 +
60235 + if (!uid_valid(real))
60236 + goto skipit;
60237 +
60238 + /* find user based on global namespace */
60239 +
60240 + globalreal = GR_GLOBAL_UID(real);
60241 +
60242 + user = find_user(make_kuid(&init_user_ns, globalreal));
60243 + if (user == NULL)
60244 + goto skipit;
60245 +
60246 + if (__gr_process_user_ban(user)) {
60247 + /* for find_user */
60248 + free_uid(user);
60249 + return 1;
60250 + }
60251 +
60252 + /* for find_user */
60253 + free_uid(user);
60254 +
60255 +skipit:
60256 +#endif
60257 +
60258 + if (unlikely(!(gr_status & GR_READY)))
60259 + return 0;
60260 +
60261 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60262 + gr_log_learn_uid_change(real, effective, fs);
60263 +
60264 + num = current->acl->user_trans_num;
60265 + uidlist = current->acl->user_transitions;
60266 +
60267 + if (uidlist == NULL)
60268 + return 0;
60269 +
60270 + if (!uid_valid(real)) {
60271 + realok = 1;
60272 + globalreal = (uid_t)-1;
60273 + } else {
60274 + globalreal = GR_GLOBAL_UID(real);
60275 + }
60276 + if (!uid_valid(effective)) {
60277 + effectiveok = 1;
60278 + globaleffective = (uid_t)-1;
60279 + } else {
60280 + globaleffective = GR_GLOBAL_UID(effective);
60281 + }
60282 + if (!uid_valid(fs)) {
60283 + fsok = 1;
60284 + globalfs = (uid_t)-1;
60285 + } else {
60286 + globalfs = GR_GLOBAL_UID(fs);
60287 + }
60288 +
60289 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
60290 + for (i = 0; i < num; i++) {
60291 + curuid = uidlist[i];
60292 + if (globalreal == curuid)
60293 + realok = 1;
60294 + if (globaleffective == curuid)
60295 + effectiveok = 1;
60296 + if (globalfs == curuid)
60297 + fsok = 1;
60298 + }
60299 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
60300 + for (i = 0; i < num; i++) {
60301 + curuid = uidlist[i];
60302 + if (globalreal == curuid)
60303 + break;
60304 + if (globaleffective == curuid)
60305 + break;
60306 + if (globalfs == curuid)
60307 + break;
60308 + }
60309 + /* not in deny list */
60310 + if (i == num) {
60311 + realok = 1;
60312 + effectiveok = 1;
60313 + fsok = 1;
60314 + }
60315 + }
60316 +
60317 + if (realok && effectiveok && fsok)
60318 + return 0;
60319 + else {
60320 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60321 + return 1;
60322 + }
60323 +}
60324 +
60325 +int
60326 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
60327 +{
60328 + unsigned int i;
60329 + __u16 num;
60330 + gid_t *gidlist;
60331 + gid_t curgid;
60332 + int realok = 0;
60333 + int effectiveok = 0;
60334 + int fsok = 0;
60335 + gid_t globalreal, globaleffective, globalfs;
60336 +
60337 + if (unlikely(!(gr_status & GR_READY)))
60338 + return 0;
60339 +
60340 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60341 + gr_log_learn_gid_change(real, effective, fs);
60342 +
60343 + num = current->acl->group_trans_num;
60344 + gidlist = current->acl->group_transitions;
60345 +
60346 + if (gidlist == NULL)
60347 + return 0;
60348 +
60349 + if (!gid_valid(real)) {
60350 + realok = 1;
60351 + globalreal = (gid_t)-1;
60352 + } else {
60353 + globalreal = GR_GLOBAL_GID(real);
60354 + }
60355 + if (!gid_valid(effective)) {
60356 + effectiveok = 1;
60357 + globaleffective = (gid_t)-1;
60358 + } else {
60359 + globaleffective = GR_GLOBAL_GID(effective);
60360 + }
60361 + if (!gid_valid(fs)) {
60362 + fsok = 1;
60363 + globalfs = (gid_t)-1;
60364 + } else {
60365 + globalfs = GR_GLOBAL_GID(fs);
60366 + }
60367 +
60368 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
60369 + for (i = 0; i < num; i++) {
60370 + curgid = gidlist[i];
60371 + if (globalreal == curgid)
60372 + realok = 1;
60373 + if (globaleffective == curgid)
60374 + effectiveok = 1;
60375 + if (globalfs == curgid)
60376 + fsok = 1;
60377 + }
60378 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
60379 + for (i = 0; i < num; i++) {
60380 + curgid = gidlist[i];
60381 + if (globalreal == curgid)
60382 + break;
60383 + if (globaleffective == curgid)
60384 + break;
60385 + if (globalfs == curgid)
60386 + break;
60387 + }
60388 + /* not in deny list */
60389 + if (i == num) {
60390 + realok = 1;
60391 + effectiveok = 1;
60392 + fsok = 1;
60393 + }
60394 + }
60395 +
60396 + if (realok && effectiveok && fsok)
60397 + return 0;
60398 + else {
60399 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60400 + return 1;
60401 + }
60402 +}
60403 +
60404 +extern int gr_acl_is_capable(const int cap);
60405 +
60406 +void
60407 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
60408 +{
60409 + struct acl_role_label *role = task->role;
60410 + struct acl_subject_label *subj = NULL;
60411 + struct acl_object_label *obj;
60412 + struct file *filp;
60413 + uid_t uid;
60414 + gid_t gid;
60415 +
60416 + if (unlikely(!(gr_status & GR_READY)))
60417 + return;
60418 +
60419 + uid = GR_GLOBAL_UID(kuid);
60420 + gid = GR_GLOBAL_GID(kgid);
60421 +
60422 + filp = task->exec_file;
60423 +
60424 + /* kernel process, we'll give them the kernel role */
60425 + if (unlikely(!filp)) {
60426 + task->role = kernel_role;
60427 + task->acl = kernel_role->root_label;
60428 + return;
60429 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
60430 + role = lookup_acl_role_label(task, uid, gid);
60431 +
60432 + /* don't change the role if we're not a privileged process */
60433 + if (role && task->role != role &&
60434 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
60435 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
60436 + return;
60437 +
60438 + /* perform subject lookup in possibly new role
60439 + we can use this result below in the case where role == task->role
60440 + */
60441 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
60442 +
60443 + /* if we changed uid/gid, but result in the same role
60444 + and are using inheritance, don't lose the inherited subject
60445 + if current subject is other than what normal lookup
60446 + would result in, we arrived via inheritance, don't
60447 + lose subject
60448 + */
60449 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
60450 + (subj == task->acl)))
60451 + task->acl = subj;
60452 +
60453 + task->role = role;
60454 +
60455 + task->is_writable = 0;
60456 +
60457 + /* ignore additional mmap checks for processes that are writable
60458 + by the default ACL */
60459 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60460 + if (unlikely(obj->mode & GR_WRITE))
60461 + task->is_writable = 1;
60462 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60463 + if (unlikely(obj->mode & GR_WRITE))
60464 + task->is_writable = 1;
60465 +
60466 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60467 + 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);
60468 +#endif
60469 +
60470 + gr_set_proc_res(task);
60471 +
60472 + return;
60473 +}
60474 +
60475 +int
60476 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
60477 + const int unsafe_flags)
60478 +{
60479 + struct task_struct *task = current;
60480 + struct acl_subject_label *newacl;
60481 + struct acl_object_label *obj;
60482 + __u32 retmode;
60483 +
60484 + if (unlikely(!(gr_status & GR_READY)))
60485 + return 0;
60486 +
60487 + newacl = chk_subj_label(dentry, mnt, task->role);
60488 +
60489 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
60490 + did an exec
60491 + */
60492 + rcu_read_lock();
60493 + read_lock(&tasklist_lock);
60494 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
60495 + (task->parent->acl->mode & GR_POVERRIDE))) {
60496 + read_unlock(&tasklist_lock);
60497 + rcu_read_unlock();
60498 + goto skip_check;
60499 + }
60500 + read_unlock(&tasklist_lock);
60501 + rcu_read_unlock();
60502 +
60503 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
60504 + !(task->role->roletype & GR_ROLE_GOD) &&
60505 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
60506 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60507 + if (unsafe_flags & LSM_UNSAFE_SHARE)
60508 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
60509 + else
60510 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
60511 + return -EACCES;
60512 + }
60513 +
60514 +skip_check:
60515 +
60516 + obj = chk_obj_label(dentry, mnt, task->acl);
60517 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
60518 +
60519 + if (!(task->acl->mode & GR_INHERITLEARN) &&
60520 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
60521 + if (obj->nested)
60522 + task->acl = obj->nested;
60523 + else
60524 + task->acl = newacl;
60525 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
60526 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
60527 +
60528 + task->is_writable = 0;
60529 +
60530 + /* ignore additional mmap checks for processes that are writable
60531 + by the default ACL */
60532 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
60533 + if (unlikely(obj->mode & GR_WRITE))
60534 + task->is_writable = 1;
60535 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
60536 + if (unlikely(obj->mode & GR_WRITE))
60537 + task->is_writable = 1;
60538 +
60539 + gr_set_proc_res(task);
60540 +
60541 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60542 + 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);
60543 +#endif
60544 + return 0;
60545 +}
60546 +
60547 +/* always called with valid inodev ptr */
60548 +static void
60549 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
60550 +{
60551 + struct acl_object_label *matchpo;
60552 + struct acl_subject_label *matchps;
60553 + struct acl_subject_label *subj;
60554 + struct acl_role_label *role;
60555 + unsigned int x;
60556 +
60557 + FOR_EACH_ROLE_START(role)
60558 + FOR_EACH_SUBJECT_START(role, subj, x)
60559 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60560 + matchpo->mode |= GR_DELETED;
60561 + FOR_EACH_SUBJECT_END(subj,x)
60562 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60563 + /* nested subjects aren't in the role's subj_hash table */
60564 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60565 + matchpo->mode |= GR_DELETED;
60566 + FOR_EACH_NESTED_SUBJECT_END(subj)
60567 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
60568 + matchps->mode |= GR_DELETED;
60569 + FOR_EACH_ROLE_END(role)
60570 +
60571 + inodev->nentry->deleted = 1;
60572 +
60573 + return;
60574 +}
60575 +
60576 +void
60577 +gr_handle_delete(const ino_t ino, const dev_t dev)
60578 +{
60579 + struct inodev_entry *inodev;
60580 +
60581 + if (unlikely(!(gr_status & GR_READY)))
60582 + return;
60583 +
60584 + write_lock(&gr_inode_lock);
60585 + inodev = lookup_inodev_entry(ino, dev);
60586 + if (inodev != NULL)
60587 + do_handle_delete(inodev, ino, dev);
60588 + write_unlock(&gr_inode_lock);
60589 +
60590 + return;
60591 +}
60592 +
60593 +static void
60594 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
60595 + const ino_t newinode, const dev_t newdevice,
60596 + struct acl_subject_label *subj)
60597 +{
60598 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
60599 + struct acl_object_label *match;
60600 +
60601 + match = subj->obj_hash[index];
60602 +
60603 + while (match && (match->inode != oldinode ||
60604 + match->device != olddevice ||
60605 + !(match->mode & GR_DELETED)))
60606 + match = match->next;
60607 +
60608 + if (match && (match->inode == oldinode)
60609 + && (match->device == olddevice)
60610 + && (match->mode & GR_DELETED)) {
60611 + if (match->prev == NULL) {
60612 + subj->obj_hash[index] = match->next;
60613 + if (match->next != NULL)
60614 + match->next->prev = NULL;
60615 + } else {
60616 + match->prev->next = match->next;
60617 + if (match->next != NULL)
60618 + match->next->prev = match->prev;
60619 + }
60620 + match->prev = NULL;
60621 + match->next = NULL;
60622 + match->inode = newinode;
60623 + match->device = newdevice;
60624 + match->mode &= ~GR_DELETED;
60625 +
60626 + insert_acl_obj_label(match, subj);
60627 + }
60628 +
60629 + return;
60630 +}
60631 +
60632 +static void
60633 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
60634 + const ino_t newinode, const dev_t newdevice,
60635 + struct acl_role_label *role)
60636 +{
60637 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
60638 + struct acl_subject_label *match;
60639 +
60640 + match = role->subj_hash[index];
60641 +
60642 + while (match && (match->inode != oldinode ||
60643 + match->device != olddevice ||
60644 + !(match->mode & GR_DELETED)))
60645 + match = match->next;
60646 +
60647 + if (match && (match->inode == oldinode)
60648 + && (match->device == olddevice)
60649 + && (match->mode & GR_DELETED)) {
60650 + if (match->prev == NULL) {
60651 + role->subj_hash[index] = match->next;
60652 + if (match->next != NULL)
60653 + match->next->prev = NULL;
60654 + } else {
60655 + match->prev->next = match->next;
60656 + if (match->next != NULL)
60657 + match->next->prev = match->prev;
60658 + }
60659 + match->prev = NULL;
60660 + match->next = NULL;
60661 + match->inode = newinode;
60662 + match->device = newdevice;
60663 + match->mode &= ~GR_DELETED;
60664 +
60665 + insert_acl_subj_label(match, role);
60666 + }
60667 +
60668 + return;
60669 +}
60670 +
60671 +static void
60672 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
60673 + const ino_t newinode, const dev_t newdevice)
60674 +{
60675 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
60676 + struct inodev_entry *match;
60677 +
60678 + match = inodev_set.i_hash[index];
60679 +
60680 + while (match && (match->nentry->inode != oldinode ||
60681 + match->nentry->device != olddevice || !match->nentry->deleted))
60682 + match = match->next;
60683 +
60684 + if (match && (match->nentry->inode == oldinode)
60685 + && (match->nentry->device == olddevice) &&
60686 + match->nentry->deleted) {
60687 + if (match->prev == NULL) {
60688 + inodev_set.i_hash[index] = match->next;
60689 + if (match->next != NULL)
60690 + match->next->prev = NULL;
60691 + } else {
60692 + match->prev->next = match->next;
60693 + if (match->next != NULL)
60694 + match->next->prev = match->prev;
60695 + }
60696 + match->prev = NULL;
60697 + match->next = NULL;
60698 + match->nentry->inode = newinode;
60699 + match->nentry->device = newdevice;
60700 + match->nentry->deleted = 0;
60701 +
60702 + insert_inodev_entry(match);
60703 + }
60704 +
60705 + return;
60706 +}
60707 +
60708 +static void
60709 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
60710 +{
60711 + struct acl_subject_label *subj;
60712 + struct acl_role_label *role;
60713 + unsigned int x;
60714 +
60715 + FOR_EACH_ROLE_START(role)
60716 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
60717 +
60718 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60719 + if ((subj->inode == ino) && (subj->device == dev)) {
60720 + subj->inode = ino;
60721 + subj->device = dev;
60722 + }
60723 + /* nested subjects aren't in the role's subj_hash table */
60724 + update_acl_obj_label(matchn->inode, matchn->device,
60725 + ino, dev, subj);
60726 + FOR_EACH_NESTED_SUBJECT_END(subj)
60727 + FOR_EACH_SUBJECT_START(role, subj, x)
60728 + update_acl_obj_label(matchn->inode, matchn->device,
60729 + ino, dev, subj);
60730 + FOR_EACH_SUBJECT_END(subj,x)
60731 + FOR_EACH_ROLE_END(role)
60732 +
60733 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
60734 +
60735 + return;
60736 +}
60737 +
60738 +static void
60739 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
60740 + const struct vfsmount *mnt)
60741 +{
60742 + ino_t ino = dentry->d_inode->i_ino;
60743 + dev_t dev = __get_dev(dentry);
60744 +
60745 + __do_handle_create(matchn, ino, dev);
60746 +
60747 + return;
60748 +}
60749 +
60750 +void
60751 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
60752 +{
60753 + struct name_entry *matchn;
60754 +
60755 + if (unlikely(!(gr_status & GR_READY)))
60756 + return;
60757 +
60758 + preempt_disable();
60759 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
60760 +
60761 + if (unlikely((unsigned long)matchn)) {
60762 + write_lock(&gr_inode_lock);
60763 + do_handle_create(matchn, dentry, mnt);
60764 + write_unlock(&gr_inode_lock);
60765 + }
60766 + preempt_enable();
60767 +
60768 + return;
60769 +}
60770 +
60771 +void
60772 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
60773 +{
60774 + struct name_entry *matchn;
60775 +
60776 + if (unlikely(!(gr_status & GR_READY)))
60777 + return;
60778 +
60779 + preempt_disable();
60780 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
60781 +
60782 + if (unlikely((unsigned long)matchn)) {
60783 + write_lock(&gr_inode_lock);
60784 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
60785 + write_unlock(&gr_inode_lock);
60786 + }
60787 + preempt_enable();
60788 +
60789 + return;
60790 +}
60791 +
60792 +void
60793 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
60794 + struct dentry *old_dentry,
60795 + struct dentry *new_dentry,
60796 + struct vfsmount *mnt, const __u8 replace)
60797 +{
60798 + struct name_entry *matchn;
60799 + struct inodev_entry *inodev;
60800 + struct inode *inode = new_dentry->d_inode;
60801 + ino_t old_ino = old_dentry->d_inode->i_ino;
60802 + dev_t old_dev = __get_dev(old_dentry);
60803 +
60804 + /* vfs_rename swaps the name and parent link for old_dentry and
60805 + new_dentry
60806 + at this point, old_dentry has the new name, parent link, and inode
60807 + for the renamed file
60808 + if a file is being replaced by a rename, new_dentry has the inode
60809 + and name for the replaced file
60810 + */
60811 +
60812 + if (unlikely(!(gr_status & GR_READY)))
60813 + return;
60814 +
60815 + preempt_disable();
60816 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
60817 +
60818 + /* we wouldn't have to check d_inode if it weren't for
60819 + NFS silly-renaming
60820 + */
60821 +
60822 + write_lock(&gr_inode_lock);
60823 + if (unlikely(replace && inode)) {
60824 + ino_t new_ino = inode->i_ino;
60825 + dev_t new_dev = __get_dev(new_dentry);
60826 +
60827 + inodev = lookup_inodev_entry(new_ino, new_dev);
60828 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
60829 + do_handle_delete(inodev, new_ino, new_dev);
60830 + }
60831 +
60832 + inodev = lookup_inodev_entry(old_ino, old_dev);
60833 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
60834 + do_handle_delete(inodev, old_ino, old_dev);
60835 +
60836 + if (unlikely((unsigned long)matchn))
60837 + do_handle_create(matchn, old_dentry, mnt);
60838 +
60839 + write_unlock(&gr_inode_lock);
60840 + preempt_enable();
60841 +
60842 + return;
60843 +}
60844 +
60845 +static int
60846 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
60847 + unsigned char **sum)
60848 +{
60849 + struct acl_role_label *r;
60850 + struct role_allowed_ip *ipp;
60851 + struct role_transition *trans;
60852 + unsigned int i;
60853 + int found = 0;
60854 + u32 curr_ip = current->signal->curr_ip;
60855 +
60856 + current->signal->saved_ip = curr_ip;
60857 +
60858 + /* check transition table */
60859 +
60860 + for (trans = current->role->transitions; trans; trans = trans->next) {
60861 + if (!strcmp(rolename, trans->rolename)) {
60862 + found = 1;
60863 + break;
60864 + }
60865 + }
60866 +
60867 + if (!found)
60868 + return 0;
60869 +
60870 + /* handle special roles that do not require authentication
60871 + and check ip */
60872 +
60873 + FOR_EACH_ROLE_START(r)
60874 + if (!strcmp(rolename, r->rolename) &&
60875 + (r->roletype & GR_ROLE_SPECIAL)) {
60876 + found = 0;
60877 + if (r->allowed_ips != NULL) {
60878 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
60879 + if ((ntohl(curr_ip) & ipp->netmask) ==
60880 + (ntohl(ipp->addr) & ipp->netmask))
60881 + found = 1;
60882 + }
60883 + } else
60884 + found = 2;
60885 + if (!found)
60886 + return 0;
60887 +
60888 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
60889 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
60890 + *salt = NULL;
60891 + *sum = NULL;
60892 + return 1;
60893 + }
60894 + }
60895 + FOR_EACH_ROLE_END(r)
60896 +
60897 + for (i = 0; i < num_sprole_pws; i++) {
60898 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
60899 + *salt = acl_special_roles[i]->salt;
60900 + *sum = acl_special_roles[i]->sum;
60901 + return 1;
60902 + }
60903 + }
60904 +
60905 + return 0;
60906 +}
60907 +
60908 +static void
60909 +assign_special_role(char *rolename)
60910 +{
60911 + struct acl_object_label *obj;
60912 + struct acl_role_label *r;
60913 + struct acl_role_label *assigned = NULL;
60914 + struct task_struct *tsk;
60915 + struct file *filp;
60916 +
60917 + FOR_EACH_ROLE_START(r)
60918 + if (!strcmp(rolename, r->rolename) &&
60919 + (r->roletype & GR_ROLE_SPECIAL)) {
60920 + assigned = r;
60921 + break;
60922 + }
60923 + FOR_EACH_ROLE_END(r)
60924 +
60925 + if (!assigned)
60926 + return;
60927 +
60928 + read_lock(&tasklist_lock);
60929 + read_lock(&grsec_exec_file_lock);
60930 +
60931 + tsk = current->real_parent;
60932 + if (tsk == NULL)
60933 + goto out_unlock;
60934 +
60935 + filp = tsk->exec_file;
60936 + if (filp == NULL)
60937 + goto out_unlock;
60938 +
60939 + tsk->is_writable = 0;
60940 +
60941 + tsk->acl_sp_role = 1;
60942 + tsk->acl_role_id = ++acl_sp_role_value;
60943 + tsk->role = assigned;
60944 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
60945 +
60946 + /* ignore additional mmap checks for processes that are writable
60947 + by the default ACL */
60948 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60949 + if (unlikely(obj->mode & GR_WRITE))
60950 + tsk->is_writable = 1;
60951 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
60952 + if (unlikely(obj->mode & GR_WRITE))
60953 + tsk->is_writable = 1;
60954 +
60955 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60956 + 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));
60957 +#endif
60958 +
60959 +out_unlock:
60960 + read_unlock(&grsec_exec_file_lock);
60961 + read_unlock(&tasklist_lock);
60962 + return;
60963 +}
60964 +
60965 +int gr_check_secure_terminal(struct task_struct *task)
60966 +{
60967 + struct task_struct *p, *p2, *p3;
60968 + struct files_struct *files;
60969 + struct fdtable *fdt;
60970 + struct file *our_file = NULL, *file;
60971 + int i;
60972 +
60973 + if (task->signal->tty == NULL)
60974 + return 1;
60975 +
60976 + files = get_files_struct(task);
60977 + if (files != NULL) {
60978 + rcu_read_lock();
60979 + fdt = files_fdtable(files);
60980 + for (i=0; i < fdt->max_fds; i++) {
60981 + file = fcheck_files(files, i);
60982 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
60983 + get_file(file);
60984 + our_file = file;
60985 + }
60986 + }
60987 + rcu_read_unlock();
60988 + put_files_struct(files);
60989 + }
60990 +
60991 + if (our_file == NULL)
60992 + return 1;
60993 +
60994 + read_lock(&tasklist_lock);
60995 + do_each_thread(p2, p) {
60996 + files = get_files_struct(p);
60997 + if (files == NULL ||
60998 + (p->signal && p->signal->tty == task->signal->tty)) {
60999 + if (files != NULL)
61000 + put_files_struct(files);
61001 + continue;
61002 + }
61003 + rcu_read_lock();
61004 + fdt = files_fdtable(files);
61005 + for (i=0; i < fdt->max_fds; i++) {
61006 + file = fcheck_files(files, i);
61007 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
61008 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
61009 + p3 = task;
61010 + while (task_pid_nr(p3) > 0) {
61011 + if (p3 == p)
61012 + break;
61013 + p3 = p3->real_parent;
61014 + }
61015 + if (p3 == p)
61016 + break;
61017 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
61018 + gr_handle_alertkill(p);
61019 + rcu_read_unlock();
61020 + put_files_struct(files);
61021 + read_unlock(&tasklist_lock);
61022 + fput(our_file);
61023 + return 0;
61024 + }
61025 + }
61026 + rcu_read_unlock();
61027 + put_files_struct(files);
61028 + } while_each_thread(p2, p);
61029 + read_unlock(&tasklist_lock);
61030 +
61031 + fput(our_file);
61032 + return 1;
61033 +}
61034 +
61035 +static int gr_rbac_disable(void *unused)
61036 +{
61037 + pax_open_kernel();
61038 + gr_status &= ~GR_READY;
61039 + pax_close_kernel();
61040 +
61041 + return 0;
61042 +}
61043 +
61044 +ssize_t
61045 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
61046 +{
61047 + struct gr_arg_wrapper uwrap;
61048 + unsigned char *sprole_salt = NULL;
61049 + unsigned char *sprole_sum = NULL;
61050 + int error = sizeof (struct gr_arg_wrapper);
61051 + int error2 = 0;
61052 +
61053 + mutex_lock(&gr_dev_mutex);
61054 +
61055 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
61056 + error = -EPERM;
61057 + goto out;
61058 + }
61059 +
61060 + if (count != sizeof (struct gr_arg_wrapper)) {
61061 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
61062 + error = -EINVAL;
61063 + goto out;
61064 + }
61065 +
61066 +
61067 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
61068 + gr_auth_expires = 0;
61069 + gr_auth_attempts = 0;
61070 + }
61071 +
61072 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
61073 + error = -EFAULT;
61074 + goto out;
61075 + }
61076 +
61077 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
61078 + error = -EINVAL;
61079 + goto out;
61080 + }
61081 +
61082 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
61083 + error = -EFAULT;
61084 + goto out;
61085 + }
61086 +
61087 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61088 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61089 + time_after(gr_auth_expires, get_seconds())) {
61090 + error = -EBUSY;
61091 + goto out;
61092 + }
61093 +
61094 + /* if non-root trying to do anything other than use a special role,
61095 + do not attempt authentication, do not count towards authentication
61096 + locking
61097 + */
61098 +
61099 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
61100 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61101 + gr_is_global_nonroot(current_uid())) {
61102 + error = -EPERM;
61103 + goto out;
61104 + }
61105 +
61106 + /* ensure pw and special role name are null terminated */
61107 +
61108 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
61109 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
61110 +
61111 + /* Okay.
61112 + * We have our enough of the argument structure..(we have yet
61113 + * to copy_from_user the tables themselves) . Copy the tables
61114 + * only if we need them, i.e. for loading operations. */
61115 +
61116 + switch (gr_usermode->mode) {
61117 + case GR_STATUS:
61118 + if (gr_status & GR_READY) {
61119 + error = 1;
61120 + if (!gr_check_secure_terminal(current))
61121 + error = 3;
61122 + } else
61123 + error = 2;
61124 + goto out;
61125 + case GR_SHUTDOWN:
61126 + if ((gr_status & GR_READY)
61127 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61128 + stop_machine(gr_rbac_disable, NULL, NULL);
61129 + free_variables();
61130 + memset(gr_usermode, 0, sizeof (struct gr_arg));
61131 + memset(gr_system_salt, 0, GR_SALT_LEN);
61132 + memset(gr_system_sum, 0, GR_SHA_LEN);
61133 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
61134 + } else if (gr_status & GR_READY) {
61135 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
61136 + error = -EPERM;
61137 + } else {
61138 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
61139 + error = -EAGAIN;
61140 + }
61141 + break;
61142 + case GR_ENABLE:
61143 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
61144 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
61145 + else {
61146 + if (gr_status & GR_READY)
61147 + error = -EAGAIN;
61148 + else
61149 + error = error2;
61150 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
61151 + }
61152 + break;
61153 + case GR_RELOAD:
61154 + if (!(gr_status & GR_READY)) {
61155 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
61156 + error = -EAGAIN;
61157 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61158 + stop_machine(gr_rbac_disable, NULL, NULL);
61159 + free_variables();
61160 + error2 = gracl_init(gr_usermode);
61161 + if (!error2)
61162 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
61163 + else {
61164 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61165 + error = error2;
61166 + }
61167 + } else {
61168 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61169 + error = -EPERM;
61170 + }
61171 + break;
61172 + case GR_SEGVMOD:
61173 + if (unlikely(!(gr_status & GR_READY))) {
61174 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
61175 + error = -EAGAIN;
61176 + break;
61177 + }
61178 +
61179 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61180 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
61181 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
61182 + struct acl_subject_label *segvacl;
61183 + segvacl =
61184 + lookup_acl_subj_label(gr_usermode->segv_inode,
61185 + gr_usermode->segv_device,
61186 + current->role);
61187 + if (segvacl) {
61188 + segvacl->crashes = 0;
61189 + segvacl->expires = 0;
61190 + }
61191 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
61192 + gr_remove_uid(gr_usermode->segv_uid);
61193 + }
61194 + } else {
61195 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
61196 + error = -EPERM;
61197 + }
61198 + break;
61199 + case GR_SPROLE:
61200 + case GR_SPROLEPAM:
61201 + if (unlikely(!(gr_status & GR_READY))) {
61202 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
61203 + error = -EAGAIN;
61204 + break;
61205 + }
61206 +
61207 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
61208 + current->role->expires = 0;
61209 + current->role->auth_attempts = 0;
61210 + }
61211 +
61212 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61213 + time_after(current->role->expires, get_seconds())) {
61214 + error = -EBUSY;
61215 + goto out;
61216 + }
61217 +
61218 + if (lookup_special_role_auth
61219 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
61220 + && ((!sprole_salt && !sprole_sum)
61221 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
61222 + char *p = "";
61223 + assign_special_role(gr_usermode->sp_role);
61224 + read_lock(&tasklist_lock);
61225 + if (current->real_parent)
61226 + p = current->real_parent->role->rolename;
61227 + read_unlock(&tasklist_lock);
61228 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
61229 + p, acl_sp_role_value);
61230 + } else {
61231 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
61232 + error = -EPERM;
61233 + if(!(current->role->auth_attempts++))
61234 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61235 +
61236 + goto out;
61237 + }
61238 + break;
61239 + case GR_UNSPROLE:
61240 + if (unlikely(!(gr_status & GR_READY))) {
61241 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
61242 + error = -EAGAIN;
61243 + break;
61244 + }
61245 +
61246 + if (current->role->roletype & GR_ROLE_SPECIAL) {
61247 + char *p = "";
61248 + int i = 0;
61249 +
61250 + read_lock(&tasklist_lock);
61251 + if (current->real_parent) {
61252 + p = current->real_parent->role->rolename;
61253 + i = current->real_parent->acl_role_id;
61254 + }
61255 + read_unlock(&tasklist_lock);
61256 +
61257 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
61258 + gr_set_acls(1);
61259 + } else {
61260 + error = -EPERM;
61261 + goto out;
61262 + }
61263 + break;
61264 + default:
61265 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
61266 + error = -EINVAL;
61267 + break;
61268 + }
61269 +
61270 + if (error != -EPERM)
61271 + goto out;
61272 +
61273 + if(!(gr_auth_attempts++))
61274 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61275 +
61276 + out:
61277 + mutex_unlock(&gr_dev_mutex);
61278 + return error;
61279 +}
61280 +
61281 +/* must be called with
61282 + rcu_read_lock();
61283 + read_lock(&tasklist_lock);
61284 + read_lock(&grsec_exec_file_lock);
61285 +*/
61286 +int gr_apply_subject_to_task(struct task_struct *task)
61287 +{
61288 + struct acl_object_label *obj;
61289 + char *tmpname;
61290 + struct acl_subject_label *tmpsubj;
61291 + struct file *filp;
61292 + struct name_entry *nmatch;
61293 +
61294 + filp = task->exec_file;
61295 + if (filp == NULL)
61296 + return 0;
61297 +
61298 + /* the following is to apply the correct subject
61299 + on binaries running when the RBAC system
61300 + is enabled, when the binaries have been
61301 + replaced or deleted since their execution
61302 + -----
61303 + when the RBAC system starts, the inode/dev
61304 + from exec_file will be one the RBAC system
61305 + is unaware of. It only knows the inode/dev
61306 + of the present file on disk, or the absence
61307 + of it.
61308 + */
61309 + preempt_disable();
61310 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
61311 +
61312 + nmatch = lookup_name_entry(tmpname);
61313 + preempt_enable();
61314 + tmpsubj = NULL;
61315 + if (nmatch) {
61316 + if (nmatch->deleted)
61317 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
61318 + else
61319 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
61320 + if (tmpsubj != NULL)
61321 + task->acl = tmpsubj;
61322 + }
61323 + if (tmpsubj == NULL)
61324 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
61325 + task->role);
61326 + if (task->acl) {
61327 + task->is_writable = 0;
61328 + /* ignore additional mmap checks for processes that are writable
61329 + by the default ACL */
61330 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61331 + if (unlikely(obj->mode & GR_WRITE))
61332 + task->is_writable = 1;
61333 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
61334 + if (unlikely(obj->mode & GR_WRITE))
61335 + task->is_writable = 1;
61336 +
61337 + gr_set_proc_res(task);
61338 +
61339 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61340 + 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);
61341 +#endif
61342 + } else {
61343 + return 1;
61344 + }
61345 +
61346 + return 0;
61347 +}
61348 +
61349 +int
61350 +gr_set_acls(const int type)
61351 +{
61352 + struct task_struct *task, *task2;
61353 + struct acl_role_label *role = current->role;
61354 + __u16 acl_role_id = current->acl_role_id;
61355 + const struct cred *cred;
61356 + int ret;
61357 +
61358 + rcu_read_lock();
61359 + read_lock(&tasklist_lock);
61360 + read_lock(&grsec_exec_file_lock);
61361 + do_each_thread(task2, task) {
61362 + /* check to see if we're called from the exit handler,
61363 + if so, only replace ACLs that have inherited the admin
61364 + ACL */
61365 +
61366 + if (type && (task->role != role ||
61367 + task->acl_role_id != acl_role_id))
61368 + continue;
61369 +
61370 + task->acl_role_id = 0;
61371 + task->acl_sp_role = 0;
61372 +
61373 + if (task->exec_file) {
61374 + cred = __task_cred(task);
61375 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
61376 + ret = gr_apply_subject_to_task(task);
61377 + if (ret) {
61378 + read_unlock(&grsec_exec_file_lock);
61379 + read_unlock(&tasklist_lock);
61380 + rcu_read_unlock();
61381 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
61382 + return ret;
61383 + }
61384 + } else {
61385 + // it's a kernel process
61386 + task->role = kernel_role;
61387 + task->acl = kernel_role->root_label;
61388 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
61389 + task->acl->mode &= ~GR_PROCFIND;
61390 +#endif
61391 + }
61392 + } while_each_thread(task2, task);
61393 + read_unlock(&grsec_exec_file_lock);
61394 + read_unlock(&tasklist_lock);
61395 + rcu_read_unlock();
61396 +
61397 + return 0;
61398 +}
61399 +
61400 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
61401 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
61402 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
61403 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
61404 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
61405 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
61406 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
61407 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
61408 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
61409 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
61410 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
61411 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
61412 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
61413 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
61414 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
61415 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
61416 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
61417 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
61418 +};
61419 +
61420 +void
61421 +gr_learn_resource(const struct task_struct *task,
61422 + const int res, const unsigned long wanted, const int gt)
61423 +{
61424 + struct acl_subject_label *acl;
61425 + const struct cred *cred;
61426 +
61427 + if (unlikely((gr_status & GR_READY) &&
61428 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
61429 + goto skip_reslog;
61430 +
61431 + gr_log_resource(task, res, wanted, gt);
61432 +skip_reslog:
61433 +
61434 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
61435 + return;
61436 +
61437 + acl = task->acl;
61438 +
61439 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
61440 + !(acl->resmask & (1U << (unsigned short) res))))
61441 + return;
61442 +
61443 + if (wanted >= acl->res[res].rlim_cur) {
61444 + unsigned long res_add;
61445 +
61446 + res_add = wanted + res_learn_bumps[res];
61447 +
61448 + acl->res[res].rlim_cur = res_add;
61449 +
61450 + if (wanted > acl->res[res].rlim_max)
61451 + acl->res[res].rlim_max = res_add;
61452 +
61453 + /* only log the subject filename, since resource logging is supported for
61454 + single-subject learning only */
61455 + rcu_read_lock();
61456 + cred = __task_cred(task);
61457 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61458 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
61459 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
61460 + "", (unsigned long) res, &task->signal->saved_ip);
61461 + rcu_read_unlock();
61462 + }
61463 +
61464 + return;
61465 +}
61466 +EXPORT_SYMBOL(gr_learn_resource);
61467 +#endif
61468 +
61469 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
61470 +void
61471 +pax_set_initial_flags(struct linux_binprm *bprm)
61472 +{
61473 + struct task_struct *task = current;
61474 + struct acl_subject_label *proc;
61475 + unsigned long flags;
61476 +
61477 + if (unlikely(!(gr_status & GR_READY)))
61478 + return;
61479 +
61480 + flags = pax_get_flags(task);
61481 +
61482 + proc = task->acl;
61483 +
61484 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
61485 + flags &= ~MF_PAX_PAGEEXEC;
61486 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
61487 + flags &= ~MF_PAX_SEGMEXEC;
61488 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
61489 + flags &= ~MF_PAX_RANDMMAP;
61490 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
61491 + flags &= ~MF_PAX_EMUTRAMP;
61492 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
61493 + flags &= ~MF_PAX_MPROTECT;
61494 +
61495 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
61496 + flags |= MF_PAX_PAGEEXEC;
61497 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
61498 + flags |= MF_PAX_SEGMEXEC;
61499 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
61500 + flags |= MF_PAX_RANDMMAP;
61501 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
61502 + flags |= MF_PAX_EMUTRAMP;
61503 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
61504 + flags |= MF_PAX_MPROTECT;
61505 +
61506 + pax_set_flags(task, flags);
61507 +
61508 + return;
61509 +}
61510 +#endif
61511 +
61512 +int
61513 +gr_handle_proc_ptrace(struct task_struct *task)
61514 +{
61515 + struct file *filp;
61516 + struct task_struct *tmp = task;
61517 + struct task_struct *curtemp = current;
61518 + __u32 retmode;
61519 +
61520 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61521 + if (unlikely(!(gr_status & GR_READY)))
61522 + return 0;
61523 +#endif
61524 +
61525 + read_lock(&tasklist_lock);
61526 + read_lock(&grsec_exec_file_lock);
61527 + filp = task->exec_file;
61528 +
61529 + while (task_pid_nr(tmp) > 0) {
61530 + if (tmp == curtemp)
61531 + break;
61532 + tmp = tmp->real_parent;
61533 + }
61534 +
61535 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61536 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
61537 + read_unlock(&grsec_exec_file_lock);
61538 + read_unlock(&tasklist_lock);
61539 + return 1;
61540 + }
61541 +
61542 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61543 + if (!(gr_status & GR_READY)) {
61544 + read_unlock(&grsec_exec_file_lock);
61545 + read_unlock(&tasklist_lock);
61546 + return 0;
61547 + }
61548 +#endif
61549 +
61550 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
61551 + read_unlock(&grsec_exec_file_lock);
61552 + read_unlock(&tasklist_lock);
61553 +
61554 + if (retmode & GR_NOPTRACE)
61555 + return 1;
61556 +
61557 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
61558 + && (current->acl != task->acl || (current->acl != current->role->root_label
61559 + && task_pid_nr(current) != task_pid_nr(task))))
61560 + return 1;
61561 +
61562 + return 0;
61563 +}
61564 +
61565 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
61566 +{
61567 + if (unlikely(!(gr_status & GR_READY)))
61568 + return;
61569 +
61570 + if (!(current->role->roletype & GR_ROLE_GOD))
61571 + return;
61572 +
61573 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
61574 + p->role->rolename, gr_task_roletype_to_char(p),
61575 + p->acl->filename);
61576 +}
61577 +
61578 +int
61579 +gr_handle_ptrace(struct task_struct *task, const long request)
61580 +{
61581 + struct task_struct *tmp = task;
61582 + struct task_struct *curtemp = current;
61583 + __u32 retmode;
61584 +
61585 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61586 + if (unlikely(!(gr_status & GR_READY)))
61587 + return 0;
61588 +#endif
61589 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
61590 + read_lock(&tasklist_lock);
61591 + while (task_pid_nr(tmp) > 0) {
61592 + if (tmp == curtemp)
61593 + break;
61594 + tmp = tmp->real_parent;
61595 + }
61596 +
61597 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61598 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
61599 + read_unlock(&tasklist_lock);
61600 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61601 + return 1;
61602 + }
61603 + read_unlock(&tasklist_lock);
61604 + }
61605 +
61606 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61607 + if (!(gr_status & GR_READY))
61608 + return 0;
61609 +#endif
61610 +
61611 + read_lock(&grsec_exec_file_lock);
61612 + if (unlikely(!task->exec_file)) {
61613 + read_unlock(&grsec_exec_file_lock);
61614 + return 0;
61615 + }
61616 +
61617 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
61618 + read_unlock(&grsec_exec_file_lock);
61619 +
61620 + if (retmode & GR_NOPTRACE) {
61621 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61622 + return 1;
61623 + }
61624 +
61625 + if (retmode & GR_PTRACERD) {
61626 + switch (request) {
61627 + case PTRACE_SEIZE:
61628 + case PTRACE_POKETEXT:
61629 + case PTRACE_POKEDATA:
61630 + case PTRACE_POKEUSR:
61631 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
61632 + case PTRACE_SETREGS:
61633 + case PTRACE_SETFPREGS:
61634 +#endif
61635 +#ifdef CONFIG_X86
61636 + case PTRACE_SETFPXREGS:
61637 +#endif
61638 +#ifdef CONFIG_ALTIVEC
61639 + case PTRACE_SETVRREGS:
61640 +#endif
61641 + return 1;
61642 + default:
61643 + return 0;
61644 + }
61645 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
61646 + !(current->role->roletype & GR_ROLE_GOD) &&
61647 + (current->acl != task->acl)) {
61648 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61649 + return 1;
61650 + }
61651 +
61652 + return 0;
61653 +}
61654 +
61655 +static int is_writable_mmap(const struct file *filp)
61656 +{
61657 + struct task_struct *task = current;
61658 + struct acl_object_label *obj, *obj2;
61659 +
61660 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
61661 + !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))) {
61662 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61663 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
61664 + task->role->root_label);
61665 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
61666 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
61667 + return 1;
61668 + }
61669 + }
61670 + return 0;
61671 +}
61672 +
61673 +int
61674 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
61675 +{
61676 + __u32 mode;
61677 +
61678 + if (unlikely(!file || !(prot & PROT_EXEC)))
61679 + return 1;
61680 +
61681 + if (is_writable_mmap(file))
61682 + return 0;
61683 +
61684 + mode =
61685 + gr_search_file(file->f_path.dentry,
61686 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61687 + file->f_path.mnt);
61688 +
61689 + if (!gr_tpe_allow(file))
61690 + return 0;
61691 +
61692 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61693 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61694 + return 0;
61695 + } else if (unlikely(!(mode & GR_EXEC))) {
61696 + return 0;
61697 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61698 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61699 + return 1;
61700 + }
61701 +
61702 + return 1;
61703 +}
61704 +
61705 +int
61706 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
61707 +{
61708 + __u32 mode;
61709 +
61710 + if (unlikely(!file || !(prot & PROT_EXEC)))
61711 + return 1;
61712 +
61713 + if (is_writable_mmap(file))
61714 + return 0;
61715 +
61716 + mode =
61717 + gr_search_file(file->f_path.dentry,
61718 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61719 + file->f_path.mnt);
61720 +
61721 + if (!gr_tpe_allow(file))
61722 + return 0;
61723 +
61724 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61725 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61726 + return 0;
61727 + } else if (unlikely(!(mode & GR_EXEC))) {
61728 + return 0;
61729 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61730 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61731 + return 1;
61732 + }
61733 +
61734 + return 1;
61735 +}
61736 +
61737 +void
61738 +gr_acl_handle_psacct(struct task_struct *task, const long code)
61739 +{
61740 + unsigned long runtime;
61741 + unsigned long cputime;
61742 + unsigned int wday, cday;
61743 + __u8 whr, chr;
61744 + __u8 wmin, cmin;
61745 + __u8 wsec, csec;
61746 + struct timespec timeval;
61747 +
61748 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
61749 + !(task->acl->mode & GR_PROCACCT)))
61750 + return;
61751 +
61752 + do_posix_clock_monotonic_gettime(&timeval);
61753 + runtime = timeval.tv_sec - task->start_time.tv_sec;
61754 + wday = runtime / (3600 * 24);
61755 + runtime -= wday * (3600 * 24);
61756 + whr = runtime / 3600;
61757 + runtime -= whr * 3600;
61758 + wmin = runtime / 60;
61759 + runtime -= wmin * 60;
61760 + wsec = runtime;
61761 +
61762 + cputime = (task->utime + task->stime) / HZ;
61763 + cday = cputime / (3600 * 24);
61764 + cputime -= cday * (3600 * 24);
61765 + chr = cputime / 3600;
61766 + cputime -= chr * 3600;
61767 + cmin = cputime / 60;
61768 + cputime -= cmin * 60;
61769 + csec = cputime;
61770 +
61771 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
61772 +
61773 + return;
61774 +}
61775 +
61776 +void gr_set_kernel_label(struct task_struct *task)
61777 +{
61778 + if (gr_status & GR_READY) {
61779 + task->role = kernel_role;
61780 + task->acl = kernel_role->root_label;
61781 + }
61782 + return;
61783 +}
61784 +
61785 +#ifdef CONFIG_TASKSTATS
61786 +int gr_is_taskstats_denied(int pid)
61787 +{
61788 + struct task_struct *task;
61789 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61790 + const struct cred *cred;
61791 +#endif
61792 + int ret = 0;
61793 +
61794 + /* restrict taskstats viewing to un-chrooted root users
61795 + who have the 'view' subject flag if the RBAC system is enabled
61796 + */
61797 +
61798 + rcu_read_lock();
61799 + read_lock(&tasklist_lock);
61800 + task = find_task_by_vpid(pid);
61801 + if (task) {
61802 +#ifdef CONFIG_GRKERNSEC_CHROOT
61803 + if (proc_is_chrooted(task))
61804 + ret = -EACCES;
61805 +#endif
61806 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61807 + cred = __task_cred(task);
61808 +#ifdef CONFIG_GRKERNSEC_PROC_USER
61809 + if (gr_is_global_nonroot(cred->uid))
61810 + ret = -EACCES;
61811 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61812 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
61813 + ret = -EACCES;
61814 +#endif
61815 +#endif
61816 + if (gr_status & GR_READY) {
61817 + if (!(task->acl->mode & GR_VIEW))
61818 + ret = -EACCES;
61819 + }
61820 + } else
61821 + ret = -ENOENT;
61822 +
61823 + read_unlock(&tasklist_lock);
61824 + rcu_read_unlock();
61825 +
61826 + return ret;
61827 +}
61828 +#endif
61829 +
61830 +/* AUXV entries are filled via a descendant of search_binary_handler
61831 + after we've already applied the subject for the target
61832 +*/
61833 +int gr_acl_enable_at_secure(void)
61834 +{
61835 + if (unlikely(!(gr_status & GR_READY)))
61836 + return 0;
61837 +
61838 + if (current->acl->mode & GR_ATSECURE)
61839 + return 1;
61840 +
61841 + return 0;
61842 +}
61843 +
61844 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
61845 +{
61846 + struct task_struct *task = current;
61847 + struct dentry *dentry = file->f_path.dentry;
61848 + struct vfsmount *mnt = file->f_path.mnt;
61849 + struct acl_object_label *obj, *tmp;
61850 + struct acl_subject_label *subj;
61851 + unsigned int bufsize;
61852 + int is_not_root;
61853 + char *path;
61854 + dev_t dev = __get_dev(dentry);
61855 +
61856 + if (unlikely(!(gr_status & GR_READY)))
61857 + return 1;
61858 +
61859 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
61860 + return 1;
61861 +
61862 + /* ignore Eric Biederman */
61863 + if (IS_PRIVATE(dentry->d_inode))
61864 + return 1;
61865 +
61866 + subj = task->acl;
61867 + read_lock(&gr_inode_lock);
61868 + do {
61869 + obj = lookup_acl_obj_label(ino, dev, subj);
61870 + if (obj != NULL) {
61871 + read_unlock(&gr_inode_lock);
61872 + return (obj->mode & GR_FIND) ? 1 : 0;
61873 + }
61874 + } while ((subj = subj->parent_subject));
61875 + read_unlock(&gr_inode_lock);
61876 +
61877 + /* this is purely an optimization since we're looking for an object
61878 + for the directory we're doing a readdir on
61879 + if it's possible for any globbed object to match the entry we're
61880 + filling into the directory, then the object we find here will be
61881 + an anchor point with attached globbed objects
61882 + */
61883 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
61884 + if (obj->globbed == NULL)
61885 + return (obj->mode & GR_FIND) ? 1 : 0;
61886 +
61887 + is_not_root = ((obj->filename[0] == '/') &&
61888 + (obj->filename[1] == '\0')) ? 0 : 1;
61889 + bufsize = PAGE_SIZE - namelen - is_not_root;
61890 +
61891 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
61892 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
61893 + return 1;
61894 +
61895 + preempt_disable();
61896 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
61897 + bufsize);
61898 +
61899 + bufsize = strlen(path);
61900 +
61901 + /* if base is "/", don't append an additional slash */
61902 + if (is_not_root)
61903 + *(path + bufsize) = '/';
61904 + memcpy(path + bufsize + is_not_root, name, namelen);
61905 + *(path + bufsize + namelen + is_not_root) = '\0';
61906 +
61907 + tmp = obj->globbed;
61908 + while (tmp) {
61909 + if (!glob_match(tmp->filename, path)) {
61910 + preempt_enable();
61911 + return (tmp->mode & GR_FIND) ? 1 : 0;
61912 + }
61913 + tmp = tmp->next;
61914 + }
61915 + preempt_enable();
61916 + return (obj->mode & GR_FIND) ? 1 : 0;
61917 +}
61918 +
61919 +void gr_put_exec_file(struct task_struct *task)
61920 +{
61921 + struct file *filp;
61922 +
61923 + write_lock(&grsec_exec_file_lock);
61924 + filp = task->exec_file;
61925 + task->exec_file = NULL;
61926 + write_unlock(&grsec_exec_file_lock);
61927 +
61928 + if (filp)
61929 + fput(filp);
61930 +
61931 + return;
61932 +}
61933 +
61934 +
61935 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
61936 +EXPORT_SYMBOL(gr_acl_is_enabled);
61937 +#endif
61938 +EXPORT_SYMBOL(gr_set_kernel_label);
61939 +#ifdef CONFIG_SECURITY
61940 +EXPORT_SYMBOL(gr_check_user_change);
61941 +EXPORT_SYMBOL(gr_check_group_change);
61942 +#endif
61943 +
61944 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
61945 new file mode 100644
61946 index 0000000..34fefda
61947 --- /dev/null
61948 +++ b/grsecurity/gracl_alloc.c
61949 @@ -0,0 +1,105 @@
61950 +#include <linux/kernel.h>
61951 +#include <linux/mm.h>
61952 +#include <linux/slab.h>
61953 +#include <linux/vmalloc.h>
61954 +#include <linux/gracl.h>
61955 +#include <linux/grsecurity.h>
61956 +
61957 +static unsigned long alloc_stack_next = 1;
61958 +static unsigned long alloc_stack_size = 1;
61959 +static void **alloc_stack;
61960 +
61961 +static __inline__ int
61962 +alloc_pop(void)
61963 +{
61964 + if (alloc_stack_next == 1)
61965 + return 0;
61966 +
61967 + kfree(alloc_stack[alloc_stack_next - 2]);
61968 +
61969 + alloc_stack_next--;
61970 +
61971 + return 1;
61972 +}
61973 +
61974 +static __inline__ int
61975 +alloc_push(void *buf)
61976 +{
61977 + if (alloc_stack_next >= alloc_stack_size)
61978 + return 1;
61979 +
61980 + alloc_stack[alloc_stack_next - 1] = buf;
61981 +
61982 + alloc_stack_next++;
61983 +
61984 + return 0;
61985 +}
61986 +
61987 +void *
61988 +acl_alloc(unsigned long len)
61989 +{
61990 + void *ret = NULL;
61991 +
61992 + if (!len || len > PAGE_SIZE)
61993 + goto out;
61994 +
61995 + ret = kmalloc(len, GFP_KERNEL);
61996 +
61997 + if (ret) {
61998 + if (alloc_push(ret)) {
61999 + kfree(ret);
62000 + ret = NULL;
62001 + }
62002 + }
62003 +
62004 +out:
62005 + return ret;
62006 +}
62007 +
62008 +void *
62009 +acl_alloc_num(unsigned long num, unsigned long len)
62010 +{
62011 + if (!len || (num > (PAGE_SIZE / len)))
62012 + return NULL;
62013 +
62014 + return acl_alloc(num * len);
62015 +}
62016 +
62017 +void
62018 +acl_free_all(void)
62019 +{
62020 + if (gr_acl_is_enabled() || !alloc_stack)
62021 + return;
62022 +
62023 + while (alloc_pop()) ;
62024 +
62025 + if (alloc_stack) {
62026 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
62027 + kfree(alloc_stack);
62028 + else
62029 + vfree(alloc_stack);
62030 + }
62031 +
62032 + alloc_stack = NULL;
62033 + alloc_stack_size = 1;
62034 + alloc_stack_next = 1;
62035 +
62036 + return;
62037 +}
62038 +
62039 +int
62040 +acl_alloc_stack_init(unsigned long size)
62041 +{
62042 + if ((size * sizeof (void *)) <= PAGE_SIZE)
62043 + alloc_stack =
62044 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
62045 + else
62046 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
62047 +
62048 + alloc_stack_size = size;
62049 +
62050 + if (!alloc_stack)
62051 + return 0;
62052 + else
62053 + return 1;
62054 +}
62055 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
62056 new file mode 100644
62057 index 0000000..bdd51ea
62058 --- /dev/null
62059 +++ b/grsecurity/gracl_cap.c
62060 @@ -0,0 +1,110 @@
62061 +#include <linux/kernel.h>
62062 +#include <linux/module.h>
62063 +#include <linux/sched.h>
62064 +#include <linux/gracl.h>
62065 +#include <linux/grsecurity.h>
62066 +#include <linux/grinternal.h>
62067 +
62068 +extern const char *captab_log[];
62069 +extern int captab_log_entries;
62070 +
62071 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
62072 +{
62073 + struct acl_subject_label *curracl;
62074 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62075 + kernel_cap_t cap_audit = __cap_empty_set;
62076 +
62077 + if (!gr_acl_is_enabled())
62078 + return 1;
62079 +
62080 + curracl = task->acl;
62081 +
62082 + cap_drop = curracl->cap_lower;
62083 + cap_mask = curracl->cap_mask;
62084 + cap_audit = curracl->cap_invert_audit;
62085 +
62086 + while ((curracl = curracl->parent_subject)) {
62087 + /* if the cap isn't specified in the current computed mask but is specified in the
62088 + current level subject, and is lowered in the current level subject, then add
62089 + it to the set of dropped capabilities
62090 + otherwise, add the current level subject's mask to the current computed mask
62091 + */
62092 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62093 + cap_raise(cap_mask, cap);
62094 + if (cap_raised(curracl->cap_lower, cap))
62095 + cap_raise(cap_drop, cap);
62096 + if (cap_raised(curracl->cap_invert_audit, cap))
62097 + cap_raise(cap_audit, cap);
62098 + }
62099 + }
62100 +
62101 + if (!cap_raised(cap_drop, cap)) {
62102 + if (cap_raised(cap_audit, cap))
62103 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
62104 + return 1;
62105 + }
62106 +
62107 + curracl = task->acl;
62108 +
62109 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
62110 + && cap_raised(cred->cap_effective, cap)) {
62111 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
62112 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
62113 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
62114 + gr_to_filename(task->exec_file->f_path.dentry,
62115 + task->exec_file->f_path.mnt) : curracl->filename,
62116 + curracl->filename, 0UL,
62117 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
62118 + return 1;
62119 + }
62120 +
62121 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
62122 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
62123 +
62124 + return 0;
62125 +}
62126 +
62127 +int
62128 +gr_acl_is_capable(const int cap)
62129 +{
62130 + return gr_task_acl_is_capable(current, current_cred(), cap);
62131 +}
62132 +
62133 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
62134 +{
62135 + struct acl_subject_label *curracl;
62136 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62137 +
62138 + if (!gr_acl_is_enabled())
62139 + return 1;
62140 +
62141 + curracl = task->acl;
62142 +
62143 + cap_drop = curracl->cap_lower;
62144 + cap_mask = curracl->cap_mask;
62145 +
62146 + while ((curracl = curracl->parent_subject)) {
62147 + /* if the cap isn't specified in the current computed mask but is specified in the
62148 + current level subject, and is lowered in the current level subject, then add
62149 + it to the set of dropped capabilities
62150 + otherwise, add the current level subject's mask to the current computed mask
62151 + */
62152 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62153 + cap_raise(cap_mask, cap);
62154 + if (cap_raised(curracl->cap_lower, cap))
62155 + cap_raise(cap_drop, cap);
62156 + }
62157 + }
62158 +
62159 + if (!cap_raised(cap_drop, cap))
62160 + return 1;
62161 +
62162 + return 0;
62163 +}
62164 +
62165 +int
62166 +gr_acl_is_capable_nolog(const int cap)
62167 +{
62168 + return gr_task_acl_is_capable_nolog(current, cap);
62169 +}
62170 +
62171 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
62172 new file mode 100644
62173 index 0000000..a340c17
62174 --- /dev/null
62175 +++ b/grsecurity/gracl_fs.c
62176 @@ -0,0 +1,431 @@
62177 +#include <linux/kernel.h>
62178 +#include <linux/sched.h>
62179 +#include <linux/types.h>
62180 +#include <linux/fs.h>
62181 +#include <linux/file.h>
62182 +#include <linux/stat.h>
62183 +#include <linux/grsecurity.h>
62184 +#include <linux/grinternal.h>
62185 +#include <linux/gracl.h>
62186 +
62187 +umode_t
62188 +gr_acl_umask(void)
62189 +{
62190 + if (unlikely(!gr_acl_is_enabled()))
62191 + return 0;
62192 +
62193 + return current->role->umask;
62194 +}
62195 +
62196 +__u32
62197 +gr_acl_handle_hidden_file(const struct dentry * dentry,
62198 + const struct vfsmount * mnt)
62199 +{
62200 + __u32 mode;
62201 +
62202 + if (unlikely(!dentry->d_inode))
62203 + return GR_FIND;
62204 +
62205 + mode =
62206 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
62207 +
62208 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
62209 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62210 + return mode;
62211 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
62212 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62213 + return 0;
62214 + } else if (unlikely(!(mode & GR_FIND)))
62215 + return 0;
62216 +
62217 + return GR_FIND;
62218 +}
62219 +
62220 +__u32
62221 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
62222 + int acc_mode)
62223 +{
62224 + __u32 reqmode = GR_FIND;
62225 + __u32 mode;
62226 +
62227 + if (unlikely(!dentry->d_inode))
62228 + return reqmode;
62229 +
62230 + if (acc_mode & MAY_APPEND)
62231 + reqmode |= GR_APPEND;
62232 + else if (acc_mode & MAY_WRITE)
62233 + reqmode |= GR_WRITE;
62234 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
62235 + reqmode |= GR_READ;
62236 +
62237 + mode =
62238 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62239 + mnt);
62240 +
62241 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62242 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62243 + reqmode & GR_READ ? " reading" : "",
62244 + reqmode & GR_WRITE ? " writing" : reqmode &
62245 + GR_APPEND ? " appending" : "");
62246 + return reqmode;
62247 + } else
62248 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62249 + {
62250 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62251 + reqmode & GR_READ ? " reading" : "",
62252 + reqmode & GR_WRITE ? " writing" : reqmode &
62253 + GR_APPEND ? " appending" : "");
62254 + return 0;
62255 + } else if (unlikely((mode & reqmode) != reqmode))
62256 + return 0;
62257 +
62258 + return reqmode;
62259 +}
62260 +
62261 +__u32
62262 +gr_acl_handle_creat(const struct dentry * dentry,
62263 + const struct dentry * p_dentry,
62264 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
62265 + const int imode)
62266 +{
62267 + __u32 reqmode = GR_WRITE | GR_CREATE;
62268 + __u32 mode;
62269 +
62270 + if (acc_mode & MAY_APPEND)
62271 + reqmode |= GR_APPEND;
62272 + // if a directory was required or the directory already exists, then
62273 + // don't count this open as a read
62274 + if ((acc_mode & MAY_READ) &&
62275 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
62276 + reqmode |= GR_READ;
62277 + if ((open_flags & O_CREAT) &&
62278 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62279 + reqmode |= GR_SETID;
62280 +
62281 + mode =
62282 + gr_check_create(dentry, p_dentry, p_mnt,
62283 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62284 +
62285 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62286 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62287 + reqmode & GR_READ ? " reading" : "",
62288 + reqmode & GR_WRITE ? " writing" : reqmode &
62289 + GR_APPEND ? " appending" : "");
62290 + return reqmode;
62291 + } else
62292 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62293 + {
62294 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62295 + reqmode & GR_READ ? " reading" : "",
62296 + reqmode & GR_WRITE ? " writing" : reqmode &
62297 + GR_APPEND ? " appending" : "");
62298 + return 0;
62299 + } else if (unlikely((mode & reqmode) != reqmode))
62300 + return 0;
62301 +
62302 + return reqmode;
62303 +}
62304 +
62305 +__u32
62306 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
62307 + const int fmode)
62308 +{
62309 + __u32 mode, reqmode = GR_FIND;
62310 +
62311 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
62312 + reqmode |= GR_EXEC;
62313 + if (fmode & S_IWOTH)
62314 + reqmode |= GR_WRITE;
62315 + if (fmode & S_IROTH)
62316 + reqmode |= GR_READ;
62317 +
62318 + mode =
62319 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62320 + mnt);
62321 +
62322 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62323 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62324 + reqmode & GR_READ ? " reading" : "",
62325 + reqmode & GR_WRITE ? " writing" : "",
62326 + reqmode & GR_EXEC ? " executing" : "");
62327 + return reqmode;
62328 + } else
62329 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62330 + {
62331 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62332 + reqmode & GR_READ ? " reading" : "",
62333 + reqmode & GR_WRITE ? " writing" : "",
62334 + reqmode & GR_EXEC ? " executing" : "");
62335 + return 0;
62336 + } else if (unlikely((mode & reqmode) != reqmode))
62337 + return 0;
62338 +
62339 + return reqmode;
62340 +}
62341 +
62342 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
62343 +{
62344 + __u32 mode;
62345 +
62346 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
62347 +
62348 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62349 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
62350 + return mode;
62351 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62352 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
62353 + return 0;
62354 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62355 + return 0;
62356 +
62357 + return (reqmode);
62358 +}
62359 +
62360 +__u32
62361 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
62362 +{
62363 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
62364 +}
62365 +
62366 +__u32
62367 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
62368 +{
62369 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
62370 +}
62371 +
62372 +__u32
62373 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
62374 +{
62375 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
62376 +}
62377 +
62378 +__u32
62379 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
62380 +{
62381 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
62382 +}
62383 +
62384 +__u32
62385 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
62386 + umode_t *modeptr)
62387 +{
62388 + umode_t mode;
62389 +
62390 + *modeptr &= ~gr_acl_umask();
62391 + mode = *modeptr;
62392 +
62393 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
62394 + return 1;
62395 +
62396 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
62397 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
62398 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
62399 + GR_CHMOD_ACL_MSG);
62400 + } else {
62401 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
62402 + }
62403 +}
62404 +
62405 +__u32
62406 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
62407 +{
62408 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
62409 +}
62410 +
62411 +__u32
62412 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
62413 +{
62414 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
62415 +}
62416 +
62417 +__u32
62418 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
62419 +{
62420 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
62421 +}
62422 +
62423 +__u32
62424 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
62425 +{
62426 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
62427 + GR_UNIXCONNECT_ACL_MSG);
62428 +}
62429 +
62430 +/* hardlinks require at minimum create and link permission,
62431 + any additional privilege required is based on the
62432 + privilege of the file being linked to
62433 +*/
62434 +__u32
62435 +gr_acl_handle_link(const struct dentry * new_dentry,
62436 + const struct dentry * parent_dentry,
62437 + const struct vfsmount * parent_mnt,
62438 + const struct dentry * old_dentry,
62439 + const struct vfsmount * old_mnt, const struct filename *to)
62440 +{
62441 + __u32 mode;
62442 + __u32 needmode = GR_CREATE | GR_LINK;
62443 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
62444 +
62445 + mode =
62446 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
62447 + old_mnt);
62448 +
62449 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
62450 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62451 + return mode;
62452 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62453 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62454 + return 0;
62455 + } else if (unlikely((mode & needmode) != needmode))
62456 + return 0;
62457 +
62458 + return 1;
62459 +}
62460 +
62461 +__u32
62462 +gr_acl_handle_symlink(const struct dentry * new_dentry,
62463 + const struct dentry * parent_dentry,
62464 + const struct vfsmount * parent_mnt, const struct filename *from)
62465 +{
62466 + __u32 needmode = GR_WRITE | GR_CREATE;
62467 + __u32 mode;
62468 +
62469 + mode =
62470 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
62471 + GR_CREATE | GR_AUDIT_CREATE |
62472 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
62473 +
62474 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
62475 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62476 + return mode;
62477 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62478 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62479 + return 0;
62480 + } else if (unlikely((mode & needmode) != needmode))
62481 + return 0;
62482 +
62483 + return (GR_WRITE | GR_CREATE);
62484 +}
62485 +
62486 +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)
62487 +{
62488 + __u32 mode;
62489 +
62490 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62491 +
62492 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62493 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
62494 + return mode;
62495 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62496 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
62497 + return 0;
62498 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62499 + return 0;
62500 +
62501 + return (reqmode);
62502 +}
62503 +
62504 +__u32
62505 +gr_acl_handle_mknod(const struct dentry * new_dentry,
62506 + const struct dentry * parent_dentry,
62507 + const struct vfsmount * parent_mnt,
62508 + const int mode)
62509 +{
62510 + __u32 reqmode = GR_WRITE | GR_CREATE;
62511 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62512 + reqmode |= GR_SETID;
62513 +
62514 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62515 + reqmode, GR_MKNOD_ACL_MSG);
62516 +}
62517 +
62518 +__u32
62519 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
62520 + const struct dentry *parent_dentry,
62521 + const struct vfsmount *parent_mnt)
62522 +{
62523 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62524 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
62525 +}
62526 +
62527 +#define RENAME_CHECK_SUCCESS(old, new) \
62528 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
62529 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
62530 +
62531 +int
62532 +gr_acl_handle_rename(struct dentry *new_dentry,
62533 + struct dentry *parent_dentry,
62534 + const struct vfsmount *parent_mnt,
62535 + struct dentry *old_dentry,
62536 + struct inode *old_parent_inode,
62537 + struct vfsmount *old_mnt, const struct filename *newname)
62538 +{
62539 + __u32 comp1, comp2;
62540 + int error = 0;
62541 +
62542 + if (unlikely(!gr_acl_is_enabled()))
62543 + return 0;
62544 +
62545 + if (!new_dentry->d_inode) {
62546 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
62547 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
62548 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
62549 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
62550 + GR_DELETE | GR_AUDIT_DELETE |
62551 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62552 + GR_SUPPRESS, old_mnt);
62553 + } else {
62554 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
62555 + GR_CREATE | GR_DELETE |
62556 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
62557 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62558 + GR_SUPPRESS, parent_mnt);
62559 + comp2 =
62560 + gr_search_file(old_dentry,
62561 + GR_READ | GR_WRITE | GR_AUDIT_READ |
62562 + GR_DELETE | GR_AUDIT_DELETE |
62563 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
62564 + }
62565 +
62566 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
62567 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
62568 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62569 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
62570 + && !(comp2 & GR_SUPPRESS)) {
62571 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62572 + error = -EACCES;
62573 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
62574 + error = -EACCES;
62575 +
62576 + return error;
62577 +}
62578 +
62579 +void
62580 +gr_acl_handle_exit(void)
62581 +{
62582 + u16 id;
62583 + char *rolename;
62584 +
62585 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
62586 + !(current->role->roletype & GR_ROLE_PERSIST))) {
62587 + id = current->acl_role_id;
62588 + rolename = current->role->rolename;
62589 + gr_set_acls(1);
62590 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
62591 + }
62592 +
62593 + gr_put_exec_file(current);
62594 + return;
62595 +}
62596 +
62597 +int
62598 +gr_acl_handle_procpidmem(const struct task_struct *task)
62599 +{
62600 + if (unlikely(!gr_acl_is_enabled()))
62601 + return 0;
62602 +
62603 + if (task != current && task->acl->mode & GR_PROTPROCFD)
62604 + return -EACCES;
62605 +
62606 + return 0;
62607 +}
62608 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
62609 new file mode 100644
62610 index 0000000..8132048
62611 --- /dev/null
62612 +++ b/grsecurity/gracl_ip.c
62613 @@ -0,0 +1,387 @@
62614 +#include <linux/kernel.h>
62615 +#include <asm/uaccess.h>
62616 +#include <asm/errno.h>
62617 +#include <net/sock.h>
62618 +#include <linux/file.h>
62619 +#include <linux/fs.h>
62620 +#include <linux/net.h>
62621 +#include <linux/in.h>
62622 +#include <linux/skbuff.h>
62623 +#include <linux/ip.h>
62624 +#include <linux/udp.h>
62625 +#include <linux/types.h>
62626 +#include <linux/sched.h>
62627 +#include <linux/netdevice.h>
62628 +#include <linux/inetdevice.h>
62629 +#include <linux/gracl.h>
62630 +#include <linux/grsecurity.h>
62631 +#include <linux/grinternal.h>
62632 +
62633 +#define GR_BIND 0x01
62634 +#define GR_CONNECT 0x02
62635 +#define GR_INVERT 0x04
62636 +#define GR_BINDOVERRIDE 0x08
62637 +#define GR_CONNECTOVERRIDE 0x10
62638 +#define GR_SOCK_FAMILY 0x20
62639 +
62640 +static const char * gr_protocols[IPPROTO_MAX] = {
62641 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
62642 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
62643 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
62644 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
62645 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
62646 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
62647 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
62648 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
62649 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
62650 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
62651 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
62652 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
62653 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
62654 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
62655 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
62656 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
62657 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
62658 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
62659 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
62660 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
62661 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
62662 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
62663 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
62664 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
62665 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
62666 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
62667 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
62668 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
62669 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
62670 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
62671 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
62672 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
62673 + };
62674 +
62675 +static const char * gr_socktypes[SOCK_MAX] = {
62676 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
62677 + "unknown:7", "unknown:8", "unknown:9", "packet"
62678 + };
62679 +
62680 +static const char * gr_sockfamilies[AF_MAX+1] = {
62681 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
62682 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
62683 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
62684 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
62685 + };
62686 +
62687 +const char *
62688 +gr_proto_to_name(unsigned char proto)
62689 +{
62690 + return gr_protocols[proto];
62691 +}
62692 +
62693 +const char *
62694 +gr_socktype_to_name(unsigned char type)
62695 +{
62696 + return gr_socktypes[type];
62697 +}
62698 +
62699 +const char *
62700 +gr_sockfamily_to_name(unsigned char family)
62701 +{
62702 + return gr_sockfamilies[family];
62703 +}
62704 +
62705 +int
62706 +gr_search_socket(const int domain, const int type, const int protocol)
62707 +{
62708 + struct acl_subject_label *curr;
62709 + const struct cred *cred = current_cred();
62710 +
62711 + if (unlikely(!gr_acl_is_enabled()))
62712 + goto exit;
62713 +
62714 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
62715 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
62716 + goto exit; // let the kernel handle it
62717 +
62718 + curr = current->acl;
62719 +
62720 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
62721 + /* the family is allowed, if this is PF_INET allow it only if
62722 + the extra sock type/protocol checks pass */
62723 + if (domain == PF_INET)
62724 + goto inet_check;
62725 + goto exit;
62726 + } else {
62727 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62728 + __u32 fakeip = 0;
62729 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62730 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62731 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62732 + gr_to_filename(current->exec_file->f_path.dentry,
62733 + current->exec_file->f_path.mnt) :
62734 + curr->filename, curr->filename,
62735 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
62736 + &current->signal->saved_ip);
62737 + goto exit;
62738 + }
62739 + goto exit_fail;
62740 + }
62741 +
62742 +inet_check:
62743 + /* the rest of this checking is for IPv4 only */
62744 + if (!curr->ips)
62745 + goto exit;
62746 +
62747 + if ((curr->ip_type & (1U << type)) &&
62748 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
62749 + goto exit;
62750 +
62751 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62752 + /* we don't place acls on raw sockets , and sometimes
62753 + dgram/ip sockets are opened for ioctl and not
62754 + bind/connect, so we'll fake a bind learn log */
62755 + if (type == SOCK_RAW || type == SOCK_PACKET) {
62756 + __u32 fakeip = 0;
62757 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62758 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62759 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62760 + gr_to_filename(current->exec_file->f_path.dentry,
62761 + current->exec_file->f_path.mnt) :
62762 + curr->filename, curr->filename,
62763 + &fakeip, 0, type,
62764 + protocol, GR_CONNECT, &current->signal->saved_ip);
62765 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
62766 + __u32 fakeip = 0;
62767 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62768 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62769 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62770 + gr_to_filename(current->exec_file->f_path.dentry,
62771 + current->exec_file->f_path.mnt) :
62772 + curr->filename, curr->filename,
62773 + &fakeip, 0, type,
62774 + protocol, GR_BIND, &current->signal->saved_ip);
62775 + }
62776 + /* we'll log when they use connect or bind */
62777 + goto exit;
62778 + }
62779 +
62780 +exit_fail:
62781 + if (domain == PF_INET)
62782 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
62783 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
62784 + else
62785 +#ifndef CONFIG_IPV6
62786 + if (domain != PF_INET6)
62787 +#endif
62788 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
62789 + gr_socktype_to_name(type), protocol);
62790 +
62791 + return 0;
62792 +exit:
62793 + return 1;
62794 +}
62795 +
62796 +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)
62797 +{
62798 + if ((ip->mode & mode) &&
62799 + (ip_port >= ip->low) &&
62800 + (ip_port <= ip->high) &&
62801 + ((ntohl(ip_addr) & our_netmask) ==
62802 + (ntohl(our_addr) & our_netmask))
62803 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
62804 + && (ip->type & (1U << type))) {
62805 + if (ip->mode & GR_INVERT)
62806 + return 2; // specifically denied
62807 + else
62808 + return 1; // allowed
62809 + }
62810 +
62811 + return 0; // not specifically allowed, may continue parsing
62812 +}
62813 +
62814 +static int
62815 +gr_search_connectbind(const int full_mode, struct sock *sk,
62816 + struct sockaddr_in *addr, const int type)
62817 +{
62818 + char iface[IFNAMSIZ] = {0};
62819 + struct acl_subject_label *curr;
62820 + struct acl_ip_label *ip;
62821 + struct inet_sock *isk;
62822 + struct net_device *dev;
62823 + struct in_device *idev;
62824 + unsigned long i;
62825 + int ret;
62826 + int mode = full_mode & (GR_BIND | GR_CONNECT);
62827 + __u32 ip_addr = 0;
62828 + __u32 our_addr;
62829 + __u32 our_netmask;
62830 + char *p;
62831 + __u16 ip_port = 0;
62832 + const struct cred *cred = current_cred();
62833 +
62834 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
62835 + return 0;
62836 +
62837 + curr = current->acl;
62838 + isk = inet_sk(sk);
62839 +
62840 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
62841 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
62842 + addr->sin_addr.s_addr = curr->inaddr_any_override;
62843 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
62844 + struct sockaddr_in saddr;
62845 + int err;
62846 +
62847 + saddr.sin_family = AF_INET;
62848 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
62849 + saddr.sin_port = isk->inet_sport;
62850 +
62851 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
62852 + if (err)
62853 + return err;
62854 +
62855 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
62856 + if (err)
62857 + return err;
62858 + }
62859 +
62860 + if (!curr->ips)
62861 + return 0;
62862 +
62863 + ip_addr = addr->sin_addr.s_addr;
62864 + ip_port = ntohs(addr->sin_port);
62865 +
62866 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62867 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62868 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62869 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62870 + gr_to_filename(current->exec_file->f_path.dentry,
62871 + current->exec_file->f_path.mnt) :
62872 + curr->filename, curr->filename,
62873 + &ip_addr, ip_port, type,
62874 + sk->sk_protocol, mode, &current->signal->saved_ip);
62875 + return 0;
62876 + }
62877 +
62878 + for (i = 0; i < curr->ip_num; i++) {
62879 + ip = *(curr->ips + i);
62880 + if (ip->iface != NULL) {
62881 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
62882 + p = strchr(iface, ':');
62883 + if (p != NULL)
62884 + *p = '\0';
62885 + dev = dev_get_by_name(sock_net(sk), iface);
62886 + if (dev == NULL)
62887 + continue;
62888 + idev = in_dev_get(dev);
62889 + if (idev == NULL) {
62890 + dev_put(dev);
62891 + continue;
62892 + }
62893 + rcu_read_lock();
62894 + for_ifa(idev) {
62895 + if (!strcmp(ip->iface, ifa->ifa_label)) {
62896 + our_addr = ifa->ifa_address;
62897 + our_netmask = 0xffffffff;
62898 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
62899 + if (ret == 1) {
62900 + rcu_read_unlock();
62901 + in_dev_put(idev);
62902 + dev_put(dev);
62903 + return 0;
62904 + } else if (ret == 2) {
62905 + rcu_read_unlock();
62906 + in_dev_put(idev);
62907 + dev_put(dev);
62908 + goto denied;
62909 + }
62910 + }
62911 + } endfor_ifa(idev);
62912 + rcu_read_unlock();
62913 + in_dev_put(idev);
62914 + dev_put(dev);
62915 + } else {
62916 + our_addr = ip->addr;
62917 + our_netmask = ip->netmask;
62918 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
62919 + if (ret == 1)
62920 + return 0;
62921 + else if (ret == 2)
62922 + goto denied;
62923 + }
62924 + }
62925 +
62926 +denied:
62927 + if (mode == GR_BIND)
62928 + 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));
62929 + else if (mode == GR_CONNECT)
62930 + 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));
62931 +
62932 + return -EACCES;
62933 +}
62934 +
62935 +int
62936 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
62937 +{
62938 + /* always allow disconnection of dgram sockets with connect */
62939 + if (addr->sin_family == AF_UNSPEC)
62940 + return 0;
62941 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
62942 +}
62943 +
62944 +int
62945 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
62946 +{
62947 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
62948 +}
62949 +
62950 +int gr_search_listen(struct socket *sock)
62951 +{
62952 + struct sock *sk = sock->sk;
62953 + struct sockaddr_in addr;
62954 +
62955 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
62956 + addr.sin_port = inet_sk(sk)->inet_sport;
62957 +
62958 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
62959 +}
62960 +
62961 +int gr_search_accept(struct socket *sock)
62962 +{
62963 + struct sock *sk = sock->sk;
62964 + struct sockaddr_in addr;
62965 +
62966 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
62967 + addr.sin_port = inet_sk(sk)->inet_sport;
62968 +
62969 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
62970 +}
62971 +
62972 +int
62973 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
62974 +{
62975 + if (addr)
62976 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
62977 + else {
62978 + struct sockaddr_in sin;
62979 + const struct inet_sock *inet = inet_sk(sk);
62980 +
62981 + sin.sin_addr.s_addr = inet->inet_daddr;
62982 + sin.sin_port = inet->inet_dport;
62983 +
62984 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
62985 + }
62986 +}
62987 +
62988 +int
62989 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
62990 +{
62991 + struct sockaddr_in sin;
62992 +
62993 + if (unlikely(skb->len < sizeof (struct udphdr)))
62994 + return 0; // skip this packet
62995 +
62996 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
62997 + sin.sin_port = udp_hdr(skb)->source;
62998 +
62999 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63000 +}
63001 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
63002 new file mode 100644
63003 index 0000000..25f54ef
63004 --- /dev/null
63005 +++ b/grsecurity/gracl_learn.c
63006 @@ -0,0 +1,207 @@
63007 +#include <linux/kernel.h>
63008 +#include <linux/mm.h>
63009 +#include <linux/sched.h>
63010 +#include <linux/poll.h>
63011 +#include <linux/string.h>
63012 +#include <linux/file.h>
63013 +#include <linux/types.h>
63014 +#include <linux/vmalloc.h>
63015 +#include <linux/grinternal.h>
63016 +
63017 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
63018 + size_t count, loff_t *ppos);
63019 +extern int gr_acl_is_enabled(void);
63020 +
63021 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
63022 +static int gr_learn_attached;
63023 +
63024 +/* use a 512k buffer */
63025 +#define LEARN_BUFFER_SIZE (512 * 1024)
63026 +
63027 +static DEFINE_SPINLOCK(gr_learn_lock);
63028 +static DEFINE_MUTEX(gr_learn_user_mutex);
63029 +
63030 +/* we need to maintain two buffers, so that the kernel context of grlearn
63031 + uses a semaphore around the userspace copying, and the other kernel contexts
63032 + use a spinlock when copying into the buffer, since they cannot sleep
63033 +*/
63034 +static char *learn_buffer;
63035 +static char *learn_buffer_user;
63036 +static int learn_buffer_len;
63037 +static int learn_buffer_user_len;
63038 +
63039 +static ssize_t
63040 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
63041 +{
63042 + DECLARE_WAITQUEUE(wait, current);
63043 + ssize_t retval = 0;
63044 +
63045 + add_wait_queue(&learn_wait, &wait);
63046 + set_current_state(TASK_INTERRUPTIBLE);
63047 + do {
63048 + mutex_lock(&gr_learn_user_mutex);
63049 + spin_lock(&gr_learn_lock);
63050 + if (learn_buffer_len)
63051 + break;
63052 + spin_unlock(&gr_learn_lock);
63053 + mutex_unlock(&gr_learn_user_mutex);
63054 + if (file->f_flags & O_NONBLOCK) {
63055 + retval = -EAGAIN;
63056 + goto out;
63057 + }
63058 + if (signal_pending(current)) {
63059 + retval = -ERESTARTSYS;
63060 + goto out;
63061 + }
63062 +
63063 + schedule();
63064 + } while (1);
63065 +
63066 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
63067 + learn_buffer_user_len = learn_buffer_len;
63068 + retval = learn_buffer_len;
63069 + learn_buffer_len = 0;
63070 +
63071 + spin_unlock(&gr_learn_lock);
63072 +
63073 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
63074 + retval = -EFAULT;
63075 +
63076 + mutex_unlock(&gr_learn_user_mutex);
63077 +out:
63078 + set_current_state(TASK_RUNNING);
63079 + remove_wait_queue(&learn_wait, &wait);
63080 + return retval;
63081 +}
63082 +
63083 +static unsigned int
63084 +poll_learn(struct file * file, poll_table * wait)
63085 +{
63086 + poll_wait(file, &learn_wait, wait);
63087 +
63088 + if (learn_buffer_len)
63089 + return (POLLIN | POLLRDNORM);
63090 +
63091 + return 0;
63092 +}
63093 +
63094 +void
63095 +gr_clear_learn_entries(void)
63096 +{
63097 + char *tmp;
63098 +
63099 + mutex_lock(&gr_learn_user_mutex);
63100 + spin_lock(&gr_learn_lock);
63101 + tmp = learn_buffer;
63102 + learn_buffer = NULL;
63103 + spin_unlock(&gr_learn_lock);
63104 + if (tmp)
63105 + vfree(tmp);
63106 + if (learn_buffer_user != NULL) {
63107 + vfree(learn_buffer_user);
63108 + learn_buffer_user = NULL;
63109 + }
63110 + learn_buffer_len = 0;
63111 + mutex_unlock(&gr_learn_user_mutex);
63112 +
63113 + return;
63114 +}
63115 +
63116 +void
63117 +gr_add_learn_entry(const char *fmt, ...)
63118 +{
63119 + va_list args;
63120 + unsigned int len;
63121 +
63122 + if (!gr_learn_attached)
63123 + return;
63124 +
63125 + spin_lock(&gr_learn_lock);
63126 +
63127 + /* leave a gap at the end so we know when it's "full" but don't have to
63128 + compute the exact length of the string we're trying to append
63129 + */
63130 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
63131 + spin_unlock(&gr_learn_lock);
63132 + wake_up_interruptible(&learn_wait);
63133 + return;
63134 + }
63135 + if (learn_buffer == NULL) {
63136 + spin_unlock(&gr_learn_lock);
63137 + return;
63138 + }
63139 +
63140 + va_start(args, fmt);
63141 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
63142 + va_end(args);
63143 +
63144 + learn_buffer_len += len + 1;
63145 +
63146 + spin_unlock(&gr_learn_lock);
63147 + wake_up_interruptible(&learn_wait);
63148 +
63149 + return;
63150 +}
63151 +
63152 +static int
63153 +open_learn(struct inode *inode, struct file *file)
63154 +{
63155 + if (file->f_mode & FMODE_READ && gr_learn_attached)
63156 + return -EBUSY;
63157 + if (file->f_mode & FMODE_READ) {
63158 + int retval = 0;
63159 + mutex_lock(&gr_learn_user_mutex);
63160 + if (learn_buffer == NULL)
63161 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
63162 + if (learn_buffer_user == NULL)
63163 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
63164 + if (learn_buffer == NULL) {
63165 + retval = -ENOMEM;
63166 + goto out_error;
63167 + }
63168 + if (learn_buffer_user == NULL) {
63169 + retval = -ENOMEM;
63170 + goto out_error;
63171 + }
63172 + learn_buffer_len = 0;
63173 + learn_buffer_user_len = 0;
63174 + gr_learn_attached = 1;
63175 +out_error:
63176 + mutex_unlock(&gr_learn_user_mutex);
63177 + return retval;
63178 + }
63179 + return 0;
63180 +}
63181 +
63182 +static int
63183 +close_learn(struct inode *inode, struct file *file)
63184 +{
63185 + if (file->f_mode & FMODE_READ) {
63186 + char *tmp = NULL;
63187 + mutex_lock(&gr_learn_user_mutex);
63188 + spin_lock(&gr_learn_lock);
63189 + tmp = learn_buffer;
63190 + learn_buffer = NULL;
63191 + spin_unlock(&gr_learn_lock);
63192 + if (tmp)
63193 + vfree(tmp);
63194 + if (learn_buffer_user != NULL) {
63195 + vfree(learn_buffer_user);
63196 + learn_buffer_user = NULL;
63197 + }
63198 + learn_buffer_len = 0;
63199 + learn_buffer_user_len = 0;
63200 + gr_learn_attached = 0;
63201 + mutex_unlock(&gr_learn_user_mutex);
63202 + }
63203 +
63204 + return 0;
63205 +}
63206 +
63207 +const struct file_operations grsec_fops = {
63208 + .read = read_learn,
63209 + .write = write_grsec_handler,
63210 + .open = open_learn,
63211 + .release = close_learn,
63212 + .poll = poll_learn,
63213 +};
63214 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
63215 new file mode 100644
63216 index 0000000..39645c9
63217 --- /dev/null
63218 +++ b/grsecurity/gracl_res.c
63219 @@ -0,0 +1,68 @@
63220 +#include <linux/kernel.h>
63221 +#include <linux/sched.h>
63222 +#include <linux/gracl.h>
63223 +#include <linux/grinternal.h>
63224 +
63225 +static const char *restab_log[] = {
63226 + [RLIMIT_CPU] = "RLIMIT_CPU",
63227 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
63228 + [RLIMIT_DATA] = "RLIMIT_DATA",
63229 + [RLIMIT_STACK] = "RLIMIT_STACK",
63230 + [RLIMIT_CORE] = "RLIMIT_CORE",
63231 + [RLIMIT_RSS] = "RLIMIT_RSS",
63232 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
63233 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
63234 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
63235 + [RLIMIT_AS] = "RLIMIT_AS",
63236 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
63237 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
63238 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
63239 + [RLIMIT_NICE] = "RLIMIT_NICE",
63240 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
63241 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
63242 + [GR_CRASH_RES] = "RLIMIT_CRASH"
63243 +};
63244 +
63245 +void
63246 +gr_log_resource(const struct task_struct *task,
63247 + const int res, const unsigned long wanted, const int gt)
63248 +{
63249 + const struct cred *cred;
63250 + unsigned long rlim;
63251 +
63252 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
63253 + return;
63254 +
63255 + // not yet supported resource
63256 + if (unlikely(!restab_log[res]))
63257 + return;
63258 +
63259 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
63260 + rlim = task_rlimit_max(task, res);
63261 + else
63262 + rlim = task_rlimit(task, res);
63263 +
63264 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
63265 + return;
63266 +
63267 + rcu_read_lock();
63268 + cred = __task_cred(task);
63269 +
63270 + if (res == RLIMIT_NPROC &&
63271 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
63272 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
63273 + goto out_rcu_unlock;
63274 + else if (res == RLIMIT_MEMLOCK &&
63275 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
63276 + goto out_rcu_unlock;
63277 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
63278 + goto out_rcu_unlock;
63279 + rcu_read_unlock();
63280 +
63281 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
63282 +
63283 + return;
63284 +out_rcu_unlock:
63285 + rcu_read_unlock();
63286 + return;
63287 +}
63288 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
63289 new file mode 100644
63290 index 0000000..4dcc92a
63291 --- /dev/null
63292 +++ b/grsecurity/gracl_segv.c
63293 @@ -0,0 +1,305 @@
63294 +#include <linux/kernel.h>
63295 +#include <linux/mm.h>
63296 +#include <asm/uaccess.h>
63297 +#include <asm/errno.h>
63298 +#include <asm/mman.h>
63299 +#include <net/sock.h>
63300 +#include <linux/file.h>
63301 +#include <linux/fs.h>
63302 +#include <linux/net.h>
63303 +#include <linux/in.h>
63304 +#include <linux/slab.h>
63305 +#include <linux/types.h>
63306 +#include <linux/sched.h>
63307 +#include <linux/timer.h>
63308 +#include <linux/gracl.h>
63309 +#include <linux/grsecurity.h>
63310 +#include <linux/grinternal.h>
63311 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63312 +#include <linux/magic.h>
63313 +#include <linux/pagemap.h>
63314 +#include "../fs/btrfs/async-thread.h"
63315 +#include "../fs/btrfs/ctree.h"
63316 +#include "../fs/btrfs/btrfs_inode.h"
63317 +#endif
63318 +
63319 +static struct crash_uid *uid_set;
63320 +static unsigned short uid_used;
63321 +static DEFINE_SPINLOCK(gr_uid_lock);
63322 +extern rwlock_t gr_inode_lock;
63323 +extern struct acl_subject_label *
63324 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
63325 + struct acl_role_label *role);
63326 +
63327 +static inline dev_t __get_dev(const struct dentry *dentry)
63328 +{
63329 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63330 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
63331 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
63332 + else
63333 +#endif
63334 + return dentry->d_sb->s_dev;
63335 +}
63336 +
63337 +int
63338 +gr_init_uidset(void)
63339 +{
63340 + uid_set =
63341 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
63342 + uid_used = 0;
63343 +
63344 + return uid_set ? 1 : 0;
63345 +}
63346 +
63347 +void
63348 +gr_free_uidset(void)
63349 +{
63350 + if (uid_set)
63351 + kfree(uid_set);
63352 +
63353 + return;
63354 +}
63355 +
63356 +int
63357 +gr_find_uid(const uid_t uid)
63358 +{
63359 + struct crash_uid *tmp = uid_set;
63360 + uid_t buid;
63361 + int low = 0, high = uid_used - 1, mid;
63362 +
63363 + while (high >= low) {
63364 + mid = (low + high) >> 1;
63365 + buid = tmp[mid].uid;
63366 + if (buid == uid)
63367 + return mid;
63368 + if (buid > uid)
63369 + high = mid - 1;
63370 + if (buid < uid)
63371 + low = mid + 1;
63372 + }
63373 +
63374 + return -1;
63375 +}
63376 +
63377 +static __inline__ void
63378 +gr_insertsort(void)
63379 +{
63380 + unsigned short i, j;
63381 + struct crash_uid index;
63382 +
63383 + for (i = 1; i < uid_used; i++) {
63384 + index = uid_set[i];
63385 + j = i;
63386 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
63387 + uid_set[j] = uid_set[j - 1];
63388 + j--;
63389 + }
63390 + uid_set[j] = index;
63391 + }
63392 +
63393 + return;
63394 +}
63395 +
63396 +static __inline__ void
63397 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
63398 +{
63399 + int loc;
63400 + uid_t uid = GR_GLOBAL_UID(kuid);
63401 +
63402 + if (uid_used == GR_UIDTABLE_MAX)
63403 + return;
63404 +
63405 + loc = gr_find_uid(uid);
63406 +
63407 + if (loc >= 0) {
63408 + uid_set[loc].expires = expires;
63409 + return;
63410 + }
63411 +
63412 + uid_set[uid_used].uid = uid;
63413 + uid_set[uid_used].expires = expires;
63414 + uid_used++;
63415 +
63416 + gr_insertsort();
63417 +
63418 + return;
63419 +}
63420 +
63421 +void
63422 +gr_remove_uid(const unsigned short loc)
63423 +{
63424 + unsigned short i;
63425 +
63426 + for (i = loc + 1; i < uid_used; i++)
63427 + uid_set[i - 1] = uid_set[i];
63428 +
63429 + uid_used--;
63430 +
63431 + return;
63432 +}
63433 +
63434 +int
63435 +gr_check_crash_uid(const kuid_t kuid)
63436 +{
63437 + int loc;
63438 + int ret = 0;
63439 + uid_t uid;
63440 +
63441 + if (unlikely(!gr_acl_is_enabled()))
63442 + return 0;
63443 +
63444 + uid = GR_GLOBAL_UID(kuid);
63445 +
63446 + spin_lock(&gr_uid_lock);
63447 + loc = gr_find_uid(uid);
63448 +
63449 + if (loc < 0)
63450 + goto out_unlock;
63451 +
63452 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
63453 + gr_remove_uid(loc);
63454 + else
63455 + ret = 1;
63456 +
63457 +out_unlock:
63458 + spin_unlock(&gr_uid_lock);
63459 + return ret;
63460 +}
63461 +
63462 +static __inline__ int
63463 +proc_is_setxid(const struct cred *cred)
63464 +{
63465 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
63466 + !uid_eq(cred->uid, cred->fsuid))
63467 + return 1;
63468 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
63469 + !gid_eq(cred->gid, cred->fsgid))
63470 + return 1;
63471 +
63472 + return 0;
63473 +}
63474 +
63475 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
63476 +
63477 +void
63478 +gr_handle_crash(struct task_struct *task, const int sig)
63479 +{
63480 + struct acl_subject_label *curr;
63481 + struct task_struct *tsk, *tsk2;
63482 + const struct cred *cred;
63483 + const struct cred *cred2;
63484 +
63485 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
63486 + return;
63487 +
63488 + if (unlikely(!gr_acl_is_enabled()))
63489 + return;
63490 +
63491 + curr = task->acl;
63492 +
63493 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
63494 + return;
63495 +
63496 + if (time_before_eq(curr->expires, get_seconds())) {
63497 + curr->expires = 0;
63498 + curr->crashes = 0;
63499 + }
63500 +
63501 + curr->crashes++;
63502 +
63503 + if (!curr->expires)
63504 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
63505 +
63506 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63507 + time_after(curr->expires, get_seconds())) {
63508 + rcu_read_lock();
63509 + cred = __task_cred(task);
63510 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
63511 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63512 + spin_lock(&gr_uid_lock);
63513 + gr_insert_uid(cred->uid, curr->expires);
63514 + spin_unlock(&gr_uid_lock);
63515 + curr->expires = 0;
63516 + curr->crashes = 0;
63517 + read_lock(&tasklist_lock);
63518 + do_each_thread(tsk2, tsk) {
63519 + cred2 = __task_cred(tsk);
63520 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
63521 + gr_fake_force_sig(SIGKILL, tsk);
63522 + } while_each_thread(tsk2, tsk);
63523 + read_unlock(&tasklist_lock);
63524 + } else {
63525 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63526 + read_lock(&tasklist_lock);
63527 + read_lock(&grsec_exec_file_lock);
63528 + do_each_thread(tsk2, tsk) {
63529 + if (likely(tsk != task)) {
63530 + // if this thread has the same subject as the one that triggered
63531 + // RES_CRASH and it's the same binary, kill it
63532 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
63533 + gr_fake_force_sig(SIGKILL, tsk);
63534 + }
63535 + } while_each_thread(tsk2, tsk);
63536 + read_unlock(&grsec_exec_file_lock);
63537 + read_unlock(&tasklist_lock);
63538 + }
63539 + rcu_read_unlock();
63540 + }
63541 +
63542 + return;
63543 +}
63544 +
63545 +int
63546 +gr_check_crash_exec(const struct file *filp)
63547 +{
63548 + struct acl_subject_label *curr;
63549 +
63550 + if (unlikely(!gr_acl_is_enabled()))
63551 + return 0;
63552 +
63553 + read_lock(&gr_inode_lock);
63554 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
63555 + __get_dev(filp->f_path.dentry),
63556 + current->role);
63557 + read_unlock(&gr_inode_lock);
63558 +
63559 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
63560 + (!curr->crashes && !curr->expires))
63561 + return 0;
63562 +
63563 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63564 + time_after(curr->expires, get_seconds()))
63565 + return 1;
63566 + else if (time_before_eq(curr->expires, get_seconds())) {
63567 + curr->crashes = 0;
63568 + curr->expires = 0;
63569 + }
63570 +
63571 + return 0;
63572 +}
63573 +
63574 +void
63575 +gr_handle_alertkill(struct task_struct *task)
63576 +{
63577 + struct acl_subject_label *curracl;
63578 + __u32 curr_ip;
63579 + struct task_struct *p, *p2;
63580 +
63581 + if (unlikely(!gr_acl_is_enabled()))
63582 + return;
63583 +
63584 + curracl = task->acl;
63585 + curr_ip = task->signal->curr_ip;
63586 +
63587 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
63588 + read_lock(&tasklist_lock);
63589 + do_each_thread(p2, p) {
63590 + if (p->signal->curr_ip == curr_ip)
63591 + gr_fake_force_sig(SIGKILL, p);
63592 + } while_each_thread(p2, p);
63593 + read_unlock(&tasklist_lock);
63594 + } else if (curracl->mode & GR_KILLPROC)
63595 + gr_fake_force_sig(SIGKILL, task);
63596 +
63597 + return;
63598 +}
63599 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
63600 new file mode 100644
63601 index 0000000..98011b0
63602 --- /dev/null
63603 +++ b/grsecurity/gracl_shm.c
63604 @@ -0,0 +1,40 @@
63605 +#include <linux/kernel.h>
63606 +#include <linux/mm.h>
63607 +#include <linux/sched.h>
63608 +#include <linux/file.h>
63609 +#include <linux/ipc.h>
63610 +#include <linux/gracl.h>
63611 +#include <linux/grsecurity.h>
63612 +#include <linux/grinternal.h>
63613 +
63614 +int
63615 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63616 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
63617 +{
63618 + struct task_struct *task;
63619 +
63620 + if (!gr_acl_is_enabled())
63621 + return 1;
63622 +
63623 + rcu_read_lock();
63624 + read_lock(&tasklist_lock);
63625 +
63626 + task = find_task_by_vpid(shm_cprid);
63627 +
63628 + if (unlikely(!task))
63629 + task = find_task_by_vpid(shm_lapid);
63630 +
63631 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
63632 + (task_pid_nr(task) == shm_lapid)) &&
63633 + (task->acl->mode & GR_PROTSHM) &&
63634 + (task->acl != current->acl))) {
63635 + read_unlock(&tasklist_lock);
63636 + rcu_read_unlock();
63637 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
63638 + return 0;
63639 + }
63640 + read_unlock(&tasklist_lock);
63641 + rcu_read_unlock();
63642 +
63643 + return 1;
63644 +}
63645 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
63646 new file mode 100644
63647 index 0000000..bc0be01
63648 --- /dev/null
63649 +++ b/grsecurity/grsec_chdir.c
63650 @@ -0,0 +1,19 @@
63651 +#include <linux/kernel.h>
63652 +#include <linux/sched.h>
63653 +#include <linux/fs.h>
63654 +#include <linux/file.h>
63655 +#include <linux/grsecurity.h>
63656 +#include <linux/grinternal.h>
63657 +
63658 +void
63659 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
63660 +{
63661 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
63662 + if ((grsec_enable_chdir && grsec_enable_group &&
63663 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
63664 + !grsec_enable_group)) {
63665 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
63666 + }
63667 +#endif
63668 + return;
63669 +}
63670 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
63671 new file mode 100644
63672 index 0000000..bd6e105
63673 --- /dev/null
63674 +++ b/grsecurity/grsec_chroot.c
63675 @@ -0,0 +1,370 @@
63676 +#include <linux/kernel.h>
63677 +#include <linux/module.h>
63678 +#include <linux/sched.h>
63679 +#include <linux/file.h>
63680 +#include <linux/fs.h>
63681 +#include <linux/mount.h>
63682 +#include <linux/types.h>
63683 +#include "../fs/mount.h"
63684 +#include <linux/grsecurity.h>
63685 +#include <linux/grinternal.h>
63686 +
63687 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
63688 +static int gr_init_ran;
63689 +#endif
63690 +
63691 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
63692 +{
63693 +#ifdef CONFIG_GRKERNSEC
63694 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
63695 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
63696 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
63697 + && gr_init_ran
63698 +#endif
63699 + )
63700 + task->gr_is_chrooted = 1;
63701 + else {
63702 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
63703 + if (task_pid_nr(task) == 1 && !gr_init_ran)
63704 + gr_init_ran = 1;
63705 +#endif
63706 + task->gr_is_chrooted = 0;
63707 + }
63708 +
63709 + task->gr_chroot_dentry = path->dentry;
63710 +#endif
63711 + return;
63712 +}
63713 +
63714 +void gr_clear_chroot_entries(struct task_struct *task)
63715 +{
63716 +#ifdef CONFIG_GRKERNSEC
63717 + task->gr_is_chrooted = 0;
63718 + task->gr_chroot_dentry = NULL;
63719 +#endif
63720 + return;
63721 +}
63722 +
63723 +int
63724 +gr_handle_chroot_unix(const pid_t pid)
63725 +{
63726 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
63727 + struct task_struct *p;
63728 +
63729 + if (unlikely(!grsec_enable_chroot_unix))
63730 + return 1;
63731 +
63732 + if (likely(!proc_is_chrooted(current)))
63733 + return 1;
63734 +
63735 + rcu_read_lock();
63736 + read_lock(&tasklist_lock);
63737 + p = find_task_by_vpid_unrestricted(pid);
63738 + if (unlikely(p && !have_same_root(current, p))) {
63739 + read_unlock(&tasklist_lock);
63740 + rcu_read_unlock();
63741 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
63742 + return 0;
63743 + }
63744 + read_unlock(&tasklist_lock);
63745 + rcu_read_unlock();
63746 +#endif
63747 + return 1;
63748 +}
63749 +
63750 +int
63751 +gr_handle_chroot_nice(void)
63752 +{
63753 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63754 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
63755 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
63756 + return -EPERM;
63757 + }
63758 +#endif
63759 + return 0;
63760 +}
63761 +
63762 +int
63763 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
63764 +{
63765 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63766 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
63767 + && proc_is_chrooted(current)) {
63768 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
63769 + return -EACCES;
63770 + }
63771 +#endif
63772 + return 0;
63773 +}
63774 +
63775 +int
63776 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
63777 +{
63778 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63779 + struct task_struct *p;
63780 + int ret = 0;
63781 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
63782 + return ret;
63783 +
63784 + read_lock(&tasklist_lock);
63785 + do_each_pid_task(pid, type, p) {
63786 + if (!have_same_root(current, p)) {
63787 + ret = 1;
63788 + goto out;
63789 + }
63790 + } while_each_pid_task(pid, type, p);
63791 +out:
63792 + read_unlock(&tasklist_lock);
63793 + return ret;
63794 +#endif
63795 + return 0;
63796 +}
63797 +
63798 +int
63799 +gr_pid_is_chrooted(struct task_struct *p)
63800 +{
63801 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63802 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
63803 + return 0;
63804 +
63805 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
63806 + !have_same_root(current, p)) {
63807 + return 1;
63808 + }
63809 +#endif
63810 + return 0;
63811 +}
63812 +
63813 +EXPORT_SYMBOL(gr_pid_is_chrooted);
63814 +
63815 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
63816 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
63817 +{
63818 + struct path path, currentroot;
63819 + int ret = 0;
63820 +
63821 + path.dentry = (struct dentry *)u_dentry;
63822 + path.mnt = (struct vfsmount *)u_mnt;
63823 + get_fs_root(current->fs, &currentroot);
63824 + if (path_is_under(&path, &currentroot))
63825 + ret = 1;
63826 + path_put(&currentroot);
63827 +
63828 + return ret;
63829 +}
63830 +#endif
63831 +
63832 +int
63833 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
63834 +{
63835 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
63836 + if (!grsec_enable_chroot_fchdir)
63837 + return 1;
63838 +
63839 + if (!proc_is_chrooted(current))
63840 + return 1;
63841 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
63842 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
63843 + return 0;
63844 + }
63845 +#endif
63846 + return 1;
63847 +}
63848 +
63849 +int
63850 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63851 + const time_t shm_createtime)
63852 +{
63853 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
63854 + struct task_struct *p;
63855 + time_t starttime;
63856 +
63857 + if (unlikely(!grsec_enable_chroot_shmat))
63858 + return 1;
63859 +
63860 + if (likely(!proc_is_chrooted(current)))
63861 + return 1;
63862 +
63863 + rcu_read_lock();
63864 + read_lock(&tasklist_lock);
63865 +
63866 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
63867 + starttime = p->start_time.tv_sec;
63868 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
63869 + if (have_same_root(current, p)) {
63870 + goto allow;
63871 + } else {
63872 + read_unlock(&tasklist_lock);
63873 + rcu_read_unlock();
63874 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
63875 + return 0;
63876 + }
63877 + }
63878 + /* creator exited, pid reuse, fall through to next check */
63879 + }
63880 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
63881 + if (unlikely(!have_same_root(current, p))) {
63882 + read_unlock(&tasklist_lock);
63883 + rcu_read_unlock();
63884 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
63885 + return 0;
63886 + }
63887 + }
63888 +
63889 +allow:
63890 + read_unlock(&tasklist_lock);
63891 + rcu_read_unlock();
63892 +#endif
63893 + return 1;
63894 +}
63895 +
63896 +void
63897 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
63898 +{
63899 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
63900 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
63901 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
63902 +#endif
63903 + return;
63904 +}
63905 +
63906 +int
63907 +gr_handle_chroot_mknod(const struct dentry *dentry,
63908 + const struct vfsmount *mnt, const int mode)
63909 +{
63910 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
63911 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
63912 + proc_is_chrooted(current)) {
63913 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
63914 + return -EPERM;
63915 + }
63916 +#endif
63917 + return 0;
63918 +}
63919 +
63920 +int
63921 +gr_handle_chroot_mount(const struct dentry *dentry,
63922 + const struct vfsmount *mnt, const char *dev_name)
63923 +{
63924 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
63925 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
63926 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
63927 + return -EPERM;
63928 + }
63929 +#endif
63930 + return 0;
63931 +}
63932 +
63933 +int
63934 +gr_handle_chroot_pivot(void)
63935 +{
63936 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
63937 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
63938 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
63939 + return -EPERM;
63940 + }
63941 +#endif
63942 + return 0;
63943 +}
63944 +
63945 +int
63946 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
63947 +{
63948 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
63949 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
63950 + !gr_is_outside_chroot(dentry, mnt)) {
63951 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
63952 + return -EPERM;
63953 + }
63954 +#endif
63955 + return 0;
63956 +}
63957 +
63958 +extern const char *captab_log[];
63959 +extern int captab_log_entries;
63960 +
63961 +int
63962 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
63963 +{
63964 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63965 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
63966 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
63967 + if (cap_raised(chroot_caps, cap)) {
63968 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
63969 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
63970 + }
63971 + return 0;
63972 + }
63973 + }
63974 +#endif
63975 + return 1;
63976 +}
63977 +
63978 +int
63979 +gr_chroot_is_capable(const int cap)
63980 +{
63981 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63982 + return gr_task_chroot_is_capable(current, current_cred(), cap);
63983 +#endif
63984 + return 1;
63985 +}
63986 +
63987 +int
63988 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
63989 +{
63990 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63991 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
63992 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
63993 + if (cap_raised(chroot_caps, cap)) {
63994 + return 0;
63995 + }
63996 + }
63997 +#endif
63998 + return 1;
63999 +}
64000 +
64001 +int
64002 +gr_chroot_is_capable_nolog(const int cap)
64003 +{
64004 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64005 + return gr_task_chroot_is_capable_nolog(current, cap);
64006 +#endif
64007 + return 1;
64008 +}
64009 +
64010 +int
64011 +gr_handle_chroot_sysctl(const int op)
64012 +{
64013 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64014 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
64015 + proc_is_chrooted(current))
64016 + return -EACCES;
64017 +#endif
64018 + return 0;
64019 +}
64020 +
64021 +void
64022 +gr_handle_chroot_chdir(const struct path *path)
64023 +{
64024 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64025 + if (grsec_enable_chroot_chdir)
64026 + set_fs_pwd(current->fs, path);
64027 +#endif
64028 + return;
64029 +}
64030 +
64031 +int
64032 +gr_handle_chroot_chmod(const struct dentry *dentry,
64033 + const struct vfsmount *mnt, const int mode)
64034 +{
64035 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64036 + /* allow chmod +s on directories, but not files */
64037 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
64038 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
64039 + proc_is_chrooted(current)) {
64040 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
64041 + return -EPERM;
64042 + }
64043 +#endif
64044 + return 0;
64045 +}
64046 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
64047 new file mode 100644
64048 index 0000000..ce65ceb
64049 --- /dev/null
64050 +++ b/grsecurity/grsec_disabled.c
64051 @@ -0,0 +1,434 @@
64052 +#include <linux/kernel.h>
64053 +#include <linux/module.h>
64054 +#include <linux/sched.h>
64055 +#include <linux/file.h>
64056 +#include <linux/fs.h>
64057 +#include <linux/kdev_t.h>
64058 +#include <linux/net.h>
64059 +#include <linux/in.h>
64060 +#include <linux/ip.h>
64061 +#include <linux/skbuff.h>
64062 +#include <linux/sysctl.h>
64063 +
64064 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
64065 +void
64066 +pax_set_initial_flags(struct linux_binprm *bprm)
64067 +{
64068 + return;
64069 +}
64070 +#endif
64071 +
64072 +#ifdef CONFIG_SYSCTL
64073 +__u32
64074 +gr_handle_sysctl(const struct ctl_table * table, const int op)
64075 +{
64076 + return 0;
64077 +}
64078 +#endif
64079 +
64080 +#ifdef CONFIG_TASKSTATS
64081 +int gr_is_taskstats_denied(int pid)
64082 +{
64083 + return 0;
64084 +}
64085 +#endif
64086 +
64087 +int
64088 +gr_acl_is_enabled(void)
64089 +{
64090 + return 0;
64091 +}
64092 +
64093 +void
64094 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
64095 +{
64096 + return;
64097 +}
64098 +
64099 +int
64100 +gr_handle_rawio(const struct inode *inode)
64101 +{
64102 + return 0;
64103 +}
64104 +
64105 +void
64106 +gr_acl_handle_psacct(struct task_struct *task, const long code)
64107 +{
64108 + return;
64109 +}
64110 +
64111 +int
64112 +gr_handle_ptrace(struct task_struct *task, const long request)
64113 +{
64114 + return 0;
64115 +}
64116 +
64117 +int
64118 +gr_handle_proc_ptrace(struct task_struct *task)
64119 +{
64120 + return 0;
64121 +}
64122 +
64123 +int
64124 +gr_set_acls(const int type)
64125 +{
64126 + return 0;
64127 +}
64128 +
64129 +int
64130 +gr_check_hidden_task(const struct task_struct *tsk)
64131 +{
64132 + return 0;
64133 +}
64134 +
64135 +int
64136 +gr_check_protected_task(const struct task_struct *task)
64137 +{
64138 + return 0;
64139 +}
64140 +
64141 +int
64142 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64143 +{
64144 + return 0;
64145 +}
64146 +
64147 +void
64148 +gr_copy_label(struct task_struct *tsk)
64149 +{
64150 + return;
64151 +}
64152 +
64153 +void
64154 +gr_set_pax_flags(struct task_struct *task)
64155 +{
64156 + return;
64157 +}
64158 +
64159 +int
64160 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64161 + const int unsafe_share)
64162 +{
64163 + return 0;
64164 +}
64165 +
64166 +void
64167 +gr_handle_delete(const ino_t ino, const dev_t dev)
64168 +{
64169 + return;
64170 +}
64171 +
64172 +void
64173 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
64174 +{
64175 + return;
64176 +}
64177 +
64178 +void
64179 +gr_handle_crash(struct task_struct *task, const int sig)
64180 +{
64181 + return;
64182 +}
64183 +
64184 +int
64185 +gr_check_crash_exec(const struct file *filp)
64186 +{
64187 + return 0;
64188 +}
64189 +
64190 +int
64191 +gr_check_crash_uid(const kuid_t uid)
64192 +{
64193 + return 0;
64194 +}
64195 +
64196 +void
64197 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
64198 + struct dentry *old_dentry,
64199 + struct dentry *new_dentry,
64200 + struct vfsmount *mnt, const __u8 replace)
64201 +{
64202 + return;
64203 +}
64204 +
64205 +int
64206 +gr_search_socket(const int family, const int type, const int protocol)
64207 +{
64208 + return 1;
64209 +}
64210 +
64211 +int
64212 +gr_search_connectbind(const int mode, const struct socket *sock,
64213 + const struct sockaddr_in *addr)
64214 +{
64215 + return 0;
64216 +}
64217 +
64218 +void
64219 +gr_handle_alertkill(struct task_struct *task)
64220 +{
64221 + return;
64222 +}
64223 +
64224 +__u32
64225 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
64226 +{
64227 + return 1;
64228 +}
64229 +
64230 +__u32
64231 +gr_acl_handle_hidden_file(const struct dentry * dentry,
64232 + const struct vfsmount * mnt)
64233 +{
64234 + return 1;
64235 +}
64236 +
64237 +__u32
64238 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
64239 + int acc_mode)
64240 +{
64241 + return 1;
64242 +}
64243 +
64244 +__u32
64245 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
64246 +{
64247 + return 1;
64248 +}
64249 +
64250 +__u32
64251 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
64252 +{
64253 + return 1;
64254 +}
64255 +
64256 +int
64257 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
64258 + unsigned int *vm_flags)
64259 +{
64260 + return 1;
64261 +}
64262 +
64263 +__u32
64264 +gr_acl_handle_truncate(const struct dentry * dentry,
64265 + const struct vfsmount * mnt)
64266 +{
64267 + return 1;
64268 +}
64269 +
64270 +__u32
64271 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
64272 +{
64273 + return 1;
64274 +}
64275 +
64276 +__u32
64277 +gr_acl_handle_access(const struct dentry * dentry,
64278 + const struct vfsmount * mnt, const int fmode)
64279 +{
64280 + return 1;
64281 +}
64282 +
64283 +__u32
64284 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
64285 + umode_t *mode)
64286 +{
64287 + return 1;
64288 +}
64289 +
64290 +__u32
64291 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
64292 +{
64293 + return 1;
64294 +}
64295 +
64296 +__u32
64297 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
64298 +{
64299 + return 1;
64300 +}
64301 +
64302 +void
64303 +grsecurity_init(void)
64304 +{
64305 + return;
64306 +}
64307 +
64308 +umode_t gr_acl_umask(void)
64309 +{
64310 + return 0;
64311 +}
64312 +
64313 +__u32
64314 +gr_acl_handle_mknod(const struct dentry * new_dentry,
64315 + const struct dentry * parent_dentry,
64316 + const struct vfsmount * parent_mnt,
64317 + const int mode)
64318 +{
64319 + return 1;
64320 +}
64321 +
64322 +__u32
64323 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
64324 + const struct dentry * parent_dentry,
64325 + const struct vfsmount * parent_mnt)
64326 +{
64327 + return 1;
64328 +}
64329 +
64330 +__u32
64331 +gr_acl_handle_symlink(const struct dentry * new_dentry,
64332 + const struct dentry * parent_dentry,
64333 + const struct vfsmount * parent_mnt, const struct filename *from)
64334 +{
64335 + return 1;
64336 +}
64337 +
64338 +__u32
64339 +gr_acl_handle_link(const struct dentry * new_dentry,
64340 + const struct dentry * parent_dentry,
64341 + const struct vfsmount * parent_mnt,
64342 + const struct dentry * old_dentry,
64343 + const struct vfsmount * old_mnt, const struct filename *to)
64344 +{
64345 + return 1;
64346 +}
64347 +
64348 +int
64349 +gr_acl_handle_rename(const struct dentry *new_dentry,
64350 + const struct dentry *parent_dentry,
64351 + const struct vfsmount *parent_mnt,
64352 + const struct dentry *old_dentry,
64353 + const struct inode *old_parent_inode,
64354 + const struct vfsmount *old_mnt, const struct filename *newname)
64355 +{
64356 + return 0;
64357 +}
64358 +
64359 +int
64360 +gr_acl_handle_filldir(const struct file *file, const char *name,
64361 + const int namelen, const ino_t ino)
64362 +{
64363 + return 1;
64364 +}
64365 +
64366 +int
64367 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64368 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64369 +{
64370 + return 1;
64371 +}
64372 +
64373 +int
64374 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
64375 +{
64376 + return 0;
64377 +}
64378 +
64379 +int
64380 +gr_search_accept(const struct socket *sock)
64381 +{
64382 + return 0;
64383 +}
64384 +
64385 +int
64386 +gr_search_listen(const struct socket *sock)
64387 +{
64388 + return 0;
64389 +}
64390 +
64391 +int
64392 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
64393 +{
64394 + return 0;
64395 +}
64396 +
64397 +__u32
64398 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
64399 +{
64400 + return 1;
64401 +}
64402 +
64403 +__u32
64404 +gr_acl_handle_creat(const struct dentry * dentry,
64405 + const struct dentry * p_dentry,
64406 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
64407 + const int imode)
64408 +{
64409 + return 1;
64410 +}
64411 +
64412 +void
64413 +gr_acl_handle_exit(void)
64414 +{
64415 + return;
64416 +}
64417 +
64418 +int
64419 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
64420 +{
64421 + return 1;
64422 +}
64423 +
64424 +void
64425 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
64426 +{
64427 + return;
64428 +}
64429 +
64430 +int
64431 +gr_acl_handle_procpidmem(const struct task_struct *task)
64432 +{
64433 + return 0;
64434 +}
64435 +
64436 +int
64437 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
64438 +{
64439 + return 0;
64440 +}
64441 +
64442 +int
64443 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
64444 +{
64445 + return 0;
64446 +}
64447 +
64448 +void
64449 +gr_set_kernel_label(struct task_struct *task)
64450 +{
64451 + return;
64452 +}
64453 +
64454 +int
64455 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64456 +{
64457 + return 0;
64458 +}
64459 +
64460 +int
64461 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64462 +{
64463 + return 0;
64464 +}
64465 +
64466 +int gr_acl_enable_at_secure(void)
64467 +{
64468 + return 0;
64469 +}
64470 +
64471 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
64472 +{
64473 + return dentry->d_sb->s_dev;
64474 +}
64475 +
64476 +void gr_put_exec_file(struct task_struct *task)
64477 +{
64478 + return;
64479 +}
64480 +
64481 +EXPORT_SYMBOL(gr_set_kernel_label);
64482 +#ifdef CONFIG_SECURITY
64483 +EXPORT_SYMBOL(gr_check_user_change);
64484 +EXPORT_SYMBOL(gr_check_group_change);
64485 +#endif
64486 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
64487 new file mode 100644
64488 index 0000000..387032b
64489 --- /dev/null
64490 +++ b/grsecurity/grsec_exec.c
64491 @@ -0,0 +1,187 @@
64492 +#include <linux/kernel.h>
64493 +#include <linux/sched.h>
64494 +#include <linux/file.h>
64495 +#include <linux/binfmts.h>
64496 +#include <linux/fs.h>
64497 +#include <linux/types.h>
64498 +#include <linux/grdefs.h>
64499 +#include <linux/grsecurity.h>
64500 +#include <linux/grinternal.h>
64501 +#include <linux/capability.h>
64502 +#include <linux/module.h>
64503 +#include <linux/compat.h>
64504 +
64505 +#include <asm/uaccess.h>
64506 +
64507 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64508 +static char gr_exec_arg_buf[132];
64509 +static DEFINE_MUTEX(gr_exec_arg_mutex);
64510 +#endif
64511 +
64512 +struct user_arg_ptr {
64513 +#ifdef CONFIG_COMPAT
64514 + bool is_compat;
64515 +#endif
64516 + union {
64517 + const char __user *const __user *native;
64518 +#ifdef CONFIG_COMPAT
64519 + const compat_uptr_t __user *compat;
64520 +#endif
64521 + } ptr;
64522 +};
64523 +
64524 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
64525 +
64526 +void
64527 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
64528 +{
64529 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64530 + char *grarg = gr_exec_arg_buf;
64531 + unsigned int i, x, execlen = 0;
64532 + char c;
64533 +
64534 + if (!((grsec_enable_execlog && grsec_enable_group &&
64535 + in_group_p(grsec_audit_gid))
64536 + || (grsec_enable_execlog && !grsec_enable_group)))
64537 + return;
64538 +
64539 + mutex_lock(&gr_exec_arg_mutex);
64540 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
64541 +
64542 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
64543 + const char __user *p;
64544 + unsigned int len;
64545 +
64546 + p = get_user_arg_ptr(argv, i);
64547 + if (IS_ERR(p))
64548 + goto log;
64549 +
64550 + len = strnlen_user(p, 128 - execlen);
64551 + if (len > 128 - execlen)
64552 + len = 128 - execlen;
64553 + else if (len > 0)
64554 + len--;
64555 + if (copy_from_user(grarg + execlen, p, len))
64556 + goto log;
64557 +
64558 + /* rewrite unprintable characters */
64559 + for (x = 0; x < len; x++) {
64560 + c = *(grarg + execlen + x);
64561 + if (c < 32 || c > 126)
64562 + *(grarg + execlen + x) = ' ';
64563 + }
64564 +
64565 + execlen += len;
64566 + *(grarg + execlen) = ' ';
64567 + *(grarg + execlen + 1) = '\0';
64568 + execlen++;
64569 + }
64570 +
64571 + log:
64572 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
64573 + bprm->file->f_path.mnt, grarg);
64574 + mutex_unlock(&gr_exec_arg_mutex);
64575 +#endif
64576 + return;
64577 +}
64578 +
64579 +#ifdef CONFIG_GRKERNSEC
64580 +extern int gr_acl_is_capable(const int cap);
64581 +extern int gr_acl_is_capable_nolog(const int cap);
64582 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64583 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
64584 +extern int gr_chroot_is_capable(const int cap);
64585 +extern int gr_chroot_is_capable_nolog(const int cap);
64586 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64587 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
64588 +#endif
64589 +
64590 +const char *captab_log[] = {
64591 + "CAP_CHOWN",
64592 + "CAP_DAC_OVERRIDE",
64593 + "CAP_DAC_READ_SEARCH",
64594 + "CAP_FOWNER",
64595 + "CAP_FSETID",
64596 + "CAP_KILL",
64597 + "CAP_SETGID",
64598 + "CAP_SETUID",
64599 + "CAP_SETPCAP",
64600 + "CAP_LINUX_IMMUTABLE",
64601 + "CAP_NET_BIND_SERVICE",
64602 + "CAP_NET_BROADCAST",
64603 + "CAP_NET_ADMIN",
64604 + "CAP_NET_RAW",
64605 + "CAP_IPC_LOCK",
64606 + "CAP_IPC_OWNER",
64607 + "CAP_SYS_MODULE",
64608 + "CAP_SYS_RAWIO",
64609 + "CAP_SYS_CHROOT",
64610 + "CAP_SYS_PTRACE",
64611 + "CAP_SYS_PACCT",
64612 + "CAP_SYS_ADMIN",
64613 + "CAP_SYS_BOOT",
64614 + "CAP_SYS_NICE",
64615 + "CAP_SYS_RESOURCE",
64616 + "CAP_SYS_TIME",
64617 + "CAP_SYS_TTY_CONFIG",
64618 + "CAP_MKNOD",
64619 + "CAP_LEASE",
64620 + "CAP_AUDIT_WRITE",
64621 + "CAP_AUDIT_CONTROL",
64622 + "CAP_SETFCAP",
64623 + "CAP_MAC_OVERRIDE",
64624 + "CAP_MAC_ADMIN",
64625 + "CAP_SYSLOG",
64626 + "CAP_WAKE_ALARM"
64627 +};
64628 +
64629 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
64630 +
64631 +int gr_is_capable(const int cap)
64632 +{
64633 +#ifdef CONFIG_GRKERNSEC
64634 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
64635 + return 1;
64636 + return 0;
64637 +#else
64638 + return 1;
64639 +#endif
64640 +}
64641 +
64642 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64643 +{
64644 +#ifdef CONFIG_GRKERNSEC
64645 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
64646 + return 1;
64647 + return 0;
64648 +#else
64649 + return 1;
64650 +#endif
64651 +}
64652 +
64653 +int gr_is_capable_nolog(const int cap)
64654 +{
64655 +#ifdef CONFIG_GRKERNSEC
64656 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
64657 + return 1;
64658 + return 0;
64659 +#else
64660 + return 1;
64661 +#endif
64662 +}
64663 +
64664 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
64665 +{
64666 +#ifdef CONFIG_GRKERNSEC
64667 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
64668 + return 1;
64669 + return 0;
64670 +#else
64671 + return 1;
64672 +#endif
64673 +}
64674 +
64675 +EXPORT_SYMBOL(gr_is_capable);
64676 +EXPORT_SYMBOL(gr_is_capable_nolog);
64677 +EXPORT_SYMBOL(gr_task_is_capable);
64678 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
64679 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
64680 new file mode 100644
64681 index 0000000..06cc6ea
64682 --- /dev/null
64683 +++ b/grsecurity/grsec_fifo.c
64684 @@ -0,0 +1,24 @@
64685 +#include <linux/kernel.h>
64686 +#include <linux/sched.h>
64687 +#include <linux/fs.h>
64688 +#include <linux/file.h>
64689 +#include <linux/grinternal.h>
64690 +
64691 +int
64692 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
64693 + const struct dentry *dir, const int flag, const int acc_mode)
64694 +{
64695 +#ifdef CONFIG_GRKERNSEC_FIFO
64696 + const struct cred *cred = current_cred();
64697 +
64698 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
64699 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
64700 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
64701 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
64702 + if (!inode_permission(dentry->d_inode, acc_mode))
64703 + 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));
64704 + return -EACCES;
64705 + }
64706 +#endif
64707 + return 0;
64708 +}
64709 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
64710 new file mode 100644
64711 index 0000000..8ca18bf
64712 --- /dev/null
64713 +++ b/grsecurity/grsec_fork.c
64714 @@ -0,0 +1,23 @@
64715 +#include <linux/kernel.h>
64716 +#include <linux/sched.h>
64717 +#include <linux/grsecurity.h>
64718 +#include <linux/grinternal.h>
64719 +#include <linux/errno.h>
64720 +
64721 +void
64722 +gr_log_forkfail(const int retval)
64723 +{
64724 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64725 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
64726 + switch (retval) {
64727 + case -EAGAIN:
64728 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
64729 + break;
64730 + case -ENOMEM:
64731 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
64732 + break;
64733 + }
64734 + }
64735 +#endif
64736 + return;
64737 +}
64738 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
64739 new file mode 100644
64740 index 0000000..a862e9f
64741 --- /dev/null
64742 +++ b/grsecurity/grsec_init.c
64743 @@ -0,0 +1,283 @@
64744 +#include <linux/kernel.h>
64745 +#include <linux/sched.h>
64746 +#include <linux/mm.h>
64747 +#include <linux/gracl.h>
64748 +#include <linux/slab.h>
64749 +#include <linux/vmalloc.h>
64750 +#include <linux/percpu.h>
64751 +#include <linux/module.h>
64752 +
64753 +int grsec_enable_ptrace_readexec;
64754 +int grsec_enable_setxid;
64755 +int grsec_enable_symlinkown;
64756 +kgid_t grsec_symlinkown_gid;
64757 +int grsec_enable_brute;
64758 +int grsec_enable_link;
64759 +int grsec_enable_dmesg;
64760 +int grsec_enable_harden_ptrace;
64761 +int grsec_enable_fifo;
64762 +int grsec_enable_execlog;
64763 +int grsec_enable_signal;
64764 +int grsec_enable_forkfail;
64765 +int grsec_enable_audit_ptrace;
64766 +int grsec_enable_time;
64767 +int grsec_enable_audit_textrel;
64768 +int grsec_enable_group;
64769 +kgid_t grsec_audit_gid;
64770 +int grsec_enable_chdir;
64771 +int grsec_enable_mount;
64772 +int grsec_enable_rofs;
64773 +int grsec_enable_chroot_findtask;
64774 +int grsec_enable_chroot_mount;
64775 +int grsec_enable_chroot_shmat;
64776 +int grsec_enable_chroot_fchdir;
64777 +int grsec_enable_chroot_double;
64778 +int grsec_enable_chroot_pivot;
64779 +int grsec_enable_chroot_chdir;
64780 +int grsec_enable_chroot_chmod;
64781 +int grsec_enable_chroot_mknod;
64782 +int grsec_enable_chroot_nice;
64783 +int grsec_enable_chroot_execlog;
64784 +int grsec_enable_chroot_caps;
64785 +int grsec_enable_chroot_sysctl;
64786 +int grsec_enable_chroot_unix;
64787 +int grsec_enable_tpe;
64788 +kgid_t grsec_tpe_gid;
64789 +int grsec_enable_blackhole;
64790 +#ifdef CONFIG_IPV6_MODULE
64791 +EXPORT_SYMBOL(grsec_enable_blackhole);
64792 +#endif
64793 +int grsec_lastack_retries;
64794 +int grsec_enable_tpe_all;
64795 +int grsec_enable_tpe_invert;
64796 +int grsec_enable_socket_all;
64797 +kgid_t grsec_socket_all_gid;
64798 +int grsec_enable_socket_client;
64799 +kgid_t grsec_socket_client_gid;
64800 +int grsec_enable_socket_server;
64801 +kgid_t grsec_socket_server_gid;
64802 +int grsec_resource_logging;
64803 +int grsec_disable_privio;
64804 +int grsec_enable_log_rwxmaps;
64805 +int grsec_lock;
64806 +
64807 +DEFINE_SPINLOCK(grsec_alert_lock);
64808 +unsigned long grsec_alert_wtime = 0;
64809 +unsigned long grsec_alert_fyet = 0;
64810 +
64811 +DEFINE_SPINLOCK(grsec_audit_lock);
64812 +
64813 +DEFINE_RWLOCK(grsec_exec_file_lock);
64814 +
64815 +char *gr_shared_page[4];
64816 +
64817 +char *gr_alert_log_fmt;
64818 +char *gr_audit_log_fmt;
64819 +char *gr_alert_log_buf;
64820 +char *gr_audit_log_buf;
64821 +
64822 +extern struct gr_arg *gr_usermode;
64823 +extern unsigned char *gr_system_salt;
64824 +extern unsigned char *gr_system_sum;
64825 +
64826 +void __init
64827 +grsecurity_init(void)
64828 +{
64829 + int j;
64830 + /* create the per-cpu shared pages */
64831 +
64832 +#ifdef CONFIG_X86
64833 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
64834 +#endif
64835 +
64836 + for (j = 0; j < 4; j++) {
64837 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
64838 + if (gr_shared_page[j] == NULL) {
64839 + panic("Unable to allocate grsecurity shared page");
64840 + return;
64841 + }
64842 + }
64843 +
64844 + /* allocate log buffers */
64845 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
64846 + if (!gr_alert_log_fmt) {
64847 + panic("Unable to allocate grsecurity alert log format buffer");
64848 + return;
64849 + }
64850 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
64851 + if (!gr_audit_log_fmt) {
64852 + panic("Unable to allocate grsecurity audit log format buffer");
64853 + return;
64854 + }
64855 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
64856 + if (!gr_alert_log_buf) {
64857 + panic("Unable to allocate grsecurity alert log buffer");
64858 + return;
64859 + }
64860 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
64861 + if (!gr_audit_log_buf) {
64862 + panic("Unable to allocate grsecurity audit log buffer");
64863 + return;
64864 + }
64865 +
64866 + /* allocate memory for authentication structure */
64867 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
64868 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
64869 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
64870 +
64871 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
64872 + panic("Unable to allocate grsecurity authentication structure");
64873 + return;
64874 + }
64875 +
64876 +
64877 +#ifdef CONFIG_GRKERNSEC_IO
64878 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
64879 + grsec_disable_privio = 1;
64880 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
64881 + grsec_disable_privio = 1;
64882 +#else
64883 + grsec_disable_privio = 0;
64884 +#endif
64885 +#endif
64886 +
64887 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
64888 + /* for backward compatibility, tpe_invert always defaults to on if
64889 + enabled in the kernel
64890 + */
64891 + grsec_enable_tpe_invert = 1;
64892 +#endif
64893 +
64894 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
64895 +#ifndef CONFIG_GRKERNSEC_SYSCTL
64896 + grsec_lock = 1;
64897 +#endif
64898 +
64899 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
64900 + grsec_enable_audit_textrel = 1;
64901 +#endif
64902 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
64903 + grsec_enable_log_rwxmaps = 1;
64904 +#endif
64905 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
64906 + grsec_enable_group = 1;
64907 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
64908 +#endif
64909 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
64910 + grsec_enable_ptrace_readexec = 1;
64911 +#endif
64912 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
64913 + grsec_enable_chdir = 1;
64914 +#endif
64915 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
64916 + grsec_enable_harden_ptrace = 1;
64917 +#endif
64918 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
64919 + grsec_enable_mount = 1;
64920 +#endif
64921 +#ifdef CONFIG_GRKERNSEC_LINK
64922 + grsec_enable_link = 1;
64923 +#endif
64924 +#ifdef CONFIG_GRKERNSEC_BRUTE
64925 + grsec_enable_brute = 1;
64926 +#endif
64927 +#ifdef CONFIG_GRKERNSEC_DMESG
64928 + grsec_enable_dmesg = 1;
64929 +#endif
64930 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
64931 + grsec_enable_blackhole = 1;
64932 + grsec_lastack_retries = 4;
64933 +#endif
64934 +#ifdef CONFIG_GRKERNSEC_FIFO
64935 + grsec_enable_fifo = 1;
64936 +#endif
64937 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64938 + grsec_enable_execlog = 1;
64939 +#endif
64940 +#ifdef CONFIG_GRKERNSEC_SETXID
64941 + grsec_enable_setxid = 1;
64942 +#endif
64943 +#ifdef CONFIG_GRKERNSEC_SIGNAL
64944 + grsec_enable_signal = 1;
64945 +#endif
64946 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64947 + grsec_enable_forkfail = 1;
64948 +#endif
64949 +#ifdef CONFIG_GRKERNSEC_TIME
64950 + grsec_enable_time = 1;
64951 +#endif
64952 +#ifdef CONFIG_GRKERNSEC_RESLOG
64953 + grsec_resource_logging = 1;
64954 +#endif
64955 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64956 + grsec_enable_chroot_findtask = 1;
64957 +#endif
64958 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
64959 + grsec_enable_chroot_unix = 1;
64960 +#endif
64961 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64962 + grsec_enable_chroot_mount = 1;
64963 +#endif
64964 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64965 + grsec_enable_chroot_fchdir = 1;
64966 +#endif
64967 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64968 + grsec_enable_chroot_shmat = 1;
64969 +#endif
64970 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
64971 + grsec_enable_audit_ptrace = 1;
64972 +#endif
64973 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64974 + grsec_enable_chroot_double = 1;
64975 +#endif
64976 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64977 + grsec_enable_chroot_pivot = 1;
64978 +#endif
64979 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64980 + grsec_enable_chroot_chdir = 1;
64981 +#endif
64982 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64983 + grsec_enable_chroot_chmod = 1;
64984 +#endif
64985 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64986 + grsec_enable_chroot_mknod = 1;
64987 +#endif
64988 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64989 + grsec_enable_chroot_nice = 1;
64990 +#endif
64991 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64992 + grsec_enable_chroot_execlog = 1;
64993 +#endif
64994 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64995 + grsec_enable_chroot_caps = 1;
64996 +#endif
64997 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64998 + grsec_enable_chroot_sysctl = 1;
64999 +#endif
65000 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65001 + grsec_enable_symlinkown = 1;
65002 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
65003 +#endif
65004 +#ifdef CONFIG_GRKERNSEC_TPE
65005 + grsec_enable_tpe = 1;
65006 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
65007 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65008 + grsec_enable_tpe_all = 1;
65009 +#endif
65010 +#endif
65011 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65012 + grsec_enable_socket_all = 1;
65013 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
65014 +#endif
65015 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65016 + grsec_enable_socket_client = 1;
65017 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
65018 +#endif
65019 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65020 + grsec_enable_socket_server = 1;
65021 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
65022 +#endif
65023 +#endif
65024 +
65025 + return;
65026 +}
65027 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
65028 new file mode 100644
65029 index 0000000..5e05e20
65030 --- /dev/null
65031 +++ b/grsecurity/grsec_link.c
65032 @@ -0,0 +1,58 @@
65033 +#include <linux/kernel.h>
65034 +#include <linux/sched.h>
65035 +#include <linux/fs.h>
65036 +#include <linux/file.h>
65037 +#include <linux/grinternal.h>
65038 +
65039 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
65040 +{
65041 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65042 + const struct inode *link_inode = link->dentry->d_inode;
65043 +
65044 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
65045 + /* ignore root-owned links, e.g. /proc/self */
65046 + gr_is_global_nonroot(link_inode->i_uid) && target &&
65047 + !uid_eq(link_inode->i_uid, target->i_uid)) {
65048 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
65049 + return 1;
65050 + }
65051 +#endif
65052 + return 0;
65053 +}
65054 +
65055 +int
65056 +gr_handle_follow_link(const struct inode *parent,
65057 + const struct inode *inode,
65058 + const struct dentry *dentry, const struct vfsmount *mnt)
65059 +{
65060 +#ifdef CONFIG_GRKERNSEC_LINK
65061 + const struct cred *cred = current_cred();
65062 +
65063 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
65064 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
65065 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
65066 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
65067 + return -EACCES;
65068 + }
65069 +#endif
65070 + return 0;
65071 +}
65072 +
65073 +int
65074 +gr_handle_hardlink(const struct dentry *dentry,
65075 + const struct vfsmount *mnt,
65076 + struct inode *inode, const int mode, const struct filename *to)
65077 +{
65078 +#ifdef CONFIG_GRKERNSEC_LINK
65079 + const struct cred *cred = current_cred();
65080 +
65081 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
65082 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
65083 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
65084 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
65085 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
65086 + return -EPERM;
65087 + }
65088 +#endif
65089 + return 0;
65090 +}
65091 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
65092 new file mode 100644
65093 index 0000000..7c06085
65094 --- /dev/null
65095 +++ b/grsecurity/grsec_log.c
65096 @@ -0,0 +1,326 @@
65097 +#include <linux/kernel.h>
65098 +#include <linux/sched.h>
65099 +#include <linux/file.h>
65100 +#include <linux/tty.h>
65101 +#include <linux/fs.h>
65102 +#include <linux/grinternal.h>
65103 +
65104 +#ifdef CONFIG_TREE_PREEMPT_RCU
65105 +#define DISABLE_PREEMPT() preempt_disable()
65106 +#define ENABLE_PREEMPT() preempt_enable()
65107 +#else
65108 +#define DISABLE_PREEMPT()
65109 +#define ENABLE_PREEMPT()
65110 +#endif
65111 +
65112 +#define BEGIN_LOCKS(x) \
65113 + DISABLE_PREEMPT(); \
65114 + rcu_read_lock(); \
65115 + read_lock(&tasklist_lock); \
65116 + read_lock(&grsec_exec_file_lock); \
65117 + if (x != GR_DO_AUDIT) \
65118 + spin_lock(&grsec_alert_lock); \
65119 + else \
65120 + spin_lock(&grsec_audit_lock)
65121 +
65122 +#define END_LOCKS(x) \
65123 + if (x != GR_DO_AUDIT) \
65124 + spin_unlock(&grsec_alert_lock); \
65125 + else \
65126 + spin_unlock(&grsec_audit_lock); \
65127 + read_unlock(&grsec_exec_file_lock); \
65128 + read_unlock(&tasklist_lock); \
65129 + rcu_read_unlock(); \
65130 + ENABLE_PREEMPT(); \
65131 + if (x == GR_DONT_AUDIT) \
65132 + gr_handle_alertkill(current)
65133 +
65134 +enum {
65135 + FLOODING,
65136 + NO_FLOODING
65137 +};
65138 +
65139 +extern char *gr_alert_log_fmt;
65140 +extern char *gr_audit_log_fmt;
65141 +extern char *gr_alert_log_buf;
65142 +extern char *gr_audit_log_buf;
65143 +
65144 +static int gr_log_start(int audit)
65145 +{
65146 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
65147 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
65148 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65149 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
65150 + unsigned long curr_secs = get_seconds();
65151 +
65152 + if (audit == GR_DO_AUDIT)
65153 + goto set_fmt;
65154 +
65155 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
65156 + grsec_alert_wtime = curr_secs;
65157 + grsec_alert_fyet = 0;
65158 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
65159 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
65160 + grsec_alert_fyet++;
65161 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
65162 + grsec_alert_wtime = curr_secs;
65163 + grsec_alert_fyet++;
65164 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
65165 + return FLOODING;
65166 + }
65167 + else return FLOODING;
65168 +
65169 +set_fmt:
65170 +#endif
65171 + memset(buf, 0, PAGE_SIZE);
65172 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
65173 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
65174 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65175 + } else if (current->signal->curr_ip) {
65176 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
65177 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
65178 + } else if (gr_acl_is_enabled()) {
65179 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
65180 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65181 + } else {
65182 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
65183 + strcpy(buf, fmt);
65184 + }
65185 +
65186 + return NO_FLOODING;
65187 +}
65188 +
65189 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65190 + __attribute__ ((format (printf, 2, 0)));
65191 +
65192 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65193 +{
65194 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65195 + unsigned int len = strlen(buf);
65196 +
65197 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65198 +
65199 + return;
65200 +}
65201 +
65202 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65203 + __attribute__ ((format (printf, 2, 3)));
65204 +
65205 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65206 +{
65207 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65208 + unsigned int len = strlen(buf);
65209 + va_list ap;
65210 +
65211 + va_start(ap, msg);
65212 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65213 + va_end(ap);
65214 +
65215 + return;
65216 +}
65217 +
65218 +static void gr_log_end(int audit, int append_default)
65219 +{
65220 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65221 + if (append_default) {
65222 + struct task_struct *task = current;
65223 + struct task_struct *parent = task->real_parent;
65224 + const struct cred *cred = __task_cred(task);
65225 + const struct cred *pcred = __task_cred(parent);
65226 + unsigned int len = strlen(buf);
65227 +
65228 + 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));
65229 + }
65230 +
65231 + printk("%s\n", buf);
65232 +
65233 + return;
65234 +}
65235 +
65236 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
65237 +{
65238 + int logtype;
65239 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
65240 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
65241 + void *voidptr = NULL;
65242 + int num1 = 0, num2 = 0;
65243 + unsigned long ulong1 = 0, ulong2 = 0;
65244 + struct dentry *dentry = NULL;
65245 + struct vfsmount *mnt = NULL;
65246 + struct file *file = NULL;
65247 + struct task_struct *task = NULL;
65248 + const struct cred *cred, *pcred;
65249 + va_list ap;
65250 +
65251 + BEGIN_LOCKS(audit);
65252 + logtype = gr_log_start(audit);
65253 + if (logtype == FLOODING) {
65254 + END_LOCKS(audit);
65255 + return;
65256 + }
65257 + va_start(ap, argtypes);
65258 + switch (argtypes) {
65259 + case GR_TTYSNIFF:
65260 + task = va_arg(ap, struct task_struct *);
65261 + 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));
65262 + break;
65263 + case GR_SYSCTL_HIDDEN:
65264 + str1 = va_arg(ap, char *);
65265 + gr_log_middle_varargs(audit, msg, result, str1);
65266 + break;
65267 + case GR_RBAC:
65268 + dentry = va_arg(ap, struct dentry *);
65269 + mnt = va_arg(ap, struct vfsmount *);
65270 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
65271 + break;
65272 + case GR_RBAC_STR:
65273 + dentry = va_arg(ap, struct dentry *);
65274 + mnt = va_arg(ap, struct vfsmount *);
65275 + str1 = va_arg(ap, char *);
65276 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
65277 + break;
65278 + case GR_STR_RBAC:
65279 + str1 = va_arg(ap, char *);
65280 + dentry = va_arg(ap, struct dentry *);
65281 + mnt = va_arg(ap, struct vfsmount *);
65282 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
65283 + break;
65284 + case GR_RBAC_MODE2:
65285 + dentry = va_arg(ap, struct dentry *);
65286 + mnt = va_arg(ap, struct vfsmount *);
65287 + str1 = va_arg(ap, char *);
65288 + str2 = va_arg(ap, char *);
65289 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
65290 + break;
65291 + case GR_RBAC_MODE3:
65292 + dentry = va_arg(ap, struct dentry *);
65293 + mnt = va_arg(ap, struct vfsmount *);
65294 + str1 = va_arg(ap, char *);
65295 + str2 = va_arg(ap, char *);
65296 + str3 = va_arg(ap, char *);
65297 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
65298 + break;
65299 + case GR_FILENAME:
65300 + dentry = va_arg(ap, struct dentry *);
65301 + mnt = va_arg(ap, struct vfsmount *);
65302 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
65303 + break;
65304 + case GR_STR_FILENAME:
65305 + str1 = va_arg(ap, char *);
65306 + dentry = va_arg(ap, struct dentry *);
65307 + mnt = va_arg(ap, struct vfsmount *);
65308 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
65309 + break;
65310 + case GR_FILENAME_STR:
65311 + dentry = va_arg(ap, struct dentry *);
65312 + mnt = va_arg(ap, struct vfsmount *);
65313 + str1 = va_arg(ap, char *);
65314 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
65315 + break;
65316 + case GR_FILENAME_TWO_INT:
65317 + dentry = va_arg(ap, struct dentry *);
65318 + mnt = va_arg(ap, struct vfsmount *);
65319 + num1 = va_arg(ap, int);
65320 + num2 = va_arg(ap, int);
65321 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
65322 + break;
65323 + case GR_FILENAME_TWO_INT_STR:
65324 + dentry = va_arg(ap, struct dentry *);
65325 + mnt = va_arg(ap, struct vfsmount *);
65326 + num1 = va_arg(ap, int);
65327 + num2 = va_arg(ap, int);
65328 + str1 = va_arg(ap, char *);
65329 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
65330 + break;
65331 + case GR_TEXTREL:
65332 + file = va_arg(ap, struct file *);
65333 + ulong1 = va_arg(ap, unsigned long);
65334 + ulong2 = va_arg(ap, unsigned long);
65335 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
65336 + break;
65337 + case GR_PTRACE:
65338 + task = va_arg(ap, struct task_struct *);
65339 + 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));
65340 + break;
65341 + case GR_RESOURCE:
65342 + task = va_arg(ap, struct task_struct *);
65343 + cred = __task_cred(task);
65344 + pcred = __task_cred(task->real_parent);
65345 + ulong1 = va_arg(ap, unsigned long);
65346 + str1 = va_arg(ap, char *);
65347 + ulong2 = va_arg(ap, unsigned long);
65348 + 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));
65349 + break;
65350 + case GR_CAP:
65351 + task = va_arg(ap, struct task_struct *);
65352 + cred = __task_cred(task);
65353 + pcred = __task_cred(task->real_parent);
65354 + str1 = va_arg(ap, char *);
65355 + 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));
65356 + break;
65357 + case GR_SIG:
65358 + str1 = va_arg(ap, char *);
65359 + voidptr = va_arg(ap, void *);
65360 + gr_log_middle_varargs(audit, msg, str1, voidptr);
65361 + break;
65362 + case GR_SIG2:
65363 + task = va_arg(ap, struct task_struct *);
65364 + cred = __task_cred(task);
65365 + pcred = __task_cred(task->real_parent);
65366 + num1 = va_arg(ap, int);
65367 + 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));
65368 + break;
65369 + case GR_CRASH1:
65370 + task = va_arg(ap, struct task_struct *);
65371 + cred = __task_cred(task);
65372 + pcred = __task_cred(task->real_parent);
65373 + ulong1 = va_arg(ap, unsigned long);
65374 + 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);
65375 + break;
65376 + case GR_CRASH2:
65377 + task = va_arg(ap, struct task_struct *);
65378 + cred = __task_cred(task);
65379 + pcred = __task_cred(task->real_parent);
65380 + ulong1 = va_arg(ap, unsigned long);
65381 + 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);
65382 + break;
65383 + case GR_RWXMAP:
65384 + file = va_arg(ap, struct file *);
65385 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
65386 + break;
65387 + case GR_PSACCT:
65388 + {
65389 + unsigned int wday, cday;
65390 + __u8 whr, chr;
65391 + __u8 wmin, cmin;
65392 + __u8 wsec, csec;
65393 + char cur_tty[64] = { 0 };
65394 + char parent_tty[64] = { 0 };
65395 +
65396 + task = va_arg(ap, struct task_struct *);
65397 + wday = va_arg(ap, unsigned int);
65398 + cday = va_arg(ap, unsigned int);
65399 + whr = va_arg(ap, int);
65400 + chr = va_arg(ap, int);
65401 + wmin = va_arg(ap, int);
65402 + cmin = va_arg(ap, int);
65403 + wsec = va_arg(ap, int);
65404 + csec = va_arg(ap, int);
65405 + ulong1 = va_arg(ap, unsigned long);
65406 + cred = __task_cred(task);
65407 + pcred = __task_cred(task->real_parent);
65408 +
65409 + 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));
65410 + }
65411 + break;
65412 + default:
65413 + gr_log_middle(audit, msg, ap);
65414 + }
65415 + va_end(ap);
65416 + // these don't need DEFAULTSECARGS printed on the end
65417 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
65418 + gr_log_end(audit, 0);
65419 + else
65420 + gr_log_end(audit, 1);
65421 + END_LOCKS(audit);
65422 +}
65423 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
65424 new file mode 100644
65425 index 0000000..f536303
65426 --- /dev/null
65427 +++ b/grsecurity/grsec_mem.c
65428 @@ -0,0 +1,40 @@
65429 +#include <linux/kernel.h>
65430 +#include <linux/sched.h>
65431 +#include <linux/mm.h>
65432 +#include <linux/mman.h>
65433 +#include <linux/grinternal.h>
65434 +
65435 +void
65436 +gr_handle_ioperm(void)
65437 +{
65438 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
65439 + return;
65440 +}
65441 +
65442 +void
65443 +gr_handle_iopl(void)
65444 +{
65445 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
65446 + return;
65447 +}
65448 +
65449 +void
65450 +gr_handle_mem_readwrite(u64 from, u64 to)
65451 +{
65452 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
65453 + return;
65454 +}
65455 +
65456 +void
65457 +gr_handle_vm86(void)
65458 +{
65459 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
65460 + return;
65461 +}
65462 +
65463 +void
65464 +gr_log_badprocpid(const char *entry)
65465 +{
65466 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
65467 + return;
65468 +}
65469 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
65470 new file mode 100644
65471 index 0000000..2131422
65472 --- /dev/null
65473 +++ b/grsecurity/grsec_mount.c
65474 @@ -0,0 +1,62 @@
65475 +#include <linux/kernel.h>
65476 +#include <linux/sched.h>
65477 +#include <linux/mount.h>
65478 +#include <linux/grsecurity.h>
65479 +#include <linux/grinternal.h>
65480 +
65481 +void
65482 +gr_log_remount(const char *devname, const int retval)
65483 +{
65484 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65485 + if (grsec_enable_mount && (retval >= 0))
65486 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
65487 +#endif
65488 + return;
65489 +}
65490 +
65491 +void
65492 +gr_log_unmount(const char *devname, const int retval)
65493 +{
65494 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65495 + if (grsec_enable_mount && (retval >= 0))
65496 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
65497 +#endif
65498 + return;
65499 +}
65500 +
65501 +void
65502 +gr_log_mount(const char *from, const char *to, const int retval)
65503 +{
65504 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65505 + if (grsec_enable_mount && (retval >= 0))
65506 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
65507 +#endif
65508 + return;
65509 +}
65510 +
65511 +int
65512 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
65513 +{
65514 +#ifdef CONFIG_GRKERNSEC_ROFS
65515 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
65516 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
65517 + return -EPERM;
65518 + } else
65519 + return 0;
65520 +#endif
65521 + return 0;
65522 +}
65523 +
65524 +int
65525 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
65526 +{
65527 +#ifdef CONFIG_GRKERNSEC_ROFS
65528 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
65529 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
65530 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
65531 + return -EPERM;
65532 + } else
65533 + return 0;
65534 +#endif
65535 + return 0;
65536 +}
65537 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
65538 new file mode 100644
65539 index 0000000..a3b12a0
65540 --- /dev/null
65541 +++ b/grsecurity/grsec_pax.c
65542 @@ -0,0 +1,36 @@
65543 +#include <linux/kernel.h>
65544 +#include <linux/sched.h>
65545 +#include <linux/mm.h>
65546 +#include <linux/file.h>
65547 +#include <linux/grinternal.h>
65548 +#include <linux/grsecurity.h>
65549 +
65550 +void
65551 +gr_log_textrel(struct vm_area_struct * vma)
65552 +{
65553 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65554 + if (grsec_enable_audit_textrel)
65555 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
65556 +#endif
65557 + return;
65558 +}
65559 +
65560 +void
65561 +gr_log_rwxmmap(struct file *file)
65562 +{
65563 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65564 + if (grsec_enable_log_rwxmaps)
65565 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
65566 +#endif
65567 + return;
65568 +}
65569 +
65570 +void
65571 +gr_log_rwxmprotect(struct file *file)
65572 +{
65573 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65574 + if (grsec_enable_log_rwxmaps)
65575 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
65576 +#endif
65577 + return;
65578 +}
65579 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
65580 new file mode 100644
65581 index 0000000..f7f29aa
65582 --- /dev/null
65583 +++ b/grsecurity/grsec_ptrace.c
65584 @@ -0,0 +1,30 @@
65585 +#include <linux/kernel.h>
65586 +#include <linux/sched.h>
65587 +#include <linux/grinternal.h>
65588 +#include <linux/security.h>
65589 +
65590 +void
65591 +gr_audit_ptrace(struct task_struct *task)
65592 +{
65593 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65594 + if (grsec_enable_audit_ptrace)
65595 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
65596 +#endif
65597 + return;
65598 +}
65599 +
65600 +int
65601 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
65602 +{
65603 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65604 + const struct dentry *dentry = file->f_path.dentry;
65605 + const struct vfsmount *mnt = file->f_path.mnt;
65606 +
65607 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
65608 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
65609 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
65610 + return -EACCES;
65611 + }
65612 +#endif
65613 + return 0;
65614 +}
65615 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
65616 new file mode 100644
65617 index 0000000..e09715a
65618 --- /dev/null
65619 +++ b/grsecurity/grsec_sig.c
65620 @@ -0,0 +1,222 @@
65621 +#include <linux/kernel.h>
65622 +#include <linux/sched.h>
65623 +#include <linux/delay.h>
65624 +#include <linux/grsecurity.h>
65625 +#include <linux/grinternal.h>
65626 +#include <linux/hardirq.h>
65627 +
65628 +char *signames[] = {
65629 + [SIGSEGV] = "Segmentation fault",
65630 + [SIGILL] = "Illegal instruction",
65631 + [SIGABRT] = "Abort",
65632 + [SIGBUS] = "Invalid alignment/Bus error"
65633 +};
65634 +
65635 +void
65636 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
65637 +{
65638 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65639 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
65640 + (sig == SIGABRT) || (sig == SIGBUS))) {
65641 + if (task_pid_nr(t) == task_pid_nr(current)) {
65642 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
65643 + } else {
65644 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
65645 + }
65646 + }
65647 +#endif
65648 + return;
65649 +}
65650 +
65651 +int
65652 +gr_handle_signal(const struct task_struct *p, const int sig)
65653 +{
65654 +#ifdef CONFIG_GRKERNSEC
65655 + /* ignore the 0 signal for protected task checks */
65656 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
65657 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
65658 + return -EPERM;
65659 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
65660 + return -EPERM;
65661 + }
65662 +#endif
65663 + return 0;
65664 +}
65665 +
65666 +#ifdef CONFIG_GRKERNSEC
65667 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
65668 +
65669 +int gr_fake_force_sig(int sig, struct task_struct *t)
65670 +{
65671 + unsigned long int flags;
65672 + int ret, blocked, ignored;
65673 + struct k_sigaction *action;
65674 +
65675 + spin_lock_irqsave(&t->sighand->siglock, flags);
65676 + action = &t->sighand->action[sig-1];
65677 + ignored = action->sa.sa_handler == SIG_IGN;
65678 + blocked = sigismember(&t->blocked, sig);
65679 + if (blocked || ignored) {
65680 + action->sa.sa_handler = SIG_DFL;
65681 + if (blocked) {
65682 + sigdelset(&t->blocked, sig);
65683 + recalc_sigpending_and_wake(t);
65684 + }
65685 + }
65686 + if (action->sa.sa_handler == SIG_DFL)
65687 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
65688 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
65689 +
65690 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
65691 +
65692 + return ret;
65693 +}
65694 +#endif
65695 +
65696 +#ifdef CONFIG_GRKERNSEC_BRUTE
65697 +#define GR_USER_BAN_TIME (15 * 60)
65698 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
65699 +
65700 +static int __get_dumpable(unsigned long mm_flags)
65701 +{
65702 + int ret;
65703 +
65704 + ret = mm_flags & MMF_DUMPABLE_MASK;
65705 + return (ret >= 2) ? 2 : ret;
65706 +}
65707 +#endif
65708 +
65709 +void gr_handle_brute_attach(unsigned long mm_flags)
65710 +{
65711 +#ifdef CONFIG_GRKERNSEC_BRUTE
65712 + struct task_struct *p = current;
65713 + kuid_t uid = GLOBAL_ROOT_UID;
65714 + int daemon = 0;
65715 +
65716 + if (!grsec_enable_brute)
65717 + return;
65718 +
65719 + rcu_read_lock();
65720 + read_lock(&tasklist_lock);
65721 + read_lock(&grsec_exec_file_lock);
65722 + if (p->real_parent && p->real_parent->exec_file == p->exec_file) {
65723 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
65724 + p->real_parent->brute = 1;
65725 + daemon = 1;
65726 + } else {
65727 + const struct cred *cred = __task_cred(p), *cred2;
65728 + struct task_struct *tsk, *tsk2;
65729 +
65730 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
65731 + struct user_struct *user;
65732 +
65733 + uid = cred->uid;
65734 +
65735 + /* this is put upon execution past expiration */
65736 + user = find_user(uid);
65737 + if (user == NULL)
65738 + goto unlock;
65739 + user->banned = 1;
65740 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
65741 + if (user->ban_expires == ~0UL)
65742 + user->ban_expires--;
65743 +
65744 + do_each_thread(tsk2, tsk) {
65745 + cred2 = __task_cred(tsk);
65746 + if (tsk != p && uid_eq(cred2->uid, uid))
65747 + gr_fake_force_sig(SIGKILL, tsk);
65748 + } while_each_thread(tsk2, tsk);
65749 + }
65750 + }
65751 +unlock:
65752 + read_unlock(&grsec_exec_file_lock);
65753 + read_unlock(&tasklist_lock);
65754 + rcu_read_unlock();
65755 +
65756 + if (gr_is_global_nonroot(uid))
65757 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n",
65758 + GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
65759 + else if (daemon)
65760 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
65761 +
65762 +#endif
65763 + return;
65764 +}
65765 +
65766 +void gr_handle_brute_check(void)
65767 +{
65768 +#ifdef CONFIG_GRKERNSEC_BRUTE
65769 + struct task_struct *p = current;
65770 +
65771 + if (unlikely(p->brute)) {
65772 + if (!grsec_enable_brute)
65773 + p->brute = 0;
65774 + else if (time_before(get_seconds(), p->brute_expires))
65775 + msleep(30 * 1000);
65776 + }
65777 +#endif
65778 + return;
65779 +}
65780 +
65781 +void gr_handle_kernel_exploit(void)
65782 +{
65783 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
65784 + const struct cred *cred;
65785 + struct task_struct *tsk, *tsk2;
65786 + struct user_struct *user;
65787 + kuid_t uid;
65788 +
65789 + if (in_irq() || in_serving_softirq() || in_nmi())
65790 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
65791 +
65792 + uid = current_uid();
65793 +
65794 + if (gr_is_global_root(uid))
65795 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
65796 + else {
65797 + /* kill all the processes of this user, hold a reference
65798 + to their creds struct, and prevent them from creating
65799 + another process until system reset
65800 + */
65801 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
65802 + GR_GLOBAL_UID(uid));
65803 + /* we intentionally leak this ref */
65804 + user = get_uid(current->cred->user);
65805 + if (user) {
65806 + user->banned = 1;
65807 + user->ban_expires = ~0UL;
65808 + }
65809 +
65810 + read_lock(&tasklist_lock);
65811 + do_each_thread(tsk2, tsk) {
65812 + cred = __task_cred(tsk);
65813 + if (uid_eq(cred->uid, uid))
65814 + gr_fake_force_sig(SIGKILL, tsk);
65815 + } while_each_thread(tsk2, tsk);
65816 + read_unlock(&tasklist_lock);
65817 + }
65818 +#endif
65819 +}
65820 +
65821 +int __gr_process_user_ban(struct user_struct *user)
65822 +{
65823 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
65824 + if (unlikely(user->banned)) {
65825 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
65826 + user->banned = 0;
65827 + user->ban_expires = 0;
65828 + free_uid(user);
65829 + } else
65830 + return -EPERM;
65831 + }
65832 +#endif
65833 + return 0;
65834 +}
65835 +
65836 +int gr_process_user_ban(void)
65837 +{
65838 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
65839 + return __gr_process_user_ban(current->cred->user);
65840 +#endif
65841 + return 0;
65842 +}
65843 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
65844 new file mode 100644
65845 index 0000000..4030d57
65846 --- /dev/null
65847 +++ b/grsecurity/grsec_sock.c
65848 @@ -0,0 +1,244 @@
65849 +#include <linux/kernel.h>
65850 +#include <linux/module.h>
65851 +#include <linux/sched.h>
65852 +#include <linux/file.h>
65853 +#include <linux/net.h>
65854 +#include <linux/in.h>
65855 +#include <linux/ip.h>
65856 +#include <net/sock.h>
65857 +#include <net/inet_sock.h>
65858 +#include <linux/grsecurity.h>
65859 +#include <linux/grinternal.h>
65860 +#include <linux/gracl.h>
65861 +
65862 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
65863 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
65864 +
65865 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
65866 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
65867 +
65868 +#ifdef CONFIG_UNIX_MODULE
65869 +EXPORT_SYMBOL(gr_acl_handle_unix);
65870 +EXPORT_SYMBOL(gr_acl_handle_mknod);
65871 +EXPORT_SYMBOL(gr_handle_chroot_unix);
65872 +EXPORT_SYMBOL(gr_handle_create);
65873 +#endif
65874 +
65875 +#ifdef CONFIG_GRKERNSEC
65876 +#define gr_conn_table_size 32749
65877 +struct conn_table_entry {
65878 + struct conn_table_entry *next;
65879 + struct signal_struct *sig;
65880 +};
65881 +
65882 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
65883 +DEFINE_SPINLOCK(gr_conn_table_lock);
65884 +
65885 +extern const char * gr_socktype_to_name(unsigned char type);
65886 +extern const char * gr_proto_to_name(unsigned char proto);
65887 +extern const char * gr_sockfamily_to_name(unsigned char family);
65888 +
65889 +static __inline__ int
65890 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
65891 +{
65892 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
65893 +}
65894 +
65895 +static __inline__ int
65896 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
65897 + __u16 sport, __u16 dport)
65898 +{
65899 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
65900 + sig->gr_sport == sport && sig->gr_dport == dport))
65901 + return 1;
65902 + else
65903 + return 0;
65904 +}
65905 +
65906 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
65907 +{
65908 + struct conn_table_entry **match;
65909 + unsigned int index;
65910 +
65911 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
65912 + sig->gr_sport, sig->gr_dport,
65913 + gr_conn_table_size);
65914 +
65915 + newent->sig = sig;
65916 +
65917 + match = &gr_conn_table[index];
65918 + newent->next = *match;
65919 + *match = newent;
65920 +
65921 + return;
65922 +}
65923 +
65924 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
65925 +{
65926 + struct conn_table_entry *match, *last = NULL;
65927 + unsigned int index;
65928 +
65929 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
65930 + sig->gr_sport, sig->gr_dport,
65931 + gr_conn_table_size);
65932 +
65933 + match = gr_conn_table[index];
65934 + while (match && !conn_match(match->sig,
65935 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
65936 + sig->gr_dport)) {
65937 + last = match;
65938 + match = match->next;
65939 + }
65940 +
65941 + if (match) {
65942 + if (last)
65943 + last->next = match->next;
65944 + else
65945 + gr_conn_table[index] = NULL;
65946 + kfree(match);
65947 + }
65948 +
65949 + return;
65950 +}
65951 +
65952 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
65953 + __u16 sport, __u16 dport)
65954 +{
65955 + struct conn_table_entry *match;
65956 + unsigned int index;
65957 +
65958 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
65959 +
65960 + match = gr_conn_table[index];
65961 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
65962 + match = match->next;
65963 +
65964 + if (match)
65965 + return match->sig;
65966 + else
65967 + return NULL;
65968 +}
65969 +
65970 +#endif
65971 +
65972 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
65973 +{
65974 +#ifdef CONFIG_GRKERNSEC
65975 + struct signal_struct *sig = task->signal;
65976 + struct conn_table_entry *newent;
65977 +
65978 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
65979 + if (newent == NULL)
65980 + return;
65981 + /* no bh lock needed since we are called with bh disabled */
65982 + spin_lock(&gr_conn_table_lock);
65983 + gr_del_task_from_ip_table_nolock(sig);
65984 + sig->gr_saddr = inet->inet_rcv_saddr;
65985 + sig->gr_daddr = inet->inet_daddr;
65986 + sig->gr_sport = inet->inet_sport;
65987 + sig->gr_dport = inet->inet_dport;
65988 + gr_add_to_task_ip_table_nolock(sig, newent);
65989 + spin_unlock(&gr_conn_table_lock);
65990 +#endif
65991 + return;
65992 +}
65993 +
65994 +void gr_del_task_from_ip_table(struct task_struct *task)
65995 +{
65996 +#ifdef CONFIG_GRKERNSEC
65997 + spin_lock_bh(&gr_conn_table_lock);
65998 + gr_del_task_from_ip_table_nolock(task->signal);
65999 + spin_unlock_bh(&gr_conn_table_lock);
66000 +#endif
66001 + return;
66002 +}
66003 +
66004 +void
66005 +gr_attach_curr_ip(const struct sock *sk)
66006 +{
66007 +#ifdef CONFIG_GRKERNSEC
66008 + struct signal_struct *p, *set;
66009 + const struct inet_sock *inet = inet_sk(sk);
66010 +
66011 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
66012 + return;
66013 +
66014 + set = current->signal;
66015 +
66016 + spin_lock_bh(&gr_conn_table_lock);
66017 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
66018 + inet->inet_dport, inet->inet_sport);
66019 + if (unlikely(p != NULL)) {
66020 + set->curr_ip = p->curr_ip;
66021 + set->used_accept = 1;
66022 + gr_del_task_from_ip_table_nolock(p);
66023 + spin_unlock_bh(&gr_conn_table_lock);
66024 + return;
66025 + }
66026 + spin_unlock_bh(&gr_conn_table_lock);
66027 +
66028 + set->curr_ip = inet->inet_daddr;
66029 + set->used_accept = 1;
66030 +#endif
66031 + return;
66032 +}
66033 +
66034 +int
66035 +gr_handle_sock_all(const int family, const int type, const int protocol)
66036 +{
66037 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66038 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
66039 + (family != AF_UNIX)) {
66040 + if (family == AF_INET)
66041 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
66042 + else
66043 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
66044 + return -EACCES;
66045 + }
66046 +#endif
66047 + return 0;
66048 +}
66049 +
66050 +int
66051 +gr_handle_sock_server(const struct sockaddr *sck)
66052 +{
66053 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66054 + if (grsec_enable_socket_server &&
66055 + in_group_p(grsec_socket_server_gid) &&
66056 + sck && (sck->sa_family != AF_UNIX) &&
66057 + (sck->sa_family != AF_LOCAL)) {
66058 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66059 + return -EACCES;
66060 + }
66061 +#endif
66062 + return 0;
66063 +}
66064 +
66065 +int
66066 +gr_handle_sock_server_other(const struct sock *sck)
66067 +{
66068 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66069 + if (grsec_enable_socket_server &&
66070 + in_group_p(grsec_socket_server_gid) &&
66071 + sck && (sck->sk_family != AF_UNIX) &&
66072 + (sck->sk_family != AF_LOCAL)) {
66073 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66074 + return -EACCES;
66075 + }
66076 +#endif
66077 + return 0;
66078 +}
66079 +
66080 +int
66081 +gr_handle_sock_client(const struct sockaddr *sck)
66082 +{
66083 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66084 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
66085 + sck && (sck->sa_family != AF_UNIX) &&
66086 + (sck->sa_family != AF_LOCAL)) {
66087 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
66088 + return -EACCES;
66089 + }
66090 +#endif
66091 + return 0;
66092 +}
66093 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
66094 new file mode 100644
66095 index 0000000..f55ef0f
66096 --- /dev/null
66097 +++ b/grsecurity/grsec_sysctl.c
66098 @@ -0,0 +1,469 @@
66099 +#include <linux/kernel.h>
66100 +#include <linux/sched.h>
66101 +#include <linux/sysctl.h>
66102 +#include <linux/grsecurity.h>
66103 +#include <linux/grinternal.h>
66104 +
66105 +int
66106 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
66107 +{
66108 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66109 + if (dirname == NULL || name == NULL)
66110 + return 0;
66111 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
66112 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
66113 + return -EACCES;
66114 + }
66115 +#endif
66116 + return 0;
66117 +}
66118 +
66119 +#ifdef CONFIG_GRKERNSEC_ROFS
66120 +static int __maybe_unused one = 1;
66121 +#endif
66122 +
66123 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
66124 +struct ctl_table grsecurity_table[] = {
66125 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66126 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
66127 +#ifdef CONFIG_GRKERNSEC_IO
66128 + {
66129 + .procname = "disable_priv_io",
66130 + .data = &grsec_disable_privio,
66131 + .maxlen = sizeof(int),
66132 + .mode = 0600,
66133 + .proc_handler = &proc_dointvec,
66134 + },
66135 +#endif
66136 +#endif
66137 +#ifdef CONFIG_GRKERNSEC_LINK
66138 + {
66139 + .procname = "linking_restrictions",
66140 + .data = &grsec_enable_link,
66141 + .maxlen = sizeof(int),
66142 + .mode = 0600,
66143 + .proc_handler = &proc_dointvec,
66144 + },
66145 +#endif
66146 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
66147 + {
66148 + .procname = "enforce_symlinksifowner",
66149 + .data = &grsec_enable_symlinkown,
66150 + .maxlen = sizeof(int),
66151 + .mode = 0600,
66152 + .proc_handler = &proc_dointvec,
66153 + },
66154 + {
66155 + .procname = "symlinkown_gid",
66156 + .data = &grsec_symlinkown_gid,
66157 + .maxlen = sizeof(int),
66158 + .mode = 0600,
66159 + .proc_handler = &proc_dointvec,
66160 + },
66161 +#endif
66162 +#ifdef CONFIG_GRKERNSEC_BRUTE
66163 + {
66164 + .procname = "deter_bruteforce",
66165 + .data = &grsec_enable_brute,
66166 + .maxlen = sizeof(int),
66167 + .mode = 0600,
66168 + .proc_handler = &proc_dointvec,
66169 + },
66170 +#endif
66171 +#ifdef CONFIG_GRKERNSEC_FIFO
66172 + {
66173 + .procname = "fifo_restrictions",
66174 + .data = &grsec_enable_fifo,
66175 + .maxlen = sizeof(int),
66176 + .mode = 0600,
66177 + .proc_handler = &proc_dointvec,
66178 + },
66179 +#endif
66180 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
66181 + {
66182 + .procname = "ptrace_readexec",
66183 + .data = &grsec_enable_ptrace_readexec,
66184 + .maxlen = sizeof(int),
66185 + .mode = 0600,
66186 + .proc_handler = &proc_dointvec,
66187 + },
66188 +#endif
66189 +#ifdef CONFIG_GRKERNSEC_SETXID
66190 + {
66191 + .procname = "consistent_setxid",
66192 + .data = &grsec_enable_setxid,
66193 + .maxlen = sizeof(int),
66194 + .mode = 0600,
66195 + .proc_handler = &proc_dointvec,
66196 + },
66197 +#endif
66198 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
66199 + {
66200 + .procname = "ip_blackhole",
66201 + .data = &grsec_enable_blackhole,
66202 + .maxlen = sizeof(int),
66203 + .mode = 0600,
66204 + .proc_handler = &proc_dointvec,
66205 + },
66206 + {
66207 + .procname = "lastack_retries",
66208 + .data = &grsec_lastack_retries,
66209 + .maxlen = sizeof(int),
66210 + .mode = 0600,
66211 + .proc_handler = &proc_dointvec,
66212 + },
66213 +#endif
66214 +#ifdef CONFIG_GRKERNSEC_EXECLOG
66215 + {
66216 + .procname = "exec_logging",
66217 + .data = &grsec_enable_execlog,
66218 + .maxlen = sizeof(int),
66219 + .mode = 0600,
66220 + .proc_handler = &proc_dointvec,
66221 + },
66222 +#endif
66223 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66224 + {
66225 + .procname = "rwxmap_logging",
66226 + .data = &grsec_enable_log_rwxmaps,
66227 + .maxlen = sizeof(int),
66228 + .mode = 0600,
66229 + .proc_handler = &proc_dointvec,
66230 + },
66231 +#endif
66232 +#ifdef CONFIG_GRKERNSEC_SIGNAL
66233 + {
66234 + .procname = "signal_logging",
66235 + .data = &grsec_enable_signal,
66236 + .maxlen = sizeof(int),
66237 + .mode = 0600,
66238 + .proc_handler = &proc_dointvec,
66239 + },
66240 +#endif
66241 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
66242 + {
66243 + .procname = "forkfail_logging",
66244 + .data = &grsec_enable_forkfail,
66245 + .maxlen = sizeof(int),
66246 + .mode = 0600,
66247 + .proc_handler = &proc_dointvec,
66248 + },
66249 +#endif
66250 +#ifdef CONFIG_GRKERNSEC_TIME
66251 + {
66252 + .procname = "timechange_logging",
66253 + .data = &grsec_enable_time,
66254 + .maxlen = sizeof(int),
66255 + .mode = 0600,
66256 + .proc_handler = &proc_dointvec,
66257 + },
66258 +#endif
66259 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
66260 + {
66261 + .procname = "chroot_deny_shmat",
66262 + .data = &grsec_enable_chroot_shmat,
66263 + .maxlen = sizeof(int),
66264 + .mode = 0600,
66265 + .proc_handler = &proc_dointvec,
66266 + },
66267 +#endif
66268 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
66269 + {
66270 + .procname = "chroot_deny_unix",
66271 + .data = &grsec_enable_chroot_unix,
66272 + .maxlen = sizeof(int),
66273 + .mode = 0600,
66274 + .proc_handler = &proc_dointvec,
66275 + },
66276 +#endif
66277 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
66278 + {
66279 + .procname = "chroot_deny_mount",
66280 + .data = &grsec_enable_chroot_mount,
66281 + .maxlen = sizeof(int),
66282 + .mode = 0600,
66283 + .proc_handler = &proc_dointvec,
66284 + },
66285 +#endif
66286 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
66287 + {
66288 + .procname = "chroot_deny_fchdir",
66289 + .data = &grsec_enable_chroot_fchdir,
66290 + .maxlen = sizeof(int),
66291 + .mode = 0600,
66292 + .proc_handler = &proc_dointvec,
66293 + },
66294 +#endif
66295 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
66296 + {
66297 + .procname = "chroot_deny_chroot",
66298 + .data = &grsec_enable_chroot_double,
66299 + .maxlen = sizeof(int),
66300 + .mode = 0600,
66301 + .proc_handler = &proc_dointvec,
66302 + },
66303 +#endif
66304 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
66305 + {
66306 + .procname = "chroot_deny_pivot",
66307 + .data = &grsec_enable_chroot_pivot,
66308 + .maxlen = sizeof(int),
66309 + .mode = 0600,
66310 + .proc_handler = &proc_dointvec,
66311 + },
66312 +#endif
66313 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
66314 + {
66315 + .procname = "chroot_enforce_chdir",
66316 + .data = &grsec_enable_chroot_chdir,
66317 + .maxlen = sizeof(int),
66318 + .mode = 0600,
66319 + .proc_handler = &proc_dointvec,
66320 + },
66321 +#endif
66322 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
66323 + {
66324 + .procname = "chroot_deny_chmod",
66325 + .data = &grsec_enable_chroot_chmod,
66326 + .maxlen = sizeof(int),
66327 + .mode = 0600,
66328 + .proc_handler = &proc_dointvec,
66329 + },
66330 +#endif
66331 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
66332 + {
66333 + .procname = "chroot_deny_mknod",
66334 + .data = &grsec_enable_chroot_mknod,
66335 + .maxlen = sizeof(int),
66336 + .mode = 0600,
66337 + .proc_handler = &proc_dointvec,
66338 + },
66339 +#endif
66340 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66341 + {
66342 + .procname = "chroot_restrict_nice",
66343 + .data = &grsec_enable_chroot_nice,
66344 + .maxlen = sizeof(int),
66345 + .mode = 0600,
66346 + .proc_handler = &proc_dointvec,
66347 + },
66348 +#endif
66349 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
66350 + {
66351 + .procname = "chroot_execlog",
66352 + .data = &grsec_enable_chroot_execlog,
66353 + .maxlen = sizeof(int),
66354 + .mode = 0600,
66355 + .proc_handler = &proc_dointvec,
66356 + },
66357 +#endif
66358 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
66359 + {
66360 + .procname = "chroot_caps",
66361 + .data = &grsec_enable_chroot_caps,
66362 + .maxlen = sizeof(int),
66363 + .mode = 0600,
66364 + .proc_handler = &proc_dointvec,
66365 + },
66366 +#endif
66367 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
66368 + {
66369 + .procname = "chroot_deny_sysctl",
66370 + .data = &grsec_enable_chroot_sysctl,
66371 + .maxlen = sizeof(int),
66372 + .mode = 0600,
66373 + .proc_handler = &proc_dointvec,
66374 + },
66375 +#endif
66376 +#ifdef CONFIG_GRKERNSEC_TPE
66377 + {
66378 + .procname = "tpe",
66379 + .data = &grsec_enable_tpe,
66380 + .maxlen = sizeof(int),
66381 + .mode = 0600,
66382 + .proc_handler = &proc_dointvec,
66383 + },
66384 + {
66385 + .procname = "tpe_gid",
66386 + .data = &grsec_tpe_gid,
66387 + .maxlen = sizeof(int),
66388 + .mode = 0600,
66389 + .proc_handler = &proc_dointvec,
66390 + },
66391 +#endif
66392 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66393 + {
66394 + .procname = "tpe_invert",
66395 + .data = &grsec_enable_tpe_invert,
66396 + .maxlen = sizeof(int),
66397 + .mode = 0600,
66398 + .proc_handler = &proc_dointvec,
66399 + },
66400 +#endif
66401 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66402 + {
66403 + .procname = "tpe_restrict_all",
66404 + .data = &grsec_enable_tpe_all,
66405 + .maxlen = sizeof(int),
66406 + .mode = 0600,
66407 + .proc_handler = &proc_dointvec,
66408 + },
66409 +#endif
66410 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66411 + {
66412 + .procname = "socket_all",
66413 + .data = &grsec_enable_socket_all,
66414 + .maxlen = sizeof(int),
66415 + .mode = 0600,
66416 + .proc_handler = &proc_dointvec,
66417 + },
66418 + {
66419 + .procname = "socket_all_gid",
66420 + .data = &grsec_socket_all_gid,
66421 + .maxlen = sizeof(int),
66422 + .mode = 0600,
66423 + .proc_handler = &proc_dointvec,
66424 + },
66425 +#endif
66426 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66427 + {
66428 + .procname = "socket_client",
66429 + .data = &grsec_enable_socket_client,
66430 + .maxlen = sizeof(int),
66431 + .mode = 0600,
66432 + .proc_handler = &proc_dointvec,
66433 + },
66434 + {
66435 + .procname = "socket_client_gid",
66436 + .data = &grsec_socket_client_gid,
66437 + .maxlen = sizeof(int),
66438 + .mode = 0600,
66439 + .proc_handler = &proc_dointvec,
66440 + },
66441 +#endif
66442 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66443 + {
66444 + .procname = "socket_server",
66445 + .data = &grsec_enable_socket_server,
66446 + .maxlen = sizeof(int),
66447 + .mode = 0600,
66448 + .proc_handler = &proc_dointvec,
66449 + },
66450 + {
66451 + .procname = "socket_server_gid",
66452 + .data = &grsec_socket_server_gid,
66453 + .maxlen = sizeof(int),
66454 + .mode = 0600,
66455 + .proc_handler = &proc_dointvec,
66456 + },
66457 +#endif
66458 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
66459 + {
66460 + .procname = "audit_group",
66461 + .data = &grsec_enable_group,
66462 + .maxlen = sizeof(int),
66463 + .mode = 0600,
66464 + .proc_handler = &proc_dointvec,
66465 + },
66466 + {
66467 + .procname = "audit_gid",
66468 + .data = &grsec_audit_gid,
66469 + .maxlen = sizeof(int),
66470 + .mode = 0600,
66471 + .proc_handler = &proc_dointvec,
66472 + },
66473 +#endif
66474 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
66475 + {
66476 + .procname = "audit_chdir",
66477 + .data = &grsec_enable_chdir,
66478 + .maxlen = sizeof(int),
66479 + .mode = 0600,
66480 + .proc_handler = &proc_dointvec,
66481 + },
66482 +#endif
66483 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66484 + {
66485 + .procname = "audit_mount",
66486 + .data = &grsec_enable_mount,
66487 + .maxlen = sizeof(int),
66488 + .mode = 0600,
66489 + .proc_handler = &proc_dointvec,
66490 + },
66491 +#endif
66492 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
66493 + {
66494 + .procname = "audit_textrel",
66495 + .data = &grsec_enable_audit_textrel,
66496 + .maxlen = sizeof(int),
66497 + .mode = 0600,
66498 + .proc_handler = &proc_dointvec,
66499 + },
66500 +#endif
66501 +#ifdef CONFIG_GRKERNSEC_DMESG
66502 + {
66503 + .procname = "dmesg",
66504 + .data = &grsec_enable_dmesg,
66505 + .maxlen = sizeof(int),
66506 + .mode = 0600,
66507 + .proc_handler = &proc_dointvec,
66508 + },
66509 +#endif
66510 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
66511 + {
66512 + .procname = "chroot_findtask",
66513 + .data = &grsec_enable_chroot_findtask,
66514 + .maxlen = sizeof(int),
66515 + .mode = 0600,
66516 + .proc_handler = &proc_dointvec,
66517 + },
66518 +#endif
66519 +#ifdef CONFIG_GRKERNSEC_RESLOG
66520 + {
66521 + .procname = "resource_logging",
66522 + .data = &grsec_resource_logging,
66523 + .maxlen = sizeof(int),
66524 + .mode = 0600,
66525 + .proc_handler = &proc_dointvec,
66526 + },
66527 +#endif
66528 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66529 + {
66530 + .procname = "audit_ptrace",
66531 + .data = &grsec_enable_audit_ptrace,
66532 + .maxlen = sizeof(int),
66533 + .mode = 0600,
66534 + .proc_handler = &proc_dointvec,
66535 + },
66536 +#endif
66537 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66538 + {
66539 + .procname = "harden_ptrace",
66540 + .data = &grsec_enable_harden_ptrace,
66541 + .maxlen = sizeof(int),
66542 + .mode = 0600,
66543 + .proc_handler = &proc_dointvec,
66544 + },
66545 +#endif
66546 + {
66547 + .procname = "grsec_lock",
66548 + .data = &grsec_lock,
66549 + .maxlen = sizeof(int),
66550 + .mode = 0600,
66551 + .proc_handler = &proc_dointvec,
66552 + },
66553 +#endif
66554 +#ifdef CONFIG_GRKERNSEC_ROFS
66555 + {
66556 + .procname = "romount_protect",
66557 + .data = &grsec_enable_rofs,
66558 + .maxlen = sizeof(int),
66559 + .mode = 0600,
66560 + .proc_handler = &proc_dointvec_minmax,
66561 + .extra1 = &one,
66562 + .extra2 = &one,
66563 + },
66564 +#endif
66565 + { }
66566 +};
66567 +#endif
66568 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
66569 new file mode 100644
66570 index 0000000..0dc13c3
66571 --- /dev/null
66572 +++ b/grsecurity/grsec_time.c
66573 @@ -0,0 +1,16 @@
66574 +#include <linux/kernel.h>
66575 +#include <linux/sched.h>
66576 +#include <linux/grinternal.h>
66577 +#include <linux/module.h>
66578 +
66579 +void
66580 +gr_log_timechange(void)
66581 +{
66582 +#ifdef CONFIG_GRKERNSEC_TIME
66583 + if (grsec_enable_time)
66584 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
66585 +#endif
66586 + return;
66587 +}
66588 +
66589 +EXPORT_SYMBOL(gr_log_timechange);
66590 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
66591 new file mode 100644
66592 index 0000000..ee57dcf
66593 --- /dev/null
66594 +++ b/grsecurity/grsec_tpe.c
66595 @@ -0,0 +1,73 @@
66596 +#include <linux/kernel.h>
66597 +#include <linux/sched.h>
66598 +#include <linux/file.h>
66599 +#include <linux/fs.h>
66600 +#include <linux/grinternal.h>
66601 +
66602 +extern int gr_acl_tpe_check(void);
66603 +
66604 +int
66605 +gr_tpe_allow(const struct file *file)
66606 +{
66607 +#ifdef CONFIG_GRKERNSEC
66608 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
66609 + const struct cred *cred = current_cred();
66610 + char *msg = NULL;
66611 + char *msg2 = NULL;
66612 +
66613 + // never restrict root
66614 + if (gr_is_global_root(cred->uid))
66615 + return 1;
66616 +
66617 + if (grsec_enable_tpe) {
66618 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66619 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
66620 + msg = "not being in trusted group";
66621 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
66622 + msg = "being in untrusted group";
66623 +#else
66624 + if (in_group_p(grsec_tpe_gid))
66625 + msg = "being in untrusted group";
66626 +#endif
66627 + }
66628 + if (!msg && gr_acl_tpe_check())
66629 + msg = "being in untrusted role";
66630 +
66631 + // not in any affected group/role
66632 + if (!msg)
66633 + goto next_check;
66634 +
66635 + if (gr_is_global_nonroot(inode->i_uid))
66636 + msg2 = "file in non-root-owned directory";
66637 + else if (inode->i_mode & S_IWOTH)
66638 + msg2 = "file in world-writable directory";
66639 + else if (inode->i_mode & S_IWGRP)
66640 + msg2 = "file in group-writable directory";
66641 +
66642 + if (msg && msg2) {
66643 + char fullmsg[70] = {0};
66644 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
66645 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
66646 + return 0;
66647 + }
66648 + msg = NULL;
66649 +next_check:
66650 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66651 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
66652 + return 1;
66653 +
66654 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
66655 + msg = "directory not owned by user";
66656 + else if (inode->i_mode & S_IWOTH)
66657 + msg = "file in world-writable directory";
66658 + else if (inode->i_mode & S_IWGRP)
66659 + msg = "file in group-writable directory";
66660 +
66661 + if (msg) {
66662 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
66663 + return 0;
66664 + }
66665 +#endif
66666 +#endif
66667 + return 1;
66668 +}
66669 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
66670 new file mode 100644
66671 index 0000000..9f7b1ac
66672 --- /dev/null
66673 +++ b/grsecurity/grsum.c
66674 @@ -0,0 +1,61 @@
66675 +#include <linux/err.h>
66676 +#include <linux/kernel.h>
66677 +#include <linux/sched.h>
66678 +#include <linux/mm.h>
66679 +#include <linux/scatterlist.h>
66680 +#include <linux/crypto.h>
66681 +#include <linux/gracl.h>
66682 +
66683 +
66684 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
66685 +#error "crypto and sha256 must be built into the kernel"
66686 +#endif
66687 +
66688 +int
66689 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
66690 +{
66691 + char *p;
66692 + struct crypto_hash *tfm;
66693 + struct hash_desc desc;
66694 + struct scatterlist sg;
66695 + unsigned char temp_sum[GR_SHA_LEN];
66696 + volatile int retval = 0;
66697 + volatile int dummy = 0;
66698 + unsigned int i;
66699 +
66700 + sg_init_table(&sg, 1);
66701 +
66702 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
66703 + if (IS_ERR(tfm)) {
66704 + /* should never happen, since sha256 should be built in */
66705 + return 1;
66706 + }
66707 +
66708 + desc.tfm = tfm;
66709 + desc.flags = 0;
66710 +
66711 + crypto_hash_init(&desc);
66712 +
66713 + p = salt;
66714 + sg_set_buf(&sg, p, GR_SALT_LEN);
66715 + crypto_hash_update(&desc, &sg, sg.length);
66716 +
66717 + p = entry->pw;
66718 + sg_set_buf(&sg, p, strlen(p));
66719 +
66720 + crypto_hash_update(&desc, &sg, sg.length);
66721 +
66722 + crypto_hash_final(&desc, temp_sum);
66723 +
66724 + memset(entry->pw, 0, GR_PW_LEN);
66725 +
66726 + for (i = 0; i < GR_SHA_LEN; i++)
66727 + if (sum[i] != temp_sum[i])
66728 + retval = 1;
66729 + else
66730 + dummy = 1; // waste a cycle
66731 +
66732 + crypto_free_hash(tfm);
66733 +
66734 + return retval;
66735 +}
66736 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
66737 index 77ff547..181834f 100644
66738 --- a/include/asm-generic/4level-fixup.h
66739 +++ b/include/asm-generic/4level-fixup.h
66740 @@ -13,8 +13,10 @@
66741 #define pmd_alloc(mm, pud, address) \
66742 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
66743 NULL: pmd_offset(pud, address))
66744 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
66745
66746 #define pud_alloc(mm, pgd, address) (pgd)
66747 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
66748 #define pud_offset(pgd, start) (pgd)
66749 #define pud_none(pud) 0
66750 #define pud_bad(pud) 0
66751 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
66752 index b7babf0..04ad282 100644
66753 --- a/include/asm-generic/atomic-long.h
66754 +++ b/include/asm-generic/atomic-long.h
66755 @@ -22,6 +22,12 @@
66756
66757 typedef atomic64_t atomic_long_t;
66758
66759 +#ifdef CONFIG_PAX_REFCOUNT
66760 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
66761 +#else
66762 +typedef atomic64_t atomic_long_unchecked_t;
66763 +#endif
66764 +
66765 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
66766
66767 static inline long atomic_long_read(atomic_long_t *l)
66768 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66769 return (long)atomic64_read(v);
66770 }
66771
66772 +#ifdef CONFIG_PAX_REFCOUNT
66773 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66774 +{
66775 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66776 +
66777 + return (long)atomic64_read_unchecked(v);
66778 +}
66779 +#endif
66780 +
66781 static inline void atomic_long_set(atomic_long_t *l, long i)
66782 {
66783 atomic64_t *v = (atomic64_t *)l;
66784 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66785 atomic64_set(v, i);
66786 }
66787
66788 +#ifdef CONFIG_PAX_REFCOUNT
66789 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66790 +{
66791 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66792 +
66793 + atomic64_set_unchecked(v, i);
66794 +}
66795 +#endif
66796 +
66797 static inline void atomic_long_inc(atomic_long_t *l)
66798 {
66799 atomic64_t *v = (atomic64_t *)l;
66800 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
66801 atomic64_inc(v);
66802 }
66803
66804 +#ifdef CONFIG_PAX_REFCOUNT
66805 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
66806 +{
66807 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66808 +
66809 + atomic64_inc_unchecked(v);
66810 +}
66811 +#endif
66812 +
66813 static inline void atomic_long_dec(atomic_long_t *l)
66814 {
66815 atomic64_t *v = (atomic64_t *)l;
66816 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
66817 atomic64_dec(v);
66818 }
66819
66820 +#ifdef CONFIG_PAX_REFCOUNT
66821 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
66822 +{
66823 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66824 +
66825 + atomic64_dec_unchecked(v);
66826 +}
66827 +#endif
66828 +
66829 static inline void atomic_long_add(long i, atomic_long_t *l)
66830 {
66831 atomic64_t *v = (atomic64_t *)l;
66832 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
66833 atomic64_add(i, v);
66834 }
66835
66836 +#ifdef CONFIG_PAX_REFCOUNT
66837 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
66838 +{
66839 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66840 +
66841 + atomic64_add_unchecked(i, v);
66842 +}
66843 +#endif
66844 +
66845 static inline void atomic_long_sub(long i, atomic_long_t *l)
66846 {
66847 atomic64_t *v = (atomic64_t *)l;
66848 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66849 atomic64_sub(i, v);
66850 }
66851
66852 +#ifdef CONFIG_PAX_REFCOUNT
66853 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
66854 +{
66855 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66856 +
66857 + atomic64_sub_unchecked(i, v);
66858 +}
66859 +#endif
66860 +
66861 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
66862 {
66863 atomic64_t *v = (atomic64_t *)l;
66864 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
66865 return (long)atomic64_add_return(i, v);
66866 }
66867
66868 +#ifdef CONFIG_PAX_REFCOUNT
66869 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
66870 +{
66871 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66872 +
66873 + return (long)atomic64_add_return_unchecked(i, v);
66874 +}
66875 +#endif
66876 +
66877 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
66878 {
66879 atomic64_t *v = (atomic64_t *)l;
66880 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
66881 return (long)atomic64_inc_return(v);
66882 }
66883
66884 +#ifdef CONFIG_PAX_REFCOUNT
66885 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
66886 +{
66887 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66888 +
66889 + return (long)atomic64_inc_return_unchecked(v);
66890 +}
66891 +#endif
66892 +
66893 static inline long atomic_long_dec_return(atomic_long_t *l)
66894 {
66895 atomic64_t *v = (atomic64_t *)l;
66896 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
66897
66898 typedef atomic_t atomic_long_t;
66899
66900 +#ifdef CONFIG_PAX_REFCOUNT
66901 +typedef atomic_unchecked_t atomic_long_unchecked_t;
66902 +#else
66903 +typedef atomic_t atomic_long_unchecked_t;
66904 +#endif
66905 +
66906 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
66907 static inline long atomic_long_read(atomic_long_t *l)
66908 {
66909 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66910 return (long)atomic_read(v);
66911 }
66912
66913 +#ifdef CONFIG_PAX_REFCOUNT
66914 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66915 +{
66916 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66917 +
66918 + return (long)atomic_read_unchecked(v);
66919 +}
66920 +#endif
66921 +
66922 static inline void atomic_long_set(atomic_long_t *l, long i)
66923 {
66924 atomic_t *v = (atomic_t *)l;
66925 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66926 atomic_set(v, i);
66927 }
66928
66929 +#ifdef CONFIG_PAX_REFCOUNT
66930 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66931 +{
66932 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66933 +
66934 + atomic_set_unchecked(v, i);
66935 +}
66936 +#endif
66937 +
66938 static inline void atomic_long_inc(atomic_long_t *l)
66939 {
66940 atomic_t *v = (atomic_t *)l;
66941 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
66942 atomic_inc(v);
66943 }
66944
66945 +#ifdef CONFIG_PAX_REFCOUNT
66946 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
66947 +{
66948 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66949 +
66950 + atomic_inc_unchecked(v);
66951 +}
66952 +#endif
66953 +
66954 static inline void atomic_long_dec(atomic_long_t *l)
66955 {
66956 atomic_t *v = (atomic_t *)l;
66957 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
66958 atomic_dec(v);
66959 }
66960
66961 +#ifdef CONFIG_PAX_REFCOUNT
66962 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
66963 +{
66964 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66965 +
66966 + atomic_dec_unchecked(v);
66967 +}
66968 +#endif
66969 +
66970 static inline void atomic_long_add(long i, atomic_long_t *l)
66971 {
66972 atomic_t *v = (atomic_t *)l;
66973 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
66974 atomic_add(i, v);
66975 }
66976
66977 +#ifdef CONFIG_PAX_REFCOUNT
66978 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
66979 +{
66980 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66981 +
66982 + atomic_add_unchecked(i, v);
66983 +}
66984 +#endif
66985 +
66986 static inline void atomic_long_sub(long i, atomic_long_t *l)
66987 {
66988 atomic_t *v = (atomic_t *)l;
66989 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66990 atomic_sub(i, v);
66991 }
66992
66993 +#ifdef CONFIG_PAX_REFCOUNT
66994 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
66995 +{
66996 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
66997 +
66998 + atomic_sub_unchecked(i, v);
66999 +}
67000 +#endif
67001 +
67002 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67003 {
67004 atomic_t *v = (atomic_t *)l;
67005 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67006 return (long)atomic_add_return(i, v);
67007 }
67008
67009 +#ifdef CONFIG_PAX_REFCOUNT
67010 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67011 +{
67012 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67013 +
67014 + return (long)atomic_add_return_unchecked(i, v);
67015 +}
67016 +
67017 +#endif
67018 +
67019 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67020 {
67021 atomic_t *v = (atomic_t *)l;
67022 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67023 return (long)atomic_inc_return(v);
67024 }
67025
67026 +#ifdef CONFIG_PAX_REFCOUNT
67027 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67028 +{
67029 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67030 +
67031 + return (long)atomic_inc_return_unchecked(v);
67032 +}
67033 +#endif
67034 +
67035 static inline long atomic_long_dec_return(atomic_long_t *l)
67036 {
67037 atomic_t *v = (atomic_t *)l;
67038 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67039
67040 #endif /* BITS_PER_LONG == 64 */
67041
67042 +#ifdef CONFIG_PAX_REFCOUNT
67043 +static inline void pax_refcount_needs_these_functions(void)
67044 +{
67045 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
67046 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
67047 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
67048 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
67049 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
67050 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
67051 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
67052 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
67053 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
67054 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
67055 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
67056 +#ifdef CONFIG_X86
67057 + atomic_clear_mask_unchecked(0, NULL);
67058 + atomic_set_mask_unchecked(0, NULL);
67059 +#endif
67060 +
67061 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
67062 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
67063 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
67064 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
67065 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
67066 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
67067 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
67068 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
67069 +}
67070 +#else
67071 +#define atomic_read_unchecked(v) atomic_read(v)
67072 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
67073 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
67074 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
67075 +#define atomic_inc_unchecked(v) atomic_inc(v)
67076 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
67077 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
67078 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
67079 +#define atomic_dec_unchecked(v) atomic_dec(v)
67080 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
67081 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
67082 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
67083 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
67084 +
67085 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
67086 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
67087 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
67088 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
67089 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
67090 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
67091 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
67092 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
67093 +#endif
67094 +
67095 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
67096 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
67097 index 33bd2de..f31bff97 100644
67098 --- a/include/asm-generic/atomic.h
67099 +++ b/include/asm-generic/atomic.h
67100 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
67101 * Atomically clears the bits set in @mask from @v
67102 */
67103 #ifndef atomic_clear_mask
67104 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
67105 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
67106 {
67107 unsigned long flags;
67108
67109 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
67110 index b18ce4f..2ee2843 100644
67111 --- a/include/asm-generic/atomic64.h
67112 +++ b/include/asm-generic/atomic64.h
67113 @@ -16,6 +16,8 @@ typedef struct {
67114 long long counter;
67115 } atomic64_t;
67116
67117 +typedef atomic64_t atomic64_unchecked_t;
67118 +
67119 #define ATOMIC64_INIT(i) { (i) }
67120
67121 extern long long atomic64_read(const atomic64_t *v);
67122 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
67123 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
67124 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
67125
67126 +#define atomic64_read_unchecked(v) atomic64_read(v)
67127 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
67128 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
67129 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
67130 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
67131 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
67132 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
67133 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
67134 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
67135 +
67136 #endif /* _ASM_GENERIC_ATOMIC64_H */
67137 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
67138 index 1bfcfe5..e04c5c9 100644
67139 --- a/include/asm-generic/cache.h
67140 +++ b/include/asm-generic/cache.h
67141 @@ -6,7 +6,7 @@
67142 * cache lines need to provide their own cache.h.
67143 */
67144
67145 -#define L1_CACHE_SHIFT 5
67146 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
67147 +#define L1_CACHE_SHIFT 5UL
67148 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
67149
67150 #endif /* __ASM_GENERIC_CACHE_H */
67151 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
67152 index 0d68a1e..b74a761 100644
67153 --- a/include/asm-generic/emergency-restart.h
67154 +++ b/include/asm-generic/emergency-restart.h
67155 @@ -1,7 +1,7 @@
67156 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
67157 #define _ASM_GENERIC_EMERGENCY_RESTART_H
67158
67159 -static inline void machine_emergency_restart(void)
67160 +static inline __noreturn void machine_emergency_restart(void)
67161 {
67162 machine_restart(NULL);
67163 }
67164 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
67165 index 90f99c7..00ce236 100644
67166 --- a/include/asm-generic/kmap_types.h
67167 +++ b/include/asm-generic/kmap_types.h
67168 @@ -2,9 +2,9 @@
67169 #define _ASM_GENERIC_KMAP_TYPES_H
67170
67171 #ifdef __WITH_KM_FENCE
67172 -# define KM_TYPE_NR 41
67173 +# define KM_TYPE_NR 42
67174 #else
67175 -# define KM_TYPE_NR 20
67176 +# define KM_TYPE_NR 21
67177 #endif
67178
67179 #endif
67180 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
67181 index 9ceb03b..62b0b8f 100644
67182 --- a/include/asm-generic/local.h
67183 +++ b/include/asm-generic/local.h
67184 @@ -23,24 +23,37 @@ typedef struct
67185 atomic_long_t a;
67186 } local_t;
67187
67188 +typedef struct {
67189 + atomic_long_unchecked_t a;
67190 +} local_unchecked_t;
67191 +
67192 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
67193
67194 #define local_read(l) atomic_long_read(&(l)->a)
67195 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
67196 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
67197 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
67198 #define local_inc(l) atomic_long_inc(&(l)->a)
67199 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
67200 #define local_dec(l) atomic_long_dec(&(l)->a)
67201 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
67202 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
67203 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
67204 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
67205 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
67206
67207 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
67208 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
67209 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
67210 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
67211 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
67212 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
67213 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
67214 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
67215 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
67216
67217 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67218 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67219 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
67220 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
67221 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
67222 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
67223 index 725612b..9cc513a 100644
67224 --- a/include/asm-generic/pgtable-nopmd.h
67225 +++ b/include/asm-generic/pgtable-nopmd.h
67226 @@ -1,14 +1,19 @@
67227 #ifndef _PGTABLE_NOPMD_H
67228 #define _PGTABLE_NOPMD_H
67229
67230 -#ifndef __ASSEMBLY__
67231 -
67232 #include <asm-generic/pgtable-nopud.h>
67233
67234 -struct mm_struct;
67235 -
67236 #define __PAGETABLE_PMD_FOLDED
67237
67238 +#define PMD_SHIFT PUD_SHIFT
67239 +#define PTRS_PER_PMD 1
67240 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
67241 +#define PMD_MASK (~(PMD_SIZE-1))
67242 +
67243 +#ifndef __ASSEMBLY__
67244 +
67245 +struct mm_struct;
67246 +
67247 /*
67248 * Having the pmd type consist of a pud gets the size right, and allows
67249 * us to conceptually access the pud entry that this pmd is folded into
67250 @@ -16,11 +21,6 @@ struct mm_struct;
67251 */
67252 typedef struct { pud_t pud; } pmd_t;
67253
67254 -#define PMD_SHIFT PUD_SHIFT
67255 -#define PTRS_PER_PMD 1
67256 -#define PMD_SIZE (1UL << PMD_SHIFT)
67257 -#define PMD_MASK (~(PMD_SIZE-1))
67258 -
67259 /*
67260 * The "pud_xxx()" functions here are trivial for a folded two-level
67261 * setup: the pmd is never bad, and a pmd always exists (as it's folded
67262 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
67263 index 810431d..0ec4804f 100644
67264 --- a/include/asm-generic/pgtable-nopud.h
67265 +++ b/include/asm-generic/pgtable-nopud.h
67266 @@ -1,10 +1,15 @@
67267 #ifndef _PGTABLE_NOPUD_H
67268 #define _PGTABLE_NOPUD_H
67269
67270 -#ifndef __ASSEMBLY__
67271 -
67272 #define __PAGETABLE_PUD_FOLDED
67273
67274 +#define PUD_SHIFT PGDIR_SHIFT
67275 +#define PTRS_PER_PUD 1
67276 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
67277 +#define PUD_MASK (~(PUD_SIZE-1))
67278 +
67279 +#ifndef __ASSEMBLY__
67280 +
67281 /*
67282 * Having the pud type consist of a pgd gets the size right, and allows
67283 * us to conceptually access the pgd entry that this pud is folded into
67284 @@ -12,11 +17,6 @@
67285 */
67286 typedef struct { pgd_t pgd; } pud_t;
67287
67288 -#define PUD_SHIFT PGDIR_SHIFT
67289 -#define PTRS_PER_PUD 1
67290 -#define PUD_SIZE (1UL << PUD_SHIFT)
67291 -#define PUD_MASK (~(PUD_SIZE-1))
67292 -
67293 /*
67294 * The "pgd_xxx()" functions here are trivial for a folded two-level
67295 * setup: the pud is never bad, and a pud always exists (as it's folded
67296 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
67297 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
67298
67299 #define pgd_populate(mm, pgd, pud) do { } while (0)
67300 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
67301 /*
67302 * (puds are folded into pgds so this doesn't get actually called,
67303 * but the define is needed for a generic inline function.)
67304 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
67305 index a59ff51..2594a70 100644
67306 --- a/include/asm-generic/pgtable.h
67307 +++ b/include/asm-generic/pgtable.h
67308 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
67309 }
67310 #endif /* CONFIG_NUMA_BALANCING */
67311
67312 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
67313 +static inline unsigned long pax_open_kernel(void) { return 0; }
67314 +#endif
67315 +
67316 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
67317 +static inline unsigned long pax_close_kernel(void) { return 0; }
67318 +#endif
67319 +
67320 #endif /* CONFIG_MMU */
67321
67322 #endif /* !__ASSEMBLY__ */
67323 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
67324 index afa12c7..99d4da0 100644
67325 --- a/include/asm-generic/vmlinux.lds.h
67326 +++ b/include/asm-generic/vmlinux.lds.h
67327 @@ -245,6 +245,7 @@
67328 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
67329 VMLINUX_SYMBOL(__start_rodata) = .; \
67330 *(.rodata) *(.rodata.*) \
67331 + *(.data..read_only) \
67332 *(__vermagic) /* Kernel version magic */ \
67333 . = ALIGN(8); \
67334 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
67335 @@ -755,17 +756,18 @@
67336 * section in the linker script will go there too. @phdr should have
67337 * a leading colon.
67338 *
67339 - * Note that this macros defines __per_cpu_load as an absolute symbol.
67340 + * Note that this macros defines per_cpu_load as an absolute symbol.
67341 * If there is no need to put the percpu section at a predetermined
67342 * address, use PERCPU_SECTION.
67343 */
67344 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
67345 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
67346 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
67347 + per_cpu_load = .; \
67348 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
67349 - LOAD_OFFSET) { \
67350 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
67351 PERCPU_INPUT(cacheline) \
67352 } phdr \
67353 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
67354 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
67355
67356 /**
67357 * PERCPU_SECTION - define output section for percpu area, simple version
67358 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
67359 index 418d270..bfd2794 100644
67360 --- a/include/crypto/algapi.h
67361 +++ b/include/crypto/algapi.h
67362 @@ -34,7 +34,7 @@ struct crypto_type {
67363 unsigned int maskclear;
67364 unsigned int maskset;
67365 unsigned int tfmsize;
67366 -};
67367 +} __do_const;
67368
67369 struct crypto_instance {
67370 struct crypto_alg alg;
67371 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
67372 index f1ce786..086a7a5 100644
67373 --- a/include/drm/drmP.h
67374 +++ b/include/drm/drmP.h
67375 @@ -72,6 +72,7 @@
67376 #include <linux/workqueue.h>
67377 #include <linux/poll.h>
67378 #include <asm/pgalloc.h>
67379 +#include <asm/local.h>
67380 #include <drm/drm.h>
67381 #include <drm/drm_sarea.h>
67382
67383 @@ -296,10 +297,12 @@ do { \
67384 * \param cmd command.
67385 * \param arg argument.
67386 */
67387 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
67388 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
67389 + struct drm_file *file_priv);
67390 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
67391 struct drm_file *file_priv);
67392
67393 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67394 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
67395 unsigned long arg);
67396
67397 #define DRM_IOCTL_NR(n) _IOC_NR(n)
67398 @@ -314,9 +317,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67399 struct drm_ioctl_desc {
67400 unsigned int cmd;
67401 int flags;
67402 - drm_ioctl_t *func;
67403 + drm_ioctl_t func;
67404 unsigned int cmd_drv;
67405 -};
67406 +} __do_const;
67407
67408 /**
67409 * Creates a driver or general drm_ioctl_desc array entry for the given
67410 @@ -1014,7 +1017,7 @@ struct drm_info_list {
67411 int (*show)(struct seq_file*, void*); /** show callback */
67412 u32 driver_features; /**< Required driver features for this entry */
67413 void *data;
67414 -};
67415 +} __do_const;
67416
67417 /**
67418 * debugfs node structure. This structure represents a debugfs file.
67419 @@ -1087,7 +1090,7 @@ struct drm_device {
67420
67421 /** \name Usage Counters */
67422 /*@{ */
67423 - int open_count; /**< Outstanding files open */
67424 + local_t open_count; /**< Outstanding files open */
67425 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
67426 atomic_t vma_count; /**< Outstanding vma areas open */
67427 int buf_use; /**< Buffers in use -- cannot alloc */
67428 @@ -1098,7 +1101,7 @@ struct drm_device {
67429 /*@{ */
67430 unsigned long counters;
67431 enum drm_stat_type types[15];
67432 - atomic_t counts[15];
67433 + atomic_unchecked_t counts[15];
67434 /*@} */
67435
67436 struct list_head filelist;
67437 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
67438 index f43d556..94d9343 100644
67439 --- a/include/drm/drm_crtc_helper.h
67440 +++ b/include/drm/drm_crtc_helper.h
67441 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
67442 struct drm_connector *connector);
67443 /* disable encoder when not in use - more explicit than dpms off */
67444 void (*disable)(struct drm_encoder *encoder);
67445 -};
67446 +} __no_const;
67447
67448 /**
67449 * drm_connector_helper_funcs - helper operations for connectors
67450 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
67451 index 72dcbe8..8db58d7 100644
67452 --- a/include/drm/ttm/ttm_memory.h
67453 +++ b/include/drm/ttm/ttm_memory.h
67454 @@ -48,7 +48,7 @@
67455
67456 struct ttm_mem_shrink {
67457 int (*do_shrink) (struct ttm_mem_shrink *);
67458 -};
67459 +} __no_const;
67460
67461 /**
67462 * struct ttm_mem_global - Global memory accounting structure.
67463 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
67464 index 4b840e8..155d235 100644
67465 --- a/include/keys/asymmetric-subtype.h
67466 +++ b/include/keys/asymmetric-subtype.h
67467 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
67468 /* Verify the signature on a key of this subtype (optional) */
67469 int (*verify_signature)(const struct key *key,
67470 const struct public_key_signature *sig);
67471 -};
67472 +} __do_const;
67473
67474 /**
67475 * asymmetric_key_subtype - Get the subtype from an asymmetric key
67476 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
67477 index c1da539..1dcec55 100644
67478 --- a/include/linux/atmdev.h
67479 +++ b/include/linux/atmdev.h
67480 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
67481 #endif
67482
67483 struct k_atm_aal_stats {
67484 -#define __HANDLE_ITEM(i) atomic_t i
67485 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
67486 __AAL_STAT_ITEMS
67487 #undef __HANDLE_ITEM
67488 };
67489 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
67490 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
67491 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
67492 struct module *owner;
67493 -};
67494 +} __do_const ;
67495
67496 struct atmphy_ops {
67497 int (*start)(struct atm_dev *dev);
67498 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
67499 index c3a0914..ec5d48a 100644
67500 --- a/include/linux/binfmts.h
67501 +++ b/include/linux/binfmts.h
67502 @@ -73,8 +73,9 @@ struct linux_binfmt {
67503 int (*load_binary)(struct linux_binprm *);
67504 int (*load_shlib)(struct file *);
67505 int (*core_dump)(struct coredump_params *cprm);
67506 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
67507 unsigned long min_coredump; /* minimal dump size */
67508 -};
67509 +} __do_const;
67510
67511 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
67512
67513 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
67514 index 33f358f..7f2c27f 100644
67515 --- a/include/linux/blkdev.h
67516 +++ b/include/linux/blkdev.h
67517 @@ -1499,7 +1499,7 @@ struct block_device_operations {
67518 /* this callback is with swap_lock and sometimes page table lock held */
67519 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
67520 struct module *owner;
67521 -};
67522 +} __do_const;
67523
67524 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
67525 unsigned long);
67526 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
67527 index 7c2e030..b72475d 100644
67528 --- a/include/linux/blktrace_api.h
67529 +++ b/include/linux/blktrace_api.h
67530 @@ -23,7 +23,7 @@ struct blk_trace {
67531 struct dentry *dir;
67532 struct dentry *dropped_file;
67533 struct dentry *msg_file;
67534 - atomic_t dropped;
67535 + atomic_unchecked_t dropped;
67536 };
67537
67538 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
67539 diff --git a/include/linux/cache.h b/include/linux/cache.h
67540 index 4c57065..4307975 100644
67541 --- a/include/linux/cache.h
67542 +++ b/include/linux/cache.h
67543 @@ -16,6 +16,10 @@
67544 #define __read_mostly
67545 #endif
67546
67547 +#ifndef __read_only
67548 +#define __read_only __read_mostly
67549 +#endif
67550 +
67551 #ifndef ____cacheline_aligned
67552 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
67553 #endif
67554 diff --git a/include/linux/capability.h b/include/linux/capability.h
67555 index d9a4f7f4..19f77d6 100644
67556 --- a/include/linux/capability.h
67557 +++ b/include/linux/capability.h
67558 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
67559 extern bool nsown_capable(int cap);
67560 extern bool inode_capable(const struct inode *inode, int cap);
67561 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
67562 +extern bool capable_nolog(int cap);
67563 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
67564 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
67565
67566 /* audit system wants to get cap info from files as well */
67567 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
67568
67569 +extern int is_privileged_binary(const struct dentry *dentry);
67570 +
67571 #endif /* !_LINUX_CAPABILITY_H */
67572 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
67573 index 8609d57..86e4d79 100644
67574 --- a/include/linux/cdrom.h
67575 +++ b/include/linux/cdrom.h
67576 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
67577
67578 /* driver specifications */
67579 const int capability; /* capability flags */
67580 - int n_minors; /* number of active minor devices */
67581 /* handle uniform packets for scsi type devices (scsi,atapi) */
67582 int (*generic_packet) (struct cdrom_device_info *,
67583 struct packet_command *);
67584 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
67585 index 42e55de..1cd0e66 100644
67586 --- a/include/linux/cleancache.h
67587 +++ b/include/linux/cleancache.h
67588 @@ -31,7 +31,7 @@ struct cleancache_ops {
67589 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
67590 void (*invalidate_inode)(int, struct cleancache_filekey);
67591 void (*invalidate_fs)(int);
67592 -};
67593 +} __no_const;
67594
67595 extern struct cleancache_ops
67596 cleancache_register_ops(struct cleancache_ops *ops);
67597 diff --git a/include/linux/compat.h b/include/linux/compat.h
67598 index 377cd8c..2479845 100644
67599 --- a/include/linux/compat.h
67600 +++ b/include/linux/compat.h
67601 @@ -332,14 +332,14 @@ long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
67602 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
67603 int version, void __user *uptr);
67604 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
67605 - void __user *uptr);
67606 + void __user *uptr) __intentional_overflow(0);
67607 #else
67608 long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
67609 long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
67610 compat_ssize_t msgsz, int msgflg);
67611 long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
67612 compat_ssize_t msgsz, long msgtyp, int msgflg);
67613 -long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
67614 +long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
67615 #endif
67616 long compat_sys_msgctl(int first, int second, void __user *uptr);
67617 long compat_sys_shmctl(int first, int second, void __user *uptr);
67618 @@ -442,7 +442,7 @@ extern int compat_ptrace_request(struct task_struct *child,
67619 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
67620 compat_ulong_t addr, compat_ulong_t data);
67621 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
67622 - compat_long_t addr, compat_long_t data);
67623 + compat_ulong_t addr, compat_ulong_t data);
67624
67625 /*
67626 * epoll (fs/eventpoll.c) compat bits follow ...
67627 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
67628 index 68b162d..660f5f0 100644
67629 --- a/include/linux/compiler-gcc4.h
67630 +++ b/include/linux/compiler-gcc4.h
67631 @@ -39,9 +39,29 @@
67632 # define __compiletime_warning(message) __attribute__((warning(message)))
67633 # define __compiletime_error(message) __attribute__((error(message)))
67634 #endif /* __CHECKER__ */
67635 +
67636 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
67637 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
67638 +#define __bos0(ptr) __bos((ptr), 0)
67639 +#define __bos1(ptr) __bos((ptr), 1)
67640 #endif /* GCC_VERSION >= 40300 */
67641
67642 #if GCC_VERSION >= 40500
67643 +
67644 +#ifdef CONSTIFY_PLUGIN
67645 +#define __no_const __attribute__((no_const))
67646 +#define __do_const __attribute__((do_const))
67647 +#endif
67648 +
67649 +#ifdef SIZE_OVERFLOW_PLUGIN
67650 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
67651 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
67652 +#endif
67653 +
67654 +#ifdef LATENT_ENTROPY_PLUGIN
67655 +#define __latent_entropy __attribute__((latent_entropy))
67656 +#endif
67657 +
67658 /*
67659 * Mark a position in code as unreachable. This can be used to
67660 * suppress control flow warnings after asm blocks that transfer
67661 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
67662 index 10b8f23..5e0b083 100644
67663 --- a/include/linux/compiler.h
67664 +++ b/include/linux/compiler.h
67665 @@ -5,11 +5,14 @@
67666
67667 #ifdef __CHECKER__
67668 # define __user __attribute__((noderef, address_space(1)))
67669 +# define __force_user __force __user
67670 # define __kernel __attribute__((address_space(0)))
67671 +# define __force_kernel __force __kernel
67672 # define __safe __attribute__((safe))
67673 # define __force __attribute__((force))
67674 # define __nocast __attribute__((nocast))
67675 # define __iomem __attribute__((noderef, address_space(2)))
67676 +# define __force_iomem __force __iomem
67677 # define __must_hold(x) __attribute__((context(x,1,1)))
67678 # define __acquires(x) __attribute__((context(x,0,1)))
67679 # define __releases(x) __attribute__((context(x,1,0)))
67680 @@ -17,20 +20,37 @@
67681 # define __release(x) __context__(x,-1)
67682 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
67683 # define __percpu __attribute__((noderef, address_space(3)))
67684 +# define __force_percpu __force __percpu
67685 #ifdef CONFIG_SPARSE_RCU_POINTER
67686 # define __rcu __attribute__((noderef, address_space(4)))
67687 +# define __force_rcu __force __rcu
67688 #else
67689 # define __rcu
67690 +# define __force_rcu
67691 #endif
67692 extern void __chk_user_ptr(const volatile void __user *);
67693 extern void __chk_io_ptr(const volatile void __iomem *);
67694 #else
67695 -# define __user
67696 -# define __kernel
67697 +# ifdef CHECKER_PLUGIN
67698 +//# define __user
67699 +//# define __force_user
67700 +//# define __kernel
67701 +//# define __force_kernel
67702 +# else
67703 +# ifdef STRUCTLEAK_PLUGIN
67704 +# define __user __attribute__((user))
67705 +# else
67706 +# define __user
67707 +# endif
67708 +# define __force_user
67709 +# define __kernel
67710 +# define __force_kernel
67711 +# endif
67712 # define __safe
67713 # define __force
67714 # define __nocast
67715 # define __iomem
67716 +# define __force_iomem
67717 # define __chk_user_ptr(x) (void)0
67718 # define __chk_io_ptr(x) (void)0
67719 # define __builtin_warning(x, y...) (1)
67720 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
67721 # define __release(x) (void)0
67722 # define __cond_lock(x,c) (c)
67723 # define __percpu
67724 +# define __force_percpu
67725 # define __rcu
67726 +# define __force_rcu
67727 #endif
67728
67729 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
67730 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67731 # define __attribute_const__ /* unimplemented */
67732 #endif
67733
67734 +#ifndef __no_const
67735 +# define __no_const
67736 +#endif
67737 +
67738 +#ifndef __do_const
67739 +# define __do_const
67740 +#endif
67741 +
67742 +#ifndef __size_overflow
67743 +# define __size_overflow(...)
67744 +#endif
67745 +
67746 +#ifndef __intentional_overflow
67747 +# define __intentional_overflow(...)
67748 +#endif
67749 +
67750 +#ifndef __latent_entropy
67751 +# define __latent_entropy
67752 +#endif
67753 +
67754 /*
67755 * Tell gcc if a function is cold. The compiler will assume any path
67756 * directly leading to the call is unlikely.
67757 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67758 #define __cold
67759 #endif
67760
67761 +#ifndef __alloc_size
67762 +#define __alloc_size(...)
67763 +#endif
67764 +
67765 +#ifndef __bos
67766 +#define __bos(ptr, arg)
67767 +#endif
67768 +
67769 +#ifndef __bos0
67770 +#define __bos0(ptr)
67771 +#endif
67772 +
67773 +#ifndef __bos1
67774 +#define __bos1(ptr)
67775 +#endif
67776 +
67777 /* Simple shorthand for a section definition */
67778 #ifndef __section
67779 # define __section(S) __attribute__ ((__section__(#S)))
67780 @@ -349,6 +407,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67781 * use is to mediate communication between process-level code and irq/NMI
67782 * handlers, all running on the same CPU.
67783 */
67784 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
67785 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
67786 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
67787
67788 #endif /* __LINUX_COMPILER_H */
67789 diff --git a/include/linux/completion.h b/include/linux/completion.h
67790 index 33f0280..35c6568 100644
67791 --- a/include/linux/completion.h
67792 +++ b/include/linux/completion.h
67793 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
67794 extern void wait_for_completion(struct completion *);
67795 extern void wait_for_completion_io(struct completion *);
67796 extern int wait_for_completion_interruptible(struct completion *x);
67797 -extern int wait_for_completion_killable(struct completion *x);
67798 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
67799 extern unsigned long wait_for_completion_timeout(struct completion *x,
67800 unsigned long timeout);
67801 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
67802 unsigned long timeout);
67803 extern long wait_for_completion_interruptible_timeout(
67804 - struct completion *x, unsigned long timeout);
67805 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
67806 extern long wait_for_completion_killable_timeout(
67807 - struct completion *x, unsigned long timeout);
67808 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
67809 extern bool try_wait_for_completion(struct completion *x);
67810 extern bool completion_done(struct completion *x);
67811
67812 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
67813 index 34025df..d94bbbc 100644
67814 --- a/include/linux/configfs.h
67815 +++ b/include/linux/configfs.h
67816 @@ -125,7 +125,7 @@ struct configfs_attribute {
67817 const char *ca_name;
67818 struct module *ca_owner;
67819 umode_t ca_mode;
67820 -};
67821 +} __do_const;
67822
67823 /*
67824 * Users often need to create attribute structures for their configurable
67825 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
67826 index ce7a074..01ab8ac 100644
67827 --- a/include/linux/cpu.h
67828 +++ b/include/linux/cpu.h
67829 @@ -115,7 +115,7 @@ enum {
67830 /* Need to know about CPUs going up/down? */
67831 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
67832 #define cpu_notifier(fn, pri) { \
67833 - static struct notifier_block fn##_nb __cpuinitdata = \
67834 + static struct notifier_block fn##_nb = \
67835 { .notifier_call = fn, .priority = pri }; \
67836 register_cpu_notifier(&fn##_nb); \
67837 }
67838 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
67839 index a22944c..4e695fe 100644
67840 --- a/include/linux/cpufreq.h
67841 +++ b/include/linux/cpufreq.h
67842 @@ -252,7 +252,7 @@ struct cpufreq_driver {
67843 int (*suspend) (struct cpufreq_policy *policy);
67844 int (*resume) (struct cpufreq_policy *policy);
67845 struct freq_attr **attr;
67846 -};
67847 +} __do_const;
67848
67849 /* flags */
67850
67851 @@ -311,6 +311,7 @@ struct global_attr {
67852 ssize_t (*store)(struct kobject *a, struct attribute *b,
67853 const char *c, size_t count);
67854 };
67855 +typedef struct global_attr __no_const global_attr_no_const;
67856
67857 #define define_one_global_ro(_name) \
67858 static struct global_attr _name = \
67859 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
67860 index 480c14d..552896f 100644
67861 --- a/include/linux/cpuidle.h
67862 +++ b/include/linux/cpuidle.h
67863 @@ -52,7 +52,8 @@ struct cpuidle_state {
67864 int index);
67865
67866 int (*enter_dead) (struct cpuidle_device *dev, int index);
67867 -};
67868 +} __do_const;
67869 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
67870
67871 /* Idle State Flags */
67872 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
67873 @@ -194,7 +195,7 @@ struct cpuidle_governor {
67874 void (*reflect) (struct cpuidle_device *dev, int index);
67875
67876 struct module *owner;
67877 -};
67878 +} __do_const;
67879
67880 #ifdef CONFIG_CPU_IDLE
67881
67882 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
67883 index 0325602..5e9feff 100644
67884 --- a/include/linux/cpumask.h
67885 +++ b/include/linux/cpumask.h
67886 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
67887 }
67888
67889 /* Valid inputs for n are -1 and 0. */
67890 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67891 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
67892 {
67893 return n+1;
67894 }
67895
67896 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67897 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
67898 {
67899 return n+1;
67900 }
67901
67902 -static inline unsigned int cpumask_next_and(int n,
67903 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
67904 const struct cpumask *srcp,
67905 const struct cpumask *andp)
67906 {
67907 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
67908 *
67909 * Returns >= nr_cpu_ids if no further cpus set.
67910 */
67911 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67912 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
67913 {
67914 /* -1 is a legal arg here. */
67915 if (n != -1)
67916 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
67917 *
67918 * Returns >= nr_cpu_ids if no further cpus unset.
67919 */
67920 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67921 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
67922 {
67923 /* -1 is a legal arg here. */
67924 if (n != -1)
67925 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
67926 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
67927 }
67928
67929 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
67930 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
67931 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
67932
67933 /**
67934 diff --git a/include/linux/cred.h b/include/linux/cred.h
67935 index 04421e8..6bce4ef 100644
67936 --- a/include/linux/cred.h
67937 +++ b/include/linux/cred.h
67938 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
67939 static inline void validate_process_creds(void)
67940 {
67941 }
67942 +static inline void validate_task_creds(struct task_struct *task)
67943 +{
67944 +}
67945 #endif
67946
67947 /**
67948 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
67949 index b92eadf..b4ecdc1 100644
67950 --- a/include/linux/crypto.h
67951 +++ b/include/linux/crypto.h
67952 @@ -373,7 +373,7 @@ struct cipher_tfm {
67953 const u8 *key, unsigned int keylen);
67954 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
67955 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
67956 -};
67957 +} __no_const;
67958
67959 struct hash_tfm {
67960 int (*init)(struct hash_desc *desc);
67961 @@ -394,13 +394,13 @@ struct compress_tfm {
67962 int (*cot_decompress)(struct crypto_tfm *tfm,
67963 const u8 *src, unsigned int slen,
67964 u8 *dst, unsigned int *dlen);
67965 -};
67966 +} __no_const;
67967
67968 struct rng_tfm {
67969 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
67970 unsigned int dlen);
67971 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
67972 -};
67973 +} __no_const;
67974
67975 #define crt_ablkcipher crt_u.ablkcipher
67976 #define crt_aead crt_u.aead
67977 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
67978 index 8acfe31..6ffccd63 100644
67979 --- a/include/linux/ctype.h
67980 +++ b/include/linux/ctype.h
67981 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
67982 * Fast implementation of tolower() for internal usage. Do not use in your
67983 * code.
67984 */
67985 -static inline char _tolower(const char c)
67986 +static inline unsigned char _tolower(const unsigned char c)
67987 {
67988 return c | 0x20;
67989 }
67990 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
67991 index 7925bf0..d5143d2 100644
67992 --- a/include/linux/decompress/mm.h
67993 +++ b/include/linux/decompress/mm.h
67994 @@ -77,7 +77,7 @@ static void free(void *where)
67995 * warnings when not needed (indeed large_malloc / large_free are not
67996 * needed by inflate */
67997
67998 -#define malloc(a) kmalloc(a, GFP_KERNEL)
67999 +#define malloc(a) kmalloc((a), GFP_KERNEL)
68000 #define free(a) kfree(a)
68001
68002 #define large_malloc(a) vmalloc(a)
68003 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
68004 index fe8c447..bdc1f33 100644
68005 --- a/include/linux/devfreq.h
68006 +++ b/include/linux/devfreq.h
68007 @@ -114,7 +114,7 @@ struct devfreq_governor {
68008 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
68009 int (*event_handler)(struct devfreq *devfreq,
68010 unsigned int event, void *data);
68011 -};
68012 +} __do_const;
68013
68014 /**
68015 * struct devfreq - Device devfreq structure
68016 diff --git a/include/linux/device.h b/include/linux/device.h
68017 index 9d6464e..8a5cc92 100644
68018 --- a/include/linux/device.h
68019 +++ b/include/linux/device.h
68020 @@ -295,7 +295,7 @@ struct subsys_interface {
68021 struct list_head node;
68022 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
68023 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
68024 -};
68025 +} __do_const;
68026
68027 int subsys_interface_register(struct subsys_interface *sif);
68028 void subsys_interface_unregister(struct subsys_interface *sif);
68029 @@ -475,7 +475,7 @@ struct device_type {
68030 void (*release)(struct device *dev);
68031
68032 const struct dev_pm_ops *pm;
68033 -};
68034 +} __do_const;
68035
68036 /* interface for exporting device attributes */
68037 struct device_attribute {
68038 @@ -485,11 +485,12 @@ struct device_attribute {
68039 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
68040 const char *buf, size_t count);
68041 };
68042 +typedef struct device_attribute __no_const device_attribute_no_const;
68043
68044 struct dev_ext_attribute {
68045 struct device_attribute attr;
68046 void *var;
68047 -};
68048 +} __do_const;
68049
68050 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
68051 char *buf);
68052 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
68053 index 94af418..b1ca7a2 100644
68054 --- a/include/linux/dma-mapping.h
68055 +++ b/include/linux/dma-mapping.h
68056 @@ -54,7 +54,7 @@ struct dma_map_ops {
68057 u64 (*get_required_mask)(struct device *dev);
68058 #endif
68059 int is_phys;
68060 -};
68061 +} __do_const;
68062
68063 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
68064
68065 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
68066 index 91ac8da..a841318 100644
68067 --- a/include/linux/dmaengine.h
68068 +++ b/include/linux/dmaengine.h
68069 @@ -1034,9 +1034,9 @@ struct dma_pinned_list {
68070 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
68071 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
68072
68073 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68074 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68075 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
68076 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68077 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68078 struct dma_pinned_list *pinned_list, struct page *page,
68079 unsigned int offset, size_t len);
68080
68081 diff --git a/include/linux/efi.h b/include/linux/efi.h
68082 index 3d7df3d..301f024 100644
68083 --- a/include/linux/efi.h
68084 +++ b/include/linux/efi.h
68085 @@ -740,6 +740,7 @@ struct efivar_operations {
68086 efi_set_variable_t *set_variable;
68087 efi_query_variable_store_t *query_variable_store;
68088 };
68089 +typedef struct efivar_operations __no_const efivar_operations_no_const;
68090
68091 struct efivars {
68092 /*
68093 diff --git a/include/linux/elf.h b/include/linux/elf.h
68094 index 40a3c0e..4c45a38 100644
68095 --- a/include/linux/elf.h
68096 +++ b/include/linux/elf.h
68097 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
68098 #define elf_note elf32_note
68099 #define elf_addr_t Elf32_Off
68100 #define Elf_Half Elf32_Half
68101 +#define elf_dyn Elf32_Dyn
68102
68103 #else
68104
68105 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
68106 #define elf_note elf64_note
68107 #define elf_addr_t Elf64_Off
68108 #define Elf_Half Elf64_Half
68109 +#define elf_dyn Elf64_Dyn
68110
68111 #endif
68112
68113 diff --git a/include/linux/err.h b/include/linux/err.h
68114 index f2edce2..cc2082c 100644
68115 --- a/include/linux/err.h
68116 +++ b/include/linux/err.h
68117 @@ -19,12 +19,12 @@
68118
68119 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
68120
68121 -static inline void * __must_check ERR_PTR(long error)
68122 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
68123 {
68124 return (void *) error;
68125 }
68126
68127 -static inline long __must_check PTR_ERR(const void *ptr)
68128 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
68129 {
68130 return (long) ptr;
68131 }
68132 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
68133 index fcb51c8..bdafcf6 100644
68134 --- a/include/linux/extcon.h
68135 +++ b/include/linux/extcon.h
68136 @@ -134,7 +134,7 @@ struct extcon_dev {
68137 /* /sys/class/extcon/.../mutually_exclusive/... */
68138 struct attribute_group attr_g_muex;
68139 struct attribute **attrs_muex;
68140 - struct device_attribute *d_attrs_muex;
68141 + device_attribute_no_const *d_attrs_muex;
68142 };
68143
68144 /**
68145 diff --git a/include/linux/fb.h b/include/linux/fb.h
68146 index 58b9860..58e5516 100644
68147 --- a/include/linux/fb.h
68148 +++ b/include/linux/fb.h
68149 @@ -304,7 +304,7 @@ struct fb_ops {
68150 /* called at KDB enter and leave time to prepare the console */
68151 int (*fb_debug_enter)(struct fb_info *info);
68152 int (*fb_debug_leave)(struct fb_info *info);
68153 -};
68154 +} __do_const;
68155
68156 #ifdef CONFIG_FB_TILEBLITTING
68157 #define FB_TILE_CURSOR_NONE 0
68158 diff --git a/include/linux/filter.h b/include/linux/filter.h
68159 index c45eabc..baa0be5 100644
68160 --- a/include/linux/filter.h
68161 +++ b/include/linux/filter.h
68162 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
68163
68164 struct sk_buff;
68165 struct sock;
68166 +struct bpf_jit_work;
68167
68168 struct sk_filter
68169 {
68170 @@ -27,6 +28,9 @@ struct sk_filter
68171 unsigned int len; /* Number of filter blocks */
68172 unsigned int (*bpf_func)(const struct sk_buff *skb,
68173 const struct sock_filter *filter);
68174 +#ifdef CONFIG_BPF_JIT
68175 + struct bpf_jit_work *work;
68176 +#endif
68177 struct rcu_head rcu;
68178 struct sock_filter insns[0];
68179 };
68180 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
68181 index 3044254..9767f41 100644
68182 --- a/include/linux/frontswap.h
68183 +++ b/include/linux/frontswap.h
68184 @@ -11,7 +11,7 @@ struct frontswap_ops {
68185 int (*load)(unsigned, pgoff_t, struct page *);
68186 void (*invalidate_page)(unsigned, pgoff_t);
68187 void (*invalidate_area)(unsigned);
68188 -};
68189 +} __no_const;
68190
68191 extern bool frontswap_enabled;
68192 extern struct frontswap_ops
68193 diff --git a/include/linux/fs.h b/include/linux/fs.h
68194 index 2c28271..8d3d74c 100644
68195 --- a/include/linux/fs.h
68196 +++ b/include/linux/fs.h
68197 @@ -1541,7 +1541,8 @@ struct file_operations {
68198 long (*fallocate)(struct file *file, int mode, loff_t offset,
68199 loff_t len);
68200 int (*show_fdinfo)(struct seq_file *m, struct file *f);
68201 -};
68202 +} __do_const;
68203 +typedef struct file_operations __no_const file_operations_no_const;
68204
68205 struct inode_operations {
68206 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
68207 @@ -2672,4 +2673,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
68208 inode->i_flags |= S_NOSEC;
68209 }
68210
68211 +static inline bool is_sidechannel_device(const struct inode *inode)
68212 +{
68213 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
68214 + umode_t mode = inode->i_mode;
68215 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
68216 +#else
68217 + return false;
68218 +#endif
68219 +}
68220 +
68221 #endif /* _LINUX_FS_H */
68222 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
68223 index 2b93a9a..855d94a 100644
68224 --- a/include/linux/fs_struct.h
68225 +++ b/include/linux/fs_struct.h
68226 @@ -6,7 +6,7 @@
68227 #include <linux/seqlock.h>
68228
68229 struct fs_struct {
68230 - int users;
68231 + atomic_t users;
68232 spinlock_t lock;
68233 seqcount_t seq;
68234 int umask;
68235 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
68236 index 5dfa0aa..6acf322 100644
68237 --- a/include/linux/fscache-cache.h
68238 +++ b/include/linux/fscache-cache.h
68239 @@ -112,7 +112,7 @@ struct fscache_operation {
68240 fscache_operation_release_t release;
68241 };
68242
68243 -extern atomic_t fscache_op_debug_id;
68244 +extern atomic_unchecked_t fscache_op_debug_id;
68245 extern void fscache_op_work_func(struct work_struct *work);
68246
68247 extern void fscache_enqueue_operation(struct fscache_operation *);
68248 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
68249 INIT_WORK(&op->work, fscache_op_work_func);
68250 atomic_set(&op->usage, 1);
68251 op->state = FSCACHE_OP_ST_INITIALISED;
68252 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
68253 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
68254 op->processor = processor;
68255 op->release = release;
68256 INIT_LIST_HEAD(&op->pend_link);
68257 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
68258 index 7a08623..4c07b0f 100644
68259 --- a/include/linux/fscache.h
68260 +++ b/include/linux/fscache.h
68261 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
68262 * - this is mandatory for any object that may have data
68263 */
68264 void (*now_uncached)(void *cookie_netfs_data);
68265 -};
68266 +} __do_const;
68267
68268 /*
68269 * fscache cached network filesystem type
68270 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
68271 index a78680a..87bd73e 100644
68272 --- a/include/linux/fsnotify.h
68273 +++ b/include/linux/fsnotify.h
68274 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
68275 struct inode *inode = path->dentry->d_inode;
68276 __u32 mask = FS_ACCESS;
68277
68278 + if (is_sidechannel_device(inode))
68279 + return;
68280 +
68281 if (S_ISDIR(inode->i_mode))
68282 mask |= FS_ISDIR;
68283
68284 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
68285 struct inode *inode = path->dentry->d_inode;
68286 __u32 mask = FS_MODIFY;
68287
68288 + if (is_sidechannel_device(inode))
68289 + return;
68290 +
68291 if (S_ISDIR(inode->i_mode))
68292 mask |= FS_ISDIR;
68293
68294 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
68295 */
68296 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
68297 {
68298 - return kstrdup(name, GFP_KERNEL);
68299 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
68300 }
68301
68302 /*
68303 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
68304 index 13a54d0..c6ce2a7 100644
68305 --- a/include/linux/ftrace_event.h
68306 +++ b/include/linux/ftrace_event.h
68307 @@ -274,7 +274,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
68308 extern int trace_add_event_call(struct ftrace_event_call *call);
68309 extern void trace_remove_event_call(struct ftrace_event_call *call);
68310
68311 -#define is_signed_type(type) (((type)(-1)) < (type)0)
68312 +#define is_signed_type(type) (((type)(-1)) < (type)1)
68313
68314 int trace_set_clr_event(const char *system, const char *event, int set);
68315
68316 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
68317 index 9f3c275..911b591 100644
68318 --- a/include/linux/genhd.h
68319 +++ b/include/linux/genhd.h
68320 @@ -194,7 +194,7 @@ struct gendisk {
68321 struct kobject *slave_dir;
68322
68323 struct timer_rand_state *random;
68324 - atomic_t sync_io; /* RAID */
68325 + atomic_unchecked_t sync_io; /* RAID */
68326 struct disk_events *ev;
68327 #ifdef CONFIG_BLK_DEV_INTEGRITY
68328 struct blk_integrity *integrity;
68329 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
68330 index 023bc34..b02b46a 100644
68331 --- a/include/linux/genl_magic_func.h
68332 +++ b/include/linux/genl_magic_func.h
68333 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
68334 },
68335
68336 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
68337 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
68338 +static struct genl_ops ZZZ_genl_ops[] = {
68339 #include GENL_MAGIC_INCLUDE_FILE
68340 };
68341
68342 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
68343 index 0f615eb..5c3832f 100644
68344 --- a/include/linux/gfp.h
68345 +++ b/include/linux/gfp.h
68346 @@ -35,6 +35,13 @@ struct vm_area_struct;
68347 #define ___GFP_NO_KSWAPD 0x400000u
68348 #define ___GFP_OTHER_NODE 0x800000u
68349 #define ___GFP_WRITE 0x1000000u
68350 +
68351 +#ifdef CONFIG_PAX_USERCOPY_SLABS
68352 +#define ___GFP_USERCOPY 0x2000000u
68353 +#else
68354 +#define ___GFP_USERCOPY 0
68355 +#endif
68356 +
68357 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
68358
68359 /*
68360 @@ -92,6 +99,7 @@ struct vm_area_struct;
68361 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
68362 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
68363 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
68364 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
68365
68366 /*
68367 * This may seem redundant, but it's a way of annotating false positives vs.
68368 @@ -99,7 +107,7 @@ struct vm_area_struct;
68369 */
68370 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
68371
68372 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
68373 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
68374 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
68375
68376 /* This equals 0, but use constants in case they ever change */
68377 @@ -153,6 +161,8 @@ struct vm_area_struct;
68378 /* 4GB DMA on some platforms */
68379 #define GFP_DMA32 __GFP_DMA32
68380
68381 +#define GFP_USERCOPY __GFP_USERCOPY
68382 +
68383 /* Convert GFP flags to their corresponding migrate type */
68384 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
68385 {
68386 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
68387 new file mode 100644
68388 index 0000000..ebe6d72
68389 --- /dev/null
68390 +++ b/include/linux/gracl.h
68391 @@ -0,0 +1,319 @@
68392 +#ifndef GR_ACL_H
68393 +#define GR_ACL_H
68394 +
68395 +#include <linux/grdefs.h>
68396 +#include <linux/resource.h>
68397 +#include <linux/capability.h>
68398 +#include <linux/dcache.h>
68399 +#include <asm/resource.h>
68400 +
68401 +/* Major status information */
68402 +
68403 +#define GR_VERSION "grsecurity 2.9.1"
68404 +#define GRSECURITY_VERSION 0x2901
68405 +
68406 +enum {
68407 + GR_SHUTDOWN = 0,
68408 + GR_ENABLE = 1,
68409 + GR_SPROLE = 2,
68410 + GR_RELOAD = 3,
68411 + GR_SEGVMOD = 4,
68412 + GR_STATUS = 5,
68413 + GR_UNSPROLE = 6,
68414 + GR_PASSSET = 7,
68415 + GR_SPROLEPAM = 8,
68416 +};
68417 +
68418 +/* Password setup definitions
68419 + * kernel/grhash.c */
68420 +enum {
68421 + GR_PW_LEN = 128,
68422 + GR_SALT_LEN = 16,
68423 + GR_SHA_LEN = 32,
68424 +};
68425 +
68426 +enum {
68427 + GR_SPROLE_LEN = 64,
68428 +};
68429 +
68430 +enum {
68431 + GR_NO_GLOB = 0,
68432 + GR_REG_GLOB,
68433 + GR_CREATE_GLOB
68434 +};
68435 +
68436 +#define GR_NLIMITS 32
68437 +
68438 +/* Begin Data Structures */
68439 +
68440 +struct sprole_pw {
68441 + unsigned char *rolename;
68442 + unsigned char salt[GR_SALT_LEN];
68443 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
68444 +};
68445 +
68446 +struct name_entry {
68447 + __u32 key;
68448 + ino_t inode;
68449 + dev_t device;
68450 + char *name;
68451 + __u16 len;
68452 + __u8 deleted;
68453 + struct name_entry *prev;
68454 + struct name_entry *next;
68455 +};
68456 +
68457 +struct inodev_entry {
68458 + struct name_entry *nentry;
68459 + struct inodev_entry *prev;
68460 + struct inodev_entry *next;
68461 +};
68462 +
68463 +struct acl_role_db {
68464 + struct acl_role_label **r_hash;
68465 + __u32 r_size;
68466 +};
68467 +
68468 +struct inodev_db {
68469 + struct inodev_entry **i_hash;
68470 + __u32 i_size;
68471 +};
68472 +
68473 +struct name_db {
68474 + struct name_entry **n_hash;
68475 + __u32 n_size;
68476 +};
68477 +
68478 +struct crash_uid {
68479 + uid_t uid;
68480 + unsigned long expires;
68481 +};
68482 +
68483 +struct gr_hash_struct {
68484 + void **table;
68485 + void **nametable;
68486 + void *first;
68487 + __u32 table_size;
68488 + __u32 used_size;
68489 + int type;
68490 +};
68491 +
68492 +/* Userspace Grsecurity ACL data structures */
68493 +
68494 +struct acl_subject_label {
68495 + char *filename;
68496 + ino_t inode;
68497 + dev_t device;
68498 + __u32 mode;
68499 + kernel_cap_t cap_mask;
68500 + kernel_cap_t cap_lower;
68501 + kernel_cap_t cap_invert_audit;
68502 +
68503 + struct rlimit res[GR_NLIMITS];
68504 + __u32 resmask;
68505 +
68506 + __u8 user_trans_type;
68507 + __u8 group_trans_type;
68508 + uid_t *user_transitions;
68509 + gid_t *group_transitions;
68510 + __u16 user_trans_num;
68511 + __u16 group_trans_num;
68512 +
68513 + __u32 sock_families[2];
68514 + __u32 ip_proto[8];
68515 + __u32 ip_type;
68516 + struct acl_ip_label **ips;
68517 + __u32 ip_num;
68518 + __u32 inaddr_any_override;
68519 +
68520 + __u32 crashes;
68521 + unsigned long expires;
68522 +
68523 + struct acl_subject_label *parent_subject;
68524 + struct gr_hash_struct *hash;
68525 + struct acl_subject_label *prev;
68526 + struct acl_subject_label *next;
68527 +
68528 + struct acl_object_label **obj_hash;
68529 + __u32 obj_hash_size;
68530 + __u16 pax_flags;
68531 +};
68532 +
68533 +struct role_allowed_ip {
68534 + __u32 addr;
68535 + __u32 netmask;
68536 +
68537 + struct role_allowed_ip *prev;
68538 + struct role_allowed_ip *next;
68539 +};
68540 +
68541 +struct role_transition {
68542 + char *rolename;
68543 +
68544 + struct role_transition *prev;
68545 + struct role_transition *next;
68546 +};
68547 +
68548 +struct acl_role_label {
68549 + char *rolename;
68550 + uid_t uidgid;
68551 + __u16 roletype;
68552 +
68553 + __u16 auth_attempts;
68554 + unsigned long expires;
68555 +
68556 + struct acl_subject_label *root_label;
68557 + struct gr_hash_struct *hash;
68558 +
68559 + struct acl_role_label *prev;
68560 + struct acl_role_label *next;
68561 +
68562 + struct role_transition *transitions;
68563 + struct role_allowed_ip *allowed_ips;
68564 + uid_t *domain_children;
68565 + __u16 domain_child_num;
68566 +
68567 + umode_t umask;
68568 +
68569 + struct acl_subject_label **subj_hash;
68570 + __u32 subj_hash_size;
68571 +};
68572 +
68573 +struct user_acl_role_db {
68574 + struct acl_role_label **r_table;
68575 + __u32 num_pointers; /* Number of allocations to track */
68576 + __u32 num_roles; /* Number of roles */
68577 + __u32 num_domain_children; /* Number of domain children */
68578 + __u32 num_subjects; /* Number of subjects */
68579 + __u32 num_objects; /* Number of objects */
68580 +};
68581 +
68582 +struct acl_object_label {
68583 + char *filename;
68584 + ino_t inode;
68585 + dev_t device;
68586 + __u32 mode;
68587 +
68588 + struct acl_subject_label *nested;
68589 + struct acl_object_label *globbed;
68590 +
68591 + /* next two structures not used */
68592 +
68593 + struct acl_object_label *prev;
68594 + struct acl_object_label *next;
68595 +};
68596 +
68597 +struct acl_ip_label {
68598 + char *iface;
68599 + __u32 addr;
68600 + __u32 netmask;
68601 + __u16 low, high;
68602 + __u8 mode;
68603 + __u32 type;
68604 + __u32 proto[8];
68605 +
68606 + /* next two structures not used */
68607 +
68608 + struct acl_ip_label *prev;
68609 + struct acl_ip_label *next;
68610 +};
68611 +
68612 +struct gr_arg {
68613 + struct user_acl_role_db role_db;
68614 + unsigned char pw[GR_PW_LEN];
68615 + unsigned char salt[GR_SALT_LEN];
68616 + unsigned char sum[GR_SHA_LEN];
68617 + unsigned char sp_role[GR_SPROLE_LEN];
68618 + struct sprole_pw *sprole_pws;
68619 + dev_t segv_device;
68620 + ino_t segv_inode;
68621 + uid_t segv_uid;
68622 + __u16 num_sprole_pws;
68623 + __u16 mode;
68624 +};
68625 +
68626 +struct gr_arg_wrapper {
68627 + struct gr_arg *arg;
68628 + __u32 version;
68629 + __u32 size;
68630 +};
68631 +
68632 +struct subject_map {
68633 + struct acl_subject_label *user;
68634 + struct acl_subject_label *kernel;
68635 + struct subject_map *prev;
68636 + struct subject_map *next;
68637 +};
68638 +
68639 +struct acl_subj_map_db {
68640 + struct subject_map **s_hash;
68641 + __u32 s_size;
68642 +};
68643 +
68644 +/* End Data Structures Section */
68645 +
68646 +/* Hash functions generated by empirical testing by Brad Spengler
68647 + Makes good use of the low bits of the inode. Generally 0-1 times
68648 + in loop for successful match. 0-3 for unsuccessful match.
68649 + Shift/add algorithm with modulus of table size and an XOR*/
68650 +
68651 +static __inline__ unsigned int
68652 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
68653 +{
68654 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
68655 +}
68656 +
68657 + static __inline__ unsigned int
68658 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
68659 +{
68660 + return ((const unsigned long)userp % sz);
68661 +}
68662 +
68663 +static __inline__ unsigned int
68664 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
68665 +{
68666 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
68667 +}
68668 +
68669 +static __inline__ unsigned int
68670 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
68671 +{
68672 + return full_name_hash((const unsigned char *)name, len) % sz;
68673 +}
68674 +
68675 +#define FOR_EACH_ROLE_START(role) \
68676 + role = role_list; \
68677 + while (role) {
68678 +
68679 +#define FOR_EACH_ROLE_END(role) \
68680 + role = role->prev; \
68681 + }
68682 +
68683 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
68684 + subj = NULL; \
68685 + iter = 0; \
68686 + while (iter < role->subj_hash_size) { \
68687 + if (subj == NULL) \
68688 + subj = role->subj_hash[iter]; \
68689 + if (subj == NULL) { \
68690 + iter++; \
68691 + continue; \
68692 + }
68693 +
68694 +#define FOR_EACH_SUBJECT_END(subj,iter) \
68695 + subj = subj->next; \
68696 + if (subj == NULL) \
68697 + iter++; \
68698 + }
68699 +
68700 +
68701 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
68702 + subj = role->hash->first; \
68703 + while (subj != NULL) {
68704 +
68705 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
68706 + subj = subj->next; \
68707 + }
68708 +
68709 +#endif
68710 +
68711 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
68712 new file mode 100644
68713 index 0000000..323ecf2
68714 --- /dev/null
68715 +++ b/include/linux/gralloc.h
68716 @@ -0,0 +1,9 @@
68717 +#ifndef __GRALLOC_H
68718 +#define __GRALLOC_H
68719 +
68720 +void acl_free_all(void);
68721 +int acl_alloc_stack_init(unsigned long size);
68722 +void *acl_alloc(unsigned long len);
68723 +void *acl_alloc_num(unsigned long num, unsigned long len);
68724 +
68725 +#endif
68726 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
68727 new file mode 100644
68728 index 0000000..be66033
68729 --- /dev/null
68730 +++ b/include/linux/grdefs.h
68731 @@ -0,0 +1,140 @@
68732 +#ifndef GRDEFS_H
68733 +#define GRDEFS_H
68734 +
68735 +/* Begin grsecurity status declarations */
68736 +
68737 +enum {
68738 + GR_READY = 0x01,
68739 + GR_STATUS_INIT = 0x00 // disabled state
68740 +};
68741 +
68742 +/* Begin ACL declarations */
68743 +
68744 +/* Role flags */
68745 +
68746 +enum {
68747 + GR_ROLE_USER = 0x0001,
68748 + GR_ROLE_GROUP = 0x0002,
68749 + GR_ROLE_DEFAULT = 0x0004,
68750 + GR_ROLE_SPECIAL = 0x0008,
68751 + GR_ROLE_AUTH = 0x0010,
68752 + GR_ROLE_NOPW = 0x0020,
68753 + GR_ROLE_GOD = 0x0040,
68754 + GR_ROLE_LEARN = 0x0080,
68755 + GR_ROLE_TPE = 0x0100,
68756 + GR_ROLE_DOMAIN = 0x0200,
68757 + GR_ROLE_PAM = 0x0400,
68758 + GR_ROLE_PERSIST = 0x0800
68759 +};
68760 +
68761 +/* ACL Subject and Object mode flags */
68762 +enum {
68763 + GR_DELETED = 0x80000000
68764 +};
68765 +
68766 +/* ACL Object-only mode flags */
68767 +enum {
68768 + GR_READ = 0x00000001,
68769 + GR_APPEND = 0x00000002,
68770 + GR_WRITE = 0x00000004,
68771 + GR_EXEC = 0x00000008,
68772 + GR_FIND = 0x00000010,
68773 + GR_INHERIT = 0x00000020,
68774 + GR_SETID = 0x00000040,
68775 + GR_CREATE = 0x00000080,
68776 + GR_DELETE = 0x00000100,
68777 + GR_LINK = 0x00000200,
68778 + GR_AUDIT_READ = 0x00000400,
68779 + GR_AUDIT_APPEND = 0x00000800,
68780 + GR_AUDIT_WRITE = 0x00001000,
68781 + GR_AUDIT_EXEC = 0x00002000,
68782 + GR_AUDIT_FIND = 0x00004000,
68783 + GR_AUDIT_INHERIT= 0x00008000,
68784 + GR_AUDIT_SETID = 0x00010000,
68785 + GR_AUDIT_CREATE = 0x00020000,
68786 + GR_AUDIT_DELETE = 0x00040000,
68787 + GR_AUDIT_LINK = 0x00080000,
68788 + GR_PTRACERD = 0x00100000,
68789 + GR_NOPTRACE = 0x00200000,
68790 + GR_SUPPRESS = 0x00400000,
68791 + GR_NOLEARN = 0x00800000,
68792 + GR_INIT_TRANSFER= 0x01000000
68793 +};
68794 +
68795 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
68796 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
68797 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
68798 +
68799 +/* ACL subject-only mode flags */
68800 +enum {
68801 + GR_KILL = 0x00000001,
68802 + GR_VIEW = 0x00000002,
68803 + GR_PROTECTED = 0x00000004,
68804 + GR_LEARN = 0x00000008,
68805 + GR_OVERRIDE = 0x00000010,
68806 + /* just a placeholder, this mode is only used in userspace */
68807 + GR_DUMMY = 0x00000020,
68808 + GR_PROTSHM = 0x00000040,
68809 + GR_KILLPROC = 0x00000080,
68810 + GR_KILLIPPROC = 0x00000100,
68811 + /* just a placeholder, this mode is only used in userspace */
68812 + GR_NOTROJAN = 0x00000200,
68813 + GR_PROTPROCFD = 0x00000400,
68814 + GR_PROCACCT = 0x00000800,
68815 + GR_RELAXPTRACE = 0x00001000,
68816 + //GR_NESTED = 0x00002000,
68817 + GR_INHERITLEARN = 0x00004000,
68818 + GR_PROCFIND = 0x00008000,
68819 + GR_POVERRIDE = 0x00010000,
68820 + GR_KERNELAUTH = 0x00020000,
68821 + GR_ATSECURE = 0x00040000,
68822 + GR_SHMEXEC = 0x00080000
68823 +};
68824 +
68825 +enum {
68826 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
68827 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
68828 + GR_PAX_ENABLE_MPROTECT = 0x0004,
68829 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
68830 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
68831 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
68832 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
68833 + GR_PAX_DISABLE_MPROTECT = 0x0400,
68834 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
68835 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
68836 +};
68837 +
68838 +enum {
68839 + GR_ID_USER = 0x01,
68840 + GR_ID_GROUP = 0x02,
68841 +};
68842 +
68843 +enum {
68844 + GR_ID_ALLOW = 0x01,
68845 + GR_ID_DENY = 0x02,
68846 +};
68847 +
68848 +#define GR_CRASH_RES 31
68849 +#define GR_UIDTABLE_MAX 500
68850 +
68851 +/* begin resource learning section */
68852 +enum {
68853 + GR_RLIM_CPU_BUMP = 60,
68854 + GR_RLIM_FSIZE_BUMP = 50000,
68855 + GR_RLIM_DATA_BUMP = 10000,
68856 + GR_RLIM_STACK_BUMP = 1000,
68857 + GR_RLIM_CORE_BUMP = 10000,
68858 + GR_RLIM_RSS_BUMP = 500000,
68859 + GR_RLIM_NPROC_BUMP = 1,
68860 + GR_RLIM_NOFILE_BUMP = 5,
68861 + GR_RLIM_MEMLOCK_BUMP = 50000,
68862 + GR_RLIM_AS_BUMP = 500000,
68863 + GR_RLIM_LOCKS_BUMP = 2,
68864 + GR_RLIM_SIGPENDING_BUMP = 5,
68865 + GR_RLIM_MSGQUEUE_BUMP = 10000,
68866 + GR_RLIM_NICE_BUMP = 1,
68867 + GR_RLIM_RTPRIO_BUMP = 1,
68868 + GR_RLIM_RTTIME_BUMP = 1000000
68869 +};
68870 +
68871 +#endif
68872 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
68873 new file mode 100644
68874 index 0000000..5402bce
68875 --- /dev/null
68876 +++ b/include/linux/grinternal.h
68877 @@ -0,0 +1,215 @@
68878 +#ifndef __GRINTERNAL_H
68879 +#define __GRINTERNAL_H
68880 +
68881 +#ifdef CONFIG_GRKERNSEC
68882 +
68883 +#include <linux/fs.h>
68884 +#include <linux/mnt_namespace.h>
68885 +#include <linux/nsproxy.h>
68886 +#include <linux/gracl.h>
68887 +#include <linux/grdefs.h>
68888 +#include <linux/grmsg.h>
68889 +
68890 +void gr_add_learn_entry(const char *fmt, ...)
68891 + __attribute__ ((format (printf, 1, 2)));
68892 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
68893 + const struct vfsmount *mnt);
68894 +__u32 gr_check_create(const struct dentry *new_dentry,
68895 + const struct dentry *parent,
68896 + const struct vfsmount *mnt, const __u32 mode);
68897 +int gr_check_protected_task(const struct task_struct *task);
68898 +__u32 to_gr_audit(const __u32 reqmode);
68899 +int gr_set_acls(const int type);
68900 +int gr_apply_subject_to_task(struct task_struct *task);
68901 +int gr_acl_is_enabled(void);
68902 +char gr_roletype_to_char(void);
68903 +
68904 +void gr_handle_alertkill(struct task_struct *task);
68905 +char *gr_to_filename(const struct dentry *dentry,
68906 + const struct vfsmount *mnt);
68907 +char *gr_to_filename1(const struct dentry *dentry,
68908 + const struct vfsmount *mnt);
68909 +char *gr_to_filename2(const struct dentry *dentry,
68910 + const struct vfsmount *mnt);
68911 +char *gr_to_filename3(const struct dentry *dentry,
68912 + const struct vfsmount *mnt);
68913 +
68914 +extern int grsec_enable_ptrace_readexec;
68915 +extern int grsec_enable_harden_ptrace;
68916 +extern int grsec_enable_link;
68917 +extern int grsec_enable_fifo;
68918 +extern int grsec_enable_execve;
68919 +extern int grsec_enable_shm;
68920 +extern int grsec_enable_execlog;
68921 +extern int grsec_enable_signal;
68922 +extern int grsec_enable_audit_ptrace;
68923 +extern int grsec_enable_forkfail;
68924 +extern int grsec_enable_time;
68925 +extern int grsec_enable_rofs;
68926 +extern int grsec_enable_chroot_shmat;
68927 +extern int grsec_enable_chroot_mount;
68928 +extern int grsec_enable_chroot_double;
68929 +extern int grsec_enable_chroot_pivot;
68930 +extern int grsec_enable_chroot_chdir;
68931 +extern int grsec_enable_chroot_chmod;
68932 +extern int grsec_enable_chroot_mknod;
68933 +extern int grsec_enable_chroot_fchdir;
68934 +extern int grsec_enable_chroot_nice;
68935 +extern int grsec_enable_chroot_execlog;
68936 +extern int grsec_enable_chroot_caps;
68937 +extern int grsec_enable_chroot_sysctl;
68938 +extern int grsec_enable_chroot_unix;
68939 +extern int grsec_enable_symlinkown;
68940 +extern kgid_t grsec_symlinkown_gid;
68941 +extern int grsec_enable_tpe;
68942 +extern kgid_t grsec_tpe_gid;
68943 +extern int grsec_enable_tpe_all;
68944 +extern int grsec_enable_tpe_invert;
68945 +extern int grsec_enable_socket_all;
68946 +extern kgid_t grsec_socket_all_gid;
68947 +extern int grsec_enable_socket_client;
68948 +extern kgid_t grsec_socket_client_gid;
68949 +extern int grsec_enable_socket_server;
68950 +extern kgid_t grsec_socket_server_gid;
68951 +extern kgid_t grsec_audit_gid;
68952 +extern int grsec_enable_group;
68953 +extern int grsec_enable_audit_textrel;
68954 +extern int grsec_enable_log_rwxmaps;
68955 +extern int grsec_enable_mount;
68956 +extern int grsec_enable_chdir;
68957 +extern int grsec_resource_logging;
68958 +extern int grsec_enable_blackhole;
68959 +extern int grsec_lastack_retries;
68960 +extern int grsec_enable_brute;
68961 +extern int grsec_lock;
68962 +
68963 +extern spinlock_t grsec_alert_lock;
68964 +extern unsigned long grsec_alert_wtime;
68965 +extern unsigned long grsec_alert_fyet;
68966 +
68967 +extern spinlock_t grsec_audit_lock;
68968 +
68969 +extern rwlock_t grsec_exec_file_lock;
68970 +
68971 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
68972 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
68973 + (tsk)->exec_file->f_path.mnt) : "/")
68974 +
68975 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
68976 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
68977 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
68978 +
68979 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
68980 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
68981 + (tsk)->exec_file->f_path.mnt) : "/")
68982 +
68983 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
68984 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
68985 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
68986 +
68987 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
68988 +
68989 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
68990 +
68991 +#define GR_CHROOT_CAPS {{ \
68992 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
68993 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
68994 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
68995 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
68996 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
68997 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
68998 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
68999 +
69000 +#define security_learn(normal_msg,args...) \
69001 +({ \
69002 + read_lock(&grsec_exec_file_lock); \
69003 + gr_add_learn_entry(normal_msg "\n", ## args); \
69004 + read_unlock(&grsec_exec_file_lock); \
69005 +})
69006 +
69007 +enum {
69008 + GR_DO_AUDIT,
69009 + GR_DONT_AUDIT,
69010 + /* used for non-audit messages that we shouldn't kill the task on */
69011 + GR_DONT_AUDIT_GOOD
69012 +};
69013 +
69014 +enum {
69015 + GR_TTYSNIFF,
69016 + GR_RBAC,
69017 + GR_RBAC_STR,
69018 + GR_STR_RBAC,
69019 + GR_RBAC_MODE2,
69020 + GR_RBAC_MODE3,
69021 + GR_FILENAME,
69022 + GR_SYSCTL_HIDDEN,
69023 + GR_NOARGS,
69024 + GR_ONE_INT,
69025 + GR_ONE_INT_TWO_STR,
69026 + GR_ONE_STR,
69027 + GR_STR_INT,
69028 + GR_TWO_STR_INT,
69029 + GR_TWO_INT,
69030 + GR_TWO_U64,
69031 + GR_THREE_INT,
69032 + GR_FIVE_INT_TWO_STR,
69033 + GR_TWO_STR,
69034 + GR_THREE_STR,
69035 + GR_FOUR_STR,
69036 + GR_STR_FILENAME,
69037 + GR_FILENAME_STR,
69038 + GR_FILENAME_TWO_INT,
69039 + GR_FILENAME_TWO_INT_STR,
69040 + GR_TEXTREL,
69041 + GR_PTRACE,
69042 + GR_RESOURCE,
69043 + GR_CAP,
69044 + GR_SIG,
69045 + GR_SIG2,
69046 + GR_CRASH1,
69047 + GR_CRASH2,
69048 + GR_PSACCT,
69049 + GR_RWXMAP
69050 +};
69051 +
69052 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
69053 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
69054 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
69055 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
69056 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
69057 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
69058 +#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)
69059 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
69060 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
69061 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
69062 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
69063 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
69064 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
69065 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
69066 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
69067 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
69068 +#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)
69069 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
69070 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
69071 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
69072 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
69073 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
69074 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
69075 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
69076 +#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)
69077 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
69078 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
69079 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
69080 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
69081 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
69082 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
69083 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
69084 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
69085 +#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)
69086 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
69087 +
69088 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
69089 +
69090 +#endif
69091 +
69092 +#endif
69093 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
69094 new file mode 100644
69095 index 0000000..2bd4c8d
69096 --- /dev/null
69097 +++ b/include/linux/grmsg.h
69098 @@ -0,0 +1,111 @@
69099 +#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"
69100 +#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"
69101 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
69102 +#define GR_STOPMOD_MSG "denied modification of module state by "
69103 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
69104 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
69105 +#define GR_IOPERM_MSG "denied use of ioperm() by "
69106 +#define GR_IOPL_MSG "denied use of iopl() by "
69107 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
69108 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
69109 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
69110 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
69111 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
69112 +#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"
69113 +#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"
69114 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
69115 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
69116 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
69117 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
69118 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
69119 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
69120 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
69121 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
69122 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
69123 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
69124 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
69125 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
69126 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
69127 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
69128 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
69129 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
69130 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
69131 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
69132 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
69133 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
69134 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
69135 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
69136 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
69137 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
69138 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
69139 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
69140 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
69141 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
69142 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
69143 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
69144 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
69145 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
69146 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
69147 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
69148 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
69149 +#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"
69150 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
69151 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
69152 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
69153 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
69154 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
69155 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
69156 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
69157 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
69158 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
69159 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
69160 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
69161 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
69162 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
69163 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
69164 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
69165 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
69166 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
69167 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
69168 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
69169 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
69170 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
69171 +#define GR_NICE_CHROOT_MSG "denied priority change by "
69172 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
69173 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
69174 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
69175 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
69176 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
69177 +#define GR_TIME_MSG "time set by "
69178 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
69179 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
69180 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
69181 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
69182 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
69183 +#define GR_BIND_MSG "denied bind() by "
69184 +#define GR_CONNECT_MSG "denied connect() by "
69185 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
69186 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
69187 +#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"
69188 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
69189 +#define GR_CAP_ACL_MSG "use of %s denied for "
69190 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
69191 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
69192 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
69193 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
69194 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
69195 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
69196 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
69197 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
69198 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
69199 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
69200 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
69201 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
69202 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
69203 +#define GR_VM86_MSG "denied use of vm86 by "
69204 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
69205 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
69206 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
69207 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
69208 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
69209 +#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 "
69210 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
69211 new file mode 100644
69212 index 0000000..d7ef0ac
69213 --- /dev/null
69214 +++ b/include/linux/grsecurity.h
69215 @@ -0,0 +1,242 @@
69216 +#ifndef GR_SECURITY_H
69217 +#define GR_SECURITY_H
69218 +#include <linux/fs.h>
69219 +#include <linux/fs_struct.h>
69220 +#include <linux/binfmts.h>
69221 +#include <linux/gracl.h>
69222 +
69223 +/* notify of brain-dead configs */
69224 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
69225 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
69226 +#endif
69227 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
69228 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
69229 +#endif
69230 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
69231 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
69232 +#endif
69233 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
69234 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
69235 +#endif
69236 +
69237 +void gr_handle_brute_attach(unsigned long mm_flags);
69238 +void gr_handle_brute_check(void);
69239 +void gr_handle_kernel_exploit(void);
69240 +int gr_process_user_ban(void);
69241 +
69242 +char gr_roletype_to_char(void);
69243 +
69244 +int gr_acl_enable_at_secure(void);
69245 +
69246 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
69247 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
69248 +
69249 +void gr_del_task_from_ip_table(struct task_struct *p);
69250 +
69251 +int gr_pid_is_chrooted(struct task_struct *p);
69252 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
69253 +int gr_handle_chroot_nice(void);
69254 +int gr_handle_chroot_sysctl(const int op);
69255 +int gr_handle_chroot_setpriority(struct task_struct *p,
69256 + const int niceval);
69257 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
69258 +int gr_handle_chroot_chroot(const struct dentry *dentry,
69259 + const struct vfsmount *mnt);
69260 +void gr_handle_chroot_chdir(const struct path *path);
69261 +int gr_handle_chroot_chmod(const struct dentry *dentry,
69262 + const struct vfsmount *mnt, const int mode);
69263 +int gr_handle_chroot_mknod(const struct dentry *dentry,
69264 + const struct vfsmount *mnt, const int mode);
69265 +int gr_handle_chroot_mount(const struct dentry *dentry,
69266 + const struct vfsmount *mnt,
69267 + const char *dev_name);
69268 +int gr_handle_chroot_pivot(void);
69269 +int gr_handle_chroot_unix(const pid_t pid);
69270 +
69271 +int gr_handle_rawio(const struct inode *inode);
69272 +
69273 +void gr_handle_ioperm(void);
69274 +void gr_handle_iopl(void);
69275 +
69276 +umode_t gr_acl_umask(void);
69277 +
69278 +int gr_tpe_allow(const struct file *file);
69279 +
69280 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
69281 +void gr_clear_chroot_entries(struct task_struct *task);
69282 +
69283 +void gr_log_forkfail(const int retval);
69284 +void gr_log_timechange(void);
69285 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
69286 +void gr_log_chdir(const struct dentry *dentry,
69287 + const struct vfsmount *mnt);
69288 +void gr_log_chroot_exec(const struct dentry *dentry,
69289 + const struct vfsmount *mnt);
69290 +void gr_log_remount(const char *devname, const int retval);
69291 +void gr_log_unmount(const char *devname, const int retval);
69292 +void gr_log_mount(const char *from, const char *to, const int retval);
69293 +void gr_log_textrel(struct vm_area_struct *vma);
69294 +void gr_log_rwxmmap(struct file *file);
69295 +void gr_log_rwxmprotect(struct file *file);
69296 +
69297 +int gr_handle_follow_link(const struct inode *parent,
69298 + const struct inode *inode,
69299 + const struct dentry *dentry,
69300 + const struct vfsmount *mnt);
69301 +int gr_handle_fifo(const struct dentry *dentry,
69302 + const struct vfsmount *mnt,
69303 + const struct dentry *dir, const int flag,
69304 + const int acc_mode);
69305 +int gr_handle_hardlink(const struct dentry *dentry,
69306 + const struct vfsmount *mnt,
69307 + struct inode *inode,
69308 + const int mode, const struct filename *to);
69309 +
69310 +int gr_is_capable(const int cap);
69311 +int gr_is_capable_nolog(const int cap);
69312 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69313 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
69314 +
69315 +void gr_copy_label(struct task_struct *tsk);
69316 +void gr_handle_crash(struct task_struct *task, const int sig);
69317 +int gr_handle_signal(const struct task_struct *p, const int sig);
69318 +int gr_check_crash_uid(const kuid_t uid);
69319 +int gr_check_protected_task(const struct task_struct *task);
69320 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
69321 +int gr_acl_handle_mmap(const struct file *file,
69322 + const unsigned long prot);
69323 +int gr_acl_handle_mprotect(const struct file *file,
69324 + const unsigned long prot);
69325 +int gr_check_hidden_task(const struct task_struct *tsk);
69326 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
69327 + const struct vfsmount *mnt);
69328 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
69329 + const struct vfsmount *mnt);
69330 +__u32 gr_acl_handle_access(const struct dentry *dentry,
69331 + const struct vfsmount *mnt, const int fmode);
69332 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
69333 + const struct vfsmount *mnt, umode_t *mode);
69334 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
69335 + const struct vfsmount *mnt);
69336 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
69337 + const struct vfsmount *mnt);
69338 +int gr_handle_ptrace(struct task_struct *task, const long request);
69339 +int gr_handle_proc_ptrace(struct task_struct *task);
69340 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
69341 + const struct vfsmount *mnt);
69342 +int gr_check_crash_exec(const struct file *filp);
69343 +int gr_acl_is_enabled(void);
69344 +void gr_set_kernel_label(struct task_struct *task);
69345 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
69346 + const kgid_t gid);
69347 +int gr_set_proc_label(const struct dentry *dentry,
69348 + const struct vfsmount *mnt,
69349 + const int unsafe_flags);
69350 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
69351 + const struct vfsmount *mnt);
69352 +__u32 gr_acl_handle_open(const struct dentry *dentry,
69353 + const struct vfsmount *mnt, int acc_mode);
69354 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
69355 + const struct dentry *p_dentry,
69356 + const struct vfsmount *p_mnt,
69357 + int open_flags, int acc_mode, const int imode);
69358 +void gr_handle_create(const struct dentry *dentry,
69359 + const struct vfsmount *mnt);
69360 +void gr_handle_proc_create(const struct dentry *dentry,
69361 + const struct inode *inode);
69362 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
69363 + const struct dentry *parent_dentry,
69364 + const struct vfsmount *parent_mnt,
69365 + const int mode);
69366 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
69367 + const struct dentry *parent_dentry,
69368 + const struct vfsmount *parent_mnt);
69369 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
69370 + const struct vfsmount *mnt);
69371 +void gr_handle_delete(const ino_t ino, const dev_t dev);
69372 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
69373 + const struct vfsmount *mnt);
69374 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
69375 + const struct dentry *parent_dentry,
69376 + const struct vfsmount *parent_mnt,
69377 + const struct filename *from);
69378 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
69379 + const struct dentry *parent_dentry,
69380 + const struct vfsmount *parent_mnt,
69381 + const struct dentry *old_dentry,
69382 + const struct vfsmount *old_mnt, const struct filename *to);
69383 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
69384 +int gr_acl_handle_rename(struct dentry *new_dentry,
69385 + struct dentry *parent_dentry,
69386 + const struct vfsmount *parent_mnt,
69387 + struct dentry *old_dentry,
69388 + struct inode *old_parent_inode,
69389 + struct vfsmount *old_mnt, const struct filename *newname);
69390 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69391 + struct dentry *old_dentry,
69392 + struct dentry *new_dentry,
69393 + struct vfsmount *mnt, const __u8 replace);
69394 +__u32 gr_check_link(const struct dentry *new_dentry,
69395 + const struct dentry *parent_dentry,
69396 + const struct vfsmount *parent_mnt,
69397 + const struct dentry *old_dentry,
69398 + const struct vfsmount *old_mnt);
69399 +int gr_acl_handle_filldir(const struct file *file, const char *name,
69400 + const unsigned int namelen, const ino_t ino);
69401 +
69402 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
69403 + const struct vfsmount *mnt);
69404 +void gr_acl_handle_exit(void);
69405 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
69406 +int gr_acl_handle_procpidmem(const struct task_struct *task);
69407 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
69408 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
69409 +void gr_audit_ptrace(struct task_struct *task);
69410 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
69411 +void gr_put_exec_file(struct task_struct *task);
69412 +
69413 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
69414 +
69415 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
69416 +extern void gr_learn_resource(const struct task_struct *task, const int res,
69417 + const unsigned long wanted, const int gt);
69418 +#else
69419 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
69420 + const unsigned long wanted, const int gt)
69421 +{
69422 +}
69423 +#endif
69424 +
69425 +#ifdef CONFIG_GRKERNSEC_RESLOG
69426 +extern void gr_log_resource(const struct task_struct *task, const int res,
69427 + const unsigned long wanted, const int gt);
69428 +#else
69429 +static inline void gr_log_resource(const struct task_struct *task, const int res,
69430 + const unsigned long wanted, const int gt)
69431 +{
69432 +}
69433 +#endif
69434 +
69435 +#ifdef CONFIG_GRKERNSEC
69436 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
69437 +void gr_handle_vm86(void);
69438 +void gr_handle_mem_readwrite(u64 from, u64 to);
69439 +
69440 +void gr_log_badprocpid(const char *entry);
69441 +
69442 +extern int grsec_enable_dmesg;
69443 +extern int grsec_disable_privio;
69444 +
69445 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
69446 +extern kgid_t grsec_proc_gid;
69447 +#endif
69448 +
69449 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69450 +extern int grsec_enable_chroot_findtask;
69451 +#endif
69452 +#ifdef CONFIG_GRKERNSEC_SETXID
69453 +extern int grsec_enable_setxid;
69454 +#endif
69455 +#endif
69456 +
69457 +#endif
69458 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
69459 new file mode 100644
69460 index 0000000..e7ffaaf
69461 --- /dev/null
69462 +++ b/include/linux/grsock.h
69463 @@ -0,0 +1,19 @@
69464 +#ifndef __GRSOCK_H
69465 +#define __GRSOCK_H
69466 +
69467 +extern void gr_attach_curr_ip(const struct sock *sk);
69468 +extern int gr_handle_sock_all(const int family, const int type,
69469 + const int protocol);
69470 +extern int gr_handle_sock_server(const struct sockaddr *sck);
69471 +extern int gr_handle_sock_server_other(const struct sock *sck);
69472 +extern int gr_handle_sock_client(const struct sockaddr *sck);
69473 +extern int gr_search_connect(struct socket * sock,
69474 + struct sockaddr_in * addr);
69475 +extern int gr_search_bind(struct socket * sock,
69476 + struct sockaddr_in * addr);
69477 +extern int gr_search_listen(struct socket * sock);
69478 +extern int gr_search_accept(struct socket * sock);
69479 +extern int gr_search_socket(const int domain, const int type,
69480 + const int protocol);
69481 +
69482 +#endif
69483 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
69484 index 7fb31da..08b5114 100644
69485 --- a/include/linux/highmem.h
69486 +++ b/include/linux/highmem.h
69487 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
69488 kunmap_atomic(kaddr);
69489 }
69490
69491 +static inline void sanitize_highpage(struct page *page)
69492 +{
69493 + void *kaddr;
69494 + unsigned long flags;
69495 +
69496 + local_irq_save(flags);
69497 + kaddr = kmap_atomic(page);
69498 + clear_page(kaddr);
69499 + kunmap_atomic(kaddr);
69500 + local_irq_restore(flags);
69501 +}
69502 +
69503 static inline void zero_user_segments(struct page *page,
69504 unsigned start1, unsigned end1,
69505 unsigned start2, unsigned end2)
69506 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
69507 index 1c7b89a..7f52502 100644
69508 --- a/include/linux/hwmon-sysfs.h
69509 +++ b/include/linux/hwmon-sysfs.h
69510 @@ -25,7 +25,8 @@
69511 struct sensor_device_attribute{
69512 struct device_attribute dev_attr;
69513 int index;
69514 -};
69515 +} __do_const;
69516 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
69517 #define to_sensor_dev_attr(_dev_attr) \
69518 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
69519
69520 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
69521 struct device_attribute dev_attr;
69522 u8 index;
69523 u8 nr;
69524 -};
69525 +} __do_const;
69526 #define to_sensor_dev_attr_2(_dev_attr) \
69527 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
69528
69529 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
69530 index d0c4db7..61b3577 100644
69531 --- a/include/linux/i2c.h
69532 +++ b/include/linux/i2c.h
69533 @@ -369,6 +369,7 @@ struct i2c_algorithm {
69534 /* To determine what the adapter supports */
69535 u32 (*functionality) (struct i2c_adapter *);
69536 };
69537 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
69538
69539 /*
69540 * i2c_adapter is the structure used to identify a physical i2c bus along
69541 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
69542 index d23c3c2..eb63c81 100644
69543 --- a/include/linux/i2o.h
69544 +++ b/include/linux/i2o.h
69545 @@ -565,7 +565,7 @@ struct i2o_controller {
69546 struct i2o_device *exec; /* Executive */
69547 #if BITS_PER_LONG == 64
69548 spinlock_t context_list_lock; /* lock for context_list */
69549 - atomic_t context_list_counter; /* needed for unique contexts */
69550 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
69551 struct list_head context_list; /* list of context id's
69552 and pointers */
69553 #endif
69554 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
69555 index aff7ad8..3942bbd 100644
69556 --- a/include/linux/if_pppox.h
69557 +++ b/include/linux/if_pppox.h
69558 @@ -76,7 +76,7 @@ struct pppox_proto {
69559 int (*ioctl)(struct socket *sock, unsigned int cmd,
69560 unsigned long arg);
69561 struct module *owner;
69562 -};
69563 +} __do_const;
69564
69565 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
69566 extern void unregister_pppox_proto(int proto_num);
69567 diff --git a/include/linux/init.h b/include/linux/init.h
69568 index 8618147..0821126 100644
69569 --- a/include/linux/init.h
69570 +++ b/include/linux/init.h
69571 @@ -39,9 +39,36 @@
69572 * Also note, that this data cannot be "const".
69573 */
69574
69575 +#ifdef MODULE
69576 +#define add_init_latent_entropy
69577 +#define add_devinit_latent_entropy
69578 +#define add_cpuinit_latent_entropy
69579 +#define add_meminit_latent_entropy
69580 +#else
69581 +#define add_init_latent_entropy __latent_entropy
69582 +
69583 +#ifdef CONFIG_HOTPLUG
69584 +#define add_devinit_latent_entropy
69585 +#else
69586 +#define add_devinit_latent_entropy __latent_entropy
69587 +#endif
69588 +
69589 +#ifdef CONFIG_HOTPLUG_CPU
69590 +#define add_cpuinit_latent_entropy
69591 +#else
69592 +#define add_cpuinit_latent_entropy __latent_entropy
69593 +#endif
69594 +
69595 +#ifdef CONFIG_MEMORY_HOTPLUG
69596 +#define add_meminit_latent_entropy
69597 +#else
69598 +#define add_meminit_latent_entropy __latent_entropy
69599 +#endif
69600 +#endif
69601 +
69602 /* These are for everybody (although not all archs will actually
69603 discard it in modules) */
69604 -#define __init __section(.init.text) __cold notrace
69605 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
69606 #define __initdata __section(.init.data)
69607 #define __initconst __constsection(.init.rodata)
69608 #define __exitdata __section(.exit.data)
69609 @@ -94,7 +121,7 @@
69610 #define __exit __section(.exit.text) __exitused __cold notrace
69611
69612 /* Used for HOTPLUG_CPU */
69613 -#define __cpuinit __section(.cpuinit.text) __cold notrace
69614 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
69615 #define __cpuinitdata __section(.cpuinit.data)
69616 #define __cpuinitconst __constsection(.cpuinit.rodata)
69617 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
69618 @@ -102,7 +129,7 @@
69619 #define __cpuexitconst __constsection(.cpuexit.rodata)
69620
69621 /* Used for MEMORY_HOTPLUG */
69622 -#define __meminit __section(.meminit.text) __cold notrace
69623 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
69624 #define __meminitdata __section(.meminit.data)
69625 #define __meminitconst __constsection(.meminit.rodata)
69626 #define __memexit __section(.memexit.text) __exitused __cold notrace
69627 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
69628 index 5cd0f09..c9f67cc 100644
69629 --- a/include/linux/init_task.h
69630 +++ b/include/linux/init_task.h
69631 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
69632
69633 #define INIT_TASK_COMM "swapper"
69634
69635 +#ifdef CONFIG_X86
69636 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
69637 +#else
69638 +#define INIT_TASK_THREAD_INFO
69639 +#endif
69640 +
69641 /*
69642 * INIT_TASK is used to set up the first task table, touch at
69643 * your own risk!. Base=0, limit=0x1fffff (=2MB)
69644 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
69645 RCU_POINTER_INITIALIZER(cred, &init_cred), \
69646 .comm = INIT_TASK_COMM, \
69647 .thread = INIT_THREAD, \
69648 + INIT_TASK_THREAD_INFO \
69649 .fs = &init_fs, \
69650 .files = &init_files, \
69651 .signal = &init_signals, \
69652 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
69653 index 5fa5afe..ac55b25 100644
69654 --- a/include/linux/interrupt.h
69655 +++ b/include/linux/interrupt.h
69656 @@ -430,7 +430,7 @@ enum
69657 /* map softirq index to softirq name. update 'softirq_to_name' in
69658 * kernel/softirq.c when adding a new softirq.
69659 */
69660 -extern char *softirq_to_name[NR_SOFTIRQS];
69661 +extern const char * const softirq_to_name[NR_SOFTIRQS];
69662
69663 /* softirq mask and active fields moved to irq_cpustat_t in
69664 * asm/hardirq.h to get better cache usage. KAO
69665 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
69666
69667 struct softirq_action
69668 {
69669 - void (*action)(struct softirq_action *);
69670 -};
69671 + void (*action)(void);
69672 +} __no_const;
69673
69674 asmlinkage void do_softirq(void);
69675 asmlinkage void __do_softirq(void);
69676 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
69677 +extern void open_softirq(int nr, void (*action)(void));
69678 extern void softirq_init(void);
69679 extern void __raise_softirq_irqoff(unsigned int nr);
69680
69681 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
69682 index ba3b8a9..7e14ed8 100644
69683 --- a/include/linux/iommu.h
69684 +++ b/include/linux/iommu.h
69685 @@ -113,7 +113,7 @@ struct iommu_ops {
69686 u32 (*domain_get_windows)(struct iommu_domain *domain);
69687
69688 unsigned long pgsize_bitmap;
69689 -};
69690 +} __do_const;
69691
69692 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
69693 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
69694 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
69695 index 85ac9b9b..e5759ab 100644
69696 --- a/include/linux/ioport.h
69697 +++ b/include/linux/ioport.h
69698 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
69699 int adjust_resource(struct resource *res, resource_size_t start,
69700 resource_size_t size);
69701 resource_size_t resource_alignment(struct resource *res);
69702 -static inline resource_size_t resource_size(const struct resource *res)
69703 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
69704 {
69705 return res->end - res->start + 1;
69706 }
69707 diff --git a/include/linux/irq.h b/include/linux/irq.h
69708 index bc4e066..50468a9 100644
69709 --- a/include/linux/irq.h
69710 +++ b/include/linux/irq.h
69711 @@ -328,7 +328,8 @@ struct irq_chip {
69712 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
69713
69714 unsigned long flags;
69715 -};
69716 +} __do_const;
69717 +typedef struct irq_chip __no_const irq_chip_no_const;
69718
69719 /*
69720 * irq_chip specific flags
69721 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
69722 index 3fd8e42..a73e966 100644
69723 --- a/include/linux/irqchip/arm-gic.h
69724 +++ b/include/linux/irqchip/arm-gic.h
69725 @@ -59,9 +59,11 @@
69726
69727 #ifndef __ASSEMBLY__
69728
69729 +#include <linux/irq.h>
69730 +
69731 struct device_node;
69732
69733 -extern struct irq_chip gic_arch_extn;
69734 +extern irq_chip_no_const gic_arch_extn;
69735
69736 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
69737 u32 offset, struct device_node *);
69738 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
69739 index 6883e19..06992b1 100644
69740 --- a/include/linux/kallsyms.h
69741 +++ b/include/linux/kallsyms.h
69742 @@ -15,7 +15,8 @@
69743
69744 struct module;
69745
69746 -#ifdef CONFIG_KALLSYMS
69747 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
69748 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
69749 /* Lookup the address for a symbol. Returns 0 if not found. */
69750 unsigned long kallsyms_lookup_name(const char *name);
69751
69752 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
69753 /* Stupid that this does nothing, but I didn't create this mess. */
69754 #define __print_symbol(fmt, addr)
69755 #endif /*CONFIG_KALLSYMS*/
69756 +#else /* when included by kallsyms.c, vsnprintf.c, or
69757 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
69758 +extern void __print_symbol(const char *fmt, unsigned long address);
69759 +extern int sprint_backtrace(char *buffer, unsigned long address);
69760 +extern int sprint_symbol(char *buffer, unsigned long address);
69761 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
69762 +const char *kallsyms_lookup(unsigned long addr,
69763 + unsigned long *symbolsize,
69764 + unsigned long *offset,
69765 + char **modname, char *namebuf);
69766 +#endif
69767
69768 /* This macro allows us to keep printk typechecking */
69769 static __printf(1, 2)
69770 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
69771 index 518a53a..5e28358 100644
69772 --- a/include/linux/key-type.h
69773 +++ b/include/linux/key-type.h
69774 @@ -125,7 +125,7 @@ struct key_type {
69775 /* internal fields */
69776 struct list_head link; /* link in types list */
69777 struct lock_class_key lock_class; /* key->sem lock class */
69778 -};
69779 +} __do_const;
69780
69781 extern struct key_type key_type_keyring;
69782
69783 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
69784 index c6e091b..a940adf 100644
69785 --- a/include/linux/kgdb.h
69786 +++ b/include/linux/kgdb.h
69787 @@ -52,7 +52,7 @@ extern int kgdb_connected;
69788 extern int kgdb_io_module_registered;
69789
69790 extern atomic_t kgdb_setting_breakpoint;
69791 -extern atomic_t kgdb_cpu_doing_single_step;
69792 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
69793
69794 extern struct task_struct *kgdb_usethread;
69795 extern struct task_struct *kgdb_contthread;
69796 @@ -254,7 +254,7 @@ struct kgdb_arch {
69797 void (*correct_hw_break)(void);
69798
69799 void (*enable_nmi)(bool on);
69800 -};
69801 +} __do_const;
69802
69803 /**
69804 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
69805 @@ -279,7 +279,7 @@ struct kgdb_io {
69806 void (*pre_exception) (void);
69807 void (*post_exception) (void);
69808 int is_console;
69809 -};
69810 +} __do_const;
69811
69812 extern struct kgdb_arch arch_kgdb_ops;
69813
69814 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
69815 index 5398d58..5883a34 100644
69816 --- a/include/linux/kmod.h
69817 +++ b/include/linux/kmod.h
69818 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
69819 * usually useless though. */
69820 extern __printf(2, 3)
69821 int __request_module(bool wait, const char *name, ...);
69822 +extern __printf(3, 4)
69823 +int ___request_module(bool wait, char *param_name, const char *name, ...);
69824 #define request_module(mod...) __request_module(true, mod)
69825 #define request_module_nowait(mod...) __request_module(false, mod)
69826 #define try_then_request_module(x, mod...) \
69827 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
69828 index 939b112..ed6ed51 100644
69829 --- a/include/linux/kobject.h
69830 +++ b/include/linux/kobject.h
69831 @@ -111,7 +111,7 @@ struct kobj_type {
69832 struct attribute **default_attrs;
69833 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
69834 const void *(*namespace)(struct kobject *kobj);
69835 -};
69836 +} __do_const;
69837
69838 struct kobj_uevent_env {
69839 char *envp[UEVENT_NUM_ENVP];
69840 @@ -134,6 +134,7 @@ struct kobj_attribute {
69841 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
69842 const char *buf, size_t count);
69843 };
69844 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
69845
69846 extern const struct sysfs_ops kobj_sysfs_ops;
69847
69848 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
69849 index f66b065..c2c29b4 100644
69850 --- a/include/linux/kobject_ns.h
69851 +++ b/include/linux/kobject_ns.h
69852 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
69853 const void *(*netlink_ns)(struct sock *sk);
69854 const void *(*initial_ns)(void);
69855 void (*drop_ns)(void *);
69856 -};
69857 +} __do_const;
69858
69859 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
69860 int kobj_ns_type_registered(enum kobj_ns_type type);
69861 diff --git a/include/linux/kref.h b/include/linux/kref.h
69862 index 7419c02..aa2f02d 100644
69863 --- a/include/linux/kref.h
69864 +++ b/include/linux/kref.h
69865 @@ -65,7 +65,7 @@ static inline void kref_get(struct kref *kref)
69866 static inline int kref_sub(struct kref *kref, unsigned int count,
69867 void (*release)(struct kref *kref))
69868 {
69869 - WARN_ON(release == NULL);
69870 + BUG_ON(release == NULL);
69871
69872 if (atomic_sub_and_test((int) count, &kref->refcount)) {
69873 release(kref);
69874 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
69875 index c139582..0b5b102 100644
69876 --- a/include/linux/kvm_host.h
69877 +++ b/include/linux/kvm_host.h
69878 @@ -424,7 +424,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
69879 int __must_check vcpu_load(struct kvm_vcpu *vcpu);
69880 void vcpu_put(struct kvm_vcpu *vcpu);
69881
69882 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69883 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69884 struct module *module);
69885 void kvm_exit(void);
69886
69887 @@ -582,7 +582,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
69888 struct kvm_guest_debug *dbg);
69889 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
69890
69891 -int kvm_arch_init(void *opaque);
69892 +int kvm_arch_init(const void *opaque);
69893 void kvm_arch_exit(void);
69894
69895 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
69896 diff --git a/include/linux/libata.h b/include/linux/libata.h
69897 index eae7a05..2cdd875 100644
69898 --- a/include/linux/libata.h
69899 +++ b/include/linux/libata.h
69900 @@ -919,7 +919,7 @@ struct ata_port_operations {
69901 * fields must be pointers.
69902 */
69903 const struct ata_port_operations *inherits;
69904 -};
69905 +} __do_const;
69906
69907 struct ata_port_info {
69908 unsigned long flags;
69909 diff --git a/include/linux/list.h b/include/linux/list.h
69910 index 6a1f8df..eaec1ff 100644
69911 --- a/include/linux/list.h
69912 +++ b/include/linux/list.h
69913 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
69914 extern void list_del(struct list_head *entry);
69915 #endif
69916
69917 +extern void __pax_list_add(struct list_head *new,
69918 + struct list_head *prev,
69919 + struct list_head *next);
69920 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
69921 +{
69922 + __pax_list_add(new, head, head->next);
69923 +}
69924 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
69925 +{
69926 + __pax_list_add(new, head->prev, head);
69927 +}
69928 +extern void pax_list_del(struct list_head *entry);
69929 +
69930 /**
69931 * list_replace - replace old entry by new one
69932 * @old : the element to be replaced
69933 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
69934 INIT_LIST_HEAD(entry);
69935 }
69936
69937 +extern void pax_list_del_init(struct list_head *entry);
69938 +
69939 /**
69940 * list_move - delete from one list and add as another's head
69941 * @list: the entry to move
69942 diff --git a/include/linux/math64.h b/include/linux/math64.h
69943 index b8ba855..0148090 100644
69944 --- a/include/linux/math64.h
69945 +++ b/include/linux/math64.h
69946 @@ -14,7 +14,7 @@
69947 * This is commonly provided by 32bit archs to provide an optimized 64bit
69948 * divide.
69949 */
69950 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69951 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69952 {
69953 *remainder = dividend % divisor;
69954 return dividend / divisor;
69955 @@ -50,7 +50,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
69956 #define div64_long(x,y) div_s64((x),(y))
69957
69958 #ifndef div_u64_rem
69959 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69960 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
69961 {
69962 *remainder = do_div(dividend, divisor);
69963 return dividend;
69964 @@ -79,7 +79,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
69965 * divide.
69966 */
69967 #ifndef div_u64
69968 -static inline u64 div_u64(u64 dividend, u32 divisor)
69969 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
69970 {
69971 u32 remainder;
69972 return div_u64_rem(dividend, divisor, &remainder);
69973 diff --git a/include/linux/mm.h b/include/linux/mm.h
69974 index e2091b8..821db54 100644
69975 --- a/include/linux/mm.h
69976 +++ b/include/linux/mm.h
69977 @@ -101,6 +101,11 @@ extern unsigned int kobjsize(const void *objp);
69978 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
69979 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
69980 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
69981 +
69982 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
69983 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
69984 +#endif
69985 +
69986 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
69987
69988 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
69989 @@ -202,8 +207,8 @@ struct vm_operations_struct {
69990 /* called by access_process_vm when get_user_pages() fails, typically
69991 * for use by special VMAs that can switch between memory and hardware
69992 */
69993 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
69994 - void *buf, int len, int write);
69995 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
69996 + void *buf, size_t len, int write);
69997 #ifdef CONFIG_NUMA
69998 /*
69999 * set_policy() op must add a reference to any non-NULL @new mempolicy
70000 @@ -233,6 +238,7 @@ struct vm_operations_struct {
70001 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
70002 unsigned long size, pgoff_t pgoff);
70003 };
70004 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
70005
70006 struct mmu_gather;
70007 struct inode;
70008 @@ -970,8 +976,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
70009 unsigned long *pfn);
70010 int follow_phys(struct vm_area_struct *vma, unsigned long address,
70011 unsigned int flags, unsigned long *prot, resource_size_t *phys);
70012 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70013 - void *buf, int len, int write);
70014 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70015 + void *buf, size_t len, int write);
70016
70017 static inline void unmap_shared_mapping_range(struct address_space *mapping,
70018 loff_t const holebegin, loff_t const holelen)
70019 @@ -1010,9 +1016,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
70020 }
70021 #endif
70022
70023 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
70024 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
70025 - void *buf, int len, int write);
70026 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
70027 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
70028 + void *buf, size_t len, int write);
70029
70030 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
70031 unsigned long start, unsigned long nr_pages,
70032 @@ -1043,34 +1049,6 @@ int set_page_dirty(struct page *page);
70033 int set_page_dirty_lock(struct page *page);
70034 int clear_page_dirty_for_io(struct page *page);
70035
70036 -/* Is the vma a continuation of the stack vma above it? */
70037 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
70038 -{
70039 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
70040 -}
70041 -
70042 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
70043 - unsigned long addr)
70044 -{
70045 - return (vma->vm_flags & VM_GROWSDOWN) &&
70046 - (vma->vm_start == addr) &&
70047 - !vma_growsdown(vma->vm_prev, addr);
70048 -}
70049 -
70050 -/* Is the vma a continuation of the stack vma below it? */
70051 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
70052 -{
70053 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
70054 -}
70055 -
70056 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
70057 - unsigned long addr)
70058 -{
70059 - return (vma->vm_flags & VM_GROWSUP) &&
70060 - (vma->vm_end == addr) &&
70061 - !vma_growsup(vma->vm_next, addr);
70062 -}
70063 -
70064 extern pid_t
70065 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
70066
70067 @@ -1173,6 +1151,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
70068 }
70069 #endif
70070
70071 +#ifdef CONFIG_MMU
70072 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
70073 +#else
70074 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
70075 +{
70076 + return __pgprot(0);
70077 +}
70078 +#endif
70079 +
70080 int vma_wants_writenotify(struct vm_area_struct *vma);
70081
70082 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
70083 @@ -1191,8 +1178,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
70084 {
70085 return 0;
70086 }
70087 +
70088 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
70089 + unsigned long address)
70090 +{
70091 + return 0;
70092 +}
70093 #else
70094 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70095 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70096 #endif
70097
70098 #ifdef __PAGETABLE_PMD_FOLDED
70099 @@ -1201,8 +1195,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
70100 {
70101 return 0;
70102 }
70103 +
70104 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
70105 + unsigned long address)
70106 +{
70107 + return 0;
70108 +}
70109 #else
70110 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
70111 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
70112 #endif
70113
70114 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
70115 @@ -1220,11 +1221,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
70116 NULL: pud_offset(pgd, address);
70117 }
70118
70119 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
70120 +{
70121 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
70122 + NULL: pud_offset(pgd, address);
70123 +}
70124 +
70125 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
70126 {
70127 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
70128 NULL: pmd_offset(pud, address);
70129 }
70130 +
70131 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
70132 +{
70133 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
70134 + NULL: pmd_offset(pud, address);
70135 +}
70136 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
70137
70138 #if USE_SPLIT_PTLOCKS
70139 @@ -1455,6 +1468,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
70140 unsigned long len, unsigned long prot, unsigned long flags,
70141 unsigned long pgoff, unsigned long *populate);
70142 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
70143 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
70144
70145 #ifdef CONFIG_MMU
70146 extern int __mm_populate(unsigned long addr, unsigned long len,
70147 @@ -1483,6 +1497,7 @@ struct vm_unmapped_area_info {
70148 unsigned long high_limit;
70149 unsigned long align_mask;
70150 unsigned long align_offset;
70151 + unsigned long threadstack_offset;
70152 };
70153
70154 extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
70155 @@ -1561,6 +1576,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
70156 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
70157 struct vm_area_struct **pprev);
70158
70159 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
70160 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
70161 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
70162 +
70163 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
70164 NULL if none. Assume start_addr < end_addr. */
70165 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
70166 @@ -1589,15 +1608,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
70167 return vma;
70168 }
70169
70170 -#ifdef CONFIG_MMU
70171 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
70172 -#else
70173 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
70174 -{
70175 - return __pgprot(0);
70176 -}
70177 -#endif
70178 -
70179 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
70180 unsigned long change_prot_numa(struct vm_area_struct *vma,
70181 unsigned long start, unsigned long end);
70182 @@ -1649,6 +1659,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
70183 static inline void vm_stat_account(struct mm_struct *mm,
70184 unsigned long flags, struct file *file, long pages)
70185 {
70186 +
70187 +#ifdef CONFIG_PAX_RANDMMAP
70188 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
70189 +#endif
70190 +
70191 mm->total_vm += pages;
70192 }
70193 #endif /* CONFIG_PROC_FS */
70194 @@ -1725,7 +1740,7 @@ extern int unpoison_memory(unsigned long pfn);
70195 extern int sysctl_memory_failure_early_kill;
70196 extern int sysctl_memory_failure_recovery;
70197 extern void shake_page(struct page *p, int access);
70198 -extern atomic_long_t num_poisoned_pages;
70199 +extern atomic_long_unchecked_t num_poisoned_pages;
70200 extern int soft_offline_page(struct page *page, int flags);
70201
70202 extern void dump_page(struct page *page);
70203 @@ -1756,5 +1771,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
70204 static inline bool page_is_guard(struct page *page) { return false; }
70205 #endif /* CONFIG_DEBUG_PAGEALLOC */
70206
70207 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
70208 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
70209 +#else
70210 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
70211 +#endif
70212 +
70213 #endif /* __KERNEL__ */
70214 #endif /* _LINUX_MM_H */
70215 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
70216 index ace9a5f..81bdb59 100644
70217 --- a/include/linux/mm_types.h
70218 +++ b/include/linux/mm_types.h
70219 @@ -289,6 +289,8 @@ struct vm_area_struct {
70220 #ifdef CONFIG_NUMA
70221 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
70222 #endif
70223 +
70224 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
70225 };
70226
70227 struct core_thread {
70228 @@ -437,6 +439,24 @@ struct mm_struct {
70229 int first_nid;
70230 #endif
70231 struct uprobes_state uprobes_state;
70232 +
70233 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
70234 + unsigned long pax_flags;
70235 +#endif
70236 +
70237 +#ifdef CONFIG_PAX_DLRESOLVE
70238 + unsigned long call_dl_resolve;
70239 +#endif
70240 +
70241 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
70242 + unsigned long call_syscall;
70243 +#endif
70244 +
70245 +#ifdef CONFIG_PAX_ASLR
70246 + unsigned long delta_mmap; /* randomized offset */
70247 + unsigned long delta_stack; /* randomized offset */
70248 +#endif
70249 +
70250 };
70251
70252 /* first nid will either be a valid NID or one of these values */
70253 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
70254 index c5d5278..f0b68c8 100644
70255 --- a/include/linux/mmiotrace.h
70256 +++ b/include/linux/mmiotrace.h
70257 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
70258 /* Called from ioremap.c */
70259 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
70260 void __iomem *addr);
70261 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
70262 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
70263
70264 /* For anyone to insert markers. Remember trailing newline. */
70265 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
70266 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
70267 {
70268 }
70269
70270 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
70271 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
70272 {
70273 }
70274
70275 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
70276 index c74092e..b663967 100644
70277 --- a/include/linux/mmzone.h
70278 +++ b/include/linux/mmzone.h
70279 @@ -396,7 +396,7 @@ struct zone {
70280 unsigned long flags; /* zone flags, see below */
70281
70282 /* Zone statistics */
70283 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70284 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70285
70286 /*
70287 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
70288 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
70289 index 779cf7c..e6768240 100644
70290 --- a/include/linux/mod_devicetable.h
70291 +++ b/include/linux/mod_devicetable.h
70292 @@ -12,7 +12,7 @@
70293 typedef unsigned long kernel_ulong_t;
70294 #endif
70295
70296 -#define PCI_ANY_ID (~0)
70297 +#define PCI_ANY_ID ((__u16)~0)
70298
70299 struct pci_device_id {
70300 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
70301 @@ -138,7 +138,7 @@ struct usb_device_id {
70302 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
70303 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
70304
70305 -#define HID_ANY_ID (~0)
70306 +#define HID_ANY_ID (~0U)
70307 #define HID_BUS_ANY 0xffff
70308 #define HID_GROUP_ANY 0x0000
70309
70310 @@ -464,7 +464,7 @@ struct dmi_system_id {
70311 const char *ident;
70312 struct dmi_strmatch matches[4];
70313 void *driver_data;
70314 -};
70315 +} __do_const;
70316 /*
70317 * struct dmi_device_id appears during expansion of
70318 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
70319 diff --git a/include/linux/module.h b/include/linux/module.h
70320 index ead1b57..81a3b6c 100644
70321 --- a/include/linux/module.h
70322 +++ b/include/linux/module.h
70323 @@ -17,9 +17,11 @@
70324 #include <linux/moduleparam.h>
70325 #include <linux/tracepoint.h>
70326 #include <linux/export.h>
70327 +#include <linux/fs.h>
70328
70329 #include <linux/percpu.h>
70330 #include <asm/module.h>
70331 +#include <asm/pgtable.h>
70332
70333 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
70334 #define MODULE_SIG_STRING "~Module signature appended~\n"
70335 @@ -54,12 +56,13 @@ struct module_attribute {
70336 int (*test)(struct module *);
70337 void (*free)(struct module *);
70338 };
70339 +typedef struct module_attribute __no_const module_attribute_no_const;
70340
70341 struct module_version_attribute {
70342 struct module_attribute mattr;
70343 const char *module_name;
70344 const char *version;
70345 -} __attribute__ ((__aligned__(sizeof(void *))));
70346 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
70347
70348 extern ssize_t __modver_version_show(struct module_attribute *,
70349 struct module_kobject *, char *);
70350 @@ -232,7 +235,7 @@ struct module
70351
70352 /* Sysfs stuff. */
70353 struct module_kobject mkobj;
70354 - struct module_attribute *modinfo_attrs;
70355 + module_attribute_no_const *modinfo_attrs;
70356 const char *version;
70357 const char *srcversion;
70358 struct kobject *holders_dir;
70359 @@ -281,19 +284,16 @@ struct module
70360 int (*init)(void);
70361
70362 /* If this is non-NULL, vfree after init() returns */
70363 - void *module_init;
70364 + void *module_init_rx, *module_init_rw;
70365
70366 /* Here is the actual code + data, vfree'd on unload. */
70367 - void *module_core;
70368 + void *module_core_rx, *module_core_rw;
70369
70370 /* Here are the sizes of the init and core sections */
70371 - unsigned int init_size, core_size;
70372 + unsigned int init_size_rw, core_size_rw;
70373
70374 /* The size of the executable code in each section. */
70375 - unsigned int init_text_size, core_text_size;
70376 -
70377 - /* Size of RO sections of the module (text+rodata) */
70378 - unsigned int init_ro_size, core_ro_size;
70379 + unsigned int init_size_rx, core_size_rx;
70380
70381 /* Arch-specific module values */
70382 struct mod_arch_specific arch;
70383 @@ -349,6 +349,10 @@ struct module
70384 #ifdef CONFIG_EVENT_TRACING
70385 struct ftrace_event_call **trace_events;
70386 unsigned int num_trace_events;
70387 + struct file_operations trace_id;
70388 + struct file_operations trace_enable;
70389 + struct file_operations trace_format;
70390 + struct file_operations trace_filter;
70391 #endif
70392 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
70393 unsigned int num_ftrace_callsites;
70394 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
70395 bool is_module_percpu_address(unsigned long addr);
70396 bool is_module_text_address(unsigned long addr);
70397
70398 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
70399 +{
70400 +
70401 +#ifdef CONFIG_PAX_KERNEXEC
70402 + if (ktla_ktva(addr) >= (unsigned long)start &&
70403 + ktla_ktva(addr) < (unsigned long)start + size)
70404 + return 1;
70405 +#endif
70406 +
70407 + return ((void *)addr >= start && (void *)addr < start + size);
70408 +}
70409 +
70410 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
70411 +{
70412 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
70413 +}
70414 +
70415 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
70416 +{
70417 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
70418 +}
70419 +
70420 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
70421 +{
70422 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
70423 +}
70424 +
70425 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
70426 +{
70427 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
70428 +}
70429 +
70430 static inline int within_module_core(unsigned long addr, const struct module *mod)
70431 {
70432 - return (unsigned long)mod->module_core <= addr &&
70433 - addr < (unsigned long)mod->module_core + mod->core_size;
70434 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
70435 }
70436
70437 static inline int within_module_init(unsigned long addr, const struct module *mod)
70438 {
70439 - return (unsigned long)mod->module_init <= addr &&
70440 - addr < (unsigned long)mod->module_init + mod->init_size;
70441 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
70442 }
70443
70444 /* Search for module by name: must hold module_mutex. */
70445 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
70446 index 560ca53..ef621ef 100644
70447 --- a/include/linux/moduleloader.h
70448 +++ b/include/linux/moduleloader.h
70449 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
70450 sections. Returns NULL on failure. */
70451 void *module_alloc(unsigned long size);
70452
70453 +#ifdef CONFIG_PAX_KERNEXEC
70454 +void *module_alloc_exec(unsigned long size);
70455 +#else
70456 +#define module_alloc_exec(x) module_alloc(x)
70457 +#endif
70458 +
70459 /* Free memory returned from module_alloc. */
70460 void module_free(struct module *mod, void *module_region);
70461
70462 +#ifdef CONFIG_PAX_KERNEXEC
70463 +void module_free_exec(struct module *mod, void *module_region);
70464 +#else
70465 +#define module_free_exec(x, y) module_free((x), (y))
70466 +#endif
70467 +
70468 /*
70469 * Apply the given relocation to the (simplified) ELF. Return -error
70470 * or 0.
70471 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
70472 unsigned int relsec,
70473 struct module *me)
70474 {
70475 +#ifdef CONFIG_MODULES
70476 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70477 +#endif
70478 return -ENOEXEC;
70479 }
70480 #endif
70481 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
70482 unsigned int relsec,
70483 struct module *me)
70484 {
70485 +#ifdef CONFIG_MODULES
70486 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70487 +#endif
70488 return -ENOEXEC;
70489 }
70490 #endif
70491 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
70492 index 137b419..fe663ec 100644
70493 --- a/include/linux/moduleparam.h
70494 +++ b/include/linux/moduleparam.h
70495 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
70496 * @len is usually just sizeof(string).
70497 */
70498 #define module_param_string(name, string, len, perm) \
70499 - static const struct kparam_string __param_string_##name \
70500 + static const struct kparam_string __param_string_##name __used \
70501 = { len, string }; \
70502 __module_param_call(MODULE_PARAM_PREFIX, name, \
70503 &param_ops_string, \
70504 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
70505 */
70506 #define module_param_array_named(name, array, type, nump, perm) \
70507 param_check_##type(name, &(array)[0]); \
70508 - static const struct kparam_array __param_arr_##name \
70509 + static const struct kparam_array __param_arr_##name __used \
70510 = { .max = ARRAY_SIZE(array), .num = nump, \
70511 .ops = &param_ops_##type, \
70512 .elemsize = sizeof(array[0]), .elem = array }; \
70513 diff --git a/include/linux/namei.h b/include/linux/namei.h
70514 index 5a5ff57..5ae5070 100644
70515 --- a/include/linux/namei.h
70516 +++ b/include/linux/namei.h
70517 @@ -19,7 +19,7 @@ struct nameidata {
70518 unsigned seq;
70519 int last_type;
70520 unsigned depth;
70521 - char *saved_names[MAX_NESTED_LINKS + 1];
70522 + const char *saved_names[MAX_NESTED_LINKS + 1];
70523 };
70524
70525 /*
70526 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
70527
70528 extern void nd_jump_link(struct nameidata *nd, struct path *path);
70529
70530 -static inline void nd_set_link(struct nameidata *nd, char *path)
70531 +static inline void nd_set_link(struct nameidata *nd, const char *path)
70532 {
70533 nd->saved_names[nd->depth] = path;
70534 }
70535
70536 -static inline char *nd_get_link(struct nameidata *nd)
70537 +static inline const char *nd_get_link(const struct nameidata *nd)
70538 {
70539 return nd->saved_names[nd->depth];
70540 }
70541 diff --git a/include/linux/net.h b/include/linux/net.h
70542 index aa16731..514b875 100644
70543 --- a/include/linux/net.h
70544 +++ b/include/linux/net.h
70545 @@ -183,7 +183,7 @@ struct net_proto_family {
70546 int (*create)(struct net *net, struct socket *sock,
70547 int protocol, int kern);
70548 struct module *owner;
70549 -};
70550 +} __do_const;
70551
70552 struct iovec;
70553 struct kvec;
70554 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
70555 index 6151e90..2e0afb0 100644
70556 --- a/include/linux/netdevice.h
70557 +++ b/include/linux/netdevice.h
70558 @@ -1028,6 +1028,7 @@ struct net_device_ops {
70559 int (*ndo_change_carrier)(struct net_device *dev,
70560 bool new_carrier);
70561 };
70562 +typedef struct net_device_ops __no_const net_device_ops_no_const;
70563
70564 /*
70565 * The DEVICE structure.
70566 @@ -1094,7 +1095,7 @@ struct net_device {
70567 int iflink;
70568
70569 struct net_device_stats stats;
70570 - atomic_long_t rx_dropped; /* dropped packets by core network
70571 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
70572 * Do not use this in drivers.
70573 */
70574
70575 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
70576 index ee14284..bc65d63 100644
70577 --- a/include/linux/netfilter.h
70578 +++ b/include/linux/netfilter.h
70579 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
70580 #endif
70581 /* Use the module struct to lock set/get code in place */
70582 struct module *owner;
70583 -};
70584 +} __do_const;
70585
70586 /* Function to register/unregister hook points. */
70587 int nf_register_hook(struct nf_hook_ops *reg);
70588 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
70589 index 7958e84..ed74d7a 100644
70590 --- a/include/linux/netfilter/ipset/ip_set.h
70591 +++ b/include/linux/netfilter/ipset/ip_set.h
70592 @@ -98,7 +98,7 @@ struct ip_set_type_variant {
70593 /* Return true if "b" set is the same as "a"
70594 * according to the create set parameters */
70595 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
70596 -};
70597 +} __do_const;
70598
70599 /* The core set type structure */
70600 struct ip_set_type {
70601 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
70602 index ecbb8e4..8a1c4e1 100644
70603 --- a/include/linux/netfilter/nfnetlink.h
70604 +++ b/include/linux/netfilter/nfnetlink.h
70605 @@ -16,7 +16,7 @@ struct nfnl_callback {
70606 const struct nlattr * const cda[]);
70607 const struct nla_policy *policy; /* netlink attribute policy */
70608 const u_int16_t attr_count; /* number of nlattr's */
70609 -};
70610 +} __do_const;
70611
70612 struct nfnetlink_subsystem {
70613 const char *name;
70614 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
70615 new file mode 100644
70616 index 0000000..33f4af8
70617 --- /dev/null
70618 +++ b/include/linux/netfilter/xt_gradm.h
70619 @@ -0,0 +1,9 @@
70620 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
70621 +#define _LINUX_NETFILTER_XT_GRADM_H 1
70622 +
70623 +struct xt_gradm_mtinfo {
70624 + __u16 flags;
70625 + __u16 invflags;
70626 +};
70627 +
70628 +#endif
70629 diff --git a/include/linux/nls.h b/include/linux/nls.h
70630 index 5dc635f..35f5e11 100644
70631 --- a/include/linux/nls.h
70632 +++ b/include/linux/nls.h
70633 @@ -31,7 +31,7 @@ struct nls_table {
70634 const unsigned char *charset2upper;
70635 struct module *owner;
70636 struct nls_table *next;
70637 -};
70638 +} __do_const;
70639
70640 /* this value hold the maximum octet of charset */
70641 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
70642 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
70643 index d65746e..62e72c2 100644
70644 --- a/include/linux/notifier.h
70645 +++ b/include/linux/notifier.h
70646 @@ -51,7 +51,8 @@ struct notifier_block {
70647 int (*notifier_call)(struct notifier_block *, unsigned long, void *);
70648 struct notifier_block __rcu *next;
70649 int priority;
70650 -};
70651 +} __do_const;
70652 +typedef struct notifier_block __no_const notifier_block_no_const;
70653
70654 struct atomic_notifier_head {
70655 spinlock_t lock;
70656 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
70657 index a4c5624..79d6d88 100644
70658 --- a/include/linux/oprofile.h
70659 +++ b/include/linux/oprofile.h
70660 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
70661 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
70662 char const * name, ulong * val);
70663
70664 -/** Create a file for read-only access to an atomic_t. */
70665 +/** Create a file for read-only access to an atomic_unchecked_t. */
70666 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
70667 - char const * name, atomic_t * val);
70668 + char const * name, atomic_unchecked_t * val);
70669
70670 /** create a directory */
70671 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
70672 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
70673 index 45fc162..01a4068 100644
70674 --- a/include/linux/pci_hotplug.h
70675 +++ b/include/linux/pci_hotplug.h
70676 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
70677 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
70678 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
70679 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
70680 -};
70681 +} __do_const;
70682 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
70683
70684 /**
70685 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
70686 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
70687 index 1d795df..b0a6449 100644
70688 --- a/include/linux/perf_event.h
70689 +++ b/include/linux/perf_event.h
70690 @@ -333,8 +333,8 @@ struct perf_event {
70691
70692 enum perf_event_active_state state;
70693 unsigned int attach_state;
70694 - local64_t count;
70695 - atomic64_t child_count;
70696 + local64_t count; /* PaX: fix it one day */
70697 + atomic64_unchecked_t child_count;
70698
70699 /*
70700 * These are the total time in nanoseconds that the event
70701 @@ -385,8 +385,8 @@ struct perf_event {
70702 * These accumulate total time (in nanoseconds) that children
70703 * events have been enabled and running, respectively.
70704 */
70705 - atomic64_t child_total_time_enabled;
70706 - atomic64_t child_total_time_running;
70707 + atomic64_unchecked_t child_total_time_enabled;
70708 + atomic64_unchecked_t child_total_time_running;
70709
70710 /*
70711 * Protect attach/detach and child_list:
70712 @@ -704,7 +704,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
70713 entry->ip[entry->nr++] = ip;
70714 }
70715
70716 -extern int sysctl_perf_event_paranoid;
70717 +extern int sysctl_perf_event_legitimately_concerned;
70718 extern int sysctl_perf_event_mlock;
70719 extern int sysctl_perf_event_sample_rate;
70720
70721 @@ -712,19 +712,24 @@ extern int perf_proc_update_handler(struct ctl_table *table, int write,
70722 void __user *buffer, size_t *lenp,
70723 loff_t *ppos);
70724
70725 +static inline bool perf_paranoid_any(void)
70726 +{
70727 + return sysctl_perf_event_legitimately_concerned > 2;
70728 +}
70729 +
70730 static inline bool perf_paranoid_tracepoint_raw(void)
70731 {
70732 - return sysctl_perf_event_paranoid > -1;
70733 + return sysctl_perf_event_legitimately_concerned > -1;
70734 }
70735
70736 static inline bool perf_paranoid_cpu(void)
70737 {
70738 - return sysctl_perf_event_paranoid > 0;
70739 + return sysctl_perf_event_legitimately_concerned > 0;
70740 }
70741
70742 static inline bool perf_paranoid_kernel(void)
70743 {
70744 - return sysctl_perf_event_paranoid > 1;
70745 + return sysctl_perf_event_legitimately_concerned > 1;
70746 }
70747
70748 extern void perf_event_init(void);
70749 @@ -812,7 +817,7 @@ static inline void perf_restore_debug_store(void) { }
70750 */
70751 #define perf_cpu_notifier(fn) \
70752 do { \
70753 - static struct notifier_block fn##_nb __cpuinitdata = \
70754 + static struct notifier_block fn##_nb = \
70755 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
70756 unsigned long cpu = smp_processor_id(); \
70757 unsigned long flags; \
70758 @@ -831,7 +836,7 @@ do { \
70759 struct perf_pmu_events_attr {
70760 struct device_attribute attr;
70761 u64 id;
70762 -};
70763 +} __do_const;
70764
70765 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
70766 static struct perf_pmu_events_attr _var = { \
70767 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
70768 index ad1a427..6419649 100644
70769 --- a/include/linux/pipe_fs_i.h
70770 +++ b/include/linux/pipe_fs_i.h
70771 @@ -45,9 +45,9 @@ struct pipe_buffer {
70772 struct pipe_inode_info {
70773 wait_queue_head_t wait;
70774 unsigned int nrbufs, curbuf, buffers;
70775 - unsigned int readers;
70776 - unsigned int writers;
70777 - unsigned int waiting_writers;
70778 + atomic_t readers;
70779 + atomic_t writers;
70780 + atomic_t waiting_writers;
70781 unsigned int r_counter;
70782 unsigned int w_counter;
70783 struct page *tmp_page;
70784 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
70785 index 5f28cae..3d23723 100644
70786 --- a/include/linux/platform_data/usb-ehci-s5p.h
70787 +++ b/include/linux/platform_data/usb-ehci-s5p.h
70788 @@ -14,7 +14,7 @@
70789 struct s5p_ehci_platdata {
70790 int (*phy_init)(struct platform_device *pdev, int type);
70791 int (*phy_exit)(struct platform_device *pdev, int type);
70792 -};
70793 +} __no_const;
70794
70795 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
70796
70797 diff --git a/include/linux/platform_data/usb-exynos.h b/include/linux/platform_data/usb-exynos.h
70798 index c256c59..8ea94c7 100644
70799 --- a/include/linux/platform_data/usb-exynos.h
70800 +++ b/include/linux/platform_data/usb-exynos.h
70801 @@ -14,7 +14,7 @@
70802 struct exynos4_ohci_platdata {
70803 int (*phy_init)(struct platform_device *pdev, int type);
70804 int (*phy_exit)(struct platform_device *pdev, int type);
70805 -};
70806 +} __no_const;
70807
70808 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
70809
70810 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
70811 index 7c1d252..c5c773e 100644
70812 --- a/include/linux/pm_domain.h
70813 +++ b/include/linux/pm_domain.h
70814 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
70815
70816 struct gpd_cpu_data {
70817 unsigned int saved_exit_latency;
70818 - struct cpuidle_state *idle_state;
70819 + cpuidle_state_no_const *idle_state;
70820 };
70821
70822 struct generic_pm_domain {
70823 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
70824 index 7d7e09e..8671ef8 100644
70825 --- a/include/linux/pm_runtime.h
70826 +++ b/include/linux/pm_runtime.h
70827 @@ -104,7 +104,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
70828
70829 static inline void pm_runtime_mark_last_busy(struct device *dev)
70830 {
70831 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
70832 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
70833 }
70834
70835 #else /* !CONFIG_PM_RUNTIME */
70836 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
70837 index 195aafc..49a7bc2 100644
70838 --- a/include/linux/pnp.h
70839 +++ b/include/linux/pnp.h
70840 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
70841 struct pnp_fixup {
70842 char id[7];
70843 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
70844 -};
70845 +} __do_const;
70846
70847 /* config parameters */
70848 #define PNP_CONFIG_NORMAL 0x0001
70849 diff --git a/include/linux/poison.h b/include/linux/poison.h
70850 index 2110a81..13a11bb 100644
70851 --- a/include/linux/poison.h
70852 +++ b/include/linux/poison.h
70853 @@ -19,8 +19,8 @@
70854 * under normal circumstances, used to verify that nobody uses
70855 * non-initialized list entries.
70856 */
70857 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
70858 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
70859 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
70860 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
70861
70862 /********** include/linux/timer.h **********/
70863 /*
70864 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
70865 index c0f44c2..1572583 100644
70866 --- a/include/linux/power/smartreflex.h
70867 +++ b/include/linux/power/smartreflex.h
70868 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
70869 int (*notify)(struct omap_sr *sr, u32 status);
70870 u8 notify_flags;
70871 u8 class_type;
70872 -};
70873 +} __do_const;
70874
70875 /**
70876 * struct omap_sr_nvalue_table - Smartreflex n-target value info
70877 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
70878 index 4ea1d37..80f4b33 100644
70879 --- a/include/linux/ppp-comp.h
70880 +++ b/include/linux/ppp-comp.h
70881 @@ -84,7 +84,7 @@ struct compressor {
70882 struct module *owner;
70883 /* Extra skb space needed by the compressor algorithm */
70884 unsigned int comp_extra;
70885 -};
70886 +} __do_const;
70887
70888 /*
70889 * The return value from decompress routine is the length of the
70890 diff --git a/include/linux/printk.h b/include/linux/printk.h
70891 index 822171f..12b30e8 100644
70892 --- a/include/linux/printk.h
70893 +++ b/include/linux/printk.h
70894 @@ -98,6 +98,8 @@ int no_printk(const char *fmt, ...)
70895 extern asmlinkage __printf(1, 2)
70896 void early_printk(const char *fmt, ...);
70897
70898 +extern int kptr_restrict;
70899 +
70900 #ifdef CONFIG_PRINTK
70901 asmlinkage __printf(5, 0)
70902 int vprintk_emit(int facility, int level,
70903 @@ -132,7 +134,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
70904
70905 extern int printk_delay_msec;
70906 extern int dmesg_restrict;
70907 -extern int kptr_restrict;
70908
70909 extern void wake_up_klogd(void);
70910
70911 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
70912 index 94dfb2a..88b9d3b 100644
70913 --- a/include/linux/proc_fs.h
70914 +++ b/include/linux/proc_fs.h
70915 @@ -165,6 +165,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
70916 return proc_create_data(name, mode, parent, proc_fops, NULL);
70917 }
70918
70919 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
70920 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
70921 +{
70922 +#ifdef CONFIG_GRKERNSEC_PROC_USER
70923 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
70924 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
70925 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
70926 +#else
70927 + return proc_create_data(name, mode, parent, proc_fops, NULL);
70928 +#endif
70929 +}
70930 +
70931 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
70932 umode_t mode, struct proc_dir_entry *base,
70933 read_proc_t *read_proc, void * data)
70934 @@ -266,7 +278,7 @@ struct proc_ns_operations {
70935 void (*put)(void *ns);
70936 int (*install)(struct nsproxy *nsproxy, void *ns);
70937 unsigned int (*inum)(void *ns);
70938 -};
70939 +} __do_const;
70940 extern const struct proc_ns_operations netns_operations;
70941 extern const struct proc_ns_operations utsns_operations;
70942 extern const struct proc_ns_operations ipcns_operations;
70943 diff --git a/include/linux/random.h b/include/linux/random.h
70944 index 347ce55..880f97c 100644
70945 --- a/include/linux/random.h
70946 +++ b/include/linux/random.h
70947 @@ -39,6 +39,11 @@ void prandom_seed(u32 seed);
70948 u32 prandom_u32_state(struct rnd_state *);
70949 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
70950
70951 +static inline unsigned long pax_get_random_long(void)
70952 +{
70953 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
70954 +}
70955 +
70956 /*
70957 * Handle minimum values for seeds
70958 */
70959 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
70960 index 8089e35..3a0d59a 100644
70961 --- a/include/linux/rculist.h
70962 +++ b/include/linux/rculist.h
70963 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
70964 struct list_head *prev, struct list_head *next);
70965 #endif
70966
70967 +extern void __pax_list_add_rcu(struct list_head *new,
70968 + struct list_head *prev, struct list_head *next);
70969 +
70970 /**
70971 * list_add_rcu - add a new entry to rcu-protected list
70972 * @new: new entry to be added
70973 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
70974 __list_add_rcu(new, head, head->next);
70975 }
70976
70977 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
70978 +{
70979 + __pax_list_add_rcu(new, head, head->next);
70980 +}
70981 +
70982 /**
70983 * list_add_tail_rcu - add a new entry to rcu-protected list
70984 * @new: new entry to be added
70985 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
70986 __list_add_rcu(new, head->prev, head);
70987 }
70988
70989 +static inline void pax_list_add_tail_rcu(struct list_head *new,
70990 + struct list_head *head)
70991 +{
70992 + __pax_list_add_rcu(new, head->prev, head);
70993 +}
70994 +
70995 /**
70996 * list_del_rcu - deletes entry from list without re-initialization
70997 * @entry: the element to delete from the list.
70998 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
70999 entry->prev = LIST_POISON2;
71000 }
71001
71002 +extern void pax_list_del_rcu(struct list_head *entry);
71003 +
71004 /**
71005 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
71006 * @n: the element to delete from the hash list.
71007 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
71008 index 23b3630..e1bc12b 100644
71009 --- a/include/linux/reboot.h
71010 +++ b/include/linux/reboot.h
71011 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
71012 * Architecture-specific implementations of sys_reboot commands.
71013 */
71014
71015 -extern void machine_restart(char *cmd);
71016 -extern void machine_halt(void);
71017 -extern void machine_power_off(void);
71018 +extern void machine_restart(char *cmd) __noreturn;
71019 +extern void machine_halt(void) __noreturn;
71020 +extern void machine_power_off(void) __noreturn;
71021
71022 extern void machine_shutdown(void);
71023 struct pt_regs;
71024 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
71025 */
71026
71027 extern void kernel_restart_prepare(char *cmd);
71028 -extern void kernel_restart(char *cmd);
71029 -extern void kernel_halt(void);
71030 -extern void kernel_power_off(void);
71031 +extern void kernel_restart(char *cmd) __noreturn;
71032 +extern void kernel_halt(void) __noreturn;
71033 +extern void kernel_power_off(void) __noreturn;
71034
71035 extern int C_A_D; /* for sysctl */
71036 void ctrl_alt_del(void);
71037 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
71038 * Emergency restart, callable from an interrupt handler.
71039 */
71040
71041 -extern void emergency_restart(void);
71042 +extern void emergency_restart(void) __noreturn;
71043 #include <asm/emergency-restart.h>
71044
71045 #endif /* _LINUX_REBOOT_H */
71046 diff --git a/include/linux/regset.h b/include/linux/regset.h
71047 index 8e0c9fe..ac4d221 100644
71048 --- a/include/linux/regset.h
71049 +++ b/include/linux/regset.h
71050 @@ -161,7 +161,8 @@ struct user_regset {
71051 unsigned int align;
71052 unsigned int bias;
71053 unsigned int core_note_type;
71054 -};
71055 +} __do_const;
71056 +typedef struct user_regset __no_const user_regset_no_const;
71057
71058 /**
71059 * struct user_regset_view - available regsets
71060 diff --git a/include/linux/relay.h b/include/linux/relay.h
71061 index 91cacc3..b55ff74 100644
71062 --- a/include/linux/relay.h
71063 +++ b/include/linux/relay.h
71064 @@ -160,7 +160,7 @@ struct rchan_callbacks
71065 * The callback should return 0 if successful, negative if not.
71066 */
71067 int (*remove_buf_file)(struct dentry *dentry);
71068 -};
71069 +} __no_const;
71070
71071 /*
71072 * CONFIG_RELAY kernel API, kernel/relay.c
71073 diff --git a/include/linux/rio.h b/include/linux/rio.h
71074 index a3e7842..d973ca6 100644
71075 --- a/include/linux/rio.h
71076 +++ b/include/linux/rio.h
71077 @@ -339,7 +339,7 @@ struct rio_ops {
71078 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
71079 u64 rstart, u32 size, u32 flags);
71080 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
71081 -};
71082 +} __no_const;
71083
71084 #define RIO_RESOURCE_MEM 0x00000100
71085 #define RIO_RESOURCE_DOORBELL 0x00000200
71086 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
71087 index 6dacb93..6174423 100644
71088 --- a/include/linux/rmap.h
71089 +++ b/include/linux/rmap.h
71090 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
71091 void anon_vma_init(void); /* create anon_vma_cachep */
71092 int anon_vma_prepare(struct vm_area_struct *);
71093 void unlink_anon_vmas(struct vm_area_struct *);
71094 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
71095 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
71096 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
71097 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
71098
71099 static inline void anon_vma_merge(struct vm_area_struct *vma,
71100 struct vm_area_struct *next)
71101 diff --git a/include/linux/sched.h b/include/linux/sched.h
71102 index be4e742..7f9d593 100644
71103 --- a/include/linux/sched.h
71104 +++ b/include/linux/sched.h
71105 @@ -62,6 +62,7 @@ struct bio_list;
71106 struct fs_struct;
71107 struct perf_event_context;
71108 struct blk_plug;
71109 +struct linux_binprm;
71110
71111 /*
71112 * List of flags we want to share for kernel threads,
71113 @@ -315,7 +316,7 @@ extern char __sched_text_start[], __sched_text_end[];
71114 extern int in_sched_functions(unsigned long addr);
71115
71116 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
71117 -extern signed long schedule_timeout(signed long timeout);
71118 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
71119 extern signed long schedule_timeout_interruptible(signed long timeout);
71120 extern signed long schedule_timeout_killable(signed long timeout);
71121 extern signed long schedule_timeout_uninterruptible(signed long timeout);
71122 @@ -329,6 +330,18 @@ struct user_namespace;
71123 #include <linux/aio.h>
71124
71125 #ifdef CONFIG_MMU
71126 +
71127 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
71128 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
71129 +#else
71130 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
71131 +{
71132 + return 0;
71133 +}
71134 +#endif
71135 +
71136 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
71137 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
71138 extern void arch_pick_mmap_layout(struct mm_struct *mm);
71139 extern unsigned long
71140 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
71141 @@ -605,6 +618,17 @@ struct signal_struct {
71142 #ifdef CONFIG_TASKSTATS
71143 struct taskstats *stats;
71144 #endif
71145 +
71146 +#ifdef CONFIG_GRKERNSEC
71147 + u32 curr_ip;
71148 + u32 saved_ip;
71149 + u32 gr_saddr;
71150 + u32 gr_daddr;
71151 + u16 gr_sport;
71152 + u16 gr_dport;
71153 + u8 used_accept:1;
71154 +#endif
71155 +
71156 #ifdef CONFIG_AUDIT
71157 unsigned audit_tty;
71158 struct tty_audit_buf *tty_audit_buf;
71159 @@ -683,6 +707,11 @@ struct user_struct {
71160 struct key *session_keyring; /* UID's default session keyring */
71161 #endif
71162
71163 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
71164 + unsigned int banned;
71165 + unsigned long ban_expires;
71166 +#endif
71167 +
71168 /* Hash table maintenance information */
71169 struct hlist_node uidhash_node;
71170 kuid_t uid;
71171 @@ -1082,7 +1111,7 @@ struct sched_class {
71172 #ifdef CONFIG_FAIR_GROUP_SCHED
71173 void (*task_move_group) (struct task_struct *p, int on_rq);
71174 #endif
71175 -};
71176 +} __do_const;
71177
71178 struct load_weight {
71179 unsigned long weight, inv_weight;
71180 @@ -1323,8 +1352,8 @@ struct task_struct {
71181 struct list_head thread_group;
71182
71183 struct completion *vfork_done; /* for vfork() */
71184 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
71185 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71186 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
71187 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71188
71189 cputime_t utime, stime, utimescaled, stimescaled;
71190 cputime_t gtime;
71191 @@ -1349,11 +1378,6 @@ struct task_struct {
71192 struct task_cputime cputime_expires;
71193 struct list_head cpu_timers[3];
71194
71195 -/* process credentials */
71196 - const struct cred __rcu *real_cred; /* objective and real subjective task
71197 - * credentials (COW) */
71198 - const struct cred __rcu *cred; /* effective (overridable) subjective task
71199 - * credentials (COW) */
71200 char comm[TASK_COMM_LEN]; /* executable name excluding path
71201 - access with [gs]et_task_comm (which lock
71202 it with task_lock())
71203 @@ -1370,6 +1394,10 @@ struct task_struct {
71204 #endif
71205 /* CPU-specific state of this task */
71206 struct thread_struct thread;
71207 +/* thread_info moved to task_struct */
71208 +#ifdef CONFIG_X86
71209 + struct thread_info tinfo;
71210 +#endif
71211 /* filesystem information */
71212 struct fs_struct *fs;
71213 /* open file information */
71214 @@ -1443,6 +1471,10 @@ struct task_struct {
71215 gfp_t lockdep_reclaim_gfp;
71216 #endif
71217
71218 +/* process credentials */
71219 + const struct cred __rcu *real_cred; /* objective and real subjective task
71220 + * credentials (COW) */
71221 +
71222 /* journalling filesystem info */
71223 void *journal_info;
71224
71225 @@ -1481,6 +1513,10 @@ struct task_struct {
71226 /* cg_list protected by css_set_lock and tsk->alloc_lock */
71227 struct list_head cg_list;
71228 #endif
71229 +
71230 + const struct cred __rcu *cred; /* effective (overridable) subjective task
71231 + * credentials (COW) */
71232 +
71233 #ifdef CONFIG_FUTEX
71234 struct robust_list_head __user *robust_list;
71235 #ifdef CONFIG_COMPAT
71236 @@ -1577,8 +1613,74 @@ struct task_struct {
71237 #ifdef CONFIG_UPROBES
71238 struct uprobe_task *utask;
71239 #endif
71240 +
71241 +#ifdef CONFIG_GRKERNSEC
71242 + /* grsecurity */
71243 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71244 + u64 exec_id;
71245 +#endif
71246 +#ifdef CONFIG_GRKERNSEC_SETXID
71247 + const struct cred *delayed_cred;
71248 +#endif
71249 + struct dentry *gr_chroot_dentry;
71250 + struct acl_subject_label *acl;
71251 + struct acl_role_label *role;
71252 + struct file *exec_file;
71253 + unsigned long brute_expires;
71254 + u16 acl_role_id;
71255 + /* is this the task that authenticated to the special role */
71256 + u8 acl_sp_role;
71257 + u8 is_writable;
71258 + u8 brute;
71259 + u8 gr_is_chrooted;
71260 +#endif
71261 +
71262 };
71263
71264 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
71265 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
71266 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
71267 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
71268 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
71269 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
71270 +
71271 +#ifdef CONFIG_PAX_SOFTMODE
71272 +extern int pax_softmode;
71273 +#endif
71274 +
71275 +extern int pax_check_flags(unsigned long *);
71276 +
71277 +/* if tsk != current then task_lock must be held on it */
71278 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
71279 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
71280 +{
71281 + if (likely(tsk->mm))
71282 + return tsk->mm->pax_flags;
71283 + else
71284 + return 0UL;
71285 +}
71286 +
71287 +/* if tsk != current then task_lock must be held on it */
71288 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
71289 +{
71290 + if (likely(tsk->mm)) {
71291 + tsk->mm->pax_flags = flags;
71292 + return 0;
71293 + }
71294 + return -EINVAL;
71295 +}
71296 +#endif
71297 +
71298 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
71299 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
71300 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
71301 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
71302 +#endif
71303 +
71304 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
71305 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
71306 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
71307 +
71308 /* Future-safe accessor for struct task_struct's cpus_allowed. */
71309 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
71310
71311 @@ -1637,7 +1739,7 @@ struct pid_namespace;
71312 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
71313 struct pid_namespace *ns);
71314
71315 -static inline pid_t task_pid_nr(struct task_struct *tsk)
71316 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
71317 {
71318 return tsk->pid;
71319 }
71320 @@ -2073,7 +2175,9 @@ void yield(void);
71321 extern struct exec_domain default_exec_domain;
71322
71323 union thread_union {
71324 +#ifndef CONFIG_X86
71325 struct thread_info thread_info;
71326 +#endif
71327 unsigned long stack[THREAD_SIZE/sizeof(long)];
71328 };
71329
71330 @@ -2106,6 +2210,7 @@ extern struct pid_namespace init_pid_ns;
71331 */
71332
71333 extern struct task_struct *find_task_by_vpid(pid_t nr);
71334 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
71335 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
71336 struct pid_namespace *ns);
71337
71338 @@ -2272,7 +2377,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
71339 extern void exit_itimers(struct signal_struct *);
71340 extern void flush_itimer_signals(void);
71341
71342 -extern void do_group_exit(int);
71343 +extern __noreturn void do_group_exit(int);
71344
71345 extern int allow_signal(int);
71346 extern int disallow_signal(int);
71347 @@ -2463,9 +2568,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
71348
71349 #endif
71350
71351 -static inline int object_is_on_stack(void *obj)
71352 +static inline int object_starts_on_stack(void *obj)
71353 {
71354 - void *stack = task_stack_page(current);
71355 + const void *stack = task_stack_page(current);
71356
71357 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
71358 }
71359 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
71360 index bf8086b..962b035 100644
71361 --- a/include/linux/sched/sysctl.h
71362 +++ b/include/linux/sched/sysctl.h
71363 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
71364 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
71365
71366 extern int sysctl_max_map_count;
71367 +extern unsigned long sysctl_heap_stack_gap;
71368
71369 extern unsigned int sysctl_sched_latency;
71370 extern unsigned int sysctl_sched_min_granularity;
71371 diff --git a/include/linux/security.h b/include/linux/security.h
71372 index 032c366..2c1c2dc2 100644
71373 --- a/include/linux/security.h
71374 +++ b/include/linux/security.h
71375 @@ -26,6 +26,7 @@
71376 #include <linux/capability.h>
71377 #include <linux/slab.h>
71378 #include <linux/err.h>
71379 +#include <linux/grsecurity.h>
71380
71381 struct linux_binprm;
71382 struct cred;
71383 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
71384 index 68a04a3..866e6a1 100644
71385 --- a/include/linux/seq_file.h
71386 +++ b/include/linux/seq_file.h
71387 @@ -26,6 +26,9 @@ struct seq_file {
71388 struct mutex lock;
71389 const struct seq_operations *op;
71390 int poll_event;
71391 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71392 + u64 exec_id;
71393 +#endif
71394 #ifdef CONFIG_USER_NS
71395 struct user_namespace *user_ns;
71396 #endif
71397 @@ -38,6 +41,7 @@ struct seq_operations {
71398 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
71399 int (*show) (struct seq_file *m, void *v);
71400 };
71401 +typedef struct seq_operations __no_const seq_operations_no_const;
71402
71403 #define SEQ_SKIP 1
71404
71405 diff --git a/include/linux/shm.h b/include/linux/shm.h
71406 index 429c199..4d42e38 100644
71407 --- a/include/linux/shm.h
71408 +++ b/include/linux/shm.h
71409 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
71410
71411 /* The task created the shm object. NULL if the task is dead. */
71412 struct task_struct *shm_creator;
71413 +#ifdef CONFIG_GRKERNSEC
71414 + time_t shm_createtime;
71415 + pid_t shm_lapid;
71416 +#endif
71417 };
71418
71419 /* shm_mode upper byte flags */
71420 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
71421 index b8292d8..96db310 100644
71422 --- a/include/linux/skbuff.h
71423 +++ b/include/linux/skbuff.h
71424 @@ -599,7 +599,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
71425 extern struct sk_buff *__alloc_skb(unsigned int size,
71426 gfp_t priority, int flags, int node);
71427 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
71428 -static inline struct sk_buff *alloc_skb(unsigned int size,
71429 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
71430 gfp_t priority)
71431 {
71432 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
71433 @@ -709,7 +709,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
71434 */
71435 static inline int skb_queue_empty(const struct sk_buff_head *list)
71436 {
71437 - return list->next == (struct sk_buff *)list;
71438 + return list->next == (const struct sk_buff *)list;
71439 }
71440
71441 /**
71442 @@ -722,7 +722,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
71443 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71444 const struct sk_buff *skb)
71445 {
71446 - return skb->next == (struct sk_buff *)list;
71447 + return skb->next == (const struct sk_buff *)list;
71448 }
71449
71450 /**
71451 @@ -735,7 +735,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71452 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
71453 const struct sk_buff *skb)
71454 {
71455 - return skb->prev == (struct sk_buff *)list;
71456 + return skb->prev == (const struct sk_buff *)list;
71457 }
71458
71459 /**
71460 @@ -1756,7 +1756,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
71461 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
71462 */
71463 #ifndef NET_SKB_PAD
71464 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
71465 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
71466 #endif
71467
71468 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
71469 @@ -2351,7 +2351,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
71470 int noblock, int *err);
71471 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
71472 struct poll_table_struct *wait);
71473 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
71474 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
71475 int offset, struct iovec *to,
71476 int size);
71477 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
71478 @@ -2641,6 +2641,9 @@ static inline void nf_reset(struct sk_buff *skb)
71479 nf_bridge_put(skb->nf_bridge);
71480 skb->nf_bridge = NULL;
71481 #endif
71482 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
71483 + skb->nf_trace = 0;
71484 +#endif
71485 }
71486
71487 static inline void nf_reset_trace(struct sk_buff *skb)
71488 diff --git a/include/linux/slab.h b/include/linux/slab.h
71489 index 5d168d7..720bff3 100644
71490 --- a/include/linux/slab.h
71491 +++ b/include/linux/slab.h
71492 @@ -12,13 +12,20 @@
71493 #include <linux/gfp.h>
71494 #include <linux/types.h>
71495 #include <linux/workqueue.h>
71496 -
71497 +#include <linux/err.h>
71498
71499 /*
71500 * Flags to pass to kmem_cache_create().
71501 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
71502 */
71503 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
71504 +
71505 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71506 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
71507 +#else
71508 +#define SLAB_USERCOPY 0x00000000UL
71509 +#endif
71510 +
71511 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
71512 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
71513 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
71514 @@ -89,10 +96,13 @@
71515 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
71516 * Both make kfree a no-op.
71517 */
71518 -#define ZERO_SIZE_PTR ((void *)16)
71519 +#define ZERO_SIZE_PTR \
71520 +({ \
71521 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
71522 + (void *)(-MAX_ERRNO-1L); \
71523 +})
71524
71525 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
71526 - (unsigned long)ZERO_SIZE_PTR)
71527 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
71528
71529 /*
71530 * Common fields provided in kmem_cache by all slab allocators
71531 @@ -112,7 +122,7 @@ struct kmem_cache {
71532 unsigned int align; /* Alignment as calculated */
71533 unsigned long flags; /* Active flags on the slab */
71534 const char *name; /* Slab name for sysfs */
71535 - int refcount; /* Use counter */
71536 + atomic_t refcount; /* Use counter */
71537 void (*ctor)(void *); /* Called on object slot creation */
71538 struct list_head list; /* List of all slab caches on the system */
71539 };
71540 @@ -232,6 +242,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
71541 void kfree(const void *);
71542 void kzfree(const void *);
71543 size_t ksize(const void *);
71544 +const char *check_heap_object(const void *ptr, unsigned long n);
71545 +bool is_usercopy_object(const void *ptr);
71546
71547 /*
71548 * Allocator specific definitions. These are mainly used to establish optimized
71549 @@ -311,6 +323,7 @@ size_t ksize(const void *);
71550 * for general use, and so are not documented here. For a full list of
71551 * potential flags, always refer to linux/gfp.h.
71552 */
71553 +
71554 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
71555 {
71556 if (size != 0 && n > SIZE_MAX / size)
71557 @@ -370,7 +383,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
71558 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71559 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71560 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71561 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71562 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
71563 #define kmalloc_track_caller(size, flags) \
71564 __kmalloc_track_caller(size, flags, _RET_IP_)
71565 #else
71566 @@ -390,7 +403,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71567 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71568 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71569 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71570 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
71571 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
71572 #define kmalloc_node_track_caller(size, flags, node) \
71573 __kmalloc_node_track_caller(size, flags, node, \
71574 _RET_IP_)
71575 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
71576 index 8bb6e0e..8eb0dbe 100644
71577 --- a/include/linux/slab_def.h
71578 +++ b/include/linux/slab_def.h
71579 @@ -52,7 +52,7 @@ struct kmem_cache {
71580 /* 4) cache creation/removal */
71581 const char *name;
71582 struct list_head list;
71583 - int refcount;
71584 + atomic_t refcount;
71585 int object_size;
71586 int align;
71587
71588 @@ -68,10 +68,10 @@ struct kmem_cache {
71589 unsigned long node_allocs;
71590 unsigned long node_frees;
71591 unsigned long node_overflow;
71592 - atomic_t allochit;
71593 - atomic_t allocmiss;
71594 - atomic_t freehit;
71595 - atomic_t freemiss;
71596 + atomic_unchecked_t allochit;
71597 + atomic_unchecked_t allocmiss;
71598 + atomic_unchecked_t freehit;
71599 + atomic_unchecked_t freemiss;
71600
71601 /*
71602 * If debugging is enabled, then the allocator can add additional
71603 @@ -111,11 +111,16 @@ struct cache_sizes {
71604 #ifdef CONFIG_ZONE_DMA
71605 struct kmem_cache *cs_dmacachep;
71606 #endif
71607 +
71608 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71609 + struct kmem_cache *cs_usercopycachep;
71610 +#endif
71611 +
71612 };
71613 extern struct cache_sizes malloc_sizes[];
71614
71615 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71616 -void *__kmalloc(size_t size, gfp_t flags);
71617 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
71618
71619 #ifdef CONFIG_TRACING
71620 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
71621 @@ -152,6 +157,13 @@ found:
71622 cachep = malloc_sizes[i].cs_dmacachep;
71623 else
71624 #endif
71625 +
71626 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71627 + if (flags & GFP_USERCOPY)
71628 + cachep = malloc_sizes[i].cs_usercopycachep;
71629 + else
71630 +#endif
71631 +
71632 cachep = malloc_sizes[i].cs_cachep;
71633
71634 ret = kmem_cache_alloc_trace(cachep, flags, size);
71635 @@ -162,7 +174,7 @@ found:
71636 }
71637
71638 #ifdef CONFIG_NUMA
71639 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
71640 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71641 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71642
71643 #ifdef CONFIG_TRACING
71644 @@ -205,6 +217,13 @@ found:
71645 cachep = malloc_sizes[i].cs_dmacachep;
71646 else
71647 #endif
71648 +
71649 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71650 + if (flags & GFP_USERCOPY)
71651 + cachep = malloc_sizes[i].cs_usercopycachep;
71652 + else
71653 +#endif
71654 +
71655 cachep = malloc_sizes[i].cs_cachep;
71656
71657 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
71658 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
71659 index f28e14a..7831211 100644
71660 --- a/include/linux/slob_def.h
71661 +++ b/include/linux/slob_def.h
71662 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
71663 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
71664 }
71665
71666 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71667 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71668
71669 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
71670 {
71671 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71672 return __kmalloc_node(size, flags, NUMA_NO_NODE);
71673 }
71674
71675 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
71676 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
71677 {
71678 return kmalloc(size, flags);
71679 }
71680 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
71681 index 9db4825..ed42fb5 100644
71682 --- a/include/linux/slub_def.h
71683 +++ b/include/linux/slub_def.h
71684 @@ -91,7 +91,7 @@ struct kmem_cache {
71685 struct kmem_cache_order_objects max;
71686 struct kmem_cache_order_objects min;
71687 gfp_t allocflags; /* gfp flags to use on each alloc */
71688 - int refcount; /* Refcount for slab cache destroy */
71689 + atomic_t refcount; /* Refcount for slab cache destroy */
71690 void (*ctor)(void *);
71691 int inuse; /* Offset to metadata */
71692 int align; /* Alignment */
71693 @@ -156,7 +156,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
71694 * Sorry that the following has to be that ugly but some versions of GCC
71695 * have trouble with constant propagation and loops.
71696 */
71697 -static __always_inline int kmalloc_index(size_t size)
71698 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
71699 {
71700 if (!size)
71701 return 0;
71702 @@ -221,7 +221,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
71703 }
71704
71705 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71706 -void *__kmalloc(size_t size, gfp_t flags);
71707 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
71708
71709 static __always_inline void *
71710 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
71711 @@ -265,7 +265,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
71712 }
71713 #endif
71714
71715 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
71716 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
71717 {
71718 unsigned int order = get_order(size);
71719 return kmalloc_order_trace(size, flags, order);
71720 @@ -290,7 +290,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71721 }
71722
71723 #ifdef CONFIG_NUMA
71724 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71725 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71726 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71727
71728 #ifdef CONFIG_TRACING
71729 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
71730 index e8d702e..0a56eb4 100644
71731 --- a/include/linux/sock_diag.h
71732 +++ b/include/linux/sock_diag.h
71733 @@ -10,7 +10,7 @@ struct sock;
71734 struct sock_diag_handler {
71735 __u8 family;
71736 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
71737 -};
71738 +} __do_const;
71739
71740 int sock_diag_register(const struct sock_diag_handler *h);
71741 void sock_diag_unregister(const struct sock_diag_handler *h);
71742 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
71743 index 680f9a3..f13aeb0 100644
71744 --- a/include/linux/sonet.h
71745 +++ b/include/linux/sonet.h
71746 @@ -7,7 +7,7 @@
71747 #include <uapi/linux/sonet.h>
71748
71749 struct k_sonet_stats {
71750 -#define __HANDLE_ITEM(i) atomic_t i
71751 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
71752 __SONET_ITEMS
71753 #undef __HANDLE_ITEM
71754 };
71755 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
71756 index 07d8e53..dc934c9 100644
71757 --- a/include/linux/sunrpc/addr.h
71758 +++ b/include/linux/sunrpc/addr.h
71759 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
71760 {
71761 switch (sap->sa_family) {
71762 case AF_INET:
71763 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
71764 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
71765 case AF_INET6:
71766 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
71767 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
71768 }
71769 return 0;
71770 }
71771 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
71772 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
71773 const struct sockaddr *src)
71774 {
71775 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
71776 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
71777 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
71778
71779 dsin->sin_family = ssin->sin_family;
71780 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
71781 if (sa->sa_family != AF_INET6)
71782 return 0;
71783
71784 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
71785 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
71786 }
71787
71788 #endif /* _LINUX_SUNRPC_ADDR_H */
71789 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
71790 index 2cf4ffa..470d140 100644
71791 --- a/include/linux/sunrpc/clnt.h
71792 +++ b/include/linux/sunrpc/clnt.h
71793 @@ -96,7 +96,7 @@ struct rpc_procinfo {
71794 unsigned int p_timer; /* Which RTT timer to use */
71795 u32 p_statidx; /* Which procedure to account */
71796 const char * p_name; /* name of procedure */
71797 -};
71798 +} __do_const;
71799
71800 #ifdef __KERNEL__
71801
71802 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
71803 index 1f0216b..6a4fa50 100644
71804 --- a/include/linux/sunrpc/svc.h
71805 +++ b/include/linux/sunrpc/svc.h
71806 @@ -411,7 +411,7 @@ struct svc_procedure {
71807 unsigned int pc_count; /* call count */
71808 unsigned int pc_cachetype; /* cache info (NFS) */
71809 unsigned int pc_xdrressize; /* maximum size of XDR reply */
71810 -};
71811 +} __do_const;
71812
71813 /*
71814 * Function prototypes.
71815 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
71816 index 0b8e3e6..33e0a01 100644
71817 --- a/include/linux/sunrpc/svc_rdma.h
71818 +++ b/include/linux/sunrpc/svc_rdma.h
71819 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
71820 extern unsigned int svcrdma_max_requests;
71821 extern unsigned int svcrdma_max_req_size;
71822
71823 -extern atomic_t rdma_stat_recv;
71824 -extern atomic_t rdma_stat_read;
71825 -extern atomic_t rdma_stat_write;
71826 -extern atomic_t rdma_stat_sq_starve;
71827 -extern atomic_t rdma_stat_rq_starve;
71828 -extern atomic_t rdma_stat_rq_poll;
71829 -extern atomic_t rdma_stat_rq_prod;
71830 -extern atomic_t rdma_stat_sq_poll;
71831 -extern atomic_t rdma_stat_sq_prod;
71832 +extern atomic_unchecked_t rdma_stat_recv;
71833 +extern atomic_unchecked_t rdma_stat_read;
71834 +extern atomic_unchecked_t rdma_stat_write;
71835 +extern atomic_unchecked_t rdma_stat_sq_starve;
71836 +extern atomic_unchecked_t rdma_stat_rq_starve;
71837 +extern atomic_unchecked_t rdma_stat_rq_poll;
71838 +extern atomic_unchecked_t rdma_stat_rq_prod;
71839 +extern atomic_unchecked_t rdma_stat_sq_poll;
71840 +extern atomic_unchecked_t rdma_stat_sq_prod;
71841
71842 #define RPCRDMA_VERSION 1
71843
71844 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
71845 index ff374ab..7fd2ecb 100644
71846 --- a/include/linux/sunrpc/svcauth.h
71847 +++ b/include/linux/sunrpc/svcauth.h
71848 @@ -109,7 +109,7 @@ struct auth_ops {
71849 int (*release)(struct svc_rqst *rq);
71850 void (*domain_release)(struct auth_domain *);
71851 int (*set_client)(struct svc_rqst *rq);
71852 -};
71853 +} __do_const;
71854
71855 #define SVC_GARBAGE 1
71856 #define SVC_SYSERR 2
71857 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
71858 index a5ffd32..0935dea 100644
71859 --- a/include/linux/swiotlb.h
71860 +++ b/include/linux/swiotlb.h
71861 @@ -60,7 +60,8 @@ extern void
71862
71863 extern void
71864 swiotlb_free_coherent(struct device *hwdev, size_t size,
71865 - void *vaddr, dma_addr_t dma_handle);
71866 + void *vaddr, dma_addr_t dma_handle,
71867 + struct dma_attrs *attrs);
71868
71869 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
71870 unsigned long offset, size_t size,
71871 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
71872 index 313a8e0..6b273a9 100644
71873 --- a/include/linux/syscalls.h
71874 +++ b/include/linux/syscalls.h
71875 @@ -418,11 +418,11 @@ asmlinkage long sys_sync(void);
71876 asmlinkage long sys_fsync(unsigned int fd);
71877 asmlinkage long sys_fdatasync(unsigned int fd);
71878 asmlinkage long sys_bdflush(int func, long data);
71879 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
71880 - char __user *type, unsigned long flags,
71881 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
71882 + const char __user *type, unsigned long flags,
71883 void __user *data);
71884 -asmlinkage long sys_umount(char __user *name, int flags);
71885 -asmlinkage long sys_oldumount(char __user *name);
71886 +asmlinkage long sys_umount(const char __user *name, int flags);
71887 +asmlinkage long sys_oldumount(const char __user *name);
71888 asmlinkage long sys_truncate(const char __user *path, long length);
71889 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
71890 asmlinkage long sys_stat(const char __user *filename,
71891 @@ -634,7 +634,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
71892 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
71893 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
71894 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
71895 - struct sockaddr __user *, int);
71896 + struct sockaddr __user *, int) __intentional_overflow(0);
71897 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
71898 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
71899 unsigned int vlen, unsigned flags);
71900 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
71901 index 27b3b0b..e093dd9 100644
71902 --- a/include/linux/syscore_ops.h
71903 +++ b/include/linux/syscore_ops.h
71904 @@ -16,7 +16,7 @@ struct syscore_ops {
71905 int (*suspend)(void);
71906 void (*resume)(void);
71907 void (*shutdown)(void);
71908 -};
71909 +} __do_const;
71910
71911 extern void register_syscore_ops(struct syscore_ops *ops);
71912 extern void unregister_syscore_ops(struct syscore_ops *ops);
71913 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
71914 index 14a8ff2..af52bad 100644
71915 --- a/include/linux/sysctl.h
71916 +++ b/include/linux/sysctl.h
71917 @@ -34,13 +34,13 @@ struct ctl_table_root;
71918 struct ctl_table_header;
71919 struct ctl_dir;
71920
71921 -typedef struct ctl_table ctl_table;
71922 -
71923 typedef int proc_handler (struct ctl_table *ctl, int write,
71924 void __user *buffer, size_t *lenp, loff_t *ppos);
71925
71926 extern int proc_dostring(struct ctl_table *, int,
71927 void __user *, size_t *, loff_t *);
71928 +extern int proc_dostring_modpriv(struct ctl_table *, int,
71929 + void __user *, size_t *, loff_t *);
71930 extern int proc_dointvec(struct ctl_table *, int,
71931 void __user *, size_t *, loff_t *);
71932 extern int proc_dointvec_minmax(struct ctl_table *, int,
71933 @@ -115,7 +115,9 @@ struct ctl_table
71934 struct ctl_table_poll *poll;
71935 void *extra1;
71936 void *extra2;
71937 -};
71938 +} __do_const;
71939 +typedef struct ctl_table __no_const ctl_table_no_const;
71940 +typedef struct ctl_table ctl_table;
71941
71942 struct ctl_node {
71943 struct rb_node node;
71944 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
71945 index e2cee22..3ddb921 100644
71946 --- a/include/linux/sysfs.h
71947 +++ b/include/linux/sysfs.h
71948 @@ -31,7 +31,8 @@ struct attribute {
71949 struct lock_class_key *key;
71950 struct lock_class_key skey;
71951 #endif
71952 -};
71953 +} __do_const;
71954 +typedef struct attribute __no_const attribute_no_const;
71955
71956 /**
71957 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
71958 @@ -59,8 +60,8 @@ struct attribute_group {
71959 umode_t (*is_visible)(struct kobject *,
71960 struct attribute *, int);
71961 struct attribute **attrs;
71962 -};
71963 -
71964 +} __do_const;
71965 +typedef struct attribute_group __no_const attribute_group_no_const;
71966
71967
71968 /**
71969 @@ -107,7 +108,8 @@ struct bin_attribute {
71970 char *, loff_t, size_t);
71971 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
71972 struct vm_area_struct *vma);
71973 -};
71974 +} __do_const;
71975 +typedef struct bin_attribute __no_const bin_attribute_no_const;
71976
71977 /**
71978 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
71979 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
71980 index 7faf933..9b85a0c 100644
71981 --- a/include/linux/sysrq.h
71982 +++ b/include/linux/sysrq.h
71983 @@ -16,6 +16,7 @@
71984
71985 #include <linux/errno.h>
71986 #include <linux/types.h>
71987 +#include <linux/compiler.h>
71988
71989 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
71990 #define SYSRQ_DEFAULT_ENABLE 1
71991 @@ -36,7 +37,7 @@ struct sysrq_key_op {
71992 char *help_msg;
71993 char *action_msg;
71994 int enable_mask;
71995 -};
71996 +} __do_const;
71997
71998 #ifdef CONFIG_MAGIC_SYSRQ
71999
72000 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
72001 index e7e0473..7989295 100644
72002 --- a/include/linux/thread_info.h
72003 +++ b/include/linux/thread_info.h
72004 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
72005 #error "no set_restore_sigmask() provided and default one won't work"
72006 #endif
72007
72008 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
72009 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
72010 +{
72011 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
72012 + if (!__builtin_constant_p(n))
72013 +#endif
72014 + __check_object_size(ptr, n, to_user);
72015 +}
72016 +
72017 #endif /* __KERNEL__ */
72018
72019 #endif /* _LINUX_THREAD_INFO_H */
72020 diff --git a/include/linux/tty.h b/include/linux/tty.h
72021 index c75d886..04cb148 100644
72022 --- a/include/linux/tty.h
72023 +++ b/include/linux/tty.h
72024 @@ -194,7 +194,7 @@ struct tty_port {
72025 const struct tty_port_operations *ops; /* Port operations */
72026 spinlock_t lock; /* Lock protecting tty field */
72027 int blocked_open; /* Waiting to open */
72028 - int count; /* Usage count */
72029 + atomic_t count; /* Usage count */
72030 wait_queue_head_t open_wait; /* Open waiters */
72031 wait_queue_head_t close_wait; /* Close waiters */
72032 wait_queue_head_t delta_msr_wait; /* Modem status change */
72033 @@ -515,7 +515,7 @@ extern int tty_port_open(struct tty_port *port,
72034 struct tty_struct *tty, struct file *filp);
72035 static inline int tty_port_users(struct tty_port *port)
72036 {
72037 - return port->count + port->blocked_open;
72038 + return atomic_read(&port->count) + port->blocked_open;
72039 }
72040
72041 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
72042 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
72043 index 756a609..b302dd6 100644
72044 --- a/include/linux/tty_driver.h
72045 +++ b/include/linux/tty_driver.h
72046 @@ -285,7 +285,7 @@ struct tty_operations {
72047 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
72048 #endif
72049 const struct file_operations *proc_fops;
72050 -};
72051 +} __do_const;
72052
72053 struct tty_driver {
72054 int magic; /* magic number for this structure */
72055 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
72056 index 455a0d7..bf97ff5 100644
72057 --- a/include/linux/tty_ldisc.h
72058 +++ b/include/linux/tty_ldisc.h
72059 @@ -146,7 +146,7 @@ struct tty_ldisc_ops {
72060
72061 struct module *owner;
72062
72063 - int refcount;
72064 + atomic_t refcount;
72065 };
72066
72067 struct tty_ldisc {
72068 diff --git a/include/linux/types.h b/include/linux/types.h
72069 index 4d118ba..c3ee9bf 100644
72070 --- a/include/linux/types.h
72071 +++ b/include/linux/types.h
72072 @@ -176,10 +176,26 @@ typedef struct {
72073 int counter;
72074 } atomic_t;
72075
72076 +#ifdef CONFIG_PAX_REFCOUNT
72077 +typedef struct {
72078 + int counter;
72079 +} atomic_unchecked_t;
72080 +#else
72081 +typedef atomic_t atomic_unchecked_t;
72082 +#endif
72083 +
72084 #ifdef CONFIG_64BIT
72085 typedef struct {
72086 long counter;
72087 } atomic64_t;
72088 +
72089 +#ifdef CONFIG_PAX_REFCOUNT
72090 +typedef struct {
72091 + long counter;
72092 +} atomic64_unchecked_t;
72093 +#else
72094 +typedef atomic64_t atomic64_unchecked_t;
72095 +#endif
72096 #endif
72097
72098 struct list_head {
72099 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
72100 index 5ca0951..ab496a5 100644
72101 --- a/include/linux/uaccess.h
72102 +++ b/include/linux/uaccess.h
72103 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
72104 long ret; \
72105 mm_segment_t old_fs = get_fs(); \
72106 \
72107 - set_fs(KERNEL_DS); \
72108 pagefault_disable(); \
72109 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
72110 - pagefault_enable(); \
72111 + set_fs(KERNEL_DS); \
72112 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
72113 set_fs(old_fs); \
72114 + pagefault_enable(); \
72115 ret; \
72116 })
72117
72118 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
72119 index 8e522cbc..aa8572d 100644
72120 --- a/include/linux/uidgid.h
72121 +++ b/include/linux/uidgid.h
72122 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
72123
72124 #endif /* CONFIG_USER_NS */
72125
72126 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
72127 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
72128 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
72129 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
72130 +
72131 #endif /* _LINUX_UIDGID_H */
72132 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
72133 index 99c1b4d..562e6f3 100644
72134 --- a/include/linux/unaligned/access_ok.h
72135 +++ b/include/linux/unaligned/access_ok.h
72136 @@ -4,34 +4,34 @@
72137 #include <linux/kernel.h>
72138 #include <asm/byteorder.h>
72139
72140 -static inline u16 get_unaligned_le16(const void *p)
72141 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
72142 {
72143 - return le16_to_cpup((__le16 *)p);
72144 + return le16_to_cpup((const __le16 *)p);
72145 }
72146
72147 -static inline u32 get_unaligned_le32(const void *p)
72148 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
72149 {
72150 - return le32_to_cpup((__le32 *)p);
72151 + return le32_to_cpup((const __le32 *)p);
72152 }
72153
72154 -static inline u64 get_unaligned_le64(const void *p)
72155 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
72156 {
72157 - return le64_to_cpup((__le64 *)p);
72158 + return le64_to_cpup((const __le64 *)p);
72159 }
72160
72161 -static inline u16 get_unaligned_be16(const void *p)
72162 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
72163 {
72164 - return be16_to_cpup((__be16 *)p);
72165 + return be16_to_cpup((const __be16 *)p);
72166 }
72167
72168 -static inline u32 get_unaligned_be32(const void *p)
72169 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
72170 {
72171 - return be32_to_cpup((__be32 *)p);
72172 + return be32_to_cpup((const __be32 *)p);
72173 }
72174
72175 -static inline u64 get_unaligned_be64(const void *p)
72176 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
72177 {
72178 - return be64_to_cpup((__be64 *)p);
72179 + return be64_to_cpup((const __be64 *)p);
72180 }
72181
72182 static inline void put_unaligned_le16(u16 val, void *p)
72183 diff --git a/include/linux/usb.h b/include/linux/usb.h
72184 index 4d22d0f..8d0e8f8 100644
72185 --- a/include/linux/usb.h
72186 +++ b/include/linux/usb.h
72187 @@ -554,7 +554,7 @@ struct usb_device {
72188 int maxchild;
72189
72190 u32 quirks;
72191 - atomic_t urbnum;
72192 + atomic_unchecked_t urbnum;
72193
72194 unsigned long active_duration;
72195
72196 @@ -1604,7 +1604,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
72197
72198 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
72199 __u8 request, __u8 requesttype, __u16 value, __u16 index,
72200 - void *data, __u16 size, int timeout);
72201 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
72202 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
72203 void *data, int len, int *actual_length, int timeout);
72204 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
72205 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
72206 index c5d36c6..108f4f9 100644
72207 --- a/include/linux/usb/renesas_usbhs.h
72208 +++ b/include/linux/usb/renesas_usbhs.h
72209 @@ -39,7 +39,7 @@ enum {
72210 */
72211 struct renesas_usbhs_driver_callback {
72212 int (*notify_hotplug)(struct platform_device *pdev);
72213 -};
72214 +} __no_const;
72215
72216 /*
72217 * callback functions for platform
72218 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
72219 index 6f8fbcf..8259001 100644
72220 --- a/include/linux/vermagic.h
72221 +++ b/include/linux/vermagic.h
72222 @@ -25,9 +25,35 @@
72223 #define MODULE_ARCH_VERMAGIC ""
72224 #endif
72225
72226 +#ifdef CONFIG_PAX_REFCOUNT
72227 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
72228 +#else
72229 +#define MODULE_PAX_REFCOUNT ""
72230 +#endif
72231 +
72232 +#ifdef CONSTIFY_PLUGIN
72233 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
72234 +#else
72235 +#define MODULE_CONSTIFY_PLUGIN ""
72236 +#endif
72237 +
72238 +#ifdef STACKLEAK_PLUGIN
72239 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
72240 +#else
72241 +#define MODULE_STACKLEAK_PLUGIN ""
72242 +#endif
72243 +
72244 +#ifdef CONFIG_GRKERNSEC
72245 +#define MODULE_GRSEC "GRSEC "
72246 +#else
72247 +#define MODULE_GRSEC ""
72248 +#endif
72249 +
72250 #define VERMAGIC_STRING \
72251 UTS_RELEASE " " \
72252 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
72253 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
72254 - MODULE_ARCH_VERMAGIC
72255 + MODULE_ARCH_VERMAGIC \
72256 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
72257 + MODULE_GRSEC
72258
72259 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
72260 index 6071e91..ca6a489 100644
72261 --- a/include/linux/vmalloc.h
72262 +++ b/include/linux/vmalloc.h
72263 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
72264 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
72265 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
72266 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
72267 +
72268 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
72269 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
72270 +#endif
72271 +
72272 /* bits [20..32] reserved for arch specific ioremap internals */
72273
72274 /*
72275 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
72276 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
72277 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
72278 unsigned long start, unsigned long end, gfp_t gfp_mask,
72279 - pgprot_t prot, int node, const void *caller);
72280 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
72281 extern void vfree(const void *addr);
72282
72283 extern void *vmap(struct page **pages, unsigned int count,
72284 @@ -124,8 +129,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
72285 extern void free_vm_area(struct vm_struct *area);
72286
72287 /* for /dev/kmem */
72288 -extern long vread(char *buf, char *addr, unsigned long count);
72289 -extern long vwrite(char *buf, char *addr, unsigned long count);
72290 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
72291 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
72292
72293 /*
72294 * Internals. Dont't use..
72295 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
72296 index 5fd71a7..e5ef9a9 100644
72297 --- a/include/linux/vmstat.h
72298 +++ b/include/linux/vmstat.h
72299 @@ -95,18 +95,18 @@ static inline void vm_events_fold_cpu(int cpu)
72300 /*
72301 * Zone based page accounting with per cpu differentials.
72302 */
72303 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72304 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72305
72306 static inline void zone_page_state_add(long x, struct zone *zone,
72307 enum zone_stat_item item)
72308 {
72309 - atomic_long_add(x, &zone->vm_stat[item]);
72310 - atomic_long_add(x, &vm_stat[item]);
72311 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
72312 + atomic_long_add_unchecked(x, &vm_stat[item]);
72313 }
72314
72315 static inline unsigned long global_page_state(enum zone_stat_item item)
72316 {
72317 - long x = atomic_long_read(&vm_stat[item]);
72318 + long x = atomic_long_read_unchecked(&vm_stat[item]);
72319 #ifdef CONFIG_SMP
72320 if (x < 0)
72321 x = 0;
72322 @@ -117,7 +117,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
72323 static inline unsigned long zone_page_state(struct zone *zone,
72324 enum zone_stat_item item)
72325 {
72326 - long x = atomic_long_read(&zone->vm_stat[item]);
72327 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72328 #ifdef CONFIG_SMP
72329 if (x < 0)
72330 x = 0;
72331 @@ -134,7 +134,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
72332 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
72333 enum zone_stat_item item)
72334 {
72335 - long x = atomic_long_read(&zone->vm_stat[item]);
72336 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72337
72338 #ifdef CONFIG_SMP
72339 int cpu;
72340 @@ -226,8 +226,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
72341
72342 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
72343 {
72344 - atomic_long_inc(&zone->vm_stat[item]);
72345 - atomic_long_inc(&vm_stat[item]);
72346 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
72347 + atomic_long_inc_unchecked(&vm_stat[item]);
72348 }
72349
72350 static inline void __inc_zone_page_state(struct page *page,
72351 @@ -238,8 +238,8 @@ static inline void __inc_zone_page_state(struct page *page,
72352
72353 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
72354 {
72355 - atomic_long_dec(&zone->vm_stat[item]);
72356 - atomic_long_dec(&vm_stat[item]);
72357 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
72358 + atomic_long_dec_unchecked(&vm_stat[item]);
72359 }
72360
72361 static inline void __dec_zone_page_state(struct page *page,
72362 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
72363 index fdbafc6..49dfe4f 100644
72364 --- a/include/linux/xattr.h
72365 +++ b/include/linux/xattr.h
72366 @@ -28,7 +28,7 @@ struct xattr_handler {
72367 size_t size, int handler_flags);
72368 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
72369 size_t size, int flags, int handler_flags);
72370 -};
72371 +} __do_const;
72372
72373 struct xattr {
72374 char *name;
72375 @@ -37,6 +37,9 @@ struct xattr {
72376 };
72377
72378 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
72379 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
72380 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
72381 +#endif
72382 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
72383 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
72384 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
72385 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
72386 index 9c5a6b4..09c9438 100644
72387 --- a/include/linux/zlib.h
72388 +++ b/include/linux/zlib.h
72389 @@ -31,6 +31,7 @@
72390 #define _ZLIB_H
72391
72392 #include <linux/zconf.h>
72393 +#include <linux/compiler.h>
72394
72395 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
72396 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
72397 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
72398
72399 /* basic functions */
72400
72401 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
72402 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
72403 /*
72404 Returns the number of bytes that needs to be allocated for a per-
72405 stream workspace with the specified parameters. A pointer to this
72406 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
72407 index 95d1c91..6798cca 100644
72408 --- a/include/media/v4l2-dev.h
72409 +++ b/include/media/v4l2-dev.h
72410 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
72411 int (*mmap) (struct file *, struct vm_area_struct *);
72412 int (*open) (struct file *);
72413 int (*release) (struct file *);
72414 -};
72415 +} __do_const;
72416
72417 /*
72418 * Newer version of video_device, handled by videodev2.c
72419 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
72420 index 4118ad1..cb7e25f 100644
72421 --- a/include/media/v4l2-ioctl.h
72422 +++ b/include/media/v4l2-ioctl.h
72423 @@ -284,7 +284,6 @@ struct v4l2_ioctl_ops {
72424 bool valid_prio, int cmd, void *arg);
72425 };
72426
72427 -
72428 /* v4l debugging and diagnostics */
72429
72430 /* Debug bitmask flags to be used on V4L2 */
72431 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
72432 index adcbb20..62c2559 100644
72433 --- a/include/net/9p/transport.h
72434 +++ b/include/net/9p/transport.h
72435 @@ -57,7 +57,7 @@ struct p9_trans_module {
72436 int (*cancel) (struct p9_client *, struct p9_req_t *req);
72437 int (*zc_request)(struct p9_client *, struct p9_req_t *,
72438 char *, char *, int , int, int, int);
72439 -};
72440 +} __do_const;
72441
72442 void v9fs_register_trans(struct p9_trans_module *m);
72443 void v9fs_unregister_trans(struct p9_trans_module *m);
72444 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
72445 index cdd3302..76f8ede 100644
72446 --- a/include/net/bluetooth/l2cap.h
72447 +++ b/include/net/bluetooth/l2cap.h
72448 @@ -551,7 +551,7 @@ struct l2cap_ops {
72449 void (*defer) (struct l2cap_chan *chan);
72450 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
72451 unsigned long len, int nb);
72452 -};
72453 +} __do_const;
72454
72455 struct l2cap_conn {
72456 struct hci_conn *hcon;
72457 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
72458 index 9e5425b..8136ffc 100644
72459 --- a/include/net/caif/cfctrl.h
72460 +++ b/include/net/caif/cfctrl.h
72461 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
72462 void (*radioset_rsp)(void);
72463 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
72464 struct cflayer *client_layer);
72465 -};
72466 +} __no_const;
72467
72468 /* Link Setup Parameters for CAIF-Links. */
72469 struct cfctrl_link_param {
72470 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
72471 struct cfctrl {
72472 struct cfsrvl serv;
72473 struct cfctrl_rsp res;
72474 - atomic_t req_seq_no;
72475 - atomic_t rsp_seq_no;
72476 + atomic_unchecked_t req_seq_no;
72477 + atomic_unchecked_t rsp_seq_no;
72478 struct list_head list;
72479 /* Protects from simultaneous access to first_req list */
72480 spinlock_t info_list_lock;
72481 diff --git a/include/net/flow.h b/include/net/flow.h
72482 index 628e11b..4c475df 100644
72483 --- a/include/net/flow.h
72484 +++ b/include/net/flow.h
72485 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
72486
72487 extern void flow_cache_flush(void);
72488 extern void flow_cache_flush_deferred(void);
72489 -extern atomic_t flow_cache_genid;
72490 +extern atomic_unchecked_t flow_cache_genid;
72491
72492 #endif
72493 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
72494 index bdfbe68..4402ebe 100644
72495 --- a/include/net/genetlink.h
72496 +++ b/include/net/genetlink.h
72497 @@ -118,7 +118,7 @@ struct genl_ops {
72498 struct netlink_callback *cb);
72499 int (*done)(struct netlink_callback *cb);
72500 struct list_head ops_list;
72501 -};
72502 +} __do_const;
72503
72504 extern int genl_register_family(struct genl_family *family);
72505 extern int genl_register_family_with_ops(struct genl_family *family,
72506 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
72507 index 734d9b5..48a9a4b 100644
72508 --- a/include/net/gro_cells.h
72509 +++ b/include/net/gro_cells.h
72510 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
72511 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
72512
72513 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
72514 - atomic_long_inc(&dev->rx_dropped);
72515 + atomic_long_inc_unchecked(&dev->rx_dropped);
72516 kfree_skb(skb);
72517 return;
72518 }
72519 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
72520 index 1832927..ce39aea 100644
72521 --- a/include/net/inet_connection_sock.h
72522 +++ b/include/net/inet_connection_sock.h
72523 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
72524 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
72525 int (*bind_conflict)(const struct sock *sk,
72526 const struct inet_bind_bucket *tb, bool relax);
72527 -};
72528 +} __do_const;
72529
72530 /** inet_connection_sock - INET connection oriented sock
72531 *
72532 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
72533 index 53f464d..ba76aaa 100644
72534 --- a/include/net/inetpeer.h
72535 +++ b/include/net/inetpeer.h
72536 @@ -47,8 +47,8 @@ struct inet_peer {
72537 */
72538 union {
72539 struct {
72540 - atomic_t rid; /* Frag reception counter */
72541 - atomic_t ip_id_count; /* IP ID for the next packet */
72542 + atomic_unchecked_t rid; /* Frag reception counter */
72543 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
72544 };
72545 struct rcu_head rcu;
72546 struct inet_peer *gc_next;
72547 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
72548 more++;
72549 inet_peer_refcheck(p);
72550 do {
72551 - old = atomic_read(&p->ip_id_count);
72552 + old = atomic_read_unchecked(&p->ip_id_count);
72553 new = old + more;
72554 if (!new)
72555 new = 1;
72556 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
72557 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
72558 return new;
72559 }
72560
72561 diff --git a/include/net/ip.h b/include/net/ip.h
72562 index a68f838..74518ab 100644
72563 --- a/include/net/ip.h
72564 +++ b/include/net/ip.h
72565 @@ -202,7 +202,7 @@ extern struct local_ports {
72566 } sysctl_local_ports;
72567 extern void inet_get_local_port_range(int *low, int *high);
72568
72569 -extern unsigned long *sysctl_local_reserved_ports;
72570 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
72571 static inline int inet_is_reserved_local_port(int port)
72572 {
72573 return test_bit(port, sysctl_local_reserved_ports);
72574 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
72575 index e49db91..76a81de 100644
72576 --- a/include/net/ip_fib.h
72577 +++ b/include/net/ip_fib.h
72578 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
72579
72580 #define FIB_RES_SADDR(net, res) \
72581 ((FIB_RES_NH(res).nh_saddr_genid == \
72582 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
72583 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
72584 FIB_RES_NH(res).nh_saddr : \
72585 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
72586 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
72587 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
72588 index fce8e6b..3ca4916 100644
72589 --- a/include/net/ip_vs.h
72590 +++ b/include/net/ip_vs.h
72591 @@ -599,7 +599,7 @@ struct ip_vs_conn {
72592 struct ip_vs_conn *control; /* Master control connection */
72593 atomic_t n_control; /* Number of controlled ones */
72594 struct ip_vs_dest *dest; /* real server */
72595 - atomic_t in_pkts; /* incoming packet counter */
72596 + atomic_unchecked_t in_pkts; /* incoming packet counter */
72597
72598 /* packet transmitter for different forwarding methods. If it
72599 mangles the packet, it must return NF_DROP or better NF_STOLEN,
72600 @@ -737,7 +737,7 @@ struct ip_vs_dest {
72601 __be16 port; /* port number of the server */
72602 union nf_inet_addr addr; /* IP address of the server */
72603 volatile unsigned int flags; /* dest status flags */
72604 - atomic_t conn_flags; /* flags to copy to conn */
72605 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
72606 atomic_t weight; /* server weight */
72607
72608 atomic_t refcnt; /* reference counter */
72609 @@ -981,11 +981,11 @@ struct netns_ipvs {
72610 /* ip_vs_lblc */
72611 int sysctl_lblc_expiration;
72612 struct ctl_table_header *lblc_ctl_header;
72613 - struct ctl_table *lblc_ctl_table;
72614 + ctl_table_no_const *lblc_ctl_table;
72615 /* ip_vs_lblcr */
72616 int sysctl_lblcr_expiration;
72617 struct ctl_table_header *lblcr_ctl_header;
72618 - struct ctl_table *lblcr_ctl_table;
72619 + ctl_table_no_const *lblcr_ctl_table;
72620 /* ip_vs_est */
72621 struct list_head est_list; /* estimator list */
72622 spinlock_t est_lock;
72623 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
72624 index 80ffde3..968b0f4 100644
72625 --- a/include/net/irda/ircomm_tty.h
72626 +++ b/include/net/irda/ircomm_tty.h
72627 @@ -35,6 +35,7 @@
72628 #include <linux/termios.h>
72629 #include <linux/timer.h>
72630 #include <linux/tty.h> /* struct tty_struct */
72631 +#include <asm/local.h>
72632
72633 #include <net/irda/irias_object.h>
72634 #include <net/irda/ircomm_core.h>
72635 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
72636 index 714cc9a..ea05f3e 100644
72637 --- a/include/net/iucv/af_iucv.h
72638 +++ b/include/net/iucv/af_iucv.h
72639 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
72640 struct iucv_sock_list {
72641 struct hlist_head head;
72642 rwlock_t lock;
72643 - atomic_t autobind_name;
72644 + atomic_unchecked_t autobind_name;
72645 };
72646
72647 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
72648 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
72649 index df83f69..9b640b8 100644
72650 --- a/include/net/llc_c_ac.h
72651 +++ b/include/net/llc_c_ac.h
72652 @@ -87,7 +87,7 @@
72653 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
72654 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
72655
72656 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72657 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72658
72659 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
72660 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
72661 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
72662 index 6ca3113..f8026dd 100644
72663 --- a/include/net/llc_c_ev.h
72664 +++ b/include/net/llc_c_ev.h
72665 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
72666 return (struct llc_conn_state_ev *)skb->cb;
72667 }
72668
72669 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72670 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72671 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72672 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72673
72674 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
72675 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
72676 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
72677 index 0e79cfb..f46db31 100644
72678 --- a/include/net/llc_c_st.h
72679 +++ b/include/net/llc_c_st.h
72680 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
72681 u8 next_state;
72682 llc_conn_ev_qfyr_t *ev_qualifiers;
72683 llc_conn_action_t *ev_actions;
72684 -};
72685 +} __do_const;
72686
72687 struct llc_conn_state {
72688 u8 current_state;
72689 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
72690 index 37a3bbd..55a4241 100644
72691 --- a/include/net/llc_s_ac.h
72692 +++ b/include/net/llc_s_ac.h
72693 @@ -23,7 +23,7 @@
72694 #define SAP_ACT_TEST_IND 9
72695
72696 /* All action functions must look like this */
72697 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72698 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72699
72700 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
72701 struct sk_buff *skb);
72702 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
72703 index 567c681..cd73ac0 100644
72704 --- a/include/net/llc_s_st.h
72705 +++ b/include/net/llc_s_st.h
72706 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
72707 llc_sap_ev_t ev;
72708 u8 next_state;
72709 llc_sap_action_t *ev_actions;
72710 -};
72711 +} __do_const;
72712
72713 struct llc_sap_state {
72714 u8 curr_state;
72715 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
72716 index f7eba13..91ed983 100644
72717 --- a/include/net/mac80211.h
72718 +++ b/include/net/mac80211.h
72719 @@ -4119,7 +4119,7 @@ struct rate_control_ops {
72720 void (*add_sta_debugfs)(void *priv, void *priv_sta,
72721 struct dentry *dir);
72722 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
72723 -};
72724 +} __do_const;
72725
72726 static inline int rate_supported(struct ieee80211_sta *sta,
72727 enum ieee80211_band band,
72728 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
72729 index 7e748ad..5c6229b 100644
72730 --- a/include/net/neighbour.h
72731 +++ b/include/net/neighbour.h
72732 @@ -123,7 +123,7 @@ struct neigh_ops {
72733 void (*error_report)(struct neighbour *, struct sk_buff *);
72734 int (*output)(struct neighbour *, struct sk_buff *);
72735 int (*connected_output)(struct neighbour *, struct sk_buff *);
72736 -};
72737 +} __do_const;
72738
72739 struct pneigh_entry {
72740 struct pneigh_entry *next;
72741 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
72742 index de644bc..dfbcc4c 100644
72743 --- a/include/net/net_namespace.h
72744 +++ b/include/net/net_namespace.h
72745 @@ -115,7 +115,7 @@ struct net {
72746 #endif
72747 struct netns_ipvs *ipvs;
72748 struct sock *diag_nlsk;
72749 - atomic_t rt_genid;
72750 + atomic_unchecked_t rt_genid;
72751 };
72752
72753 /*
72754 @@ -272,7 +272,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
72755 #define __net_init __init
72756 #define __net_exit __exit_refok
72757 #define __net_initdata __initdata
72758 +#ifdef CONSTIFY_PLUGIN
72759 #define __net_initconst __initconst
72760 +#else
72761 +#define __net_initconst __initdata
72762 +#endif
72763 #endif
72764
72765 struct pernet_operations {
72766 @@ -282,7 +286,7 @@ struct pernet_operations {
72767 void (*exit_batch)(struct list_head *net_exit_list);
72768 int *id;
72769 size_t size;
72770 -};
72771 +} __do_const;
72772
72773 /*
72774 * Use these carefully. If you implement a network device and it
72775 @@ -330,12 +334,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
72776
72777 static inline int rt_genid(struct net *net)
72778 {
72779 - return atomic_read(&net->rt_genid);
72780 + return atomic_read_unchecked(&net->rt_genid);
72781 }
72782
72783 static inline void rt_genid_bump(struct net *net)
72784 {
72785 - atomic_inc(&net->rt_genid);
72786 + atomic_inc_unchecked(&net->rt_genid);
72787 }
72788
72789 #endif /* __NET_NET_NAMESPACE_H */
72790 diff --git a/include/net/netdma.h b/include/net/netdma.h
72791 index 8ba8ce2..99b7fff 100644
72792 --- a/include/net/netdma.h
72793 +++ b/include/net/netdma.h
72794 @@ -24,7 +24,7 @@
72795 #include <linux/dmaengine.h>
72796 #include <linux/skbuff.h>
72797
72798 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72799 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72800 struct sk_buff *skb, int offset, struct iovec *to,
72801 size_t len, struct dma_pinned_list *pinned_list);
72802
72803 diff --git a/include/net/netlink.h b/include/net/netlink.h
72804 index 9690b0f..87aded7 100644
72805 --- a/include/net/netlink.h
72806 +++ b/include/net/netlink.h
72807 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
72808 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
72809 {
72810 if (mark)
72811 - skb_trim(skb, (unsigned char *) mark - skb->data);
72812 + skb_trim(skb, (const unsigned char *) mark - skb->data);
72813 }
72814
72815 /**
72816 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
72817 index c9c0c53..53f24c3 100644
72818 --- a/include/net/netns/conntrack.h
72819 +++ b/include/net/netns/conntrack.h
72820 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
72821 struct nf_proto_net {
72822 #ifdef CONFIG_SYSCTL
72823 struct ctl_table_header *ctl_table_header;
72824 - struct ctl_table *ctl_table;
72825 + ctl_table_no_const *ctl_table;
72826 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
72827 struct ctl_table_header *ctl_compat_header;
72828 - struct ctl_table *ctl_compat_table;
72829 + ctl_table_no_const *ctl_compat_table;
72830 #endif
72831 #endif
72832 unsigned int users;
72833 @@ -58,7 +58,7 @@ struct nf_ip_net {
72834 struct nf_icmp_net icmpv6;
72835 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
72836 struct ctl_table_header *ctl_table_header;
72837 - struct ctl_table *ctl_table;
72838 + ctl_table_no_const *ctl_table;
72839 #endif
72840 };
72841
72842 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
72843 index 2ba9de8..47bd6c7 100644
72844 --- a/include/net/netns/ipv4.h
72845 +++ b/include/net/netns/ipv4.h
72846 @@ -67,7 +67,7 @@ struct netns_ipv4 {
72847 kgid_t sysctl_ping_group_range[2];
72848 long sysctl_tcp_mem[3];
72849
72850 - atomic_t dev_addr_genid;
72851 + atomic_unchecked_t dev_addr_genid;
72852
72853 #ifdef CONFIG_IP_MROUTE
72854 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
72855 diff --git a/include/net/protocol.h b/include/net/protocol.h
72856 index 047c047..b9dad15 100644
72857 --- a/include/net/protocol.h
72858 +++ b/include/net/protocol.h
72859 @@ -44,7 +44,7 @@ struct net_protocol {
72860 void (*err_handler)(struct sk_buff *skb, u32 info);
72861 unsigned int no_policy:1,
72862 netns_ok:1;
72863 -};
72864 +} __do_const;
72865
72866 #if IS_ENABLED(CONFIG_IPV6)
72867 struct inet6_protocol {
72868 @@ -57,7 +57,7 @@ struct inet6_protocol {
72869 u8 type, u8 code, int offset,
72870 __be32 info);
72871 unsigned int flags; /* INET6_PROTO_xxx */
72872 -};
72873 +} __do_const;
72874
72875 #define INET6_PROTO_NOPOLICY 0x1
72876 #define INET6_PROTO_FINAL 0x2
72877 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
72878 index 5a15fab..d799ea7 100644
72879 --- a/include/net/rtnetlink.h
72880 +++ b/include/net/rtnetlink.h
72881 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
72882 const struct net_device *dev);
72883 unsigned int (*get_num_tx_queues)(void);
72884 unsigned int (*get_num_rx_queues)(void);
72885 -};
72886 +} __do_const;
72887
72888 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
72889 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
72890 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
72891 index df85a0c..19ac300 100644
72892 --- a/include/net/sctp/sctp.h
72893 +++ b/include/net/sctp/sctp.h
72894 @@ -330,9 +330,9 @@ do { \
72895
72896 #else /* SCTP_DEBUG */
72897
72898 -#define SCTP_DEBUG_PRINTK(whatever...)
72899 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
72900 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
72901 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
72902 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
72903 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
72904 #define SCTP_ENABLE_DEBUG
72905 #define SCTP_DISABLE_DEBUG
72906 #define SCTP_ASSERT(expr, str, func)
72907 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
72908 index 2a82d13..62a31c2 100644
72909 --- a/include/net/sctp/sm.h
72910 +++ b/include/net/sctp/sm.h
72911 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
72912 typedef struct {
72913 sctp_state_fn_t *fn;
72914 const char *name;
72915 -} sctp_sm_table_entry_t;
72916 +} __do_const sctp_sm_table_entry_t;
72917
72918 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
72919 * currently in use.
72920 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
72921 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
72922
72923 /* Extern declarations for major data structures. */
72924 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
72925 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
72926
72927
72928 /* Get the size of a DATA chunk payload. */
72929 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
72930 index 0e0f9d2..cd05ebb 100644
72931 --- a/include/net/sctp/structs.h
72932 +++ b/include/net/sctp/structs.h
72933 @@ -517,7 +517,7 @@ struct sctp_pf {
72934 struct sctp_association *asoc);
72935 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
72936 struct sctp_af *af;
72937 -};
72938 +} __do_const;
72939
72940
72941 /* Structure to track chunk fragments that have been acked, but peer
72942 diff --git a/include/net/secure_seq.h b/include/net/secure_seq.h
72943 index c2e542b..6ca975b 100644
72944 --- a/include/net/secure_seq.h
72945 +++ b/include/net/secure_seq.h
72946 @@ -3,6 +3,7 @@
72947
72948 #include <linux/types.h>
72949
72950 +extern void net_secret_init(void);
72951 extern __u32 secure_ip_id(__be32 daddr);
72952 extern __u32 secure_ipv6_id(const __be32 daddr[4]);
72953 extern u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
72954 diff --git a/include/net/sock.h b/include/net/sock.h
72955 index 0be480a..586232f 100644
72956 --- a/include/net/sock.h
72957 +++ b/include/net/sock.h
72958 @@ -325,7 +325,7 @@ struct sock {
72959 #ifdef CONFIG_RPS
72960 __u32 sk_rxhash;
72961 #endif
72962 - atomic_t sk_drops;
72963 + atomic_unchecked_t sk_drops;
72964 int sk_rcvbuf;
72965
72966 struct sk_filter __rcu *sk_filter;
72967 @@ -1796,7 +1796,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
72968 }
72969
72970 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
72971 - char __user *from, char *to,
72972 + char __user *from, unsigned char *to,
72973 int copy, int offset)
72974 {
72975 if (skb->ip_summed == CHECKSUM_NONE) {
72976 @@ -2055,7 +2055,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
72977 }
72978 }
72979
72980 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
72981 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
72982
72983 /**
72984 * sk_page_frag - return an appropriate page_frag
72985 diff --git a/include/net/tcp.h b/include/net/tcp.h
72986 index a345480..3c65cf4 100644
72987 --- a/include/net/tcp.h
72988 +++ b/include/net/tcp.h
72989 @@ -529,7 +529,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
72990 extern void tcp_xmit_retransmit_queue(struct sock *);
72991 extern void tcp_simple_retransmit(struct sock *);
72992 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
72993 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
72994 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
72995
72996 extern void tcp_send_probe0(struct sock *);
72997 extern void tcp_send_partial(struct sock *);
72998 @@ -700,8 +700,8 @@ struct tcp_skb_cb {
72999 struct inet6_skb_parm h6;
73000 #endif
73001 } header; /* For incoming frames */
73002 - __u32 seq; /* Starting sequence number */
73003 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
73004 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
73005 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
73006 __u32 when; /* used to compute rtt's */
73007 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
73008
73009 @@ -715,7 +715,7 @@ struct tcp_skb_cb {
73010
73011 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
73012 /* 1 byte hole */
73013 - __u32 ack_seq; /* Sequence number ACK'd */
73014 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
73015 };
73016
73017 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
73018 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
73019 index 24c8886..e6fb816 100644
73020 --- a/include/net/xfrm.h
73021 +++ b/include/net/xfrm.h
73022 @@ -304,7 +304,7 @@ struct xfrm_policy_afinfo {
73023 struct net_device *dev,
73024 const struct flowi *fl);
73025 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
73026 -};
73027 +} __do_const;
73028
73029 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
73030 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
73031 @@ -340,7 +340,7 @@ struct xfrm_state_afinfo {
73032 struct sk_buff *skb);
73033 int (*transport_finish)(struct sk_buff *skb,
73034 int async);
73035 -};
73036 +} __do_const;
73037
73038 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
73039 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
73040 @@ -423,7 +423,7 @@ struct xfrm_mode {
73041 struct module *owner;
73042 unsigned int encap;
73043 int flags;
73044 -};
73045 +} __do_const;
73046
73047 /* Flags for xfrm_mode. */
73048 enum {
73049 @@ -520,7 +520,7 @@ struct xfrm_policy {
73050 struct timer_list timer;
73051
73052 struct flow_cache_object flo;
73053 - atomic_t genid;
73054 + atomic_unchecked_t genid;
73055 u32 priority;
73056 u32 index;
73057 struct xfrm_mark mark;
73058 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
73059 index 1a046b1..ee0bef0 100644
73060 --- a/include/rdma/iw_cm.h
73061 +++ b/include/rdma/iw_cm.h
73062 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
73063 int backlog);
73064
73065 int (*destroy_listen)(struct iw_cm_id *cm_id);
73066 -};
73067 +} __no_const;
73068
73069 /**
73070 * iw_create_cm_id - Create an IW CM identifier.
73071 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
73072 index e1379b4..67eafbe 100644
73073 --- a/include/scsi/libfc.h
73074 +++ b/include/scsi/libfc.h
73075 @@ -762,6 +762,7 @@ struct libfc_function_template {
73076 */
73077 void (*disc_stop_final) (struct fc_lport *);
73078 };
73079 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
73080
73081 /**
73082 * struct fc_disc - Discovery context
73083 @@ -866,7 +867,7 @@ struct fc_lport {
73084 struct fc_vport *vport;
73085
73086 /* Operational Information */
73087 - struct libfc_function_template tt;
73088 + libfc_function_template_no_const tt;
73089 u8 link_up;
73090 u8 qfull;
73091 enum fc_lport_state state;
73092 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
73093 index a7f9cba..b1f44d0 100644
73094 --- a/include/scsi/scsi_device.h
73095 +++ b/include/scsi/scsi_device.h
73096 @@ -171,9 +171,9 @@ struct scsi_device {
73097 unsigned int max_device_blocked; /* what device_blocked counts down from */
73098 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
73099
73100 - atomic_t iorequest_cnt;
73101 - atomic_t iodone_cnt;
73102 - atomic_t ioerr_cnt;
73103 + atomic_unchecked_t iorequest_cnt;
73104 + atomic_unchecked_t iodone_cnt;
73105 + atomic_unchecked_t ioerr_cnt;
73106
73107 struct device sdev_gendev,
73108 sdev_dev;
73109 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
73110 index b797e8f..8e2c3aa 100644
73111 --- a/include/scsi/scsi_transport_fc.h
73112 +++ b/include/scsi/scsi_transport_fc.h
73113 @@ -751,7 +751,8 @@ struct fc_function_template {
73114 unsigned long show_host_system_hostname:1;
73115
73116 unsigned long disable_target_scan:1;
73117 -};
73118 +} __do_const;
73119 +typedef struct fc_function_template __no_const fc_function_template_no_const;
73120
73121
73122 /**
73123 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
73124 index ff6c741..393815f 100644
73125 --- a/include/sound/compress_driver.h
73126 +++ b/include/sound/compress_driver.h
73127 @@ -130,7 +130,7 @@ struct snd_compr_ops {
73128 struct snd_compr_caps *caps);
73129 int (*get_codec_caps) (struct snd_compr_stream *stream,
73130 struct snd_compr_codec_caps *codec);
73131 -};
73132 +} __no_const;
73133
73134 /**
73135 * struct snd_compr: Compressed device
73136 diff --git a/include/sound/soc.h b/include/sound/soc.h
73137 index a6a059c..2243336 100644
73138 --- a/include/sound/soc.h
73139 +++ b/include/sound/soc.h
73140 @@ -771,7 +771,7 @@ struct snd_soc_codec_driver {
73141 /* probe ordering - for components with runtime dependencies */
73142 int probe_order;
73143 int remove_order;
73144 -};
73145 +} __do_const;
73146
73147 /* SoC platform interface */
73148 struct snd_soc_platform_driver {
73149 @@ -817,7 +817,7 @@ struct snd_soc_platform_driver {
73150 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
73151 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
73152 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
73153 -};
73154 +} __do_const;
73155
73156 struct snd_soc_platform {
73157 const char *name;
73158 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
73159 index c4af592..20c52d2 100644
73160 --- a/include/target/target_core_base.h
73161 +++ b/include/target/target_core_base.h
73162 @@ -657,7 +657,7 @@ struct se_device {
73163 spinlock_t stats_lock;
73164 /* Active commands on this virtual SE device */
73165 atomic_t simple_cmds;
73166 - atomic_t dev_ordered_id;
73167 + atomic_unchecked_t dev_ordered_id;
73168 atomic_t dev_ordered_sync;
73169 atomic_t dev_qf_count;
73170 int export_count;
73171 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
73172 new file mode 100644
73173 index 0000000..fb634b7
73174 --- /dev/null
73175 +++ b/include/trace/events/fs.h
73176 @@ -0,0 +1,53 @@
73177 +#undef TRACE_SYSTEM
73178 +#define TRACE_SYSTEM fs
73179 +
73180 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
73181 +#define _TRACE_FS_H
73182 +
73183 +#include <linux/fs.h>
73184 +#include <linux/tracepoint.h>
73185 +
73186 +TRACE_EVENT(do_sys_open,
73187 +
73188 + TP_PROTO(const char *filename, int flags, int mode),
73189 +
73190 + TP_ARGS(filename, flags, mode),
73191 +
73192 + TP_STRUCT__entry(
73193 + __string( filename, filename )
73194 + __field( int, flags )
73195 + __field( int, mode )
73196 + ),
73197 +
73198 + TP_fast_assign(
73199 + __assign_str(filename, filename);
73200 + __entry->flags = flags;
73201 + __entry->mode = mode;
73202 + ),
73203 +
73204 + TP_printk("\"%s\" %x %o",
73205 + __get_str(filename), __entry->flags, __entry->mode)
73206 +);
73207 +
73208 +TRACE_EVENT(open_exec,
73209 +
73210 + TP_PROTO(const char *filename),
73211 +
73212 + TP_ARGS(filename),
73213 +
73214 + TP_STRUCT__entry(
73215 + __string( filename, filename )
73216 + ),
73217 +
73218 + TP_fast_assign(
73219 + __assign_str(filename, filename);
73220 + ),
73221 +
73222 + TP_printk("\"%s\"",
73223 + __get_str(filename))
73224 +);
73225 +
73226 +#endif /* _TRACE_FS_H */
73227 +
73228 +/* This part must be outside protection */
73229 +#include <trace/define_trace.h>
73230 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
73231 index 1c09820..7f5ec79 100644
73232 --- a/include/trace/events/irq.h
73233 +++ b/include/trace/events/irq.h
73234 @@ -36,7 +36,7 @@ struct softirq_action;
73235 */
73236 TRACE_EVENT(irq_handler_entry,
73237
73238 - TP_PROTO(int irq, struct irqaction *action),
73239 + TP_PROTO(int irq, const struct irqaction *action),
73240
73241 TP_ARGS(irq, action),
73242
73243 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
73244 */
73245 TRACE_EVENT(irq_handler_exit,
73246
73247 - TP_PROTO(int irq, struct irqaction *action, int ret),
73248 + TP_PROTO(int irq, const struct irqaction *action, int ret),
73249
73250 TP_ARGS(irq, action, ret),
73251
73252 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
73253 index 7caf44c..23c6f27 100644
73254 --- a/include/uapi/linux/a.out.h
73255 +++ b/include/uapi/linux/a.out.h
73256 @@ -39,6 +39,14 @@ enum machine_type {
73257 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
73258 };
73259
73260 +/* Constants for the N_FLAGS field */
73261 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73262 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
73263 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
73264 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
73265 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73266 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73267 +
73268 #if !defined (N_MAGIC)
73269 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
73270 #endif
73271 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
73272 index d876736..ccce5c0 100644
73273 --- a/include/uapi/linux/byteorder/little_endian.h
73274 +++ b/include/uapi/linux/byteorder/little_endian.h
73275 @@ -42,51 +42,51 @@
73276
73277 static inline __le64 __cpu_to_le64p(const __u64 *p)
73278 {
73279 - return (__force __le64)*p;
73280 + return (__force const __le64)*p;
73281 }
73282 -static inline __u64 __le64_to_cpup(const __le64 *p)
73283 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
73284 {
73285 - return (__force __u64)*p;
73286 + return (__force const __u64)*p;
73287 }
73288 static inline __le32 __cpu_to_le32p(const __u32 *p)
73289 {
73290 - return (__force __le32)*p;
73291 + return (__force const __le32)*p;
73292 }
73293 static inline __u32 __le32_to_cpup(const __le32 *p)
73294 {
73295 - return (__force __u32)*p;
73296 + return (__force const __u32)*p;
73297 }
73298 static inline __le16 __cpu_to_le16p(const __u16 *p)
73299 {
73300 - return (__force __le16)*p;
73301 + return (__force const __le16)*p;
73302 }
73303 static inline __u16 __le16_to_cpup(const __le16 *p)
73304 {
73305 - return (__force __u16)*p;
73306 + return (__force const __u16)*p;
73307 }
73308 static inline __be64 __cpu_to_be64p(const __u64 *p)
73309 {
73310 - return (__force __be64)__swab64p(p);
73311 + return (__force const __be64)__swab64p(p);
73312 }
73313 static inline __u64 __be64_to_cpup(const __be64 *p)
73314 {
73315 - return __swab64p((__u64 *)p);
73316 + return __swab64p((const __u64 *)p);
73317 }
73318 static inline __be32 __cpu_to_be32p(const __u32 *p)
73319 {
73320 - return (__force __be32)__swab32p(p);
73321 + return (__force const __be32)__swab32p(p);
73322 }
73323 -static inline __u32 __be32_to_cpup(const __be32 *p)
73324 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
73325 {
73326 - return __swab32p((__u32 *)p);
73327 + return __swab32p((const __u32 *)p);
73328 }
73329 static inline __be16 __cpu_to_be16p(const __u16 *p)
73330 {
73331 - return (__force __be16)__swab16p(p);
73332 + return (__force const __be16)__swab16p(p);
73333 }
73334 static inline __u16 __be16_to_cpup(const __be16 *p)
73335 {
73336 - return __swab16p((__u16 *)p);
73337 + return __swab16p((const __u16 *)p);
73338 }
73339 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
73340 #define __le64_to_cpus(x) do { (void)(x); } while (0)
73341 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
73342 index 8072d35..e77aeb8 100644
73343 --- a/include/uapi/linux/elf.h
73344 +++ b/include/uapi/linux/elf.h
73345 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
73346 #define PT_GNU_EH_FRAME 0x6474e550
73347
73348 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
73349 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
73350 +
73351 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
73352 +
73353 +/* Constants for the e_flags field */
73354 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73355 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
73356 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
73357 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
73358 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73359 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73360
73361 /*
73362 * Extended Numbering
73363 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
73364 #define DT_DEBUG 21
73365 #define DT_TEXTREL 22
73366 #define DT_JMPREL 23
73367 +#define DT_FLAGS 30
73368 + #define DF_TEXTREL 0x00000004
73369 #define DT_ENCODING 32
73370 #define OLD_DT_LOOS 0x60000000
73371 #define DT_LOOS 0x6000000d
73372 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
73373 #define PF_W 0x2
73374 #define PF_X 0x1
73375
73376 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
73377 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
73378 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
73379 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
73380 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
73381 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
73382 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
73383 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
73384 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
73385 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
73386 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
73387 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
73388 +
73389 typedef struct elf32_phdr{
73390 Elf32_Word p_type;
73391 Elf32_Off p_offset;
73392 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
73393 #define EI_OSABI 7
73394 #define EI_PAD 8
73395
73396 +#define EI_PAX 14
73397 +
73398 #define ELFMAG0 0x7f /* EI_MAG */
73399 #define ELFMAG1 'E'
73400 #define ELFMAG2 'L'
73401 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
73402 index aa169c4..6a2771d 100644
73403 --- a/include/uapi/linux/personality.h
73404 +++ b/include/uapi/linux/personality.h
73405 @@ -30,6 +30,7 @@ enum {
73406 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
73407 ADDR_NO_RANDOMIZE | \
73408 ADDR_COMPAT_LAYOUT | \
73409 + ADDR_LIMIT_3GB | \
73410 MMAP_PAGE_ZERO)
73411
73412 /*
73413 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
73414 index 7530e74..e714828 100644
73415 --- a/include/uapi/linux/screen_info.h
73416 +++ b/include/uapi/linux/screen_info.h
73417 @@ -43,7 +43,8 @@ struct screen_info {
73418 __u16 pages; /* 0x32 */
73419 __u16 vesa_attributes; /* 0x34 */
73420 __u32 capabilities; /* 0x36 */
73421 - __u8 _reserved[6]; /* 0x3a */
73422 + __u16 vesapm_size; /* 0x3a */
73423 + __u8 _reserved[4]; /* 0x3c */
73424 } __attribute__((packed));
73425
73426 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
73427 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
73428 index 0e011eb..82681b1 100644
73429 --- a/include/uapi/linux/swab.h
73430 +++ b/include/uapi/linux/swab.h
73431 @@ -43,7 +43,7 @@
73432 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
73433 */
73434
73435 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
73436 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
73437 {
73438 #ifdef __HAVE_BUILTIN_BSWAP16__
73439 return __builtin_bswap16(val);
73440 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
73441 #endif
73442 }
73443
73444 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
73445 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
73446 {
73447 #ifdef __HAVE_BUILTIN_BSWAP32__
73448 return __builtin_bswap32(val);
73449 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
73450 #endif
73451 }
73452
73453 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
73454 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
73455 {
73456 #ifdef __HAVE_BUILTIN_BSWAP64__
73457 return __builtin_bswap64(val);
73458 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
73459 index 6d67213..8dab561 100644
73460 --- a/include/uapi/linux/sysctl.h
73461 +++ b/include/uapi/linux/sysctl.h
73462 @@ -155,7 +155,11 @@ enum
73463 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
73464 };
73465
73466 -
73467 +#ifdef CONFIG_PAX_SOFTMODE
73468 +enum {
73469 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
73470 +};
73471 +#endif
73472
73473 /* CTL_VM names: */
73474 enum
73475 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
73476 index e4629b9..6958086 100644
73477 --- a/include/uapi/linux/xattr.h
73478 +++ b/include/uapi/linux/xattr.h
73479 @@ -63,5 +63,9 @@
73480 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
73481 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
73482
73483 +/* User namespace */
73484 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
73485 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
73486 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
73487
73488 #endif /* _UAPI_LINUX_XATTR_H */
73489 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
73490 index f9466fa..f4e2b81 100644
73491 --- a/include/video/udlfb.h
73492 +++ b/include/video/udlfb.h
73493 @@ -53,10 +53,10 @@ struct dlfb_data {
73494 u32 pseudo_palette[256];
73495 int blank_mode; /*one of FB_BLANK_ */
73496 /* blit-only rendering path metrics, exposed through sysfs */
73497 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73498 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
73499 - atomic_t bytes_sent; /* to usb, after compression including overhead */
73500 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
73501 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73502 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
73503 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
73504 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
73505 };
73506
73507 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
73508 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
73509 index 1a91850..28573f8 100644
73510 --- a/include/video/uvesafb.h
73511 +++ b/include/video/uvesafb.h
73512 @@ -122,6 +122,7 @@ struct uvesafb_par {
73513 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
73514 u8 pmi_setpal; /* PMI for palette changes */
73515 u16 *pmi_base; /* protected mode interface location */
73516 + u8 *pmi_code; /* protected mode code location */
73517 void *pmi_start;
73518 void *pmi_pal;
73519 u8 *vbe_state_orig; /*
73520 diff --git a/init/Kconfig b/init/Kconfig
73521 index 5341d72..153f24f 100644
73522 --- a/init/Kconfig
73523 +++ b/init/Kconfig
73524 @@ -984,6 +984,7 @@ endif # CGROUPS
73525
73526 config CHECKPOINT_RESTORE
73527 bool "Checkpoint/restore support" if EXPERT
73528 + depends on !GRKERNSEC
73529 default n
73530 help
73531 Enables additional kernel features in a sake of checkpoint/restore.
73532 @@ -1471,7 +1472,7 @@ config SLUB_DEBUG
73533
73534 config COMPAT_BRK
73535 bool "Disable heap randomization"
73536 - default y
73537 + default n
73538 help
73539 Randomizing heap placement makes heap exploits harder, but it
73540 also breaks ancient binaries (including anything libc5 based).
73541 @@ -1734,7 +1735,7 @@ config INIT_ALL_POSSIBLE
73542 config STOP_MACHINE
73543 bool
73544 default y
73545 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
73546 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
73547 help
73548 Need stop_machine() primitive.
73549
73550 diff --git a/init/Makefile b/init/Makefile
73551 index 7bc47ee..6da2dc7 100644
73552 --- a/init/Makefile
73553 +++ b/init/Makefile
73554 @@ -2,6 +2,9 @@
73555 # Makefile for the linux kernel.
73556 #
73557
73558 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
73559 +asflags-y := $(GCC_PLUGINS_AFLAGS)
73560 +
73561 obj-y := main.o version.o mounts.o
73562 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
73563 obj-y += noinitramfs.o
73564 diff --git a/init/do_mounts.c b/init/do_mounts.c
73565 index a2b49f2..03a0e17c 100644
73566 --- a/init/do_mounts.c
73567 +++ b/init/do_mounts.c
73568 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
73569 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
73570 {
73571 struct super_block *s;
73572 - int err = sys_mount(name, "/root", fs, flags, data);
73573 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
73574 if (err)
73575 return err;
73576
73577 - sys_chdir("/root");
73578 + sys_chdir((const char __force_user *)"/root");
73579 s = current->fs->pwd.dentry->d_sb;
73580 ROOT_DEV = s->s_dev;
73581 printk(KERN_INFO
73582 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
73583 va_start(args, fmt);
73584 vsprintf(buf, fmt, args);
73585 va_end(args);
73586 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
73587 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
73588 if (fd >= 0) {
73589 sys_ioctl(fd, FDEJECT, 0);
73590 sys_close(fd);
73591 }
73592 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
73593 - fd = sys_open("/dev/console", O_RDWR, 0);
73594 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
73595 if (fd >= 0) {
73596 sys_ioctl(fd, TCGETS, (long)&termios);
73597 termios.c_lflag &= ~ICANON;
73598 sys_ioctl(fd, TCSETSF, (long)&termios);
73599 - sys_read(fd, &c, 1);
73600 + sys_read(fd, (char __user *)&c, 1);
73601 termios.c_lflag |= ICANON;
73602 sys_ioctl(fd, TCSETSF, (long)&termios);
73603 sys_close(fd);
73604 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
73605 mount_root();
73606 out:
73607 devtmpfs_mount("dev");
73608 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
73609 - sys_chroot(".");
73610 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
73611 + sys_chroot((const char __force_user *)".");
73612 }
73613 diff --git a/init/do_mounts.h b/init/do_mounts.h
73614 index f5b978a..69dbfe8 100644
73615 --- a/init/do_mounts.h
73616 +++ b/init/do_mounts.h
73617 @@ -15,15 +15,15 @@ extern int root_mountflags;
73618
73619 static inline int create_dev(char *name, dev_t dev)
73620 {
73621 - sys_unlink(name);
73622 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
73623 + sys_unlink((char __force_user *)name);
73624 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
73625 }
73626
73627 #if BITS_PER_LONG == 32
73628 static inline u32 bstat(char *name)
73629 {
73630 struct stat64 stat;
73631 - if (sys_stat64(name, &stat) != 0)
73632 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
73633 return 0;
73634 if (!S_ISBLK(stat.st_mode))
73635 return 0;
73636 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
73637 static inline u32 bstat(char *name)
73638 {
73639 struct stat stat;
73640 - if (sys_newstat(name, &stat) != 0)
73641 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
73642 return 0;
73643 if (!S_ISBLK(stat.st_mode))
73644 return 0;
73645 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
73646 index a32ec1c..60a6659 100644
73647 --- a/init/do_mounts_initrd.c
73648 +++ b/init/do_mounts_initrd.c
73649 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
73650 {
73651 sys_unshare(CLONE_FS | CLONE_FILES);
73652 /* stdin/stdout/stderr for /linuxrc */
73653 - sys_open("/dev/console", O_RDWR, 0);
73654 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
73655 sys_dup(0);
73656 sys_dup(0);
73657 /* move initrd over / and chdir/chroot in initrd root */
73658 - sys_chdir("/root");
73659 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
73660 - sys_chroot(".");
73661 + sys_chdir((const char __force_user *)"/root");
73662 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
73663 + sys_chroot((const char __force_user *)".");
73664 sys_setsid();
73665 return 0;
73666 }
73667 @@ -58,8 +58,8 @@ static void __init handle_initrd(void)
73668 create_dev("/dev/root.old", Root_RAM0);
73669 /* mount initrd on rootfs' /root */
73670 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
73671 - sys_mkdir("/old", 0700);
73672 - sys_chdir("/old");
73673 + sys_mkdir((const char __force_user *)"/old", 0700);
73674 + sys_chdir((const char __force_user *)"/old");
73675
73676 /* try loading default modules from initrd */
73677 load_default_modules();
73678 @@ -76,31 +76,31 @@ static void __init handle_initrd(void)
73679 current->flags &= ~PF_FREEZER_SKIP;
73680
73681 /* move initrd to rootfs' /old */
73682 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
73683 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
73684 /* switch root and cwd back to / of rootfs */
73685 - sys_chroot("..");
73686 + sys_chroot((const char __force_user *)"..");
73687
73688 if (new_decode_dev(real_root_dev) == Root_RAM0) {
73689 - sys_chdir("/old");
73690 + sys_chdir((const char __force_user *)"/old");
73691 return;
73692 }
73693
73694 - sys_chdir("/");
73695 + sys_chdir((const char __force_user *)"/");
73696 ROOT_DEV = new_decode_dev(real_root_dev);
73697 mount_root();
73698
73699 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
73700 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
73701 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
73702 if (!error)
73703 printk("okay\n");
73704 else {
73705 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
73706 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
73707 if (error == -ENOENT)
73708 printk("/initrd does not exist. Ignored.\n");
73709 else
73710 printk("failed\n");
73711 printk(KERN_NOTICE "Unmounting old root\n");
73712 - sys_umount("/old", MNT_DETACH);
73713 + sys_umount((char __force_user *)"/old", MNT_DETACH);
73714 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
73715 if (fd < 0) {
73716 error = fd;
73717 @@ -123,11 +123,11 @@ int __init initrd_load(void)
73718 * mounted in the normal path.
73719 */
73720 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
73721 - sys_unlink("/initrd.image");
73722 + sys_unlink((const char __force_user *)"/initrd.image");
73723 handle_initrd();
73724 return 1;
73725 }
73726 }
73727 - sys_unlink("/initrd.image");
73728 + sys_unlink((const char __force_user *)"/initrd.image");
73729 return 0;
73730 }
73731 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
73732 index 8cb6db5..d729f50 100644
73733 --- a/init/do_mounts_md.c
73734 +++ b/init/do_mounts_md.c
73735 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
73736 partitioned ? "_d" : "", minor,
73737 md_setup_args[ent].device_names);
73738
73739 - fd = sys_open(name, 0, 0);
73740 + fd = sys_open((char __force_user *)name, 0, 0);
73741 if (fd < 0) {
73742 printk(KERN_ERR "md: open failed - cannot start "
73743 "array %s\n", name);
73744 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
73745 * array without it
73746 */
73747 sys_close(fd);
73748 - fd = sys_open(name, 0, 0);
73749 + fd = sys_open((char __force_user *)name, 0, 0);
73750 sys_ioctl(fd, BLKRRPART, 0);
73751 }
73752 sys_close(fd);
73753 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
73754
73755 wait_for_device_probe();
73756
73757 - fd = sys_open("/dev/md0", 0, 0);
73758 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
73759 if (fd >= 0) {
73760 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
73761 sys_close(fd);
73762 diff --git a/init/init_task.c b/init/init_task.c
73763 index ba0a7f36..2bcf1d5 100644
73764 --- a/init/init_task.c
73765 +++ b/init/init_task.c
73766 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
73767 * Initial thread structure. Alignment of this is handled by a special
73768 * linker map entry.
73769 */
73770 +#ifdef CONFIG_X86
73771 +union thread_union init_thread_union __init_task_data;
73772 +#else
73773 union thread_union init_thread_union __init_task_data =
73774 { INIT_THREAD_INFO(init_task) };
73775 +#endif
73776 diff --git a/init/initramfs.c b/init/initramfs.c
73777 index a67ef9d..3d88592 100644
73778 --- a/init/initramfs.c
73779 +++ b/init/initramfs.c
73780 @@ -84,7 +84,7 @@ static void __init free_hash(void)
73781 }
73782 }
73783
73784 -static long __init do_utime(char *filename, time_t mtime)
73785 +static long __init do_utime(char __force_user *filename, time_t mtime)
73786 {
73787 struct timespec t[2];
73788
73789 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
73790 struct dir_entry *de, *tmp;
73791 list_for_each_entry_safe(de, tmp, &dir_list, list) {
73792 list_del(&de->list);
73793 - do_utime(de->name, de->mtime);
73794 + do_utime((char __force_user *)de->name, de->mtime);
73795 kfree(de->name);
73796 kfree(de);
73797 }
73798 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
73799 if (nlink >= 2) {
73800 char *old = find_link(major, minor, ino, mode, collected);
73801 if (old)
73802 - return (sys_link(old, collected) < 0) ? -1 : 1;
73803 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
73804 }
73805 return 0;
73806 }
73807 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
73808 {
73809 struct stat st;
73810
73811 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
73812 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
73813 if (S_ISDIR(st.st_mode))
73814 - sys_rmdir(path);
73815 + sys_rmdir((char __force_user *)path);
73816 else
73817 - sys_unlink(path);
73818 + sys_unlink((char __force_user *)path);
73819 }
73820 }
73821
73822 @@ -315,7 +315,7 @@ static int __init do_name(void)
73823 int openflags = O_WRONLY|O_CREAT;
73824 if (ml != 1)
73825 openflags |= O_TRUNC;
73826 - wfd = sys_open(collected, openflags, mode);
73827 + wfd = sys_open((char __force_user *)collected, openflags, mode);
73828
73829 if (wfd >= 0) {
73830 sys_fchown(wfd, uid, gid);
73831 @@ -327,17 +327,17 @@ static int __init do_name(void)
73832 }
73833 }
73834 } else if (S_ISDIR(mode)) {
73835 - sys_mkdir(collected, mode);
73836 - sys_chown(collected, uid, gid);
73837 - sys_chmod(collected, mode);
73838 + sys_mkdir((char __force_user *)collected, mode);
73839 + sys_chown((char __force_user *)collected, uid, gid);
73840 + sys_chmod((char __force_user *)collected, mode);
73841 dir_add(collected, mtime);
73842 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
73843 S_ISFIFO(mode) || S_ISSOCK(mode)) {
73844 if (maybe_link() == 0) {
73845 - sys_mknod(collected, mode, rdev);
73846 - sys_chown(collected, uid, gid);
73847 - sys_chmod(collected, mode);
73848 - do_utime(collected, mtime);
73849 + sys_mknod((char __force_user *)collected, mode, rdev);
73850 + sys_chown((char __force_user *)collected, uid, gid);
73851 + sys_chmod((char __force_user *)collected, mode);
73852 + do_utime((char __force_user *)collected, mtime);
73853 }
73854 }
73855 return 0;
73856 @@ -346,15 +346,15 @@ static int __init do_name(void)
73857 static int __init do_copy(void)
73858 {
73859 if (count >= body_len) {
73860 - sys_write(wfd, victim, body_len);
73861 + sys_write(wfd, (char __force_user *)victim, body_len);
73862 sys_close(wfd);
73863 - do_utime(vcollected, mtime);
73864 + do_utime((char __force_user *)vcollected, mtime);
73865 kfree(vcollected);
73866 eat(body_len);
73867 state = SkipIt;
73868 return 0;
73869 } else {
73870 - sys_write(wfd, victim, count);
73871 + sys_write(wfd, (char __force_user *)victim, count);
73872 body_len -= count;
73873 eat(count);
73874 return 1;
73875 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
73876 {
73877 collected[N_ALIGN(name_len) + body_len] = '\0';
73878 clean_path(collected, 0);
73879 - sys_symlink(collected + N_ALIGN(name_len), collected);
73880 - sys_lchown(collected, uid, gid);
73881 - do_utime(collected, mtime);
73882 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
73883 + sys_lchown((char __force_user *)collected, uid, gid);
73884 + do_utime((char __force_user *)collected, mtime);
73885 state = SkipIt;
73886 next_state = Reset;
73887 return 0;
73888 diff --git a/init/main.c b/init/main.c
73889 index 63534a1..85feae2 100644
73890 --- a/init/main.c
73891 +++ b/init/main.c
73892 @@ -98,6 +98,8 @@ static inline void mark_rodata_ro(void) { }
73893 extern void tc_init(void);
73894 #endif
73895
73896 +extern void grsecurity_init(void);
73897 +
73898 /*
73899 * Debug helper: via this flag we know that we are in 'early bootup code'
73900 * where only the boot processor is running with IRQ disabled. This means
73901 @@ -151,6 +153,64 @@ static int __init set_reset_devices(char *str)
73902
73903 __setup("reset_devices", set_reset_devices);
73904
73905 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
73906 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
73907 +static int __init setup_grsec_proc_gid(char *str)
73908 +{
73909 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
73910 + return 1;
73911 +}
73912 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
73913 +#endif
73914 +
73915 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
73916 +unsigned long pax_user_shadow_base __read_only = 1UL << TASK_SIZE_MAX_SHIFT;
73917 +EXPORT_SYMBOL(pax_user_shadow_base);
73918 +extern char pax_enter_kernel_user[];
73919 +extern char pax_exit_kernel_user[];
73920 +extern pgdval_t clone_pgd_mask;
73921 +#endif
73922 +
73923 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
73924 +static int __init setup_pax_nouderef(char *str)
73925 +{
73926 +#ifdef CONFIG_X86_32
73927 + unsigned int cpu;
73928 + struct desc_struct *gdt;
73929 +
73930 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
73931 + gdt = get_cpu_gdt_table(cpu);
73932 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
73933 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
73934 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
73935 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
73936 + }
73937 + loadsegment(ds, __KERNEL_DS);
73938 + loadsegment(es, __KERNEL_DS);
73939 + loadsegment(ss, __KERNEL_DS);
73940 +#else
73941 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
73942 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
73943 + clone_pgd_mask = ~(pgdval_t)0UL;
73944 + pax_user_shadow_base = 0UL;
73945 +#endif
73946 +
73947 + return 0;
73948 +}
73949 +early_param("pax_nouderef", setup_pax_nouderef);
73950 +#endif
73951 +
73952 +#ifdef CONFIG_PAX_SOFTMODE
73953 +int pax_softmode;
73954 +
73955 +static int __init setup_pax_softmode(char *str)
73956 +{
73957 + get_option(&str, &pax_softmode);
73958 + return 1;
73959 +}
73960 +__setup("pax_softmode=", setup_pax_softmode);
73961 +#endif
73962 +
73963 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
73964 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
73965 static const char *panic_later, *panic_param;
73966 @@ -683,6 +743,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
73967 {
73968 int count = preempt_count();
73969 int ret;
73970 + const char *msg1 = "", *msg2 = "";
73971
73972 if (initcall_debug)
73973 ret = do_one_initcall_debug(fn);
73974 @@ -695,15 +756,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
73975 sprintf(msgbuf, "error code %d ", ret);
73976
73977 if (preempt_count() != count) {
73978 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
73979 + msg1 = " preemption imbalance";
73980 preempt_count() = count;
73981 }
73982 if (irqs_disabled()) {
73983 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
73984 + msg2 = " disabled interrupts";
73985 local_irq_enable();
73986 }
73987 - if (msgbuf[0]) {
73988 - printk("initcall %pF returned with %s\n", fn, msgbuf);
73989 + if (msgbuf[0] || *msg1 || *msg2) {
73990 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
73991 }
73992
73993 return ret;
73994 @@ -757,8 +818,14 @@ static void __init do_initcall_level(int level)
73995 level, level,
73996 &repair_env_string);
73997
73998 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
73999 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
74000 do_one_initcall(*fn);
74001 +
74002 +#ifdef LATENT_ENTROPY_PLUGIN
74003 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74004 +#endif
74005 +
74006 + }
74007 }
74008
74009 static void __init do_initcalls(void)
74010 @@ -792,8 +859,14 @@ static void __init do_pre_smp_initcalls(void)
74011 {
74012 initcall_t *fn;
74013
74014 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
74015 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
74016 do_one_initcall(*fn);
74017 +
74018 +#ifdef LATENT_ENTROPY_PLUGIN
74019 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74020 +#endif
74021 +
74022 + }
74023 }
74024
74025 /*
74026 @@ -811,8 +884,8 @@ static int run_init_process(const char *init_filename)
74027 {
74028 argv_init[0] = init_filename;
74029 return do_execve(init_filename,
74030 - (const char __user *const __user *)argv_init,
74031 - (const char __user *const __user *)envp_init);
74032 + (const char __user *const __force_user *)argv_init,
74033 + (const char __user *const __force_user *)envp_init);
74034 }
74035
74036 static noinline void __init kernel_init_freeable(void);
74037 @@ -890,7 +963,7 @@ static noinline void __init kernel_init_freeable(void)
74038 do_basic_setup();
74039
74040 /* Open the /dev/console on the rootfs, this should never fail */
74041 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
74042 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
74043 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
74044
74045 (void) sys_dup(0);
74046 @@ -903,11 +976,13 @@ static noinline void __init kernel_init_freeable(void)
74047 if (!ramdisk_execute_command)
74048 ramdisk_execute_command = "/init";
74049
74050 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
74051 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
74052 ramdisk_execute_command = NULL;
74053 prepare_namespace();
74054 }
74055
74056 + grsecurity_init();
74057 +
74058 /*
74059 * Ok, we have completed the initial bootup, and
74060 * we're essentially up and running. Get rid of the
74061 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
74062 index 130dfec..cc88451 100644
74063 --- a/ipc/ipc_sysctl.c
74064 +++ b/ipc/ipc_sysctl.c
74065 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
74066 static int proc_ipc_dointvec(ctl_table *table, int write,
74067 void __user *buffer, size_t *lenp, loff_t *ppos)
74068 {
74069 - struct ctl_table ipc_table;
74070 + ctl_table_no_const ipc_table;
74071
74072 memcpy(&ipc_table, table, sizeof(ipc_table));
74073 ipc_table.data = get_ipc(table);
74074 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
74075 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
74076 void __user *buffer, size_t *lenp, loff_t *ppos)
74077 {
74078 - struct ctl_table ipc_table;
74079 + ctl_table_no_const ipc_table;
74080
74081 memcpy(&ipc_table, table, sizeof(ipc_table));
74082 ipc_table.data = get_ipc(table);
74083 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
74084 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74085 void __user *buffer, size_t *lenp, loff_t *ppos)
74086 {
74087 - struct ctl_table ipc_table;
74088 + ctl_table_no_const ipc_table;
74089 size_t lenp_bef = *lenp;
74090 int rc;
74091
74092 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74093 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
74094 void __user *buffer, size_t *lenp, loff_t *ppos)
74095 {
74096 - struct ctl_table ipc_table;
74097 + ctl_table_no_const ipc_table;
74098 memcpy(&ipc_table, table, sizeof(ipc_table));
74099 ipc_table.data = get_ipc(table);
74100
74101 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
74102 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
74103 void __user *buffer, size_t *lenp, loff_t *ppos)
74104 {
74105 - struct ctl_table ipc_table;
74106 + ctl_table_no_const ipc_table;
74107 size_t lenp_bef = *lenp;
74108 int oldval;
74109 int rc;
74110 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
74111 index 383d638..943fdbb 100644
74112 --- a/ipc/mq_sysctl.c
74113 +++ b/ipc/mq_sysctl.c
74114 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
74115 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
74116 void __user *buffer, size_t *lenp, loff_t *ppos)
74117 {
74118 - struct ctl_table mq_table;
74119 + ctl_table_no_const mq_table;
74120 memcpy(&mq_table, table, sizeof(mq_table));
74121 mq_table.data = get_mq(table);
74122
74123 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
74124 index e4e47f6..a85e0ad 100644
74125 --- a/ipc/mqueue.c
74126 +++ b/ipc/mqueue.c
74127 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
74128 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
74129 info->attr.mq_msgsize);
74130
74131 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
74132 spin_lock(&mq_lock);
74133 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
74134 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
74135 diff --git a/ipc/msg.c b/ipc/msg.c
74136 index fede1d0..9778e0f8 100644
74137 --- a/ipc/msg.c
74138 +++ b/ipc/msg.c
74139 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
74140 return security_msg_queue_associate(msq, msgflg);
74141 }
74142
74143 +static struct ipc_ops msg_ops = {
74144 + .getnew = newque,
74145 + .associate = msg_security,
74146 + .more_checks = NULL
74147 +};
74148 +
74149 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
74150 {
74151 struct ipc_namespace *ns;
74152 - struct ipc_ops msg_ops;
74153 struct ipc_params msg_params;
74154
74155 ns = current->nsproxy->ipc_ns;
74156
74157 - msg_ops.getnew = newque;
74158 - msg_ops.associate = msg_security;
74159 - msg_ops.more_checks = NULL;
74160 -
74161 msg_params.key = key;
74162 msg_params.flg = msgflg;
74163
74164 diff --git a/ipc/sem.c b/ipc/sem.c
74165 index 58d31f1..cce7a55 100644
74166 --- a/ipc/sem.c
74167 +++ b/ipc/sem.c
74168 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
74169 return 0;
74170 }
74171
74172 +static struct ipc_ops sem_ops = {
74173 + .getnew = newary,
74174 + .associate = sem_security,
74175 + .more_checks = sem_more_checks
74176 +};
74177 +
74178 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74179 {
74180 struct ipc_namespace *ns;
74181 - struct ipc_ops sem_ops;
74182 struct ipc_params sem_params;
74183
74184 ns = current->nsproxy->ipc_ns;
74185 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74186 if (nsems < 0 || nsems > ns->sc_semmsl)
74187 return -EINVAL;
74188
74189 - sem_ops.getnew = newary;
74190 - sem_ops.associate = sem_security;
74191 - sem_ops.more_checks = sem_more_checks;
74192 -
74193 sem_params.key = key;
74194 sem_params.flg = semflg;
74195 sem_params.u.nsems = nsems;
74196 diff --git a/ipc/shm.c b/ipc/shm.c
74197 index 7e199fa..180a1ca 100644
74198 --- a/ipc/shm.c
74199 +++ b/ipc/shm.c
74200 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
74201 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
74202 #endif
74203
74204 +#ifdef CONFIG_GRKERNSEC
74205 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74206 + const time_t shm_createtime, const kuid_t cuid,
74207 + const int shmid);
74208 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74209 + const time_t shm_createtime);
74210 +#endif
74211 +
74212 void shm_init_ns(struct ipc_namespace *ns)
74213 {
74214 ns->shm_ctlmax = SHMMAX;
74215 @@ -531,6 +539,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
74216 shp->shm_lprid = 0;
74217 shp->shm_atim = shp->shm_dtim = 0;
74218 shp->shm_ctim = get_seconds();
74219 +#ifdef CONFIG_GRKERNSEC
74220 + {
74221 + struct timespec timeval;
74222 + do_posix_clock_monotonic_gettime(&timeval);
74223 +
74224 + shp->shm_createtime = timeval.tv_sec;
74225 + }
74226 +#endif
74227 shp->shm_segsz = size;
74228 shp->shm_nattch = 0;
74229 shp->shm_file = file;
74230 @@ -582,18 +598,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
74231 return 0;
74232 }
74233
74234 +static struct ipc_ops shm_ops = {
74235 + .getnew = newseg,
74236 + .associate = shm_security,
74237 + .more_checks = shm_more_checks
74238 +};
74239 +
74240 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
74241 {
74242 struct ipc_namespace *ns;
74243 - struct ipc_ops shm_ops;
74244 struct ipc_params shm_params;
74245
74246 ns = current->nsproxy->ipc_ns;
74247
74248 - shm_ops.getnew = newseg;
74249 - shm_ops.associate = shm_security;
74250 - shm_ops.more_checks = shm_more_checks;
74251 -
74252 shm_params.key = key;
74253 shm_params.flg = shmflg;
74254 shm_params.u.size = size;
74255 @@ -1014,6 +1031,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74256 f_mode = FMODE_READ | FMODE_WRITE;
74257 }
74258 if (shmflg & SHM_EXEC) {
74259 +
74260 +#ifdef CONFIG_PAX_MPROTECT
74261 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
74262 + goto out;
74263 +#endif
74264 +
74265 prot |= PROT_EXEC;
74266 acc_mode |= S_IXUGO;
74267 }
74268 @@ -1037,9 +1060,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74269 if (err)
74270 goto out_unlock;
74271
74272 +#ifdef CONFIG_GRKERNSEC
74273 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
74274 + shp->shm_perm.cuid, shmid) ||
74275 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
74276 + err = -EACCES;
74277 + goto out_unlock;
74278 + }
74279 +#endif
74280 +
74281 path = shp->shm_file->f_path;
74282 path_get(&path);
74283 shp->shm_nattch++;
74284 +#ifdef CONFIG_GRKERNSEC
74285 + shp->shm_lapid = current->pid;
74286 +#endif
74287 size = i_size_read(path.dentry->d_inode);
74288 shm_unlock(shp);
74289
74290 diff --git a/kernel/acct.c b/kernel/acct.c
74291 index b9bd7f0..1762b4a 100644
74292 --- a/kernel/acct.c
74293 +++ b/kernel/acct.c
74294 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
74295 */
74296 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
74297 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
74298 - file->f_op->write(file, (char *)&ac,
74299 + file->f_op->write(file, (char __force_user *)&ac,
74300 sizeof(acct_t), &file->f_pos);
74301 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
74302 set_fs(fs);
74303 diff --git a/kernel/audit.c b/kernel/audit.c
74304 index d596e53..dbef3c3 100644
74305 --- a/kernel/audit.c
74306 +++ b/kernel/audit.c
74307 @@ -116,7 +116,7 @@ u32 audit_sig_sid = 0;
74308 3) suppressed due to audit_rate_limit
74309 4) suppressed due to audit_backlog_limit
74310 */
74311 -static atomic_t audit_lost = ATOMIC_INIT(0);
74312 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
74313
74314 /* The netlink socket. */
74315 static struct sock *audit_sock;
74316 @@ -238,7 +238,7 @@ void audit_log_lost(const char *message)
74317 unsigned long now;
74318 int print;
74319
74320 - atomic_inc(&audit_lost);
74321 + atomic_inc_unchecked(&audit_lost);
74322
74323 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
74324
74325 @@ -257,7 +257,7 @@ void audit_log_lost(const char *message)
74326 printk(KERN_WARNING
74327 "audit: audit_lost=%d audit_rate_limit=%d "
74328 "audit_backlog_limit=%d\n",
74329 - atomic_read(&audit_lost),
74330 + atomic_read_unchecked(&audit_lost),
74331 audit_rate_limit,
74332 audit_backlog_limit);
74333 audit_panic(message);
74334 @@ -681,7 +681,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
74335 status_set.pid = audit_pid;
74336 status_set.rate_limit = audit_rate_limit;
74337 status_set.backlog_limit = audit_backlog_limit;
74338 - status_set.lost = atomic_read(&audit_lost);
74339 + status_set.lost = atomic_read_unchecked(&audit_lost);
74340 status_set.backlog = skb_queue_len(&audit_skb_queue);
74341 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
74342 &status_set, sizeof(status_set));
74343 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
74344 index c4b72b0..8654c4e 100644
74345 --- a/kernel/auditsc.c
74346 +++ b/kernel/auditsc.c
74347 @@ -2295,7 +2295,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
74348 }
74349
74350 /* global counter which is incremented every time something logs in */
74351 -static atomic_t session_id = ATOMIC_INIT(0);
74352 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
74353
74354 /**
74355 * audit_set_loginuid - set current task's audit_context loginuid
74356 @@ -2319,7 +2319,7 @@ int audit_set_loginuid(kuid_t loginuid)
74357 return -EPERM;
74358 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
74359
74360 - sessionid = atomic_inc_return(&session_id);
74361 + sessionid = atomic_inc_return_unchecked(&session_id);
74362 if (context && context->in_syscall) {
74363 struct audit_buffer *ab;
74364
74365 diff --git a/kernel/capability.c b/kernel/capability.c
74366 index f6c2ce5..982c0f9 100644
74367 --- a/kernel/capability.c
74368 +++ b/kernel/capability.c
74369 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
74370 * before modification is attempted and the application
74371 * fails.
74372 */
74373 + if (tocopy > ARRAY_SIZE(kdata))
74374 + return -EFAULT;
74375 +
74376 if (copy_to_user(dataptr, kdata, tocopy
74377 * sizeof(struct __user_cap_data_struct))) {
74378 return -EFAULT;
74379 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
74380 int ret;
74381
74382 rcu_read_lock();
74383 - ret = security_capable(__task_cred(t), ns, cap);
74384 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
74385 + gr_task_is_capable(t, __task_cred(t), cap);
74386 rcu_read_unlock();
74387
74388 - return (ret == 0);
74389 + return ret;
74390 }
74391
74392 /**
74393 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
74394 int ret;
74395
74396 rcu_read_lock();
74397 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
74398 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
74399 rcu_read_unlock();
74400
74401 - return (ret == 0);
74402 + return ret;
74403 }
74404
74405 /**
74406 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
74407 BUG();
74408 }
74409
74410 - if (security_capable(current_cred(), ns, cap) == 0) {
74411 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
74412 current->flags |= PF_SUPERPRIV;
74413 return true;
74414 }
74415 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
74416 }
74417 EXPORT_SYMBOL(ns_capable);
74418
74419 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
74420 +{
74421 + if (unlikely(!cap_valid(cap))) {
74422 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
74423 + BUG();
74424 + }
74425 +
74426 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
74427 + current->flags |= PF_SUPERPRIV;
74428 + return true;
74429 + }
74430 + return false;
74431 +}
74432 +EXPORT_SYMBOL(ns_capable_nolog);
74433 +
74434 /**
74435 * file_ns_capable - Determine if the file's opener had a capability in effect
74436 * @file: The file we want to check
74437 @@ -432,6 +451,12 @@ bool capable(int cap)
74438 }
74439 EXPORT_SYMBOL(capable);
74440
74441 +bool capable_nolog(int cap)
74442 +{
74443 + return ns_capable_nolog(&init_user_ns, cap);
74444 +}
74445 +EXPORT_SYMBOL(capable_nolog);
74446 +
74447 /**
74448 * nsown_capable - Check superior capability to one's own user_ns
74449 * @cap: The capability in question
74450 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
74451
74452 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74453 }
74454 +
74455 +bool inode_capable_nolog(const struct inode *inode, int cap)
74456 +{
74457 + struct user_namespace *ns = current_user_ns();
74458 +
74459 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74460 +}
74461 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
74462 index ba1f977..f840d9c 100644
74463 --- a/kernel/cgroup.c
74464 +++ b/kernel/cgroup.c
74465 @@ -5569,7 +5569,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
74466 struct css_set *cg = link->cg;
74467 struct task_struct *task;
74468 int count = 0;
74469 - seq_printf(seq, "css_set %p\n", cg);
74470 + seq_printf(seq, "css_set %pK\n", cg);
74471 list_for_each_entry(task, &cg->tasks, cg_list) {
74472 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
74473 seq_puts(seq, " ...\n");
74474 diff --git a/kernel/compat.c b/kernel/compat.c
74475 index 19971d8..02fe2df 100644
74476 --- a/kernel/compat.c
74477 +++ b/kernel/compat.c
74478 @@ -13,6 +13,7 @@
74479
74480 #include <linux/linkage.h>
74481 #include <linux/compat.h>
74482 +#include <linux/module.h>
74483 #include <linux/errno.h>
74484 #include <linux/time.h>
74485 #include <linux/signal.h>
74486 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
74487 mm_segment_t oldfs;
74488 long ret;
74489
74490 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
74491 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
74492 oldfs = get_fs();
74493 set_fs(KERNEL_DS);
74494 ret = hrtimer_nanosleep_restart(restart);
74495 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
74496 oldfs = get_fs();
74497 set_fs(KERNEL_DS);
74498 ret = hrtimer_nanosleep(&tu,
74499 - rmtp ? (struct timespec __user *)&rmt : NULL,
74500 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
74501 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
74502 set_fs(oldfs);
74503
74504 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
74505 mm_segment_t old_fs = get_fs();
74506
74507 set_fs(KERNEL_DS);
74508 - ret = sys_sigpending((old_sigset_t __user *) &s);
74509 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
74510 set_fs(old_fs);
74511 if (ret == 0)
74512 ret = put_user(s, set);
74513 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
74514 mm_segment_t old_fs = get_fs();
74515
74516 set_fs(KERNEL_DS);
74517 - ret = sys_old_getrlimit(resource, &r);
74518 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
74519 set_fs(old_fs);
74520
74521 if (!ret) {
74522 @@ -523,7 +524,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
74523 mm_segment_t old_fs = get_fs();
74524
74525 set_fs(KERNEL_DS);
74526 - ret = sys_getrusage(who, (struct rusage __user *) &r);
74527 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
74528 set_fs(old_fs);
74529
74530 if (ret)
74531 @@ -552,8 +553,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
74532 set_fs (KERNEL_DS);
74533 ret = sys_wait4(pid,
74534 (stat_addr ?
74535 - (unsigned int __user *) &status : NULL),
74536 - options, (struct rusage __user *) &r);
74537 + (unsigned int __force_user *) &status : NULL),
74538 + options, (struct rusage __force_user *) &r);
74539 set_fs (old_fs);
74540
74541 if (ret > 0) {
74542 @@ -579,8 +580,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
74543 memset(&info, 0, sizeof(info));
74544
74545 set_fs(KERNEL_DS);
74546 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
74547 - uru ? (struct rusage __user *)&ru : NULL);
74548 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
74549 + uru ? (struct rusage __force_user *)&ru : NULL);
74550 set_fs(old_fs);
74551
74552 if ((ret < 0) || (info.si_signo == 0))
74553 @@ -714,8 +715,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
74554 oldfs = get_fs();
74555 set_fs(KERNEL_DS);
74556 err = sys_timer_settime(timer_id, flags,
74557 - (struct itimerspec __user *) &newts,
74558 - (struct itimerspec __user *) &oldts);
74559 + (struct itimerspec __force_user *) &newts,
74560 + (struct itimerspec __force_user *) &oldts);
74561 set_fs(oldfs);
74562 if (!err && old && put_compat_itimerspec(old, &oldts))
74563 return -EFAULT;
74564 @@ -732,7 +733,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
74565 oldfs = get_fs();
74566 set_fs(KERNEL_DS);
74567 err = sys_timer_gettime(timer_id,
74568 - (struct itimerspec __user *) &ts);
74569 + (struct itimerspec __force_user *) &ts);
74570 set_fs(oldfs);
74571 if (!err && put_compat_itimerspec(setting, &ts))
74572 return -EFAULT;
74573 @@ -751,7 +752,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
74574 oldfs = get_fs();
74575 set_fs(KERNEL_DS);
74576 err = sys_clock_settime(which_clock,
74577 - (struct timespec __user *) &ts);
74578 + (struct timespec __force_user *) &ts);
74579 set_fs(oldfs);
74580 return err;
74581 }
74582 @@ -766,7 +767,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
74583 oldfs = get_fs();
74584 set_fs(KERNEL_DS);
74585 err = sys_clock_gettime(which_clock,
74586 - (struct timespec __user *) &ts);
74587 + (struct timespec __force_user *) &ts);
74588 set_fs(oldfs);
74589 if (!err && put_compat_timespec(&ts, tp))
74590 return -EFAULT;
74591 @@ -786,7 +787,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
74592
74593 oldfs = get_fs();
74594 set_fs(KERNEL_DS);
74595 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
74596 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
74597 set_fs(oldfs);
74598
74599 err = compat_put_timex(utp, &txc);
74600 @@ -806,7 +807,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
74601 oldfs = get_fs();
74602 set_fs(KERNEL_DS);
74603 err = sys_clock_getres(which_clock,
74604 - (struct timespec __user *) &ts);
74605 + (struct timespec __force_user *) &ts);
74606 set_fs(oldfs);
74607 if (!err && tp && put_compat_timespec(&ts, tp))
74608 return -EFAULT;
74609 @@ -818,9 +819,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
74610 long err;
74611 mm_segment_t oldfs;
74612 struct timespec tu;
74613 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
74614 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
74615
74616 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
74617 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
74618 oldfs = get_fs();
74619 set_fs(KERNEL_DS);
74620 err = clock_nanosleep_restart(restart);
74621 @@ -852,8 +853,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
74622 oldfs = get_fs();
74623 set_fs(KERNEL_DS);
74624 err = sys_clock_nanosleep(which_clock, flags,
74625 - (struct timespec __user *) &in,
74626 - (struct timespec __user *) &out);
74627 + (struct timespec __force_user *) &in,
74628 + (struct timespec __force_user *) &out);
74629 set_fs(oldfs);
74630
74631 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
74632 diff --git a/kernel/configs.c b/kernel/configs.c
74633 index 42e8fa0..9e7406b 100644
74634 --- a/kernel/configs.c
74635 +++ b/kernel/configs.c
74636 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
74637 struct proc_dir_entry *entry;
74638
74639 /* create the current config file */
74640 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
74641 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
74642 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
74643 + &ikconfig_file_ops);
74644 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74645 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
74646 + &ikconfig_file_ops);
74647 +#endif
74648 +#else
74649 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
74650 &ikconfig_file_ops);
74651 +#endif
74652 +
74653 if (!entry)
74654 return -ENOMEM;
74655
74656 diff --git a/kernel/cred.c b/kernel/cred.c
74657 index e0573a4..3874e41 100644
74658 --- a/kernel/cred.c
74659 +++ b/kernel/cred.c
74660 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
74661 validate_creds(cred);
74662 alter_cred_subscribers(cred, -1);
74663 put_cred(cred);
74664 +
74665 +#ifdef CONFIG_GRKERNSEC_SETXID
74666 + cred = (struct cred *) tsk->delayed_cred;
74667 + if (cred != NULL) {
74668 + tsk->delayed_cred = NULL;
74669 + validate_creds(cred);
74670 + alter_cred_subscribers(cred, -1);
74671 + put_cred(cred);
74672 + }
74673 +#endif
74674 }
74675
74676 /**
74677 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
74678 * Always returns 0 thus allowing this function to be tail-called at the end
74679 * of, say, sys_setgid().
74680 */
74681 -int commit_creds(struct cred *new)
74682 +static int __commit_creds(struct cred *new)
74683 {
74684 struct task_struct *task = current;
74685 const struct cred *old = task->real_cred;
74686 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
74687
74688 get_cred(new); /* we will require a ref for the subj creds too */
74689
74690 + gr_set_role_label(task, new->uid, new->gid);
74691 +
74692 /* dumpability changes */
74693 if (!uid_eq(old->euid, new->euid) ||
74694 !gid_eq(old->egid, new->egid) ||
74695 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
74696 put_cred(old);
74697 return 0;
74698 }
74699 +#ifdef CONFIG_GRKERNSEC_SETXID
74700 +extern int set_user(struct cred *new);
74701 +
74702 +void gr_delayed_cred_worker(void)
74703 +{
74704 + const struct cred *new = current->delayed_cred;
74705 + struct cred *ncred;
74706 +
74707 + current->delayed_cred = NULL;
74708 +
74709 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
74710 + // from doing get_cred on it when queueing this
74711 + put_cred(new);
74712 + return;
74713 + } else if (new == NULL)
74714 + return;
74715 +
74716 + ncred = prepare_creds();
74717 + if (!ncred)
74718 + goto die;
74719 + // uids
74720 + ncred->uid = new->uid;
74721 + ncred->euid = new->euid;
74722 + ncred->suid = new->suid;
74723 + ncred->fsuid = new->fsuid;
74724 + // gids
74725 + ncred->gid = new->gid;
74726 + ncred->egid = new->egid;
74727 + ncred->sgid = new->sgid;
74728 + ncred->fsgid = new->fsgid;
74729 + // groups
74730 + if (set_groups(ncred, new->group_info) < 0) {
74731 + abort_creds(ncred);
74732 + goto die;
74733 + }
74734 + // caps
74735 + ncred->securebits = new->securebits;
74736 + ncred->cap_inheritable = new->cap_inheritable;
74737 + ncred->cap_permitted = new->cap_permitted;
74738 + ncred->cap_effective = new->cap_effective;
74739 + ncred->cap_bset = new->cap_bset;
74740 +
74741 + if (set_user(ncred)) {
74742 + abort_creds(ncred);
74743 + goto die;
74744 + }
74745 +
74746 + // from doing get_cred on it when queueing this
74747 + put_cred(new);
74748 +
74749 + __commit_creds(ncred);
74750 + return;
74751 +die:
74752 + // from doing get_cred on it when queueing this
74753 + put_cred(new);
74754 + do_group_exit(SIGKILL);
74755 +}
74756 +#endif
74757 +
74758 +int commit_creds(struct cred *new)
74759 +{
74760 +#ifdef CONFIG_GRKERNSEC_SETXID
74761 + int ret;
74762 + int schedule_it = 0;
74763 + struct task_struct *t;
74764 +
74765 + /* we won't get called with tasklist_lock held for writing
74766 + and interrupts disabled as the cred struct in that case is
74767 + init_cred
74768 + */
74769 + if (grsec_enable_setxid && !current_is_single_threaded() &&
74770 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
74771 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
74772 + schedule_it = 1;
74773 + }
74774 + ret = __commit_creds(new);
74775 + if (schedule_it) {
74776 + rcu_read_lock();
74777 + read_lock(&tasklist_lock);
74778 + for (t = next_thread(current); t != current;
74779 + t = next_thread(t)) {
74780 + if (t->delayed_cred == NULL) {
74781 + t->delayed_cred = get_cred(new);
74782 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
74783 + set_tsk_need_resched(t);
74784 + }
74785 + }
74786 + read_unlock(&tasklist_lock);
74787 + rcu_read_unlock();
74788 + }
74789 + return ret;
74790 +#else
74791 + return __commit_creds(new);
74792 +#endif
74793 +}
74794 +
74795 EXPORT_SYMBOL(commit_creds);
74796
74797 /**
74798 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
74799 index c26278f..e323fb8 100644
74800 --- a/kernel/debug/debug_core.c
74801 +++ b/kernel/debug/debug_core.c
74802 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
74803 */
74804 static atomic_t masters_in_kgdb;
74805 static atomic_t slaves_in_kgdb;
74806 -static atomic_t kgdb_break_tasklet_var;
74807 +static atomic_unchecked_t kgdb_break_tasklet_var;
74808 atomic_t kgdb_setting_breakpoint;
74809
74810 struct task_struct *kgdb_usethread;
74811 @@ -133,7 +133,7 @@ int kgdb_single_step;
74812 static pid_t kgdb_sstep_pid;
74813
74814 /* to keep track of the CPU which is doing the single stepping*/
74815 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74816 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74817
74818 /*
74819 * If you are debugging a problem where roundup (the collection of
74820 @@ -541,7 +541,7 @@ return_normal:
74821 * kernel will only try for the value of sstep_tries before
74822 * giving up and continuing on.
74823 */
74824 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
74825 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
74826 (kgdb_info[cpu].task &&
74827 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
74828 atomic_set(&kgdb_active, -1);
74829 @@ -635,8 +635,8 @@ cpu_master_loop:
74830 }
74831
74832 kgdb_restore:
74833 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
74834 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
74835 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
74836 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
74837 if (kgdb_info[sstep_cpu].task)
74838 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
74839 else
74840 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
74841 static void kgdb_tasklet_bpt(unsigned long ing)
74842 {
74843 kgdb_breakpoint();
74844 - atomic_set(&kgdb_break_tasklet_var, 0);
74845 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
74846 }
74847
74848 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
74849
74850 void kgdb_schedule_breakpoint(void)
74851 {
74852 - if (atomic_read(&kgdb_break_tasklet_var) ||
74853 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
74854 atomic_read(&kgdb_active) != -1 ||
74855 atomic_read(&kgdb_setting_breakpoint))
74856 return;
74857 - atomic_inc(&kgdb_break_tasklet_var);
74858 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
74859 tasklet_schedule(&kgdb_tasklet_breakpoint);
74860 }
74861 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
74862 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
74863 index 00eb8f7..d7e3244 100644
74864 --- a/kernel/debug/kdb/kdb_main.c
74865 +++ b/kernel/debug/kdb/kdb_main.c
74866 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
74867 continue;
74868
74869 kdb_printf("%-20s%8u 0x%p ", mod->name,
74870 - mod->core_size, (void *)mod);
74871 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
74872 #ifdef CONFIG_MODULE_UNLOAD
74873 kdb_printf("%4ld ", module_refcount(mod));
74874 #endif
74875 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
74876 kdb_printf(" (Loading)");
74877 else
74878 kdb_printf(" (Live)");
74879 - kdb_printf(" 0x%p", mod->module_core);
74880 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
74881
74882 #ifdef CONFIG_MODULE_UNLOAD
74883 {
74884 diff --git a/kernel/events/core.c b/kernel/events/core.c
74885 index 9fcb094..8370228 100644
74886 --- a/kernel/events/core.c
74887 +++ b/kernel/events/core.c
74888 @@ -154,8 +154,15 @@ static struct srcu_struct pmus_srcu;
74889 * 0 - disallow raw tracepoint access for unpriv
74890 * 1 - disallow cpu events for unpriv
74891 * 2 - disallow kernel profiling for unpriv
74892 + * 3 - disallow all unpriv perf event use
74893 */
74894 -int sysctl_perf_event_paranoid __read_mostly = 1;
74895 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
74896 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
74897 +#elif CONFIG_GRKERNSEC_HIDESYM
74898 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
74899 +#else
74900 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
74901 +#endif
74902
74903 /* Minimum for 512 kiB + 1 user control page */
74904 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
74905 @@ -182,7 +189,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
74906 return 0;
74907 }
74908
74909 -static atomic64_t perf_event_id;
74910 +static atomic64_unchecked_t perf_event_id;
74911
74912 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
74913 enum event_type_t event_type);
74914 @@ -2677,7 +2684,7 @@ static void __perf_event_read(void *info)
74915
74916 static inline u64 perf_event_count(struct perf_event *event)
74917 {
74918 - return local64_read(&event->count) + atomic64_read(&event->child_count);
74919 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
74920 }
74921
74922 static u64 perf_event_read(struct perf_event *event)
74923 @@ -3007,9 +3014,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
74924 mutex_lock(&event->child_mutex);
74925 total += perf_event_read(event);
74926 *enabled += event->total_time_enabled +
74927 - atomic64_read(&event->child_total_time_enabled);
74928 + atomic64_read_unchecked(&event->child_total_time_enabled);
74929 *running += event->total_time_running +
74930 - atomic64_read(&event->child_total_time_running);
74931 + atomic64_read_unchecked(&event->child_total_time_running);
74932
74933 list_for_each_entry(child, &event->child_list, child_list) {
74934 total += perf_event_read(child);
74935 @@ -3412,10 +3419,10 @@ void perf_event_update_userpage(struct perf_event *event)
74936 userpg->offset -= local64_read(&event->hw.prev_count);
74937
74938 userpg->time_enabled = enabled +
74939 - atomic64_read(&event->child_total_time_enabled);
74940 + atomic64_read_unchecked(&event->child_total_time_enabled);
74941
74942 userpg->time_running = running +
74943 - atomic64_read(&event->child_total_time_running);
74944 + atomic64_read_unchecked(&event->child_total_time_running);
74945
74946 arch_perf_update_userpage(userpg, now);
74947
74948 @@ -3886,7 +3893,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
74949
74950 /* Data. */
74951 sp = perf_user_stack_pointer(regs);
74952 - rem = __output_copy_user(handle, (void *) sp, dump_size);
74953 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
74954 dyn_size = dump_size - rem;
74955
74956 perf_output_skip(handle, rem);
74957 @@ -3974,11 +3981,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
74958 values[n++] = perf_event_count(event);
74959 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
74960 values[n++] = enabled +
74961 - atomic64_read(&event->child_total_time_enabled);
74962 + atomic64_read_unchecked(&event->child_total_time_enabled);
74963 }
74964 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
74965 values[n++] = running +
74966 - atomic64_read(&event->child_total_time_running);
74967 + atomic64_read_unchecked(&event->child_total_time_running);
74968 }
74969 if (read_format & PERF_FORMAT_ID)
74970 values[n++] = primary_event_id(event);
74971 @@ -4726,12 +4733,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
74972 * need to add enough zero bytes after the string to handle
74973 * the 64bit alignment we do later.
74974 */
74975 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
74976 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
74977 if (!buf) {
74978 name = strncpy(tmp, "//enomem", sizeof(tmp));
74979 goto got_name;
74980 }
74981 - name = d_path(&file->f_path, buf, PATH_MAX);
74982 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
74983 if (IS_ERR(name)) {
74984 name = strncpy(tmp, "//toolong", sizeof(tmp));
74985 goto got_name;
74986 @@ -6167,7 +6174,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
74987 event->parent = parent_event;
74988
74989 event->ns = get_pid_ns(task_active_pid_ns(current));
74990 - event->id = atomic64_inc_return(&perf_event_id);
74991 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
74992
74993 event->state = PERF_EVENT_STATE_INACTIVE;
74994
74995 @@ -6463,6 +6470,11 @@ SYSCALL_DEFINE5(perf_event_open,
74996 if (flags & ~PERF_FLAG_ALL)
74997 return -EINVAL;
74998
74999 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
75000 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
75001 + return -EACCES;
75002 +#endif
75003 +
75004 err = perf_copy_attr(attr_uptr, &attr);
75005 if (err)
75006 return err;
75007 @@ -6795,10 +6807,10 @@ static void sync_child_event(struct perf_event *child_event,
75008 /*
75009 * Add back the child's count to the parent's count:
75010 */
75011 - atomic64_add(child_val, &parent_event->child_count);
75012 - atomic64_add(child_event->total_time_enabled,
75013 + atomic64_add_unchecked(child_val, &parent_event->child_count);
75014 + atomic64_add_unchecked(child_event->total_time_enabled,
75015 &parent_event->child_total_time_enabled);
75016 - atomic64_add(child_event->total_time_running,
75017 + atomic64_add_unchecked(child_event->total_time_running,
75018 &parent_event->child_total_time_running);
75019
75020 /*
75021 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
75022 index eb675c4..54912ff 100644
75023 --- a/kernel/events/internal.h
75024 +++ b/kernel/events/internal.h
75025 @@ -77,10 +77,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
75026 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
75027 }
75028
75029 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
75030 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
75031 static inline unsigned int \
75032 func_name(struct perf_output_handle *handle, \
75033 - const void *buf, unsigned int len) \
75034 + const void user *buf, unsigned int len) \
75035 { \
75036 unsigned long size, written; \
75037 \
75038 @@ -112,17 +112,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
75039 return n;
75040 }
75041
75042 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
75043 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
75044
75045 #define MEMCPY_SKIP(dst, src, n) (n)
75046
75047 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
75048 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
75049
75050 #ifndef arch_perf_out_copy_user
75051 #define arch_perf_out_copy_user __copy_from_user_inatomic
75052 #endif
75053
75054 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
75055 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
75056
75057 /* Callchain handling */
75058 extern struct perf_callchain_entry *
75059 diff --git a/kernel/exit.c b/kernel/exit.c
75060 index 60bc027..ca6d727 100644
75061 --- a/kernel/exit.c
75062 +++ b/kernel/exit.c
75063 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
75064 struct task_struct *leader;
75065 int zap_leader;
75066 repeat:
75067 +#ifdef CONFIG_NET
75068 + gr_del_task_from_ip_table(p);
75069 +#endif
75070 +
75071 /* don't need to get the RCU readlock here - the process is dead and
75072 * can't be modifying its own credentials. But shut RCU-lockdep up */
75073 rcu_read_lock();
75074 @@ -340,7 +344,7 @@ int allow_signal(int sig)
75075 * know it'll be handled, so that they don't get converted to
75076 * SIGKILL or just silently dropped.
75077 */
75078 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
75079 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
75080 recalc_sigpending();
75081 spin_unlock_irq(&current->sighand->siglock);
75082 return 0;
75083 @@ -710,6 +714,8 @@ void do_exit(long code)
75084 struct task_struct *tsk = current;
75085 int group_dead;
75086
75087 + set_fs(USER_DS);
75088 +
75089 profile_task_exit(tsk);
75090
75091 WARN_ON(blk_needs_flush_plug(tsk));
75092 @@ -726,7 +732,6 @@ void do_exit(long code)
75093 * mm_release()->clear_child_tid() from writing to a user-controlled
75094 * kernel address.
75095 */
75096 - set_fs(USER_DS);
75097
75098 ptrace_event(PTRACE_EVENT_EXIT, code);
75099
75100 @@ -785,6 +790,9 @@ void do_exit(long code)
75101 tsk->exit_code = code;
75102 taskstats_exit(tsk, group_dead);
75103
75104 + gr_acl_handle_psacct(tsk, code);
75105 + gr_acl_handle_exit();
75106 +
75107 exit_mm(tsk);
75108
75109 if (group_dead)
75110 @@ -905,7 +913,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
75111 * Take down every thread in the group. This is called by fatal signals
75112 * as well as by sys_exit_group (below).
75113 */
75114 -void
75115 +__noreturn void
75116 do_group_exit(int exit_code)
75117 {
75118 struct signal_struct *sig = current->signal;
75119 diff --git a/kernel/fork.c b/kernel/fork.c
75120 index 1766d32..c0e44e2 100644
75121 --- a/kernel/fork.c
75122 +++ b/kernel/fork.c
75123 @@ -318,7 +318,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
75124 *stackend = STACK_END_MAGIC; /* for overflow detection */
75125
75126 #ifdef CONFIG_CC_STACKPROTECTOR
75127 - tsk->stack_canary = get_random_int();
75128 + tsk->stack_canary = pax_get_random_long();
75129 #endif
75130
75131 /*
75132 @@ -344,13 +344,81 @@ free_tsk:
75133 }
75134
75135 #ifdef CONFIG_MMU
75136 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
75137 +{
75138 + struct vm_area_struct *tmp;
75139 + unsigned long charge;
75140 + struct mempolicy *pol;
75141 + struct file *file;
75142 +
75143 + charge = 0;
75144 + if (mpnt->vm_flags & VM_ACCOUNT) {
75145 + unsigned long len = vma_pages(mpnt);
75146 +
75147 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75148 + goto fail_nomem;
75149 + charge = len;
75150 + }
75151 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75152 + if (!tmp)
75153 + goto fail_nomem;
75154 + *tmp = *mpnt;
75155 + tmp->vm_mm = mm;
75156 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
75157 + pol = mpol_dup(vma_policy(mpnt));
75158 + if (IS_ERR(pol))
75159 + goto fail_nomem_policy;
75160 + vma_set_policy(tmp, pol);
75161 + if (anon_vma_fork(tmp, mpnt))
75162 + goto fail_nomem_anon_vma_fork;
75163 + tmp->vm_flags &= ~VM_LOCKED;
75164 + tmp->vm_next = tmp->vm_prev = NULL;
75165 + tmp->vm_mirror = NULL;
75166 + file = tmp->vm_file;
75167 + if (file) {
75168 + struct inode *inode = file_inode(file);
75169 + struct address_space *mapping = file->f_mapping;
75170 +
75171 + get_file(file);
75172 + if (tmp->vm_flags & VM_DENYWRITE)
75173 + atomic_dec(&inode->i_writecount);
75174 + mutex_lock(&mapping->i_mmap_mutex);
75175 + if (tmp->vm_flags & VM_SHARED)
75176 + mapping->i_mmap_writable++;
75177 + flush_dcache_mmap_lock(mapping);
75178 + /* insert tmp into the share list, just after mpnt */
75179 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75180 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
75181 + else
75182 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
75183 + flush_dcache_mmap_unlock(mapping);
75184 + mutex_unlock(&mapping->i_mmap_mutex);
75185 + }
75186 +
75187 + /*
75188 + * Clear hugetlb-related page reserves for children. This only
75189 + * affects MAP_PRIVATE mappings. Faults generated by the child
75190 + * are not guaranteed to succeed, even if read-only
75191 + */
75192 + if (is_vm_hugetlb_page(tmp))
75193 + reset_vma_resv_huge_pages(tmp);
75194 +
75195 + return tmp;
75196 +
75197 +fail_nomem_anon_vma_fork:
75198 + mpol_put(pol);
75199 +fail_nomem_policy:
75200 + kmem_cache_free(vm_area_cachep, tmp);
75201 +fail_nomem:
75202 + vm_unacct_memory(charge);
75203 + return NULL;
75204 +}
75205 +
75206 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75207 {
75208 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
75209 struct rb_node **rb_link, *rb_parent;
75210 int retval;
75211 - unsigned long charge;
75212 - struct mempolicy *pol;
75213
75214 uprobe_start_dup_mmap();
75215 down_write(&oldmm->mmap_sem);
75216 @@ -364,8 +432,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75217 mm->locked_vm = 0;
75218 mm->mmap = NULL;
75219 mm->mmap_cache = NULL;
75220 - mm->free_area_cache = oldmm->mmap_base;
75221 - mm->cached_hole_size = ~0UL;
75222 + mm->free_area_cache = oldmm->free_area_cache;
75223 + mm->cached_hole_size = oldmm->cached_hole_size;
75224 mm->map_count = 0;
75225 cpumask_clear(mm_cpumask(mm));
75226 mm->mm_rb = RB_ROOT;
75227 @@ -381,57 +449,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75228
75229 prev = NULL;
75230 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
75231 - struct file *file;
75232 -
75233 if (mpnt->vm_flags & VM_DONTCOPY) {
75234 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
75235 -vma_pages(mpnt));
75236 continue;
75237 }
75238 - charge = 0;
75239 - if (mpnt->vm_flags & VM_ACCOUNT) {
75240 - unsigned long len = vma_pages(mpnt);
75241 -
75242 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75243 - goto fail_nomem;
75244 - charge = len;
75245 - }
75246 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75247 - if (!tmp)
75248 - goto fail_nomem;
75249 - *tmp = *mpnt;
75250 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
75251 - pol = mpol_dup(vma_policy(mpnt));
75252 - retval = PTR_ERR(pol);
75253 - if (IS_ERR(pol))
75254 - goto fail_nomem_policy;
75255 - vma_set_policy(tmp, pol);
75256 - tmp->vm_mm = mm;
75257 - if (anon_vma_fork(tmp, mpnt))
75258 - goto fail_nomem_anon_vma_fork;
75259 - tmp->vm_flags &= ~VM_LOCKED;
75260 - tmp->vm_next = tmp->vm_prev = NULL;
75261 - file = tmp->vm_file;
75262 - if (file) {
75263 - struct inode *inode = file_inode(file);
75264 - struct address_space *mapping = file->f_mapping;
75265 -
75266 - get_file(file);
75267 - if (tmp->vm_flags & VM_DENYWRITE)
75268 - atomic_dec(&inode->i_writecount);
75269 - mutex_lock(&mapping->i_mmap_mutex);
75270 - if (tmp->vm_flags & VM_SHARED)
75271 - mapping->i_mmap_writable++;
75272 - flush_dcache_mmap_lock(mapping);
75273 - /* insert tmp into the share list, just after mpnt */
75274 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75275 - vma_nonlinear_insert(tmp,
75276 - &mapping->i_mmap_nonlinear);
75277 - else
75278 - vma_interval_tree_insert_after(tmp, mpnt,
75279 - &mapping->i_mmap);
75280 - flush_dcache_mmap_unlock(mapping);
75281 - mutex_unlock(&mapping->i_mmap_mutex);
75282 + tmp = dup_vma(mm, oldmm, mpnt);
75283 + if (!tmp) {
75284 + retval = -ENOMEM;
75285 + goto out;
75286 }
75287
75288 /*
75289 @@ -463,6 +489,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75290 if (retval)
75291 goto out;
75292 }
75293 +
75294 +#ifdef CONFIG_PAX_SEGMEXEC
75295 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
75296 + struct vm_area_struct *mpnt_m;
75297 +
75298 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
75299 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
75300 +
75301 + if (!mpnt->vm_mirror)
75302 + continue;
75303 +
75304 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
75305 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
75306 + mpnt->vm_mirror = mpnt_m;
75307 + } else {
75308 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
75309 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
75310 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
75311 + mpnt->vm_mirror->vm_mirror = mpnt;
75312 + }
75313 + }
75314 + BUG_ON(mpnt_m);
75315 + }
75316 +#endif
75317 +
75318 /* a new mm has just been created */
75319 arch_dup_mmap(oldmm, mm);
75320 retval = 0;
75321 @@ -472,14 +523,6 @@ out:
75322 up_write(&oldmm->mmap_sem);
75323 uprobe_end_dup_mmap();
75324 return retval;
75325 -fail_nomem_anon_vma_fork:
75326 - mpol_put(pol);
75327 -fail_nomem_policy:
75328 - kmem_cache_free(vm_area_cachep, tmp);
75329 -fail_nomem:
75330 - retval = -ENOMEM;
75331 - vm_unacct_memory(charge);
75332 - goto out;
75333 }
75334
75335 static inline int mm_alloc_pgd(struct mm_struct *mm)
75336 @@ -694,8 +737,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
75337 return ERR_PTR(err);
75338
75339 mm = get_task_mm(task);
75340 - if (mm && mm != current->mm &&
75341 - !ptrace_may_access(task, mode)) {
75342 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
75343 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
75344 mmput(mm);
75345 mm = ERR_PTR(-EACCES);
75346 }
75347 @@ -917,13 +960,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
75348 spin_unlock(&fs->lock);
75349 return -EAGAIN;
75350 }
75351 - fs->users++;
75352 + atomic_inc(&fs->users);
75353 spin_unlock(&fs->lock);
75354 return 0;
75355 }
75356 tsk->fs = copy_fs_struct(fs);
75357 if (!tsk->fs)
75358 return -ENOMEM;
75359 + /* Carry through gr_chroot_dentry and is_chrooted instead
75360 + of recomputing it here. Already copied when the task struct
75361 + is duplicated. This allows pivot_root to not be treated as
75362 + a chroot
75363 + */
75364 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
75365 +
75366 return 0;
75367 }
75368
75369 @@ -1196,6 +1246,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75370 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
75371 #endif
75372 retval = -EAGAIN;
75373 +
75374 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
75375 +
75376 if (atomic_read(&p->real_cred->user->processes) >=
75377 task_rlimit(p, RLIMIT_NPROC)) {
75378 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
75379 @@ -1441,6 +1494,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75380 goto bad_fork_free_pid;
75381 }
75382
75383 + /* synchronizes with gr_set_acls()
75384 + we need to call this past the point of no return for fork()
75385 + */
75386 + gr_copy_label(p);
75387 +
75388 if (clone_flags & CLONE_THREAD) {
75389 current->signal->nr_threads++;
75390 atomic_inc(&current->signal->live);
75391 @@ -1524,6 +1582,8 @@ bad_fork_cleanup_count:
75392 bad_fork_free:
75393 free_task(p);
75394 fork_out:
75395 + gr_log_forkfail(retval);
75396 +
75397 return ERR_PTR(retval);
75398 }
75399
75400 @@ -1574,6 +1634,23 @@ long do_fork(unsigned long clone_flags,
75401 return -EINVAL;
75402 }
75403
75404 +#ifdef CONFIG_GRKERNSEC
75405 + if (clone_flags & CLONE_NEWUSER) {
75406 + /*
75407 + * This doesn't really inspire confidence:
75408 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
75409 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
75410 + * Increases kernel attack surface in areas developers
75411 + * previously cared little about ("low importance due
75412 + * to requiring "root" capability")
75413 + * To be removed when this code receives *proper* review
75414 + */
75415 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
75416 + !capable(CAP_SETGID))
75417 + return -EPERM;
75418 + }
75419 +#endif
75420 +
75421 /*
75422 * Determine whether and which event to report to ptracer. When
75423 * called from kernel_thread or CLONE_UNTRACED is explicitly
75424 @@ -1608,6 +1685,8 @@ long do_fork(unsigned long clone_flags,
75425 if (clone_flags & CLONE_PARENT_SETTID)
75426 put_user(nr, parent_tidptr);
75427
75428 + gr_handle_brute_check();
75429 +
75430 if (clone_flags & CLONE_VFORK) {
75431 p->vfork_done = &vfork;
75432 init_completion(&vfork);
75433 @@ -1761,7 +1840,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
75434 return 0;
75435
75436 /* don't need lock here; in the worst case we'll do useless copy */
75437 - if (fs->users == 1)
75438 + if (atomic_read(&fs->users) == 1)
75439 return 0;
75440
75441 *new_fsp = copy_fs_struct(fs);
75442 @@ -1873,7 +1952,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
75443 fs = current->fs;
75444 spin_lock(&fs->lock);
75445 current->fs = new_fs;
75446 - if (--fs->users)
75447 + gr_set_chroot_entries(current, &current->fs->root);
75448 + if (atomic_dec_return(&fs->users))
75449 new_fs = NULL;
75450 else
75451 new_fs = fs;
75452 diff --git a/kernel/futex.c b/kernel/futex.c
75453 index b26dcfc..39e266a 100644
75454 --- a/kernel/futex.c
75455 +++ b/kernel/futex.c
75456 @@ -54,6 +54,7 @@
75457 #include <linux/mount.h>
75458 #include <linux/pagemap.h>
75459 #include <linux/syscalls.h>
75460 +#include <linux/ptrace.h>
75461 #include <linux/signal.h>
75462 #include <linux/export.h>
75463 #include <linux/magic.h>
75464 @@ -241,6 +242,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
75465 struct page *page, *page_head;
75466 int err, ro = 0;
75467
75468 +#ifdef CONFIG_PAX_SEGMEXEC
75469 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
75470 + return -EFAULT;
75471 +#endif
75472 +
75473 /*
75474 * The futex address must be "naturally" aligned.
75475 */
75476 @@ -2732,6 +2738,7 @@ static int __init futex_init(void)
75477 {
75478 u32 curval;
75479 int i;
75480 + mm_segment_t oldfs;
75481
75482 /*
75483 * This will fail and we want it. Some arch implementations do
75484 @@ -2743,8 +2750,11 @@ static int __init futex_init(void)
75485 * implementation, the non-functional ones will return
75486 * -ENOSYS.
75487 */
75488 + oldfs = get_fs();
75489 + set_fs(USER_DS);
75490 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
75491 futex_cmpxchg_enabled = 1;
75492 + set_fs(oldfs);
75493
75494 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
75495 plist_head_init(&futex_queues[i].chain);
75496 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
75497 index f9f44fd..29885e4 100644
75498 --- a/kernel/futex_compat.c
75499 +++ b/kernel/futex_compat.c
75500 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
75501 return 0;
75502 }
75503
75504 -static void __user *futex_uaddr(struct robust_list __user *entry,
75505 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
75506 compat_long_t futex_offset)
75507 {
75508 compat_uptr_t base = ptr_to_compat(entry);
75509 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
75510 index 9b22d03..6295b62 100644
75511 --- a/kernel/gcov/base.c
75512 +++ b/kernel/gcov/base.c
75513 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
75514 }
75515
75516 #ifdef CONFIG_MODULES
75517 -static inline int within(void *addr, void *start, unsigned long size)
75518 -{
75519 - return ((addr >= start) && (addr < start + size));
75520 -}
75521 -
75522 /* Update list and generate events when modules are unloaded. */
75523 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75524 void *data)
75525 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75526 prev = NULL;
75527 /* Remove entries located in module from linked list. */
75528 for (info = gcov_info_head; info; info = info->next) {
75529 - if (within(info, mod->module_core, mod->core_size)) {
75530 + if (within_module_core_rw((unsigned long)info, mod)) {
75531 if (prev)
75532 prev->next = info->next;
75533 else
75534 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
75535 index 7ef5556..8247f11 100644
75536 --- a/kernel/hrtimer.c
75537 +++ b/kernel/hrtimer.c
75538 @@ -1416,7 +1416,7 @@ void hrtimer_peek_ahead_timers(void)
75539 local_irq_restore(flags);
75540 }
75541
75542 -static void run_hrtimer_softirq(struct softirq_action *h)
75543 +static void run_hrtimer_softirq(void)
75544 {
75545 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
75546
75547 @@ -1758,7 +1758,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
75548 return NOTIFY_OK;
75549 }
75550
75551 -static struct notifier_block __cpuinitdata hrtimers_nb = {
75552 +static struct notifier_block hrtimers_nb = {
75553 .notifier_call = hrtimer_cpu_notify,
75554 };
75555
75556 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
75557 index 55fcce6..0e4cf34 100644
75558 --- a/kernel/irq_work.c
75559 +++ b/kernel/irq_work.c
75560 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
75561 return NOTIFY_OK;
75562 }
75563
75564 -static struct notifier_block cpu_notify;
75565 +static struct notifier_block cpu_notify = {
75566 + .notifier_call = irq_work_cpu_notify,
75567 + .priority = 0,
75568 +};
75569
75570 static __init int irq_work_init_cpu_notifier(void)
75571 {
75572 - cpu_notify.notifier_call = irq_work_cpu_notify;
75573 - cpu_notify.priority = 0;
75574 register_cpu_notifier(&cpu_notify);
75575 return 0;
75576 }
75577 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
75578 index 60f48fa..7f3a770 100644
75579 --- a/kernel/jump_label.c
75580 +++ b/kernel/jump_label.c
75581 @@ -13,6 +13,7 @@
75582 #include <linux/sort.h>
75583 #include <linux/err.h>
75584 #include <linux/static_key.h>
75585 +#include <linux/mm.h>
75586
75587 #ifdef HAVE_JUMP_LABEL
75588
75589 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
75590
75591 size = (((unsigned long)stop - (unsigned long)start)
75592 / sizeof(struct jump_entry));
75593 + pax_open_kernel();
75594 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
75595 + pax_close_kernel();
75596 }
75597
75598 static void jump_label_update(struct static_key *key, int enable);
75599 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
75600 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
75601 struct jump_entry *iter;
75602
75603 + pax_open_kernel();
75604 for (iter = iter_start; iter < iter_stop; iter++) {
75605 if (within_module_init(iter->code, mod))
75606 iter->code = 0;
75607 }
75608 + pax_close_kernel();
75609 }
75610
75611 static int
75612 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
75613 index 2169fee..706ccca 100644
75614 --- a/kernel/kallsyms.c
75615 +++ b/kernel/kallsyms.c
75616 @@ -11,6 +11,9 @@
75617 * Changed the compression method from stem compression to "table lookup"
75618 * compression (see scripts/kallsyms.c for a more complete description)
75619 */
75620 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75621 +#define __INCLUDED_BY_HIDESYM 1
75622 +#endif
75623 #include <linux/kallsyms.h>
75624 #include <linux/module.h>
75625 #include <linux/init.h>
75626 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
75627
75628 static inline int is_kernel_inittext(unsigned long addr)
75629 {
75630 + if (system_state != SYSTEM_BOOTING)
75631 + return 0;
75632 +
75633 if (addr >= (unsigned long)_sinittext
75634 && addr <= (unsigned long)_einittext)
75635 return 1;
75636 return 0;
75637 }
75638
75639 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75640 +#ifdef CONFIG_MODULES
75641 +static inline int is_module_text(unsigned long addr)
75642 +{
75643 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
75644 + return 1;
75645 +
75646 + addr = ktla_ktva(addr);
75647 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
75648 +}
75649 +#else
75650 +static inline int is_module_text(unsigned long addr)
75651 +{
75652 + return 0;
75653 +}
75654 +#endif
75655 +#endif
75656 +
75657 static inline int is_kernel_text(unsigned long addr)
75658 {
75659 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
75660 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
75661
75662 static inline int is_kernel(unsigned long addr)
75663 {
75664 +
75665 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75666 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
75667 + return 1;
75668 +
75669 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
75670 +#else
75671 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
75672 +#endif
75673 +
75674 return 1;
75675 return in_gate_area_no_mm(addr);
75676 }
75677
75678 static int is_ksym_addr(unsigned long addr)
75679 {
75680 +
75681 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75682 + if (is_module_text(addr))
75683 + return 0;
75684 +#endif
75685 +
75686 if (all_var)
75687 return is_kernel(addr);
75688
75689 @@ -470,7 +509,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
75690
75691 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
75692 {
75693 - iter->name[0] = '\0';
75694 iter->nameoff = get_symbol_offset(new_pos);
75695 iter->pos = new_pos;
75696 }
75697 @@ -518,6 +556,11 @@ static int s_show(struct seq_file *m, void *p)
75698 {
75699 struct kallsym_iter *iter = m->private;
75700
75701 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75702 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
75703 + return 0;
75704 +#endif
75705 +
75706 /* Some debugging symbols have no name. Ignore them. */
75707 if (!iter->name[0])
75708 return 0;
75709 @@ -531,6 +574,7 @@ static int s_show(struct seq_file *m, void *p)
75710 */
75711 type = iter->exported ? toupper(iter->type) :
75712 tolower(iter->type);
75713 +
75714 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
75715 type, iter->name, iter->module_name);
75716 } else
75717 @@ -556,7 +600,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
75718 struct kallsym_iter *iter;
75719 int ret;
75720
75721 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
75722 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
75723 if (!iter)
75724 return -ENOMEM;
75725 reset_iter(iter, 0);
75726 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
75727 index e30ac0f..3528cac 100644
75728 --- a/kernel/kcmp.c
75729 +++ b/kernel/kcmp.c
75730 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
75731 struct task_struct *task1, *task2;
75732 int ret;
75733
75734 +#ifdef CONFIG_GRKERNSEC
75735 + return -ENOSYS;
75736 +#endif
75737 +
75738 rcu_read_lock();
75739
75740 /*
75741 diff --git a/kernel/kexec.c b/kernel/kexec.c
75742 index ffd4e11..c3ff6bf 100644
75743 --- a/kernel/kexec.c
75744 +++ b/kernel/kexec.c
75745 @@ -1048,7 +1048,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
75746 unsigned long flags)
75747 {
75748 struct compat_kexec_segment in;
75749 - struct kexec_segment out, __user *ksegments;
75750 + struct kexec_segment out;
75751 + struct kexec_segment __user *ksegments;
75752 unsigned long i, result;
75753
75754 /* Don't allow clients that don't understand the native
75755 diff --git a/kernel/kmod.c b/kernel/kmod.c
75756 index 8985c87..f539dbe 100644
75757 --- a/kernel/kmod.c
75758 +++ b/kernel/kmod.c
75759 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
75760 kfree(info->argv);
75761 }
75762
75763 -static int call_modprobe(char *module_name, int wait)
75764 +static int call_modprobe(char *module_name, char *module_param, int wait)
75765 {
75766 static char *envp[] = {
75767 "HOME=/",
75768 @@ -84,7 +84,7 @@ static int call_modprobe(char *module_name, int wait)
75769 NULL
75770 };
75771
75772 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
75773 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
75774 if (!argv)
75775 goto out;
75776
75777 @@ -96,7 +96,8 @@ static int call_modprobe(char *module_name, int wait)
75778 argv[1] = "-q";
75779 argv[2] = "--";
75780 argv[3] = module_name; /* check free_modprobe_argv() */
75781 - argv[4] = NULL;
75782 + argv[4] = module_param;
75783 + argv[5] = NULL;
75784
75785 return call_usermodehelper_fns(modprobe_path, argv, envp,
75786 wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
75787 @@ -121,9 +122,8 @@ out:
75788 * If module auto-loading support is disabled then this function
75789 * becomes a no-operation.
75790 */
75791 -int __request_module(bool wait, const char *fmt, ...)
75792 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
75793 {
75794 - va_list args;
75795 char module_name[MODULE_NAME_LEN];
75796 unsigned int max_modprobes;
75797 int ret;
75798 @@ -139,9 +139,7 @@ int __request_module(bool wait, const char *fmt, ...)
75799 */
75800 WARN_ON_ONCE(wait && current_is_async());
75801
75802 - va_start(args, fmt);
75803 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
75804 - va_end(args);
75805 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
75806 if (ret >= MODULE_NAME_LEN)
75807 return -ENAMETOOLONG;
75808
75809 @@ -149,6 +147,20 @@ int __request_module(bool wait, const char *fmt, ...)
75810 if (ret)
75811 return ret;
75812
75813 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75814 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75815 + /* hack to workaround consolekit/udisks stupidity */
75816 + read_lock(&tasklist_lock);
75817 + if (!strcmp(current->comm, "mount") &&
75818 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
75819 + read_unlock(&tasklist_lock);
75820 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
75821 + return -EPERM;
75822 + }
75823 + read_unlock(&tasklist_lock);
75824 + }
75825 +#endif
75826 +
75827 /* If modprobe needs a service that is in a module, we get a recursive
75828 * loop. Limit the number of running kmod threads to max_threads/2 or
75829 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
75830 @@ -177,11 +189,52 @@ int __request_module(bool wait, const char *fmt, ...)
75831
75832 trace_module_request(module_name, wait, _RET_IP_);
75833
75834 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75835 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75836
75837 atomic_dec(&kmod_concurrent);
75838 return ret;
75839 }
75840 +
75841 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
75842 +{
75843 + va_list args;
75844 + int ret;
75845 +
75846 + va_start(args, fmt);
75847 + ret = ____request_module(wait, module_param, fmt, args);
75848 + va_end(args);
75849 +
75850 + return ret;
75851 +}
75852 +
75853 +int __request_module(bool wait, const char *fmt, ...)
75854 +{
75855 + va_list args;
75856 + int ret;
75857 +
75858 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75859 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75860 + char module_param[MODULE_NAME_LEN];
75861 +
75862 + memset(module_param, 0, sizeof(module_param));
75863 +
75864 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
75865 +
75866 + va_start(args, fmt);
75867 + ret = ____request_module(wait, module_param, fmt, args);
75868 + va_end(args);
75869 +
75870 + return ret;
75871 + }
75872 +#endif
75873 +
75874 + va_start(args, fmt);
75875 + ret = ____request_module(wait, NULL, fmt, args);
75876 + va_end(args);
75877 +
75878 + return ret;
75879 +}
75880 +
75881 EXPORT_SYMBOL(__request_module);
75882 #endif /* CONFIG_MODULES */
75883
75884 @@ -292,7 +345,7 @@ static int wait_for_helper(void *data)
75885 *
75886 * Thus the __user pointer cast is valid here.
75887 */
75888 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
75889 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
75890
75891 /*
75892 * If ret is 0, either ____call_usermodehelper failed and the
75893 @@ -649,7 +702,7 @@ EXPORT_SYMBOL(call_usermodehelper_fns);
75894 static int proc_cap_handler(struct ctl_table *table, int write,
75895 void __user *buffer, size_t *lenp, loff_t *ppos)
75896 {
75897 - struct ctl_table t;
75898 + ctl_table_no_const t;
75899 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
75900 kernel_cap_t new_cap;
75901 int err, i;
75902 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
75903 index 3fed7f0..a3f95ed 100644
75904 --- a/kernel/kprobes.c
75905 +++ b/kernel/kprobes.c
75906 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
75907 * kernel image and loaded module images reside. This is required
75908 * so x86_64 can correctly handle the %rip-relative fixups.
75909 */
75910 - kip->insns = module_alloc(PAGE_SIZE);
75911 + kip->insns = module_alloc_exec(PAGE_SIZE);
75912 if (!kip->insns) {
75913 kfree(kip);
75914 return NULL;
75915 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
75916 */
75917 if (!list_is_singular(&kip->list)) {
75918 list_del(&kip->list);
75919 - module_free(NULL, kip->insns);
75920 + module_free_exec(NULL, kip->insns);
75921 kfree(kip);
75922 }
75923 return 1;
75924 @@ -2073,7 +2073,7 @@ static int __init init_kprobes(void)
75925 {
75926 int i, err = 0;
75927 unsigned long offset = 0, size = 0;
75928 - char *modname, namebuf[128];
75929 + char *modname, namebuf[KSYM_NAME_LEN];
75930 const char *symbol_name;
75931 void *addr;
75932 struct kprobe_blackpoint *kb;
75933 @@ -2158,11 +2158,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
75934 kprobe_type = "k";
75935
75936 if (sym)
75937 - seq_printf(pi, "%p %s %s+0x%x %s ",
75938 + seq_printf(pi, "%pK %s %s+0x%x %s ",
75939 p->addr, kprobe_type, sym, offset,
75940 (modname ? modname : " "));
75941 else
75942 - seq_printf(pi, "%p %s %p ",
75943 + seq_printf(pi, "%pK %s %pK ",
75944 p->addr, kprobe_type, p->addr);
75945
75946 if (!pp)
75947 @@ -2199,7 +2199,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
75948 const char *sym = NULL;
75949 unsigned int i = *(loff_t *) v;
75950 unsigned long offset = 0;
75951 - char *modname, namebuf[128];
75952 + char *modname, namebuf[KSYM_NAME_LEN];
75953
75954 head = &kprobe_table[i];
75955 preempt_disable();
75956 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
75957 index 6ada93c..dce7d5d 100644
75958 --- a/kernel/ksysfs.c
75959 +++ b/kernel/ksysfs.c
75960 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
75961 {
75962 if (count+1 > UEVENT_HELPER_PATH_LEN)
75963 return -ENOENT;
75964 + if (!capable(CAP_SYS_ADMIN))
75965 + return -EPERM;
75966 memcpy(uevent_helper, buf, count);
75967 uevent_helper[count] = '\0';
75968 if (count && uevent_helper[count-1] == '\n')
75969 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
75970 return count;
75971 }
75972
75973 -static struct bin_attribute notes_attr = {
75974 +static bin_attribute_no_const notes_attr __read_only = {
75975 .attr = {
75976 .name = "notes",
75977 .mode = S_IRUGO,
75978 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
75979 index 8a0efac..56f1e2d 100644
75980 --- a/kernel/lockdep.c
75981 +++ b/kernel/lockdep.c
75982 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
75983 end = (unsigned long) &_end,
75984 addr = (unsigned long) obj;
75985
75986 +#ifdef CONFIG_PAX_KERNEXEC
75987 + start = ktla_ktva(start);
75988 +#endif
75989 +
75990 /*
75991 * static variable?
75992 */
75993 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
75994 if (!static_obj(lock->key)) {
75995 debug_locks_off();
75996 printk("INFO: trying to register non-static key.\n");
75997 + printk("lock:%pS key:%pS.\n", lock, lock->key);
75998 printk("the code is fine but needs lockdep annotation.\n");
75999 printk("turning off the locking correctness validator.\n");
76000 dump_stack();
76001 @@ -3078,7 +3083,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
76002 if (!class)
76003 return 0;
76004 }
76005 - atomic_inc((atomic_t *)&class->ops);
76006 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
76007 if (very_verbose(class)) {
76008 printk("\nacquire class [%p] %s", class->key, class->name);
76009 if (class->name_version > 1)
76010 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
76011 index b2c71c5..7b88d63 100644
76012 --- a/kernel/lockdep_proc.c
76013 +++ b/kernel/lockdep_proc.c
76014 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
76015 return 0;
76016 }
76017
76018 - seq_printf(m, "%p", class->key);
76019 + seq_printf(m, "%pK", class->key);
76020 #ifdef CONFIG_DEBUG_LOCKDEP
76021 seq_printf(m, " OPS:%8ld", class->ops);
76022 #endif
76023 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
76024
76025 list_for_each_entry(entry, &class->locks_after, entry) {
76026 if (entry->distance == 1) {
76027 - seq_printf(m, " -> [%p] ", entry->class->key);
76028 + seq_printf(m, " -> [%pK] ", entry->class->key);
76029 print_name(m, entry->class);
76030 seq_puts(m, "\n");
76031 }
76032 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
76033 if (!class->key)
76034 continue;
76035
76036 - seq_printf(m, "[%p] ", class->key);
76037 + seq_printf(m, "[%pK] ", class->key);
76038 print_name(m, class);
76039 seq_puts(m, "\n");
76040 }
76041 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76042 if (!i)
76043 seq_line(m, '-', 40-namelen, namelen);
76044
76045 - snprintf(ip, sizeof(ip), "[<%p>]",
76046 + snprintf(ip, sizeof(ip), "[<%pK>]",
76047 (void *)class->contention_point[i]);
76048 seq_printf(m, "%40s %14lu %29s %pS\n",
76049 name, stats->contention_point[i],
76050 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76051 if (!i)
76052 seq_line(m, '-', 40-namelen, namelen);
76053
76054 - snprintf(ip, sizeof(ip), "[<%p>]",
76055 + snprintf(ip, sizeof(ip), "[<%pK>]",
76056 (void *)class->contending_point[i]);
76057 seq_printf(m, "%40s %14lu %29s %pS\n",
76058 name, stats->contending_point[i],
76059 diff --git a/kernel/module.c b/kernel/module.c
76060 index 0925c9a..6b044ac 100644
76061 --- a/kernel/module.c
76062 +++ b/kernel/module.c
76063 @@ -61,6 +61,7 @@
76064 #include <linux/pfn.h>
76065 #include <linux/bsearch.h>
76066 #include <linux/fips.h>
76067 +#include <linux/grsecurity.h>
76068 #include <uapi/linux/module.h>
76069 #include "module-internal.h"
76070
76071 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
76072
76073 /* Bounds of module allocation, for speeding __module_address.
76074 * Protected by module_mutex. */
76075 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
76076 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
76077 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
76078
76079 int register_module_notifier(struct notifier_block * nb)
76080 {
76081 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76082 return true;
76083
76084 list_for_each_entry_rcu(mod, &modules, list) {
76085 - struct symsearch arr[] = {
76086 + struct symsearch modarr[] = {
76087 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
76088 NOT_GPL_ONLY, false },
76089 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
76090 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76091 if (mod->state == MODULE_STATE_UNFORMED)
76092 continue;
76093
76094 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
76095 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
76096 return true;
76097 }
76098 return false;
76099 @@ -485,7 +487,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
76100 static int percpu_modalloc(struct module *mod,
76101 unsigned long size, unsigned long align)
76102 {
76103 - if (align > PAGE_SIZE) {
76104 + if (align-1 >= PAGE_SIZE) {
76105 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
76106 mod->name, align, PAGE_SIZE);
76107 align = PAGE_SIZE;
76108 @@ -1089,7 +1091,7 @@ struct module_attribute module_uevent =
76109 static ssize_t show_coresize(struct module_attribute *mattr,
76110 struct module_kobject *mk, char *buffer)
76111 {
76112 - return sprintf(buffer, "%u\n", mk->mod->core_size);
76113 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
76114 }
76115
76116 static struct module_attribute modinfo_coresize =
76117 @@ -1098,7 +1100,7 @@ static struct module_attribute modinfo_coresize =
76118 static ssize_t show_initsize(struct module_attribute *mattr,
76119 struct module_kobject *mk, char *buffer)
76120 {
76121 - return sprintf(buffer, "%u\n", mk->mod->init_size);
76122 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
76123 }
76124
76125 static struct module_attribute modinfo_initsize =
76126 @@ -1312,7 +1314,7 @@ resolve_symbol_wait(struct module *mod,
76127 */
76128 #ifdef CONFIG_SYSFS
76129
76130 -#ifdef CONFIG_KALLSYMS
76131 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
76132 static inline bool sect_empty(const Elf_Shdr *sect)
76133 {
76134 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
76135 @@ -1452,7 +1454,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
76136 {
76137 unsigned int notes, loaded, i;
76138 struct module_notes_attrs *notes_attrs;
76139 - struct bin_attribute *nattr;
76140 + bin_attribute_no_const *nattr;
76141
76142 /* failed to create section attributes, so can't create notes */
76143 if (!mod->sect_attrs)
76144 @@ -1564,7 +1566,7 @@ static void del_usage_links(struct module *mod)
76145 static int module_add_modinfo_attrs(struct module *mod)
76146 {
76147 struct module_attribute *attr;
76148 - struct module_attribute *temp_attr;
76149 + module_attribute_no_const *temp_attr;
76150 int error = 0;
76151 int i;
76152
76153 @@ -1778,21 +1780,21 @@ static void set_section_ro_nx(void *base,
76154
76155 static void unset_module_core_ro_nx(struct module *mod)
76156 {
76157 - set_page_attributes(mod->module_core + mod->core_text_size,
76158 - mod->module_core + mod->core_size,
76159 + set_page_attributes(mod->module_core_rw,
76160 + mod->module_core_rw + mod->core_size_rw,
76161 set_memory_x);
76162 - set_page_attributes(mod->module_core,
76163 - mod->module_core + mod->core_ro_size,
76164 + set_page_attributes(mod->module_core_rx,
76165 + mod->module_core_rx + mod->core_size_rx,
76166 set_memory_rw);
76167 }
76168
76169 static void unset_module_init_ro_nx(struct module *mod)
76170 {
76171 - set_page_attributes(mod->module_init + mod->init_text_size,
76172 - mod->module_init + mod->init_size,
76173 + set_page_attributes(mod->module_init_rw,
76174 + mod->module_init_rw + mod->init_size_rw,
76175 set_memory_x);
76176 - set_page_attributes(mod->module_init,
76177 - mod->module_init + mod->init_ro_size,
76178 + set_page_attributes(mod->module_init_rx,
76179 + mod->module_init_rx + mod->init_size_rx,
76180 set_memory_rw);
76181 }
76182
76183 @@ -1805,14 +1807,14 @@ void set_all_modules_text_rw(void)
76184 list_for_each_entry_rcu(mod, &modules, list) {
76185 if (mod->state == MODULE_STATE_UNFORMED)
76186 continue;
76187 - if ((mod->module_core) && (mod->core_text_size)) {
76188 - set_page_attributes(mod->module_core,
76189 - mod->module_core + mod->core_text_size,
76190 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76191 + set_page_attributes(mod->module_core_rx,
76192 + mod->module_core_rx + mod->core_size_rx,
76193 set_memory_rw);
76194 }
76195 - if ((mod->module_init) && (mod->init_text_size)) {
76196 - set_page_attributes(mod->module_init,
76197 - mod->module_init + mod->init_text_size,
76198 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76199 + set_page_attributes(mod->module_init_rx,
76200 + mod->module_init_rx + mod->init_size_rx,
76201 set_memory_rw);
76202 }
76203 }
76204 @@ -1828,14 +1830,14 @@ void set_all_modules_text_ro(void)
76205 list_for_each_entry_rcu(mod, &modules, list) {
76206 if (mod->state == MODULE_STATE_UNFORMED)
76207 continue;
76208 - if ((mod->module_core) && (mod->core_text_size)) {
76209 - set_page_attributes(mod->module_core,
76210 - mod->module_core + mod->core_text_size,
76211 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76212 + set_page_attributes(mod->module_core_rx,
76213 + mod->module_core_rx + mod->core_size_rx,
76214 set_memory_ro);
76215 }
76216 - if ((mod->module_init) && (mod->init_text_size)) {
76217 - set_page_attributes(mod->module_init,
76218 - mod->module_init + mod->init_text_size,
76219 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76220 + set_page_attributes(mod->module_init_rx,
76221 + mod->module_init_rx + mod->init_size_rx,
76222 set_memory_ro);
76223 }
76224 }
76225 @@ -1881,16 +1883,19 @@ static void free_module(struct module *mod)
76226
76227 /* This may be NULL, but that's OK */
76228 unset_module_init_ro_nx(mod);
76229 - module_free(mod, mod->module_init);
76230 + module_free(mod, mod->module_init_rw);
76231 + module_free_exec(mod, mod->module_init_rx);
76232 kfree(mod->args);
76233 percpu_modfree(mod);
76234
76235 /* Free lock-classes: */
76236 - lockdep_free_key_range(mod->module_core, mod->core_size);
76237 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
76238 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
76239
76240 /* Finally, free the core (containing the module structure) */
76241 unset_module_core_ro_nx(mod);
76242 - module_free(mod, mod->module_core);
76243 + module_free_exec(mod, mod->module_core_rx);
76244 + module_free(mod, mod->module_core_rw);
76245
76246 #ifdef CONFIG_MPU
76247 update_protections(current->mm);
76248 @@ -1960,9 +1965,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76249 int ret = 0;
76250 const struct kernel_symbol *ksym;
76251
76252 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76253 + int is_fs_load = 0;
76254 + int register_filesystem_found = 0;
76255 + char *p;
76256 +
76257 + p = strstr(mod->args, "grsec_modharden_fs");
76258 + if (p) {
76259 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
76260 + /* copy \0 as well */
76261 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
76262 + is_fs_load = 1;
76263 + }
76264 +#endif
76265 +
76266 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
76267 const char *name = info->strtab + sym[i].st_name;
76268
76269 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76270 + /* it's a real shame this will never get ripped and copied
76271 + upstream! ;(
76272 + */
76273 + if (is_fs_load && !strcmp(name, "register_filesystem"))
76274 + register_filesystem_found = 1;
76275 +#endif
76276 +
76277 switch (sym[i].st_shndx) {
76278 case SHN_COMMON:
76279 /* We compiled with -fno-common. These are not
76280 @@ -1983,7 +2010,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76281 ksym = resolve_symbol_wait(mod, info, name);
76282 /* Ok if resolved. */
76283 if (ksym && !IS_ERR(ksym)) {
76284 + pax_open_kernel();
76285 sym[i].st_value = ksym->value;
76286 + pax_close_kernel();
76287 break;
76288 }
76289
76290 @@ -2002,11 +2031,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76291 secbase = (unsigned long)mod_percpu(mod);
76292 else
76293 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
76294 + pax_open_kernel();
76295 sym[i].st_value += secbase;
76296 + pax_close_kernel();
76297 break;
76298 }
76299 }
76300
76301 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76302 + if (is_fs_load && !register_filesystem_found) {
76303 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
76304 + ret = -EPERM;
76305 + }
76306 +#endif
76307 +
76308 return ret;
76309 }
76310
76311 @@ -2090,22 +2128,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
76312 || s->sh_entsize != ~0UL
76313 || strstarts(sname, ".init"))
76314 continue;
76315 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
76316 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76317 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
76318 + else
76319 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
76320 pr_debug("\t%s\n", sname);
76321 }
76322 - switch (m) {
76323 - case 0: /* executable */
76324 - mod->core_size = debug_align(mod->core_size);
76325 - mod->core_text_size = mod->core_size;
76326 - break;
76327 - case 1: /* RO: text and ro-data */
76328 - mod->core_size = debug_align(mod->core_size);
76329 - mod->core_ro_size = mod->core_size;
76330 - break;
76331 - case 3: /* whole core */
76332 - mod->core_size = debug_align(mod->core_size);
76333 - break;
76334 - }
76335 }
76336
76337 pr_debug("Init section allocation order:\n");
76338 @@ -2119,23 +2147,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
76339 || s->sh_entsize != ~0UL
76340 || !strstarts(sname, ".init"))
76341 continue;
76342 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
76343 - | INIT_OFFSET_MASK);
76344 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76345 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
76346 + else
76347 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
76348 + s->sh_entsize |= INIT_OFFSET_MASK;
76349 pr_debug("\t%s\n", sname);
76350 }
76351 - switch (m) {
76352 - case 0: /* executable */
76353 - mod->init_size = debug_align(mod->init_size);
76354 - mod->init_text_size = mod->init_size;
76355 - break;
76356 - case 1: /* RO: text and ro-data */
76357 - mod->init_size = debug_align(mod->init_size);
76358 - mod->init_ro_size = mod->init_size;
76359 - break;
76360 - case 3: /* whole init */
76361 - mod->init_size = debug_align(mod->init_size);
76362 - break;
76363 - }
76364 }
76365 }
76366
76367 @@ -2308,7 +2326,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76368
76369 /* Put symbol section at end of init part of module. */
76370 symsect->sh_flags |= SHF_ALLOC;
76371 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
76372 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
76373 info->index.sym) | INIT_OFFSET_MASK;
76374 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
76375
76376 @@ -2325,13 +2343,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76377 }
76378
76379 /* Append room for core symbols at end of core part. */
76380 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
76381 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
76382 - mod->core_size += strtab_size;
76383 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
76384 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
76385 + mod->core_size_rx += strtab_size;
76386
76387 /* Put string table section at end of init part of module. */
76388 strsect->sh_flags |= SHF_ALLOC;
76389 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
76390 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
76391 info->index.str) | INIT_OFFSET_MASK;
76392 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
76393 }
76394 @@ -2349,12 +2367,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76395 /* Make sure we get permanent strtab: don't use info->strtab. */
76396 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
76397
76398 + pax_open_kernel();
76399 +
76400 /* Set types up while we still have access to sections. */
76401 for (i = 0; i < mod->num_symtab; i++)
76402 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
76403
76404 - mod->core_symtab = dst = mod->module_core + info->symoffs;
76405 - mod->core_strtab = s = mod->module_core + info->stroffs;
76406 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
76407 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
76408 src = mod->symtab;
76409 for (ndst = i = 0; i < mod->num_symtab; i++) {
76410 if (i == 0 ||
76411 @@ -2366,6 +2386,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76412 }
76413 }
76414 mod->core_num_syms = ndst;
76415 +
76416 + pax_close_kernel();
76417 }
76418 #else
76419 static inline void layout_symtab(struct module *mod, struct load_info *info)
76420 @@ -2399,17 +2421,33 @@ void * __weak module_alloc(unsigned long size)
76421 return vmalloc_exec(size);
76422 }
76423
76424 -static void *module_alloc_update_bounds(unsigned long size)
76425 +static void *module_alloc_update_bounds_rw(unsigned long size)
76426 {
76427 void *ret = module_alloc(size);
76428
76429 if (ret) {
76430 mutex_lock(&module_mutex);
76431 /* Update module bounds. */
76432 - if ((unsigned long)ret < module_addr_min)
76433 - module_addr_min = (unsigned long)ret;
76434 - if ((unsigned long)ret + size > module_addr_max)
76435 - module_addr_max = (unsigned long)ret + size;
76436 + if ((unsigned long)ret < module_addr_min_rw)
76437 + module_addr_min_rw = (unsigned long)ret;
76438 + if ((unsigned long)ret + size > module_addr_max_rw)
76439 + module_addr_max_rw = (unsigned long)ret + size;
76440 + mutex_unlock(&module_mutex);
76441 + }
76442 + return ret;
76443 +}
76444 +
76445 +static void *module_alloc_update_bounds_rx(unsigned long size)
76446 +{
76447 + void *ret = module_alloc_exec(size);
76448 +
76449 + if (ret) {
76450 + mutex_lock(&module_mutex);
76451 + /* Update module bounds. */
76452 + if ((unsigned long)ret < module_addr_min_rx)
76453 + module_addr_min_rx = (unsigned long)ret;
76454 + if ((unsigned long)ret + size > module_addr_max_rx)
76455 + module_addr_max_rx = (unsigned long)ret + size;
76456 mutex_unlock(&module_mutex);
76457 }
76458 return ret;
76459 @@ -2685,8 +2723,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
76460 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76461 {
76462 const char *modmagic = get_modinfo(info, "vermagic");
76463 + const char *license = get_modinfo(info, "license");
76464 int err;
76465
76466 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
76467 + if (!license || !license_is_gpl_compatible(license))
76468 + return -ENOEXEC;
76469 +#endif
76470 +
76471 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
76472 modmagic = NULL;
76473
76474 @@ -2712,7 +2756,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76475 }
76476
76477 /* Set up license info based on the info section */
76478 - set_license(mod, get_modinfo(info, "license"));
76479 + set_license(mod, license);
76480
76481 return 0;
76482 }
76483 @@ -2806,7 +2850,7 @@ static int move_module(struct module *mod, struct load_info *info)
76484 void *ptr;
76485
76486 /* Do the allocs. */
76487 - ptr = module_alloc_update_bounds(mod->core_size);
76488 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
76489 /*
76490 * The pointer to this block is stored in the module structure
76491 * which is inside the block. Just mark it as not being a
76492 @@ -2816,11 +2860,11 @@ static int move_module(struct module *mod, struct load_info *info)
76493 if (!ptr)
76494 return -ENOMEM;
76495
76496 - memset(ptr, 0, mod->core_size);
76497 - mod->module_core = ptr;
76498 + memset(ptr, 0, mod->core_size_rw);
76499 + mod->module_core_rw = ptr;
76500
76501 - if (mod->init_size) {
76502 - ptr = module_alloc_update_bounds(mod->init_size);
76503 + if (mod->init_size_rw) {
76504 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
76505 /*
76506 * The pointer to this block is stored in the module structure
76507 * which is inside the block. This block doesn't need to be
76508 @@ -2829,13 +2873,45 @@ static int move_module(struct module *mod, struct load_info *info)
76509 */
76510 kmemleak_ignore(ptr);
76511 if (!ptr) {
76512 - module_free(mod, mod->module_core);
76513 + module_free(mod, mod->module_core_rw);
76514 return -ENOMEM;
76515 }
76516 - memset(ptr, 0, mod->init_size);
76517 - mod->module_init = ptr;
76518 + memset(ptr, 0, mod->init_size_rw);
76519 + mod->module_init_rw = ptr;
76520 } else
76521 - mod->module_init = NULL;
76522 + mod->module_init_rw = NULL;
76523 +
76524 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
76525 + kmemleak_not_leak(ptr);
76526 + if (!ptr) {
76527 + if (mod->module_init_rw)
76528 + module_free(mod, mod->module_init_rw);
76529 + module_free(mod, mod->module_core_rw);
76530 + return -ENOMEM;
76531 + }
76532 +
76533 + pax_open_kernel();
76534 + memset(ptr, 0, mod->core_size_rx);
76535 + pax_close_kernel();
76536 + mod->module_core_rx = ptr;
76537 +
76538 + if (mod->init_size_rx) {
76539 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
76540 + kmemleak_ignore(ptr);
76541 + if (!ptr && mod->init_size_rx) {
76542 + module_free_exec(mod, mod->module_core_rx);
76543 + if (mod->module_init_rw)
76544 + module_free(mod, mod->module_init_rw);
76545 + module_free(mod, mod->module_core_rw);
76546 + return -ENOMEM;
76547 + }
76548 +
76549 + pax_open_kernel();
76550 + memset(ptr, 0, mod->init_size_rx);
76551 + pax_close_kernel();
76552 + mod->module_init_rx = ptr;
76553 + } else
76554 + mod->module_init_rx = NULL;
76555
76556 /* Transfer each section which specifies SHF_ALLOC */
76557 pr_debug("final section addresses:\n");
76558 @@ -2846,16 +2922,45 @@ static int move_module(struct module *mod, struct load_info *info)
76559 if (!(shdr->sh_flags & SHF_ALLOC))
76560 continue;
76561
76562 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
76563 - dest = mod->module_init
76564 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76565 - else
76566 - dest = mod->module_core + shdr->sh_entsize;
76567 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
76568 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76569 + dest = mod->module_init_rw
76570 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76571 + else
76572 + dest = mod->module_init_rx
76573 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76574 + } else {
76575 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76576 + dest = mod->module_core_rw + shdr->sh_entsize;
76577 + else
76578 + dest = mod->module_core_rx + shdr->sh_entsize;
76579 + }
76580 +
76581 + if (shdr->sh_type != SHT_NOBITS) {
76582 +
76583 +#ifdef CONFIG_PAX_KERNEXEC
76584 +#ifdef CONFIG_X86_64
76585 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
76586 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
76587 +#endif
76588 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
76589 + pax_open_kernel();
76590 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76591 + pax_close_kernel();
76592 + } else
76593 +#endif
76594
76595 - if (shdr->sh_type != SHT_NOBITS)
76596 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76597 + }
76598 /* Update sh_addr to point to copy in image. */
76599 - shdr->sh_addr = (unsigned long)dest;
76600 +
76601 +#ifdef CONFIG_PAX_KERNEXEC
76602 + if (shdr->sh_flags & SHF_EXECINSTR)
76603 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
76604 + else
76605 +#endif
76606 +
76607 + shdr->sh_addr = (unsigned long)dest;
76608 pr_debug("\t0x%lx %s\n",
76609 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
76610 }
76611 @@ -2912,12 +3017,12 @@ static void flush_module_icache(const struct module *mod)
76612 * Do it before processing of module parameters, so the module
76613 * can provide parameter accessor functions of its own.
76614 */
76615 - if (mod->module_init)
76616 - flush_icache_range((unsigned long)mod->module_init,
76617 - (unsigned long)mod->module_init
76618 - + mod->init_size);
76619 - flush_icache_range((unsigned long)mod->module_core,
76620 - (unsigned long)mod->module_core + mod->core_size);
76621 + if (mod->module_init_rx)
76622 + flush_icache_range((unsigned long)mod->module_init_rx,
76623 + (unsigned long)mod->module_init_rx
76624 + + mod->init_size_rx);
76625 + flush_icache_range((unsigned long)mod->module_core_rx,
76626 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
76627
76628 set_fs(old_fs);
76629 }
76630 @@ -2987,8 +3092,10 @@ out:
76631 static void module_deallocate(struct module *mod, struct load_info *info)
76632 {
76633 percpu_modfree(mod);
76634 - module_free(mod, mod->module_init);
76635 - module_free(mod, mod->module_core);
76636 + module_free_exec(mod, mod->module_init_rx);
76637 + module_free_exec(mod, mod->module_core_rx);
76638 + module_free(mod, mod->module_init_rw);
76639 + module_free(mod, mod->module_core_rw);
76640 }
76641
76642 int __weak module_finalize(const Elf_Ehdr *hdr,
76643 @@ -3001,7 +3108,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
76644 static int post_relocation(struct module *mod, const struct load_info *info)
76645 {
76646 /* Sort exception table now relocations are done. */
76647 + pax_open_kernel();
76648 sort_extable(mod->extable, mod->extable + mod->num_exentries);
76649 + pax_close_kernel();
76650
76651 /* Copy relocated percpu area over. */
76652 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
76653 @@ -3055,16 +3164,16 @@ static int do_init_module(struct module *mod)
76654 MODULE_STATE_COMING, mod);
76655
76656 /* Set RO and NX regions for core */
76657 - set_section_ro_nx(mod->module_core,
76658 - mod->core_text_size,
76659 - mod->core_ro_size,
76660 - mod->core_size);
76661 + set_section_ro_nx(mod->module_core_rx,
76662 + mod->core_size_rx,
76663 + mod->core_size_rx,
76664 + mod->core_size_rx);
76665
76666 /* Set RO and NX regions for init */
76667 - set_section_ro_nx(mod->module_init,
76668 - mod->init_text_size,
76669 - mod->init_ro_size,
76670 - mod->init_size);
76671 + set_section_ro_nx(mod->module_init_rx,
76672 + mod->init_size_rx,
76673 + mod->init_size_rx,
76674 + mod->init_size_rx);
76675
76676 do_mod_ctors(mod);
76677 /* Start the module */
76678 @@ -3126,11 +3235,12 @@ static int do_init_module(struct module *mod)
76679 mod->strtab = mod->core_strtab;
76680 #endif
76681 unset_module_init_ro_nx(mod);
76682 - module_free(mod, mod->module_init);
76683 - mod->module_init = NULL;
76684 - mod->init_size = 0;
76685 - mod->init_ro_size = 0;
76686 - mod->init_text_size = 0;
76687 + module_free(mod, mod->module_init_rw);
76688 + module_free_exec(mod, mod->module_init_rx);
76689 + mod->module_init_rw = NULL;
76690 + mod->module_init_rx = NULL;
76691 + mod->init_size_rw = 0;
76692 + mod->init_size_rx = 0;
76693 mutex_unlock(&module_mutex);
76694 wake_up_all(&module_wq);
76695
76696 @@ -3257,9 +3367,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
76697 if (err)
76698 goto free_unload;
76699
76700 + /* Now copy in args */
76701 + mod->args = strndup_user(uargs, ~0UL >> 1);
76702 + if (IS_ERR(mod->args)) {
76703 + err = PTR_ERR(mod->args);
76704 + goto free_unload;
76705 + }
76706 +
76707 /* Set up MODINFO_ATTR fields */
76708 setup_modinfo(mod, info);
76709
76710 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76711 + {
76712 + char *p, *p2;
76713 +
76714 + if (strstr(mod->args, "grsec_modharden_netdev")) {
76715 + 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);
76716 + err = -EPERM;
76717 + goto free_modinfo;
76718 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
76719 + p += sizeof("grsec_modharden_normal") - 1;
76720 + p2 = strstr(p, "_");
76721 + if (p2) {
76722 + *p2 = '\0';
76723 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
76724 + *p2 = '_';
76725 + }
76726 + err = -EPERM;
76727 + goto free_modinfo;
76728 + }
76729 + }
76730 +#endif
76731 +
76732 /* Fix up syms, so that st_value is a pointer to location. */
76733 err = simplify_symbols(mod, info);
76734 if (err < 0)
76735 @@ -3275,13 +3414,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
76736
76737 flush_module_icache(mod);
76738
76739 - /* Now copy in args */
76740 - mod->args = strndup_user(uargs, ~0UL >> 1);
76741 - if (IS_ERR(mod->args)) {
76742 - err = PTR_ERR(mod->args);
76743 - goto free_arch_cleanup;
76744 - }
76745 -
76746 dynamic_debug_setup(info->debug, info->num_debug);
76747
76748 /* Finally it's fully formed, ready to start executing. */
76749 @@ -3316,11 +3448,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
76750 ddebug_cleanup:
76751 dynamic_debug_remove(info->debug);
76752 synchronize_sched();
76753 - kfree(mod->args);
76754 - free_arch_cleanup:
76755 module_arch_cleanup(mod);
76756 free_modinfo:
76757 free_modinfo(mod);
76758 + kfree(mod->args);
76759 free_unload:
76760 module_unload_free(mod);
76761 unlink_mod:
76762 @@ -3403,10 +3534,16 @@ static const char *get_ksymbol(struct module *mod,
76763 unsigned long nextval;
76764
76765 /* At worse, next value is at end of module */
76766 - if (within_module_init(addr, mod))
76767 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
76768 + if (within_module_init_rx(addr, mod))
76769 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
76770 + else if (within_module_init_rw(addr, mod))
76771 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
76772 + else if (within_module_core_rx(addr, mod))
76773 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
76774 + else if (within_module_core_rw(addr, mod))
76775 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
76776 else
76777 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
76778 + return NULL;
76779
76780 /* Scan for closest preceding symbol, and next symbol. (ELF
76781 starts real symbols at 1). */
76782 @@ -3659,7 +3796,7 @@ static int m_show(struct seq_file *m, void *p)
76783 return 0;
76784
76785 seq_printf(m, "%s %u",
76786 - mod->name, mod->init_size + mod->core_size);
76787 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
76788 print_unload_info(m, mod);
76789
76790 /* Informative for users. */
76791 @@ -3668,7 +3805,7 @@ static int m_show(struct seq_file *m, void *p)
76792 mod->state == MODULE_STATE_COMING ? "Loading":
76793 "Live");
76794 /* Used by oprofile and other similar tools. */
76795 - seq_printf(m, " 0x%pK", mod->module_core);
76796 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
76797
76798 /* Taints info */
76799 if (mod->taints)
76800 @@ -3704,7 +3841,17 @@ static const struct file_operations proc_modules_operations = {
76801
76802 static int __init proc_modules_init(void)
76803 {
76804 +#ifndef CONFIG_GRKERNSEC_HIDESYM
76805 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76806 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76807 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76808 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
76809 +#else
76810 proc_create("modules", 0, NULL, &proc_modules_operations);
76811 +#endif
76812 +#else
76813 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76814 +#endif
76815 return 0;
76816 }
76817 module_init(proc_modules_init);
76818 @@ -3765,14 +3912,14 @@ struct module *__module_address(unsigned long addr)
76819 {
76820 struct module *mod;
76821
76822 - if (addr < module_addr_min || addr > module_addr_max)
76823 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
76824 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
76825 return NULL;
76826
76827 list_for_each_entry_rcu(mod, &modules, list) {
76828 if (mod->state == MODULE_STATE_UNFORMED)
76829 continue;
76830 - if (within_module_core(addr, mod)
76831 - || within_module_init(addr, mod))
76832 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
76833 return mod;
76834 }
76835 return NULL;
76836 @@ -3807,11 +3954,20 @@ bool is_module_text_address(unsigned long addr)
76837 */
76838 struct module *__module_text_address(unsigned long addr)
76839 {
76840 - struct module *mod = __module_address(addr);
76841 + struct module *mod;
76842 +
76843 +#ifdef CONFIG_X86_32
76844 + addr = ktla_ktva(addr);
76845 +#endif
76846 +
76847 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
76848 + return NULL;
76849 +
76850 + mod = __module_address(addr);
76851 +
76852 if (mod) {
76853 /* Make sure it's within the text section. */
76854 - if (!within(addr, mod->module_init, mod->init_text_size)
76855 - && !within(addr, mod->module_core, mod->core_text_size))
76856 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
76857 mod = NULL;
76858 }
76859 return mod;
76860 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
76861 index 7e3443f..b2a1e6b 100644
76862 --- a/kernel/mutex-debug.c
76863 +++ b/kernel/mutex-debug.c
76864 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
76865 }
76866
76867 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76868 - struct thread_info *ti)
76869 + struct task_struct *task)
76870 {
76871 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
76872
76873 /* Mark the current thread as blocked on the lock: */
76874 - ti->task->blocked_on = waiter;
76875 + task->blocked_on = waiter;
76876 }
76877
76878 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76879 - struct thread_info *ti)
76880 + struct task_struct *task)
76881 {
76882 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
76883 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
76884 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
76885 - ti->task->blocked_on = NULL;
76886 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
76887 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
76888 + task->blocked_on = NULL;
76889
76890 list_del_init(&waiter->list);
76891 waiter->task = NULL;
76892 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
76893 index 0799fd3..d06ae3b 100644
76894 --- a/kernel/mutex-debug.h
76895 +++ b/kernel/mutex-debug.h
76896 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
76897 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
76898 extern void debug_mutex_add_waiter(struct mutex *lock,
76899 struct mutex_waiter *waiter,
76900 - struct thread_info *ti);
76901 + struct task_struct *task);
76902 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76903 - struct thread_info *ti);
76904 + struct task_struct *task);
76905 extern void debug_mutex_unlock(struct mutex *lock);
76906 extern void debug_mutex_init(struct mutex *lock, const char *name,
76907 struct lock_class_key *key);
76908 diff --git a/kernel/mutex.c b/kernel/mutex.c
76909 index 52f2301..73f7528 100644
76910 --- a/kernel/mutex.c
76911 +++ b/kernel/mutex.c
76912 @@ -199,7 +199,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76913 spin_lock_mutex(&lock->wait_lock, flags);
76914
76915 debug_mutex_lock_common(lock, &waiter);
76916 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
76917 + debug_mutex_add_waiter(lock, &waiter, task);
76918
76919 /* add waiting tasks to the end of the waitqueue (FIFO): */
76920 list_add_tail(&waiter.list, &lock->wait_list);
76921 @@ -228,8 +228,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76922 * TASK_UNINTERRUPTIBLE case.)
76923 */
76924 if (unlikely(signal_pending_state(state, task))) {
76925 - mutex_remove_waiter(lock, &waiter,
76926 - task_thread_info(task));
76927 + mutex_remove_waiter(lock, &waiter, task);
76928 mutex_release(&lock->dep_map, 1, ip);
76929 spin_unlock_mutex(&lock->wait_lock, flags);
76930
76931 @@ -248,7 +247,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76932 done:
76933 lock_acquired(&lock->dep_map, ip);
76934 /* got the lock - rejoice! */
76935 - mutex_remove_waiter(lock, &waiter, current_thread_info());
76936 + mutex_remove_waiter(lock, &waiter, task);
76937 mutex_set_owner(lock);
76938
76939 /* set it to 0 if there are no waiters left: */
76940 diff --git a/kernel/notifier.c b/kernel/notifier.c
76941 index 2d5cc4c..d9ea600 100644
76942 --- a/kernel/notifier.c
76943 +++ b/kernel/notifier.c
76944 @@ -5,6 +5,7 @@
76945 #include <linux/rcupdate.h>
76946 #include <linux/vmalloc.h>
76947 #include <linux/reboot.h>
76948 +#include <linux/mm.h>
76949
76950 /*
76951 * Notifier list for kernel code which wants to be called
76952 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
76953 while ((*nl) != NULL) {
76954 if (n->priority > (*nl)->priority)
76955 break;
76956 - nl = &((*nl)->next);
76957 + nl = (struct notifier_block **)&((*nl)->next);
76958 }
76959 - n->next = *nl;
76960 + pax_open_kernel();
76961 + *(const void **)&n->next = *nl;
76962 rcu_assign_pointer(*nl, n);
76963 + pax_close_kernel();
76964 return 0;
76965 }
76966
76967 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
76968 return 0;
76969 if (n->priority > (*nl)->priority)
76970 break;
76971 - nl = &((*nl)->next);
76972 + nl = (struct notifier_block **)&((*nl)->next);
76973 }
76974 - n->next = *nl;
76975 + pax_open_kernel();
76976 + *(const void **)&n->next = *nl;
76977 rcu_assign_pointer(*nl, n);
76978 + pax_close_kernel();
76979 return 0;
76980 }
76981
76982 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
76983 {
76984 while ((*nl) != NULL) {
76985 if ((*nl) == n) {
76986 + pax_open_kernel();
76987 rcu_assign_pointer(*nl, n->next);
76988 + pax_close_kernel();
76989 return 0;
76990 }
76991 - nl = &((*nl)->next);
76992 + nl = (struct notifier_block **)&((*nl)->next);
76993 }
76994 return -ENOENT;
76995 }
76996 diff --git a/kernel/panic.c b/kernel/panic.c
76997 index 7c57cc9..28f1b3f 100644
76998 --- a/kernel/panic.c
76999 +++ b/kernel/panic.c
77000 @@ -403,7 +403,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
77001 const char *board;
77002
77003 printk(KERN_WARNING "------------[ cut here ]------------\n");
77004 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
77005 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
77006 board = dmi_get_system_info(DMI_PRODUCT_NAME);
77007 if (board)
77008 printk(KERN_WARNING "Hardware name: %s\n", board);
77009 @@ -459,7 +459,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
77010 */
77011 void __stack_chk_fail(void)
77012 {
77013 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
77014 + dump_stack();
77015 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
77016 __builtin_return_address(0));
77017 }
77018 EXPORT_SYMBOL(__stack_chk_fail);
77019 diff --git a/kernel/pid.c b/kernel/pid.c
77020 index 047dc62..418d74b 100644
77021 --- a/kernel/pid.c
77022 +++ b/kernel/pid.c
77023 @@ -33,6 +33,7 @@
77024 #include <linux/rculist.h>
77025 #include <linux/bootmem.h>
77026 #include <linux/hash.h>
77027 +#include <linux/security.h>
77028 #include <linux/pid_namespace.h>
77029 #include <linux/init_task.h>
77030 #include <linux/syscalls.h>
77031 @@ -46,7 +47,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
77032
77033 int pid_max = PID_MAX_DEFAULT;
77034
77035 -#define RESERVED_PIDS 300
77036 +#define RESERVED_PIDS 500
77037
77038 int pid_max_min = RESERVED_PIDS + 1;
77039 int pid_max_max = PID_MAX_LIMIT;
77040 @@ -440,10 +441,18 @@ EXPORT_SYMBOL(pid_task);
77041 */
77042 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
77043 {
77044 + struct task_struct *task;
77045 +
77046 rcu_lockdep_assert(rcu_read_lock_held(),
77047 "find_task_by_pid_ns() needs rcu_read_lock()"
77048 " protection");
77049 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77050 +
77051 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77052 +
77053 + if (gr_pid_is_chrooted(task))
77054 + return NULL;
77055 +
77056 + return task;
77057 }
77058
77059 struct task_struct *find_task_by_vpid(pid_t vnr)
77060 @@ -451,6 +460,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
77061 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
77062 }
77063
77064 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
77065 +{
77066 + rcu_lockdep_assert(rcu_read_lock_held(),
77067 + "find_task_by_pid_ns() needs rcu_read_lock()"
77068 + " protection");
77069 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
77070 +}
77071 +
77072 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
77073 {
77074 struct pid *pid;
77075 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
77076 index bea15bd..789f3d0 100644
77077 --- a/kernel/pid_namespace.c
77078 +++ b/kernel/pid_namespace.c
77079 @@ -249,7 +249,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
77080 void __user *buffer, size_t *lenp, loff_t *ppos)
77081 {
77082 struct pid_namespace *pid_ns = task_active_pid_ns(current);
77083 - struct ctl_table tmp = *table;
77084 + ctl_table_no_const tmp = *table;
77085
77086 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
77087 return -EPERM;
77088 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
77089 index 8fd709c..542bf4b 100644
77090 --- a/kernel/posix-cpu-timers.c
77091 +++ b/kernel/posix-cpu-timers.c
77092 @@ -1592,14 +1592,14 @@ struct k_clock clock_posix_cpu = {
77093
77094 static __init int init_posix_cpu_timers(void)
77095 {
77096 - struct k_clock process = {
77097 + static struct k_clock process = {
77098 .clock_getres = process_cpu_clock_getres,
77099 .clock_get = process_cpu_clock_get,
77100 .timer_create = process_cpu_timer_create,
77101 .nsleep = process_cpu_nsleep,
77102 .nsleep_restart = process_cpu_nsleep_restart,
77103 };
77104 - struct k_clock thread = {
77105 + static struct k_clock thread = {
77106 .clock_getres = thread_cpu_clock_getres,
77107 .clock_get = thread_cpu_clock_get,
77108 .timer_create = thread_cpu_timer_create,
77109 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
77110 index 6edbb2c..334f085 100644
77111 --- a/kernel/posix-timers.c
77112 +++ b/kernel/posix-timers.c
77113 @@ -43,6 +43,7 @@
77114 #include <linux/idr.h>
77115 #include <linux/posix-clock.h>
77116 #include <linux/posix-timers.h>
77117 +#include <linux/grsecurity.h>
77118 #include <linux/syscalls.h>
77119 #include <linux/wait.h>
77120 #include <linux/workqueue.h>
77121 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
77122 * which we beg off on and pass to do_sys_settimeofday().
77123 */
77124
77125 -static struct k_clock posix_clocks[MAX_CLOCKS];
77126 +static struct k_clock *posix_clocks[MAX_CLOCKS];
77127
77128 /*
77129 * These ones are defined below.
77130 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
77131 */
77132 static __init int init_posix_timers(void)
77133 {
77134 - struct k_clock clock_realtime = {
77135 + static struct k_clock clock_realtime = {
77136 .clock_getres = hrtimer_get_res,
77137 .clock_get = posix_clock_realtime_get,
77138 .clock_set = posix_clock_realtime_set,
77139 @@ -239,7 +240,7 @@ static __init int init_posix_timers(void)
77140 .timer_get = common_timer_get,
77141 .timer_del = common_timer_del,
77142 };
77143 - struct k_clock clock_monotonic = {
77144 + static struct k_clock clock_monotonic = {
77145 .clock_getres = hrtimer_get_res,
77146 .clock_get = posix_ktime_get_ts,
77147 .nsleep = common_nsleep,
77148 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
77149 .timer_get = common_timer_get,
77150 .timer_del = common_timer_del,
77151 };
77152 - struct k_clock clock_monotonic_raw = {
77153 + static struct k_clock clock_monotonic_raw = {
77154 .clock_getres = hrtimer_get_res,
77155 .clock_get = posix_get_monotonic_raw,
77156 };
77157 - struct k_clock clock_realtime_coarse = {
77158 + static struct k_clock clock_realtime_coarse = {
77159 .clock_getres = posix_get_coarse_res,
77160 .clock_get = posix_get_realtime_coarse,
77161 };
77162 - struct k_clock clock_monotonic_coarse = {
77163 + static struct k_clock clock_monotonic_coarse = {
77164 .clock_getres = posix_get_coarse_res,
77165 .clock_get = posix_get_monotonic_coarse,
77166 };
77167 - struct k_clock clock_boottime = {
77168 + static struct k_clock clock_boottime = {
77169 .clock_getres = hrtimer_get_res,
77170 .clock_get = posix_get_boottime,
77171 .nsleep = common_nsleep,
77172 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
77173 return;
77174 }
77175
77176 - posix_clocks[clock_id] = *new_clock;
77177 + posix_clocks[clock_id] = new_clock;
77178 }
77179 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
77180
77181 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
77182 return (id & CLOCKFD_MASK) == CLOCKFD ?
77183 &clock_posix_dynamic : &clock_posix_cpu;
77184
77185 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
77186 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
77187 return NULL;
77188 - return &posix_clocks[id];
77189 + return posix_clocks[id];
77190 }
77191
77192 static int common_timer_create(struct k_itimer *new_timer)
77193 @@ -964,6 +965,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
77194 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
77195 return -EFAULT;
77196
77197 + /* only the CLOCK_REALTIME clock can be set, all other clocks
77198 + have their clock_set fptr set to a nosettime dummy function
77199 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
77200 + call common_clock_set, which calls do_sys_settimeofday, which
77201 + we hook
77202 + */
77203 +
77204 return kc->clock_set(which_clock, &new_tp);
77205 }
77206
77207 diff --git a/kernel/power/process.c b/kernel/power/process.c
77208 index 98088e0..aaf95c0 100644
77209 --- a/kernel/power/process.c
77210 +++ b/kernel/power/process.c
77211 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
77212 u64 elapsed_csecs64;
77213 unsigned int elapsed_csecs;
77214 bool wakeup = false;
77215 + bool timedout = false;
77216
77217 do_gettimeofday(&start);
77218
77219 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
77220
77221 while (true) {
77222 todo = 0;
77223 + if (time_after(jiffies, end_time))
77224 + timedout = true;
77225 read_lock(&tasklist_lock);
77226 do_each_thread(g, p) {
77227 if (p == current || !freeze_task(p))
77228 continue;
77229
77230 - if (!freezer_should_skip(p))
77231 + if (!freezer_should_skip(p)) {
77232 todo++;
77233 + if (timedout) {
77234 + printk(KERN_ERR "Task refusing to freeze:\n");
77235 + sched_show_task(p);
77236 + }
77237 + }
77238 } while_each_thread(g, p);
77239 read_unlock(&tasklist_lock);
77240
77241 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
77242 todo += wq_busy;
77243 }
77244
77245 - if (!todo || time_after(jiffies, end_time))
77246 + if (!todo || timedout)
77247 break;
77248
77249 if (pm_wakeup_pending()) {
77250 diff --git a/kernel/printk.c b/kernel/printk.c
77251 index abbdd9e..f294251 100644
77252 --- a/kernel/printk.c
77253 +++ b/kernel/printk.c
77254 @@ -615,11 +615,17 @@ static unsigned int devkmsg_poll(struct file *file, poll_table *wait)
77255 return ret;
77256 }
77257
77258 +static int check_syslog_permissions(int type, bool from_file);
77259 +
77260 static int devkmsg_open(struct inode *inode, struct file *file)
77261 {
77262 struct devkmsg_user *user;
77263 int err;
77264
77265 + err = check_syslog_permissions(SYSLOG_ACTION_OPEN, SYSLOG_FROM_FILE);
77266 + if (err)
77267 + return err;
77268 +
77269 /* write-only does not need any file context */
77270 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
77271 return 0;
77272 @@ -828,7 +834,7 @@ static int syslog_action_restricted(int type)
77273 if (dmesg_restrict)
77274 return 1;
77275 /* Unless restricted, we allow "read all" and "get buffer size" for everybody */
77276 - return type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
77277 + return type != SYSLOG_ACTION_OPEN && type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
77278 }
77279
77280 static int check_syslog_permissions(int type, bool from_file)
77281 @@ -840,6 +846,11 @@ static int check_syslog_permissions(int type, bool from_file)
77282 if (from_file && type != SYSLOG_ACTION_OPEN)
77283 return 0;
77284
77285 +#ifdef CONFIG_GRKERNSEC_DMESG
77286 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
77287 + return -EPERM;
77288 +#endif
77289 +
77290 if (syslog_action_restricted(type)) {
77291 if (capable(CAP_SYSLOG))
77292 return 0;
77293 diff --git a/kernel/profile.c b/kernel/profile.c
77294 index dc3384e..0de5b49 100644
77295 --- a/kernel/profile.c
77296 +++ b/kernel/profile.c
77297 @@ -37,7 +37,7 @@ struct profile_hit {
77298 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
77299 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
77300
77301 -static atomic_t *prof_buffer;
77302 +static atomic_unchecked_t *prof_buffer;
77303 static unsigned long prof_len, prof_shift;
77304
77305 int prof_on __read_mostly;
77306 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
77307 hits[i].pc = 0;
77308 continue;
77309 }
77310 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77311 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77312 hits[i].hits = hits[i].pc = 0;
77313 }
77314 }
77315 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77316 * Add the current hit(s) and flush the write-queue out
77317 * to the global buffer:
77318 */
77319 - atomic_add(nr_hits, &prof_buffer[pc]);
77320 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
77321 for (i = 0; i < NR_PROFILE_HIT; ++i) {
77322 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77323 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77324 hits[i].pc = hits[i].hits = 0;
77325 }
77326 out:
77327 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77328 {
77329 unsigned long pc;
77330 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
77331 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77332 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77333 }
77334 #endif /* !CONFIG_SMP */
77335
77336 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
77337 return -EFAULT;
77338 buf++; p++; count--; read++;
77339 }
77340 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
77341 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
77342 if (copy_to_user(buf, (void *)pnt, count))
77343 return -EFAULT;
77344 read += count;
77345 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
77346 }
77347 #endif
77348 profile_discard_flip_buffers();
77349 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
77350 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
77351 return count;
77352 }
77353
77354 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
77355 index acbd284..00bb0c9 100644
77356 --- a/kernel/ptrace.c
77357 +++ b/kernel/ptrace.c
77358 @@ -324,7 +324,7 @@ static int ptrace_attach(struct task_struct *task, long request,
77359 if (seize)
77360 flags |= PT_SEIZED;
77361 rcu_read_lock();
77362 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77363 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77364 flags |= PT_PTRACE_CAP;
77365 rcu_read_unlock();
77366 task->ptrace = flags;
77367 @@ -535,7 +535,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
77368 break;
77369 return -EIO;
77370 }
77371 - if (copy_to_user(dst, buf, retval))
77372 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
77373 return -EFAULT;
77374 copied += retval;
77375 src += retval;
77376 @@ -726,7 +726,7 @@ int ptrace_request(struct task_struct *child, long request,
77377 bool seized = child->ptrace & PT_SEIZED;
77378 int ret = -EIO;
77379 siginfo_t siginfo, *si;
77380 - void __user *datavp = (void __user *) data;
77381 + void __user *datavp = (__force void __user *) data;
77382 unsigned long __user *datalp = datavp;
77383 unsigned long flags;
77384
77385 @@ -928,14 +928,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
77386 goto out;
77387 }
77388
77389 + if (gr_handle_ptrace(child, request)) {
77390 + ret = -EPERM;
77391 + goto out_put_task_struct;
77392 + }
77393 +
77394 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77395 ret = ptrace_attach(child, request, addr, data);
77396 /*
77397 * Some architectures need to do book-keeping after
77398 * a ptrace attach.
77399 */
77400 - if (!ret)
77401 + if (!ret) {
77402 arch_ptrace_attach(child);
77403 + gr_audit_ptrace(child);
77404 + }
77405 goto out_put_task_struct;
77406 }
77407
77408 @@ -963,7 +970,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
77409 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
77410 if (copied != sizeof(tmp))
77411 return -EIO;
77412 - return put_user(tmp, (unsigned long __user *)data);
77413 + return put_user(tmp, (__force unsigned long __user *)data);
77414 }
77415
77416 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
77417 @@ -1057,7 +1064,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
77418 }
77419
77420 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77421 - compat_long_t addr, compat_long_t data)
77422 + compat_ulong_t addr, compat_ulong_t data)
77423 {
77424 struct task_struct *child;
77425 long ret;
77426 @@ -1073,14 +1080,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77427 goto out;
77428 }
77429
77430 + if (gr_handle_ptrace(child, request)) {
77431 + ret = -EPERM;
77432 + goto out_put_task_struct;
77433 + }
77434 +
77435 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77436 ret = ptrace_attach(child, request, addr, data);
77437 /*
77438 * Some architectures need to do book-keeping after
77439 * a ptrace attach.
77440 */
77441 - if (!ret)
77442 + if (!ret) {
77443 arch_ptrace_attach(child);
77444 + gr_audit_ptrace(child);
77445 + }
77446 goto out_put_task_struct;
77447 }
77448
77449 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
77450 index 48ab703..07561d4 100644
77451 --- a/kernel/rcupdate.c
77452 +++ b/kernel/rcupdate.c
77453 @@ -439,10 +439,10 @@ int rcu_jiffies_till_stall_check(void)
77454 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
77455 */
77456 if (till_stall_check < 3) {
77457 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
77458 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
77459 till_stall_check = 3;
77460 } else if (till_stall_check > 300) {
77461 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
77462 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
77463 till_stall_check = 300;
77464 }
77465 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
77466 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
77467 index a0714a5..2ab5e34 100644
77468 --- a/kernel/rcutiny.c
77469 +++ b/kernel/rcutiny.c
77470 @@ -46,7 +46,7 @@
77471 struct rcu_ctrlblk;
77472 static void invoke_rcu_callbacks(void);
77473 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
77474 -static void rcu_process_callbacks(struct softirq_action *unused);
77475 +static void rcu_process_callbacks(void);
77476 static void __call_rcu(struct rcu_head *head,
77477 void (*func)(struct rcu_head *rcu),
77478 struct rcu_ctrlblk *rcp);
77479 @@ -312,7 +312,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
77480 rcu_is_callbacks_kthread()));
77481 }
77482
77483 -static void rcu_process_callbacks(struct softirq_action *unused)
77484 +static void rcu_process_callbacks(void)
77485 {
77486 __rcu_process_callbacks(&rcu_sched_ctrlblk);
77487 __rcu_process_callbacks(&rcu_bh_ctrlblk);
77488 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
77489 index 8a23300..4255818 100644
77490 --- a/kernel/rcutiny_plugin.h
77491 +++ b/kernel/rcutiny_plugin.h
77492 @@ -945,7 +945,7 @@ static int rcu_kthread(void *arg)
77493 have_rcu_kthread_work = morework;
77494 local_irq_restore(flags);
77495 if (work)
77496 - rcu_process_callbacks(NULL);
77497 + rcu_process_callbacks();
77498 schedule_timeout_interruptible(1); /* Leave CPU for others. */
77499 }
77500
77501 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
77502 index e1f3a8c..42c94a2 100644
77503 --- a/kernel/rcutorture.c
77504 +++ b/kernel/rcutorture.c
77505 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
77506 { 0 };
77507 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
77508 { 0 };
77509 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77510 -static atomic_t n_rcu_torture_alloc;
77511 -static atomic_t n_rcu_torture_alloc_fail;
77512 -static atomic_t n_rcu_torture_free;
77513 -static atomic_t n_rcu_torture_mberror;
77514 -static atomic_t n_rcu_torture_error;
77515 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77516 +static atomic_unchecked_t n_rcu_torture_alloc;
77517 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
77518 +static atomic_unchecked_t n_rcu_torture_free;
77519 +static atomic_unchecked_t n_rcu_torture_mberror;
77520 +static atomic_unchecked_t n_rcu_torture_error;
77521 static long n_rcu_torture_barrier_error;
77522 static long n_rcu_torture_boost_ktrerror;
77523 static long n_rcu_torture_boost_rterror;
77524 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
77525
77526 spin_lock_bh(&rcu_torture_lock);
77527 if (list_empty(&rcu_torture_freelist)) {
77528 - atomic_inc(&n_rcu_torture_alloc_fail);
77529 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
77530 spin_unlock_bh(&rcu_torture_lock);
77531 return NULL;
77532 }
77533 - atomic_inc(&n_rcu_torture_alloc);
77534 + atomic_inc_unchecked(&n_rcu_torture_alloc);
77535 p = rcu_torture_freelist.next;
77536 list_del_init(p);
77537 spin_unlock_bh(&rcu_torture_lock);
77538 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
77539 static void
77540 rcu_torture_free(struct rcu_torture *p)
77541 {
77542 - atomic_inc(&n_rcu_torture_free);
77543 + atomic_inc_unchecked(&n_rcu_torture_free);
77544 spin_lock_bh(&rcu_torture_lock);
77545 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
77546 spin_unlock_bh(&rcu_torture_lock);
77547 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
77548 i = rp->rtort_pipe_count;
77549 if (i > RCU_TORTURE_PIPE_LEN)
77550 i = RCU_TORTURE_PIPE_LEN;
77551 - atomic_inc(&rcu_torture_wcount[i]);
77552 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77553 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77554 rp->rtort_mbtest = 0;
77555 rcu_torture_free(rp);
77556 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
77557 i = rp->rtort_pipe_count;
77558 if (i > RCU_TORTURE_PIPE_LEN)
77559 i = RCU_TORTURE_PIPE_LEN;
77560 - atomic_inc(&rcu_torture_wcount[i]);
77561 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77562 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77563 rp->rtort_mbtest = 0;
77564 list_del(&rp->rtort_free);
77565 @@ -990,7 +990,7 @@ rcu_torture_writer(void *arg)
77566 i = old_rp->rtort_pipe_count;
77567 if (i > RCU_TORTURE_PIPE_LEN)
77568 i = RCU_TORTURE_PIPE_LEN;
77569 - atomic_inc(&rcu_torture_wcount[i]);
77570 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77571 old_rp->rtort_pipe_count++;
77572 cur_ops->deferred_free(old_rp);
77573 }
77574 @@ -1076,7 +1076,7 @@ static void rcu_torture_timer(unsigned long unused)
77575 return;
77576 }
77577 if (p->rtort_mbtest == 0)
77578 - atomic_inc(&n_rcu_torture_mberror);
77579 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77580 spin_lock(&rand_lock);
77581 cur_ops->read_delay(&rand);
77582 n_rcu_torture_timers++;
77583 @@ -1146,7 +1146,7 @@ rcu_torture_reader(void *arg)
77584 continue;
77585 }
77586 if (p->rtort_mbtest == 0)
77587 - atomic_inc(&n_rcu_torture_mberror);
77588 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77589 cur_ops->read_delay(&rand);
77590 preempt_disable();
77591 pipe_count = p->rtort_pipe_count;
77592 @@ -1209,11 +1209,11 @@ rcu_torture_printk(char *page)
77593 rcu_torture_current,
77594 rcu_torture_current_version,
77595 list_empty(&rcu_torture_freelist),
77596 - atomic_read(&n_rcu_torture_alloc),
77597 - atomic_read(&n_rcu_torture_alloc_fail),
77598 - atomic_read(&n_rcu_torture_free));
77599 + atomic_read_unchecked(&n_rcu_torture_alloc),
77600 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
77601 + atomic_read_unchecked(&n_rcu_torture_free));
77602 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
77603 - atomic_read(&n_rcu_torture_mberror),
77604 + atomic_read_unchecked(&n_rcu_torture_mberror),
77605 n_rcu_torture_boost_ktrerror,
77606 n_rcu_torture_boost_rterror);
77607 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
77608 @@ -1232,14 +1232,14 @@ rcu_torture_printk(char *page)
77609 n_barrier_attempts,
77610 n_rcu_torture_barrier_error);
77611 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
77612 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
77613 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
77614 n_rcu_torture_barrier_error != 0 ||
77615 n_rcu_torture_boost_ktrerror != 0 ||
77616 n_rcu_torture_boost_rterror != 0 ||
77617 n_rcu_torture_boost_failure != 0 ||
77618 i > 1) {
77619 cnt += sprintf(&page[cnt], "!!! ");
77620 - atomic_inc(&n_rcu_torture_error);
77621 + atomic_inc_unchecked(&n_rcu_torture_error);
77622 WARN_ON_ONCE(1);
77623 }
77624 cnt += sprintf(&page[cnt], "Reader Pipe: ");
77625 @@ -1253,7 +1253,7 @@ rcu_torture_printk(char *page)
77626 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
77627 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77628 cnt += sprintf(&page[cnt], " %d",
77629 - atomic_read(&rcu_torture_wcount[i]));
77630 + atomic_read_unchecked(&rcu_torture_wcount[i]));
77631 }
77632 cnt += sprintf(&page[cnt], "\n");
77633 if (cur_ops->stats)
77634 @@ -1962,7 +1962,7 @@ rcu_torture_cleanup(void)
77635
77636 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
77637
77638 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77639 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77640 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
77641 else if (n_online_successes != n_online_attempts ||
77642 n_offline_successes != n_offline_attempts)
77643 @@ -2031,18 +2031,18 @@ rcu_torture_init(void)
77644
77645 rcu_torture_current = NULL;
77646 rcu_torture_current_version = 0;
77647 - atomic_set(&n_rcu_torture_alloc, 0);
77648 - atomic_set(&n_rcu_torture_alloc_fail, 0);
77649 - atomic_set(&n_rcu_torture_free, 0);
77650 - atomic_set(&n_rcu_torture_mberror, 0);
77651 - atomic_set(&n_rcu_torture_error, 0);
77652 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
77653 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
77654 + atomic_set_unchecked(&n_rcu_torture_free, 0);
77655 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
77656 + atomic_set_unchecked(&n_rcu_torture_error, 0);
77657 n_rcu_torture_barrier_error = 0;
77658 n_rcu_torture_boost_ktrerror = 0;
77659 n_rcu_torture_boost_rterror = 0;
77660 n_rcu_torture_boost_failure = 0;
77661 n_rcu_torture_boosts = 0;
77662 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
77663 - atomic_set(&rcu_torture_wcount[i], 0);
77664 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
77665 for_each_possible_cpu(cpu) {
77666 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77667 per_cpu(rcu_torture_count, cpu)[i] = 0;
77668 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
77669 index 5b8ad82..17274d1 100644
77670 --- a/kernel/rcutree.c
77671 +++ b/kernel/rcutree.c
77672 @@ -353,9 +353,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
77673 rcu_prepare_for_idle(smp_processor_id());
77674 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77675 smp_mb__before_atomic_inc(); /* See above. */
77676 - atomic_inc(&rdtp->dynticks);
77677 + atomic_inc_unchecked(&rdtp->dynticks);
77678 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
77679 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77680 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77681
77682 /*
77683 * It is illegal to enter an extended quiescent state while
77684 @@ -491,10 +491,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
77685 int user)
77686 {
77687 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
77688 - atomic_inc(&rdtp->dynticks);
77689 + atomic_inc_unchecked(&rdtp->dynticks);
77690 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77691 smp_mb__after_atomic_inc(); /* See above. */
77692 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77693 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77694 rcu_cleanup_after_idle(smp_processor_id());
77695 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
77696 if (!user && !is_idle_task(current)) {
77697 @@ -633,14 +633,14 @@ void rcu_nmi_enter(void)
77698 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
77699
77700 if (rdtp->dynticks_nmi_nesting == 0 &&
77701 - (atomic_read(&rdtp->dynticks) & 0x1))
77702 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
77703 return;
77704 rdtp->dynticks_nmi_nesting++;
77705 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
77706 - atomic_inc(&rdtp->dynticks);
77707 + atomic_inc_unchecked(&rdtp->dynticks);
77708 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77709 smp_mb__after_atomic_inc(); /* See above. */
77710 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77711 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77712 }
77713
77714 /**
77715 @@ -659,9 +659,9 @@ void rcu_nmi_exit(void)
77716 return;
77717 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77718 smp_mb__before_atomic_inc(); /* See above. */
77719 - atomic_inc(&rdtp->dynticks);
77720 + atomic_inc_unchecked(&rdtp->dynticks);
77721 smp_mb__after_atomic_inc(); /* Force delay to next write. */
77722 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77723 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77724 }
77725
77726 /**
77727 @@ -675,7 +675,7 @@ int rcu_is_cpu_idle(void)
77728 int ret;
77729
77730 preempt_disable();
77731 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77732 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77733 preempt_enable();
77734 return ret;
77735 }
77736 @@ -743,7 +743,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
77737 */
77738 static int dyntick_save_progress_counter(struct rcu_data *rdp)
77739 {
77740 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
77741 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77742 return (rdp->dynticks_snap & 0x1) == 0;
77743 }
77744
77745 @@ -758,7 +758,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
77746 unsigned int curr;
77747 unsigned int snap;
77748
77749 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
77750 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77751 snap = (unsigned int)rdp->dynticks_snap;
77752
77753 /*
77754 @@ -1698,7 +1698,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
77755 rsp->qlen += rdp->qlen;
77756 rdp->n_cbs_orphaned += rdp->qlen;
77757 rdp->qlen_lazy = 0;
77758 - ACCESS_ONCE(rdp->qlen) = 0;
77759 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77760 }
77761
77762 /*
77763 @@ -1944,7 +1944,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
77764 }
77765 smp_mb(); /* List handling before counting for rcu_barrier(). */
77766 rdp->qlen_lazy -= count_lazy;
77767 - ACCESS_ONCE(rdp->qlen) -= count;
77768 + ACCESS_ONCE_RW(rdp->qlen) -= count;
77769 rdp->n_cbs_invoked += count;
77770
77771 /* Reinstate batch limit if we have worked down the excess. */
77772 @@ -2137,7 +2137,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
77773 /*
77774 * Do RCU core processing for the current CPU.
77775 */
77776 -static void rcu_process_callbacks(struct softirq_action *unused)
77777 +static void rcu_process_callbacks(void)
77778 {
77779 struct rcu_state *rsp;
77780
77781 @@ -2260,7 +2260,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
77782 local_irq_restore(flags);
77783 return;
77784 }
77785 - ACCESS_ONCE(rdp->qlen)++;
77786 + ACCESS_ONCE_RW(rdp->qlen)++;
77787 if (lazy)
77788 rdp->qlen_lazy++;
77789 else
77790 @@ -2469,11 +2469,11 @@ void synchronize_sched_expedited(void)
77791 * counter wrap on a 32-bit system. Quite a few more CPUs would of
77792 * course be required on a 64-bit system.
77793 */
77794 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
77795 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
77796 (ulong)atomic_long_read(&rsp->expedited_done) +
77797 ULONG_MAX / 8)) {
77798 synchronize_sched();
77799 - atomic_long_inc(&rsp->expedited_wrap);
77800 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
77801 return;
77802 }
77803
77804 @@ -2481,7 +2481,7 @@ void synchronize_sched_expedited(void)
77805 * Take a ticket. Note that atomic_inc_return() implies a
77806 * full memory barrier.
77807 */
77808 - snap = atomic_long_inc_return(&rsp->expedited_start);
77809 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
77810 firstsnap = snap;
77811 get_online_cpus();
77812 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
77813 @@ -2494,14 +2494,14 @@ void synchronize_sched_expedited(void)
77814 synchronize_sched_expedited_cpu_stop,
77815 NULL) == -EAGAIN) {
77816 put_online_cpus();
77817 - atomic_long_inc(&rsp->expedited_tryfail);
77818 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
77819
77820 /* Check to see if someone else did our work for us. */
77821 s = atomic_long_read(&rsp->expedited_done);
77822 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77823 /* ensure test happens before caller kfree */
77824 smp_mb__before_atomic_inc(); /* ^^^ */
77825 - atomic_long_inc(&rsp->expedited_workdone1);
77826 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
77827 return;
77828 }
77829
77830 @@ -2510,7 +2510,7 @@ void synchronize_sched_expedited(void)
77831 udelay(trycount * num_online_cpus());
77832 } else {
77833 wait_rcu_gp(call_rcu_sched);
77834 - atomic_long_inc(&rsp->expedited_normal);
77835 + atomic_long_inc_unchecked(&rsp->expedited_normal);
77836 return;
77837 }
77838
77839 @@ -2519,7 +2519,7 @@ void synchronize_sched_expedited(void)
77840 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77841 /* ensure test happens before caller kfree */
77842 smp_mb__before_atomic_inc(); /* ^^^ */
77843 - atomic_long_inc(&rsp->expedited_workdone2);
77844 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
77845 return;
77846 }
77847
77848 @@ -2531,10 +2531,10 @@ void synchronize_sched_expedited(void)
77849 * period works for us.
77850 */
77851 get_online_cpus();
77852 - snap = atomic_long_read(&rsp->expedited_start);
77853 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
77854 smp_mb(); /* ensure read is before try_stop_cpus(). */
77855 }
77856 - atomic_long_inc(&rsp->expedited_stoppedcpus);
77857 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
77858
77859 /*
77860 * Everyone up to our most recent fetch is covered by our grace
77861 @@ -2543,16 +2543,16 @@ void synchronize_sched_expedited(void)
77862 * than we did already did their update.
77863 */
77864 do {
77865 - atomic_long_inc(&rsp->expedited_done_tries);
77866 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
77867 s = atomic_long_read(&rsp->expedited_done);
77868 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
77869 /* ensure test happens before caller kfree */
77870 smp_mb__before_atomic_inc(); /* ^^^ */
77871 - atomic_long_inc(&rsp->expedited_done_lost);
77872 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
77873 break;
77874 }
77875 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
77876 - atomic_long_inc(&rsp->expedited_done_exit);
77877 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
77878
77879 put_online_cpus();
77880 }
77881 @@ -2726,7 +2726,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77882 * ACCESS_ONCE() to prevent the compiler from speculating
77883 * the increment to precede the early-exit check.
77884 */
77885 - ACCESS_ONCE(rsp->n_barrier_done)++;
77886 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77887 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
77888 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
77889 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
77890 @@ -2776,7 +2776,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77891
77892 /* Increment ->n_barrier_done to prevent duplicate work. */
77893 smp_mb(); /* Keep increment after above mechanism. */
77894 - ACCESS_ONCE(rsp->n_barrier_done)++;
77895 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77896 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
77897 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
77898 smp_mb(); /* Keep increment before caller's subsequent code. */
77899 @@ -2821,10 +2821,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
77900 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
77901 init_callback_list(rdp);
77902 rdp->qlen_lazy = 0;
77903 - ACCESS_ONCE(rdp->qlen) = 0;
77904 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77905 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
77906 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
77907 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
77908 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
77909 rdp->cpu = cpu;
77910 rdp->rsp = rsp;
77911 rcu_boot_init_nocb_percpu_data(rdp);
77912 @@ -2857,8 +2857,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
77913 rdp->blimit = blimit;
77914 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
77915 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
77916 - atomic_set(&rdp->dynticks->dynticks,
77917 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
77918 + atomic_set_unchecked(&rdp->dynticks->dynticks,
77919 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
77920 rcu_prepare_for_idle_init(cpu);
77921 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
77922
77923 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
77924 index c896b50..c357252 100644
77925 --- a/kernel/rcutree.h
77926 +++ b/kernel/rcutree.h
77927 @@ -86,7 +86,7 @@ struct rcu_dynticks {
77928 long long dynticks_nesting; /* Track irq/process nesting level. */
77929 /* Process level is worth LLONG_MAX/2. */
77930 int dynticks_nmi_nesting; /* Track NMI nesting level. */
77931 - atomic_t dynticks; /* Even value for idle, else odd. */
77932 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
77933 #ifdef CONFIG_RCU_FAST_NO_HZ
77934 int dyntick_drain; /* Prepare-for-idle state variable. */
77935 unsigned long dyntick_holdoff;
77936 @@ -416,17 +416,17 @@ struct rcu_state {
77937 /* _rcu_barrier(). */
77938 /* End of fields guarded by barrier_mutex. */
77939
77940 - atomic_long_t expedited_start; /* Starting ticket. */
77941 - atomic_long_t expedited_done; /* Done ticket. */
77942 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
77943 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
77944 - atomic_long_t expedited_workdone1; /* # done by others #1. */
77945 - atomic_long_t expedited_workdone2; /* # done by others #2. */
77946 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
77947 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
77948 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
77949 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
77950 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
77951 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
77952 + atomic_long_t expedited_done; /* Done ticket. */
77953 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
77954 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
77955 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
77956 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
77957 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
77958 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
77959 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
77960 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
77961 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
77962
77963 unsigned long jiffies_force_qs; /* Time at which to invoke */
77964 /* force_quiescent_state(). */
77965 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
77966 index c1cc7e1..f62e436 100644
77967 --- a/kernel/rcutree_plugin.h
77968 +++ b/kernel/rcutree_plugin.h
77969 @@ -892,7 +892,7 @@ void synchronize_rcu_expedited(void)
77970
77971 /* Clean up and exit. */
77972 smp_mb(); /* ensure expedited GP seen before counter increment. */
77973 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
77974 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
77975 unlock_mb_ret:
77976 mutex_unlock(&sync_rcu_preempt_exp_mutex);
77977 mb_ret:
77978 @@ -1440,7 +1440,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
77979 free_cpumask_var(cm);
77980 }
77981
77982 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
77983 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
77984 .store = &rcu_cpu_kthread_task,
77985 .thread_should_run = rcu_cpu_kthread_should_run,
77986 .thread_fn = rcu_cpu_kthread,
77987 @@ -2072,7 +2072,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
77988 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
77989 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
77990 cpu, ticks_value, ticks_title,
77991 - atomic_read(&rdtp->dynticks) & 0xfff,
77992 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
77993 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
77994 fast_no_hz);
77995 }
77996 @@ -2192,7 +2192,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
77997
77998 /* Enqueue the callback on the nocb list and update counts. */
77999 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
78000 - ACCESS_ONCE(*old_rhpp) = rhp;
78001 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
78002 atomic_long_add(rhcount, &rdp->nocb_q_count);
78003 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
78004
78005 @@ -2384,12 +2384,12 @@ static int rcu_nocb_kthread(void *arg)
78006 * Extract queued callbacks, update counts, and wait
78007 * for a grace period to elapse.
78008 */
78009 - ACCESS_ONCE(rdp->nocb_head) = NULL;
78010 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
78011 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
78012 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
78013 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
78014 - ACCESS_ONCE(rdp->nocb_p_count) += c;
78015 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
78016 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
78017 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
78018 wait_rcu_gp(rdp->rsp->call_remote);
78019
78020 /* Each pass through the following loop invokes a callback. */
78021 @@ -2411,8 +2411,8 @@ static int rcu_nocb_kthread(void *arg)
78022 list = next;
78023 }
78024 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
78025 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
78026 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
78027 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
78028 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
78029 rdp->n_nocbs_invoked += c;
78030 }
78031 return 0;
78032 @@ -2438,7 +2438,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
78033 rdp = per_cpu_ptr(rsp->rda, cpu);
78034 t = kthread_run(rcu_nocb_kthread, rdp, "rcuo%d", cpu);
78035 BUG_ON(IS_ERR(t));
78036 - ACCESS_ONCE(rdp->nocb_kthread) = t;
78037 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
78038 }
78039 }
78040
78041 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
78042 index 93f8e8f..cf812ae 100644
78043 --- a/kernel/rcutree_trace.c
78044 +++ b/kernel/rcutree_trace.c
78045 @@ -123,7 +123,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
78046 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
78047 rdp->passed_quiesce, rdp->qs_pending);
78048 seq_printf(m, " dt=%d/%llx/%d df=%lu",
78049 - atomic_read(&rdp->dynticks->dynticks),
78050 + atomic_read_unchecked(&rdp->dynticks->dynticks),
78051 rdp->dynticks->dynticks_nesting,
78052 rdp->dynticks->dynticks_nmi_nesting,
78053 rdp->dynticks_fqs);
78054 @@ -184,17 +184,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
78055 struct rcu_state *rsp = (struct rcu_state *)m->private;
78056
78057 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",
78058 - atomic_long_read(&rsp->expedited_start),
78059 + atomic_long_read_unchecked(&rsp->expedited_start),
78060 atomic_long_read(&rsp->expedited_done),
78061 - atomic_long_read(&rsp->expedited_wrap),
78062 - atomic_long_read(&rsp->expedited_tryfail),
78063 - atomic_long_read(&rsp->expedited_workdone1),
78064 - atomic_long_read(&rsp->expedited_workdone2),
78065 - atomic_long_read(&rsp->expedited_normal),
78066 - atomic_long_read(&rsp->expedited_stoppedcpus),
78067 - atomic_long_read(&rsp->expedited_done_tries),
78068 - atomic_long_read(&rsp->expedited_done_lost),
78069 - atomic_long_read(&rsp->expedited_done_exit));
78070 + atomic_long_read_unchecked(&rsp->expedited_wrap),
78071 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
78072 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
78073 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
78074 + atomic_long_read_unchecked(&rsp->expedited_normal),
78075 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
78076 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
78077 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
78078 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
78079 return 0;
78080 }
78081
78082 diff --git a/kernel/resource.c b/kernel/resource.c
78083 index 73f35d4..4684fc4 100644
78084 --- a/kernel/resource.c
78085 +++ b/kernel/resource.c
78086 @@ -143,8 +143,18 @@ static const struct file_operations proc_iomem_operations = {
78087
78088 static int __init ioresources_init(void)
78089 {
78090 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78091 +#ifdef CONFIG_GRKERNSEC_PROC_USER
78092 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
78093 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
78094 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
78095 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
78096 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
78097 +#endif
78098 +#else
78099 proc_create("ioports", 0, NULL, &proc_ioports_operations);
78100 proc_create("iomem", 0, NULL, &proc_iomem_operations);
78101 +#endif
78102 return 0;
78103 }
78104 __initcall(ioresources_init);
78105 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
78106 index 7890b10..8b68605f 100644
78107 --- a/kernel/rtmutex-tester.c
78108 +++ b/kernel/rtmutex-tester.c
78109 @@ -21,7 +21,7 @@
78110 #define MAX_RT_TEST_MUTEXES 8
78111
78112 static spinlock_t rttest_lock;
78113 -static atomic_t rttest_event;
78114 +static atomic_unchecked_t rttest_event;
78115
78116 struct test_thread_data {
78117 int opcode;
78118 @@ -62,7 +62,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78119
78120 case RTTEST_LOCKCONT:
78121 td->mutexes[td->opdata] = 1;
78122 - td->event = atomic_add_return(1, &rttest_event);
78123 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78124 return 0;
78125
78126 case RTTEST_RESET:
78127 @@ -75,7 +75,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78128 return 0;
78129
78130 case RTTEST_RESETEVENT:
78131 - atomic_set(&rttest_event, 0);
78132 + atomic_set_unchecked(&rttest_event, 0);
78133 return 0;
78134
78135 default:
78136 @@ -92,9 +92,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78137 return ret;
78138
78139 td->mutexes[id] = 1;
78140 - td->event = atomic_add_return(1, &rttest_event);
78141 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78142 rt_mutex_lock(&mutexes[id]);
78143 - td->event = atomic_add_return(1, &rttest_event);
78144 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78145 td->mutexes[id] = 4;
78146 return 0;
78147
78148 @@ -105,9 +105,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78149 return ret;
78150
78151 td->mutexes[id] = 1;
78152 - td->event = atomic_add_return(1, &rttest_event);
78153 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78154 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
78155 - td->event = atomic_add_return(1, &rttest_event);
78156 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78157 td->mutexes[id] = ret ? 0 : 4;
78158 return ret ? -EINTR : 0;
78159
78160 @@ -116,9 +116,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78161 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
78162 return ret;
78163
78164 - td->event = atomic_add_return(1, &rttest_event);
78165 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78166 rt_mutex_unlock(&mutexes[id]);
78167 - td->event = atomic_add_return(1, &rttest_event);
78168 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78169 td->mutexes[id] = 0;
78170 return 0;
78171
78172 @@ -165,7 +165,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78173 break;
78174
78175 td->mutexes[dat] = 2;
78176 - td->event = atomic_add_return(1, &rttest_event);
78177 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78178 break;
78179
78180 default:
78181 @@ -185,7 +185,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78182 return;
78183
78184 td->mutexes[dat] = 3;
78185 - td->event = atomic_add_return(1, &rttest_event);
78186 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78187 break;
78188
78189 case RTTEST_LOCKNOWAIT:
78190 @@ -197,7 +197,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78191 return;
78192
78193 td->mutexes[dat] = 1;
78194 - td->event = atomic_add_return(1, &rttest_event);
78195 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78196 return;
78197
78198 default:
78199 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
78200 index 64de5f8..7735e12 100644
78201 --- a/kernel/sched/auto_group.c
78202 +++ b/kernel/sched/auto_group.c
78203 @@ -11,7 +11,7 @@
78204
78205 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
78206 static struct autogroup autogroup_default;
78207 -static atomic_t autogroup_seq_nr;
78208 +static atomic_unchecked_t autogroup_seq_nr;
78209
78210 void __init autogroup_init(struct task_struct *init_task)
78211 {
78212 @@ -81,7 +81,7 @@ static inline struct autogroup *autogroup_create(void)
78213
78214 kref_init(&ag->kref);
78215 init_rwsem(&ag->lock);
78216 - ag->id = atomic_inc_return(&autogroup_seq_nr);
78217 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
78218 ag->tg = tg;
78219 #ifdef CONFIG_RT_GROUP_SCHED
78220 /*
78221 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
78222 index 67d0465..4cf9361 100644
78223 --- a/kernel/sched/core.c
78224 +++ b/kernel/sched/core.c
78225 @@ -3406,7 +3406,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
78226 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78227 * positive (at least 1, or number of jiffies left till timeout) if completed.
78228 */
78229 -long __sched
78230 +long __sched __intentional_overflow(-1)
78231 wait_for_completion_interruptible_timeout(struct completion *x,
78232 unsigned long timeout)
78233 {
78234 @@ -3423,7 +3423,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
78235 *
78236 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
78237 */
78238 -int __sched wait_for_completion_killable(struct completion *x)
78239 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
78240 {
78241 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
78242 if (t == -ERESTARTSYS)
78243 @@ -3444,7 +3444,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
78244 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78245 * positive (at least 1, or number of jiffies left till timeout) if completed.
78246 */
78247 -long __sched
78248 +long __sched __intentional_overflow(-1)
78249 wait_for_completion_killable_timeout(struct completion *x,
78250 unsigned long timeout)
78251 {
78252 @@ -3670,6 +3670,8 @@ int can_nice(const struct task_struct *p, const int nice)
78253 /* convert nice value [19,-20] to rlimit style value [1,40] */
78254 int nice_rlim = 20 - nice;
78255
78256 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
78257 +
78258 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
78259 capable(CAP_SYS_NICE));
78260 }
78261 @@ -3703,7 +3705,8 @@ SYSCALL_DEFINE1(nice, int, increment)
78262 if (nice > 19)
78263 nice = 19;
78264
78265 - if (increment < 0 && !can_nice(current, nice))
78266 + if (increment < 0 && (!can_nice(current, nice) ||
78267 + gr_handle_chroot_nice()))
78268 return -EPERM;
78269
78270 retval = security_task_setnice(current, nice);
78271 @@ -3857,6 +3860,7 @@ recheck:
78272 unsigned long rlim_rtprio =
78273 task_rlimit(p, RLIMIT_RTPRIO);
78274
78275 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
78276 /* can't set/change the rt policy */
78277 if (policy != p->policy && !rlim_rtprio)
78278 return -EPERM;
78279 @@ -4954,7 +4958,7 @@ static void migrate_tasks(unsigned int dead_cpu)
78280
78281 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
78282
78283 -static struct ctl_table sd_ctl_dir[] = {
78284 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
78285 {
78286 .procname = "sched_domain",
78287 .mode = 0555,
78288 @@ -4971,17 +4975,17 @@ static struct ctl_table sd_ctl_root[] = {
78289 {}
78290 };
78291
78292 -static struct ctl_table *sd_alloc_ctl_entry(int n)
78293 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
78294 {
78295 - struct ctl_table *entry =
78296 + ctl_table_no_const *entry =
78297 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
78298
78299 return entry;
78300 }
78301
78302 -static void sd_free_ctl_entry(struct ctl_table **tablep)
78303 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
78304 {
78305 - struct ctl_table *entry;
78306 + ctl_table_no_const *entry;
78307
78308 /*
78309 * In the intermediate directories, both the child directory and
78310 @@ -4989,22 +4993,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
78311 * will always be set. In the lowest directory the names are
78312 * static strings and all have proc handlers.
78313 */
78314 - for (entry = *tablep; entry->mode; entry++) {
78315 - if (entry->child)
78316 - sd_free_ctl_entry(&entry->child);
78317 + for (entry = tablep; entry->mode; entry++) {
78318 + if (entry->child) {
78319 + sd_free_ctl_entry(entry->child);
78320 + pax_open_kernel();
78321 + entry->child = NULL;
78322 + pax_close_kernel();
78323 + }
78324 if (entry->proc_handler == NULL)
78325 kfree(entry->procname);
78326 }
78327
78328 - kfree(*tablep);
78329 - *tablep = NULL;
78330 + kfree(tablep);
78331 }
78332
78333 static int min_load_idx = 0;
78334 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
78335
78336 static void
78337 -set_table_entry(struct ctl_table *entry,
78338 +set_table_entry(ctl_table_no_const *entry,
78339 const char *procname, void *data, int maxlen,
78340 umode_t mode, proc_handler *proc_handler,
78341 bool load_idx)
78342 @@ -5024,7 +5031,7 @@ set_table_entry(struct ctl_table *entry,
78343 static struct ctl_table *
78344 sd_alloc_ctl_domain_table(struct sched_domain *sd)
78345 {
78346 - struct ctl_table *table = sd_alloc_ctl_entry(13);
78347 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
78348
78349 if (table == NULL)
78350 return NULL;
78351 @@ -5059,9 +5066,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
78352 return table;
78353 }
78354
78355 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
78356 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
78357 {
78358 - struct ctl_table *entry, *table;
78359 + ctl_table_no_const *entry, *table;
78360 struct sched_domain *sd;
78361 int domain_num = 0, i;
78362 char buf[32];
78363 @@ -5088,11 +5095,13 @@ static struct ctl_table_header *sd_sysctl_header;
78364 static void register_sched_domain_sysctl(void)
78365 {
78366 int i, cpu_num = num_possible_cpus();
78367 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
78368 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
78369 char buf[32];
78370
78371 WARN_ON(sd_ctl_dir[0].child);
78372 + pax_open_kernel();
78373 sd_ctl_dir[0].child = entry;
78374 + pax_close_kernel();
78375
78376 if (entry == NULL)
78377 return;
78378 @@ -5115,8 +5124,12 @@ static void unregister_sched_domain_sysctl(void)
78379 if (sd_sysctl_header)
78380 unregister_sysctl_table(sd_sysctl_header);
78381 sd_sysctl_header = NULL;
78382 - if (sd_ctl_dir[0].child)
78383 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
78384 + if (sd_ctl_dir[0].child) {
78385 + sd_free_ctl_entry(sd_ctl_dir[0].child);
78386 + pax_open_kernel();
78387 + sd_ctl_dir[0].child = NULL;
78388 + pax_close_kernel();
78389 + }
78390 }
78391 #else
78392 static void register_sched_domain_sysctl(void)
78393 @@ -5215,7 +5228,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
78394 * happens before everything else. This has to be lower priority than
78395 * the notifier in the perf_event subsystem, though.
78396 */
78397 -static struct notifier_block __cpuinitdata migration_notifier = {
78398 +static struct notifier_block migration_notifier = {
78399 .notifier_call = migration_call,
78400 .priority = CPU_PRI_MIGRATION,
78401 };
78402 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
78403 index 7a33e59..2f7730c 100644
78404 --- a/kernel/sched/fair.c
78405 +++ b/kernel/sched/fair.c
78406 @@ -830,7 +830,7 @@ void task_numa_fault(int node, int pages, bool migrated)
78407
78408 static void reset_ptenuma_scan(struct task_struct *p)
78409 {
78410 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
78411 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
78412 p->mm->numa_scan_offset = 0;
78413 }
78414
78415 @@ -5654,7 +5654,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
78416 * run_rebalance_domains is triggered when needed from the scheduler tick.
78417 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
78418 */
78419 -static void run_rebalance_domains(struct softirq_action *h)
78420 +static void run_rebalance_domains(void)
78421 {
78422 int this_cpu = smp_processor_id();
78423 struct rq *this_rq = cpu_rq(this_cpu);
78424 diff --git a/kernel/signal.c b/kernel/signal.c
78425 index 598dc06..471310a 100644
78426 --- a/kernel/signal.c
78427 +++ b/kernel/signal.c
78428 @@ -50,12 +50,12 @@ static struct kmem_cache *sigqueue_cachep;
78429
78430 int print_fatal_signals __read_mostly;
78431
78432 -static void __user *sig_handler(struct task_struct *t, int sig)
78433 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
78434 {
78435 return t->sighand->action[sig - 1].sa.sa_handler;
78436 }
78437
78438 -static int sig_handler_ignored(void __user *handler, int sig)
78439 +static int sig_handler_ignored(__sighandler_t handler, int sig)
78440 {
78441 /* Is it explicitly or implicitly ignored? */
78442 return handler == SIG_IGN ||
78443 @@ -64,7 +64,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
78444
78445 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
78446 {
78447 - void __user *handler;
78448 + __sighandler_t handler;
78449
78450 handler = sig_handler(t, sig);
78451
78452 @@ -368,6 +368,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
78453 atomic_inc(&user->sigpending);
78454 rcu_read_unlock();
78455
78456 + if (!override_rlimit)
78457 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
78458 +
78459 if (override_rlimit ||
78460 atomic_read(&user->sigpending) <=
78461 task_rlimit(t, RLIMIT_SIGPENDING)) {
78462 @@ -495,7 +498,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
78463
78464 int unhandled_signal(struct task_struct *tsk, int sig)
78465 {
78466 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
78467 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
78468 if (is_global_init(tsk))
78469 return 1;
78470 if (handler != SIG_IGN && handler != SIG_DFL)
78471 @@ -815,6 +818,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
78472 }
78473 }
78474
78475 + /* allow glibc communication via tgkill to other threads in our
78476 + thread group */
78477 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
78478 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
78479 + && gr_handle_signal(t, sig))
78480 + return -EPERM;
78481 +
78482 return security_task_kill(t, info, sig, 0);
78483 }
78484
78485 @@ -1197,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78486 return send_signal(sig, info, p, 1);
78487 }
78488
78489 -static int
78490 +int
78491 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78492 {
78493 return send_signal(sig, info, t, 0);
78494 @@ -1234,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78495 unsigned long int flags;
78496 int ret, blocked, ignored;
78497 struct k_sigaction *action;
78498 + int is_unhandled = 0;
78499
78500 spin_lock_irqsave(&t->sighand->siglock, flags);
78501 action = &t->sighand->action[sig-1];
78502 @@ -1248,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78503 }
78504 if (action->sa.sa_handler == SIG_DFL)
78505 t->signal->flags &= ~SIGNAL_UNKILLABLE;
78506 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
78507 + is_unhandled = 1;
78508 ret = specific_send_sig_info(sig, info, t);
78509 spin_unlock_irqrestore(&t->sighand->siglock, flags);
78510
78511 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
78512 + normal operation */
78513 + if (is_unhandled) {
78514 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
78515 + gr_handle_crash(t, sig);
78516 + }
78517 +
78518 return ret;
78519 }
78520
78521 @@ -1317,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78522 ret = check_kill_permission(sig, info, p);
78523 rcu_read_unlock();
78524
78525 - if (!ret && sig)
78526 + if (!ret && sig) {
78527 ret = do_send_sig_info(sig, info, p, true);
78528 + if (!ret)
78529 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
78530 + }
78531
78532 return ret;
78533 }
78534 @@ -2923,7 +2946,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
78535 int error = -ESRCH;
78536
78537 rcu_read_lock();
78538 - p = find_task_by_vpid(pid);
78539 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
78540 + /* allow glibc communication via tgkill to other threads in our
78541 + thread group */
78542 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
78543 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
78544 + p = find_task_by_vpid_unrestricted(pid);
78545 + else
78546 +#endif
78547 + p = find_task_by_vpid(pid);
78548 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
78549 error = check_kill_permission(sig, info, p);
78550 /*
78551 @@ -3237,8 +3268,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
78552 }
78553 seg = get_fs();
78554 set_fs(KERNEL_DS);
78555 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
78556 - (stack_t __force __user *) &uoss,
78557 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
78558 + (stack_t __force_user *) &uoss,
78559 compat_user_stack_pointer());
78560 set_fs(seg);
78561 if (ret >= 0 && uoss_ptr) {
78562 diff --git a/kernel/smp.c b/kernel/smp.c
78563 index 8e451f3..8322029 100644
78564 --- a/kernel/smp.c
78565 +++ b/kernel/smp.c
78566 @@ -73,7 +73,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
78567 return NOTIFY_OK;
78568 }
78569
78570 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
78571 +static struct notifier_block hotplug_cfd_notifier = {
78572 .notifier_call = hotplug_cfd,
78573 };
78574
78575 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
78576 index 02fc5c9..e54c335 100644
78577 --- a/kernel/smpboot.c
78578 +++ b/kernel/smpboot.c
78579 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
78580 }
78581 smpboot_unpark_thread(plug_thread, cpu);
78582 }
78583 - list_add(&plug_thread->list, &hotplug_threads);
78584 + pax_list_add(&plug_thread->list, &hotplug_threads);
78585 out:
78586 mutex_unlock(&smpboot_threads_lock);
78587 return ret;
78588 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
78589 {
78590 get_online_cpus();
78591 mutex_lock(&smpboot_threads_lock);
78592 - list_del(&plug_thread->list);
78593 + pax_list_del(&plug_thread->list);
78594 smpboot_destroy_threads(plug_thread);
78595 mutex_unlock(&smpboot_threads_lock);
78596 put_online_cpus();
78597 diff --git a/kernel/softirq.c b/kernel/softirq.c
78598 index 14d7758..012121f 100644
78599 --- a/kernel/softirq.c
78600 +++ b/kernel/softirq.c
78601 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
78602 EXPORT_SYMBOL(irq_stat);
78603 #endif
78604
78605 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
78606 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
78607
78608 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
78609
78610 -char *softirq_to_name[NR_SOFTIRQS] = {
78611 +const char * const softirq_to_name[NR_SOFTIRQS] = {
78612 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
78613 "TASKLET", "SCHED", "HRTIMER", "RCU"
78614 };
78615 @@ -244,7 +244,7 @@ restart:
78616 kstat_incr_softirqs_this_cpu(vec_nr);
78617
78618 trace_softirq_entry(vec_nr);
78619 - h->action(h);
78620 + h->action();
78621 trace_softirq_exit(vec_nr);
78622 if (unlikely(prev_count != preempt_count())) {
78623 printk(KERN_ERR "huh, entered softirq %u %s %p"
78624 @@ -389,7 +389,7 @@ void __raise_softirq_irqoff(unsigned int nr)
78625 or_softirq_pending(1UL << nr);
78626 }
78627
78628 -void open_softirq(int nr, void (*action)(struct softirq_action *))
78629 +void __init open_softirq(int nr, void (*action)(void))
78630 {
78631 softirq_vec[nr].action = action;
78632 }
78633 @@ -445,7 +445,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
78634
78635 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
78636
78637 -static void tasklet_action(struct softirq_action *a)
78638 +static void tasklet_action(void)
78639 {
78640 struct tasklet_struct *list;
78641
78642 @@ -480,7 +480,7 @@ static void tasklet_action(struct softirq_action *a)
78643 }
78644 }
78645
78646 -static void tasklet_hi_action(struct softirq_action *a)
78647 +static void tasklet_hi_action(void)
78648 {
78649 struct tasklet_struct *list;
78650
78651 @@ -716,7 +716,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
78652 return NOTIFY_OK;
78653 }
78654
78655 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
78656 +static struct notifier_block remote_softirq_cpu_notifier = {
78657 .notifier_call = remote_softirq_cpu_notify,
78658 };
78659
78660 @@ -833,11 +833,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
78661 return NOTIFY_OK;
78662 }
78663
78664 -static struct notifier_block __cpuinitdata cpu_nfb = {
78665 +static struct notifier_block cpu_nfb = {
78666 .notifier_call = cpu_callback
78667 };
78668
78669 -static struct smp_hotplug_thread softirq_threads = {
78670 +static struct smp_hotplug_thread softirq_threads __read_only = {
78671 .store = &ksoftirqd,
78672 .thread_should_run = ksoftirqd_should_run,
78673 .thread_fn = run_ksoftirqd,
78674 diff --git a/kernel/srcu.c b/kernel/srcu.c
78675 index 01d5ccb..cdcbee6 100644
78676 --- a/kernel/srcu.c
78677 +++ b/kernel/srcu.c
78678 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
78679
78680 idx = ACCESS_ONCE(sp->completed) & 0x1;
78681 preempt_disable();
78682 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78683 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78684 smp_mb(); /* B */ /* Avoid leaking the critical section. */
78685 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78686 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78687 preempt_enable();
78688 return idx;
78689 }
78690 diff --git a/kernel/sys.c b/kernel/sys.c
78691 index 0da73cf..5c2af3c 100644
78692 --- a/kernel/sys.c
78693 +++ b/kernel/sys.c
78694 @@ -158,6 +158,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
78695 error = -EACCES;
78696 goto out;
78697 }
78698 +
78699 + if (gr_handle_chroot_setpriority(p, niceval)) {
78700 + error = -EACCES;
78701 + goto out;
78702 + }
78703 +
78704 no_nice = security_task_setnice(p, niceval);
78705 if (no_nice) {
78706 error = no_nice;
78707 @@ -598,6 +604,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
78708 goto error;
78709 }
78710
78711 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
78712 + goto error;
78713 +
78714 if (rgid != (gid_t) -1 ||
78715 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
78716 new->sgid = new->egid;
78717 @@ -633,6 +642,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
78718 old = current_cred();
78719
78720 retval = -EPERM;
78721 +
78722 + if (gr_check_group_change(kgid, kgid, kgid))
78723 + goto error;
78724 +
78725 if (nsown_capable(CAP_SETGID))
78726 new->gid = new->egid = new->sgid = new->fsgid = kgid;
78727 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
78728 @@ -650,7 +663,7 @@ error:
78729 /*
78730 * change the user struct in a credentials set to match the new UID
78731 */
78732 -static int set_user(struct cred *new)
78733 +int set_user(struct cred *new)
78734 {
78735 struct user_struct *new_user;
78736
78737 @@ -730,6 +743,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
78738 goto error;
78739 }
78740
78741 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
78742 + goto error;
78743 +
78744 if (!uid_eq(new->uid, old->uid)) {
78745 retval = set_user(new);
78746 if (retval < 0)
78747 @@ -780,6 +796,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
78748 old = current_cred();
78749
78750 retval = -EPERM;
78751 +
78752 + if (gr_check_crash_uid(kuid))
78753 + goto error;
78754 + if (gr_check_user_change(kuid, kuid, kuid))
78755 + goto error;
78756 +
78757 if (nsown_capable(CAP_SETUID)) {
78758 new->suid = new->uid = kuid;
78759 if (!uid_eq(kuid, old->uid)) {
78760 @@ -849,6 +871,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
78761 goto error;
78762 }
78763
78764 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
78765 + goto error;
78766 +
78767 if (ruid != (uid_t) -1) {
78768 new->uid = kruid;
78769 if (!uid_eq(kruid, old->uid)) {
78770 @@ -931,6 +956,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
78771 goto error;
78772 }
78773
78774 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
78775 + goto error;
78776 +
78777 if (rgid != (gid_t) -1)
78778 new->gid = krgid;
78779 if (egid != (gid_t) -1)
78780 @@ -992,12 +1020,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
78781 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
78782 nsown_capable(CAP_SETUID)) {
78783 if (!uid_eq(kuid, old->fsuid)) {
78784 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
78785 + goto error;
78786 +
78787 new->fsuid = kuid;
78788 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
78789 goto change_okay;
78790 }
78791 }
78792
78793 +error:
78794 abort_creds(new);
78795 return old_fsuid;
78796
78797 @@ -1030,12 +1062,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
78798 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
78799 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
78800 nsown_capable(CAP_SETGID)) {
78801 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
78802 + goto error;
78803 +
78804 if (!gid_eq(kgid, old->fsgid)) {
78805 new->fsgid = kgid;
78806 goto change_okay;
78807 }
78808 }
78809
78810 +error:
78811 abort_creds(new);
78812 return old_fsgid;
78813
78814 @@ -1343,19 +1379,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
78815 return -EFAULT;
78816
78817 down_read(&uts_sem);
78818 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
78819 + error = __copy_to_user(name->sysname, &utsname()->sysname,
78820 __OLD_UTS_LEN);
78821 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
78822 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
78823 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
78824 __OLD_UTS_LEN);
78825 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
78826 - error |= __copy_to_user(&name->release, &utsname()->release,
78827 + error |= __copy_to_user(name->release, &utsname()->release,
78828 __OLD_UTS_LEN);
78829 error |= __put_user(0, name->release + __OLD_UTS_LEN);
78830 - error |= __copy_to_user(&name->version, &utsname()->version,
78831 + error |= __copy_to_user(name->version, &utsname()->version,
78832 __OLD_UTS_LEN);
78833 error |= __put_user(0, name->version + __OLD_UTS_LEN);
78834 - error |= __copy_to_user(&name->machine, &utsname()->machine,
78835 + error |= __copy_to_user(name->machine, &utsname()->machine,
78836 __OLD_UTS_LEN);
78837 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
78838 up_read(&uts_sem);
78839 @@ -1557,6 +1593,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
78840 */
78841 new_rlim->rlim_cur = 1;
78842 }
78843 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
78844 + is changed to a lower value. Since tasks can be created by the same
78845 + user in between this limit change and an execve by this task, force
78846 + a recheck only for this task by setting PF_NPROC_EXCEEDED
78847 + */
78848 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
78849 + tsk->flags |= PF_NPROC_EXCEEDED;
78850 }
78851 if (!retval) {
78852 if (old_rlim)
78853 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
78854 index afc1dc6..fb0671d 100644
78855 --- a/kernel/sysctl.c
78856 +++ b/kernel/sysctl.c
78857 @@ -93,7 +93,6 @@
78858
78859
78860 #if defined(CONFIG_SYSCTL)
78861 -
78862 /* External variables not in a header file. */
78863 extern int sysctl_overcommit_memory;
78864 extern int sysctl_overcommit_ratio;
78865 @@ -178,10 +177,8 @@ static int proc_taint(struct ctl_table *table, int write,
78866 void __user *buffer, size_t *lenp, loff_t *ppos);
78867 #endif
78868
78869 -#ifdef CONFIG_PRINTK
78870 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78871 void __user *buffer, size_t *lenp, loff_t *ppos);
78872 -#endif
78873
78874 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
78875 void __user *buffer, size_t *lenp, loff_t *ppos);
78876 @@ -212,6 +209,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
78877
78878 #endif
78879
78880 +extern struct ctl_table grsecurity_table[];
78881 +
78882 static struct ctl_table kern_table[];
78883 static struct ctl_table vm_table[];
78884 static struct ctl_table fs_table[];
78885 @@ -226,6 +225,20 @@ extern struct ctl_table epoll_table[];
78886 int sysctl_legacy_va_layout;
78887 #endif
78888
78889 +#ifdef CONFIG_PAX_SOFTMODE
78890 +static ctl_table pax_table[] = {
78891 + {
78892 + .procname = "softmode",
78893 + .data = &pax_softmode,
78894 + .maxlen = sizeof(unsigned int),
78895 + .mode = 0600,
78896 + .proc_handler = &proc_dointvec,
78897 + },
78898 +
78899 + { }
78900 +};
78901 +#endif
78902 +
78903 /* The default sysctl tables: */
78904
78905 static struct ctl_table sysctl_base_table[] = {
78906 @@ -274,6 +287,22 @@ static int max_extfrag_threshold = 1000;
78907 #endif
78908
78909 static struct ctl_table kern_table[] = {
78910 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
78911 + {
78912 + .procname = "grsecurity",
78913 + .mode = 0500,
78914 + .child = grsecurity_table,
78915 + },
78916 +#endif
78917 +
78918 +#ifdef CONFIG_PAX_SOFTMODE
78919 + {
78920 + .procname = "pax",
78921 + .mode = 0500,
78922 + .child = pax_table,
78923 + },
78924 +#endif
78925 +
78926 {
78927 .procname = "sched_child_runs_first",
78928 .data = &sysctl_sched_child_runs_first,
78929 @@ -608,7 +637,7 @@ static struct ctl_table kern_table[] = {
78930 .data = &modprobe_path,
78931 .maxlen = KMOD_PATH_LEN,
78932 .mode = 0644,
78933 - .proc_handler = proc_dostring,
78934 + .proc_handler = proc_dostring_modpriv,
78935 },
78936 {
78937 .procname = "modules_disabled",
78938 @@ -775,16 +804,20 @@ static struct ctl_table kern_table[] = {
78939 .extra1 = &zero,
78940 .extra2 = &one,
78941 },
78942 +#endif
78943 {
78944 .procname = "kptr_restrict",
78945 .data = &kptr_restrict,
78946 .maxlen = sizeof(int),
78947 .mode = 0644,
78948 .proc_handler = proc_dointvec_minmax_sysadmin,
78949 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78950 + .extra1 = &two,
78951 +#else
78952 .extra1 = &zero,
78953 +#endif
78954 .extra2 = &two,
78955 },
78956 -#endif
78957 {
78958 .procname = "ngroups_max",
78959 .data = &ngroups_max,
78960 @@ -1026,10 +1059,17 @@ static struct ctl_table kern_table[] = {
78961 */
78962 {
78963 .procname = "perf_event_paranoid",
78964 - .data = &sysctl_perf_event_paranoid,
78965 - .maxlen = sizeof(sysctl_perf_event_paranoid),
78966 + .data = &sysctl_perf_event_legitimately_concerned,
78967 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
78968 .mode = 0644,
78969 - .proc_handler = proc_dointvec,
78970 + /* go ahead, be a hero */
78971 + .proc_handler = proc_dointvec_minmax_sysadmin,
78972 + .extra1 = &zero,
78973 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
78974 + .extra2 = &three,
78975 +#else
78976 + .extra2 = &two,
78977 +#endif
78978 },
78979 {
78980 .procname = "perf_event_mlock_kb",
78981 @@ -1283,6 +1323,13 @@ static struct ctl_table vm_table[] = {
78982 .proc_handler = proc_dointvec_minmax,
78983 .extra1 = &zero,
78984 },
78985 + {
78986 + .procname = "heap_stack_gap",
78987 + .data = &sysctl_heap_stack_gap,
78988 + .maxlen = sizeof(sysctl_heap_stack_gap),
78989 + .mode = 0644,
78990 + .proc_handler = proc_doulongvec_minmax,
78991 + },
78992 #else
78993 {
78994 .procname = "nr_trim_pages",
78995 @@ -1733,6 +1780,16 @@ int proc_dostring(struct ctl_table *table, int write,
78996 buffer, lenp, ppos);
78997 }
78998
78999 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79000 + void __user *buffer, size_t *lenp, loff_t *ppos)
79001 +{
79002 + if (write && !capable(CAP_SYS_MODULE))
79003 + return -EPERM;
79004 +
79005 + return _proc_do_string(table->data, table->maxlen, write,
79006 + buffer, lenp, ppos);
79007 +}
79008 +
79009 static size_t proc_skip_spaces(char **buf)
79010 {
79011 size_t ret;
79012 @@ -1838,6 +1895,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
79013 len = strlen(tmp);
79014 if (len > *size)
79015 len = *size;
79016 + if (len > sizeof(tmp))
79017 + len = sizeof(tmp);
79018 if (copy_to_user(*buf, tmp, len))
79019 return -EFAULT;
79020 *size -= len;
79021 @@ -2002,7 +2061,7 @@ int proc_dointvec(struct ctl_table *table, int write,
79022 static int proc_taint(struct ctl_table *table, int write,
79023 void __user *buffer, size_t *lenp, loff_t *ppos)
79024 {
79025 - struct ctl_table t;
79026 + ctl_table_no_const t;
79027 unsigned long tmptaint = get_taint();
79028 int err;
79029
79030 @@ -2030,7 +2089,6 @@ static int proc_taint(struct ctl_table *table, int write,
79031 return err;
79032 }
79033
79034 -#ifdef CONFIG_PRINTK
79035 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79036 void __user *buffer, size_t *lenp, loff_t *ppos)
79037 {
79038 @@ -2039,7 +2097,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79039
79040 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
79041 }
79042 -#endif
79043
79044 struct do_proc_dointvec_minmax_conv_param {
79045 int *min;
79046 @@ -2186,8 +2243,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
79047 *i = val;
79048 } else {
79049 val = convdiv * (*i) / convmul;
79050 - if (!first)
79051 + if (!first) {
79052 err = proc_put_char(&buffer, &left, '\t');
79053 + if (err)
79054 + break;
79055 + }
79056 err = proc_put_long(&buffer, &left, val, false);
79057 if (err)
79058 break;
79059 @@ -2579,6 +2639,12 @@ int proc_dostring(struct ctl_table *table, int write,
79060 return -ENOSYS;
79061 }
79062
79063 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79064 + void __user *buffer, size_t *lenp, loff_t *ppos)
79065 +{
79066 + return -ENOSYS;
79067 +}
79068 +
79069 int proc_dointvec(struct ctl_table *table, int write,
79070 void __user *buffer, size_t *lenp, loff_t *ppos)
79071 {
79072 @@ -2635,5 +2701,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
79073 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
79074 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
79075 EXPORT_SYMBOL(proc_dostring);
79076 +EXPORT_SYMBOL(proc_dostring_modpriv);
79077 EXPORT_SYMBOL(proc_doulongvec_minmax);
79078 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
79079 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
79080 index 145bb4d..b2aa969 100644
79081 --- a/kernel/taskstats.c
79082 +++ b/kernel/taskstats.c
79083 @@ -28,9 +28,12 @@
79084 #include <linux/fs.h>
79085 #include <linux/file.h>
79086 #include <linux/pid_namespace.h>
79087 +#include <linux/grsecurity.h>
79088 #include <net/genetlink.h>
79089 #include <linux/atomic.h>
79090
79091 +extern int gr_is_taskstats_denied(int pid);
79092 +
79093 /*
79094 * Maximum length of a cpumask that can be specified in
79095 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
79096 @@ -570,6 +573,9 @@ err:
79097
79098 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
79099 {
79100 + if (gr_is_taskstats_denied(current->pid))
79101 + return -EACCES;
79102 +
79103 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
79104 return cmd_attr_register_cpumask(info);
79105 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
79106 diff --git a/kernel/time.c b/kernel/time.c
79107 index f8342a4..288f13b 100644
79108 --- a/kernel/time.c
79109 +++ b/kernel/time.c
79110 @@ -171,6 +171,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
79111 return error;
79112
79113 if (tz) {
79114 + /* we log in do_settimeofday called below, so don't log twice
79115 + */
79116 + if (!tv)
79117 + gr_log_timechange();
79118 +
79119 sys_tz = *tz;
79120 update_vsyscall_tz();
79121 if (firsttime) {
79122 @@ -501,7 +506,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
79123 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
79124 * value to a scaled second value.
79125 */
79126 -unsigned long
79127 +unsigned long __intentional_overflow(-1)
79128 timespec_to_jiffies(const struct timespec *value)
79129 {
79130 unsigned long sec = value->tv_sec;
79131 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
79132 index f11d83b..d016d91 100644
79133 --- a/kernel/time/alarmtimer.c
79134 +++ b/kernel/time/alarmtimer.c
79135 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
79136 struct platform_device *pdev;
79137 int error = 0;
79138 int i;
79139 - struct k_clock alarm_clock = {
79140 + static struct k_clock alarm_clock = {
79141 .clock_getres = alarm_clock_getres,
79142 .clock_get = alarm_clock_get,
79143 .timer_create = alarm_timer_create,
79144 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
79145 index 90ad470..1814e9a 100644
79146 --- a/kernel/time/tick-broadcast.c
79147 +++ b/kernel/time/tick-broadcast.c
79148 @@ -138,7 +138,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
79149 * then clear the broadcast bit.
79150 */
79151 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
79152 - int cpu = smp_processor_id();
79153 + cpu = smp_processor_id();
79154 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
79155 tick_broadcast_clear_oneshot(cpu);
79156 } else {
79157 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
79158 index 9a0bc98..fceb7d0 100644
79159 --- a/kernel/time/timekeeping.c
79160 +++ b/kernel/time/timekeeping.c
79161 @@ -15,6 +15,7 @@
79162 #include <linux/init.h>
79163 #include <linux/mm.h>
79164 #include <linux/sched.h>
79165 +#include <linux/grsecurity.h>
79166 #include <linux/syscore_ops.h>
79167 #include <linux/clocksource.h>
79168 #include <linux/jiffies.h>
79169 @@ -448,6 +449,8 @@ int do_settimeofday(const struct timespec *tv)
79170 if (!timespec_valid_strict(tv))
79171 return -EINVAL;
79172
79173 + gr_log_timechange();
79174 +
79175 write_seqlock_irqsave(&tk->lock, flags);
79176
79177 timekeeping_forward_now(tk);
79178 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
79179 index af5a7e9..715611a 100644
79180 --- a/kernel/time/timer_list.c
79181 +++ b/kernel/time/timer_list.c
79182 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
79183
79184 static void print_name_offset(struct seq_file *m, void *sym)
79185 {
79186 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79187 + SEQ_printf(m, "<%p>", NULL);
79188 +#else
79189 char symname[KSYM_NAME_LEN];
79190
79191 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
79192 SEQ_printf(m, "<%pK>", sym);
79193 else
79194 SEQ_printf(m, "%s", symname);
79195 +#endif
79196 }
79197
79198 static void
79199 @@ -112,7 +116,11 @@ next_one:
79200 static void
79201 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
79202 {
79203 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79204 + SEQ_printf(m, " .base: %p\n", NULL);
79205 +#else
79206 SEQ_printf(m, " .base: %pK\n", base);
79207 +#endif
79208 SEQ_printf(m, " .index: %d\n",
79209 base->index);
79210 SEQ_printf(m, " .resolution: %Lu nsecs\n",
79211 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
79212 {
79213 struct proc_dir_entry *pe;
79214
79215 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79216 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
79217 +#else
79218 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
79219 +#endif
79220 if (!pe)
79221 return -ENOMEM;
79222 return 0;
79223 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
79224 index 0b537f2..40d6c20 100644
79225 --- a/kernel/time/timer_stats.c
79226 +++ b/kernel/time/timer_stats.c
79227 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
79228 static unsigned long nr_entries;
79229 static struct entry entries[MAX_ENTRIES];
79230
79231 -static atomic_t overflow_count;
79232 +static atomic_unchecked_t overflow_count;
79233
79234 /*
79235 * The entries are in a hash-table, for fast lookup:
79236 @@ -140,7 +140,7 @@ static void reset_entries(void)
79237 nr_entries = 0;
79238 memset(entries, 0, sizeof(entries));
79239 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
79240 - atomic_set(&overflow_count, 0);
79241 + atomic_set_unchecked(&overflow_count, 0);
79242 }
79243
79244 static struct entry *alloc_entry(void)
79245 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79246 if (likely(entry))
79247 entry->count++;
79248 else
79249 - atomic_inc(&overflow_count);
79250 + atomic_inc_unchecked(&overflow_count);
79251
79252 out_unlock:
79253 raw_spin_unlock_irqrestore(lock, flags);
79254 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79255
79256 static void print_name_offset(struct seq_file *m, unsigned long addr)
79257 {
79258 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79259 + seq_printf(m, "<%p>", NULL);
79260 +#else
79261 char symname[KSYM_NAME_LEN];
79262
79263 if (lookup_symbol_name(addr, symname) < 0)
79264 - seq_printf(m, "<%p>", (void *)addr);
79265 + seq_printf(m, "<%pK>", (void *)addr);
79266 else
79267 seq_printf(m, "%s", symname);
79268 +#endif
79269 }
79270
79271 static int tstats_show(struct seq_file *m, void *v)
79272 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
79273
79274 seq_puts(m, "Timer Stats Version: v0.2\n");
79275 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
79276 - if (atomic_read(&overflow_count))
79277 + if (atomic_read_unchecked(&overflow_count))
79278 seq_printf(m, "Overflow: %d entries\n",
79279 - atomic_read(&overflow_count));
79280 + atomic_read_unchecked(&overflow_count));
79281
79282 for (i = 0; i < nr_entries; i++) {
79283 entry = entries + i;
79284 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
79285 {
79286 struct proc_dir_entry *pe;
79287
79288 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79289 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
79290 +#else
79291 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
79292 +#endif
79293 if (!pe)
79294 return -ENOMEM;
79295 return 0;
79296 diff --git a/kernel/timer.c b/kernel/timer.c
79297 index 1b399c8..90e1849 100644
79298 --- a/kernel/timer.c
79299 +++ b/kernel/timer.c
79300 @@ -1363,7 +1363,7 @@ void update_process_times(int user_tick)
79301 /*
79302 * This function runs timers and the timer-tq in bottom half context.
79303 */
79304 -static void run_timer_softirq(struct softirq_action *h)
79305 +static void run_timer_softirq(void)
79306 {
79307 struct tvec_base *base = __this_cpu_read(tvec_bases);
79308
79309 @@ -1481,7 +1481,7 @@ static void process_timeout(unsigned long __data)
79310 *
79311 * In all cases the return value is guaranteed to be non-negative.
79312 */
79313 -signed long __sched schedule_timeout(signed long timeout)
79314 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
79315 {
79316 struct timer_list timer;
79317 unsigned long expire;
79318 @@ -1772,7 +1772,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
79319 return NOTIFY_OK;
79320 }
79321
79322 -static struct notifier_block __cpuinitdata timers_nb = {
79323 +static struct notifier_block timers_nb = {
79324 .notifier_call = timer_cpu_notify,
79325 };
79326
79327 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
79328 index 5a0f781..1497f95 100644
79329 --- a/kernel/trace/blktrace.c
79330 +++ b/kernel/trace/blktrace.c
79331 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
79332 struct blk_trace *bt = filp->private_data;
79333 char buf[16];
79334
79335 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
79336 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
79337
79338 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
79339 }
79340 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
79341 return 1;
79342
79343 bt = buf->chan->private_data;
79344 - atomic_inc(&bt->dropped);
79345 + atomic_inc_unchecked(&bt->dropped);
79346 return 0;
79347 }
79348
79349 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
79350
79351 bt->dir = dir;
79352 bt->dev = dev;
79353 - atomic_set(&bt->dropped, 0);
79354 + atomic_set_unchecked(&bt->dropped, 0);
79355
79356 ret = -EIO;
79357 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
79358 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
79359 index 0a0e2a6..943495e 100644
79360 --- a/kernel/trace/ftrace.c
79361 +++ b/kernel/trace/ftrace.c
79362 @@ -1909,12 +1909,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
79363 if (unlikely(ftrace_disabled))
79364 return 0;
79365
79366 + ret = ftrace_arch_code_modify_prepare();
79367 + FTRACE_WARN_ON(ret);
79368 + if (ret)
79369 + return 0;
79370 +
79371 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
79372 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
79373 if (ret) {
79374 ftrace_bug(ret, ip);
79375 - return 0;
79376 }
79377 - return 1;
79378 + return ret ? 0 : 1;
79379 }
79380
79381 /*
79382 @@ -2986,7 +2991,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
79383
79384 int
79385 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
79386 - void *data)
79387 + void *data)
79388 {
79389 struct ftrace_func_probe *entry;
79390 struct ftrace_page *pg;
79391 @@ -3854,8 +3859,10 @@ static int ftrace_process_locs(struct module *mod,
79392 if (!count)
79393 return 0;
79394
79395 + pax_open_kernel();
79396 sort(start, count, sizeof(*start),
79397 ftrace_cmp_ips, ftrace_swap_ips);
79398 + pax_close_kernel();
79399
79400 start_pg = ftrace_allocate_pages(count);
79401 if (!start_pg)
79402 @@ -4574,8 +4581,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
79403 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
79404
79405 static int ftrace_graph_active;
79406 -static struct notifier_block ftrace_suspend_notifier;
79407 -
79408 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
79409 {
79410 return 0;
79411 @@ -4719,6 +4724,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
79412 return NOTIFY_DONE;
79413 }
79414
79415 +static struct notifier_block ftrace_suspend_notifier = {
79416 + .notifier_call = ftrace_suspend_notifier_call
79417 +};
79418 +
79419 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79420 trace_func_graph_ent_t entryfunc)
79421 {
79422 @@ -4732,7 +4741,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79423 goto out;
79424 }
79425
79426 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
79427 register_pm_notifier(&ftrace_suspend_notifier);
79428
79429 ftrace_graph_active++;
79430 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
79431 index 6989df2..c2265cf 100644
79432 --- a/kernel/trace/ring_buffer.c
79433 +++ b/kernel/trace/ring_buffer.c
79434 @@ -349,9 +349,9 @@ struct buffer_data_page {
79435 */
79436 struct buffer_page {
79437 struct list_head list; /* list of buffer pages */
79438 - local_t write; /* index for next write */
79439 + local_unchecked_t write; /* index for next write */
79440 unsigned read; /* index for next read */
79441 - local_t entries; /* entries on this page */
79442 + local_unchecked_t entries; /* entries on this page */
79443 unsigned long real_end; /* real end of data */
79444 struct buffer_data_page *page; /* Actual data page */
79445 };
79446 @@ -464,8 +464,8 @@ struct ring_buffer_per_cpu {
79447 unsigned long last_overrun;
79448 local_t entries_bytes;
79449 local_t entries;
79450 - local_t overrun;
79451 - local_t commit_overrun;
79452 + local_unchecked_t overrun;
79453 + local_unchecked_t commit_overrun;
79454 local_t dropped_events;
79455 local_t committing;
79456 local_t commits;
79457 @@ -864,8 +864,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79458 *
79459 * We add a counter to the write field to denote this.
79460 */
79461 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
79462 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
79463 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
79464 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
79465
79466 /*
79467 * Just make sure we have seen our old_write and synchronize
79468 @@ -893,8 +893,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79469 * cmpxchg to only update if an interrupt did not already
79470 * do it for us. If the cmpxchg fails, we don't care.
79471 */
79472 - (void)local_cmpxchg(&next_page->write, old_write, val);
79473 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
79474 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
79475 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
79476
79477 /*
79478 * No need to worry about races with clearing out the commit.
79479 @@ -1253,12 +1253,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
79480
79481 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
79482 {
79483 - return local_read(&bpage->entries) & RB_WRITE_MASK;
79484 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
79485 }
79486
79487 static inline unsigned long rb_page_write(struct buffer_page *bpage)
79488 {
79489 - return local_read(&bpage->write) & RB_WRITE_MASK;
79490 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
79491 }
79492
79493 static int
79494 @@ -1353,7 +1353,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
79495 * bytes consumed in ring buffer from here.
79496 * Increment overrun to account for the lost events.
79497 */
79498 - local_add(page_entries, &cpu_buffer->overrun);
79499 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
79500 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79501 }
79502
79503 @@ -1909,7 +1909,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
79504 * it is our responsibility to update
79505 * the counters.
79506 */
79507 - local_add(entries, &cpu_buffer->overrun);
79508 + local_add_unchecked(entries, &cpu_buffer->overrun);
79509 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79510
79511 /*
79512 @@ -2059,7 +2059,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79513 if (tail == BUF_PAGE_SIZE)
79514 tail_page->real_end = 0;
79515
79516 - local_sub(length, &tail_page->write);
79517 + local_sub_unchecked(length, &tail_page->write);
79518 return;
79519 }
79520
79521 @@ -2094,7 +2094,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79522 rb_event_set_padding(event);
79523
79524 /* Set the write back to the previous setting */
79525 - local_sub(length, &tail_page->write);
79526 + local_sub_unchecked(length, &tail_page->write);
79527 return;
79528 }
79529
79530 @@ -2106,7 +2106,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79531
79532 /* Set write to end of buffer */
79533 length = (tail + length) - BUF_PAGE_SIZE;
79534 - local_sub(length, &tail_page->write);
79535 + local_sub_unchecked(length, &tail_page->write);
79536 }
79537
79538 /*
79539 @@ -2132,7 +2132,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79540 * about it.
79541 */
79542 if (unlikely(next_page == commit_page)) {
79543 - local_inc(&cpu_buffer->commit_overrun);
79544 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79545 goto out_reset;
79546 }
79547
79548 @@ -2188,7 +2188,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79549 cpu_buffer->tail_page) &&
79550 (cpu_buffer->commit_page ==
79551 cpu_buffer->reader_page))) {
79552 - local_inc(&cpu_buffer->commit_overrun);
79553 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79554 goto out_reset;
79555 }
79556 }
79557 @@ -2236,7 +2236,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79558 length += RB_LEN_TIME_EXTEND;
79559
79560 tail_page = cpu_buffer->tail_page;
79561 - write = local_add_return(length, &tail_page->write);
79562 + write = local_add_return_unchecked(length, &tail_page->write);
79563
79564 /* set write to only the index of the write */
79565 write &= RB_WRITE_MASK;
79566 @@ -2253,7 +2253,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79567 kmemcheck_annotate_bitfield(event, bitfield);
79568 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
79569
79570 - local_inc(&tail_page->entries);
79571 + local_inc_unchecked(&tail_page->entries);
79572
79573 /*
79574 * If this is the first commit on the page, then update
79575 @@ -2286,7 +2286,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79576
79577 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
79578 unsigned long write_mask =
79579 - local_read(&bpage->write) & ~RB_WRITE_MASK;
79580 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
79581 unsigned long event_length = rb_event_length(event);
79582 /*
79583 * This is on the tail page. It is possible that
79584 @@ -2296,7 +2296,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79585 */
79586 old_index += write_mask;
79587 new_index += write_mask;
79588 - index = local_cmpxchg(&bpage->write, old_index, new_index);
79589 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
79590 if (index == old_index) {
79591 /* update counters */
79592 local_sub(event_length, &cpu_buffer->entries_bytes);
79593 @@ -2670,7 +2670,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79594
79595 /* Do the likely case first */
79596 if (likely(bpage->page == (void *)addr)) {
79597 - local_dec(&bpage->entries);
79598 + local_dec_unchecked(&bpage->entries);
79599 return;
79600 }
79601
79602 @@ -2682,7 +2682,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79603 start = bpage;
79604 do {
79605 if (bpage->page == (void *)addr) {
79606 - local_dec(&bpage->entries);
79607 + local_dec_unchecked(&bpage->entries);
79608 return;
79609 }
79610 rb_inc_page(cpu_buffer, &bpage);
79611 @@ -2964,7 +2964,7 @@ static inline unsigned long
79612 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
79613 {
79614 return local_read(&cpu_buffer->entries) -
79615 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
79616 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
79617 }
79618
79619 /**
79620 @@ -3053,7 +3053,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
79621 return 0;
79622
79623 cpu_buffer = buffer->buffers[cpu];
79624 - ret = local_read(&cpu_buffer->overrun);
79625 + ret = local_read_unchecked(&cpu_buffer->overrun);
79626
79627 return ret;
79628 }
79629 @@ -3076,7 +3076,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
79630 return 0;
79631
79632 cpu_buffer = buffer->buffers[cpu];
79633 - ret = local_read(&cpu_buffer->commit_overrun);
79634 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
79635
79636 return ret;
79637 }
79638 @@ -3161,7 +3161,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
79639 /* if you care about this being correct, lock the buffer */
79640 for_each_buffer_cpu(buffer, cpu) {
79641 cpu_buffer = buffer->buffers[cpu];
79642 - overruns += local_read(&cpu_buffer->overrun);
79643 + overruns += local_read_unchecked(&cpu_buffer->overrun);
79644 }
79645
79646 return overruns;
79647 @@ -3337,8 +3337,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79648 /*
79649 * Reset the reader page to size zero.
79650 */
79651 - local_set(&cpu_buffer->reader_page->write, 0);
79652 - local_set(&cpu_buffer->reader_page->entries, 0);
79653 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79654 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79655 local_set(&cpu_buffer->reader_page->page->commit, 0);
79656 cpu_buffer->reader_page->real_end = 0;
79657
79658 @@ -3372,7 +3372,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79659 * want to compare with the last_overrun.
79660 */
79661 smp_mb();
79662 - overwrite = local_read(&(cpu_buffer->overrun));
79663 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
79664
79665 /*
79666 * Here's the tricky part.
79667 @@ -3942,8 +3942,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79668
79669 cpu_buffer->head_page
79670 = list_entry(cpu_buffer->pages, struct buffer_page, list);
79671 - local_set(&cpu_buffer->head_page->write, 0);
79672 - local_set(&cpu_buffer->head_page->entries, 0);
79673 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
79674 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
79675 local_set(&cpu_buffer->head_page->page->commit, 0);
79676
79677 cpu_buffer->head_page->read = 0;
79678 @@ -3953,14 +3953,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79679
79680 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
79681 INIT_LIST_HEAD(&cpu_buffer->new_pages);
79682 - local_set(&cpu_buffer->reader_page->write, 0);
79683 - local_set(&cpu_buffer->reader_page->entries, 0);
79684 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79685 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79686 local_set(&cpu_buffer->reader_page->page->commit, 0);
79687 cpu_buffer->reader_page->read = 0;
79688
79689 local_set(&cpu_buffer->entries_bytes, 0);
79690 - local_set(&cpu_buffer->overrun, 0);
79691 - local_set(&cpu_buffer->commit_overrun, 0);
79692 + local_set_unchecked(&cpu_buffer->overrun, 0);
79693 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
79694 local_set(&cpu_buffer->dropped_events, 0);
79695 local_set(&cpu_buffer->entries, 0);
79696 local_set(&cpu_buffer->committing, 0);
79697 @@ -4364,8 +4364,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
79698 rb_init_page(bpage);
79699 bpage = reader->page;
79700 reader->page = *data_page;
79701 - local_set(&reader->write, 0);
79702 - local_set(&reader->entries, 0);
79703 + local_set_unchecked(&reader->write, 0);
79704 + local_set_unchecked(&reader->entries, 0);
79705 reader->read = 0;
79706 *data_page = bpage;
79707
79708 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
79709 index 3f28192..a29e8b0 100644
79710 --- a/kernel/trace/trace.c
79711 +++ b/kernel/trace/trace.c
79712 @@ -2893,7 +2893,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
79713 return 0;
79714 }
79715
79716 -int set_tracer_flag(unsigned int mask, int enabled)
79717 +int set_tracer_flag(unsigned long mask, int enabled)
79718 {
79719 /* do nothing if flag is already set */
79720 if (!!(trace_flags & mask) == !!enabled)
79721 @@ -4637,10 +4637,9 @@ static const struct file_operations tracing_dyn_info_fops = {
79722 };
79723 #endif
79724
79725 -static struct dentry *d_tracer;
79726 -
79727 struct dentry *tracing_init_dentry(void)
79728 {
79729 + static struct dentry *d_tracer;
79730 static int once;
79731
79732 if (d_tracer)
79733 @@ -4660,10 +4659,9 @@ struct dentry *tracing_init_dentry(void)
79734 return d_tracer;
79735 }
79736
79737 -static struct dentry *d_percpu;
79738 -
79739 static struct dentry *tracing_dentry_percpu(void)
79740 {
79741 + static struct dentry *d_percpu;
79742 static int once;
79743 struct dentry *d_tracer;
79744
79745 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
79746 index 2081971..09f861e 100644
79747 --- a/kernel/trace/trace.h
79748 +++ b/kernel/trace/trace.h
79749 @@ -948,7 +948,7 @@ extern const char *__stop___trace_bprintk_fmt[];
79750 void trace_printk_init_buffers(void);
79751 void trace_printk_start_comm(void);
79752 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
79753 -int set_tracer_flag(unsigned int mask, int enabled);
79754 +int set_tracer_flag(unsigned long mask, int enabled);
79755
79756 #undef FTRACE_ENTRY
79757 #define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter) \
79758 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
79759 index 57e9b28..eebe41c 100644
79760 --- a/kernel/trace/trace_events.c
79761 +++ b/kernel/trace/trace_events.c
79762 @@ -1329,10 +1329,6 @@ static LIST_HEAD(ftrace_module_file_list);
79763 struct ftrace_module_file_ops {
79764 struct list_head list;
79765 struct module *mod;
79766 - struct file_operations id;
79767 - struct file_operations enable;
79768 - struct file_operations format;
79769 - struct file_operations filter;
79770 };
79771
79772 static struct ftrace_module_file_ops *
79773 @@ -1353,17 +1349,12 @@ trace_create_file_ops(struct module *mod)
79774
79775 file_ops->mod = mod;
79776
79777 - file_ops->id = ftrace_event_id_fops;
79778 - file_ops->id.owner = mod;
79779 -
79780 - file_ops->enable = ftrace_enable_fops;
79781 - file_ops->enable.owner = mod;
79782 -
79783 - file_ops->filter = ftrace_event_filter_fops;
79784 - file_ops->filter.owner = mod;
79785 -
79786 - file_ops->format = ftrace_event_format_fops;
79787 - file_ops->format.owner = mod;
79788 + pax_open_kernel();
79789 + mod->trace_id.owner = mod;
79790 + mod->trace_enable.owner = mod;
79791 + mod->trace_filter.owner = mod;
79792 + mod->trace_format.owner = mod;
79793 + pax_close_kernel();
79794
79795 list_add(&file_ops->list, &ftrace_module_file_list);
79796
79797 @@ -1387,8 +1378,8 @@ static void trace_module_add_events(struct module *mod)
79798
79799 for_each_event(call, start, end) {
79800 __trace_add_event_call(*call, mod,
79801 - &file_ops->id, &file_ops->enable,
79802 - &file_ops->filter, &file_ops->format);
79803 + &mod->trace_id, &mod->trace_enable,
79804 + &mod->trace_filter, &mod->trace_format);
79805 }
79806 }
79807
79808 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
79809 index fd3c8aa..5f324a6 100644
79810 --- a/kernel/trace/trace_mmiotrace.c
79811 +++ b/kernel/trace/trace_mmiotrace.c
79812 @@ -24,7 +24,7 @@ struct header_iter {
79813 static struct trace_array *mmio_trace_array;
79814 static bool overrun_detected;
79815 static unsigned long prev_overruns;
79816 -static atomic_t dropped_count;
79817 +static atomic_unchecked_t dropped_count;
79818
79819 static void mmio_reset_data(struct trace_array *tr)
79820 {
79821 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
79822
79823 static unsigned long count_overruns(struct trace_iterator *iter)
79824 {
79825 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
79826 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
79827 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
79828
79829 if (over > prev_overruns)
79830 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
79831 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
79832 sizeof(*entry), 0, pc);
79833 if (!event) {
79834 - atomic_inc(&dropped_count);
79835 + atomic_inc_unchecked(&dropped_count);
79836 return;
79837 }
79838 entry = ring_buffer_event_data(event);
79839 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
79840 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
79841 sizeof(*entry), 0, pc);
79842 if (!event) {
79843 - atomic_inc(&dropped_count);
79844 + atomic_inc_unchecked(&dropped_count);
79845 return;
79846 }
79847 entry = ring_buffer_event_data(event);
79848 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
79849 index 697e88d..1a79993 100644
79850 --- a/kernel/trace/trace_output.c
79851 +++ b/kernel/trace/trace_output.c
79852 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
79853
79854 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
79855 if (!IS_ERR(p)) {
79856 - p = mangle_path(s->buffer + s->len, p, "\n");
79857 + p = mangle_path(s->buffer + s->len, p, "\n\\");
79858 if (p) {
79859 s->len = p - s->buffer;
79860 return 1;
79861 @@ -851,14 +851,16 @@ int register_ftrace_event(struct trace_event *event)
79862 goto out;
79863 }
79864
79865 + pax_open_kernel();
79866 if (event->funcs->trace == NULL)
79867 - event->funcs->trace = trace_nop_print;
79868 + *(void **)&event->funcs->trace = trace_nop_print;
79869 if (event->funcs->raw == NULL)
79870 - event->funcs->raw = trace_nop_print;
79871 + *(void **)&event->funcs->raw = trace_nop_print;
79872 if (event->funcs->hex == NULL)
79873 - event->funcs->hex = trace_nop_print;
79874 + *(void **)&event->funcs->hex = trace_nop_print;
79875 if (event->funcs->binary == NULL)
79876 - event->funcs->binary = trace_nop_print;
79877 + *(void **)&event->funcs->binary = trace_nop_print;
79878 + pax_close_kernel();
79879
79880 key = event->type & (EVENT_HASHSIZE - 1);
79881
79882 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
79883 index b20428c..4845a10 100644
79884 --- a/kernel/trace/trace_stack.c
79885 +++ b/kernel/trace/trace_stack.c
79886 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
79887 return;
79888
79889 /* we do not handle interrupt stacks yet */
79890 - if (!object_is_on_stack(stack))
79891 + if (!object_starts_on_stack(stack))
79892 return;
79893
79894 local_irq_save(flags);
79895 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
79896 index e134d8f..a018cdd 100644
79897 --- a/kernel/user_namespace.c
79898 +++ b/kernel/user_namespace.c
79899 @@ -853,7 +853,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
79900 if (atomic_read(&current->mm->mm_users) > 1)
79901 return -EINVAL;
79902
79903 - if (current->fs->users != 1)
79904 + if (atomic_read(&current->fs->users) != 1)
79905 return -EINVAL;
79906
79907 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
79908 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
79909 index 4f69f9a..7c6f8f8 100644
79910 --- a/kernel/utsname_sysctl.c
79911 +++ b/kernel/utsname_sysctl.c
79912 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
79913 static int proc_do_uts_string(ctl_table *table, int write,
79914 void __user *buffer, size_t *lenp, loff_t *ppos)
79915 {
79916 - struct ctl_table uts_table;
79917 + ctl_table_no_const uts_table;
79918 int r;
79919 memcpy(&uts_table, table, sizeof(uts_table));
79920 uts_table.data = get_uts(table, write);
79921 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
79922 index 4a94467..80a6f9c 100644
79923 --- a/kernel/watchdog.c
79924 +++ b/kernel/watchdog.c
79925 @@ -526,7 +526,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
79926 }
79927 #endif /* CONFIG_SYSCTL */
79928
79929 -static struct smp_hotplug_thread watchdog_threads = {
79930 +static struct smp_hotplug_thread watchdog_threads __read_only = {
79931 .store = &softlockup_watchdog,
79932 .thread_should_run = watchdog_should_run,
79933 .thread_fn = watchdog,
79934 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
79935 index 28be08c..47bab92 100644
79936 --- a/lib/Kconfig.debug
79937 +++ b/lib/Kconfig.debug
79938 @@ -549,7 +549,7 @@ config DEBUG_MUTEXES
79939
79940 config DEBUG_LOCK_ALLOC
79941 bool "Lock debugging: detect incorrect freeing of live locks"
79942 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79943 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79944 select DEBUG_SPINLOCK
79945 select DEBUG_MUTEXES
79946 select LOCKDEP
79947 @@ -563,7 +563,7 @@ config DEBUG_LOCK_ALLOC
79948
79949 config PROVE_LOCKING
79950 bool "Lock debugging: prove locking correctness"
79951 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79952 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79953 select LOCKDEP
79954 select DEBUG_SPINLOCK
79955 select DEBUG_MUTEXES
79956 @@ -614,7 +614,7 @@ config LOCKDEP
79957
79958 config LOCK_STAT
79959 bool "Lock usage statistics"
79960 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79961 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79962 select LOCKDEP
79963 select DEBUG_SPINLOCK
79964 select DEBUG_MUTEXES
79965 @@ -1282,6 +1282,7 @@ config LATENCYTOP
79966 depends on DEBUG_KERNEL
79967 depends on STACKTRACE_SUPPORT
79968 depends on PROC_FS
79969 + depends on !GRKERNSEC_HIDESYM
79970 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
79971 select KALLSYMS
79972 select KALLSYMS_ALL
79973 @@ -1310,7 +1311,7 @@ config INTERVAL_TREE_TEST
79974
79975 config PROVIDE_OHCI1394_DMA_INIT
79976 bool "Remote debugging over FireWire early on boot"
79977 - depends on PCI && X86
79978 + depends on PCI && X86 && !GRKERNSEC
79979 help
79980 If you want to debug problems which hang or crash the kernel early
79981 on boot and the crashing machine has a FireWire port, you can use
79982 @@ -1339,7 +1340,7 @@ config PROVIDE_OHCI1394_DMA_INIT
79983
79984 config FIREWIRE_OHCI_REMOTE_DMA
79985 bool "Remote debugging over FireWire with firewire-ohci"
79986 - depends on FIREWIRE_OHCI
79987 + depends on FIREWIRE_OHCI && !GRKERNSEC
79988 help
79989 This option lets you use the FireWire bus for remote debugging
79990 with help of the firewire-ohci driver. It enables unfiltered
79991 diff --git a/lib/Makefile b/lib/Makefile
79992 index 6e2cc56..9b13738 100644
79993 --- a/lib/Makefile
79994 +++ b/lib/Makefile
79995 @@ -47,7 +47,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
79996
79997 obj-$(CONFIG_BTREE) += btree.o
79998 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
79999 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
80000 +obj-y += list_debug.o
80001 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
80002
80003 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
80004 diff --git a/lib/bitmap.c b/lib/bitmap.c
80005 index 06f7e4f..f3cf2b0 100644
80006 --- a/lib/bitmap.c
80007 +++ b/lib/bitmap.c
80008 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
80009 {
80010 int c, old_c, totaldigits, ndigits, nchunks, nbits;
80011 u32 chunk;
80012 - const char __user __force *ubuf = (const char __user __force *)buf;
80013 + const char __user *ubuf = (const char __force_user *)buf;
80014
80015 bitmap_zero(maskp, nmaskbits);
80016
80017 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
80018 {
80019 if (!access_ok(VERIFY_READ, ubuf, ulen))
80020 return -EFAULT;
80021 - return __bitmap_parse((const char __force *)ubuf,
80022 + return __bitmap_parse((const char __force_kernel *)ubuf,
80023 ulen, 1, maskp, nmaskbits);
80024
80025 }
80026 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
80027 {
80028 unsigned a, b;
80029 int c, old_c, totaldigits;
80030 - const char __user __force *ubuf = (const char __user __force *)buf;
80031 + const char __user *ubuf = (const char __force_user *)buf;
80032 int exp_digit, in_range;
80033
80034 totaldigits = c = 0;
80035 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
80036 {
80037 if (!access_ok(VERIFY_READ, ubuf, ulen))
80038 return -EFAULT;
80039 - return __bitmap_parselist((const char __force *)ubuf,
80040 + return __bitmap_parselist((const char __force_kernel *)ubuf,
80041 ulen, 1, maskp, nmaskbits);
80042 }
80043 EXPORT_SYMBOL(bitmap_parselist_user);
80044 diff --git a/lib/bug.c b/lib/bug.c
80045 index 1686034..a9c00c8 100644
80046 --- a/lib/bug.c
80047 +++ b/lib/bug.c
80048 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
80049 return BUG_TRAP_TYPE_NONE;
80050
80051 bug = find_bug(bugaddr);
80052 + if (!bug)
80053 + return BUG_TRAP_TYPE_NONE;
80054
80055 file = NULL;
80056 line = 0;
80057 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
80058 index 37061ed..da83f48 100644
80059 --- a/lib/debugobjects.c
80060 +++ b/lib/debugobjects.c
80061 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
80062 if (limit > 4)
80063 return;
80064
80065 - is_on_stack = object_is_on_stack(addr);
80066 + is_on_stack = object_starts_on_stack(addr);
80067 if (is_on_stack == onstack)
80068 return;
80069
80070 diff --git a/lib/devres.c b/lib/devres.c
80071 index 8235331..5881053 100644
80072 --- a/lib/devres.c
80073 +++ b/lib/devres.c
80074 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
80075 void devm_iounmap(struct device *dev, void __iomem *addr)
80076 {
80077 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
80078 - (void *)addr));
80079 + (void __force *)addr));
80080 iounmap(addr);
80081 }
80082 EXPORT_SYMBOL(devm_iounmap);
80083 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
80084 {
80085 ioport_unmap(addr);
80086 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
80087 - devm_ioport_map_match, (void *)addr));
80088 + devm_ioport_map_match, (void __force *)addr));
80089 }
80090 EXPORT_SYMBOL(devm_ioport_unmap);
80091 #endif /* CONFIG_HAS_IOPORT */
80092 diff --git a/lib/div64.c b/lib/div64.c
80093 index a163b6c..9618fa5 100644
80094 --- a/lib/div64.c
80095 +++ b/lib/div64.c
80096 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
80097 EXPORT_SYMBOL(__div64_32);
80098
80099 #ifndef div_s64_rem
80100 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80101 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80102 {
80103 u64 quotient;
80104
80105 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
80106 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
80107 */
80108 #ifndef div64_u64
80109 -u64 div64_u64(u64 dividend, u64 divisor)
80110 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
80111 {
80112 u32 high = divisor >> 32;
80113 u64 quot;
80114 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
80115 index d87a17a..ac0d79a 100644
80116 --- a/lib/dma-debug.c
80117 +++ b/lib/dma-debug.c
80118 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
80119
80120 void dma_debug_add_bus(struct bus_type *bus)
80121 {
80122 - struct notifier_block *nb;
80123 + notifier_block_no_const *nb;
80124
80125 if (global_disable)
80126 return;
80127 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
80128
80129 static void check_for_stack(struct device *dev, void *addr)
80130 {
80131 - if (object_is_on_stack(addr))
80132 + if (object_starts_on_stack(addr))
80133 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
80134 "stack [addr=%p]\n", addr);
80135 }
80136 diff --git a/lib/inflate.c b/lib/inflate.c
80137 index 013a761..c28f3fc 100644
80138 --- a/lib/inflate.c
80139 +++ b/lib/inflate.c
80140 @@ -269,7 +269,7 @@ static void free(void *where)
80141 malloc_ptr = free_mem_ptr;
80142 }
80143 #else
80144 -#define malloc(a) kmalloc(a, GFP_KERNEL)
80145 +#define malloc(a) kmalloc((a), GFP_KERNEL)
80146 #define free(a) kfree(a)
80147 #endif
80148
80149 diff --git a/lib/ioremap.c b/lib/ioremap.c
80150 index 0c9216c..863bd89 100644
80151 --- a/lib/ioremap.c
80152 +++ b/lib/ioremap.c
80153 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
80154 unsigned long next;
80155
80156 phys_addr -= addr;
80157 - pmd = pmd_alloc(&init_mm, pud, addr);
80158 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
80159 if (!pmd)
80160 return -ENOMEM;
80161 do {
80162 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
80163 unsigned long next;
80164
80165 phys_addr -= addr;
80166 - pud = pud_alloc(&init_mm, pgd, addr);
80167 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
80168 if (!pud)
80169 return -ENOMEM;
80170 do {
80171 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
80172 index bd2bea9..6b3c95e 100644
80173 --- a/lib/is_single_threaded.c
80174 +++ b/lib/is_single_threaded.c
80175 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
80176 struct task_struct *p, *t;
80177 bool ret;
80178
80179 + if (!mm)
80180 + return true;
80181 +
80182 if (atomic_read(&task->signal->live) != 1)
80183 return false;
80184
80185 diff --git a/lib/kobject.c b/lib/kobject.c
80186 index a654866..a4fd13d 100644
80187 --- a/lib/kobject.c
80188 +++ b/lib/kobject.c
80189 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
80190
80191
80192 static DEFINE_SPINLOCK(kobj_ns_type_lock);
80193 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
80194 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
80195
80196 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80197 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80198 {
80199 enum kobj_ns_type type = ops->type;
80200 int error;
80201 diff --git a/lib/list_debug.c b/lib/list_debug.c
80202 index c24c2f7..06e070b 100644
80203 --- a/lib/list_debug.c
80204 +++ b/lib/list_debug.c
80205 @@ -11,7 +11,9 @@
80206 #include <linux/bug.h>
80207 #include <linux/kernel.h>
80208 #include <linux/rculist.h>
80209 +#include <linux/mm.h>
80210
80211 +#ifdef CONFIG_DEBUG_LIST
80212 /*
80213 * Insert a new entry between two known consecutive entries.
80214 *
80215 @@ -19,21 +21,32 @@
80216 * the prev/next entries already!
80217 */
80218
80219 -void __list_add(struct list_head *new,
80220 - struct list_head *prev,
80221 - struct list_head *next)
80222 +static bool __list_add_debug(struct list_head *new,
80223 + struct list_head *prev,
80224 + struct list_head *next)
80225 {
80226 - WARN(next->prev != prev,
80227 + if (WARN(next->prev != prev,
80228 "list_add corruption. next->prev should be "
80229 "prev (%p), but was %p. (next=%p).\n",
80230 - prev, next->prev, next);
80231 - WARN(prev->next != next,
80232 + prev, next->prev, next) ||
80233 + WARN(prev->next != next,
80234 "list_add corruption. prev->next should be "
80235 "next (%p), but was %p. (prev=%p).\n",
80236 - next, prev->next, prev);
80237 - WARN(new == prev || new == next,
80238 - "list_add double add: new=%p, prev=%p, next=%p.\n",
80239 - new, prev, next);
80240 + next, prev->next, prev) ||
80241 + WARN(new == prev || new == next,
80242 + "list_add double add: new=%p, prev=%p, next=%p.\n",
80243 + new, prev, next))
80244 + return false;
80245 + return true;
80246 +}
80247 +
80248 +void __list_add(struct list_head *new,
80249 + struct list_head *prev,
80250 + struct list_head *next)
80251 +{
80252 + if (!__list_add_debug(new, prev, next))
80253 + return;
80254 +
80255 next->prev = new;
80256 new->next = next;
80257 new->prev = prev;
80258 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
80259 }
80260 EXPORT_SYMBOL(__list_add);
80261
80262 -void __list_del_entry(struct list_head *entry)
80263 +static bool __list_del_entry_debug(struct list_head *entry)
80264 {
80265 struct list_head *prev, *next;
80266
80267 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
80268 WARN(next->prev != entry,
80269 "list_del corruption. next->prev should be %p, "
80270 "but was %p\n", entry, next->prev))
80271 + return false;
80272 + return true;
80273 +}
80274 +
80275 +void __list_del_entry(struct list_head *entry)
80276 +{
80277 + if (!__list_del_entry_debug(entry))
80278 return;
80279
80280 - __list_del(prev, next);
80281 + __list_del(entry->prev, entry->next);
80282 }
80283 EXPORT_SYMBOL(__list_del_entry);
80284
80285 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
80286 void __list_add_rcu(struct list_head *new,
80287 struct list_head *prev, struct list_head *next)
80288 {
80289 - WARN(next->prev != prev,
80290 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
80291 - prev, next->prev, next);
80292 - WARN(prev->next != next,
80293 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
80294 - next, prev->next, prev);
80295 + if (!__list_add_debug(new, prev, next))
80296 + return;
80297 +
80298 new->next = next;
80299 new->prev = prev;
80300 rcu_assign_pointer(list_next_rcu(prev), new);
80301 next->prev = new;
80302 }
80303 EXPORT_SYMBOL(__list_add_rcu);
80304 +#endif
80305 +
80306 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
80307 +{
80308 +#ifdef CONFIG_DEBUG_LIST
80309 + if (!__list_add_debug(new, prev, next))
80310 + return;
80311 +#endif
80312 +
80313 + pax_open_kernel();
80314 + next->prev = new;
80315 + new->next = next;
80316 + new->prev = prev;
80317 + prev->next = new;
80318 + pax_close_kernel();
80319 +}
80320 +EXPORT_SYMBOL(__pax_list_add);
80321 +
80322 +void pax_list_del(struct list_head *entry)
80323 +{
80324 +#ifdef CONFIG_DEBUG_LIST
80325 + if (!__list_del_entry_debug(entry))
80326 + return;
80327 +#endif
80328 +
80329 + pax_open_kernel();
80330 + __list_del(entry->prev, entry->next);
80331 + entry->next = LIST_POISON1;
80332 + entry->prev = LIST_POISON2;
80333 + pax_close_kernel();
80334 +}
80335 +EXPORT_SYMBOL(pax_list_del);
80336 +
80337 +void pax_list_del_init(struct list_head *entry)
80338 +{
80339 + pax_open_kernel();
80340 + __list_del(entry->prev, entry->next);
80341 + INIT_LIST_HEAD(entry);
80342 + pax_close_kernel();
80343 +}
80344 +EXPORT_SYMBOL(pax_list_del_init);
80345 +
80346 +void __pax_list_add_rcu(struct list_head *new,
80347 + struct list_head *prev, struct list_head *next)
80348 +{
80349 +#ifdef CONFIG_DEBUG_LIST
80350 + if (!__list_add_debug(new, prev, next))
80351 + return;
80352 +#endif
80353 +
80354 + pax_open_kernel();
80355 + new->next = next;
80356 + new->prev = prev;
80357 + rcu_assign_pointer(list_next_rcu(prev), new);
80358 + next->prev = new;
80359 + pax_close_kernel();
80360 +}
80361 +EXPORT_SYMBOL(__pax_list_add_rcu);
80362 +
80363 +void pax_list_del_rcu(struct list_head *entry)
80364 +{
80365 +#ifdef CONFIG_DEBUG_LIST
80366 + if (!__list_del_entry_debug(entry))
80367 + return;
80368 +#endif
80369 +
80370 + pax_open_kernel();
80371 + __list_del(entry->prev, entry->next);
80372 + entry->next = LIST_POISON1;
80373 + entry->prev = LIST_POISON2;
80374 + pax_close_kernel();
80375 +}
80376 +EXPORT_SYMBOL(pax_list_del_rcu);
80377 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
80378 index e796429..6e38f9f 100644
80379 --- a/lib/radix-tree.c
80380 +++ b/lib/radix-tree.c
80381 @@ -92,7 +92,7 @@ struct radix_tree_preload {
80382 int nr;
80383 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
80384 };
80385 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
80386 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
80387
80388 static inline void *ptr_to_indirect(void *ptr)
80389 {
80390 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
80391 index bb2b201..46abaf9 100644
80392 --- a/lib/strncpy_from_user.c
80393 +++ b/lib/strncpy_from_user.c
80394 @@ -21,7 +21,7 @@
80395 */
80396 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
80397 {
80398 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80399 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80400 long res = 0;
80401
80402 /*
80403 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
80404 index a28df52..3d55877 100644
80405 --- a/lib/strnlen_user.c
80406 +++ b/lib/strnlen_user.c
80407 @@ -26,7 +26,7 @@
80408 */
80409 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
80410 {
80411 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80412 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80413 long align, res = 0;
80414 unsigned long c;
80415
80416 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
80417 index d23762e..e21eab2 100644
80418 --- a/lib/swiotlb.c
80419 +++ b/lib/swiotlb.c
80420 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
80421
80422 void
80423 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
80424 - dma_addr_t dev_addr)
80425 + dma_addr_t dev_addr, struct dma_attrs *attrs)
80426 {
80427 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
80428
80429 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
80430 index 0d62fd7..b7bc911 100644
80431 --- a/lib/vsprintf.c
80432 +++ b/lib/vsprintf.c
80433 @@ -16,6 +16,9 @@
80434 * - scnprintf and vscnprintf
80435 */
80436
80437 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80438 +#define __INCLUDED_BY_HIDESYM 1
80439 +#endif
80440 #include <stdarg.h>
80441 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
80442 #include <linux/types.h>
80443 @@ -974,7 +977,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
80444 return number(buf, end, *(const netdev_features_t *)addr, spec);
80445 }
80446
80447 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80448 +int kptr_restrict __read_mostly = 2;
80449 +#else
80450 int kptr_restrict __read_mostly;
80451 +#endif
80452
80453 /*
80454 * Show a '%p' thing. A kernel extension is that the '%p' is followed
80455 @@ -988,6 +995,8 @@ int kptr_restrict __read_mostly;
80456 * - 'S' For symbolic direct pointers with offset
80457 * - 's' For symbolic direct pointers without offset
80458 * - 'B' For backtraced symbolic direct pointers with offset
80459 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
80460 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
80461 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
80462 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
80463 * - 'M' For a 6-byte MAC address, it prints the address in the
80464 @@ -1044,12 +1053,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80465
80466 if (!ptr && *fmt != 'K') {
80467 /*
80468 - * Print (null) with the same width as a pointer so it makes
80469 + * Print (nil) with the same width as a pointer so it makes
80470 * tabular output look nice.
80471 */
80472 if (spec.field_width == -1)
80473 spec.field_width = default_width;
80474 - return string(buf, end, "(null)", spec);
80475 + return string(buf, end, "(nil)", spec);
80476 }
80477
80478 switch (*fmt) {
80479 @@ -1059,6 +1068,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80480 /* Fallthrough */
80481 case 'S':
80482 case 's':
80483 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80484 + break;
80485 +#else
80486 + return symbol_string(buf, end, ptr, spec, *fmt);
80487 +#endif
80488 + case 'A':
80489 case 'B':
80490 return symbol_string(buf, end, ptr, spec, *fmt);
80491 case 'R':
80492 @@ -1099,6 +1114,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80493 va_end(va);
80494 return buf;
80495 }
80496 + case 'P':
80497 + break;
80498 case 'K':
80499 /*
80500 * %pK cannot be used in IRQ context because its test
80501 @@ -1128,6 +1145,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80502 return number(buf, end,
80503 (unsigned long long) *((phys_addr_t *)ptr), spec);
80504 }
80505 +
80506 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80507 + /* 'P' = approved pointers to copy to userland,
80508 + as in the /proc/kallsyms case, as we make it display nothing
80509 + for non-root users, and the real contents for root users
80510 + Also ignore 'K' pointers, since we force their NULLing for non-root users
80511 + above
80512 + */
80513 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
80514 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
80515 + dump_stack();
80516 + ptr = NULL;
80517 + }
80518 +#endif
80519 +
80520 spec.flags |= SMALL;
80521 if (spec.field_width == -1) {
80522 spec.field_width = default_width;
80523 @@ -1849,11 +1881,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80524 typeof(type) value; \
80525 if (sizeof(type) == 8) { \
80526 args = PTR_ALIGN(args, sizeof(u32)); \
80527 - *(u32 *)&value = *(u32 *)args; \
80528 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
80529 + *(u32 *)&value = *(const u32 *)args; \
80530 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
80531 } else { \
80532 args = PTR_ALIGN(args, sizeof(type)); \
80533 - value = *(typeof(type) *)args; \
80534 + value = *(const typeof(type) *)args; \
80535 } \
80536 args += sizeof(type); \
80537 value; \
80538 @@ -1916,7 +1948,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80539 case FORMAT_TYPE_STR: {
80540 const char *str_arg = args;
80541 args += strlen(str_arg) + 1;
80542 - str = string(str, end, (char *)str_arg, spec);
80543 + str = string(str, end, str_arg, spec);
80544 break;
80545 }
80546
80547 diff --git a/localversion-grsec b/localversion-grsec
80548 new file mode 100644
80549 index 0000000..7cd6065
80550 --- /dev/null
80551 +++ b/localversion-grsec
80552 @@ -0,0 +1 @@
80553 +-grsec
80554 diff --git a/mm/Kconfig b/mm/Kconfig
80555 index 3bea74f..e821c99 100644
80556 --- a/mm/Kconfig
80557 +++ b/mm/Kconfig
80558 @@ -311,10 +311,10 @@ config KSM
80559 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
80560
80561 config DEFAULT_MMAP_MIN_ADDR
80562 - int "Low address space to protect from user allocation"
80563 + int "Low address space to protect from user allocation"
80564 depends on MMU
80565 - default 4096
80566 - help
80567 + default 65536
80568 + help
80569 This is the portion of low virtual memory which should be protected
80570 from userspace allocation. Keeping a user from writing to low pages
80571 can help reduce the impact of kernel NULL pointer bugs.
80572 @@ -345,7 +345,7 @@ config MEMORY_FAILURE
80573
80574 config HWPOISON_INJECT
80575 tristate "HWPoison pages injector"
80576 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
80577 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
80578 select PROC_PAGE_MONITOR
80579
80580 config NOMMU_INITIAL_TRIM_EXCESS
80581 diff --git a/mm/filemap.c b/mm/filemap.c
80582 index e1979fd..dda5120 100644
80583 --- a/mm/filemap.c
80584 +++ b/mm/filemap.c
80585 @@ -1748,7 +1748,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
80586 struct address_space *mapping = file->f_mapping;
80587
80588 if (!mapping->a_ops->readpage)
80589 - return -ENOEXEC;
80590 + return -ENODEV;
80591 file_accessed(file);
80592 vma->vm_ops = &generic_file_vm_ops;
80593 return 0;
80594 @@ -2088,6 +2088,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
80595 *pos = i_size_read(inode);
80596
80597 if (limit != RLIM_INFINITY) {
80598 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
80599 if (*pos >= limit) {
80600 send_sig(SIGXFSZ, current, 0);
80601 return -EFBIG;
80602 diff --git a/mm/fremap.c b/mm/fremap.c
80603 index 87da359..3f41cb1 100644
80604 --- a/mm/fremap.c
80605 +++ b/mm/fremap.c
80606 @@ -158,6 +158,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
80607 retry:
80608 vma = find_vma(mm, start);
80609
80610 +#ifdef CONFIG_PAX_SEGMEXEC
80611 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
80612 + goto out;
80613 +#endif
80614 +
80615 /*
80616 * Make sure the vma is shared, that it supports prefaulting,
80617 * and that the remapped range is valid and fully within
80618 diff --git a/mm/highmem.c b/mm/highmem.c
80619 index b32b70c..e512eb0 100644
80620 --- a/mm/highmem.c
80621 +++ b/mm/highmem.c
80622 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
80623 * So no dangers, even with speculative execution.
80624 */
80625 page = pte_page(pkmap_page_table[i]);
80626 + pax_open_kernel();
80627 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
80628 -
80629 + pax_close_kernel();
80630 set_page_address(page, NULL);
80631 need_flush = 1;
80632 }
80633 @@ -198,9 +199,11 @@ start:
80634 }
80635 }
80636 vaddr = PKMAP_ADDR(last_pkmap_nr);
80637 +
80638 + pax_open_kernel();
80639 set_pte_at(&init_mm, vaddr,
80640 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
80641 -
80642 + pax_close_kernel();
80643 pkmap_count[last_pkmap_nr] = 1;
80644 set_page_address(page, (void *)vaddr);
80645
80646 diff --git a/mm/huge_memory.c b/mm/huge_memory.c
80647 index e2f7f5aa..a4510d4 100644
80648 --- a/mm/huge_memory.c
80649 +++ b/mm/huge_memory.c
80650 @@ -2318,7 +2318,12 @@ static void collapse_huge_page(struct mm_struct *mm,
80651 pte_unmap(pte);
80652 spin_lock(&mm->page_table_lock);
80653 BUG_ON(!pmd_none(*pmd));
80654 - set_pmd_at(mm, address, pmd, _pmd);
80655 + /*
80656 + * We can only use set_pmd_at when establishing
80657 + * hugepmds and never for establishing regular pmds that
80658 + * points to regular pagetables. Use pmd_populate for that
80659 + */
80660 + pmd_populate(mm, pmd, pmd_pgtable(_pmd));
80661 spin_unlock(&mm->page_table_lock);
80662 anon_vma_unlock_write(vma->anon_vma);
80663 goto out;
80664 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
80665 index 1a12f5b..a85b8fc 100644
80666 --- a/mm/hugetlb.c
80667 +++ b/mm/hugetlb.c
80668 @@ -2005,15 +2005,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
80669 struct hstate *h = &default_hstate;
80670 unsigned long tmp;
80671 int ret;
80672 + ctl_table_no_const hugetlb_table;
80673
80674 tmp = h->max_huge_pages;
80675
80676 if (write && h->order >= MAX_ORDER)
80677 return -EINVAL;
80678
80679 - table->data = &tmp;
80680 - table->maxlen = sizeof(unsigned long);
80681 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80682 + hugetlb_table = *table;
80683 + hugetlb_table.data = &tmp;
80684 + hugetlb_table.maxlen = sizeof(unsigned long);
80685 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80686 if (ret)
80687 goto out;
80688
80689 @@ -2070,15 +2072,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
80690 struct hstate *h = &default_hstate;
80691 unsigned long tmp;
80692 int ret;
80693 + ctl_table_no_const hugetlb_table;
80694
80695 tmp = h->nr_overcommit_huge_pages;
80696
80697 if (write && h->order >= MAX_ORDER)
80698 return -EINVAL;
80699
80700 - table->data = &tmp;
80701 - table->maxlen = sizeof(unsigned long);
80702 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80703 + hugetlb_table = *table;
80704 + hugetlb_table.data = &tmp;
80705 + hugetlb_table.maxlen = sizeof(unsigned long);
80706 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80707 if (ret)
80708 goto out;
80709
80710 @@ -2512,6 +2516,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
80711 return 1;
80712 }
80713
80714 +#ifdef CONFIG_PAX_SEGMEXEC
80715 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
80716 +{
80717 + struct mm_struct *mm = vma->vm_mm;
80718 + struct vm_area_struct *vma_m;
80719 + unsigned long address_m;
80720 + pte_t *ptep_m;
80721 +
80722 + vma_m = pax_find_mirror_vma(vma);
80723 + if (!vma_m)
80724 + return;
80725 +
80726 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80727 + address_m = address + SEGMEXEC_TASK_SIZE;
80728 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
80729 + get_page(page_m);
80730 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
80731 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
80732 +}
80733 +#endif
80734 +
80735 /*
80736 * Hugetlb_cow() should be called with page lock of the original hugepage held.
80737 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
80738 @@ -2630,6 +2655,11 @@ retry_avoidcopy:
80739 make_huge_pte(vma, new_page, 1));
80740 page_remove_rmap(old_page);
80741 hugepage_add_new_anon_rmap(new_page, vma, address);
80742 +
80743 +#ifdef CONFIG_PAX_SEGMEXEC
80744 + pax_mirror_huge_pte(vma, address, new_page);
80745 +#endif
80746 +
80747 /* Make the old page be freed below */
80748 new_page = old_page;
80749 }
80750 @@ -2788,6 +2818,10 @@ retry:
80751 && (vma->vm_flags & VM_SHARED)));
80752 set_huge_pte_at(mm, address, ptep, new_pte);
80753
80754 +#ifdef CONFIG_PAX_SEGMEXEC
80755 + pax_mirror_huge_pte(vma, address, page);
80756 +#endif
80757 +
80758 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
80759 /* Optimization, do the COW without a second fault */
80760 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
80761 @@ -2817,6 +2851,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80762 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
80763 struct hstate *h = hstate_vma(vma);
80764
80765 +#ifdef CONFIG_PAX_SEGMEXEC
80766 + struct vm_area_struct *vma_m;
80767 +#endif
80768 +
80769 address &= huge_page_mask(h);
80770
80771 ptep = huge_pte_offset(mm, address);
80772 @@ -2830,6 +2868,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80773 VM_FAULT_SET_HINDEX(hstate_index(h));
80774 }
80775
80776 +#ifdef CONFIG_PAX_SEGMEXEC
80777 + vma_m = pax_find_mirror_vma(vma);
80778 + if (vma_m) {
80779 + unsigned long address_m;
80780 +
80781 + if (vma->vm_start > vma_m->vm_start) {
80782 + address_m = address;
80783 + address -= SEGMEXEC_TASK_SIZE;
80784 + vma = vma_m;
80785 + h = hstate_vma(vma);
80786 + } else
80787 + address_m = address + SEGMEXEC_TASK_SIZE;
80788 +
80789 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
80790 + return VM_FAULT_OOM;
80791 + address_m &= HPAGE_MASK;
80792 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
80793 + }
80794 +#endif
80795 +
80796 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
80797 if (!ptep)
80798 return VM_FAULT_OOM;
80799 diff --git a/mm/internal.h b/mm/internal.h
80800 index 8562de0..7fdfe92 100644
80801 --- a/mm/internal.h
80802 +++ b/mm/internal.h
80803 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
80804 * in mm/page_alloc.c
80805 */
80806 extern void __free_pages_bootmem(struct page *page, unsigned int order);
80807 +extern void free_compound_page(struct page *page);
80808 extern void prep_compound_page(struct page *page, unsigned long order);
80809 #ifdef CONFIG_MEMORY_FAILURE
80810 extern bool is_free_buddy_page(struct page *page);
80811 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
80812 index c8d7f31..2dbeffd 100644
80813 --- a/mm/kmemleak.c
80814 +++ b/mm/kmemleak.c
80815 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
80816
80817 for (i = 0; i < object->trace_len; i++) {
80818 void *ptr = (void *)object->trace[i];
80819 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
80820 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
80821 }
80822 }
80823
80824 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
80825 return -ENOMEM;
80826 }
80827
80828 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
80829 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
80830 &kmemleak_fops);
80831 if (!dentry)
80832 pr_warning("Failed to create the debugfs kmemleak file\n");
80833 diff --git a/mm/maccess.c b/mm/maccess.c
80834 index d53adf9..03a24bf 100644
80835 --- a/mm/maccess.c
80836 +++ b/mm/maccess.c
80837 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
80838 set_fs(KERNEL_DS);
80839 pagefault_disable();
80840 ret = __copy_from_user_inatomic(dst,
80841 - (__force const void __user *)src, size);
80842 + (const void __force_user *)src, size);
80843 pagefault_enable();
80844 set_fs(old_fs);
80845
80846 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
80847
80848 set_fs(KERNEL_DS);
80849 pagefault_disable();
80850 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
80851 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
80852 pagefault_enable();
80853 set_fs(old_fs);
80854
80855 diff --git a/mm/madvise.c b/mm/madvise.c
80856 index c58c94b..86ec14e 100644
80857 --- a/mm/madvise.c
80858 +++ b/mm/madvise.c
80859 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
80860 pgoff_t pgoff;
80861 unsigned long new_flags = vma->vm_flags;
80862
80863 +#ifdef CONFIG_PAX_SEGMEXEC
80864 + struct vm_area_struct *vma_m;
80865 +#endif
80866 +
80867 switch (behavior) {
80868 case MADV_NORMAL:
80869 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
80870 @@ -126,6 +130,13 @@ success:
80871 /*
80872 * vm_flags is protected by the mmap_sem held in write mode.
80873 */
80874 +
80875 +#ifdef CONFIG_PAX_SEGMEXEC
80876 + vma_m = pax_find_mirror_vma(vma);
80877 + if (vma_m)
80878 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
80879 +#endif
80880 +
80881 vma->vm_flags = new_flags;
80882
80883 out:
80884 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
80885 struct vm_area_struct ** prev,
80886 unsigned long start, unsigned long end)
80887 {
80888 +
80889 +#ifdef CONFIG_PAX_SEGMEXEC
80890 + struct vm_area_struct *vma_m;
80891 +#endif
80892 +
80893 *prev = vma;
80894 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
80895 return -EINVAL;
80896 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
80897 zap_page_range(vma, start, end - start, &details);
80898 } else
80899 zap_page_range(vma, start, end - start, NULL);
80900 +
80901 +#ifdef CONFIG_PAX_SEGMEXEC
80902 + vma_m = pax_find_mirror_vma(vma);
80903 + if (vma_m) {
80904 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
80905 + struct zap_details details = {
80906 + .nonlinear_vma = vma_m,
80907 + .last_index = ULONG_MAX,
80908 + };
80909 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
80910 + } else
80911 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
80912 + }
80913 +#endif
80914 +
80915 return 0;
80916 }
80917
80918 @@ -491,6 +522,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
80919 if (end < start)
80920 goto out;
80921
80922 +#ifdef CONFIG_PAX_SEGMEXEC
80923 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
80924 + if (end > SEGMEXEC_TASK_SIZE)
80925 + goto out;
80926 + } else
80927 +#endif
80928 +
80929 + if (end > TASK_SIZE)
80930 + goto out;
80931 +
80932 error = 0;
80933 if (end == start)
80934 goto out;
80935 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
80936 index df0694c..bc95539 100644
80937 --- a/mm/memory-failure.c
80938 +++ b/mm/memory-failure.c
80939 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
80940
80941 int sysctl_memory_failure_recovery __read_mostly = 1;
80942
80943 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
80944 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
80945
80946 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
80947
80948 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
80949 pfn, t->comm, t->pid);
80950 si.si_signo = SIGBUS;
80951 si.si_errno = 0;
80952 - si.si_addr = (void *)addr;
80953 + si.si_addr = (void __user *)addr;
80954 #ifdef __ARCH_SI_TRAPNO
80955 si.si_trapno = trapno;
80956 #endif
80957 @@ -760,7 +760,7 @@ static struct page_state {
80958 unsigned long res;
80959 char *msg;
80960 int (*action)(struct page *p, unsigned long pfn);
80961 -} error_states[] = {
80962 +} __do_const error_states[] = {
80963 { reserved, reserved, "reserved kernel", me_kernel },
80964 /*
80965 * free pages are specially detected outside this table:
80966 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80967 nr_pages = 1 << compound_order(hpage);
80968 else /* normal page or thp */
80969 nr_pages = 1;
80970 - atomic_long_add(nr_pages, &num_poisoned_pages);
80971 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
80972
80973 /*
80974 * We need/can do nothing about count=0 pages.
80975 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80976 if (!PageHWPoison(hpage)
80977 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
80978 || (p != hpage && TestSetPageHWPoison(hpage))) {
80979 - atomic_long_sub(nr_pages, &num_poisoned_pages);
80980 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
80981 return 0;
80982 }
80983 set_page_hwpoison_huge_page(hpage);
80984 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
80985 }
80986 if (hwpoison_filter(p)) {
80987 if (TestClearPageHWPoison(p))
80988 - atomic_long_sub(nr_pages, &num_poisoned_pages);
80989 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
80990 unlock_page(hpage);
80991 put_page(hpage);
80992 return 0;
80993 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
80994 return 0;
80995 }
80996 if (TestClearPageHWPoison(p))
80997 - atomic_long_sub(nr_pages, &num_poisoned_pages);
80998 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
80999 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
81000 return 0;
81001 }
81002 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
81003 */
81004 if (TestClearPageHWPoison(page)) {
81005 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
81006 - atomic_long_sub(nr_pages, &num_poisoned_pages);
81007 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
81008 freeit = 1;
81009 if (PageHuge(page))
81010 clear_page_hwpoison_huge_page(page);
81011 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
81012 } else {
81013 set_page_hwpoison_huge_page(hpage);
81014 dequeue_hwpoisoned_huge_page(hpage);
81015 - atomic_long_add(1 << compound_trans_order(hpage),
81016 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
81017 &num_poisoned_pages);
81018 }
81019 /* keep elevated page count for bad page */
81020 @@ -1552,11 +1552,11 @@ int soft_offline_page(struct page *page, int flags)
81021 if (PageHuge(page)) {
81022 set_page_hwpoison_huge_page(hpage);
81023 dequeue_hwpoisoned_huge_page(hpage);
81024 - atomic_long_add(1 << compound_trans_order(hpage),
81025 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
81026 &num_poisoned_pages);
81027 } else {
81028 SetPageHWPoison(page);
81029 - atomic_long_inc(&num_poisoned_pages);
81030 + atomic_long_inc_unchecked(&num_poisoned_pages);
81031 }
81032 }
81033 /* keep elevated page count for bad page */
81034 @@ -1596,7 +1596,7 @@ static int __soft_offline_page(struct page *page, int flags)
81035 put_page(page);
81036 pr_info("soft_offline: %#lx: invalidated\n", pfn);
81037 SetPageHWPoison(page);
81038 - atomic_long_inc(&num_poisoned_pages);
81039 + atomic_long_inc_unchecked(&num_poisoned_pages);
81040 return 0;
81041 }
81042
81043 @@ -1626,7 +1626,7 @@ static int __soft_offline_page(struct page *page, int flags)
81044 ret = -EIO;
81045 } else {
81046 SetPageHWPoison(page);
81047 - atomic_long_inc(&num_poisoned_pages);
81048 + atomic_long_inc_unchecked(&num_poisoned_pages);
81049 }
81050 } else {
81051 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
81052 diff --git a/mm/memory.c b/mm/memory.c
81053 index ba94dec..08ffe0d 100644
81054 --- a/mm/memory.c
81055 +++ b/mm/memory.c
81056 @@ -438,6 +438,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81057 free_pte_range(tlb, pmd, addr);
81058 } while (pmd++, addr = next, addr != end);
81059
81060 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
81061 start &= PUD_MASK;
81062 if (start < floor)
81063 return;
81064 @@ -452,6 +453,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81065 pmd = pmd_offset(pud, start);
81066 pud_clear(pud);
81067 pmd_free_tlb(tlb, pmd, start);
81068 +#endif
81069 +
81070 }
81071
81072 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81073 @@ -471,6 +474,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81074 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
81075 } while (pud++, addr = next, addr != end);
81076
81077 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
81078 start &= PGDIR_MASK;
81079 if (start < floor)
81080 return;
81081 @@ -485,6 +489,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81082 pud = pud_offset(pgd, start);
81083 pgd_clear(pgd);
81084 pud_free_tlb(tlb, pud, start);
81085 +#endif
81086 +
81087 }
81088
81089 /*
81090 @@ -1644,12 +1650,6 @@ no_page_table:
81091 return page;
81092 }
81093
81094 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
81095 -{
81096 - return stack_guard_page_start(vma, addr) ||
81097 - stack_guard_page_end(vma, addr+PAGE_SIZE);
81098 -}
81099 -
81100 /**
81101 * __get_user_pages() - pin user pages in memory
81102 * @tsk: task_struct of target task
81103 @@ -1736,10 +1736,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81104
81105 i = 0;
81106
81107 - do {
81108 + while (nr_pages) {
81109 struct vm_area_struct *vma;
81110
81111 - vma = find_extend_vma(mm, start);
81112 + vma = find_vma(mm, start);
81113 if (!vma && in_gate_area(mm, start)) {
81114 unsigned long pg = start & PAGE_MASK;
81115 pgd_t *pgd;
81116 @@ -1788,7 +1788,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81117 goto next_page;
81118 }
81119
81120 - if (!vma ||
81121 + if (!vma || start < vma->vm_start ||
81122 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
81123 !(vm_flags & vma->vm_flags))
81124 return i ? : -EFAULT;
81125 @@ -1817,11 +1817,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81126 int ret;
81127 unsigned int fault_flags = 0;
81128
81129 - /* For mlock, just skip the stack guard page. */
81130 - if (foll_flags & FOLL_MLOCK) {
81131 - if (stack_guard_page(vma, start))
81132 - goto next_page;
81133 - }
81134 if (foll_flags & FOLL_WRITE)
81135 fault_flags |= FAULT_FLAG_WRITE;
81136 if (nonblocking)
81137 @@ -1901,7 +1896,7 @@ next_page:
81138 start += page_increm * PAGE_SIZE;
81139 nr_pages -= page_increm;
81140 } while (nr_pages && start < vma->vm_end);
81141 - } while (nr_pages);
81142 + }
81143 return i;
81144 }
81145 EXPORT_SYMBOL(__get_user_pages);
81146 @@ -2108,6 +2103,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
81147 page_add_file_rmap(page);
81148 set_pte_at(mm, addr, pte, mk_pte(page, prot));
81149
81150 +#ifdef CONFIG_PAX_SEGMEXEC
81151 + pax_mirror_file_pte(vma, addr, page, ptl);
81152 +#endif
81153 +
81154 retval = 0;
81155 pte_unmap_unlock(pte, ptl);
81156 return retval;
81157 @@ -2152,9 +2151,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
81158 if (!page_count(page))
81159 return -EINVAL;
81160 if (!(vma->vm_flags & VM_MIXEDMAP)) {
81161 +
81162 +#ifdef CONFIG_PAX_SEGMEXEC
81163 + struct vm_area_struct *vma_m;
81164 +#endif
81165 +
81166 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
81167 BUG_ON(vma->vm_flags & VM_PFNMAP);
81168 vma->vm_flags |= VM_MIXEDMAP;
81169 +
81170 +#ifdef CONFIG_PAX_SEGMEXEC
81171 + vma_m = pax_find_mirror_vma(vma);
81172 + if (vma_m)
81173 + vma_m->vm_flags |= VM_MIXEDMAP;
81174 +#endif
81175 +
81176 }
81177 return insert_page(vma, addr, page, vma->vm_page_prot);
81178 }
81179 @@ -2237,6 +2248,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
81180 unsigned long pfn)
81181 {
81182 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
81183 + BUG_ON(vma->vm_mirror);
81184
81185 if (addr < vma->vm_start || addr >= vma->vm_end)
81186 return -EFAULT;
81187 @@ -2484,7 +2496,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
81188
81189 BUG_ON(pud_huge(*pud));
81190
81191 - pmd = pmd_alloc(mm, pud, addr);
81192 + pmd = (mm == &init_mm) ?
81193 + pmd_alloc_kernel(mm, pud, addr) :
81194 + pmd_alloc(mm, pud, addr);
81195 if (!pmd)
81196 return -ENOMEM;
81197 do {
81198 @@ -2504,7 +2518,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
81199 unsigned long next;
81200 int err;
81201
81202 - pud = pud_alloc(mm, pgd, addr);
81203 + pud = (mm == &init_mm) ?
81204 + pud_alloc_kernel(mm, pgd, addr) :
81205 + pud_alloc(mm, pgd, addr);
81206 if (!pud)
81207 return -ENOMEM;
81208 do {
81209 @@ -2592,6 +2608,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
81210 copy_user_highpage(dst, src, va, vma);
81211 }
81212
81213 +#ifdef CONFIG_PAX_SEGMEXEC
81214 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
81215 +{
81216 + struct mm_struct *mm = vma->vm_mm;
81217 + spinlock_t *ptl;
81218 + pte_t *pte, entry;
81219 +
81220 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
81221 + entry = *pte;
81222 + if (!pte_present(entry)) {
81223 + if (!pte_none(entry)) {
81224 + BUG_ON(pte_file(entry));
81225 + free_swap_and_cache(pte_to_swp_entry(entry));
81226 + pte_clear_not_present_full(mm, address, pte, 0);
81227 + }
81228 + } else {
81229 + struct page *page;
81230 +
81231 + flush_cache_page(vma, address, pte_pfn(entry));
81232 + entry = ptep_clear_flush(vma, address, pte);
81233 + BUG_ON(pte_dirty(entry));
81234 + page = vm_normal_page(vma, address, entry);
81235 + if (page) {
81236 + update_hiwater_rss(mm);
81237 + if (PageAnon(page))
81238 + dec_mm_counter_fast(mm, MM_ANONPAGES);
81239 + else
81240 + dec_mm_counter_fast(mm, MM_FILEPAGES);
81241 + page_remove_rmap(page);
81242 + page_cache_release(page);
81243 + }
81244 + }
81245 + pte_unmap_unlock(pte, ptl);
81246 +}
81247 +
81248 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
81249 + *
81250 + * the ptl of the lower mapped page is held on entry and is not released on exit
81251 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
81252 + */
81253 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81254 +{
81255 + struct mm_struct *mm = vma->vm_mm;
81256 + unsigned long address_m;
81257 + spinlock_t *ptl_m;
81258 + struct vm_area_struct *vma_m;
81259 + pmd_t *pmd_m;
81260 + pte_t *pte_m, entry_m;
81261 +
81262 + BUG_ON(!page_m || !PageAnon(page_m));
81263 +
81264 + vma_m = pax_find_mirror_vma(vma);
81265 + if (!vma_m)
81266 + return;
81267 +
81268 + BUG_ON(!PageLocked(page_m));
81269 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81270 + address_m = address + SEGMEXEC_TASK_SIZE;
81271 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81272 + pte_m = pte_offset_map(pmd_m, address_m);
81273 + ptl_m = pte_lockptr(mm, pmd_m);
81274 + if (ptl != ptl_m) {
81275 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81276 + if (!pte_none(*pte_m))
81277 + goto out;
81278 + }
81279 +
81280 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81281 + page_cache_get(page_m);
81282 + page_add_anon_rmap(page_m, vma_m, address_m);
81283 + inc_mm_counter_fast(mm, MM_ANONPAGES);
81284 + set_pte_at(mm, address_m, pte_m, entry_m);
81285 + update_mmu_cache(vma_m, address_m, pte_m);
81286 +out:
81287 + if (ptl != ptl_m)
81288 + spin_unlock(ptl_m);
81289 + pte_unmap(pte_m);
81290 + unlock_page(page_m);
81291 +}
81292 +
81293 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81294 +{
81295 + struct mm_struct *mm = vma->vm_mm;
81296 + unsigned long address_m;
81297 + spinlock_t *ptl_m;
81298 + struct vm_area_struct *vma_m;
81299 + pmd_t *pmd_m;
81300 + pte_t *pte_m, entry_m;
81301 +
81302 + BUG_ON(!page_m || PageAnon(page_m));
81303 +
81304 + vma_m = pax_find_mirror_vma(vma);
81305 + if (!vma_m)
81306 + return;
81307 +
81308 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81309 + address_m = address + SEGMEXEC_TASK_SIZE;
81310 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81311 + pte_m = pte_offset_map(pmd_m, address_m);
81312 + ptl_m = pte_lockptr(mm, pmd_m);
81313 + if (ptl != ptl_m) {
81314 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81315 + if (!pte_none(*pte_m))
81316 + goto out;
81317 + }
81318 +
81319 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81320 + page_cache_get(page_m);
81321 + page_add_file_rmap(page_m);
81322 + inc_mm_counter_fast(mm, MM_FILEPAGES);
81323 + set_pte_at(mm, address_m, pte_m, entry_m);
81324 + update_mmu_cache(vma_m, address_m, pte_m);
81325 +out:
81326 + if (ptl != ptl_m)
81327 + spin_unlock(ptl_m);
81328 + pte_unmap(pte_m);
81329 +}
81330 +
81331 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
81332 +{
81333 + struct mm_struct *mm = vma->vm_mm;
81334 + unsigned long address_m;
81335 + spinlock_t *ptl_m;
81336 + struct vm_area_struct *vma_m;
81337 + pmd_t *pmd_m;
81338 + pte_t *pte_m, entry_m;
81339 +
81340 + vma_m = pax_find_mirror_vma(vma);
81341 + if (!vma_m)
81342 + return;
81343 +
81344 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81345 + address_m = address + SEGMEXEC_TASK_SIZE;
81346 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81347 + pte_m = pte_offset_map(pmd_m, address_m);
81348 + ptl_m = pte_lockptr(mm, pmd_m);
81349 + if (ptl != ptl_m) {
81350 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81351 + if (!pte_none(*pte_m))
81352 + goto out;
81353 + }
81354 +
81355 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
81356 + set_pte_at(mm, address_m, pte_m, entry_m);
81357 +out:
81358 + if (ptl != ptl_m)
81359 + spin_unlock(ptl_m);
81360 + pte_unmap(pte_m);
81361 +}
81362 +
81363 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
81364 +{
81365 + struct page *page_m;
81366 + pte_t entry;
81367 +
81368 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
81369 + goto out;
81370 +
81371 + entry = *pte;
81372 + page_m = vm_normal_page(vma, address, entry);
81373 + if (!page_m)
81374 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
81375 + else if (PageAnon(page_m)) {
81376 + if (pax_find_mirror_vma(vma)) {
81377 + pte_unmap_unlock(pte, ptl);
81378 + lock_page(page_m);
81379 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
81380 + if (pte_same(entry, *pte))
81381 + pax_mirror_anon_pte(vma, address, page_m, ptl);
81382 + else
81383 + unlock_page(page_m);
81384 + }
81385 + } else
81386 + pax_mirror_file_pte(vma, address, page_m, ptl);
81387 +
81388 +out:
81389 + pte_unmap_unlock(pte, ptl);
81390 +}
81391 +#endif
81392 +
81393 /*
81394 * This routine handles present pages, when users try to write
81395 * to a shared page. It is done by copying the page to a new address
81396 @@ -2808,6 +3004,12 @@ gotten:
81397 */
81398 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81399 if (likely(pte_same(*page_table, orig_pte))) {
81400 +
81401 +#ifdef CONFIG_PAX_SEGMEXEC
81402 + if (pax_find_mirror_vma(vma))
81403 + BUG_ON(!trylock_page(new_page));
81404 +#endif
81405 +
81406 if (old_page) {
81407 if (!PageAnon(old_page)) {
81408 dec_mm_counter_fast(mm, MM_FILEPAGES);
81409 @@ -2859,6 +3061,10 @@ gotten:
81410 page_remove_rmap(old_page);
81411 }
81412
81413 +#ifdef CONFIG_PAX_SEGMEXEC
81414 + pax_mirror_anon_pte(vma, address, new_page, ptl);
81415 +#endif
81416 +
81417 /* Free the old page.. */
81418 new_page = old_page;
81419 ret |= VM_FAULT_WRITE;
81420 @@ -3134,6 +3340,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81421 swap_free(entry);
81422 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
81423 try_to_free_swap(page);
81424 +
81425 +#ifdef CONFIG_PAX_SEGMEXEC
81426 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
81427 +#endif
81428 +
81429 unlock_page(page);
81430 if (page != swapcache) {
81431 /*
81432 @@ -3157,6 +3368,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81433
81434 /* No need to invalidate - it was non-present before */
81435 update_mmu_cache(vma, address, page_table);
81436 +
81437 +#ifdef CONFIG_PAX_SEGMEXEC
81438 + pax_mirror_anon_pte(vma, address, page, ptl);
81439 +#endif
81440 +
81441 unlock:
81442 pte_unmap_unlock(page_table, ptl);
81443 out:
81444 @@ -3176,40 +3392,6 @@ out_release:
81445 }
81446
81447 /*
81448 - * This is like a special single-page "expand_{down|up}wards()",
81449 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
81450 - * doesn't hit another vma.
81451 - */
81452 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
81453 -{
81454 - address &= PAGE_MASK;
81455 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
81456 - struct vm_area_struct *prev = vma->vm_prev;
81457 -
81458 - /*
81459 - * Is there a mapping abutting this one below?
81460 - *
81461 - * That's only ok if it's the same stack mapping
81462 - * that has gotten split..
81463 - */
81464 - if (prev && prev->vm_end == address)
81465 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
81466 -
81467 - expand_downwards(vma, address - PAGE_SIZE);
81468 - }
81469 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
81470 - struct vm_area_struct *next = vma->vm_next;
81471 -
81472 - /* As VM_GROWSDOWN but s/below/above/ */
81473 - if (next && next->vm_start == address + PAGE_SIZE)
81474 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
81475 -
81476 - expand_upwards(vma, address + PAGE_SIZE);
81477 - }
81478 - return 0;
81479 -}
81480 -
81481 -/*
81482 * We enter with non-exclusive mmap_sem (to exclude vma changes,
81483 * but allow concurrent faults), and pte mapped but not yet locked.
81484 * We return with mmap_sem still held, but pte unmapped and unlocked.
81485 @@ -3218,27 +3400,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81486 unsigned long address, pte_t *page_table, pmd_t *pmd,
81487 unsigned int flags)
81488 {
81489 - struct page *page;
81490 + struct page *page = NULL;
81491 spinlock_t *ptl;
81492 pte_t entry;
81493
81494 - pte_unmap(page_table);
81495 -
81496 - /* Check if we need to add a guard page to the stack */
81497 - if (check_stack_guard_page(vma, address) < 0)
81498 - return VM_FAULT_SIGBUS;
81499 -
81500 - /* Use the zero-page for reads */
81501 if (!(flags & FAULT_FLAG_WRITE)) {
81502 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
81503 vma->vm_page_prot));
81504 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81505 + ptl = pte_lockptr(mm, pmd);
81506 + spin_lock(ptl);
81507 if (!pte_none(*page_table))
81508 goto unlock;
81509 goto setpte;
81510 }
81511
81512 /* Allocate our own private page. */
81513 + pte_unmap(page_table);
81514 +
81515 if (unlikely(anon_vma_prepare(vma)))
81516 goto oom;
81517 page = alloc_zeroed_user_highpage_movable(vma, address);
81518 @@ -3257,6 +3435,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81519 if (!pte_none(*page_table))
81520 goto release;
81521
81522 +#ifdef CONFIG_PAX_SEGMEXEC
81523 + if (pax_find_mirror_vma(vma))
81524 + BUG_ON(!trylock_page(page));
81525 +#endif
81526 +
81527 inc_mm_counter_fast(mm, MM_ANONPAGES);
81528 page_add_new_anon_rmap(page, vma, address);
81529 setpte:
81530 @@ -3264,6 +3447,12 @@ setpte:
81531
81532 /* No need to invalidate - it was non-present before */
81533 update_mmu_cache(vma, address, page_table);
81534 +
81535 +#ifdef CONFIG_PAX_SEGMEXEC
81536 + if (page)
81537 + pax_mirror_anon_pte(vma, address, page, ptl);
81538 +#endif
81539 +
81540 unlock:
81541 pte_unmap_unlock(page_table, ptl);
81542 return 0;
81543 @@ -3407,6 +3596,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81544 */
81545 /* Only go through if we didn't race with anybody else... */
81546 if (likely(pte_same(*page_table, orig_pte))) {
81547 +
81548 +#ifdef CONFIG_PAX_SEGMEXEC
81549 + if (anon && pax_find_mirror_vma(vma))
81550 + BUG_ON(!trylock_page(page));
81551 +#endif
81552 +
81553 flush_icache_page(vma, page);
81554 entry = mk_pte(page, vma->vm_page_prot);
81555 if (flags & FAULT_FLAG_WRITE)
81556 @@ -3426,6 +3621,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81557
81558 /* no need to invalidate: a not-present page won't be cached */
81559 update_mmu_cache(vma, address, page_table);
81560 +
81561 +#ifdef CONFIG_PAX_SEGMEXEC
81562 + if (anon)
81563 + pax_mirror_anon_pte(vma, address, page, ptl);
81564 + else
81565 + pax_mirror_file_pte(vma, address, page, ptl);
81566 +#endif
81567 +
81568 } else {
81569 if (cow_page)
81570 mem_cgroup_uncharge_page(cow_page);
81571 @@ -3747,6 +3950,12 @@ int handle_pte_fault(struct mm_struct *mm,
81572 if (flags & FAULT_FLAG_WRITE)
81573 flush_tlb_fix_spurious_fault(vma, address);
81574 }
81575 +
81576 +#ifdef CONFIG_PAX_SEGMEXEC
81577 + pax_mirror_pte(vma, address, pte, pmd, ptl);
81578 + return 0;
81579 +#endif
81580 +
81581 unlock:
81582 pte_unmap_unlock(pte, ptl);
81583 return 0;
81584 @@ -3763,6 +3972,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81585 pmd_t *pmd;
81586 pte_t *pte;
81587
81588 +#ifdef CONFIG_PAX_SEGMEXEC
81589 + struct vm_area_struct *vma_m;
81590 +#endif
81591 +
81592 __set_current_state(TASK_RUNNING);
81593
81594 count_vm_event(PGFAULT);
81595 @@ -3774,6 +3987,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81596 if (unlikely(is_vm_hugetlb_page(vma)))
81597 return hugetlb_fault(mm, vma, address, flags);
81598
81599 +#ifdef CONFIG_PAX_SEGMEXEC
81600 + vma_m = pax_find_mirror_vma(vma);
81601 + if (vma_m) {
81602 + unsigned long address_m;
81603 + pgd_t *pgd_m;
81604 + pud_t *pud_m;
81605 + pmd_t *pmd_m;
81606 +
81607 + if (vma->vm_start > vma_m->vm_start) {
81608 + address_m = address;
81609 + address -= SEGMEXEC_TASK_SIZE;
81610 + vma = vma_m;
81611 + } else
81612 + address_m = address + SEGMEXEC_TASK_SIZE;
81613 +
81614 + pgd_m = pgd_offset(mm, address_m);
81615 + pud_m = pud_alloc(mm, pgd_m, address_m);
81616 + if (!pud_m)
81617 + return VM_FAULT_OOM;
81618 + pmd_m = pmd_alloc(mm, pud_m, address_m);
81619 + if (!pmd_m)
81620 + return VM_FAULT_OOM;
81621 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
81622 + return VM_FAULT_OOM;
81623 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
81624 + }
81625 +#endif
81626 +
81627 retry:
81628 pgd = pgd_offset(mm, address);
81629 pud = pud_alloc(mm, pgd, address);
81630 @@ -3872,6 +4113,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81631 spin_unlock(&mm->page_table_lock);
81632 return 0;
81633 }
81634 +
81635 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81636 +{
81637 + pud_t *new = pud_alloc_one(mm, address);
81638 + if (!new)
81639 + return -ENOMEM;
81640 +
81641 + smp_wmb(); /* See comment in __pte_alloc */
81642 +
81643 + spin_lock(&mm->page_table_lock);
81644 + if (pgd_present(*pgd)) /* Another has populated it */
81645 + pud_free(mm, new);
81646 + else
81647 + pgd_populate_kernel(mm, pgd, new);
81648 + spin_unlock(&mm->page_table_lock);
81649 + return 0;
81650 +}
81651 #endif /* __PAGETABLE_PUD_FOLDED */
81652
81653 #ifndef __PAGETABLE_PMD_FOLDED
81654 @@ -3902,6 +4160,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
81655 spin_unlock(&mm->page_table_lock);
81656 return 0;
81657 }
81658 +
81659 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
81660 +{
81661 + pmd_t *new = pmd_alloc_one(mm, address);
81662 + if (!new)
81663 + return -ENOMEM;
81664 +
81665 + smp_wmb(); /* See comment in __pte_alloc */
81666 +
81667 + spin_lock(&mm->page_table_lock);
81668 +#ifndef __ARCH_HAS_4LEVEL_HACK
81669 + if (pud_present(*pud)) /* Another has populated it */
81670 + pmd_free(mm, new);
81671 + else
81672 + pud_populate_kernel(mm, pud, new);
81673 +#else
81674 + if (pgd_present(*pud)) /* Another has populated it */
81675 + pmd_free(mm, new);
81676 + else
81677 + pgd_populate_kernel(mm, pud, new);
81678 +#endif /* __ARCH_HAS_4LEVEL_HACK */
81679 + spin_unlock(&mm->page_table_lock);
81680 + return 0;
81681 +}
81682 #endif /* __PAGETABLE_PMD_FOLDED */
81683
81684 #if !defined(__HAVE_ARCH_GATE_AREA)
81685 @@ -3915,7 +4197,7 @@ static int __init gate_vma_init(void)
81686 gate_vma.vm_start = FIXADDR_USER_START;
81687 gate_vma.vm_end = FIXADDR_USER_END;
81688 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
81689 - gate_vma.vm_page_prot = __P101;
81690 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
81691
81692 return 0;
81693 }
81694 @@ -4049,8 +4331,8 @@ out:
81695 return ret;
81696 }
81697
81698 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81699 - void *buf, int len, int write)
81700 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81701 + void *buf, size_t len, int write)
81702 {
81703 resource_size_t phys_addr;
81704 unsigned long prot = 0;
81705 @@ -4075,8 +4357,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81706 * Access another process' address space as given in mm. If non-NULL, use the
81707 * given task for page fault accounting.
81708 */
81709 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81710 - unsigned long addr, void *buf, int len, int write)
81711 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81712 + unsigned long addr, void *buf, size_t len, int write)
81713 {
81714 struct vm_area_struct *vma;
81715 void *old_buf = buf;
81716 @@ -4084,7 +4366,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81717 down_read(&mm->mmap_sem);
81718 /* ignore errors, just check how much was successfully transferred */
81719 while (len) {
81720 - int bytes, ret, offset;
81721 + ssize_t bytes, ret, offset;
81722 void *maddr;
81723 struct page *page = NULL;
81724
81725 @@ -4143,8 +4425,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81726 *
81727 * The caller must hold a reference on @mm.
81728 */
81729 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81730 - void *buf, int len, int write)
81731 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
81732 + void *buf, size_t len, int write)
81733 {
81734 return __access_remote_vm(NULL, mm, addr, buf, len, write);
81735 }
81736 @@ -4154,11 +4436,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81737 * Source/target buffer must be kernel space,
81738 * Do not walk the page table directly, use get_user_pages
81739 */
81740 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
81741 - void *buf, int len, int write)
81742 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
81743 + void *buf, size_t len, int write)
81744 {
81745 struct mm_struct *mm;
81746 - int ret;
81747 + ssize_t ret;
81748
81749 mm = get_task_mm(tsk);
81750 if (!mm)
81751 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
81752 index 7431001..0f8344e 100644
81753 --- a/mm/mempolicy.c
81754 +++ b/mm/mempolicy.c
81755 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81756 unsigned long vmstart;
81757 unsigned long vmend;
81758
81759 +#ifdef CONFIG_PAX_SEGMEXEC
81760 + struct vm_area_struct *vma_m;
81761 +#endif
81762 +
81763 vma = find_vma(mm, start);
81764 if (!vma || vma->vm_start > start)
81765 return -EFAULT;
81766 @@ -744,9 +748,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81767 if (err)
81768 goto out;
81769 }
81770 +
81771 err = vma_replace_policy(vma, new_pol);
81772 if (err)
81773 goto out;
81774 +
81775 +#ifdef CONFIG_PAX_SEGMEXEC
81776 + vma_m = pax_find_mirror_vma(vma);
81777 + if (vma_m) {
81778 + err = vma_replace_policy(vma_m, new_pol);
81779 + if (err)
81780 + goto out;
81781 + }
81782 +#endif
81783 +
81784 }
81785
81786 out:
81787 @@ -1202,6 +1217,17 @@ static long do_mbind(unsigned long start, unsigned long len,
81788
81789 if (end < start)
81790 return -EINVAL;
81791 +
81792 +#ifdef CONFIG_PAX_SEGMEXEC
81793 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
81794 + if (end > SEGMEXEC_TASK_SIZE)
81795 + return -EINVAL;
81796 + } else
81797 +#endif
81798 +
81799 + if (end > TASK_SIZE)
81800 + return -EINVAL;
81801 +
81802 if (end == start)
81803 return 0;
81804
81805 @@ -1430,8 +1456,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
81806 */
81807 tcred = __task_cred(task);
81808 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
81809 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
81810 - !capable(CAP_SYS_NICE)) {
81811 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
81812 rcu_read_unlock();
81813 err = -EPERM;
81814 goto out_put;
81815 @@ -1462,6 +1487,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
81816 goto out;
81817 }
81818
81819 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81820 + if (mm != current->mm &&
81821 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
81822 + mmput(mm);
81823 + err = -EPERM;
81824 + goto out;
81825 + }
81826 +#endif
81827 +
81828 err = do_migrate_pages(mm, old, new,
81829 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
81830
81831 diff --git a/mm/migrate.c b/mm/migrate.c
81832 index 3bbaf5d..299b0e9 100644
81833 --- a/mm/migrate.c
81834 +++ b/mm/migrate.c
81835 @@ -1382,8 +1382,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
81836 */
81837 tcred = __task_cred(task);
81838 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
81839 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
81840 - !capable(CAP_SYS_NICE)) {
81841 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
81842 rcu_read_unlock();
81843 err = -EPERM;
81844 goto out;
81845 diff --git a/mm/mlock.c b/mm/mlock.c
81846 index 79b7cf7..9944291 100644
81847 --- a/mm/mlock.c
81848 +++ b/mm/mlock.c
81849 @@ -13,6 +13,7 @@
81850 #include <linux/pagemap.h>
81851 #include <linux/mempolicy.h>
81852 #include <linux/syscalls.h>
81853 +#include <linux/security.h>
81854 #include <linux/sched.h>
81855 #include <linux/export.h>
81856 #include <linux/rmap.h>
81857 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
81858 {
81859 unsigned long nstart, end, tmp;
81860 struct vm_area_struct * vma, * prev;
81861 - int error;
81862 + int error = 0;
81863
81864 VM_BUG_ON(start & ~PAGE_MASK);
81865 VM_BUG_ON(len != PAGE_ALIGN(len));
81866 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
81867 return -EINVAL;
81868 if (end == start)
81869 return 0;
81870 + if (end > TASK_SIZE)
81871 + return -EINVAL;
81872 +
81873 vma = find_vma(current->mm, start);
81874 if (!vma || vma->vm_start > start)
81875 return -ENOMEM;
81876 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
81877 for (nstart = start ; ; ) {
81878 vm_flags_t newflags;
81879
81880 +#ifdef CONFIG_PAX_SEGMEXEC
81881 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
81882 + break;
81883 +#endif
81884 +
81885 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
81886
81887 newflags = vma->vm_flags & ~VM_LOCKED;
81888 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
81889 lock_limit >>= PAGE_SHIFT;
81890
81891 /* check against resource limits */
81892 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
81893 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
81894 error = do_mlock(start, len, 1);
81895 up_write(&current->mm->mmap_sem);
81896 @@ -500,6 +510,11 @@ static int do_mlockall(int flags)
81897 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
81898 vm_flags_t newflags;
81899
81900 +#ifdef CONFIG_PAX_SEGMEXEC
81901 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
81902 + break;
81903 +#endif
81904 +
81905 newflags = vma->vm_flags & ~VM_LOCKED;
81906 if (flags & MCL_CURRENT)
81907 newflags |= VM_LOCKED;
81908 @@ -532,6 +547,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
81909 lock_limit >>= PAGE_SHIFT;
81910
81911 ret = -ENOMEM;
81912 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
81913 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
81914 capable(CAP_IPC_LOCK))
81915 ret = do_mlockall(flags);
81916 diff --git a/mm/mmap.c b/mm/mmap.c
81917 index 0dceed8..671951c 100644
81918 --- a/mm/mmap.c
81919 +++ b/mm/mmap.c
81920 @@ -33,6 +33,7 @@
81921 #include <linux/uprobes.h>
81922 #include <linux/rbtree_augmented.h>
81923 #include <linux/sched/sysctl.h>
81924 +#include <linux/random.h>
81925
81926 #include <asm/uaccess.h>
81927 #include <asm/cacheflush.h>
81928 @@ -49,6 +50,16 @@
81929 #define arch_rebalance_pgtables(addr, len) (addr)
81930 #endif
81931
81932 +static inline void verify_mm_writelocked(struct mm_struct *mm)
81933 +{
81934 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
81935 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
81936 + up_read(&mm->mmap_sem);
81937 + BUG();
81938 + }
81939 +#endif
81940 +}
81941 +
81942 static void unmap_region(struct mm_struct *mm,
81943 struct vm_area_struct *vma, struct vm_area_struct *prev,
81944 unsigned long start, unsigned long end);
81945 @@ -68,22 +79,32 @@ static void unmap_region(struct mm_struct *mm,
81946 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
81947 *
81948 */
81949 -pgprot_t protection_map[16] = {
81950 +pgprot_t protection_map[16] __read_only = {
81951 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
81952 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
81953 };
81954
81955 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
81956 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
81957 {
81958 - return __pgprot(pgprot_val(protection_map[vm_flags &
81959 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
81960 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
81961 pgprot_val(arch_vm_get_page_prot(vm_flags)));
81962 +
81963 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81964 + if (!(__supported_pte_mask & _PAGE_NX) &&
81965 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
81966 + (vm_flags & (VM_READ | VM_WRITE)))
81967 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
81968 +#endif
81969 +
81970 + return prot;
81971 }
81972 EXPORT_SYMBOL(vm_get_page_prot);
81973
81974 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
81975 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
81976 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
81977 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
81978 /*
81979 * Make sure vm_committed_as in one cacheline and not cacheline shared with
81980 * other variables. It can be updated by several CPUs frequently.
81981 @@ -239,6 +260,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
81982 struct vm_area_struct *next = vma->vm_next;
81983
81984 might_sleep();
81985 + BUG_ON(vma->vm_mirror);
81986 if (vma->vm_ops && vma->vm_ops->close)
81987 vma->vm_ops->close(vma);
81988 if (vma->vm_file)
81989 @@ -283,6 +305,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
81990 * not page aligned -Ram Gupta
81991 */
81992 rlim = rlimit(RLIMIT_DATA);
81993 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
81994 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
81995 (mm->end_data - mm->start_data) > rlim)
81996 goto out;
81997 @@ -897,6 +920,12 @@ static int
81998 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
81999 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82000 {
82001 +
82002 +#ifdef CONFIG_PAX_SEGMEXEC
82003 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
82004 + return 0;
82005 +#endif
82006 +
82007 if (is_mergeable_vma(vma, file, vm_flags) &&
82008 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82009 if (vma->vm_pgoff == vm_pgoff)
82010 @@ -916,6 +945,12 @@ static int
82011 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82012 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82013 {
82014 +
82015 +#ifdef CONFIG_PAX_SEGMEXEC
82016 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
82017 + return 0;
82018 +#endif
82019 +
82020 if (is_mergeable_vma(vma, file, vm_flags) &&
82021 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82022 pgoff_t vm_pglen;
82023 @@ -958,13 +993,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82024 struct vm_area_struct *vma_merge(struct mm_struct *mm,
82025 struct vm_area_struct *prev, unsigned long addr,
82026 unsigned long end, unsigned long vm_flags,
82027 - struct anon_vma *anon_vma, struct file *file,
82028 + struct anon_vma *anon_vma, struct file *file,
82029 pgoff_t pgoff, struct mempolicy *policy)
82030 {
82031 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
82032 struct vm_area_struct *area, *next;
82033 int err;
82034
82035 +#ifdef CONFIG_PAX_SEGMEXEC
82036 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
82037 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
82038 +
82039 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
82040 +#endif
82041 +
82042 /*
82043 * We later require that vma->vm_flags == vm_flags,
82044 * so this tests vma->vm_flags & VM_SPECIAL, too.
82045 @@ -980,6 +1022,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82046 if (next && next->vm_end == end) /* cases 6, 7, 8 */
82047 next = next->vm_next;
82048
82049 +#ifdef CONFIG_PAX_SEGMEXEC
82050 + if (prev)
82051 + prev_m = pax_find_mirror_vma(prev);
82052 + if (area)
82053 + area_m = pax_find_mirror_vma(area);
82054 + if (next)
82055 + next_m = pax_find_mirror_vma(next);
82056 +#endif
82057 +
82058 /*
82059 * Can it merge with the predecessor?
82060 */
82061 @@ -999,9 +1050,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82062 /* cases 1, 6 */
82063 err = vma_adjust(prev, prev->vm_start,
82064 next->vm_end, prev->vm_pgoff, NULL);
82065 - } else /* cases 2, 5, 7 */
82066 +
82067 +#ifdef CONFIG_PAX_SEGMEXEC
82068 + if (!err && prev_m)
82069 + err = vma_adjust(prev_m, prev_m->vm_start,
82070 + next_m->vm_end, prev_m->vm_pgoff, NULL);
82071 +#endif
82072 +
82073 + } else { /* cases 2, 5, 7 */
82074 err = vma_adjust(prev, prev->vm_start,
82075 end, prev->vm_pgoff, NULL);
82076 +
82077 +#ifdef CONFIG_PAX_SEGMEXEC
82078 + if (!err && prev_m)
82079 + err = vma_adjust(prev_m, prev_m->vm_start,
82080 + end_m, prev_m->vm_pgoff, NULL);
82081 +#endif
82082 +
82083 + }
82084 if (err)
82085 return NULL;
82086 khugepaged_enter_vma_merge(prev);
82087 @@ -1015,12 +1081,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82088 mpol_equal(policy, vma_policy(next)) &&
82089 can_vma_merge_before(next, vm_flags,
82090 anon_vma, file, pgoff+pglen)) {
82091 - if (prev && addr < prev->vm_end) /* case 4 */
82092 + if (prev && addr < prev->vm_end) { /* case 4 */
82093 err = vma_adjust(prev, prev->vm_start,
82094 addr, prev->vm_pgoff, NULL);
82095 - else /* cases 3, 8 */
82096 +
82097 +#ifdef CONFIG_PAX_SEGMEXEC
82098 + if (!err && prev_m)
82099 + err = vma_adjust(prev_m, prev_m->vm_start,
82100 + addr_m, prev_m->vm_pgoff, NULL);
82101 +#endif
82102 +
82103 + } else { /* cases 3, 8 */
82104 err = vma_adjust(area, addr, next->vm_end,
82105 next->vm_pgoff - pglen, NULL);
82106 +
82107 +#ifdef CONFIG_PAX_SEGMEXEC
82108 + if (!err && area_m)
82109 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
82110 + next_m->vm_pgoff - pglen, NULL);
82111 +#endif
82112 +
82113 + }
82114 if (err)
82115 return NULL;
82116 khugepaged_enter_vma_merge(area);
82117 @@ -1129,8 +1210,10 @@ none:
82118 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82119 struct file *file, long pages)
82120 {
82121 - const unsigned long stack_flags
82122 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
82123 +
82124 +#ifdef CONFIG_PAX_RANDMMAP
82125 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82126 +#endif
82127
82128 mm->total_vm += pages;
82129
82130 @@ -1138,7 +1221,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82131 mm->shared_vm += pages;
82132 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
82133 mm->exec_vm += pages;
82134 - } else if (flags & stack_flags)
82135 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
82136 mm->stack_vm += pages;
82137 }
82138 #endif /* CONFIG_PROC_FS */
82139 @@ -1177,7 +1260,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82140 * (the exception is when the underlying filesystem is noexec
82141 * mounted, in which case we dont add PROT_EXEC.)
82142 */
82143 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
82144 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
82145 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
82146 prot |= PROT_EXEC;
82147
82148 @@ -1203,7 +1286,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82149 /* Obtain the address to map to. we verify (or select) it and ensure
82150 * that it represents a valid section of the address space.
82151 */
82152 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
82153 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
82154 if (addr & ~PAGE_MASK)
82155 return addr;
82156
82157 @@ -1214,6 +1297,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82158 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
82159 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
82160
82161 +#ifdef CONFIG_PAX_MPROTECT
82162 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82163 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82164 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
82165 + gr_log_rwxmmap(file);
82166 +
82167 +#ifdef CONFIG_PAX_EMUPLT
82168 + vm_flags &= ~VM_EXEC;
82169 +#else
82170 + return -EPERM;
82171 +#endif
82172 +
82173 + }
82174 +
82175 + if (!(vm_flags & VM_EXEC))
82176 + vm_flags &= ~VM_MAYEXEC;
82177 +#else
82178 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82179 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82180 +#endif
82181 + else
82182 + vm_flags &= ~VM_MAYWRITE;
82183 + }
82184 +#endif
82185 +
82186 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82187 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
82188 + vm_flags &= ~VM_PAGEEXEC;
82189 +#endif
82190 +
82191 if (flags & MAP_LOCKED)
82192 if (!can_do_mlock())
82193 return -EPERM;
82194 @@ -1225,6 +1338,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82195 locked += mm->locked_vm;
82196 lock_limit = rlimit(RLIMIT_MEMLOCK);
82197 lock_limit >>= PAGE_SHIFT;
82198 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82199 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
82200 return -EAGAIN;
82201 }
82202 @@ -1305,6 +1419,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82203 vm_flags |= VM_NORESERVE;
82204 }
82205
82206 + if (!gr_acl_handle_mmap(file, prot))
82207 + return -EACCES;
82208 +
82209 addr = mmap_region(file, addr, len, vm_flags, pgoff);
82210 if (!IS_ERR_VALUE(addr) &&
82211 ((vm_flags & VM_LOCKED) ||
82212 @@ -1396,7 +1513,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
82213 vm_flags_t vm_flags = vma->vm_flags;
82214
82215 /* If it was private or non-writable, the write bit is already clear */
82216 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
82217 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
82218 return 0;
82219
82220 /* The backer wishes to know when pages are first written to? */
82221 @@ -1444,16 +1561,30 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
82222 unsigned long charged = 0;
82223 struct inode *inode = file ? file_inode(file) : NULL;
82224
82225 +#ifdef CONFIG_PAX_SEGMEXEC
82226 + struct vm_area_struct *vma_m = NULL;
82227 +#endif
82228 +
82229 + /*
82230 + * mm->mmap_sem is required to protect against another thread
82231 + * changing the mappings in case we sleep.
82232 + */
82233 + verify_mm_writelocked(mm);
82234 +
82235 /* Clear old maps */
82236 error = -ENOMEM;
82237 -munmap_back:
82238 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82239 if (do_munmap(mm, addr, len))
82240 return -ENOMEM;
82241 - goto munmap_back;
82242 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82243 }
82244
82245 /* Check against address space limit. */
82246 +
82247 +#ifdef CONFIG_PAX_RANDMMAP
82248 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82249 +#endif
82250 +
82251 if (!may_expand_vm(mm, len >> PAGE_SHIFT))
82252 return -ENOMEM;
82253
82254 @@ -1485,6 +1616,16 @@ munmap_back:
82255 goto unacct_error;
82256 }
82257
82258 +#ifdef CONFIG_PAX_SEGMEXEC
82259 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
82260 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82261 + if (!vma_m) {
82262 + error = -ENOMEM;
82263 + goto free_vma;
82264 + }
82265 + }
82266 +#endif
82267 +
82268 vma->vm_mm = mm;
82269 vma->vm_start = addr;
82270 vma->vm_end = addr + len;
82271 @@ -1509,6 +1650,13 @@ munmap_back:
82272 if (error)
82273 goto unmap_and_free_vma;
82274
82275 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82276 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
82277 + vma->vm_flags |= VM_PAGEEXEC;
82278 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82279 + }
82280 +#endif
82281 +
82282 /* Can addr have changed??
82283 *
82284 * Answer: Yes, several device drivers can do it in their
82285 @@ -1547,6 +1695,11 @@ munmap_back:
82286 vma_link(mm, vma, prev, rb_link, rb_parent);
82287 file = vma->vm_file;
82288
82289 +#ifdef CONFIG_PAX_SEGMEXEC
82290 + if (vma_m)
82291 + BUG_ON(pax_mirror_vma(vma_m, vma));
82292 +#endif
82293 +
82294 /* Once vma denies write, undo our temporary denial count */
82295 if (correct_wcount)
82296 atomic_inc(&inode->i_writecount);
82297 @@ -1554,6 +1707,7 @@ out:
82298 perf_event_mmap(vma);
82299
82300 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
82301 + track_exec_limit(mm, addr, addr + len, vm_flags);
82302 if (vm_flags & VM_LOCKED) {
82303 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
82304 vma == get_gate_vma(current->mm)))
82305 @@ -1577,6 +1731,12 @@ unmap_and_free_vma:
82306 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
82307 charged = 0;
82308 free_vma:
82309 +
82310 +#ifdef CONFIG_PAX_SEGMEXEC
82311 + if (vma_m)
82312 + kmem_cache_free(vm_area_cachep, vma_m);
82313 +#endif
82314 +
82315 kmem_cache_free(vm_area_cachep, vma);
82316 unacct_error:
82317 if (charged)
82318 @@ -1584,6 +1744,62 @@ unacct_error:
82319 return error;
82320 }
82321
82322 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
82323 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
82324 +{
82325 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
82326 + return (random32() & 0xFF) << PAGE_SHIFT;
82327 +
82328 + return 0;
82329 +}
82330 +#endif
82331 +
82332 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
82333 +{
82334 + if (!vma) {
82335 +#ifdef CONFIG_STACK_GROWSUP
82336 + if (addr > sysctl_heap_stack_gap)
82337 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
82338 + else
82339 + vma = find_vma(current->mm, 0);
82340 + if (vma && (vma->vm_flags & VM_GROWSUP))
82341 + return false;
82342 +#endif
82343 + return true;
82344 + }
82345 +
82346 + if (addr + len > vma->vm_start)
82347 + return false;
82348 +
82349 + if (vma->vm_flags & VM_GROWSDOWN)
82350 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
82351 +#ifdef CONFIG_STACK_GROWSUP
82352 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
82353 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
82354 +#endif
82355 + else if (offset)
82356 + return offset <= vma->vm_start - addr - len;
82357 +
82358 + return true;
82359 +}
82360 +
82361 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
82362 +{
82363 + if (vma->vm_start < len)
82364 + return -ENOMEM;
82365 +
82366 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
82367 + if (offset <= vma->vm_start - len)
82368 + return vma->vm_start - len - offset;
82369 + else
82370 + return -ENOMEM;
82371 + }
82372 +
82373 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
82374 + return vma->vm_start - len - sysctl_heap_stack_gap;
82375 + return -ENOMEM;
82376 +}
82377 +
82378 unsigned long unmapped_area(struct vm_unmapped_area_info *info)
82379 {
82380 /*
82381 @@ -1803,6 +2019,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82382 struct mm_struct *mm = current->mm;
82383 struct vm_area_struct *vma;
82384 struct vm_unmapped_area_info info;
82385 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82386
82387 if (len > TASK_SIZE)
82388 return -ENOMEM;
82389 @@ -1810,29 +2027,45 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82390 if (flags & MAP_FIXED)
82391 return addr;
82392
82393 +#ifdef CONFIG_PAX_RANDMMAP
82394 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82395 +#endif
82396 +
82397 if (addr) {
82398 addr = PAGE_ALIGN(addr);
82399 vma = find_vma(mm, addr);
82400 - if (TASK_SIZE - len >= addr &&
82401 - (!vma || addr + len <= vma->vm_start))
82402 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82403 return addr;
82404 }
82405
82406 info.flags = 0;
82407 info.length = len;
82408 info.low_limit = TASK_UNMAPPED_BASE;
82409 +
82410 +#ifdef CONFIG_PAX_RANDMMAP
82411 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82412 + info.low_limit += mm->delta_mmap;
82413 +#endif
82414 +
82415 info.high_limit = TASK_SIZE;
82416 info.align_mask = 0;
82417 + info.threadstack_offset = offset;
82418 return vm_unmapped_area(&info);
82419 }
82420 #endif
82421
82422 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
82423 {
82424 +
82425 +#ifdef CONFIG_PAX_SEGMEXEC
82426 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82427 + return;
82428 +#endif
82429 +
82430 /*
82431 * Is this a new hole at the lowest possible address?
82432 */
82433 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
82434 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
82435 mm->free_area_cache = addr;
82436 }
82437
82438 @@ -1850,6 +2083,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82439 struct mm_struct *mm = current->mm;
82440 unsigned long addr = addr0;
82441 struct vm_unmapped_area_info info;
82442 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82443
82444 /* requested length too big for entire address space */
82445 if (len > TASK_SIZE)
82446 @@ -1858,12 +2092,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82447 if (flags & MAP_FIXED)
82448 return addr;
82449
82450 +#ifdef CONFIG_PAX_RANDMMAP
82451 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82452 +#endif
82453 +
82454 /* requesting a specific address */
82455 if (addr) {
82456 addr = PAGE_ALIGN(addr);
82457 vma = find_vma(mm, addr);
82458 - if (TASK_SIZE - len >= addr &&
82459 - (!vma || addr + len <= vma->vm_start))
82460 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82461 return addr;
82462 }
82463
82464 @@ -1872,6 +2109,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82465 info.low_limit = PAGE_SIZE;
82466 info.high_limit = mm->mmap_base;
82467 info.align_mask = 0;
82468 + info.threadstack_offset = offset;
82469 addr = vm_unmapped_area(&info);
82470
82471 /*
82472 @@ -1884,6 +2122,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82473 VM_BUG_ON(addr != -ENOMEM);
82474 info.flags = 0;
82475 info.low_limit = TASK_UNMAPPED_BASE;
82476 +
82477 +#ifdef CONFIG_PAX_RANDMMAP
82478 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82479 + info.low_limit += mm->delta_mmap;
82480 +#endif
82481 +
82482 info.high_limit = TASK_SIZE;
82483 addr = vm_unmapped_area(&info);
82484 }
82485 @@ -1894,6 +2138,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82486
82487 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82488 {
82489 +
82490 +#ifdef CONFIG_PAX_SEGMEXEC
82491 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82492 + return;
82493 +#endif
82494 +
82495 /*
82496 * Is this a new hole at the highest possible address?
82497 */
82498 @@ -1901,8 +2151,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82499 mm->free_area_cache = addr;
82500
82501 /* dont allow allocations above current base */
82502 - if (mm->free_area_cache > mm->mmap_base)
82503 + if (mm->free_area_cache > mm->mmap_base) {
82504 mm->free_area_cache = mm->mmap_base;
82505 + mm->cached_hole_size = ~0UL;
82506 + }
82507 }
82508
82509 unsigned long
82510 @@ -2001,6 +2253,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
82511 return vma;
82512 }
82513
82514 +#ifdef CONFIG_PAX_SEGMEXEC
82515 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
82516 +{
82517 + struct vm_area_struct *vma_m;
82518 +
82519 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
82520 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
82521 + BUG_ON(vma->vm_mirror);
82522 + return NULL;
82523 + }
82524 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
82525 + vma_m = vma->vm_mirror;
82526 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
82527 + BUG_ON(vma->vm_file != vma_m->vm_file);
82528 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
82529 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
82530 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
82531 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
82532 + return vma_m;
82533 +}
82534 +#endif
82535 +
82536 /*
82537 * Verify that the stack growth is acceptable and
82538 * update accounting. This is shared with both the
82539 @@ -2017,6 +2291,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82540 return -ENOMEM;
82541
82542 /* Stack limit test */
82543 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
82544 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
82545 return -ENOMEM;
82546
82547 @@ -2027,6 +2302,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82548 locked = mm->locked_vm + grow;
82549 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
82550 limit >>= PAGE_SHIFT;
82551 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82552 if (locked > limit && !capable(CAP_IPC_LOCK))
82553 return -ENOMEM;
82554 }
82555 @@ -2056,37 +2332,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82556 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
82557 * vma is the last one with address > vma->vm_end. Have to extend vma.
82558 */
82559 +#ifndef CONFIG_IA64
82560 +static
82561 +#endif
82562 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82563 {
82564 int error;
82565 + bool locknext;
82566
82567 if (!(vma->vm_flags & VM_GROWSUP))
82568 return -EFAULT;
82569
82570 + /* Also guard against wrapping around to address 0. */
82571 + if (address < PAGE_ALIGN(address+1))
82572 + address = PAGE_ALIGN(address+1);
82573 + else
82574 + return -ENOMEM;
82575 +
82576 /*
82577 * We must make sure the anon_vma is allocated
82578 * so that the anon_vma locking is not a noop.
82579 */
82580 if (unlikely(anon_vma_prepare(vma)))
82581 return -ENOMEM;
82582 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
82583 + if (locknext && anon_vma_prepare(vma->vm_next))
82584 + return -ENOMEM;
82585 vma_lock_anon_vma(vma);
82586 + if (locknext)
82587 + vma_lock_anon_vma(vma->vm_next);
82588
82589 /*
82590 * vma->vm_start/vm_end cannot change under us because the caller
82591 * is required to hold the mmap_sem in read mode. We need the
82592 - * anon_vma lock to serialize against concurrent expand_stacks.
82593 - * Also guard against wrapping around to address 0.
82594 + * anon_vma locks to serialize against concurrent expand_stacks
82595 + * and expand_upwards.
82596 */
82597 - if (address < PAGE_ALIGN(address+4))
82598 - address = PAGE_ALIGN(address+4);
82599 - else {
82600 - vma_unlock_anon_vma(vma);
82601 - return -ENOMEM;
82602 - }
82603 error = 0;
82604
82605 /* Somebody else might have raced and expanded it already */
82606 - if (address > vma->vm_end) {
82607 + 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)
82608 + error = -ENOMEM;
82609 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
82610 unsigned long size, grow;
82611
82612 size = address - vma->vm_start;
82613 @@ -2121,6 +2408,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82614 }
82615 }
82616 }
82617 + if (locknext)
82618 + vma_unlock_anon_vma(vma->vm_next);
82619 vma_unlock_anon_vma(vma);
82620 khugepaged_enter_vma_merge(vma);
82621 validate_mm(vma->vm_mm);
82622 @@ -2135,6 +2424,8 @@ int expand_downwards(struct vm_area_struct *vma,
82623 unsigned long address)
82624 {
82625 int error;
82626 + bool lockprev = false;
82627 + struct vm_area_struct *prev;
82628
82629 /*
82630 * We must make sure the anon_vma is allocated
82631 @@ -2148,6 +2439,15 @@ int expand_downwards(struct vm_area_struct *vma,
82632 if (error)
82633 return error;
82634
82635 + prev = vma->vm_prev;
82636 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
82637 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
82638 +#endif
82639 + if (lockprev && anon_vma_prepare(prev))
82640 + return -ENOMEM;
82641 + if (lockprev)
82642 + vma_lock_anon_vma(prev);
82643 +
82644 vma_lock_anon_vma(vma);
82645
82646 /*
82647 @@ -2157,9 +2457,17 @@ int expand_downwards(struct vm_area_struct *vma,
82648 */
82649
82650 /* Somebody else might have raced and expanded it already */
82651 - if (address < vma->vm_start) {
82652 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
82653 + error = -ENOMEM;
82654 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
82655 unsigned long size, grow;
82656
82657 +#ifdef CONFIG_PAX_SEGMEXEC
82658 + struct vm_area_struct *vma_m;
82659 +
82660 + vma_m = pax_find_mirror_vma(vma);
82661 +#endif
82662 +
82663 size = vma->vm_end - address;
82664 grow = (vma->vm_start - address) >> PAGE_SHIFT;
82665
82666 @@ -2184,6 +2492,18 @@ int expand_downwards(struct vm_area_struct *vma,
82667 vma->vm_pgoff -= grow;
82668 anon_vma_interval_tree_post_update_vma(vma);
82669 vma_gap_update(vma);
82670 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
82671 +
82672 +#ifdef CONFIG_PAX_SEGMEXEC
82673 + if (vma_m) {
82674 + anon_vma_interval_tree_pre_update_vma(vma_m);
82675 + vma_m->vm_start -= grow << PAGE_SHIFT;
82676 + vma_m->vm_pgoff -= grow;
82677 + anon_vma_interval_tree_post_update_vma(vma_m);
82678 + vma_gap_update(vma_m);
82679 + }
82680 +#endif
82681 +
82682 spin_unlock(&vma->vm_mm->page_table_lock);
82683
82684 perf_event_mmap(vma);
82685 @@ -2288,6 +2608,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
82686 do {
82687 long nrpages = vma_pages(vma);
82688
82689 +#ifdef CONFIG_PAX_SEGMEXEC
82690 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
82691 + vma = remove_vma(vma);
82692 + continue;
82693 + }
82694 +#endif
82695 +
82696 if (vma->vm_flags & VM_ACCOUNT)
82697 nr_accounted += nrpages;
82698 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
82699 @@ -2333,6 +2660,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
82700 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
82701 vma->vm_prev = NULL;
82702 do {
82703 +
82704 +#ifdef CONFIG_PAX_SEGMEXEC
82705 + if (vma->vm_mirror) {
82706 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
82707 + vma->vm_mirror->vm_mirror = NULL;
82708 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
82709 + vma->vm_mirror = NULL;
82710 + }
82711 +#endif
82712 +
82713 vma_rb_erase(vma, &mm->mm_rb);
82714 mm->map_count--;
82715 tail_vma = vma;
82716 @@ -2364,14 +2701,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82717 struct vm_area_struct *new;
82718 int err = -ENOMEM;
82719
82720 +#ifdef CONFIG_PAX_SEGMEXEC
82721 + struct vm_area_struct *vma_m, *new_m = NULL;
82722 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
82723 +#endif
82724 +
82725 if (is_vm_hugetlb_page(vma) && (addr &
82726 ~(huge_page_mask(hstate_vma(vma)))))
82727 return -EINVAL;
82728
82729 +#ifdef CONFIG_PAX_SEGMEXEC
82730 + vma_m = pax_find_mirror_vma(vma);
82731 +#endif
82732 +
82733 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82734 if (!new)
82735 goto out_err;
82736
82737 +#ifdef CONFIG_PAX_SEGMEXEC
82738 + if (vma_m) {
82739 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82740 + if (!new_m) {
82741 + kmem_cache_free(vm_area_cachep, new);
82742 + goto out_err;
82743 + }
82744 + }
82745 +#endif
82746 +
82747 /* most fields are the same, copy all, and then fixup */
82748 *new = *vma;
82749
82750 @@ -2384,6 +2740,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82751 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
82752 }
82753
82754 +#ifdef CONFIG_PAX_SEGMEXEC
82755 + if (vma_m) {
82756 + *new_m = *vma_m;
82757 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
82758 + new_m->vm_mirror = new;
82759 + new->vm_mirror = new_m;
82760 +
82761 + if (new_below)
82762 + new_m->vm_end = addr_m;
82763 + else {
82764 + new_m->vm_start = addr_m;
82765 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
82766 + }
82767 + }
82768 +#endif
82769 +
82770 pol = mpol_dup(vma_policy(vma));
82771 if (IS_ERR(pol)) {
82772 err = PTR_ERR(pol);
82773 @@ -2406,6 +2778,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82774 else
82775 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
82776
82777 +#ifdef CONFIG_PAX_SEGMEXEC
82778 + if (!err && vma_m) {
82779 + if (anon_vma_clone(new_m, vma_m))
82780 + goto out_free_mpol;
82781 +
82782 + mpol_get(pol);
82783 + vma_set_policy(new_m, pol);
82784 +
82785 + if (new_m->vm_file)
82786 + get_file(new_m->vm_file);
82787 +
82788 + if (new_m->vm_ops && new_m->vm_ops->open)
82789 + new_m->vm_ops->open(new_m);
82790 +
82791 + if (new_below)
82792 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
82793 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
82794 + else
82795 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
82796 +
82797 + if (err) {
82798 + if (new_m->vm_ops && new_m->vm_ops->close)
82799 + new_m->vm_ops->close(new_m);
82800 + if (new_m->vm_file)
82801 + fput(new_m->vm_file);
82802 + mpol_put(pol);
82803 + }
82804 + }
82805 +#endif
82806 +
82807 /* Success. */
82808 if (!err)
82809 return 0;
82810 @@ -2415,10 +2817,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82811 new->vm_ops->close(new);
82812 if (new->vm_file)
82813 fput(new->vm_file);
82814 - unlink_anon_vmas(new);
82815 out_free_mpol:
82816 mpol_put(pol);
82817 out_free_vma:
82818 +
82819 +#ifdef CONFIG_PAX_SEGMEXEC
82820 + if (new_m) {
82821 + unlink_anon_vmas(new_m);
82822 + kmem_cache_free(vm_area_cachep, new_m);
82823 + }
82824 +#endif
82825 +
82826 + unlink_anon_vmas(new);
82827 kmem_cache_free(vm_area_cachep, new);
82828 out_err:
82829 return err;
82830 @@ -2431,6 +2841,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82831 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82832 unsigned long addr, int new_below)
82833 {
82834 +
82835 +#ifdef CONFIG_PAX_SEGMEXEC
82836 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
82837 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
82838 + if (mm->map_count >= sysctl_max_map_count-1)
82839 + return -ENOMEM;
82840 + } else
82841 +#endif
82842 +
82843 if (mm->map_count >= sysctl_max_map_count)
82844 return -ENOMEM;
82845
82846 @@ -2442,11 +2861,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82847 * work. This now handles partial unmappings.
82848 * Jeremy Fitzhardinge <jeremy@goop.org>
82849 */
82850 +#ifdef CONFIG_PAX_SEGMEXEC
82851 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82852 {
82853 + int ret = __do_munmap(mm, start, len);
82854 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
82855 + return ret;
82856 +
82857 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
82858 +}
82859 +
82860 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82861 +#else
82862 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82863 +#endif
82864 +{
82865 unsigned long end;
82866 struct vm_area_struct *vma, *prev, *last;
82867
82868 + /*
82869 + * mm->mmap_sem is required to protect against another thread
82870 + * changing the mappings in case we sleep.
82871 + */
82872 + verify_mm_writelocked(mm);
82873 +
82874 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
82875 return -EINVAL;
82876
82877 @@ -2521,6 +2959,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82878 /* Fix up all other VM information */
82879 remove_vma_list(mm, vma);
82880
82881 + track_exec_limit(mm, start, end, 0UL);
82882 +
82883 return 0;
82884 }
82885
82886 @@ -2529,6 +2969,13 @@ int vm_munmap(unsigned long start, size_t len)
82887 int ret;
82888 struct mm_struct *mm = current->mm;
82889
82890 +
82891 +#ifdef CONFIG_PAX_SEGMEXEC
82892 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
82893 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
82894 + return -EINVAL;
82895 +#endif
82896 +
82897 down_write(&mm->mmap_sem);
82898 ret = do_munmap(mm, start, len);
82899 up_write(&mm->mmap_sem);
82900 @@ -2542,16 +2989,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
82901 return vm_munmap(addr, len);
82902 }
82903
82904 -static inline void verify_mm_writelocked(struct mm_struct *mm)
82905 -{
82906 -#ifdef CONFIG_DEBUG_VM
82907 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
82908 - WARN_ON(1);
82909 - up_read(&mm->mmap_sem);
82910 - }
82911 -#endif
82912 -}
82913 -
82914 /*
82915 * this is really a simplified "do_mmap". it only handles
82916 * anonymous maps. eventually we may be able to do some
82917 @@ -2565,6 +3002,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82918 struct rb_node ** rb_link, * rb_parent;
82919 pgoff_t pgoff = addr >> PAGE_SHIFT;
82920 int error;
82921 + unsigned long charged;
82922
82923 len = PAGE_ALIGN(len);
82924 if (!len)
82925 @@ -2572,16 +3010,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82926
82927 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
82928
82929 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
82930 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
82931 + flags &= ~VM_EXEC;
82932 +
82933 +#ifdef CONFIG_PAX_MPROTECT
82934 + if (mm->pax_flags & MF_PAX_MPROTECT)
82935 + flags &= ~VM_MAYEXEC;
82936 +#endif
82937 +
82938 + }
82939 +#endif
82940 +
82941 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
82942 if (error & ~PAGE_MASK)
82943 return error;
82944
82945 + charged = len >> PAGE_SHIFT;
82946 +
82947 /*
82948 * mlock MCL_FUTURE?
82949 */
82950 if (mm->def_flags & VM_LOCKED) {
82951 unsigned long locked, lock_limit;
82952 - locked = len >> PAGE_SHIFT;
82953 + locked = charged;
82954 locked += mm->locked_vm;
82955 lock_limit = rlimit(RLIMIT_MEMLOCK);
82956 lock_limit >>= PAGE_SHIFT;
82957 @@ -2598,21 +3050,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82958 /*
82959 * Clear old maps. this also does some error checking for us
82960 */
82961 - munmap_back:
82962 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82963 if (do_munmap(mm, addr, len))
82964 return -ENOMEM;
82965 - goto munmap_back;
82966 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82967 }
82968
82969 /* Check against address space limits *after* clearing old maps... */
82970 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
82971 + if (!may_expand_vm(mm, charged))
82972 return -ENOMEM;
82973
82974 if (mm->map_count > sysctl_max_map_count)
82975 return -ENOMEM;
82976
82977 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
82978 + if (security_vm_enough_memory_mm(mm, charged))
82979 return -ENOMEM;
82980
82981 /* Can we just expand an old private anonymous mapping? */
82982 @@ -2626,7 +3077,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82983 */
82984 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82985 if (!vma) {
82986 - vm_unacct_memory(len >> PAGE_SHIFT);
82987 + vm_unacct_memory(charged);
82988 return -ENOMEM;
82989 }
82990
82991 @@ -2640,9 +3091,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82992 vma_link(mm, vma, prev, rb_link, rb_parent);
82993 out:
82994 perf_event_mmap(vma);
82995 - mm->total_vm += len >> PAGE_SHIFT;
82996 + mm->total_vm += charged;
82997 if (flags & VM_LOCKED)
82998 - mm->locked_vm += (len >> PAGE_SHIFT);
82999 + mm->locked_vm += charged;
83000 + track_exec_limit(mm, addr, addr + len, flags);
83001 return addr;
83002 }
83003
83004 @@ -2704,6 +3156,7 @@ void exit_mmap(struct mm_struct *mm)
83005 while (vma) {
83006 if (vma->vm_flags & VM_ACCOUNT)
83007 nr_accounted += vma_pages(vma);
83008 + vma->vm_mirror = NULL;
83009 vma = remove_vma(vma);
83010 }
83011 vm_unacct_memory(nr_accounted);
83012 @@ -2720,6 +3173,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83013 struct vm_area_struct *prev;
83014 struct rb_node **rb_link, *rb_parent;
83015
83016 +#ifdef CONFIG_PAX_SEGMEXEC
83017 + struct vm_area_struct *vma_m = NULL;
83018 +#endif
83019 +
83020 + if (security_mmap_addr(vma->vm_start))
83021 + return -EPERM;
83022 +
83023 /*
83024 * The vm_pgoff of a purely anonymous vma should be irrelevant
83025 * until its first write fault, when page's anon_vma and index
83026 @@ -2743,7 +3203,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83027 security_vm_enough_memory_mm(mm, vma_pages(vma)))
83028 return -ENOMEM;
83029
83030 +#ifdef CONFIG_PAX_SEGMEXEC
83031 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
83032 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83033 + if (!vma_m)
83034 + return -ENOMEM;
83035 + }
83036 +#endif
83037 +
83038 vma_link(mm, vma, prev, rb_link, rb_parent);
83039 +
83040 +#ifdef CONFIG_PAX_SEGMEXEC
83041 + if (vma_m)
83042 + BUG_ON(pax_mirror_vma(vma_m, vma));
83043 +#endif
83044 +
83045 return 0;
83046 }
83047
83048 @@ -2763,6 +3237,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83049 struct mempolicy *pol;
83050 bool faulted_in_anon_vma = true;
83051
83052 + BUG_ON(vma->vm_mirror);
83053 +
83054 /*
83055 * If anonymous vma has not yet been faulted, update new pgoff
83056 * to match new location, to increase its chance of merging.
83057 @@ -2829,6 +3305,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83058 return NULL;
83059 }
83060
83061 +#ifdef CONFIG_PAX_SEGMEXEC
83062 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
83063 +{
83064 + struct vm_area_struct *prev_m;
83065 + struct rb_node **rb_link_m, *rb_parent_m;
83066 + struct mempolicy *pol_m;
83067 +
83068 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
83069 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
83070 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
83071 + *vma_m = *vma;
83072 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
83073 + if (anon_vma_clone(vma_m, vma))
83074 + return -ENOMEM;
83075 + pol_m = vma_policy(vma_m);
83076 + mpol_get(pol_m);
83077 + vma_set_policy(vma_m, pol_m);
83078 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
83079 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
83080 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
83081 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
83082 + if (vma_m->vm_file)
83083 + get_file(vma_m->vm_file);
83084 + if (vma_m->vm_ops && vma_m->vm_ops->open)
83085 + vma_m->vm_ops->open(vma_m);
83086 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
83087 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
83088 + vma_m->vm_mirror = vma;
83089 + vma->vm_mirror = vma_m;
83090 + return 0;
83091 +}
83092 +#endif
83093 +
83094 /*
83095 * Return true if the calling process may expand its vm space by the passed
83096 * number of pages
83097 @@ -2840,6 +3349,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
83098
83099 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
83100
83101 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
83102 if (cur + npages > lim)
83103 return 0;
83104 return 1;
83105 @@ -2910,6 +3420,22 @@ int install_special_mapping(struct mm_struct *mm,
83106 vma->vm_start = addr;
83107 vma->vm_end = addr + len;
83108
83109 +#ifdef CONFIG_PAX_MPROTECT
83110 + if (mm->pax_flags & MF_PAX_MPROTECT) {
83111 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
83112 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
83113 + return -EPERM;
83114 + if (!(vm_flags & VM_EXEC))
83115 + vm_flags &= ~VM_MAYEXEC;
83116 +#else
83117 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
83118 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
83119 +#endif
83120 + else
83121 + vm_flags &= ~VM_MAYWRITE;
83122 + }
83123 +#endif
83124 +
83125 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
83126 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
83127
83128 diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c
83129 index be04122..6725ff1 100644
83130 --- a/mm/mmu_notifier.c
83131 +++ b/mm/mmu_notifier.c
83132 @@ -40,48 +40,44 @@ void __mmu_notifier_release(struct mm_struct *mm)
83133 int id;
83134
83135 /*
83136 - * srcu_read_lock() here will block synchronize_srcu() in
83137 - * mmu_notifier_unregister() until all registered
83138 - * ->release() callouts this function makes have
83139 - * returned.
83140 + * SRCU here will block mmu_notifier_unregister until
83141 + * ->release returns.
83142 */
83143 id = srcu_read_lock(&srcu);
83144 + hlist_for_each_entry_rcu(mn, &mm->mmu_notifier_mm->list, hlist)
83145 + /*
83146 + * If ->release runs before mmu_notifier_unregister it must be
83147 + * handled, as it's the only way for the driver to flush all
83148 + * existing sptes and stop the driver from establishing any more
83149 + * sptes before all the pages in the mm are freed.
83150 + */
83151 + if (mn->ops->release)
83152 + mn->ops->release(mn, mm);
83153 + srcu_read_unlock(&srcu, id);
83154 +
83155 spin_lock(&mm->mmu_notifier_mm->lock);
83156 while (unlikely(!hlist_empty(&mm->mmu_notifier_mm->list))) {
83157 mn = hlist_entry(mm->mmu_notifier_mm->list.first,
83158 struct mmu_notifier,
83159 hlist);
83160 -
83161 /*
83162 - * Unlink. This will prevent mmu_notifier_unregister()
83163 - * from also making the ->release() callout.
83164 + * We arrived before mmu_notifier_unregister so
83165 + * mmu_notifier_unregister will do nothing other than to wait
83166 + * for ->release to finish and for mmu_notifier_unregister to
83167 + * return.
83168 */
83169 hlist_del_init_rcu(&mn->hlist);
83170 - spin_unlock(&mm->mmu_notifier_mm->lock);
83171 -
83172 - /*
83173 - * Clear sptes. (see 'release' description in mmu_notifier.h)
83174 - */
83175 - if (mn->ops->release)
83176 - mn->ops->release(mn, mm);
83177 -
83178 - spin_lock(&mm->mmu_notifier_mm->lock);
83179 }
83180 spin_unlock(&mm->mmu_notifier_mm->lock);
83181
83182 /*
83183 - * All callouts to ->release() which we have done are complete.
83184 - * Allow synchronize_srcu() in mmu_notifier_unregister() to complete
83185 - */
83186 - srcu_read_unlock(&srcu, id);
83187 -
83188 - /*
83189 - * mmu_notifier_unregister() may have unlinked a notifier and may
83190 - * still be calling out to it. Additionally, other notifiers
83191 - * may have been active via vmtruncate() et. al. Block here
83192 - * to ensure that all notifier callouts for this mm have been
83193 - * completed and the sptes are really cleaned up before returning
83194 - * to exit_mmap().
83195 + * synchronize_srcu here prevents mmu_notifier_release from returning to
83196 + * exit_mmap (which would proceed with freeing all pages in the mm)
83197 + * until the ->release method returns, if it was invoked by
83198 + * mmu_notifier_unregister.
83199 + *
83200 + * The mmu_notifier_mm can't go away from under us because one mm_count
83201 + * is held by exit_mmap.
83202 */
83203 synchronize_srcu(&srcu);
83204 }
83205 @@ -292,31 +288,34 @@ void mmu_notifier_unregister(struct mmu_notifier *mn, struct mm_struct *mm)
83206 {
83207 BUG_ON(atomic_read(&mm->mm_count) <= 0);
83208
83209 - spin_lock(&mm->mmu_notifier_mm->lock);
83210 if (!hlist_unhashed(&mn->hlist)) {
83211 + /*
83212 + * SRCU here will force exit_mmap to wait for ->release to
83213 + * finish before freeing the pages.
83214 + */
83215 int id;
83216
83217 - /*
83218 - * Ensure we synchronize up with __mmu_notifier_release().
83219 - */
83220 id = srcu_read_lock(&srcu);
83221 -
83222 - hlist_del_rcu(&mn->hlist);
83223 - spin_unlock(&mm->mmu_notifier_mm->lock);
83224 -
83225 - if (mn->ops->release)
83226 - mn->ops->release(mn, mm);
83227 -
83228 /*
83229 - * Allow __mmu_notifier_release() to complete.
83230 + * exit_mmap will block in mmu_notifier_release to guarantee
83231 + * that ->release is called before freeing the pages.
83232 */
83233 + if (mn->ops->release)
83234 + mn->ops->release(mn, mm);
83235 srcu_read_unlock(&srcu, id);
83236 - } else
83237 +
83238 + spin_lock(&mm->mmu_notifier_mm->lock);
83239 + /*
83240 + * Can not use list_del_rcu() since __mmu_notifier_release
83241 + * can delete it before we hold the lock.
83242 + */
83243 + hlist_del_init_rcu(&mn->hlist);
83244 spin_unlock(&mm->mmu_notifier_mm->lock);
83245 + }
83246
83247 /*
83248 - * Wait for any running method to finish, including ->release() if it
83249 - * was run by __mmu_notifier_release() instead of us.
83250 + * Wait for any running method to finish, of course including
83251 + * ->release if it was run by mmu_notifier_relase instead of us.
83252 */
83253 synchronize_srcu(&srcu);
83254
83255 diff --git a/mm/mprotect.c b/mm/mprotect.c
83256 index 94722a4..07d9926 100644
83257 --- a/mm/mprotect.c
83258 +++ b/mm/mprotect.c
83259 @@ -23,10 +23,18 @@
83260 #include <linux/mmu_notifier.h>
83261 #include <linux/migrate.h>
83262 #include <linux/perf_event.h>
83263 +#include <linux/sched/sysctl.h>
83264 +
83265 +#ifdef CONFIG_PAX_MPROTECT
83266 +#include <linux/elf.h>
83267 +#include <linux/binfmts.h>
83268 +#endif
83269 +
83270 #include <asm/uaccess.h>
83271 #include <asm/pgtable.h>
83272 #include <asm/cacheflush.h>
83273 #include <asm/tlbflush.h>
83274 +#include <asm/mmu_context.h>
83275
83276 #ifndef pgprot_modify
83277 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
83278 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
83279 return pages;
83280 }
83281
83282 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83283 +/* called while holding the mmap semaphor for writing except stack expansion */
83284 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
83285 +{
83286 + unsigned long oldlimit, newlimit = 0UL;
83287 +
83288 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
83289 + return;
83290 +
83291 + spin_lock(&mm->page_table_lock);
83292 + oldlimit = mm->context.user_cs_limit;
83293 + if ((prot & VM_EXEC) && oldlimit < end)
83294 + /* USER_CS limit moved up */
83295 + newlimit = end;
83296 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
83297 + /* USER_CS limit moved down */
83298 + newlimit = start;
83299 +
83300 + if (newlimit) {
83301 + mm->context.user_cs_limit = newlimit;
83302 +
83303 +#ifdef CONFIG_SMP
83304 + wmb();
83305 + cpus_clear(mm->context.cpu_user_cs_mask);
83306 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
83307 +#endif
83308 +
83309 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
83310 + }
83311 + spin_unlock(&mm->page_table_lock);
83312 + if (newlimit == end) {
83313 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
83314 +
83315 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
83316 + if (is_vm_hugetlb_page(vma))
83317 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
83318 + else
83319 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
83320 + }
83321 +}
83322 +#endif
83323 +
83324 int
83325 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83326 unsigned long start, unsigned long end, unsigned long newflags)
83327 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83328 int error;
83329 int dirty_accountable = 0;
83330
83331 +#ifdef CONFIG_PAX_SEGMEXEC
83332 + struct vm_area_struct *vma_m = NULL;
83333 + unsigned long start_m, end_m;
83334 +
83335 + start_m = start + SEGMEXEC_TASK_SIZE;
83336 + end_m = end + SEGMEXEC_TASK_SIZE;
83337 +#endif
83338 +
83339 if (newflags == oldflags) {
83340 *pprev = vma;
83341 return 0;
83342 }
83343
83344 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
83345 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
83346 +
83347 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
83348 + return -ENOMEM;
83349 +
83350 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
83351 + return -ENOMEM;
83352 + }
83353 +
83354 /*
83355 * If we make a private mapping writable we increase our commit;
83356 * but (without finer accounting) cannot reduce our commit if we
83357 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83358 }
83359 }
83360
83361 +#ifdef CONFIG_PAX_SEGMEXEC
83362 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
83363 + if (start != vma->vm_start) {
83364 + error = split_vma(mm, vma, start, 1);
83365 + if (error)
83366 + goto fail;
83367 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
83368 + *pprev = (*pprev)->vm_next;
83369 + }
83370 +
83371 + if (end != vma->vm_end) {
83372 + error = split_vma(mm, vma, end, 0);
83373 + if (error)
83374 + goto fail;
83375 + }
83376 +
83377 + if (pax_find_mirror_vma(vma)) {
83378 + error = __do_munmap(mm, start_m, end_m - start_m);
83379 + if (error)
83380 + goto fail;
83381 + } else {
83382 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83383 + if (!vma_m) {
83384 + error = -ENOMEM;
83385 + goto fail;
83386 + }
83387 + vma->vm_flags = newflags;
83388 + error = pax_mirror_vma(vma_m, vma);
83389 + if (error) {
83390 + vma->vm_flags = oldflags;
83391 + goto fail;
83392 + }
83393 + }
83394 + }
83395 +#endif
83396 +
83397 /*
83398 * First try to merge with previous and/or next vma.
83399 */
83400 @@ -296,9 +400,21 @@ success:
83401 * vm_flags and vm_page_prot are protected by the mmap_sem
83402 * held in write mode.
83403 */
83404 +
83405 +#ifdef CONFIG_PAX_SEGMEXEC
83406 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
83407 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
83408 +#endif
83409 +
83410 vma->vm_flags = newflags;
83411 +
83412 +#ifdef CONFIG_PAX_MPROTECT
83413 + if (mm->binfmt && mm->binfmt->handle_mprotect)
83414 + mm->binfmt->handle_mprotect(vma, newflags);
83415 +#endif
83416 +
83417 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
83418 - vm_get_page_prot(newflags));
83419 + vm_get_page_prot(vma->vm_flags));
83420
83421 if (vma_wants_writenotify(vma)) {
83422 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
83423 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83424 end = start + len;
83425 if (end <= start)
83426 return -ENOMEM;
83427 +
83428 +#ifdef CONFIG_PAX_SEGMEXEC
83429 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
83430 + if (end > SEGMEXEC_TASK_SIZE)
83431 + return -EINVAL;
83432 + } else
83433 +#endif
83434 +
83435 + if (end > TASK_SIZE)
83436 + return -EINVAL;
83437 +
83438 if (!arch_validate_prot(prot))
83439 return -EINVAL;
83440
83441 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83442 /*
83443 * Does the application expect PROT_READ to imply PROT_EXEC:
83444 */
83445 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
83446 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
83447 prot |= PROT_EXEC;
83448
83449 vm_flags = calc_vm_prot_bits(prot);
83450 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83451 if (start > vma->vm_start)
83452 prev = vma;
83453
83454 +#ifdef CONFIG_PAX_MPROTECT
83455 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
83456 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
83457 +#endif
83458 +
83459 for (nstart = start ; ; ) {
83460 unsigned long newflags;
83461
83462 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83463
83464 /* newflags >> 4 shift VM_MAY% in place of VM_% */
83465 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
83466 + if (prot & (PROT_WRITE | PROT_EXEC))
83467 + gr_log_rwxmprotect(vma->vm_file);
83468 +
83469 + error = -EACCES;
83470 + goto out;
83471 + }
83472 +
83473 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
83474 error = -EACCES;
83475 goto out;
83476 }
83477 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83478 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
83479 if (error)
83480 goto out;
83481 +
83482 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
83483 +
83484 nstart = tmp;
83485
83486 if (nstart < prev->vm_end)
83487 diff --git a/mm/mremap.c b/mm/mremap.c
83488 index 463a257..c0c7a92 100644
83489 --- a/mm/mremap.c
83490 +++ b/mm/mremap.c
83491 @@ -126,6 +126,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
83492 continue;
83493 pte = ptep_get_and_clear(mm, old_addr, old_pte);
83494 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
83495 +
83496 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83497 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
83498 + pte = pte_exprotect(pte);
83499 +#endif
83500 +
83501 set_pte_at(mm, new_addr, new_pte, pte);
83502 }
83503
83504 @@ -318,6 +324,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
83505 if (is_vm_hugetlb_page(vma))
83506 goto Einval;
83507
83508 +#ifdef CONFIG_PAX_SEGMEXEC
83509 + if (pax_find_mirror_vma(vma))
83510 + goto Einval;
83511 +#endif
83512 +
83513 /* We can't remap across vm area boundaries */
83514 if (old_len > vma->vm_end - addr)
83515 goto Efault;
83516 @@ -373,20 +384,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
83517 unsigned long ret = -EINVAL;
83518 unsigned long charged = 0;
83519 unsigned long map_flags;
83520 + unsigned long pax_task_size = TASK_SIZE;
83521
83522 if (new_addr & ~PAGE_MASK)
83523 goto out;
83524
83525 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
83526 +#ifdef CONFIG_PAX_SEGMEXEC
83527 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83528 + pax_task_size = SEGMEXEC_TASK_SIZE;
83529 +#endif
83530 +
83531 + pax_task_size -= PAGE_SIZE;
83532 +
83533 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
83534 goto out;
83535
83536 /* Check if the location we're moving into overlaps the
83537 * old location at all, and fail if it does.
83538 */
83539 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
83540 - goto out;
83541 -
83542 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
83543 + if (addr + old_len > new_addr && new_addr + new_len > addr)
83544 goto out;
83545
83546 ret = do_munmap(mm, new_addr, new_len);
83547 @@ -455,6 +471,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83548 unsigned long ret = -EINVAL;
83549 unsigned long charged = 0;
83550 bool locked = false;
83551 + unsigned long pax_task_size = TASK_SIZE;
83552
83553 down_write(&current->mm->mmap_sem);
83554
83555 @@ -475,6 +492,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83556 if (!new_len)
83557 goto out;
83558
83559 +#ifdef CONFIG_PAX_SEGMEXEC
83560 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83561 + pax_task_size = SEGMEXEC_TASK_SIZE;
83562 +#endif
83563 +
83564 + pax_task_size -= PAGE_SIZE;
83565 +
83566 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
83567 + old_len > pax_task_size || addr > pax_task_size-old_len)
83568 + goto out;
83569 +
83570 if (flags & MREMAP_FIXED) {
83571 if (flags & MREMAP_MAYMOVE)
83572 ret = mremap_to(addr, old_len, new_addr, new_len,
83573 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83574 new_addr = addr;
83575 }
83576 ret = addr;
83577 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
83578 goto out;
83579 }
83580 }
83581 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83582 goto out;
83583 }
83584
83585 + map_flags = vma->vm_flags;
83586 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
83587 + if (!(ret & ~PAGE_MASK)) {
83588 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
83589 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
83590 + }
83591 }
83592 out:
83593 if (ret & ~PAGE_MASK)
83594 diff --git a/mm/nommu.c b/mm/nommu.c
83595 index e001768..9b52b30 100644
83596 --- a/mm/nommu.c
83597 +++ b/mm/nommu.c
83598 @@ -63,7 +63,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
83599 int sysctl_overcommit_ratio = 50; /* default is 50% */
83600 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
83601 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
83602 -int heap_stack_gap = 0;
83603
83604 atomic_long_t mmap_pages_allocated;
83605
83606 @@ -841,15 +840,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
83607 EXPORT_SYMBOL(find_vma);
83608
83609 /*
83610 - * find a VMA
83611 - * - we don't extend stack VMAs under NOMMU conditions
83612 - */
83613 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
83614 -{
83615 - return find_vma(mm, addr);
83616 -}
83617 -
83618 -/*
83619 * expand a stack to a given address
83620 * - not supported under NOMMU conditions
83621 */
83622 @@ -1560,6 +1550,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83623
83624 /* most fields are the same, copy all, and then fixup */
83625 *new = *vma;
83626 + INIT_LIST_HEAD(&new->anon_vma_chain);
83627 *region = *vma->vm_region;
83628 new->vm_region = region;
83629
83630 @@ -1992,8 +1983,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
83631 }
83632 EXPORT_SYMBOL(generic_file_remap_pages);
83633
83634 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83635 - unsigned long addr, void *buf, int len, int write)
83636 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83637 + unsigned long addr, void *buf, size_t len, int write)
83638 {
83639 struct vm_area_struct *vma;
83640
83641 @@ -2034,8 +2025,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83642 *
83643 * The caller must hold a reference on @mm.
83644 */
83645 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83646 - void *buf, int len, int write)
83647 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
83648 + void *buf, size_t len, int write)
83649 {
83650 return __access_remote_vm(NULL, mm, addr, buf, len, write);
83651 }
83652 @@ -2044,7 +2035,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83653 * Access another process' address space.
83654 * - source/target buffer must be kernel space
83655 */
83656 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
83657 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
83658 {
83659 struct mm_struct *mm;
83660
83661 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
83662 index efe6814..64b4701 100644
83663 --- a/mm/page-writeback.c
83664 +++ b/mm/page-writeback.c
83665 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
83666 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
83667 * - the bdi dirty thresh drops quickly due to change of JBOD workload
83668 */
83669 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
83670 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
83671 unsigned long thresh,
83672 unsigned long bg_thresh,
83673 unsigned long dirty,
83674 @@ -1634,7 +1634,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
83675 }
83676 }
83677
83678 -static struct notifier_block __cpuinitdata ratelimit_nb = {
83679 +static struct notifier_block ratelimit_nb = {
83680 .notifier_call = ratelimit_handler,
83681 .next = NULL,
83682 };
83683 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
83684 index 8fcced7..ebcd481 100644
83685 --- a/mm/page_alloc.c
83686 +++ b/mm/page_alloc.c
83687 @@ -59,6 +59,7 @@
83688 #include <linux/migrate.h>
83689 #include <linux/page-debug-flags.h>
83690 #include <linux/sched/rt.h>
83691 +#include <linux/random.h>
83692
83693 #include <asm/tlbflush.h>
83694 #include <asm/div64.h>
83695 @@ -344,7 +345,7 @@ out:
83696 * This usage means that zero-order pages may not be compound.
83697 */
83698
83699 -static void free_compound_page(struct page *page)
83700 +void free_compound_page(struct page *page)
83701 {
83702 __free_pages_ok(page, compound_order(page));
83703 }
83704 @@ -701,6 +702,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83705 int i;
83706 int bad = 0;
83707
83708 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83709 + unsigned long index = 1UL << order;
83710 +#endif
83711 +
83712 trace_mm_page_free(page, order);
83713 kmemcheck_free_shadow(page, order);
83714
83715 @@ -716,6 +721,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83716 debug_check_no_obj_freed(page_address(page),
83717 PAGE_SIZE << order);
83718 }
83719 +
83720 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83721 + for (; index; --index)
83722 + sanitize_highpage(page + index - 1);
83723 +#endif
83724 +
83725 arch_free_page(page, order);
83726 kernel_map_pages(page, 1 << order, 0);
83727
83728 @@ -738,6 +749,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
83729 local_irq_restore(flags);
83730 }
83731
83732 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83733 +bool __meminitdata extra_latent_entropy;
83734 +
83735 +static int __init setup_pax_extra_latent_entropy(char *str)
83736 +{
83737 + extra_latent_entropy = true;
83738 + return 0;
83739 +}
83740 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
83741 +
83742 +volatile u64 latent_entropy;
83743 +#endif
83744 +
83745 /*
83746 * Read access to zone->managed_pages is safe because it's unsigned long,
83747 * but we still need to serialize writers. Currently all callers of
83748 @@ -760,6 +784,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
83749 set_page_count(p, 0);
83750 }
83751
83752 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83753 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
83754 + u64 hash = 0;
83755 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
83756 + const u64 *data = lowmem_page_address(page);
83757 +
83758 + for (index = 0; index < end; index++)
83759 + hash ^= hash + data[index];
83760 + latent_entropy ^= hash;
83761 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
83762 + }
83763 +#endif
83764 +
83765 page_zone(page)->managed_pages += 1 << order;
83766 set_page_refcounted(page);
83767 __free_pages(page, order);
83768 @@ -869,8 +906,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
83769 arch_alloc_page(page, order);
83770 kernel_map_pages(page, 1 << order, 1);
83771
83772 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
83773 if (gfp_flags & __GFP_ZERO)
83774 prep_zero_page(page, order, gfp_flags);
83775 +#endif
83776
83777 if (order && (gfp_flags & __GFP_COMP))
83778 prep_compound_page(page, order);
83779 diff --git a/mm/page_io.c b/mm/page_io.c
83780 index 6182870..4bba6a2 100644
83781 --- a/mm/page_io.c
83782 +++ b/mm/page_io.c
83783 @@ -205,7 +205,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
83784 struct file *swap_file = sis->swap_file;
83785 struct address_space *mapping = swap_file->f_mapping;
83786 struct iovec iov = {
83787 - .iov_base = kmap(page),
83788 + .iov_base = (void __force_user *)kmap(page),
83789 .iov_len = PAGE_SIZE,
83790 };
83791
83792 diff --git a/mm/percpu.c b/mm/percpu.c
83793 index 8c8e08f..73a5cda 100644
83794 --- a/mm/percpu.c
83795 +++ b/mm/percpu.c
83796 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
83797 static unsigned int pcpu_high_unit_cpu __read_mostly;
83798
83799 /* the address of the first chunk which starts with the kernel static area */
83800 -void *pcpu_base_addr __read_mostly;
83801 +void *pcpu_base_addr __read_only;
83802 EXPORT_SYMBOL_GPL(pcpu_base_addr);
83803
83804 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
83805 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
83806 index fd26d04..0cea1b0 100644
83807 --- a/mm/process_vm_access.c
83808 +++ b/mm/process_vm_access.c
83809 @@ -13,6 +13,7 @@
83810 #include <linux/uio.h>
83811 #include <linux/sched.h>
83812 #include <linux/highmem.h>
83813 +#include <linux/security.h>
83814 #include <linux/ptrace.h>
83815 #include <linux/slab.h>
83816 #include <linux/syscalls.h>
83817 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83818 size_t iov_l_curr_offset = 0;
83819 ssize_t iov_len;
83820
83821 + return -ENOSYS; // PaX: until properly audited
83822 +
83823 /*
83824 * Work out how many pages of struct pages we're going to need
83825 * when eventually calling get_user_pages
83826 */
83827 for (i = 0; i < riovcnt; i++) {
83828 iov_len = rvec[i].iov_len;
83829 - if (iov_len > 0) {
83830 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
83831 - + iov_len)
83832 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
83833 - / PAGE_SIZE + 1;
83834 - nr_pages = max(nr_pages, nr_pages_iov);
83835 - }
83836 + if (iov_len <= 0)
83837 + continue;
83838 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
83839 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
83840 + nr_pages = max(nr_pages, nr_pages_iov);
83841 }
83842
83843 if (nr_pages == 0)
83844 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83845 goto free_proc_pages;
83846 }
83847
83848 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
83849 + rc = -EPERM;
83850 + goto put_task_struct;
83851 + }
83852 +
83853 mm = mm_access(task, PTRACE_MODE_ATTACH);
83854 if (!mm || IS_ERR(mm)) {
83855 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
83856 diff --git a/mm/rmap.c b/mm/rmap.c
83857 index 807c96b..0e05279 100644
83858 --- a/mm/rmap.c
83859 +++ b/mm/rmap.c
83860 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83861 struct anon_vma *anon_vma = vma->anon_vma;
83862 struct anon_vma_chain *avc;
83863
83864 +#ifdef CONFIG_PAX_SEGMEXEC
83865 + struct anon_vma_chain *avc_m = NULL;
83866 +#endif
83867 +
83868 might_sleep();
83869 if (unlikely(!anon_vma)) {
83870 struct mm_struct *mm = vma->vm_mm;
83871 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83872 if (!avc)
83873 goto out_enomem;
83874
83875 +#ifdef CONFIG_PAX_SEGMEXEC
83876 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
83877 + if (!avc_m)
83878 + goto out_enomem_free_avc;
83879 +#endif
83880 +
83881 anon_vma = find_mergeable_anon_vma(vma);
83882 allocated = NULL;
83883 if (!anon_vma) {
83884 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83885 /* page_table_lock to protect against threads */
83886 spin_lock(&mm->page_table_lock);
83887 if (likely(!vma->anon_vma)) {
83888 +
83889 +#ifdef CONFIG_PAX_SEGMEXEC
83890 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
83891 +
83892 + if (vma_m) {
83893 + BUG_ON(vma_m->anon_vma);
83894 + vma_m->anon_vma = anon_vma;
83895 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
83896 + avc_m = NULL;
83897 + }
83898 +#endif
83899 +
83900 vma->anon_vma = anon_vma;
83901 anon_vma_chain_link(vma, avc, anon_vma);
83902 allocated = NULL;
83903 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83904
83905 if (unlikely(allocated))
83906 put_anon_vma(allocated);
83907 +
83908 +#ifdef CONFIG_PAX_SEGMEXEC
83909 + if (unlikely(avc_m))
83910 + anon_vma_chain_free(avc_m);
83911 +#endif
83912 +
83913 if (unlikely(avc))
83914 anon_vma_chain_free(avc);
83915 }
83916 return 0;
83917
83918 out_enomem_free_avc:
83919 +
83920 +#ifdef CONFIG_PAX_SEGMEXEC
83921 + if (avc_m)
83922 + anon_vma_chain_free(avc_m);
83923 +#endif
83924 +
83925 anon_vma_chain_free(avc);
83926 out_enomem:
83927 return -ENOMEM;
83928 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
83929 * Attach the anon_vmas from src to dst.
83930 * Returns 0 on success, -ENOMEM on failure.
83931 */
83932 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
83933 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
83934 {
83935 struct anon_vma_chain *avc, *pavc;
83936 struct anon_vma *root = NULL;
83937 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
83938 * the corresponding VMA in the parent process is attached to.
83939 * Returns 0 on success, non-zero on failure.
83940 */
83941 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
83942 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
83943 {
83944 struct anon_vma_chain *avc;
83945 struct anon_vma *anon_vma;
83946 diff --git a/mm/shmem.c b/mm/shmem.c
83947 index 1c44af7..cefe9a6 100644
83948 --- a/mm/shmem.c
83949 +++ b/mm/shmem.c
83950 @@ -31,7 +31,7 @@
83951 #include <linux/export.h>
83952 #include <linux/swap.h>
83953
83954 -static struct vfsmount *shm_mnt;
83955 +struct vfsmount *shm_mnt;
83956
83957 #ifdef CONFIG_SHMEM
83958 /*
83959 @@ -75,7 +75,7 @@ static struct vfsmount *shm_mnt;
83960 #define BOGO_DIRENT_SIZE 20
83961
83962 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
83963 -#define SHORT_SYMLINK_LEN 128
83964 +#define SHORT_SYMLINK_LEN 64
83965
83966 /*
83967 * shmem_fallocate and shmem_writepage communicate via inode->i_private
83968 @@ -2201,6 +2201,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
83969 static int shmem_xattr_validate(const char *name)
83970 {
83971 struct { const char *prefix; size_t len; } arr[] = {
83972 +
83973 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
83974 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
83975 +#endif
83976 +
83977 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
83978 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
83979 };
83980 @@ -2256,6 +2261,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
83981 if (err)
83982 return err;
83983
83984 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
83985 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
83986 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
83987 + return -EOPNOTSUPP;
83988 + if (size > 8)
83989 + return -EINVAL;
83990 + }
83991 +#endif
83992 +
83993 return simple_xattr_set(&info->xattrs, name, value, size, flags);
83994 }
83995
83996 @@ -2568,8 +2582,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
83997 int err = -ENOMEM;
83998
83999 /* Round up to L1_CACHE_BYTES to resist false sharing */
84000 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
84001 - L1_CACHE_BYTES), GFP_KERNEL);
84002 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
84003 if (!sbinfo)
84004 return -ENOMEM;
84005
84006 diff --git a/mm/slab.c b/mm/slab.c
84007 index 856e4a1..fafb820 100644
84008 --- a/mm/slab.c
84009 +++ b/mm/slab.c
84010 @@ -306,7 +306,7 @@ struct kmem_list3 {
84011 * Need this for bootstrapping a per node allocator.
84012 */
84013 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
84014 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
84015 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
84016 #define CACHE_CACHE 0
84017 #define SIZE_AC MAX_NUMNODES
84018 #define SIZE_L3 (2 * MAX_NUMNODES)
84019 @@ -407,10 +407,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
84020 if ((x)->max_freeable < i) \
84021 (x)->max_freeable = i; \
84022 } while (0)
84023 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
84024 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
84025 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
84026 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
84027 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
84028 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
84029 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
84030 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
84031 #else
84032 #define STATS_INC_ACTIVE(x) do { } while (0)
84033 #define STATS_DEC_ACTIVE(x) do { } while (0)
84034 @@ -518,7 +518,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
84035 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
84036 */
84037 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
84038 - const struct slab *slab, void *obj)
84039 + const struct slab *slab, const void *obj)
84040 {
84041 u32 offset = (obj - slab->s_mem);
84042 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
84043 @@ -539,12 +539,13 @@ EXPORT_SYMBOL(malloc_sizes);
84044 struct cache_names {
84045 char *name;
84046 char *name_dma;
84047 + char *name_usercopy;
84048 };
84049
84050 static struct cache_names __initdata cache_names[] = {
84051 -#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
84052 +#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)", .name_usercopy = "size-" #x "(USERCOPY)" },
84053 #include <linux/kmalloc_sizes.h>
84054 - {NULL,}
84055 + {NULL}
84056 #undef CACHE
84057 };
84058
84059 @@ -729,6 +730,12 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
84060 if (unlikely(gfpflags & GFP_DMA))
84061 return csizep->cs_dmacachep;
84062 #endif
84063 +
84064 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84065 + if (unlikely(gfpflags & GFP_USERCOPY))
84066 + return csizep->cs_usercopycachep;
84067 +#endif
84068 +
84069 return csizep->cs_cachep;
84070 }
84071
84072 @@ -1482,7 +1489,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
84073 return notifier_from_errno(err);
84074 }
84075
84076 -static struct notifier_block __cpuinitdata cpucache_notifier = {
84077 +static struct notifier_block cpucache_notifier = {
84078 &cpuup_callback, NULL, 0
84079 };
84080
84081 @@ -1667,12 +1674,12 @@ void __init kmem_cache_init(void)
84082 */
84083
84084 sizes[INDEX_AC].cs_cachep = create_kmalloc_cache(names[INDEX_AC].name,
84085 - sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS);
84086 + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84087
84088 if (INDEX_AC != INDEX_L3)
84089 sizes[INDEX_L3].cs_cachep =
84090 create_kmalloc_cache(names[INDEX_L3].name,
84091 - sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS);
84092 + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84093
84094 slab_early_init = 0;
84095
84096 @@ -1686,13 +1693,20 @@ void __init kmem_cache_init(void)
84097 */
84098 if (!sizes->cs_cachep)
84099 sizes->cs_cachep = create_kmalloc_cache(names->name,
84100 - sizes->cs_size, ARCH_KMALLOC_FLAGS);
84101 + sizes->cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84102
84103 #ifdef CONFIG_ZONE_DMA
84104 sizes->cs_dmacachep = create_kmalloc_cache(
84105 names->name_dma, sizes->cs_size,
84106 SLAB_CACHE_DMA|ARCH_KMALLOC_FLAGS);
84107 #endif
84108 +
84109 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84110 + sizes->cs_usercopycachep = create_kmalloc_cache(
84111 + names->name_usercopy, sizes->cs_size,
84112 + ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84113 +#endif
84114 +
84115 sizes++;
84116 names++;
84117 }
84118 @@ -3924,6 +3938,7 @@ void kfree(const void *objp)
84119
84120 if (unlikely(ZERO_OR_NULL_PTR(objp)))
84121 return;
84122 + VM_BUG_ON(!virt_addr_valid(objp));
84123 local_irq_save(flags);
84124 kfree_debugcheck(objp);
84125 c = virt_to_cache(objp);
84126 @@ -4365,10 +4380,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
84127 }
84128 /* cpu stats */
84129 {
84130 - unsigned long allochit = atomic_read(&cachep->allochit);
84131 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
84132 - unsigned long freehit = atomic_read(&cachep->freehit);
84133 - unsigned long freemiss = atomic_read(&cachep->freemiss);
84134 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
84135 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
84136 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
84137 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
84138
84139 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
84140 allochit, allocmiss, freehit, freemiss);
84141 @@ -4600,13 +4615,71 @@ static const struct file_operations proc_slabstats_operations = {
84142 static int __init slab_proc_init(void)
84143 {
84144 #ifdef CONFIG_DEBUG_SLAB_LEAK
84145 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
84146 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
84147 #endif
84148 return 0;
84149 }
84150 module_init(slab_proc_init);
84151 #endif
84152
84153 +bool is_usercopy_object(const void *ptr)
84154 +{
84155 + struct page *page;
84156 + struct kmem_cache *cachep;
84157 +
84158 + if (ZERO_OR_NULL_PTR(ptr))
84159 + return false;
84160 +
84161 + if (!slab_is_available())
84162 + return false;
84163 +
84164 + if (!virt_addr_valid(ptr))
84165 + return false;
84166 +
84167 + page = virt_to_head_page(ptr);
84168 +
84169 + if (!PageSlab(page))
84170 + return false;
84171 +
84172 + cachep = page->slab_cache;
84173 + return cachep->flags & SLAB_USERCOPY;
84174 +}
84175 +
84176 +#ifdef CONFIG_PAX_USERCOPY
84177 +const char *check_heap_object(const void *ptr, unsigned long n)
84178 +{
84179 + struct page *page;
84180 + struct kmem_cache *cachep;
84181 + struct slab *slabp;
84182 + unsigned int objnr;
84183 + unsigned long offset;
84184 +
84185 + if (ZERO_OR_NULL_PTR(ptr))
84186 + return "<null>";
84187 +
84188 + if (!virt_addr_valid(ptr))
84189 + return NULL;
84190 +
84191 + page = virt_to_head_page(ptr);
84192 +
84193 + if (!PageSlab(page))
84194 + return NULL;
84195 +
84196 + cachep = page->slab_cache;
84197 + if (!(cachep->flags & SLAB_USERCOPY))
84198 + return cachep->name;
84199 +
84200 + slabp = page->slab_page;
84201 + objnr = obj_to_index(cachep, slabp, ptr);
84202 + BUG_ON(objnr >= cachep->num);
84203 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
84204 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
84205 + return NULL;
84206 +
84207 + return cachep->name;
84208 +}
84209 +#endif
84210 +
84211 /**
84212 * ksize - get the actual amount of memory allocated for a given object
84213 * @objp: Pointer to the object
84214 diff --git a/mm/slab.h b/mm/slab.h
84215 index 34a98d6..73633d1 100644
84216 --- a/mm/slab.h
84217 +++ b/mm/slab.h
84218 @@ -58,7 +58,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84219
84220 /* Legal flag mask for kmem_cache_create(), for various configurations */
84221 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
84222 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
84223 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
84224
84225 #if defined(CONFIG_DEBUG_SLAB)
84226 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
84227 @@ -220,6 +220,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
84228 return s;
84229
84230 page = virt_to_head_page(x);
84231 +
84232 + BUG_ON(!PageSlab(page));
84233 +
84234 cachep = page->slab_cache;
84235 if (slab_equal_or_root(cachep, s))
84236 return cachep;
84237 diff --git a/mm/slab_common.c b/mm/slab_common.c
84238 index 3f3cd97..93b0236 100644
84239 --- a/mm/slab_common.c
84240 +++ b/mm/slab_common.c
84241 @@ -22,7 +22,7 @@
84242
84243 #include "slab.h"
84244
84245 -enum slab_state slab_state;
84246 +enum slab_state slab_state __read_only;
84247 LIST_HEAD(slab_caches);
84248 DEFINE_MUTEX(slab_mutex);
84249 struct kmem_cache *kmem_cache;
84250 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
84251
84252 err = __kmem_cache_create(s, flags);
84253 if (!err) {
84254 - s->refcount = 1;
84255 + atomic_set(&s->refcount, 1);
84256 list_add(&s->list, &slab_caches);
84257 memcg_cache_list_add(memcg, s);
84258 } else {
84259 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
84260
84261 get_online_cpus();
84262 mutex_lock(&slab_mutex);
84263 - s->refcount--;
84264 - if (!s->refcount) {
84265 + if (atomic_dec_and_test(&s->refcount)) {
84266 list_del(&s->list);
84267
84268 if (!__kmem_cache_shutdown(s)) {
84269 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
84270 panic("Creation of kmalloc slab %s size=%zd failed. Reason %d\n",
84271 name, size, err);
84272
84273 - s->refcount = -1; /* Exempt from merging for now */
84274 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
84275 }
84276
84277 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84278 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84279
84280 create_boot_cache(s, name, size, flags);
84281 list_add(&s->list, &slab_caches);
84282 - s->refcount = 1;
84283 + atomic_set(&s->refcount, 1);
84284 return s;
84285 }
84286
84287 diff --git a/mm/slob.c b/mm/slob.c
84288 index eeed4a0..6ee34ec 100644
84289 --- a/mm/slob.c
84290 +++ b/mm/slob.c
84291 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
84292 /*
84293 * Return the size of a slob block.
84294 */
84295 -static slobidx_t slob_units(slob_t *s)
84296 +static slobidx_t slob_units(const slob_t *s)
84297 {
84298 if (s->units > 0)
84299 return s->units;
84300 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
84301 /*
84302 * Return the next free slob block pointer after this one.
84303 */
84304 -static slob_t *slob_next(slob_t *s)
84305 +static slob_t *slob_next(const slob_t *s)
84306 {
84307 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
84308 slobidx_t next;
84309 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
84310 /*
84311 * Returns true if s is the last free block in its page.
84312 */
84313 -static int slob_last(slob_t *s)
84314 +static int slob_last(const slob_t *s)
84315 {
84316 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
84317 }
84318
84319 -static void *slob_new_pages(gfp_t gfp, int order, int node)
84320 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
84321 {
84322 - void *page;
84323 + struct page *page;
84324
84325 #ifdef CONFIG_NUMA
84326 if (node != NUMA_NO_NODE)
84327 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
84328 if (!page)
84329 return NULL;
84330
84331 - return page_address(page);
84332 + __SetPageSlab(page);
84333 + return page;
84334 }
84335
84336 -static void slob_free_pages(void *b, int order)
84337 +static void slob_free_pages(struct page *sp, int order)
84338 {
84339 if (current->reclaim_state)
84340 current->reclaim_state->reclaimed_slab += 1 << order;
84341 - free_pages((unsigned long)b, order);
84342 + __ClearPageSlab(sp);
84343 + reset_page_mapcount(sp);
84344 + sp->private = 0;
84345 + __free_pages(sp, order);
84346 }
84347
84348 /*
84349 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
84350
84351 /* Not enough space: must allocate a new page */
84352 if (!b) {
84353 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84354 - if (!b)
84355 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84356 + if (!sp)
84357 return NULL;
84358 - sp = virt_to_page(b);
84359 - __SetPageSlab(sp);
84360 + b = page_address(sp);
84361
84362 spin_lock_irqsave(&slob_lock, flags);
84363 sp->units = SLOB_UNITS(PAGE_SIZE);
84364 sp->freelist = b;
84365 + sp->private = 0;
84366 INIT_LIST_HEAD(&sp->list);
84367 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
84368 set_slob_page_free(sp, slob_list);
84369 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
84370 if (slob_page_free(sp))
84371 clear_slob_page_free(sp);
84372 spin_unlock_irqrestore(&slob_lock, flags);
84373 - __ClearPageSlab(sp);
84374 - page_mapcount_reset(sp);
84375 - slob_free_pages(b, 0);
84376 + slob_free_pages(sp, 0);
84377 return;
84378 }
84379
84380 @@ -424,11 +426,10 @@ out:
84381 */
84382
84383 static __always_inline void *
84384 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84385 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
84386 {
84387 - unsigned int *m;
84388 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84389 - void *ret;
84390 + slob_t *m;
84391 + void *ret = NULL;
84392
84393 gfp &= gfp_allowed_mask;
84394
84395 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84396
84397 if (!m)
84398 return NULL;
84399 - *m = size;
84400 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
84401 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
84402 + m[0].units = size;
84403 + m[1].units = align;
84404 ret = (void *)m + align;
84405
84406 trace_kmalloc_node(caller, ret,
84407 size, size + align, gfp, node);
84408 } else {
84409 unsigned int order = get_order(size);
84410 + struct page *page;
84411
84412 if (likely(order))
84413 gfp |= __GFP_COMP;
84414 - ret = slob_new_pages(gfp, order, node);
84415 + page = slob_new_pages(gfp, order, node);
84416 + if (page) {
84417 + ret = page_address(page);
84418 + page->private = size;
84419 + }
84420
84421 trace_kmalloc_node(caller, ret,
84422 size, PAGE_SIZE << order, gfp, node);
84423 }
84424
84425 - kmemleak_alloc(ret, size, 1, gfp);
84426 + return ret;
84427 +}
84428 +
84429 +static __always_inline void *
84430 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84431 +{
84432 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84433 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
84434 +
84435 + if (!ZERO_OR_NULL_PTR(ret))
84436 + kmemleak_alloc(ret, size, 1, gfp);
84437 return ret;
84438 }
84439
84440 @@ -493,34 +512,112 @@ void kfree(const void *block)
84441 return;
84442 kmemleak_free(block);
84443
84444 + VM_BUG_ON(!virt_addr_valid(block));
84445 sp = virt_to_page(block);
84446 - if (PageSlab(sp)) {
84447 + VM_BUG_ON(!PageSlab(sp));
84448 + if (!sp->private) {
84449 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84450 - unsigned int *m = (unsigned int *)(block - align);
84451 - slob_free(m, *m + align);
84452 - } else
84453 + slob_t *m = (slob_t *)(block - align);
84454 + slob_free(m, m[0].units + align);
84455 + } else {
84456 + __ClearPageSlab(sp);
84457 + reset_page_mapcount(sp);
84458 + sp->private = 0;
84459 __free_pages(sp, compound_order(sp));
84460 + }
84461 }
84462 EXPORT_SYMBOL(kfree);
84463
84464 +bool is_usercopy_object(const void *ptr)
84465 +{
84466 + if (!slab_is_available())
84467 + return false;
84468 +
84469 + // PAX: TODO
84470 +
84471 + return false;
84472 +}
84473 +
84474 +#ifdef CONFIG_PAX_USERCOPY
84475 +const char *check_heap_object(const void *ptr, unsigned long n)
84476 +{
84477 + struct page *page;
84478 + const slob_t *free;
84479 + const void *base;
84480 + unsigned long flags;
84481 +
84482 + if (ZERO_OR_NULL_PTR(ptr))
84483 + return "<null>";
84484 +
84485 + if (!virt_addr_valid(ptr))
84486 + return NULL;
84487 +
84488 + page = virt_to_head_page(ptr);
84489 + if (!PageSlab(page))
84490 + return NULL;
84491 +
84492 + if (page->private) {
84493 + base = page;
84494 + if (base <= ptr && n <= page->private - (ptr - base))
84495 + return NULL;
84496 + return "<slob>";
84497 + }
84498 +
84499 + /* some tricky double walking to find the chunk */
84500 + spin_lock_irqsave(&slob_lock, flags);
84501 + base = (void *)((unsigned long)ptr & PAGE_MASK);
84502 + free = page->freelist;
84503 +
84504 + while (!slob_last(free) && (void *)free <= ptr) {
84505 + base = free + slob_units(free);
84506 + free = slob_next(free);
84507 + }
84508 +
84509 + while (base < (void *)free) {
84510 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
84511 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
84512 + int offset;
84513 +
84514 + if (ptr < base + align)
84515 + break;
84516 +
84517 + offset = ptr - base - align;
84518 + if (offset >= m) {
84519 + base += size;
84520 + continue;
84521 + }
84522 +
84523 + if (n > m - offset)
84524 + break;
84525 +
84526 + spin_unlock_irqrestore(&slob_lock, flags);
84527 + return NULL;
84528 + }
84529 +
84530 + spin_unlock_irqrestore(&slob_lock, flags);
84531 + return "<slob>";
84532 +}
84533 +#endif
84534 +
84535 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
84536 size_t ksize(const void *block)
84537 {
84538 struct page *sp;
84539 int align;
84540 - unsigned int *m;
84541 + slob_t *m;
84542
84543 BUG_ON(!block);
84544 if (unlikely(block == ZERO_SIZE_PTR))
84545 return 0;
84546
84547 sp = virt_to_page(block);
84548 - if (unlikely(!PageSlab(sp)))
84549 - return PAGE_SIZE << compound_order(sp);
84550 + VM_BUG_ON(!PageSlab(sp));
84551 + if (sp->private)
84552 + return sp->private;
84553
84554 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84555 - m = (unsigned int *)(block - align);
84556 - return SLOB_UNITS(*m) * SLOB_UNIT;
84557 + m = (slob_t *)(block - align);
84558 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
84559 }
84560 EXPORT_SYMBOL(ksize);
84561
84562 @@ -536,23 +633,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
84563
84564 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
84565 {
84566 - void *b;
84567 + void *b = NULL;
84568
84569 flags &= gfp_allowed_mask;
84570
84571 lockdep_trace_alloc(flags);
84572
84573 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84574 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
84575 +#else
84576 if (c->size < PAGE_SIZE) {
84577 b = slob_alloc(c->size, flags, c->align, node);
84578 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84579 SLOB_UNITS(c->size) * SLOB_UNIT,
84580 flags, node);
84581 } else {
84582 - b = slob_new_pages(flags, get_order(c->size), node);
84583 + struct page *sp;
84584 +
84585 + sp = slob_new_pages(flags, get_order(c->size), node);
84586 + if (sp) {
84587 + b = page_address(sp);
84588 + sp->private = c->size;
84589 + }
84590 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84591 PAGE_SIZE << get_order(c->size),
84592 flags, node);
84593 }
84594 +#endif
84595
84596 if (c->ctor)
84597 c->ctor(b);
84598 @@ -564,10 +671,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
84599
84600 static void __kmem_cache_free(void *b, int size)
84601 {
84602 - if (size < PAGE_SIZE)
84603 + struct page *sp;
84604 +
84605 + sp = virt_to_page(b);
84606 + BUG_ON(!PageSlab(sp));
84607 + if (!sp->private)
84608 slob_free(b, size);
84609 else
84610 - slob_free_pages(b, get_order(size));
84611 + slob_free_pages(sp, get_order(size));
84612 }
84613
84614 static void kmem_rcu_free(struct rcu_head *head)
84615 @@ -580,17 +691,31 @@ static void kmem_rcu_free(struct rcu_head *head)
84616
84617 void kmem_cache_free(struct kmem_cache *c, void *b)
84618 {
84619 + int size = c->size;
84620 +
84621 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84622 + if (size + c->align < PAGE_SIZE) {
84623 + size += c->align;
84624 + b -= c->align;
84625 + }
84626 +#endif
84627 +
84628 kmemleak_free_recursive(b, c->flags);
84629 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
84630 struct slob_rcu *slob_rcu;
84631 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
84632 - slob_rcu->size = c->size;
84633 + slob_rcu = b + (size - sizeof(struct slob_rcu));
84634 + slob_rcu->size = size;
84635 call_rcu(&slob_rcu->head, kmem_rcu_free);
84636 } else {
84637 - __kmem_cache_free(b, c->size);
84638 + __kmem_cache_free(b, size);
84639 }
84640
84641 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84642 + trace_kfree(_RET_IP_, b);
84643 +#else
84644 trace_kmem_cache_free(_RET_IP_, b);
84645 +#endif
84646 +
84647 }
84648 EXPORT_SYMBOL(kmem_cache_free);
84649
84650 diff --git a/mm/slub.c b/mm/slub.c
84651 index 4aec537..a64753d 100644
84652 --- a/mm/slub.c
84653 +++ b/mm/slub.c
84654 @@ -197,7 +197,7 @@ struct track {
84655
84656 enum track_item { TRACK_ALLOC, TRACK_FREE };
84657
84658 -#ifdef CONFIG_SYSFS
84659 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84660 static int sysfs_slab_add(struct kmem_cache *);
84661 static int sysfs_slab_alias(struct kmem_cache *, const char *);
84662 static void sysfs_slab_remove(struct kmem_cache *);
84663 @@ -518,7 +518,7 @@ static void print_track(const char *s, struct track *t)
84664 if (!t->addr)
84665 return;
84666
84667 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
84668 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
84669 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
84670 #ifdef CONFIG_STACKTRACE
84671 {
84672 @@ -2653,7 +2653,7 @@ static int slub_min_objects;
84673 * Merge control. If this is set then no merging of slab caches will occur.
84674 * (Could be removed. This was introduced to pacify the merge skeptics.)
84675 */
84676 -static int slub_nomerge;
84677 +static int slub_nomerge = 1;
84678
84679 /*
84680 * Calculate the order of allocation given an slab object size.
84681 @@ -3181,6 +3181,10 @@ EXPORT_SYMBOL(kmalloc_caches);
84682 static struct kmem_cache *kmalloc_dma_caches[SLUB_PAGE_SHIFT];
84683 #endif
84684
84685 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84686 +static struct kmem_cache *kmalloc_usercopy_caches[SLUB_PAGE_SHIFT];
84687 +#endif
84688 +
84689 static int __init setup_slub_min_order(char *str)
84690 {
84691 get_option(&str, &slub_min_order);
84692 @@ -3272,6 +3276,13 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
84693 return kmalloc_dma_caches[index];
84694
84695 #endif
84696 +
84697 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84698 + if (flags & SLAB_USERCOPY)
84699 + return kmalloc_usercopy_caches[index];
84700 +
84701 +#endif
84702 +
84703 return kmalloc_caches[index];
84704 }
84705
84706 @@ -3340,6 +3351,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
84707 EXPORT_SYMBOL(__kmalloc_node);
84708 #endif
84709
84710 +bool is_usercopy_object(const void *ptr)
84711 +{
84712 + struct page *page;
84713 + struct kmem_cache *s;
84714 +
84715 + if (ZERO_OR_NULL_PTR(ptr))
84716 + return false;
84717 +
84718 + if (!slab_is_available())
84719 + return false;
84720 +
84721 + if (!virt_addr_valid(ptr))
84722 + return false;
84723 +
84724 + page = virt_to_head_page(ptr);
84725 +
84726 + if (!PageSlab(page))
84727 + return false;
84728 +
84729 + s = page->slab_cache;
84730 + return s->flags & SLAB_USERCOPY;
84731 +}
84732 +
84733 +#ifdef CONFIG_PAX_USERCOPY
84734 +const char *check_heap_object(const void *ptr, unsigned long n)
84735 +{
84736 + struct page *page;
84737 + struct kmem_cache *s;
84738 + unsigned long offset;
84739 +
84740 + if (ZERO_OR_NULL_PTR(ptr))
84741 + return "<null>";
84742 +
84743 + if (!virt_addr_valid(ptr))
84744 + return NULL;
84745 +
84746 + page = virt_to_head_page(ptr);
84747 +
84748 + if (!PageSlab(page))
84749 + return NULL;
84750 +
84751 + s = page->slab_cache;
84752 + if (!(s->flags & SLAB_USERCOPY))
84753 + return s->name;
84754 +
84755 + offset = (ptr - page_address(page)) % s->size;
84756 + if (offset <= s->object_size && n <= s->object_size - offset)
84757 + return NULL;
84758 +
84759 + return s->name;
84760 +}
84761 +#endif
84762 +
84763 size_t ksize(const void *object)
84764 {
84765 struct page *page;
84766 @@ -3404,6 +3468,7 @@ void kfree(const void *x)
84767 if (unlikely(ZERO_OR_NULL_PTR(x)))
84768 return;
84769
84770 + VM_BUG_ON(!virt_addr_valid(x));
84771 page = virt_to_head_page(x);
84772 if (unlikely(!PageSlab(page))) {
84773 BUG_ON(!PageCompound(page));
84774 @@ -3712,17 +3777,17 @@ void __init kmem_cache_init(void)
84775
84776 /* Caches that are not of the two-to-the-power-of size */
84777 if (KMALLOC_MIN_SIZE <= 32) {
84778 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
84779 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
84780 caches++;
84781 }
84782
84783 if (KMALLOC_MIN_SIZE <= 64) {
84784 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
84785 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
84786 caches++;
84787 }
84788
84789 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
84790 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
84791 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
84792 caches++;
84793 }
84794
84795 @@ -3764,6 +3829,22 @@ void __init kmem_cache_init(void)
84796 }
84797 }
84798 #endif
84799 +
84800 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84801 + for (i = 0; i < SLUB_PAGE_SHIFT; i++) {
84802 + struct kmem_cache *s = kmalloc_caches[i];
84803 +
84804 + if (s && s->size) {
84805 + char *name = kasprintf(GFP_NOWAIT,
84806 + "usercopy-kmalloc-%d", s->object_size);
84807 +
84808 + BUG_ON(!name);
84809 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(name,
84810 + s->object_size, SLAB_USERCOPY);
84811 + }
84812 + }
84813 +#endif
84814 +
84815 printk(KERN_INFO
84816 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
84817 " CPUs=%d, Nodes=%d\n",
84818 @@ -3790,7 +3871,7 @@ static int slab_unmergeable(struct kmem_cache *s)
84819 /*
84820 * We may have set a slab to be unmergeable during bootstrap.
84821 */
84822 - if (s->refcount < 0)
84823 + if (atomic_read(&s->refcount) < 0)
84824 return 1;
84825
84826 return 0;
84827 @@ -3848,7 +3929,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84828
84829 s = find_mergeable(memcg, size, align, flags, name, ctor);
84830 if (s) {
84831 - s->refcount++;
84832 + atomic_inc(&s->refcount);
84833 /*
84834 * Adjust the object sizes so that we clear
84835 * the complete object on kzalloc.
84836 @@ -3857,7 +3938,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84837 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
84838
84839 if (sysfs_slab_alias(s, name)) {
84840 - s->refcount--;
84841 + atomic_dec(&s->refcount);
84842 s = NULL;
84843 }
84844 }
84845 @@ -3919,7 +4000,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
84846 return NOTIFY_OK;
84847 }
84848
84849 -static struct notifier_block __cpuinitdata slab_notifier = {
84850 +static struct notifier_block slab_notifier = {
84851 .notifier_call = slab_cpuup_callback
84852 };
84853
84854 @@ -3977,7 +4058,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
84855 }
84856 #endif
84857
84858 -#ifdef CONFIG_SYSFS
84859 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84860 static int count_inuse(struct page *page)
84861 {
84862 return page->inuse;
84863 @@ -4364,12 +4445,12 @@ static void resiliency_test(void)
84864 validate_slab_cache(kmalloc_caches[9]);
84865 }
84866 #else
84867 -#ifdef CONFIG_SYSFS
84868 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84869 static void resiliency_test(void) {};
84870 #endif
84871 #endif
84872
84873 -#ifdef CONFIG_SYSFS
84874 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84875 enum slab_stat_type {
84876 SL_ALL, /* All slabs */
84877 SL_PARTIAL, /* Only partially allocated slabs */
84878 @@ -4613,7 +4694,7 @@ SLAB_ATTR_RO(ctor);
84879
84880 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
84881 {
84882 - return sprintf(buf, "%d\n", s->refcount - 1);
84883 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
84884 }
84885 SLAB_ATTR_RO(aliases);
84886
84887 @@ -5266,6 +5347,7 @@ static char *create_unique_id(struct kmem_cache *s)
84888 return name;
84889 }
84890
84891 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84892 static int sysfs_slab_add(struct kmem_cache *s)
84893 {
84894 int err;
84895 @@ -5323,6 +5405,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
84896 kobject_del(&s->kobj);
84897 kobject_put(&s->kobj);
84898 }
84899 +#endif
84900
84901 /*
84902 * Need to buffer aliases during bootup until sysfs becomes
84903 @@ -5336,6 +5419,7 @@ struct saved_alias {
84904
84905 static struct saved_alias *alias_list;
84906
84907 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84908 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
84909 {
84910 struct saved_alias *al;
84911 @@ -5358,6 +5442,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
84912 alias_list = al;
84913 return 0;
84914 }
84915 +#endif
84916
84917 static int __init slab_sysfs_init(void)
84918 {
84919 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
84920 index 1b7e22a..3fcd4f3 100644
84921 --- a/mm/sparse-vmemmap.c
84922 +++ b/mm/sparse-vmemmap.c
84923 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
84924 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
84925 if (!p)
84926 return NULL;
84927 - pud_populate(&init_mm, pud, p);
84928 + pud_populate_kernel(&init_mm, pud, p);
84929 }
84930 return pud;
84931 }
84932 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
84933 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
84934 if (!p)
84935 return NULL;
84936 - pgd_populate(&init_mm, pgd, p);
84937 + pgd_populate_kernel(&init_mm, pgd, p);
84938 }
84939 return pgd;
84940 }
84941 diff --git a/mm/sparse.c b/mm/sparse.c
84942 index 7ca6dc8..6472aa1 100644
84943 --- a/mm/sparse.c
84944 +++ b/mm/sparse.c
84945 @@ -783,7 +783,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
84946
84947 for (i = 0; i < PAGES_PER_SECTION; i++) {
84948 if (PageHWPoison(&memmap[i])) {
84949 - atomic_long_sub(1, &num_poisoned_pages);
84950 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
84951 ClearPageHWPoison(&memmap[i]);
84952 }
84953 }
84954 diff --git a/mm/swap.c b/mm/swap.c
84955 index 8a529a0..154ef26 100644
84956 --- a/mm/swap.c
84957 +++ b/mm/swap.c
84958 @@ -30,6 +30,7 @@
84959 #include <linux/backing-dev.h>
84960 #include <linux/memcontrol.h>
84961 #include <linux/gfp.h>
84962 +#include <linux/hugetlb.h>
84963
84964 #include "internal.h"
84965
84966 @@ -72,6 +73,8 @@ static void __put_compound_page(struct page *page)
84967
84968 __page_cache_release(page);
84969 dtor = get_compound_page_dtor(page);
84970 + if (!PageHuge(page))
84971 + BUG_ON(dtor != free_compound_page);
84972 (*dtor)(page);
84973 }
84974
84975 diff --git a/mm/swapfile.c b/mm/swapfile.c
84976 index a1f7772..9e982ac 100644
84977 --- a/mm/swapfile.c
84978 +++ b/mm/swapfile.c
84979 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
84980
84981 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
84982 /* Activity counter to indicate that a swapon or swapoff has occurred */
84983 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
84984 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
84985
84986 static inline unsigned char swap_count(unsigned char ent)
84987 {
84988 @@ -1683,7 +1683,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
84989 }
84990 filp_close(swap_file, NULL);
84991 err = 0;
84992 - atomic_inc(&proc_poll_event);
84993 + atomic_inc_unchecked(&proc_poll_event);
84994 wake_up_interruptible(&proc_poll_wait);
84995
84996 out_dput:
84997 @@ -1700,8 +1700,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
84998
84999 poll_wait(file, &proc_poll_wait, wait);
85000
85001 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
85002 - seq->poll_event = atomic_read(&proc_poll_event);
85003 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
85004 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85005 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
85006 }
85007
85008 @@ -1799,7 +1799,7 @@ static int swaps_open(struct inode *inode, struct file *file)
85009 return ret;
85010
85011 seq = file->private_data;
85012 - seq->poll_event = atomic_read(&proc_poll_event);
85013 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85014 return 0;
85015 }
85016
85017 @@ -2142,7 +2142,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
85018 (frontswap_map) ? "FS" : "");
85019
85020 mutex_unlock(&swapon_mutex);
85021 - atomic_inc(&proc_poll_event);
85022 + atomic_inc_unchecked(&proc_poll_event);
85023 wake_up_interruptible(&proc_poll_wait);
85024
85025 if (S_ISREG(inode->i_mode))
85026 diff --git a/mm/util.c b/mm/util.c
85027 index ab1424d..7c5bd5a 100644
85028 --- a/mm/util.c
85029 +++ b/mm/util.c
85030 @@ -294,6 +294,12 @@ done:
85031 void arch_pick_mmap_layout(struct mm_struct *mm)
85032 {
85033 mm->mmap_base = TASK_UNMAPPED_BASE;
85034 +
85035 +#ifdef CONFIG_PAX_RANDMMAP
85036 + if (mm->pax_flags & MF_PAX_RANDMMAP)
85037 + mm->mmap_base += mm->delta_mmap;
85038 +#endif
85039 +
85040 mm->get_unmapped_area = arch_get_unmapped_area;
85041 mm->unmap_area = arch_unmap_area;
85042 }
85043 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
85044 index 0f751f2..ef398a0 100644
85045 --- a/mm/vmalloc.c
85046 +++ b/mm/vmalloc.c
85047 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
85048
85049 pte = pte_offset_kernel(pmd, addr);
85050 do {
85051 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85052 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85053 +
85054 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85055 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
85056 + BUG_ON(!pte_exec(*pte));
85057 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
85058 + continue;
85059 + }
85060 +#endif
85061 +
85062 + {
85063 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85064 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85065 + }
85066 } while (pte++, addr += PAGE_SIZE, addr != end);
85067 }
85068
85069 @@ -100,16 +111,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
85070 pte = pte_alloc_kernel(pmd, addr);
85071 if (!pte)
85072 return -ENOMEM;
85073 +
85074 + pax_open_kernel();
85075 do {
85076 struct page *page = pages[*nr];
85077
85078 - if (WARN_ON(!pte_none(*pte)))
85079 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85080 + if (pgprot_val(prot) & _PAGE_NX)
85081 +#endif
85082 +
85083 + if (!pte_none(*pte)) {
85084 + pax_close_kernel();
85085 + WARN_ON(1);
85086 return -EBUSY;
85087 - if (WARN_ON(!page))
85088 + }
85089 + if (!page) {
85090 + pax_close_kernel();
85091 + WARN_ON(1);
85092 return -ENOMEM;
85093 + }
85094 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
85095 (*nr)++;
85096 } while (pte++, addr += PAGE_SIZE, addr != end);
85097 + pax_close_kernel();
85098 return 0;
85099 }
85100
85101 @@ -119,7 +143,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
85102 pmd_t *pmd;
85103 unsigned long next;
85104
85105 - pmd = pmd_alloc(&init_mm, pud, addr);
85106 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85107 if (!pmd)
85108 return -ENOMEM;
85109 do {
85110 @@ -136,7 +160,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
85111 pud_t *pud;
85112 unsigned long next;
85113
85114 - pud = pud_alloc(&init_mm, pgd, addr);
85115 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85116 if (!pud)
85117 return -ENOMEM;
85118 do {
85119 @@ -191,11 +215,20 @@ int is_vmalloc_or_module_addr(const void *x)
85120 * and fall back on vmalloc() if that fails. Others
85121 * just put it in the vmalloc space.
85122 */
85123 -#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
85124 +#ifdef CONFIG_MODULES
85125 +#ifdef MODULES_VADDR
85126 unsigned long addr = (unsigned long)x;
85127 if (addr >= MODULES_VADDR && addr < MODULES_END)
85128 return 1;
85129 #endif
85130 +
85131 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85132 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
85133 + return 1;
85134 +#endif
85135 +
85136 +#endif
85137 +
85138 return is_vmalloc_addr(x);
85139 }
85140
85141 @@ -216,8 +249,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
85142
85143 if (!pgd_none(*pgd)) {
85144 pud_t *pud = pud_offset(pgd, addr);
85145 +#ifdef CONFIG_X86
85146 + if (!pud_large(*pud))
85147 +#endif
85148 if (!pud_none(*pud)) {
85149 pmd_t *pmd = pmd_offset(pud, addr);
85150 +#ifdef CONFIG_X86
85151 + if (!pmd_large(*pmd))
85152 +#endif
85153 if (!pmd_none(*pmd)) {
85154 pte_t *ptep, pte;
85155
85156 @@ -329,7 +368,7 @@ static void purge_vmap_area_lazy(void);
85157 * Allocate a region of KVA of the specified size and alignment, within the
85158 * vstart and vend.
85159 */
85160 -static struct vmap_area *alloc_vmap_area(unsigned long size,
85161 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
85162 unsigned long align,
85163 unsigned long vstart, unsigned long vend,
85164 int node, gfp_t gfp_mask)
85165 @@ -1328,6 +1367,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
85166 struct vm_struct *area;
85167
85168 BUG_ON(in_interrupt());
85169 +
85170 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85171 + if (flags & VM_KERNEXEC) {
85172 + if (start != VMALLOC_START || end != VMALLOC_END)
85173 + return NULL;
85174 + start = (unsigned long)MODULES_EXEC_VADDR;
85175 + end = (unsigned long)MODULES_EXEC_END;
85176 + }
85177 +#endif
85178 +
85179 if (flags & VM_IOREMAP) {
85180 int bit = fls(size);
85181
85182 @@ -1569,6 +1618,11 @@ void *vmap(struct page **pages, unsigned int count,
85183 if (count > totalram_pages)
85184 return NULL;
85185
85186 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85187 + if (!(pgprot_val(prot) & _PAGE_NX))
85188 + flags |= VM_KERNEXEC;
85189 +#endif
85190 +
85191 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
85192 __builtin_return_address(0));
85193 if (!area)
85194 @@ -1670,6 +1724,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
85195 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
85196 goto fail;
85197
85198 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85199 + if (!(pgprot_val(prot) & _PAGE_NX))
85200 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
85201 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
85202 + else
85203 +#endif
85204 +
85205 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
85206 start, end, node, gfp_mask, caller);
85207 if (!area)
85208 @@ -1845,10 +1906,9 @@ EXPORT_SYMBOL(vzalloc_node);
85209 * For tight control over page level allocator and protection flags
85210 * use __vmalloc() instead.
85211 */
85212 -
85213 void *vmalloc_exec(unsigned long size)
85214 {
85215 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
85216 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
85217 NUMA_NO_NODE, __builtin_return_address(0));
85218 }
85219
85220 @@ -2139,6 +2199,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
85221 unsigned long uaddr = vma->vm_start;
85222 unsigned long usize = vma->vm_end - vma->vm_start;
85223
85224 + BUG_ON(vma->vm_mirror);
85225 +
85226 if ((PAGE_SIZE-1) & (unsigned long)addr)
85227 return -EINVAL;
85228
85229 @@ -2578,7 +2640,11 @@ static int s_show(struct seq_file *m, void *p)
85230 v->addr, v->addr + v->size, v->size);
85231
85232 if (v->caller)
85233 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85234 + seq_printf(m, " %pK", v->caller);
85235 +#else
85236 seq_printf(m, " %pS", v->caller);
85237 +#endif
85238
85239 if (v->nr_pages)
85240 seq_printf(m, " pages=%d", v->nr_pages);
85241 diff --git a/mm/vmstat.c b/mm/vmstat.c
85242 index e1d8ed1..253fa3c 100644
85243 --- a/mm/vmstat.c
85244 +++ b/mm/vmstat.c
85245 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
85246 *
85247 * vm_stat contains the global counters
85248 */
85249 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85250 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85251 EXPORT_SYMBOL(vm_stat);
85252
85253 #ifdef CONFIG_SMP
85254 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
85255 v = p->vm_stat_diff[i];
85256 p->vm_stat_diff[i] = 0;
85257 local_irq_restore(flags);
85258 - atomic_long_add(v, &zone->vm_stat[i]);
85259 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85260 global_diff[i] += v;
85261 #ifdef CONFIG_NUMA
85262 /* 3 seconds idle till flush */
85263 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
85264
85265 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
85266 if (global_diff[i])
85267 - atomic_long_add(global_diff[i], &vm_stat[i]);
85268 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
85269 }
85270
85271 void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85272 @@ -503,8 +503,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85273 if (pset->vm_stat_diff[i]) {
85274 int v = pset->vm_stat_diff[i];
85275 pset->vm_stat_diff[i] = 0;
85276 - atomic_long_add(v, &zone->vm_stat[i]);
85277 - atomic_long_add(v, &vm_stat[i]);
85278 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85279 + atomic_long_add_unchecked(v, &vm_stat[i]);
85280 }
85281 }
85282 #endif
85283 @@ -1224,7 +1224,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
85284 return NOTIFY_OK;
85285 }
85286
85287 -static struct notifier_block __cpuinitdata vmstat_notifier =
85288 +static struct notifier_block vmstat_notifier =
85289 { &vmstat_cpuup_callback, NULL, 0 };
85290 #endif
85291
85292 @@ -1239,10 +1239,20 @@ static int __init setup_vmstat(void)
85293 start_cpu_timer(cpu);
85294 #endif
85295 #ifdef CONFIG_PROC_FS
85296 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
85297 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
85298 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
85299 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
85300 + {
85301 + mode_t gr_mode = S_IRUGO;
85302 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85303 + gr_mode = S_IRUSR;
85304 +#endif
85305 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
85306 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
85307 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
85308 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
85309 +#else
85310 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
85311 +#endif
85312 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
85313 + }
85314 #endif
85315 return 0;
85316 }
85317 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
85318 index 85addcd..c429a13 100644
85319 --- a/net/8021q/vlan.c
85320 +++ b/net/8021q/vlan.c
85321 @@ -114,6 +114,13 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
85322 if (vlan_id)
85323 vlan_vid_del(real_dev, vlan_id);
85324
85325 + /* Take it out of our own structures, but be sure to interlock with
85326 + * HW accelerating devices or SW vlan input packet processing if
85327 + * VLAN is not 0 (leave it there for 802.1p).
85328 + */
85329 + if (vlan_id)
85330 + vlan_vid_del(real_dev, vlan_id);
85331 +
85332 /* Get rid of the vlan's reference to real_dev */
85333 dev_put(real_dev);
85334 }
85335 @@ -496,7 +503,7 @@ out:
85336 return NOTIFY_DONE;
85337 }
85338
85339 -static struct notifier_block vlan_notifier_block __read_mostly = {
85340 +static struct notifier_block vlan_notifier_block = {
85341 .notifier_call = vlan_device_event,
85342 };
85343
85344 @@ -571,8 +578,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
85345 err = -EPERM;
85346 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
85347 break;
85348 - if ((args.u.name_type >= 0) &&
85349 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
85350 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
85351 struct vlan_net *vn;
85352
85353 vn = net_generic(net, vlan_net_id);
85354 diff --git a/net/9p/mod.c b/net/9p/mod.c
85355 index 6ab36ae..6f1841b 100644
85356 --- a/net/9p/mod.c
85357 +++ b/net/9p/mod.c
85358 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
85359 void v9fs_register_trans(struct p9_trans_module *m)
85360 {
85361 spin_lock(&v9fs_trans_lock);
85362 - list_add_tail(&m->list, &v9fs_trans_list);
85363 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
85364 spin_unlock(&v9fs_trans_lock);
85365 }
85366 EXPORT_SYMBOL(v9fs_register_trans);
85367 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
85368 void v9fs_unregister_trans(struct p9_trans_module *m)
85369 {
85370 spin_lock(&v9fs_trans_lock);
85371 - list_del_init(&m->list);
85372 + pax_list_del_init((struct list_head *)&m->list);
85373 spin_unlock(&v9fs_trans_lock);
85374 }
85375 EXPORT_SYMBOL(v9fs_unregister_trans);
85376 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
85377 index 02efb25..41541a9 100644
85378 --- a/net/9p/trans_fd.c
85379 +++ b/net/9p/trans_fd.c
85380 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
85381 oldfs = get_fs();
85382 set_fs(get_ds());
85383 /* The cast to a user pointer is valid due to the set_fs() */
85384 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
85385 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
85386 set_fs(oldfs);
85387
85388 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
85389 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
85390 index 876fbe8..8bbea9f 100644
85391 --- a/net/atm/atm_misc.c
85392 +++ b/net/atm/atm_misc.c
85393 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
85394 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
85395 return 1;
85396 atm_return(vcc, truesize);
85397 - atomic_inc(&vcc->stats->rx_drop);
85398 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85399 return 0;
85400 }
85401 EXPORT_SYMBOL(atm_charge);
85402 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
85403 }
85404 }
85405 atm_return(vcc, guess);
85406 - atomic_inc(&vcc->stats->rx_drop);
85407 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85408 return NULL;
85409 }
85410 EXPORT_SYMBOL(atm_alloc_charge);
85411 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
85412
85413 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85414 {
85415 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85416 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85417 __SONET_ITEMS
85418 #undef __HANDLE_ITEM
85419 }
85420 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
85421
85422 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85423 {
85424 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85425 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
85426 __SONET_ITEMS
85427 #undef __HANDLE_ITEM
85428 }
85429 diff --git a/net/atm/lec.h b/net/atm/lec.h
85430 index a86aff9..3a0d6f6 100644
85431 --- a/net/atm/lec.h
85432 +++ b/net/atm/lec.h
85433 @@ -48,7 +48,7 @@ struct lane2_ops {
85434 const u8 *tlvs, u32 sizeoftlvs);
85435 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
85436 const u8 *tlvs, u32 sizeoftlvs);
85437 -};
85438 +} __no_const;
85439
85440 /*
85441 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
85442 diff --git a/net/atm/proc.c b/net/atm/proc.c
85443 index 6ac35ff..ac0e136 100644
85444 --- a/net/atm/proc.c
85445 +++ b/net/atm/proc.c
85446 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
85447 const struct k_atm_aal_stats *stats)
85448 {
85449 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
85450 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
85451 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
85452 - atomic_read(&stats->rx_drop));
85453 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
85454 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
85455 + atomic_read_unchecked(&stats->rx_drop));
85456 }
85457
85458 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
85459 diff --git a/net/atm/resources.c b/net/atm/resources.c
85460 index 0447d5d..3cf4728 100644
85461 --- a/net/atm/resources.c
85462 +++ b/net/atm/resources.c
85463 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
85464 static void copy_aal_stats(struct k_atm_aal_stats *from,
85465 struct atm_aal_stats *to)
85466 {
85467 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85468 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85469 __AAL_STAT_ITEMS
85470 #undef __HANDLE_ITEM
85471 }
85472 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
85473 static void subtract_aal_stats(struct k_atm_aal_stats *from,
85474 struct atm_aal_stats *to)
85475 {
85476 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85477 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
85478 __AAL_STAT_ITEMS
85479 #undef __HANDLE_ITEM
85480 }
85481 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
85482 index d5744b7..506bae3 100644
85483 --- a/net/ax25/sysctl_net_ax25.c
85484 +++ b/net/ax25/sysctl_net_ax25.c
85485 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
85486 {
85487 char path[sizeof("net/ax25/") + IFNAMSIZ];
85488 int k;
85489 - struct ctl_table *table;
85490 + ctl_table_no_const *table;
85491
85492 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
85493 if (!table)
85494 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
85495 index a5bb0a7..e1d8b97 100644
85496 --- a/net/batman-adv/bat_iv_ogm.c
85497 +++ b/net/batman-adv/bat_iv_ogm.c
85498 @@ -63,7 +63,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
85499
85500 /* randomize initial seqno to avoid collision */
85501 get_random_bytes(&random_seqno, sizeof(random_seqno));
85502 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85503 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85504
85505 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
85506 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
85507 @@ -611,9 +611,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
85508 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
85509
85510 /* change sequence number to network order */
85511 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
85512 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
85513 batadv_ogm_packet->seqno = htonl(seqno);
85514 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
85515 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
85516
85517 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
85518 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
85519 @@ -1013,7 +1013,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
85520 return;
85521
85522 /* could be changed by schedule_own_packet() */
85523 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
85524 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
85525
85526 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
85527 has_directlink_flag = 1;
85528 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
85529 index 368219e..53f56f9 100644
85530 --- a/net/batman-adv/hard-interface.c
85531 +++ b/net/batman-adv/hard-interface.c
85532 @@ -370,7 +370,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
85533 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
85534 dev_add_pack(&hard_iface->batman_adv_ptype);
85535
85536 - atomic_set(&hard_iface->frag_seqno, 1);
85537 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
85538 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
85539 hard_iface->net_dev->name);
85540
85541 @@ -514,7 +514,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
85542 /* This can't be called via a bat_priv callback because
85543 * we have no bat_priv yet.
85544 */
85545 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
85546 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
85547 hard_iface->bat_iv.ogm_buff = NULL;
85548
85549 return hard_iface;
85550 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
85551 index 2711e87..4ca48fa 100644
85552 --- a/net/batman-adv/soft-interface.c
85553 +++ b/net/batman-adv/soft-interface.c
85554 @@ -252,7 +252,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
85555 primary_if->net_dev->dev_addr, ETH_ALEN);
85556
85557 /* set broadcast sequence number */
85558 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
85559 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
85560 bcast_packet->seqno = htonl(seqno);
85561
85562 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
85563 @@ -527,7 +527,7 @@ struct net_device *batadv_softif_create(const char *name)
85564 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
85565
85566 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
85567 - atomic_set(&bat_priv->bcast_seqno, 1);
85568 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
85569 atomic_set(&bat_priv->tt.vn, 0);
85570 atomic_set(&bat_priv->tt.local_changes, 0);
85571 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
85572 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
85573 index 4cd87a0..348e705 100644
85574 --- a/net/batman-adv/types.h
85575 +++ b/net/batman-adv/types.h
85576 @@ -51,7 +51,7 @@
85577 struct batadv_hard_iface_bat_iv {
85578 unsigned char *ogm_buff;
85579 int ogm_buff_len;
85580 - atomic_t ogm_seqno;
85581 + atomic_unchecked_t ogm_seqno;
85582 };
85583
85584 /**
85585 @@ -75,7 +75,7 @@ struct batadv_hard_iface {
85586 int16_t if_num;
85587 char if_status;
85588 struct net_device *net_dev;
85589 - atomic_t frag_seqno;
85590 + atomic_unchecked_t frag_seqno;
85591 struct kobject *hardif_obj;
85592 atomic_t refcount;
85593 struct packet_type batman_adv_ptype;
85594 @@ -495,7 +495,7 @@ struct batadv_priv {
85595 #ifdef CONFIG_BATMAN_ADV_DEBUG
85596 atomic_t log_level;
85597 #endif
85598 - atomic_t bcast_seqno;
85599 + atomic_unchecked_t bcast_seqno;
85600 atomic_t bcast_queue_left;
85601 atomic_t batman_queue_left;
85602 char num_ifaces;
85603 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
85604 index 50e079f..49ce2d2 100644
85605 --- a/net/batman-adv/unicast.c
85606 +++ b/net/batman-adv/unicast.c
85607 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
85608 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
85609 frag2->flags = large_tail;
85610
85611 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
85612 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
85613 frag1->seqno = htons(seqno - 1);
85614 frag2->seqno = htons(seqno);
85615
85616 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
85617 index 6a93614..1415549 100644
85618 --- a/net/bluetooth/hci_sock.c
85619 +++ b/net/bluetooth/hci_sock.c
85620 @@ -929,7 +929,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
85621 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
85622 }
85623
85624 - len = min_t(unsigned int, len, sizeof(uf));
85625 + len = min((size_t)len, sizeof(uf));
85626 if (copy_from_user(&uf, optval, len)) {
85627 err = -EFAULT;
85628 break;
85629 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
85630 index 7c7e932..7a7815d 100644
85631 --- a/net/bluetooth/l2cap_core.c
85632 +++ b/net/bluetooth/l2cap_core.c
85633 @@ -3395,8 +3395,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
85634 break;
85635
85636 case L2CAP_CONF_RFC:
85637 - if (olen == sizeof(rfc))
85638 - memcpy(&rfc, (void *)val, olen);
85639 + if (olen != sizeof(rfc))
85640 + break;
85641 +
85642 + memcpy(&rfc, (void *)val, olen);
85643
85644 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
85645 rfc.mode != chan->mode)
85646 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
85647 index 1bcfb84..dad9f98 100644
85648 --- a/net/bluetooth/l2cap_sock.c
85649 +++ b/net/bluetooth/l2cap_sock.c
85650 @@ -479,7 +479,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85651 struct sock *sk = sock->sk;
85652 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
85653 struct l2cap_options opts;
85654 - int len, err = 0;
85655 + int err = 0;
85656 + size_t len = optlen;
85657 u32 opt;
85658
85659 BT_DBG("sk %p", sk);
85660 @@ -501,7 +502,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85661 opts.max_tx = chan->max_tx;
85662 opts.txwin_size = chan->tx_win;
85663
85664 - len = min_t(unsigned int, sizeof(opts), optlen);
85665 + len = min(sizeof(opts), len);
85666 if (copy_from_user((char *) &opts, optval, len)) {
85667 err = -EFAULT;
85668 break;
85669 @@ -581,7 +582,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85670 struct bt_security sec;
85671 struct bt_power pwr;
85672 struct l2cap_conn *conn;
85673 - int len, err = 0;
85674 + int err = 0;
85675 + size_t len = optlen;
85676 u32 opt;
85677
85678 BT_DBG("sk %p", sk);
85679 @@ -604,7 +606,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85680
85681 sec.level = BT_SECURITY_LOW;
85682
85683 - len = min_t(unsigned int, sizeof(sec), optlen);
85684 + len = min(sizeof(sec), len);
85685 if (copy_from_user((char *) &sec, optval, len)) {
85686 err = -EFAULT;
85687 break;
85688 @@ -701,7 +703,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85689
85690 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
85691
85692 - len = min_t(unsigned int, sizeof(pwr), optlen);
85693 + len = min(sizeof(pwr), len);
85694 if (copy_from_user((char *) &pwr, optval, len)) {
85695 err = -EFAULT;
85696 break;
85697 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
85698 index 7c9224b..381009e 100644
85699 --- a/net/bluetooth/rfcomm/sock.c
85700 +++ b/net/bluetooth/rfcomm/sock.c
85701 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85702 struct sock *sk = sock->sk;
85703 struct bt_security sec;
85704 int err = 0;
85705 - size_t len;
85706 + size_t len = optlen;
85707 u32 opt;
85708
85709 BT_DBG("sk %p", sk);
85710 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85711
85712 sec.level = BT_SECURITY_LOW;
85713
85714 - len = min_t(unsigned int, sizeof(sec), optlen);
85715 + len = min(sizeof(sec), len);
85716 if (copy_from_user((char *) &sec, optval, len)) {
85717 err = -EFAULT;
85718 break;
85719 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
85720 index b6e44ad..5b0d514 100644
85721 --- a/net/bluetooth/rfcomm/tty.c
85722 +++ b/net/bluetooth/rfcomm/tty.c
85723 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
85724 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
85725
85726 spin_lock_irqsave(&dev->port.lock, flags);
85727 - if (dev->port.count > 0) {
85728 + if (atomic_read(&dev->port.count) > 0) {
85729 spin_unlock_irqrestore(&dev->port.lock, flags);
85730 return;
85731 }
85732 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
85733 return -ENODEV;
85734
85735 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
85736 - dev->channel, dev->port.count);
85737 + dev->channel, atomic_read(&dev->port.count));
85738
85739 spin_lock_irqsave(&dev->port.lock, flags);
85740 - if (++dev->port.count > 1) {
85741 + if (atomic_inc_return(&dev->port.count) > 1) {
85742 spin_unlock_irqrestore(&dev->port.lock, flags);
85743 return 0;
85744 }
85745 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
85746 return;
85747
85748 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
85749 - dev->port.count);
85750 + atomic_read(&dev->port.count));
85751
85752 spin_lock_irqsave(&dev->port.lock, flags);
85753 - if (!--dev->port.count) {
85754 + if (!atomic_dec_return(&dev->port.count)) {
85755 spin_unlock_irqrestore(&dev->port.lock, flags);
85756 if (dev->tty_dev->parent)
85757 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
85758 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
85759 index 8d493c9..3849e49 100644
85760 --- a/net/bridge/netfilter/ebtables.c
85761 +++ b/net/bridge/netfilter/ebtables.c
85762 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
85763 tmp.valid_hooks = t->table->valid_hooks;
85764 }
85765 mutex_unlock(&ebt_mutex);
85766 - if (copy_to_user(user, &tmp, *len) != 0){
85767 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
85768 BUGPRINT("c2u Didn't work\n");
85769 ret = -EFAULT;
85770 break;
85771 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85772 goto out;
85773 tmp.valid_hooks = t->valid_hooks;
85774
85775 - if (copy_to_user(user, &tmp, *len) != 0) {
85776 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85777 ret = -EFAULT;
85778 break;
85779 }
85780 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85781 tmp.entries_size = t->table->entries_size;
85782 tmp.valid_hooks = t->table->valid_hooks;
85783
85784 - if (copy_to_user(user, &tmp, *len) != 0) {
85785 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85786 ret = -EFAULT;
85787 break;
85788 }
85789 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
85790 index a376ec1..1fbd6be 100644
85791 --- a/net/caif/cfctrl.c
85792 +++ b/net/caif/cfctrl.c
85793 @@ -10,6 +10,7 @@
85794 #include <linux/spinlock.h>
85795 #include <linux/slab.h>
85796 #include <linux/pkt_sched.h>
85797 +#include <linux/sched.h>
85798 #include <net/caif/caif_layer.h>
85799 #include <net/caif/cfpkt.h>
85800 #include <net/caif/cfctrl.h>
85801 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
85802 memset(&dev_info, 0, sizeof(dev_info));
85803 dev_info.id = 0xff;
85804 cfsrvl_init(&this->serv, 0, &dev_info, false);
85805 - atomic_set(&this->req_seq_no, 1);
85806 - atomic_set(&this->rsp_seq_no, 1);
85807 + atomic_set_unchecked(&this->req_seq_no, 1);
85808 + atomic_set_unchecked(&this->rsp_seq_no, 1);
85809 this->serv.layer.receive = cfctrl_recv;
85810 sprintf(this->serv.layer.name, "ctrl");
85811 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
85812 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
85813 struct cfctrl_request_info *req)
85814 {
85815 spin_lock_bh(&ctrl->info_list_lock);
85816 - atomic_inc(&ctrl->req_seq_no);
85817 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
85818 + atomic_inc_unchecked(&ctrl->req_seq_no);
85819 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
85820 list_add_tail(&req->list, &ctrl->list);
85821 spin_unlock_bh(&ctrl->info_list_lock);
85822 }
85823 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
85824 if (p != first)
85825 pr_warn("Requests are not received in order\n");
85826
85827 - atomic_set(&ctrl->rsp_seq_no,
85828 + atomic_set_unchecked(&ctrl->rsp_seq_no,
85829 p->sequence_no);
85830 list_del(&p->list);
85831 goto out;
85832 diff --git a/net/can/af_can.c b/net/can/af_can.c
85833 index c48e522..1223690 100644
85834 --- a/net/can/af_can.c
85835 +++ b/net/can/af_can.c
85836 @@ -870,7 +870,7 @@ static const struct net_proto_family can_family_ops = {
85837 };
85838
85839 /* notifier block for netdevice event */
85840 -static struct notifier_block can_netdev_notifier __read_mostly = {
85841 +static struct notifier_block can_netdev_notifier = {
85842 .notifier_call = can_notifier,
85843 };
85844
85845 diff --git a/net/can/gw.c b/net/can/gw.c
85846 index 117814a..ad4fb73 100644
85847 --- a/net/can/gw.c
85848 +++ b/net/can/gw.c
85849 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
85850 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
85851
85852 static HLIST_HEAD(cgw_list);
85853 -static struct notifier_block notifier;
85854
85855 static struct kmem_cache *cgw_cache __read_mostly;
85856
85857 @@ -928,6 +927,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
85858 return err;
85859 }
85860
85861 +static struct notifier_block notifier = {
85862 + .notifier_call = cgw_notifier
85863 +};
85864 +
85865 static __init int cgw_module_init(void)
85866 {
85867 /* sanitize given module parameter */
85868 @@ -943,7 +946,6 @@ static __init int cgw_module_init(void)
85869 return -ENOMEM;
85870
85871 /* set notifier */
85872 - notifier.notifier_call = cgw_notifier;
85873 register_netdevice_notifier(&notifier);
85874
85875 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
85876 diff --git a/net/compat.c b/net/compat.c
85877 index 79ae884..17c5c09 100644
85878 --- a/net/compat.c
85879 +++ b/net/compat.c
85880 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
85881 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
85882 __get_user(kmsg->msg_flags, &umsg->msg_flags))
85883 return -EFAULT;
85884 - kmsg->msg_name = compat_ptr(tmp1);
85885 - kmsg->msg_iov = compat_ptr(tmp2);
85886 - kmsg->msg_control = compat_ptr(tmp3);
85887 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
85888 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
85889 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
85890 return 0;
85891 }
85892
85893 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85894
85895 if (kern_msg->msg_namelen) {
85896 if (mode == VERIFY_READ) {
85897 - int err = move_addr_to_kernel(kern_msg->msg_name,
85898 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
85899 kern_msg->msg_namelen,
85900 kern_address);
85901 if (err < 0)
85902 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85903 kern_msg->msg_name = NULL;
85904
85905 tot_len = iov_from_user_compat_to_kern(kern_iov,
85906 - (struct compat_iovec __user *)kern_msg->msg_iov,
85907 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
85908 kern_msg->msg_iovlen);
85909 if (tot_len >= 0)
85910 kern_msg->msg_iov = kern_iov;
85911 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85912
85913 #define CMSG_COMPAT_FIRSTHDR(msg) \
85914 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
85915 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
85916 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
85917 (struct compat_cmsghdr __user *)NULL)
85918
85919 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
85920 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
85921 (ucmlen) <= (unsigned long) \
85922 ((mhdr)->msg_controllen - \
85923 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
85924 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
85925
85926 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
85927 struct compat_cmsghdr __user *cmsg, int cmsg_len)
85928 {
85929 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
85930 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
85931 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
85932 msg->msg_controllen)
85933 return NULL;
85934 return (struct compat_cmsghdr __user *)ptr;
85935 @@ -219,7 +219,7 @@ Efault:
85936
85937 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
85938 {
85939 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
85940 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
85941 struct compat_cmsghdr cmhdr;
85942 struct compat_timeval ctv;
85943 struct compat_timespec cts[3];
85944 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
85945
85946 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
85947 {
85948 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
85949 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
85950 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
85951 int fdnum = scm->fp->count;
85952 struct file **fp = scm->fp->fp;
85953 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
85954 return -EFAULT;
85955 old_fs = get_fs();
85956 set_fs(KERNEL_DS);
85957 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
85958 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
85959 set_fs(old_fs);
85960
85961 return err;
85962 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
85963 len = sizeof(ktime);
85964 old_fs = get_fs();
85965 set_fs(KERNEL_DS);
85966 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
85967 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
85968 set_fs(old_fs);
85969
85970 if (!err) {
85971 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85972 case MCAST_JOIN_GROUP:
85973 case MCAST_LEAVE_GROUP:
85974 {
85975 - struct compat_group_req __user *gr32 = (void *)optval;
85976 + struct compat_group_req __user *gr32 = (void __user *)optval;
85977 struct group_req __user *kgr =
85978 compat_alloc_user_space(sizeof(struct group_req));
85979 u32 interface;
85980 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85981 case MCAST_BLOCK_SOURCE:
85982 case MCAST_UNBLOCK_SOURCE:
85983 {
85984 - struct compat_group_source_req __user *gsr32 = (void *)optval;
85985 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
85986 struct group_source_req __user *kgsr = compat_alloc_user_space(
85987 sizeof(struct group_source_req));
85988 u32 interface;
85989 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85990 }
85991 case MCAST_MSFILTER:
85992 {
85993 - struct compat_group_filter __user *gf32 = (void *)optval;
85994 + struct compat_group_filter __user *gf32 = (void __user *)optval;
85995 struct group_filter __user *kgf;
85996 u32 interface, fmode, numsrc;
85997
85998 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
85999 char __user *optval, int __user *optlen,
86000 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
86001 {
86002 - struct compat_group_filter __user *gf32 = (void *)optval;
86003 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86004 struct group_filter __user *kgf;
86005 int __user *koptlen;
86006 u32 interface, fmode, numsrc;
86007 @@ -796,7 +796,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
86008
86009 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
86010 return -EINVAL;
86011 - if (copy_from_user(a, args, nas[call]))
86012 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
86013 return -EFAULT;
86014 a0 = a[0];
86015 a1 = a[1];
86016 diff --git a/net/core/datagram.c b/net/core/datagram.c
86017 index 368f9c3..f82d4a3 100644
86018 --- a/net/core/datagram.c
86019 +++ b/net/core/datagram.c
86020 @@ -289,7 +289,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
86021 }
86022
86023 kfree_skb(skb);
86024 - atomic_inc(&sk->sk_drops);
86025 + atomic_inc_unchecked(&sk->sk_drops);
86026 sk_mem_reclaim_partial(sk);
86027
86028 return err;
86029 diff --git a/net/core/dev.c b/net/core/dev.c
86030 index 9a278e9..15f2b9e 100644
86031 --- a/net/core/dev.c
86032 +++ b/net/core/dev.c
86033 @@ -1617,7 +1617,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86034 {
86035 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
86036 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
86037 - atomic_long_inc(&dev->rx_dropped);
86038 + atomic_long_inc_unchecked(&dev->rx_dropped);
86039 kfree_skb(skb);
86040 return NET_RX_DROP;
86041 }
86042 @@ -1626,7 +1626,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86043 skb_orphan(skb);
86044
86045 if (unlikely(!is_skb_forwardable(dev, skb))) {
86046 - atomic_long_inc(&dev->rx_dropped);
86047 + atomic_long_inc_unchecked(&dev->rx_dropped);
86048 kfree_skb(skb);
86049 return NET_RX_DROP;
86050 }
86051 @@ -2351,7 +2351,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
86052
86053 struct dev_gso_cb {
86054 void (*destructor)(struct sk_buff *skb);
86055 -};
86056 +} __no_const;
86057
86058 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
86059
86060 @@ -3093,7 +3093,7 @@ enqueue:
86061
86062 local_irq_restore(flags);
86063
86064 - atomic_long_inc(&skb->dev->rx_dropped);
86065 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86066 kfree_skb(skb);
86067 return NET_RX_DROP;
86068 }
86069 @@ -3165,7 +3165,7 @@ int netif_rx_ni(struct sk_buff *skb)
86070 }
86071 EXPORT_SYMBOL(netif_rx_ni);
86072
86073 -static void net_tx_action(struct softirq_action *h)
86074 +static void net_tx_action(void)
86075 {
86076 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86077
86078 @@ -3490,7 +3490,7 @@ ncls:
86079 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
86080 } else {
86081 drop:
86082 - atomic_long_inc(&skb->dev->rx_dropped);
86083 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86084 kfree_skb(skb);
86085 /* Jamal, now you will not able to escape explaining
86086 * me how you were going to use this. :-)
86087 @@ -4095,7 +4095,7 @@ void netif_napi_del(struct napi_struct *napi)
86088 }
86089 EXPORT_SYMBOL(netif_napi_del);
86090
86091 -static void net_rx_action(struct softirq_action *h)
86092 +static void net_rx_action(void)
86093 {
86094 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86095 unsigned long time_limit = jiffies + 2;
86096 @@ -5522,7 +5522,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
86097 } else {
86098 netdev_stats_to_stats64(storage, &dev->stats);
86099 }
86100 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
86101 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
86102 return storage;
86103 }
86104 EXPORT_SYMBOL(dev_get_stats);
86105 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
86106 index 6cc0481..59cfb00 100644
86107 --- a/net/core/dev_ioctl.c
86108 +++ b/net/core/dev_ioctl.c
86109 @@ -376,9 +376,13 @@ void dev_load(struct net *net, const char *name)
86110 if (no_module && capable(CAP_NET_ADMIN))
86111 no_module = request_module("netdev-%s", name);
86112 if (no_module && capable(CAP_SYS_MODULE)) {
86113 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
86114 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
86115 +#else
86116 if (!request_module("%s", name))
86117 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
86118 name);
86119 +#endif
86120 }
86121 }
86122 EXPORT_SYMBOL(dev_load);
86123 diff --git a/net/core/flow.c b/net/core/flow.c
86124 index 2bfd081..53c6058 100644
86125 --- a/net/core/flow.c
86126 +++ b/net/core/flow.c
86127 @@ -61,7 +61,7 @@ struct flow_cache {
86128 struct timer_list rnd_timer;
86129 };
86130
86131 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
86132 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
86133 EXPORT_SYMBOL(flow_cache_genid);
86134 static struct flow_cache flow_cache_global;
86135 static struct kmem_cache *flow_cachep __read_mostly;
86136 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
86137
86138 static int flow_entry_valid(struct flow_cache_entry *fle)
86139 {
86140 - if (atomic_read(&flow_cache_genid) != fle->genid)
86141 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
86142 return 0;
86143 if (fle->object && !fle->object->ops->check(fle->object))
86144 return 0;
86145 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
86146 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
86147 fcp->hash_count++;
86148 }
86149 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
86150 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
86151 flo = fle->object;
86152 if (!flo)
86153 goto ret_object;
86154 @@ -279,7 +279,7 @@ nocache:
86155 }
86156 flo = resolver(net, key, family, dir, flo, ctx);
86157 if (fle) {
86158 - fle->genid = atomic_read(&flow_cache_genid);
86159 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
86160 if (!IS_ERR(flo))
86161 fle->object = flo;
86162 else
86163 diff --git a/net/core/iovec.c b/net/core/iovec.c
86164 index 7e7aeb0..2a998cb 100644
86165 --- a/net/core/iovec.c
86166 +++ b/net/core/iovec.c
86167 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86168 if (m->msg_namelen) {
86169 if (mode == VERIFY_READ) {
86170 void __user *namep;
86171 - namep = (void __user __force *) m->msg_name;
86172 + namep = (void __force_user *) m->msg_name;
86173 err = move_addr_to_kernel(namep, m->msg_namelen,
86174 address);
86175 if (err < 0)
86176 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86177 }
86178
86179 size = m->msg_iovlen * sizeof(struct iovec);
86180 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
86181 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
86182 return -EFAULT;
86183
86184 m->msg_iov = iov;
86185 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
86186 index 3863b8f..85c99a6 100644
86187 --- a/net/core/neighbour.c
86188 +++ b/net/core/neighbour.c
86189 @@ -2778,7 +2778,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
86190 size_t *lenp, loff_t *ppos)
86191 {
86192 int size, ret;
86193 - ctl_table tmp = *ctl;
86194 + ctl_table_no_const tmp = *ctl;
86195
86196 tmp.extra1 = &zero;
86197 tmp.extra2 = &unres_qlen_max;
86198 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
86199 index 3174f19..5810985 100644
86200 --- a/net/core/net-procfs.c
86201 +++ b/net/core/net-procfs.c
86202 @@ -271,8 +271,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
86203 else
86204 seq_printf(seq, "%04x", ntohs(pt->type));
86205
86206 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86207 + seq_printf(seq, " %-8s %pF\n",
86208 + pt->dev ? pt->dev->name : "", NULL);
86209 +#else
86210 seq_printf(seq, " %-8s %pF\n",
86211 pt->dev ? pt->dev->name : "", pt->func);
86212 +#endif
86213 }
86214
86215 return 0;
86216 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
86217 index 7427ab5..389f411 100644
86218 --- a/net/core/net-sysfs.c
86219 +++ b/net/core/net-sysfs.c
86220 @@ -1321,7 +1321,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
86221 }
86222 EXPORT_SYMBOL(netdev_class_remove_file);
86223
86224 -int netdev_kobject_init(void)
86225 +int __init netdev_kobject_init(void)
86226 {
86227 kobj_ns_type_register(&net_ns_type_operations);
86228 return class_register(&net_class);
86229 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
86230 index 80e271d..2980cc2 100644
86231 --- a/net/core/net_namespace.c
86232 +++ b/net/core/net_namespace.c
86233 @@ -442,7 +442,7 @@ static int __register_pernet_operations(struct list_head *list,
86234 int error;
86235 LIST_HEAD(net_exit_list);
86236
86237 - list_add_tail(&ops->list, list);
86238 + pax_list_add_tail((struct list_head *)&ops->list, list);
86239 if (ops->init || (ops->id && ops->size)) {
86240 for_each_net(net) {
86241 error = ops_init(ops, net);
86242 @@ -455,7 +455,7 @@ static int __register_pernet_operations(struct list_head *list,
86243
86244 out_undo:
86245 /* If I have an error cleanup all namespaces I initialized */
86246 - list_del(&ops->list);
86247 + pax_list_del((struct list_head *)&ops->list);
86248 ops_exit_list(ops, &net_exit_list);
86249 ops_free_list(ops, &net_exit_list);
86250 return error;
86251 @@ -466,7 +466,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
86252 struct net *net;
86253 LIST_HEAD(net_exit_list);
86254
86255 - list_del(&ops->list);
86256 + pax_list_del((struct list_head *)&ops->list);
86257 for_each_net(net)
86258 list_add_tail(&net->exit_list, &net_exit_list);
86259 ops_exit_list(ops, &net_exit_list);
86260 @@ -600,7 +600,7 @@ int register_pernet_device(struct pernet_operations *ops)
86261 mutex_lock(&net_mutex);
86262 error = register_pernet_operations(&pernet_list, ops);
86263 if (!error && (first_device == &pernet_list))
86264 - first_device = &ops->list;
86265 + first_device = (struct list_head *)&ops->list;
86266 mutex_unlock(&net_mutex);
86267 return error;
86268 }
86269 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
86270 index 23854b5..ff4fda4 100644
86271 --- a/net/core/rtnetlink.c
86272 +++ b/net/core/rtnetlink.c
86273 @@ -58,7 +58,7 @@ struct rtnl_link {
86274 rtnl_doit_func doit;
86275 rtnl_dumpit_func dumpit;
86276 rtnl_calcit_func calcit;
86277 -};
86278 +} __no_const;
86279
86280 static DEFINE_MUTEX(rtnl_mutex);
86281
86282 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
86283 if (rtnl_link_ops_get(ops->kind))
86284 return -EEXIST;
86285
86286 - if (!ops->dellink)
86287 - ops->dellink = unregister_netdevice_queue;
86288 + if (!ops->dellink) {
86289 + pax_open_kernel();
86290 + *(void **)&ops->dellink = unregister_netdevice_queue;
86291 + pax_close_kernel();
86292 + }
86293
86294 - list_add_tail(&ops->list, &link_ops);
86295 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
86296 return 0;
86297 }
86298 EXPORT_SYMBOL_GPL(__rtnl_link_register);
86299 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
86300 for_each_net(net) {
86301 __rtnl_kill_links(net, ops);
86302 }
86303 - list_del(&ops->list);
86304 + pax_list_del((struct list_head *)&ops->list);
86305 }
86306 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
86307
86308 diff --git a/net/core/scm.c b/net/core/scm.c
86309 index 2dc6cda..2159524 100644
86310 --- a/net/core/scm.c
86311 +++ b/net/core/scm.c
86312 @@ -226,7 +226,7 @@ EXPORT_SYMBOL(__scm_send);
86313 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86314 {
86315 struct cmsghdr __user *cm
86316 - = (__force struct cmsghdr __user *)msg->msg_control;
86317 + = (struct cmsghdr __force_user *)msg->msg_control;
86318 struct cmsghdr cmhdr;
86319 int cmlen = CMSG_LEN(len);
86320 int err;
86321 @@ -249,7 +249,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86322 err = -EFAULT;
86323 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
86324 goto out;
86325 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
86326 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
86327 goto out;
86328 cmlen = CMSG_SPACE(len);
86329 if (msg->msg_controllen < cmlen)
86330 @@ -265,7 +265,7 @@ EXPORT_SYMBOL(put_cmsg);
86331 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86332 {
86333 struct cmsghdr __user *cm
86334 - = (__force struct cmsghdr __user*)msg->msg_control;
86335 + = (struct cmsghdr __force_user *)msg->msg_control;
86336
86337 int fdmax = 0;
86338 int fdnum = scm->fp->count;
86339 @@ -285,7 +285,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86340 if (fdnum < fdmax)
86341 fdmax = fdnum;
86342
86343 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
86344 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
86345 i++, cmfptr++)
86346 {
86347 struct socket *sock;
86348 diff --git a/net/core/secure_seq.c b/net/core/secure_seq.c
86349 index e61a8bb..6a2f13c 100644
86350 --- a/net/core/secure_seq.c
86351 +++ b/net/core/secure_seq.c
86352 @@ -12,12 +12,10 @@
86353
86354 static u32 net_secret[MD5_MESSAGE_BYTES / 4] ____cacheline_aligned;
86355
86356 -static int __init net_secret_init(void)
86357 +void net_secret_init(void)
86358 {
86359 get_random_bytes(net_secret, sizeof(net_secret));
86360 - return 0;
86361 }
86362 -late_initcall(net_secret_init);
86363
86364 #ifdef CONFIG_INET
86365 static u32 seq_scale(u32 seq)
86366 diff --git a/net/core/sock.c b/net/core/sock.c
86367 index 1432266..1a0d4a1 100644
86368 --- a/net/core/sock.c
86369 +++ b/net/core/sock.c
86370 @@ -390,7 +390,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86371 struct sk_buff_head *list = &sk->sk_receive_queue;
86372
86373 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
86374 - atomic_inc(&sk->sk_drops);
86375 + atomic_inc_unchecked(&sk->sk_drops);
86376 trace_sock_rcvqueue_full(sk, skb);
86377 return -ENOMEM;
86378 }
86379 @@ -400,7 +400,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86380 return err;
86381
86382 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
86383 - atomic_inc(&sk->sk_drops);
86384 + atomic_inc_unchecked(&sk->sk_drops);
86385 return -ENOBUFS;
86386 }
86387
86388 @@ -420,7 +420,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86389 skb_dst_force(skb);
86390
86391 spin_lock_irqsave(&list->lock, flags);
86392 - skb->dropcount = atomic_read(&sk->sk_drops);
86393 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
86394 __skb_queue_tail(list, skb);
86395 spin_unlock_irqrestore(&list->lock, flags);
86396
86397 @@ -440,7 +440,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86398 skb->dev = NULL;
86399
86400 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
86401 - atomic_inc(&sk->sk_drops);
86402 + atomic_inc_unchecked(&sk->sk_drops);
86403 goto discard_and_relse;
86404 }
86405 if (nested)
86406 @@ -458,7 +458,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86407 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
86408 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
86409 bh_unlock_sock(sk);
86410 - atomic_inc(&sk->sk_drops);
86411 + atomic_inc_unchecked(&sk->sk_drops);
86412 goto discard_and_relse;
86413 }
86414
86415 @@ -942,12 +942,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86416 struct timeval tm;
86417 } v;
86418
86419 - int lv = sizeof(int);
86420 - int len;
86421 + unsigned int lv = sizeof(int);
86422 + unsigned int len;
86423
86424 if (get_user(len, optlen))
86425 return -EFAULT;
86426 - if (len < 0)
86427 + if (len > INT_MAX)
86428 return -EINVAL;
86429
86430 memset(&v, 0, sizeof(v));
86431 @@ -1099,11 +1099,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86432
86433 case SO_PEERNAME:
86434 {
86435 - char address[128];
86436 + char address[_K_SS_MAXSIZE];
86437
86438 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
86439 return -ENOTCONN;
86440 - if (lv < len)
86441 + if (lv < len || sizeof address < len)
86442 return -EINVAL;
86443 if (copy_to_user(optval, address, len))
86444 return -EFAULT;
86445 @@ -1166,7 +1166,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86446
86447 if (len > lv)
86448 len = lv;
86449 - if (copy_to_user(optval, &v, len))
86450 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
86451 return -EFAULT;
86452 lenout:
86453 if (put_user(len, optlen))
86454 @@ -2284,7 +2284,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
86455 */
86456 smp_wmb();
86457 atomic_set(&sk->sk_refcnt, 1);
86458 - atomic_set(&sk->sk_drops, 0);
86459 + atomic_set_unchecked(&sk->sk_drops, 0);
86460 }
86461 EXPORT_SYMBOL(sock_init_data);
86462
86463 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
86464 index a29e90c..922399c 100644
86465 --- a/net/core/sock_diag.c
86466 +++ b/net/core/sock_diag.c
86467 @@ -9,26 +9,33 @@
86468 #include <linux/inet_diag.h>
86469 #include <linux/sock_diag.h>
86470
86471 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
86472 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
86473 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
86474 static DEFINE_MUTEX(sock_diag_table_mutex);
86475
86476 int sock_diag_check_cookie(void *sk, __u32 *cookie)
86477 {
86478 +#ifndef CONFIG_GRKERNSEC_HIDESYM
86479 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
86480 cookie[1] != INET_DIAG_NOCOOKIE) &&
86481 ((u32)(unsigned long)sk != cookie[0] ||
86482 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
86483 return -ESTALE;
86484 else
86485 +#endif
86486 return 0;
86487 }
86488 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
86489
86490 void sock_diag_save_cookie(void *sk, __u32 *cookie)
86491 {
86492 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86493 + cookie[0] = 0;
86494 + cookie[1] = 0;
86495 +#else
86496 cookie[0] = (u32)(unsigned long)sk;
86497 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
86498 +#endif
86499 }
86500 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
86501
86502 @@ -75,8 +82,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
86503 mutex_lock(&sock_diag_table_mutex);
86504 if (sock_diag_handlers[hndl->family])
86505 err = -EBUSY;
86506 - else
86507 + else {
86508 + pax_open_kernel();
86509 sock_diag_handlers[hndl->family] = hndl;
86510 + pax_close_kernel();
86511 + }
86512 mutex_unlock(&sock_diag_table_mutex);
86513
86514 return err;
86515 @@ -92,7 +102,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
86516
86517 mutex_lock(&sock_diag_table_mutex);
86518 BUG_ON(sock_diag_handlers[family] != hnld);
86519 + pax_open_kernel();
86520 sock_diag_handlers[family] = NULL;
86521 + pax_close_kernel();
86522 mutex_unlock(&sock_diag_table_mutex);
86523 }
86524 EXPORT_SYMBOL_GPL(sock_diag_unregister);
86525 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
86526 index cfdb46a..cef55e1 100644
86527 --- a/net/core/sysctl_net_core.c
86528 +++ b/net/core/sysctl_net_core.c
86529 @@ -28,7 +28,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
86530 {
86531 unsigned int orig_size, size;
86532 int ret, i;
86533 - ctl_table tmp = {
86534 + ctl_table_no_const tmp = {
86535 .data = &size,
86536 .maxlen = sizeof(size),
86537 .mode = table->mode
86538 @@ -211,13 +211,12 @@ static struct ctl_table netns_core_table[] = {
86539
86540 static __net_init int sysctl_core_net_init(struct net *net)
86541 {
86542 - struct ctl_table *tbl;
86543 + ctl_table_no_const *tbl = NULL;
86544
86545 net->core.sysctl_somaxconn = SOMAXCONN;
86546
86547 - tbl = netns_core_table;
86548 if (!net_eq(net, &init_net)) {
86549 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
86550 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
86551 if (tbl == NULL)
86552 goto err_dup;
86553
86554 @@ -227,17 +226,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
86555 if (net->user_ns != &init_user_ns) {
86556 tbl[0].procname = NULL;
86557 }
86558 - }
86559 -
86560 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86561 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86562 + } else
86563 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
86564 if (net->core.sysctl_hdr == NULL)
86565 goto err_reg;
86566
86567 return 0;
86568
86569 err_reg:
86570 - if (tbl != netns_core_table)
86571 - kfree(tbl);
86572 + kfree(tbl);
86573 err_dup:
86574 return -ENOMEM;
86575 }
86576 @@ -252,7 +250,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
86577 kfree(tbl);
86578 }
86579
86580 -static __net_initdata struct pernet_operations sysctl_core_ops = {
86581 +static __net_initconst struct pernet_operations sysctl_core_ops = {
86582 .init = sysctl_core_net_init,
86583 .exit = sysctl_core_net_exit,
86584 };
86585 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
86586 index c21f200..bc4565b 100644
86587 --- a/net/decnet/af_decnet.c
86588 +++ b/net/decnet/af_decnet.c
86589 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
86590 .sysctl_rmem = sysctl_decnet_rmem,
86591 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
86592 .obj_size = sizeof(struct dn_sock),
86593 + .slab_flags = SLAB_USERCOPY,
86594 };
86595
86596 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
86597 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
86598 index a55eecc..dd8428c 100644
86599 --- a/net/decnet/sysctl_net_decnet.c
86600 +++ b/net/decnet/sysctl_net_decnet.c
86601 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
86602
86603 if (len > *lenp) len = *lenp;
86604
86605 - if (copy_to_user(buffer, addr, len))
86606 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
86607 return -EFAULT;
86608
86609 *lenp = len;
86610 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
86611
86612 if (len > *lenp) len = *lenp;
86613
86614 - if (copy_to_user(buffer, devname, len))
86615 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
86616 return -EFAULT;
86617
86618 *lenp = len;
86619 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
86620 index c929d9c..df10cde 100644
86621 --- a/net/ipv4/af_inet.c
86622 +++ b/net/ipv4/af_inet.c
86623 @@ -115,6 +115,7 @@
86624 #include <net/inet_common.h>
86625 #include <net/xfrm.h>
86626 #include <net/net_namespace.h>
86627 +#include <net/secure_seq.h>
86628 #ifdef CONFIG_IP_MROUTE
86629 #include <linux/mroute.h>
86630 #endif
86631 @@ -263,8 +264,10 @@ void build_ehash_secret(void)
86632 get_random_bytes(&rnd, sizeof(rnd));
86633 } while (rnd == 0);
86634
86635 - if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0)
86636 + if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0) {
86637 get_random_bytes(&ipv6_hash_secret, sizeof(ipv6_hash_secret));
86638 + net_secret_init();
86639 + }
86640 }
86641 EXPORT_SYMBOL(build_ehash_secret);
86642
86643 @@ -1699,13 +1702,9 @@ static int __init inet_init(void)
86644
86645 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
86646
86647 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
86648 - if (!sysctl_local_reserved_ports)
86649 - goto out;
86650 -
86651 rc = proto_register(&tcp_prot, 1);
86652 if (rc)
86653 - goto out_free_reserved_ports;
86654 + goto out;
86655
86656 rc = proto_register(&udp_prot, 1);
86657 if (rc)
86658 @@ -1814,8 +1813,6 @@ out_unregister_udp_proto:
86659 proto_unregister(&udp_prot);
86660 out_unregister_tcp_proto:
86661 proto_unregister(&tcp_prot);
86662 -out_free_reserved_ports:
86663 - kfree(sysctl_local_reserved_ports);
86664 goto out;
86665 }
86666
86667 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
86668 index 2e7f194..0fa4d6d 100644
86669 --- a/net/ipv4/ah4.c
86670 +++ b/net/ipv4/ah4.c
86671 @@ -420,7 +420,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
86672 return;
86673
86674 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86675 - atomic_inc(&flow_cache_genid);
86676 + atomic_inc_unchecked(&flow_cache_genid);
86677 rt_genid_bump(net);
86678
86679 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
86680 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
86681 index c6287cd..e9bc96a 100644
86682 --- a/net/ipv4/devinet.c
86683 +++ b/net/ipv4/devinet.c
86684 @@ -1992,7 +1992,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
86685 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
86686 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
86687
86688 -static struct devinet_sysctl_table {
86689 +static const struct devinet_sysctl_table {
86690 struct ctl_table_header *sysctl_header;
86691 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
86692 } devinet_sysctl = {
86693 @@ -2110,7 +2110,7 @@ static __net_init int devinet_init_net(struct net *net)
86694 int err;
86695 struct ipv4_devconf *all, *dflt;
86696 #ifdef CONFIG_SYSCTL
86697 - struct ctl_table *tbl = ctl_forward_entry;
86698 + ctl_table_no_const *tbl = NULL;
86699 struct ctl_table_header *forw_hdr;
86700 #endif
86701
86702 @@ -2128,7 +2128,7 @@ static __net_init int devinet_init_net(struct net *net)
86703 goto err_alloc_dflt;
86704
86705 #ifdef CONFIG_SYSCTL
86706 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
86707 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
86708 if (tbl == NULL)
86709 goto err_alloc_ctl;
86710
86711 @@ -2148,7 +2148,10 @@ static __net_init int devinet_init_net(struct net *net)
86712 goto err_reg_dflt;
86713
86714 err = -ENOMEM;
86715 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86716 + if (!net_eq(net, &init_net))
86717 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86718 + else
86719 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
86720 if (forw_hdr == NULL)
86721 goto err_reg_ctl;
86722 net->ipv4.forw_hdr = forw_hdr;
86723 @@ -2164,8 +2167,7 @@ err_reg_ctl:
86724 err_reg_dflt:
86725 __devinet_sysctl_unregister(all);
86726 err_reg_all:
86727 - if (tbl != ctl_forward_entry)
86728 - kfree(tbl);
86729 + kfree(tbl);
86730 err_alloc_ctl:
86731 #endif
86732 if (dflt != &ipv4_devconf_dflt)
86733 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
86734 index 4cfe34d..a6ba66e 100644
86735 --- a/net/ipv4/esp4.c
86736 +++ b/net/ipv4/esp4.c
86737 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
86738 return;
86739
86740 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86741 - atomic_inc(&flow_cache_genid);
86742 + atomic_inc_unchecked(&flow_cache_genid);
86743 rt_genid_bump(net);
86744
86745 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
86746 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
86747 index eb4bb12..ee4ec7d 100644
86748 --- a/net/ipv4/fib_frontend.c
86749 +++ b/net/ipv4/fib_frontend.c
86750 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
86751 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86752 fib_sync_up(dev);
86753 #endif
86754 - atomic_inc(&net->ipv4.dev_addr_genid);
86755 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86756 rt_cache_flush(dev_net(dev));
86757 break;
86758 case NETDEV_DOWN:
86759 fib_del_ifaddr(ifa, NULL);
86760 - atomic_inc(&net->ipv4.dev_addr_genid);
86761 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86762 if (ifa->ifa_dev->ifa_list == NULL) {
86763 /* Last address was deleted from this interface.
86764 * Disable IP.
86765 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
86766 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86767 fib_sync_up(dev);
86768 #endif
86769 - atomic_inc(&net->ipv4.dev_addr_genid);
86770 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86771 rt_cache_flush(net);
86772 break;
86773 case NETDEV_DOWN:
86774 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
86775 index 8f6cb7a..34507f9 100644
86776 --- a/net/ipv4/fib_semantics.c
86777 +++ b/net/ipv4/fib_semantics.c
86778 @@ -765,7 +765,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
86779 nh->nh_saddr = inet_select_addr(nh->nh_dev,
86780 nh->nh_gw,
86781 nh->nh_parent->fib_scope);
86782 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
86783 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
86784
86785 return nh->nh_saddr;
86786 }
86787 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
86788 index 786d97a..1889c0d 100644
86789 --- a/net/ipv4/inet_connection_sock.c
86790 +++ b/net/ipv4/inet_connection_sock.c
86791 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
86792 .range = { 32768, 61000 },
86793 };
86794
86795 -unsigned long *sysctl_local_reserved_ports;
86796 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
86797 EXPORT_SYMBOL(sysctl_local_reserved_ports);
86798
86799 void inet_get_local_port_range(int *low, int *high)
86800 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
86801 index 6af375a..c493c74 100644
86802 --- a/net/ipv4/inet_hashtables.c
86803 +++ b/net/ipv4/inet_hashtables.c
86804 @@ -18,12 +18,15 @@
86805 #include <linux/sched.h>
86806 #include <linux/slab.h>
86807 #include <linux/wait.h>
86808 +#include <linux/security.h>
86809
86810 #include <net/inet_connection_sock.h>
86811 #include <net/inet_hashtables.h>
86812 #include <net/secure_seq.h>
86813 #include <net/ip.h>
86814
86815 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
86816 +
86817 /*
86818 * Allocate and initialize a new local port bind bucket.
86819 * The bindhash mutex for snum's hash chain must be held here.
86820 @@ -554,6 +557,8 @@ ok:
86821 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
86822 spin_unlock(&head->lock);
86823
86824 + gr_update_task_in_ip_table(current, inet_sk(sk));
86825 +
86826 if (tw) {
86827 inet_twsk_deschedule(tw, death_row);
86828 while (twrefcnt) {
86829 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
86830 index 000e3d2..5472da3 100644
86831 --- a/net/ipv4/inetpeer.c
86832 +++ b/net/ipv4/inetpeer.c
86833 @@ -503,8 +503,8 @@ relookup:
86834 if (p) {
86835 p->daddr = *daddr;
86836 atomic_set(&p->refcnt, 1);
86837 - atomic_set(&p->rid, 0);
86838 - atomic_set(&p->ip_id_count,
86839 + atomic_set_unchecked(&p->rid, 0);
86840 + atomic_set_unchecked(&p->ip_id_count,
86841 (daddr->family == AF_INET) ?
86842 secure_ip_id(daddr->addr.a4) :
86843 secure_ipv6_id(daddr->addr.a6));
86844 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
86845 index 52c273e..579060b 100644
86846 --- a/net/ipv4/ip_fragment.c
86847 +++ b/net/ipv4/ip_fragment.c
86848 @@ -311,7 +311,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
86849 return 0;
86850
86851 start = qp->rid;
86852 - end = atomic_inc_return(&peer->rid);
86853 + end = atomic_inc_return_unchecked(&peer->rid);
86854 qp->rid = end;
86855
86856 rc = qp->q.fragments && (end - start) > max;
86857 @@ -788,12 +788,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
86858
86859 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86860 {
86861 - struct ctl_table *table;
86862 + ctl_table_no_const *table = NULL;
86863 struct ctl_table_header *hdr;
86864
86865 - table = ip4_frags_ns_ctl_table;
86866 if (!net_eq(net, &init_net)) {
86867 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
86868 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
86869 if (table == NULL)
86870 goto err_alloc;
86871
86872 @@ -804,9 +803,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86873 /* Don't export sysctls to unprivileged users */
86874 if (net->user_ns != &init_user_ns)
86875 table[0].procname = NULL;
86876 - }
86877 + hdr = register_net_sysctl(net, "net/ipv4", table);
86878 + } else
86879 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
86880
86881 - hdr = register_net_sysctl(net, "net/ipv4", table);
86882 if (hdr == NULL)
86883 goto err_reg;
86884
86885 @@ -814,8 +814,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86886 return 0;
86887
86888 err_reg:
86889 - if (!net_eq(net, &init_net))
86890 - kfree(table);
86891 + kfree(table);
86892 err_alloc:
86893 return -ENOMEM;
86894 }
86895 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
86896 index 91d66db..4af7d99 100644
86897 --- a/net/ipv4/ip_gre.c
86898 +++ b/net/ipv4/ip_gre.c
86899 @@ -124,7 +124,7 @@ static bool log_ecn_error = true;
86900 module_param(log_ecn_error, bool, 0644);
86901 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
86902
86903 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
86904 +static struct rtnl_link_ops ipgre_link_ops;
86905 static int ipgre_tunnel_init(struct net_device *dev);
86906 static void ipgre_tunnel_setup(struct net_device *dev);
86907 static int ipgre_tunnel_bind_dev(struct net_device *dev);
86908 @@ -1823,7 +1823,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
86909 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
86910 };
86911
86912 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
86913 +static struct rtnl_link_ops ipgre_link_ops = {
86914 .kind = "gre",
86915 .maxtype = IFLA_GRE_MAX,
86916 .policy = ipgre_policy,
86917 @@ -1836,7 +1836,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
86918 .fill_info = ipgre_fill_info,
86919 };
86920
86921 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
86922 +static struct rtnl_link_ops ipgre_tap_ops = {
86923 .kind = "gretap",
86924 .maxtype = IFLA_GRE_MAX,
86925 .policy = ipgre_policy,
86926 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
86927 index d9c4f11..02b82dbc 100644
86928 --- a/net/ipv4/ip_sockglue.c
86929 +++ b/net/ipv4/ip_sockglue.c
86930 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
86931 len = min_t(unsigned int, len, opt->optlen);
86932 if (put_user(len, optlen))
86933 return -EFAULT;
86934 - if (copy_to_user(optval, opt->__data, len))
86935 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
86936 + copy_to_user(optval, opt->__data, len))
86937 return -EFAULT;
86938 return 0;
86939 }
86940 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
86941 if (sk->sk_type != SOCK_STREAM)
86942 return -ENOPROTOOPT;
86943
86944 - msg.msg_control = optval;
86945 + msg.msg_control = (void __force_kernel *)optval;
86946 msg.msg_controllen = len;
86947 msg.msg_flags = flags;
86948
86949 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
86950 index c3a4233..1412161 100644
86951 --- a/net/ipv4/ip_vti.c
86952 +++ b/net/ipv4/ip_vti.c
86953 @@ -47,7 +47,7 @@
86954 #define HASH_SIZE 16
86955 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
86956
86957 -static struct rtnl_link_ops vti_link_ops __read_mostly;
86958 +static struct rtnl_link_ops vti_link_ops;
86959
86960 static int vti_net_id __read_mostly;
86961 struct vti_net {
86962 @@ -886,7 +886,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
86963 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
86964 };
86965
86966 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
86967 +static struct rtnl_link_ops vti_link_ops = {
86968 .kind = "vti",
86969 .maxtype = IFLA_VTI_MAX,
86970 .policy = vti_policy,
86971 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
86972 index f01d1b1..8fe03ad 100644
86973 --- a/net/ipv4/ipcomp.c
86974 +++ b/net/ipv4/ipcomp.c
86975 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
86976 return;
86977
86978 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86979 - atomic_inc(&flow_cache_genid);
86980 + atomic_inc_unchecked(&flow_cache_genid);
86981 rt_genid_bump(net);
86982
86983 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
86984 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
86985 index bf6c5cf..ab2e9c6 100644
86986 --- a/net/ipv4/ipconfig.c
86987 +++ b/net/ipv4/ipconfig.c
86988 @@ -323,7 +323,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
86989
86990 mm_segment_t oldfs = get_fs();
86991 set_fs(get_ds());
86992 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
86993 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
86994 set_fs(oldfs);
86995 return res;
86996 }
86997 @@ -334,7 +334,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
86998
86999 mm_segment_t oldfs = get_fs();
87000 set_fs(get_ds());
87001 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87002 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87003 set_fs(oldfs);
87004 return res;
87005 }
87006 @@ -345,7 +345,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
87007
87008 mm_segment_t oldfs = get_fs();
87009 set_fs(get_ds());
87010 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
87011 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
87012 set_fs(oldfs);
87013 return res;
87014 }
87015 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
87016 index 8f024d4..8b3500c 100644
87017 --- a/net/ipv4/ipip.c
87018 +++ b/net/ipv4/ipip.c
87019 @@ -138,7 +138,7 @@ struct ipip_net {
87020 static int ipip_tunnel_init(struct net_device *dev);
87021 static void ipip_tunnel_setup(struct net_device *dev);
87022 static void ipip_dev_free(struct net_device *dev);
87023 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
87024 +static struct rtnl_link_ops ipip_link_ops;
87025
87026 static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev,
87027 struct rtnl_link_stats64 *tot)
87028 @@ -974,7 +974,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
87029 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
87030 };
87031
87032 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
87033 +static struct rtnl_link_ops ipip_link_ops = {
87034 .kind = "ipip",
87035 .maxtype = IFLA_IPTUN_MAX,
87036 .policy = ipip_policy,
87037 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
87038 index 7dc6a97..229c61b 100644
87039 --- a/net/ipv4/netfilter/arp_tables.c
87040 +++ b/net/ipv4/netfilter/arp_tables.c
87041 @@ -879,14 +879,14 @@ static int compat_table_info(const struct xt_table_info *info,
87042 #endif
87043
87044 static int get_info(struct net *net, void __user *user,
87045 - const int *len, int compat)
87046 + int len, int compat)
87047 {
87048 char name[XT_TABLE_MAXNAMELEN];
87049 struct xt_table *t;
87050 int ret;
87051
87052 - if (*len != sizeof(struct arpt_getinfo)) {
87053 - duprintf("length %u != %Zu\n", *len,
87054 + if (len != sizeof(struct arpt_getinfo)) {
87055 + duprintf("length %u != %Zu\n", len,
87056 sizeof(struct arpt_getinfo));
87057 return -EINVAL;
87058 }
87059 @@ -923,7 +923,7 @@ static int get_info(struct net *net, void __user *user,
87060 info.size = private->size;
87061 strcpy(info.name, name);
87062
87063 - if (copy_to_user(user, &info, *len) != 0)
87064 + if (copy_to_user(user, &info, len) != 0)
87065 ret = -EFAULT;
87066 else
87067 ret = 0;
87068 @@ -1682,7 +1682,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
87069
87070 switch (cmd) {
87071 case ARPT_SO_GET_INFO:
87072 - ret = get_info(sock_net(sk), user, len, 1);
87073 + ret = get_info(sock_net(sk), user, *len, 1);
87074 break;
87075 case ARPT_SO_GET_ENTRIES:
87076 ret = compat_get_entries(sock_net(sk), user, len);
87077 @@ -1727,7 +1727,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
87078
87079 switch (cmd) {
87080 case ARPT_SO_GET_INFO:
87081 - ret = get_info(sock_net(sk), user, len, 0);
87082 + ret = get_info(sock_net(sk), user, *len, 0);
87083 break;
87084
87085 case ARPT_SO_GET_ENTRIES:
87086 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
87087 index 3efcf87..5247916 100644
87088 --- a/net/ipv4/netfilter/ip_tables.c
87089 +++ b/net/ipv4/netfilter/ip_tables.c
87090 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
87091 #endif
87092
87093 static int get_info(struct net *net, void __user *user,
87094 - const int *len, int compat)
87095 + int len, int compat)
87096 {
87097 char name[XT_TABLE_MAXNAMELEN];
87098 struct xt_table *t;
87099 int ret;
87100
87101 - if (*len != sizeof(struct ipt_getinfo)) {
87102 - duprintf("length %u != %zu\n", *len,
87103 + if (len != sizeof(struct ipt_getinfo)) {
87104 + duprintf("length %u != %zu\n", len,
87105 sizeof(struct ipt_getinfo));
87106 return -EINVAL;
87107 }
87108 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
87109 info.size = private->size;
87110 strcpy(info.name, name);
87111
87112 - if (copy_to_user(user, &info, *len) != 0)
87113 + if (copy_to_user(user, &info, len) != 0)
87114 ret = -EFAULT;
87115 else
87116 ret = 0;
87117 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87118
87119 switch (cmd) {
87120 case IPT_SO_GET_INFO:
87121 - ret = get_info(sock_net(sk), user, len, 1);
87122 + ret = get_info(sock_net(sk), user, *len, 1);
87123 break;
87124 case IPT_SO_GET_ENTRIES:
87125 ret = compat_get_entries(sock_net(sk), user, len);
87126 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87127
87128 switch (cmd) {
87129 case IPT_SO_GET_INFO:
87130 - ret = get_info(sock_net(sk), user, len, 0);
87131 + ret = get_info(sock_net(sk), user, *len, 0);
87132 break;
87133
87134 case IPT_SO_GET_ENTRIES:
87135 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
87136 index 2e91006..f084394 100644
87137 --- a/net/ipv4/ping.c
87138 +++ b/net/ipv4/ping.c
87139 @@ -844,7 +844,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
87140 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87141 0, sock_i_ino(sp),
87142 atomic_read(&sp->sk_refcnt), sp,
87143 - atomic_read(&sp->sk_drops), len);
87144 + atomic_read_unchecked(&sp->sk_drops), len);
87145 }
87146
87147 static int ping_seq_show(struct seq_file *seq, void *v)
87148 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
87149 index dd44e0a..06dcca4 100644
87150 --- a/net/ipv4/raw.c
87151 +++ b/net/ipv4/raw.c
87152 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
87153 int raw_rcv(struct sock *sk, struct sk_buff *skb)
87154 {
87155 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
87156 - atomic_inc(&sk->sk_drops);
87157 + atomic_inc_unchecked(&sk->sk_drops);
87158 kfree_skb(skb);
87159 return NET_RX_DROP;
87160 }
87161 @@ -745,16 +745,20 @@ static int raw_init(struct sock *sk)
87162
87163 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
87164 {
87165 + struct icmp_filter filter;
87166 +
87167 if (optlen > sizeof(struct icmp_filter))
87168 optlen = sizeof(struct icmp_filter);
87169 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
87170 + if (copy_from_user(&filter, optval, optlen))
87171 return -EFAULT;
87172 + raw_sk(sk)->filter = filter;
87173 return 0;
87174 }
87175
87176 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
87177 {
87178 int len, ret = -EFAULT;
87179 + struct icmp_filter filter;
87180
87181 if (get_user(len, optlen))
87182 goto out;
87183 @@ -764,8 +768,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
87184 if (len > sizeof(struct icmp_filter))
87185 len = sizeof(struct icmp_filter);
87186 ret = -EFAULT;
87187 - if (put_user(len, optlen) ||
87188 - copy_to_user(optval, &raw_sk(sk)->filter, len))
87189 + filter = raw_sk(sk)->filter;
87190 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
87191 goto out;
87192 ret = 0;
87193 out: return ret;
87194 @@ -994,7 +998,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87195 0, 0L, 0,
87196 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87197 0, sock_i_ino(sp),
87198 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87199 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87200 }
87201
87202 static int raw_seq_show(struct seq_file *seq, void *v)
87203 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
87204 index 6e28514..5e1b055 100644
87205 --- a/net/ipv4/route.c
87206 +++ b/net/ipv4/route.c
87207 @@ -2553,34 +2553,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
87208 .maxlen = sizeof(int),
87209 .mode = 0200,
87210 .proc_handler = ipv4_sysctl_rtcache_flush,
87211 + .extra1 = &init_net,
87212 },
87213 { },
87214 };
87215
87216 static __net_init int sysctl_route_net_init(struct net *net)
87217 {
87218 - struct ctl_table *tbl;
87219 + ctl_table_no_const *tbl = NULL;
87220
87221 - tbl = ipv4_route_flush_table;
87222 if (!net_eq(net, &init_net)) {
87223 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87224 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87225 if (tbl == NULL)
87226 goto err_dup;
87227
87228 /* Don't export sysctls to unprivileged users */
87229 if (net->user_ns != &init_user_ns)
87230 tbl[0].procname = NULL;
87231 - }
87232 - tbl[0].extra1 = net;
87233 + tbl[0].extra1 = net;
87234 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87235 + } else
87236 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
87237
87238 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87239 if (net->ipv4.route_hdr == NULL)
87240 goto err_reg;
87241 return 0;
87242
87243 err_reg:
87244 - if (tbl != ipv4_route_flush_table)
87245 - kfree(tbl);
87246 + kfree(tbl);
87247 err_dup:
87248 return -ENOMEM;
87249 }
87250 @@ -2603,7 +2603,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
87251
87252 static __net_init int rt_genid_init(struct net *net)
87253 {
87254 - atomic_set(&net->rt_genid, 0);
87255 + atomic_set_unchecked(&net->rt_genid, 0);
87256 get_random_bytes(&net->ipv4.dev_addr_genid,
87257 sizeof(net->ipv4.dev_addr_genid));
87258 return 0;
87259 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
87260 index 960fd29..d55bf64 100644
87261 --- a/net/ipv4/sysctl_net_ipv4.c
87262 +++ b/net/ipv4/sysctl_net_ipv4.c
87263 @@ -55,7 +55,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
87264 {
87265 int ret;
87266 int range[2];
87267 - ctl_table tmp = {
87268 + ctl_table_no_const tmp = {
87269 .data = &range,
87270 .maxlen = sizeof(range),
87271 .mode = table->mode,
87272 @@ -108,7 +108,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
87273 int ret;
87274 gid_t urange[2];
87275 kgid_t low, high;
87276 - ctl_table tmp = {
87277 + ctl_table_no_const tmp = {
87278 .data = &urange,
87279 .maxlen = sizeof(urange),
87280 .mode = table->mode,
87281 @@ -139,7 +139,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
87282 void __user *buffer, size_t *lenp, loff_t *ppos)
87283 {
87284 char val[TCP_CA_NAME_MAX];
87285 - ctl_table tbl = {
87286 + ctl_table_no_const tbl = {
87287 .data = val,
87288 .maxlen = TCP_CA_NAME_MAX,
87289 };
87290 @@ -158,7 +158,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
87291 void __user *buffer, size_t *lenp,
87292 loff_t *ppos)
87293 {
87294 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
87295 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
87296 int ret;
87297
87298 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87299 @@ -175,7 +175,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
87300 void __user *buffer, size_t *lenp,
87301 loff_t *ppos)
87302 {
87303 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
87304 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
87305 int ret;
87306
87307 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87308 @@ -201,15 +201,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87309 struct mem_cgroup *memcg;
87310 #endif
87311
87312 - ctl_table tmp = {
87313 + ctl_table_no_const tmp = {
87314 .data = &vec,
87315 .maxlen = sizeof(vec),
87316 .mode = ctl->mode,
87317 };
87318
87319 if (!write) {
87320 - ctl->data = &net->ipv4.sysctl_tcp_mem;
87321 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
87322 + ctl_table_no_const tcp_mem = *ctl;
87323 +
87324 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
87325 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
87326 }
87327
87328 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
87329 @@ -236,7 +238,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87330 static int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
87331 size_t *lenp, loff_t *ppos)
87332 {
87333 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87334 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87335 struct tcp_fastopen_context *ctxt;
87336 int ret;
87337 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
87338 @@ -477,7 +479,7 @@ static struct ctl_table ipv4_table[] = {
87339 },
87340 {
87341 .procname = "ip_local_reserved_ports",
87342 - .data = NULL, /* initialized in sysctl_ipv4_init */
87343 + .data = sysctl_local_reserved_ports,
87344 .maxlen = 65536,
87345 .mode = 0644,
87346 .proc_handler = proc_do_large_bitmap,
87347 @@ -856,11 +858,10 @@ static struct ctl_table ipv4_net_table[] = {
87348
87349 static __net_init int ipv4_sysctl_init_net(struct net *net)
87350 {
87351 - struct ctl_table *table;
87352 + ctl_table_no_const *table = NULL;
87353
87354 - table = ipv4_net_table;
87355 if (!net_eq(net, &init_net)) {
87356 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
87357 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
87358 if (table == NULL)
87359 goto err_alloc;
87360
87361 @@ -895,15 +896,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
87362
87363 tcp_init_mem(net);
87364
87365 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87366 + if (!net_eq(net, &init_net))
87367 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87368 + else
87369 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
87370 if (net->ipv4.ipv4_hdr == NULL)
87371 goto err_reg;
87372
87373 return 0;
87374
87375 err_reg:
87376 - if (!net_eq(net, &init_net))
87377 - kfree(table);
87378 + kfree(table);
87379 err_alloc:
87380 return -ENOMEM;
87381 }
87382 @@ -925,16 +928,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
87383 static __init int sysctl_ipv4_init(void)
87384 {
87385 struct ctl_table_header *hdr;
87386 - struct ctl_table *i;
87387 -
87388 - for (i = ipv4_table; i->procname; i++) {
87389 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
87390 - i->data = sysctl_local_reserved_ports;
87391 - break;
87392 - }
87393 - }
87394 - if (!i->procname)
87395 - return -EINVAL;
87396
87397 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
87398 if (hdr == NULL)
87399 diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
87400 index e220207..cdeb839 100644
87401 --- a/net/ipv4/tcp.c
87402 +++ b/net/ipv4/tcp.c
87403 @@ -3383,8 +3383,11 @@ int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *hp,
87404
87405 for (i = 0; i < shi->nr_frags; ++i) {
87406 const struct skb_frag_struct *f = &shi->frags[i];
87407 - struct page *page = skb_frag_page(f);
87408 - sg_set_page(&sg, page, skb_frag_size(f), f->page_offset);
87409 + unsigned int offset = f->page_offset;
87410 + struct page *page = skb_frag_page(f) + (offset >> PAGE_SHIFT);
87411 +
87412 + sg_set_page(&sg, page, skb_frag_size(f),
87413 + offset_in_page(offset));
87414 if (crypto_hash_update(desc, &sg, skb_frag_size(f)))
87415 return 1;
87416 }
87417 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
87418 index 13b9c08..d33a8d0 100644
87419 --- a/net/ipv4/tcp_input.c
87420 +++ b/net/ipv4/tcp_input.c
87421 @@ -4724,7 +4724,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
87422 * simplifies code)
87423 */
87424 static void
87425 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87426 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87427 struct sk_buff *head, struct sk_buff *tail,
87428 u32 start, u32 end)
87429 {
87430 @@ -5838,6 +5838,7 @@ discard:
87431 tcp_paws_reject(&tp->rx_opt, 0))
87432 goto discard_and_undo;
87433
87434 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
87435 if (th->syn) {
87436 /* We see SYN without ACK. It is attempt of
87437 * simultaneous connect with crossed SYNs.
87438 @@ -5888,6 +5889,7 @@ discard:
87439 goto discard;
87440 #endif
87441 }
87442 +#endif
87443 /* "fifth, if neither of the SYN or RST bits is set then
87444 * drop the segment and return."
87445 */
87446 @@ -5932,7 +5934,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
87447 goto discard;
87448
87449 if (th->syn) {
87450 - if (th->fin)
87451 + if (th->fin || th->urg || th->psh)
87452 goto discard;
87453 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
87454 return 1;
87455 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
87456 index d09203c..fd5cc91 100644
87457 --- a/net/ipv4/tcp_ipv4.c
87458 +++ b/net/ipv4/tcp_ipv4.c
87459 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
87460 EXPORT_SYMBOL(sysctl_tcp_low_latency);
87461
87462
87463 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87464 +extern int grsec_enable_blackhole;
87465 +#endif
87466 +
87467 #ifdef CONFIG_TCP_MD5SIG
87468 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
87469 __be32 daddr, __be32 saddr, const struct tcphdr *th);
87470 @@ -1897,6 +1901,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
87471 return 0;
87472
87473 reset:
87474 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87475 + if (!grsec_enable_blackhole)
87476 +#endif
87477 tcp_v4_send_reset(rsk, skb);
87478 discard:
87479 kfree_skb(skb);
87480 @@ -1996,12 +2003,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
87481 TCP_SKB_CB(skb)->sacked = 0;
87482
87483 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
87484 - if (!sk)
87485 + if (!sk) {
87486 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87487 + ret = 1;
87488 +#endif
87489 goto no_tcp_socket;
87490 -
87491 + }
87492 process:
87493 - if (sk->sk_state == TCP_TIME_WAIT)
87494 + if (sk->sk_state == TCP_TIME_WAIT) {
87495 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87496 + ret = 2;
87497 +#endif
87498 goto do_time_wait;
87499 + }
87500
87501 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
87502 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87503 @@ -2052,6 +2066,10 @@ no_tcp_socket:
87504 bad_packet:
87505 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87506 } else {
87507 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87508 + if (!grsec_enable_blackhole || (ret == 1 &&
87509 + (skb->dev->flags & IFF_LOOPBACK)))
87510 +#endif
87511 tcp_v4_send_reset(NULL, skb);
87512 }
87513
87514 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
87515 index 2f672e7..b8895e9 100644
87516 --- a/net/ipv4/tcp_minisocks.c
87517 +++ b/net/ipv4/tcp_minisocks.c
87518 @@ -27,6 +27,10 @@
87519 #include <net/inet_common.h>
87520 #include <net/xfrm.h>
87521
87522 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87523 +extern int grsec_enable_blackhole;
87524 +#endif
87525 +
87526 int sysctl_tcp_syncookies __read_mostly = 1;
87527 EXPORT_SYMBOL(sysctl_tcp_syncookies);
87528
87529 @@ -749,7 +753,10 @@ embryonic_reset:
87530 * avoid becoming vulnerable to outside attack aiming at
87531 * resetting legit local connections.
87532 */
87533 - req->rsk_ops->send_reset(sk, skb);
87534 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87535 + if (!grsec_enable_blackhole)
87536 +#endif
87537 + req->rsk_ops->send_reset(sk, skb);
87538 } else if (fastopen) { /* received a valid RST pkt */
87539 reqsk_fastopen_remove(sk, req, true);
87540 tcp_reset(sk);
87541 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
87542 index d4943f6..e7a74a5 100644
87543 --- a/net/ipv4/tcp_probe.c
87544 +++ b/net/ipv4/tcp_probe.c
87545 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
87546 if (cnt + width >= len)
87547 break;
87548
87549 - if (copy_to_user(buf + cnt, tbuf, width))
87550 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
87551 return -EFAULT;
87552 cnt += width;
87553 }
87554 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
87555 index b78aac3..e18230b 100644
87556 --- a/net/ipv4/tcp_timer.c
87557 +++ b/net/ipv4/tcp_timer.c
87558 @@ -22,6 +22,10 @@
87559 #include <linux/gfp.h>
87560 #include <net/tcp.h>
87561
87562 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87563 +extern int grsec_lastack_retries;
87564 +#endif
87565 +
87566 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
87567 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
87568 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
87569 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
87570 }
87571 }
87572
87573 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87574 + if ((sk->sk_state == TCP_LAST_ACK) &&
87575 + (grsec_lastack_retries > 0) &&
87576 + (grsec_lastack_retries < retry_until))
87577 + retry_until = grsec_lastack_retries;
87578 +#endif
87579 +
87580 if (retransmits_timed_out(sk, retry_until,
87581 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
87582 /* Has it gone just too far? */
87583 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
87584 index 0a073a2..ddf6279 100644
87585 --- a/net/ipv4/udp.c
87586 +++ b/net/ipv4/udp.c
87587 @@ -87,6 +87,7 @@
87588 #include <linux/types.h>
87589 #include <linux/fcntl.h>
87590 #include <linux/module.h>
87591 +#include <linux/security.h>
87592 #include <linux/socket.h>
87593 #include <linux/sockios.h>
87594 #include <linux/igmp.h>
87595 @@ -111,6 +112,10 @@
87596 #include <trace/events/skb.h>
87597 #include "udp_impl.h"
87598
87599 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87600 +extern int grsec_enable_blackhole;
87601 +#endif
87602 +
87603 struct udp_table udp_table __read_mostly;
87604 EXPORT_SYMBOL(udp_table);
87605
87606 @@ -594,6 +599,9 @@ found:
87607 return s;
87608 }
87609
87610 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
87611 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
87612 +
87613 /*
87614 * This routine is called by the ICMP module when it gets some
87615 * sort of error condition. If err < 0 then the socket should
87616 @@ -889,9 +897,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
87617 dport = usin->sin_port;
87618 if (dport == 0)
87619 return -EINVAL;
87620 +
87621 + err = gr_search_udp_sendmsg(sk, usin);
87622 + if (err)
87623 + return err;
87624 } else {
87625 if (sk->sk_state != TCP_ESTABLISHED)
87626 return -EDESTADDRREQ;
87627 +
87628 + err = gr_search_udp_sendmsg(sk, NULL);
87629 + if (err)
87630 + return err;
87631 +
87632 daddr = inet->inet_daddr;
87633 dport = inet->inet_dport;
87634 /* Open fast path for connected socket.
87635 @@ -1133,7 +1150,7 @@ static unsigned int first_packet_length(struct sock *sk)
87636 udp_lib_checksum_complete(skb)) {
87637 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87638 IS_UDPLITE(sk));
87639 - atomic_inc(&sk->sk_drops);
87640 + atomic_inc_unchecked(&sk->sk_drops);
87641 __skb_unlink(skb, rcvq);
87642 __skb_queue_tail(&list_kill, skb);
87643 }
87644 @@ -1219,6 +1236,10 @@ try_again:
87645 if (!skb)
87646 goto out;
87647
87648 + err = gr_search_udp_recvmsg(sk, skb);
87649 + if (err)
87650 + goto out_free;
87651 +
87652 ulen = skb->len - sizeof(struct udphdr);
87653 copied = len;
87654 if (copied > ulen)
87655 @@ -1252,7 +1273,7 @@ try_again:
87656 if (unlikely(err)) {
87657 trace_kfree_skb(skb, udp_recvmsg);
87658 if (!peeked) {
87659 - atomic_inc(&sk->sk_drops);
87660 + atomic_inc_unchecked(&sk->sk_drops);
87661 UDP_INC_STATS_USER(sock_net(sk),
87662 UDP_MIB_INERRORS, is_udplite);
87663 }
87664 @@ -1535,7 +1556,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87665
87666 drop:
87667 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
87668 - atomic_inc(&sk->sk_drops);
87669 + atomic_inc_unchecked(&sk->sk_drops);
87670 kfree_skb(skb);
87671 return -1;
87672 }
87673 @@ -1554,7 +1575,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
87674 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
87675
87676 if (!skb1) {
87677 - atomic_inc(&sk->sk_drops);
87678 + atomic_inc_unchecked(&sk->sk_drops);
87679 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87680 IS_UDPLITE(sk));
87681 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87682 @@ -1723,6 +1744,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87683 goto csum_error;
87684
87685 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87686 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87687 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87688 +#endif
87689 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
87690
87691 /*
87692 @@ -2152,7 +2176,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
87693 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87694 0, sock_i_ino(sp),
87695 atomic_read(&sp->sk_refcnt), sp,
87696 - atomic_read(&sp->sk_drops), len);
87697 + atomic_read_unchecked(&sp->sk_drops), len);
87698 }
87699
87700 int udp4_seq_show(struct seq_file *seq, void *v)
87701 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
87702 index 9a459be..086b866 100644
87703 --- a/net/ipv4/xfrm4_policy.c
87704 +++ b/net/ipv4/xfrm4_policy.c
87705 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
87706
87707 static int __net_init xfrm4_net_init(struct net *net)
87708 {
87709 - struct ctl_table *table;
87710 + ctl_table_no_const *table = NULL;
87711 struct ctl_table_header *hdr;
87712
87713 - table = xfrm4_policy_table;
87714 if (!net_eq(net, &init_net)) {
87715 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
87716 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
87717 if (!table)
87718 goto err_alloc;
87719
87720 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
87721 - }
87722 -
87723 - hdr = register_net_sysctl(net, "net/ipv4", table);
87724 + hdr = register_net_sysctl(net, "net/ipv4", table);
87725 + } else
87726 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
87727 if (!hdr)
87728 goto err_reg;
87729
87730 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
87731 return 0;
87732
87733 err_reg:
87734 - if (!net_eq(net, &init_net))
87735 - kfree(table);
87736 + kfree(table);
87737 err_alloc:
87738 return -ENOMEM;
87739 }
87740 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
87741 index dae802c..bfa4baa 100644
87742 --- a/net/ipv6/addrconf.c
87743 +++ b/net/ipv6/addrconf.c
87744 @@ -2274,7 +2274,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
87745 p.iph.ihl = 5;
87746 p.iph.protocol = IPPROTO_IPV6;
87747 p.iph.ttl = 64;
87748 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
87749 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
87750
87751 if (ops->ndo_do_ioctl) {
87752 mm_segment_t oldfs = get_fs();
87753 @@ -4410,7 +4410,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
87754 int *valp = ctl->data;
87755 int val = *valp;
87756 loff_t pos = *ppos;
87757 - ctl_table lctl;
87758 + ctl_table_no_const lctl;
87759 int ret;
87760
87761 /*
87762 @@ -4492,7 +4492,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
87763 int *valp = ctl->data;
87764 int val = *valp;
87765 loff_t pos = *ppos;
87766 - ctl_table lctl;
87767 + ctl_table_no_const lctl;
87768 int ret;
87769
87770 /*
87771 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
87772 index fff5bdd..15194fb 100644
87773 --- a/net/ipv6/icmp.c
87774 +++ b/net/ipv6/icmp.c
87775 @@ -973,7 +973,7 @@ ctl_table ipv6_icmp_table_template[] = {
87776
87777 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
87778 {
87779 - struct ctl_table *table;
87780 + ctl_table_no_const *table;
87781
87782 table = kmemdup(ipv6_icmp_table_template,
87783 sizeof(ipv6_icmp_table_template),
87784 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
87785 index 95d13c7..791fe2f 100644
87786 --- a/net/ipv6/ip6_gre.c
87787 +++ b/net/ipv6/ip6_gre.c
87788 @@ -73,7 +73,7 @@ struct ip6gre_net {
87789 struct net_device *fb_tunnel_dev;
87790 };
87791
87792 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
87793 +static struct rtnl_link_ops ip6gre_link_ops;
87794 static int ip6gre_tunnel_init(struct net_device *dev);
87795 static void ip6gre_tunnel_setup(struct net_device *dev);
87796 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
87797 @@ -1337,7 +1337,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
87798 }
87799
87800
87801 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
87802 +static struct inet6_protocol ip6gre_protocol = {
87803 .handler = ip6gre_rcv,
87804 .err_handler = ip6gre_err,
87805 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
87806 @@ -1671,7 +1671,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
87807 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
87808 };
87809
87810 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87811 +static struct rtnl_link_ops ip6gre_link_ops = {
87812 .kind = "ip6gre",
87813 .maxtype = IFLA_GRE_MAX,
87814 .policy = ip6gre_policy,
87815 @@ -1684,7 +1684,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87816 .fill_info = ip6gre_fill_info,
87817 };
87818
87819 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
87820 +static struct rtnl_link_ops ip6gre_tap_ops = {
87821 .kind = "ip6gretap",
87822 .maxtype = IFLA_GRE_MAX,
87823 .policy = ip6gre_policy,
87824 diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
87825 index 155eccf..851fdae 100644
87826 --- a/net/ipv6/ip6_output.c
87827 +++ b/net/ipv6/ip6_output.c
87828 @@ -1147,7 +1147,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
87829 if (WARN_ON(np->cork.opt))
87830 return -EINVAL;
87831
87832 - np->cork.opt = kmalloc(opt->tot_len, sk->sk_allocation);
87833 + np->cork.opt = kzalloc(opt->tot_len, sk->sk_allocation);
87834 if (unlikely(np->cork.opt == NULL))
87835 return -ENOBUFS;
87836
87837 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
87838 index fff83cb..82d49dd 100644
87839 --- a/net/ipv6/ip6_tunnel.c
87840 +++ b/net/ipv6/ip6_tunnel.c
87841 @@ -87,7 +87,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
87842
87843 static int ip6_tnl_dev_init(struct net_device *dev);
87844 static void ip6_tnl_dev_setup(struct net_device *dev);
87845 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
87846 +static struct rtnl_link_ops ip6_link_ops;
87847
87848 static int ip6_tnl_net_id __read_mostly;
87849 struct ip6_tnl_net {
87850 @@ -1684,7 +1684,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
87851 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
87852 };
87853
87854 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
87855 +static struct rtnl_link_ops ip6_link_ops = {
87856 .kind = "ip6tnl",
87857 .maxtype = IFLA_IPTUN_MAX,
87858 .policy = ip6_tnl_policy,
87859 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
87860 index d1e2e8e..51c19ae 100644
87861 --- a/net/ipv6/ipv6_sockglue.c
87862 +++ b/net/ipv6/ipv6_sockglue.c
87863 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
87864 if (sk->sk_type != SOCK_STREAM)
87865 return -ENOPROTOOPT;
87866
87867 - msg.msg_control = optval;
87868 + msg.msg_control = (void __force_kernel *)optval;
87869 msg.msg_controllen = len;
87870 msg.msg_flags = flags;
87871
87872 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
87873 index 341b54a..591e8ed 100644
87874 --- a/net/ipv6/netfilter/ip6_tables.c
87875 +++ b/net/ipv6/netfilter/ip6_tables.c
87876 @@ -1076,14 +1076,14 @@ static int compat_table_info(const struct xt_table_info *info,
87877 #endif
87878
87879 static int get_info(struct net *net, void __user *user,
87880 - const int *len, int compat)
87881 + int len, int compat)
87882 {
87883 char name[XT_TABLE_MAXNAMELEN];
87884 struct xt_table *t;
87885 int ret;
87886
87887 - if (*len != sizeof(struct ip6t_getinfo)) {
87888 - duprintf("length %u != %zu\n", *len,
87889 + if (len != sizeof(struct ip6t_getinfo)) {
87890 + duprintf("length %u != %zu\n", len,
87891 sizeof(struct ip6t_getinfo));
87892 return -EINVAL;
87893 }
87894 @@ -1120,7 +1120,7 @@ static int get_info(struct net *net, void __user *user,
87895 info.size = private->size;
87896 strcpy(info.name, name);
87897
87898 - if (copy_to_user(user, &info, *len) != 0)
87899 + if (copy_to_user(user, &info, len) != 0)
87900 ret = -EFAULT;
87901 else
87902 ret = 0;
87903 @@ -1974,7 +1974,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87904
87905 switch (cmd) {
87906 case IP6T_SO_GET_INFO:
87907 - ret = get_info(sock_net(sk), user, len, 1);
87908 + ret = get_info(sock_net(sk), user, *len, 1);
87909 break;
87910 case IP6T_SO_GET_ENTRIES:
87911 ret = compat_get_entries(sock_net(sk), user, len);
87912 @@ -2021,7 +2021,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87913
87914 switch (cmd) {
87915 case IP6T_SO_GET_INFO:
87916 - ret = get_info(sock_net(sk), user, len, 0);
87917 + ret = get_info(sock_net(sk), user, *len, 0);
87918 break;
87919
87920 case IP6T_SO_GET_ENTRIES:
87921 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
87922 index 6700069..1e50f42 100644
87923 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
87924 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
87925 @@ -89,12 +89,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
87926
87927 static int nf_ct_frag6_sysctl_register(struct net *net)
87928 {
87929 - struct ctl_table *table;
87930 + ctl_table_no_const *table = NULL;
87931 struct ctl_table_header *hdr;
87932
87933 - table = nf_ct_frag6_sysctl_table;
87934 if (!net_eq(net, &init_net)) {
87935 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
87936 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
87937 GFP_KERNEL);
87938 if (table == NULL)
87939 goto err_alloc;
87940 @@ -102,9 +101,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
87941 table[0].data = &net->nf_frag.frags.timeout;
87942 table[1].data = &net->nf_frag.frags.low_thresh;
87943 table[2].data = &net->nf_frag.frags.high_thresh;
87944 - }
87945 -
87946 - hdr = register_net_sysctl(net, "net/netfilter", table);
87947 + hdr = register_net_sysctl(net, "net/netfilter", table);
87948 + } else
87949 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
87950 if (hdr == NULL)
87951 goto err_reg;
87952
87953 @@ -112,8 +111,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
87954 return 0;
87955
87956 err_reg:
87957 - if (!net_eq(net, &init_net))
87958 - kfree(table);
87959 + kfree(table);
87960 err_alloc:
87961 return -ENOMEM;
87962 }
87963 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
87964 index 330b5e7..796fbf1 100644
87965 --- a/net/ipv6/raw.c
87966 +++ b/net/ipv6/raw.c
87967 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
87968 {
87969 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
87970 skb_checksum_complete(skb)) {
87971 - atomic_inc(&sk->sk_drops);
87972 + atomic_inc_unchecked(&sk->sk_drops);
87973 kfree_skb(skb);
87974 return NET_RX_DROP;
87975 }
87976 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
87977 struct raw6_sock *rp = raw6_sk(sk);
87978
87979 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
87980 - atomic_inc(&sk->sk_drops);
87981 + atomic_inc_unchecked(&sk->sk_drops);
87982 kfree_skb(skb);
87983 return NET_RX_DROP;
87984 }
87985 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
87986
87987 if (inet->hdrincl) {
87988 if (skb_checksum_complete(skb)) {
87989 - atomic_inc(&sk->sk_drops);
87990 + atomic_inc_unchecked(&sk->sk_drops);
87991 kfree_skb(skb);
87992 return NET_RX_DROP;
87993 }
87994 @@ -603,7 +603,7 @@ out:
87995 return err;
87996 }
87997
87998 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
87999 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
88000 struct flowi6 *fl6, struct dst_entry **dstp,
88001 unsigned int flags)
88002 {
88003 @@ -915,12 +915,15 @@ do_confirm:
88004 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
88005 char __user *optval, int optlen)
88006 {
88007 + struct icmp6_filter filter;
88008 +
88009 switch (optname) {
88010 case ICMPV6_FILTER:
88011 if (optlen > sizeof(struct icmp6_filter))
88012 optlen = sizeof(struct icmp6_filter);
88013 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
88014 + if (copy_from_user(&filter, optval, optlen))
88015 return -EFAULT;
88016 + raw6_sk(sk)->filter = filter;
88017 return 0;
88018 default:
88019 return -ENOPROTOOPT;
88020 @@ -933,6 +936,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88021 char __user *optval, int __user *optlen)
88022 {
88023 int len;
88024 + struct icmp6_filter filter;
88025
88026 switch (optname) {
88027 case ICMPV6_FILTER:
88028 @@ -944,7 +948,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88029 len = sizeof(struct icmp6_filter);
88030 if (put_user(len, optlen))
88031 return -EFAULT;
88032 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
88033 + filter = raw6_sk(sk)->filter;
88034 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
88035 return -EFAULT;
88036 return 0;
88037 default:
88038 @@ -1252,7 +1257,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
88039 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
88040 0,
88041 sock_i_ino(sp),
88042 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
88043 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
88044 }
88045
88046 static int raw6_seq_show(struct seq_file *seq, void *v)
88047 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
88048 index 0ba10e5..c14a4f6 100644
88049 --- a/net/ipv6/reassembly.c
88050 +++ b/net/ipv6/reassembly.c
88051 @@ -602,12 +602,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
88052
88053 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88054 {
88055 - struct ctl_table *table;
88056 + ctl_table_no_const *table = NULL;
88057 struct ctl_table_header *hdr;
88058
88059 - table = ip6_frags_ns_ctl_table;
88060 if (!net_eq(net, &init_net)) {
88061 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88062 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88063 if (table == NULL)
88064 goto err_alloc;
88065
88066 @@ -618,9 +617,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88067 /* Don't export sysctls to unprivileged users */
88068 if (net->user_ns != &init_user_ns)
88069 table[0].procname = NULL;
88070 - }
88071 + hdr = register_net_sysctl(net, "net/ipv6", table);
88072 + } else
88073 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
88074
88075 - hdr = register_net_sysctl(net, "net/ipv6", table);
88076 if (hdr == NULL)
88077 goto err_reg;
88078
88079 @@ -628,8 +628,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88080 return 0;
88081
88082 err_reg:
88083 - if (!net_eq(net, &init_net))
88084 - kfree(table);
88085 + kfree(table);
88086 err_alloc:
88087 return -ENOMEM;
88088 }
88089 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
88090 index e5fe004..9fe3e8e 100644
88091 --- a/net/ipv6/route.c
88092 +++ b/net/ipv6/route.c
88093 @@ -2881,7 +2881,7 @@ ctl_table ipv6_route_table_template[] = {
88094
88095 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
88096 {
88097 - struct ctl_table *table;
88098 + ctl_table_no_const *table;
88099
88100 table = kmemdup(ipv6_route_table_template,
88101 sizeof(ipv6_route_table_template),
88102 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
88103 index 02f96dc..4a5a6e5 100644
88104 --- a/net/ipv6/sit.c
88105 +++ b/net/ipv6/sit.c
88106 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
88107 static void ipip6_dev_free(struct net_device *dev);
88108 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
88109 __be32 *v4dst);
88110 -static struct rtnl_link_ops sit_link_ops __read_mostly;
88111 +static struct rtnl_link_ops sit_link_ops;
88112
88113 static int sit_net_id __read_mostly;
88114 struct sit_net {
88115 @@ -1486,7 +1486,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
88116 #endif
88117 };
88118
88119 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
88120 +static struct rtnl_link_ops sit_link_ops = {
88121 .kind = "sit",
88122 .maxtype = IFLA_IPTUN_MAX,
88123 .policy = ipip6_policy,
88124 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
88125 index e85c48b..b8268d3 100644
88126 --- a/net/ipv6/sysctl_net_ipv6.c
88127 +++ b/net/ipv6/sysctl_net_ipv6.c
88128 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
88129
88130 static int __net_init ipv6_sysctl_net_init(struct net *net)
88131 {
88132 - struct ctl_table *ipv6_table;
88133 + ctl_table_no_const *ipv6_table;
88134 struct ctl_table *ipv6_route_table;
88135 struct ctl_table *ipv6_icmp_table;
88136 int err;
88137 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
88138 index 0fce928..c52a518 100644
88139 --- a/net/ipv6/tcp_ipv6.c
88140 +++ b/net/ipv6/tcp_ipv6.c
88141 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
88142 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
88143 }
88144
88145 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88146 +extern int grsec_enable_blackhole;
88147 +#endif
88148 +
88149 static void tcp_v6_hash(struct sock *sk)
88150 {
88151 if (sk->sk_state != TCP_CLOSE) {
88152 @@ -1446,6 +1450,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
88153 return 0;
88154
88155 reset:
88156 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88157 + if (!grsec_enable_blackhole)
88158 +#endif
88159 tcp_v6_send_reset(sk, skb);
88160 discard:
88161 if (opt_skb)
88162 @@ -1527,12 +1534,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
88163 TCP_SKB_CB(skb)->sacked = 0;
88164
88165 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
88166 - if (!sk)
88167 + if (!sk) {
88168 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88169 + ret = 1;
88170 +#endif
88171 goto no_tcp_socket;
88172 + }
88173
88174 process:
88175 - if (sk->sk_state == TCP_TIME_WAIT)
88176 + if (sk->sk_state == TCP_TIME_WAIT) {
88177 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88178 + ret = 2;
88179 +#endif
88180 goto do_time_wait;
88181 + }
88182
88183 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
88184 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
88185 @@ -1581,6 +1596,10 @@ no_tcp_socket:
88186 bad_packet:
88187 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
88188 } else {
88189 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88190 + if (!grsec_enable_blackhole || (ret == 1 &&
88191 + (skb->dev->flags & IFF_LOOPBACK)))
88192 +#endif
88193 tcp_v6_send_reset(NULL, skb);
88194 }
88195
88196 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
88197 index 27f0f8e..949e7ee 100644
88198 --- a/net/ipv6/udp.c
88199 +++ b/net/ipv6/udp.c
88200 @@ -52,6 +52,10 @@
88201 #include <trace/events/skb.h>
88202 #include "udp_impl.h"
88203
88204 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88205 +extern int grsec_enable_blackhole;
88206 +#endif
88207 +
88208 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
88209 {
88210 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
88211 @@ -419,7 +423,7 @@ try_again:
88212 if (unlikely(err)) {
88213 trace_kfree_skb(skb, udpv6_recvmsg);
88214 if (!peeked) {
88215 - atomic_inc(&sk->sk_drops);
88216 + atomic_inc_unchecked(&sk->sk_drops);
88217 if (is_udp4)
88218 UDP_INC_STATS_USER(sock_net(sk),
88219 UDP_MIB_INERRORS,
88220 @@ -657,7 +661,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
88221 return rc;
88222 drop:
88223 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
88224 - atomic_inc(&sk->sk_drops);
88225 + atomic_inc_unchecked(&sk->sk_drops);
88226 kfree_skb(skb);
88227 return -1;
88228 }
88229 @@ -715,7 +719,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
88230 if (likely(skb1 == NULL))
88231 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
88232 if (!skb1) {
88233 - atomic_inc(&sk->sk_drops);
88234 + atomic_inc_unchecked(&sk->sk_drops);
88235 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
88236 IS_UDPLITE(sk));
88237 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
88238 @@ -852,6 +856,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
88239 goto discard;
88240
88241 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
88242 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88243 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
88244 +#endif
88245 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
88246
88247 kfree_skb(skb);
88248 @@ -1377,7 +1384,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
88249 0,
88250 sock_i_ino(sp),
88251 atomic_read(&sp->sk_refcnt), sp,
88252 - atomic_read(&sp->sk_drops));
88253 + atomic_read_unchecked(&sp->sk_drops));
88254 }
88255
88256 int udp6_seq_show(struct seq_file *seq, void *v)
88257 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
88258 index 23ed03d..465a71d 100644
88259 --- a/net/ipv6/xfrm6_policy.c
88260 +++ b/net/ipv6/xfrm6_policy.c
88261 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
88262
88263 static int __net_init xfrm6_net_init(struct net *net)
88264 {
88265 - struct ctl_table *table;
88266 + ctl_table_no_const *table = NULL;
88267 struct ctl_table_header *hdr;
88268
88269 - table = xfrm6_policy_table;
88270 if (!net_eq(net, &init_net)) {
88271 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
88272 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
88273 if (!table)
88274 goto err_alloc;
88275
88276 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
88277 - }
88278 + hdr = register_net_sysctl(net, "net/ipv6", table);
88279 + } else
88280 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
88281
88282 - hdr = register_net_sysctl(net, "net/ipv6", table);
88283 if (!hdr)
88284 goto err_reg;
88285
88286 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
88287 return 0;
88288
88289 err_reg:
88290 - if (!net_eq(net, &init_net))
88291 - kfree(table);
88292 + kfree(table);
88293 err_alloc:
88294 return -ENOMEM;
88295 }
88296 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
88297 index 362ba47..66196f4 100644
88298 --- a/net/irda/ircomm/ircomm_tty.c
88299 +++ b/net/irda/ircomm/ircomm_tty.c
88300 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88301 add_wait_queue(&port->open_wait, &wait);
88302
88303 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
88304 - __FILE__, __LINE__, tty->driver->name, port->count);
88305 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88306
88307 spin_lock_irqsave(&port->lock, flags);
88308 if (!tty_hung_up_p(filp))
88309 - port->count--;
88310 + atomic_dec(&port->count);
88311 port->blocked_open++;
88312 spin_unlock_irqrestore(&port->lock, flags);
88313
88314 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88315 }
88316
88317 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
88318 - __FILE__, __LINE__, tty->driver->name, port->count);
88319 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88320
88321 schedule();
88322 }
88323 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88324
88325 spin_lock_irqsave(&port->lock, flags);
88326 if (!tty_hung_up_p(filp))
88327 - port->count++;
88328 + atomic_inc(&port->count);
88329 port->blocked_open--;
88330 spin_unlock_irqrestore(&port->lock, flags);
88331
88332 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
88333 - __FILE__, __LINE__, tty->driver->name, port->count);
88334 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88335
88336 if (!retval)
88337 port->flags |= ASYNC_NORMAL_ACTIVE;
88338 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
88339
88340 /* ++ is not atomic, so this should be protected - Jean II */
88341 spin_lock_irqsave(&self->port.lock, flags);
88342 - self->port.count++;
88343 + atomic_inc(&self->port.count);
88344 spin_unlock_irqrestore(&self->port.lock, flags);
88345 tty_port_tty_set(&self->port, tty);
88346
88347 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
88348 - self->line, self->port.count);
88349 + self->line, atomic_read(&self->port.count));
88350
88351 /* Not really used by us, but lets do it anyway */
88352 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
88353 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
88354 tty_kref_put(port->tty);
88355 }
88356 port->tty = NULL;
88357 - port->count = 0;
88358 + atomic_set(&port->count, 0);
88359 spin_unlock_irqrestore(&port->lock, flags);
88360
88361 wake_up_interruptible(&port->open_wait);
88362 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
88363 seq_putc(m, '\n');
88364
88365 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
88366 - seq_printf(m, "Open count: %d\n", self->port.count);
88367 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
88368 seq_printf(m, "Max data size: %d\n", self->max_data_size);
88369 seq_printf(m, "Max header size: %d\n", self->max_header_size);
88370
88371 diff --git a/net/irda/irlap_frame.c b/net/irda/irlap_frame.c
88372 index 8c00416..9ea0c93 100644
88373 --- a/net/irda/irlap_frame.c
88374 +++ b/net/irda/irlap_frame.c
88375 @@ -544,7 +544,7 @@ static void irlap_recv_discovery_xid_cmd(struct irlap_cb *self,
88376 /*
88377 * We now have some discovery info to deliver!
88378 */
88379 - discovery = kmalloc(sizeof(discovery_t), GFP_ATOMIC);
88380 + discovery = kzalloc(sizeof(discovery_t), GFP_ATOMIC);
88381 if (!discovery) {
88382 IRDA_WARNING("%s: unable to malloc!\n", __func__);
88383 return;
88384 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
88385 index 206ce6d..cfb27cd 100644
88386 --- a/net/iucv/af_iucv.c
88387 +++ b/net/iucv/af_iucv.c
88388 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
88389
88390 write_lock_bh(&iucv_sk_list.lock);
88391
88392 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
88393 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88394 while (__iucv_get_sock_by_name(name)) {
88395 sprintf(name, "%08x",
88396 - atomic_inc_return(&iucv_sk_list.autobind_name));
88397 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88398 }
88399
88400 write_unlock_bh(&iucv_sk_list.lock);
88401 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
88402 index 4fe76ff..426a904 100644
88403 --- a/net/iucv/iucv.c
88404 +++ b/net/iucv/iucv.c
88405 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
88406 return NOTIFY_OK;
88407 }
88408
88409 -static struct notifier_block __refdata iucv_cpu_notifier = {
88410 +static struct notifier_block iucv_cpu_notifier = {
88411 .notifier_call = iucv_cpu_notify,
88412 };
88413
88414 diff --git a/net/key/af_key.c b/net/key/af_key.c
88415 index 5b1e5af..2358147 100644
88416 --- a/net/key/af_key.c
88417 +++ b/net/key/af_key.c
88418 @@ -3041,10 +3041,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
88419 static u32 get_acqseq(void)
88420 {
88421 u32 res;
88422 - static atomic_t acqseq;
88423 + static atomic_unchecked_t acqseq;
88424
88425 do {
88426 - res = atomic_inc_return(&acqseq);
88427 + res = atomic_inc_return_unchecked(&acqseq);
88428 } while (!res);
88429 return res;
88430 }
88431 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
88432 index 843d8c4..cb04fa1 100644
88433 --- a/net/mac80211/cfg.c
88434 +++ b/net/mac80211/cfg.c
88435 @@ -799,7 +799,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
88436 ret = ieee80211_vif_use_channel(sdata, chandef,
88437 IEEE80211_CHANCTX_EXCLUSIVE);
88438 }
88439 - } else if (local->open_count == local->monitors) {
88440 + } else if (local_read(&local->open_count) == local->monitors) {
88441 local->_oper_channel = chandef->chan;
88442 local->_oper_channel_type = cfg80211_get_chandef_type(chandef);
88443 ieee80211_hw_config(local, 0);
88444 @@ -2834,7 +2834,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
88445 else
88446 local->probe_req_reg--;
88447
88448 - if (!local->open_count)
88449 + if (!local_read(&local->open_count))
88450 break;
88451
88452 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
88453 @@ -3297,8 +3297,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
88454 if (chanctx_conf) {
88455 *chandef = chanctx_conf->def;
88456 ret = 0;
88457 - } else if (local->open_count > 0 &&
88458 - local->open_count == local->monitors &&
88459 + } else if (local_read(&local->open_count) > 0 &&
88460 + local_read(&local->open_count) == local->monitors &&
88461 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
88462 if (local->use_chanctx)
88463 *chandef = local->monitor_chandef;
88464 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
88465 index 5672533..6738c93 100644
88466 --- a/net/mac80211/ieee80211_i.h
88467 +++ b/net/mac80211/ieee80211_i.h
88468 @@ -28,6 +28,7 @@
88469 #include <net/ieee80211_radiotap.h>
88470 #include <net/cfg80211.h>
88471 #include <net/mac80211.h>
88472 +#include <asm/local.h>
88473 #include "key.h"
88474 #include "sta_info.h"
88475 #include "debug.h"
88476 @@ -897,7 +898,7 @@ struct ieee80211_local {
88477 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
88478 spinlock_t queue_stop_reason_lock;
88479
88480 - int open_count;
88481 + local_t open_count;
88482 int monitors, cooked_mntrs;
88483 /* number of interfaces with corresponding FIF_ flags */
88484 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
88485 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
88486 index d51ca9d..042c35f 100644
88487 --- a/net/mac80211/iface.c
88488 +++ b/net/mac80211/iface.c
88489 @@ -495,7 +495,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88490 break;
88491 }
88492
88493 - if (local->open_count == 0) {
88494 + if (local_read(&local->open_count) == 0) {
88495 res = drv_start(local);
88496 if (res)
88497 goto err_del_bss;
88498 @@ -540,7 +540,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88499 break;
88500 }
88501
88502 - if (local->monitors == 0 && local->open_count == 0) {
88503 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
88504 res = ieee80211_add_virtual_monitor(local);
88505 if (res)
88506 goto err_stop;
88507 @@ -649,7 +649,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88508 atomic_inc(&local->iff_promiscs);
88509
88510 if (coming_up)
88511 - local->open_count++;
88512 + local_inc(&local->open_count);
88513
88514 if (hw_reconf_flags)
88515 ieee80211_hw_config(local, hw_reconf_flags);
88516 @@ -663,7 +663,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88517 err_del_interface:
88518 drv_remove_interface(local, sdata);
88519 err_stop:
88520 - if (!local->open_count)
88521 + if (!local_read(&local->open_count))
88522 drv_stop(local);
88523 err_del_bss:
88524 sdata->bss = NULL;
88525 @@ -806,7 +806,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88526 }
88527
88528 if (going_down)
88529 - local->open_count--;
88530 + local_dec(&local->open_count);
88531
88532 switch (sdata->vif.type) {
88533 case NL80211_IFTYPE_AP_VLAN:
88534 @@ -871,7 +871,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88535
88536 ieee80211_recalc_ps(local, -1);
88537
88538 - if (local->open_count == 0) {
88539 + if (local_read(&local->open_count) == 0) {
88540 if (local->ops->napi_poll)
88541 napi_disable(&local->napi);
88542 ieee80211_clear_tx_pending(local);
88543 @@ -897,7 +897,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88544 }
88545 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
88546
88547 - if (local->monitors == local->open_count && local->monitors > 0)
88548 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
88549 ieee80211_add_virtual_monitor(local);
88550 }
88551
88552 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
88553 index 1a8591b..ef5db54 100644
88554 --- a/net/mac80211/main.c
88555 +++ b/net/mac80211/main.c
88556 @@ -180,7 +180,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
88557 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
88558 IEEE80211_CONF_CHANGE_POWER);
88559
88560 - if (changed && local->open_count) {
88561 + if (changed && local_read(&local->open_count)) {
88562 ret = drv_config(local, changed);
88563 /*
88564 * Goal:
88565 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
88566 index 835584c..be46e67 100644
88567 --- a/net/mac80211/pm.c
88568 +++ b/net/mac80211/pm.c
88569 @@ -33,7 +33,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88570 struct sta_info *sta;
88571 struct ieee80211_chanctx *ctx;
88572
88573 - if (!local->open_count)
88574 + if (!local_read(&local->open_count))
88575 goto suspend;
88576
88577 ieee80211_scan_cancel(local);
88578 @@ -75,7 +75,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88579 cancel_work_sync(&local->dynamic_ps_enable_work);
88580 del_timer_sync(&local->dynamic_ps_timer);
88581
88582 - local->wowlan = wowlan && local->open_count;
88583 + local->wowlan = wowlan && local_read(&local->open_count);
88584 if (local->wowlan) {
88585 int err = drv_suspend(local, wowlan);
88586 if (err < 0) {
88587 @@ -214,7 +214,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88588 mutex_unlock(&local->chanctx_mtx);
88589
88590 /* stop hardware - this must stop RX */
88591 - if (local->open_count)
88592 + if (local_read(&local->open_count))
88593 ieee80211_stop_device(local);
88594
88595 suspend:
88596 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
88597 index dd88381..eef4dd6 100644
88598 --- a/net/mac80211/rate.c
88599 +++ b/net/mac80211/rate.c
88600 @@ -493,7 +493,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
88601
88602 ASSERT_RTNL();
88603
88604 - if (local->open_count)
88605 + if (local_read(&local->open_count))
88606 return -EBUSY;
88607
88608 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
88609 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
88610 index c97a065..ff61928 100644
88611 --- a/net/mac80211/rc80211_pid_debugfs.c
88612 +++ b/net/mac80211/rc80211_pid_debugfs.c
88613 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
88614
88615 spin_unlock_irqrestore(&events->lock, status);
88616
88617 - if (copy_to_user(buf, pb, p))
88618 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
88619 return -EFAULT;
88620
88621 return p;
88622 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
88623 index 0f38f43..e53d4a8 100644
88624 --- a/net/mac80211/util.c
88625 +++ b/net/mac80211/util.c
88626 @@ -1388,7 +1388,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
88627 }
88628 #endif
88629 /* everything else happens only if HW was up & running */
88630 - if (!local->open_count)
88631 + if (!local_read(&local->open_count))
88632 goto wake_up;
88633
88634 /*
88635 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
88636 index 56d22ca..87c778f 100644
88637 --- a/net/netfilter/Kconfig
88638 +++ b/net/netfilter/Kconfig
88639 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
88640
88641 To compile it as a module, choose M here. If unsure, say N.
88642
88643 +config NETFILTER_XT_MATCH_GRADM
88644 + tristate '"gradm" match support'
88645 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
88646 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
88647 + ---help---
88648 + The gradm match allows to match on grsecurity RBAC being enabled.
88649 + It is useful when iptables rules are applied early on bootup to
88650 + prevent connections to the machine (except from a trusted host)
88651 + while the RBAC system is disabled.
88652 +
88653 config NETFILTER_XT_MATCH_HASHLIMIT
88654 tristate '"hashlimit" match support'
88655 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
88656 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
88657 index a1abf87..dbcb7ee 100644
88658 --- a/net/netfilter/Makefile
88659 +++ b/net/netfilter/Makefile
88660 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
88661 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
88662 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
88663 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
88664 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
88665 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
88666 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
88667 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
88668 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
88669 index 1ba9dbc..e39f4ca 100644
88670 --- a/net/netfilter/ipset/ip_set_core.c
88671 +++ b/net/netfilter/ipset/ip_set_core.c
88672 @@ -1801,7 +1801,7 @@ done:
88673 return ret;
88674 }
88675
88676 -static struct nf_sockopt_ops so_set __read_mostly = {
88677 +static struct nf_sockopt_ops so_set = {
88678 .pf = PF_INET,
88679 .get_optmin = SO_IP_SET,
88680 .get_optmax = SO_IP_SET + 1,
88681 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
88682 index 704e514..d644cc2 100644
88683 --- a/net/netfilter/ipvs/ip_vs_conn.c
88684 +++ b/net/netfilter/ipvs/ip_vs_conn.c
88685 @@ -551,7 +551,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
88686 /* Increase the refcnt counter of the dest */
88687 atomic_inc(&dest->refcnt);
88688
88689 - conn_flags = atomic_read(&dest->conn_flags);
88690 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
88691 if (cp->protocol != IPPROTO_UDP)
88692 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
88693 flags = cp->flags;
88694 @@ -895,7 +895,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
88695 atomic_set(&cp->refcnt, 1);
88696
88697 atomic_set(&cp->n_control, 0);
88698 - atomic_set(&cp->in_pkts, 0);
88699 + atomic_set_unchecked(&cp->in_pkts, 0);
88700
88701 atomic_inc(&ipvs->conn_count);
88702 if (flags & IP_VS_CONN_F_NO_CPORT)
88703 @@ -1174,7 +1174,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
88704
88705 /* Don't drop the entry if its number of incoming packets is not
88706 located in [0, 8] */
88707 - i = atomic_read(&cp->in_pkts);
88708 + i = atomic_read_unchecked(&cp->in_pkts);
88709 if (i > 8 || i < 0) return 0;
88710
88711 if (!todrop_rate[i]) return 0;
88712 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
88713 index 61f49d2..6c8c5bc 100644
88714 --- a/net/netfilter/ipvs/ip_vs_core.c
88715 +++ b/net/netfilter/ipvs/ip_vs_core.c
88716 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
88717 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
88718 /* do not touch skb anymore */
88719
88720 - atomic_inc(&cp->in_pkts);
88721 + atomic_inc_unchecked(&cp->in_pkts);
88722 ip_vs_conn_put(cp);
88723 return ret;
88724 }
88725 @@ -1689,7 +1689,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
88726 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
88727 pkts = sysctl_sync_threshold(ipvs);
88728 else
88729 - pkts = atomic_add_return(1, &cp->in_pkts);
88730 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88731
88732 if (ipvs->sync_state & IP_VS_STATE_MASTER)
88733 ip_vs_sync_conn(net, cp, pkts);
88734 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
88735 index 9e2d1cc..7f8f569 100644
88736 --- a/net/netfilter/ipvs/ip_vs_ctl.c
88737 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
88738 @@ -787,7 +787,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
88739 ip_vs_rs_hash(ipvs, dest);
88740 write_unlock_bh(&ipvs->rs_lock);
88741 }
88742 - atomic_set(&dest->conn_flags, conn_flags);
88743 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
88744
88745 /* bind the service */
88746 if (!dest->svc) {
88747 @@ -1688,7 +1688,7 @@ proc_do_sync_ports(ctl_table *table, int write,
88748 * align with netns init in ip_vs_control_net_init()
88749 */
88750
88751 -static struct ctl_table vs_vars[] = {
88752 +static ctl_table_no_const vs_vars[] __read_only = {
88753 {
88754 .procname = "amemthresh",
88755 .maxlen = sizeof(int),
88756 @@ -2087,7 +2087,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88757 " %-7s %-6d %-10d %-10d\n",
88758 &dest->addr.in6,
88759 ntohs(dest->port),
88760 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88761 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88762 atomic_read(&dest->weight),
88763 atomic_read(&dest->activeconns),
88764 atomic_read(&dest->inactconns));
88765 @@ -2098,7 +2098,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88766 "%-7s %-6d %-10d %-10d\n",
88767 ntohl(dest->addr.ip),
88768 ntohs(dest->port),
88769 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88770 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88771 atomic_read(&dest->weight),
88772 atomic_read(&dest->activeconns),
88773 atomic_read(&dest->inactconns));
88774 @@ -2568,7 +2568,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
88775
88776 entry.addr = dest->addr.ip;
88777 entry.port = dest->port;
88778 - entry.conn_flags = atomic_read(&dest->conn_flags);
88779 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
88780 entry.weight = atomic_read(&dest->weight);
88781 entry.u_threshold = dest->u_threshold;
88782 entry.l_threshold = dest->l_threshold;
88783 @@ -3104,7 +3104,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
88784 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
88785 nla_put_u16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
88786 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
88787 - (atomic_read(&dest->conn_flags) &
88788 + (atomic_read_unchecked(&dest->conn_flags) &
88789 IP_VS_CONN_F_FWD_MASK)) ||
88790 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
88791 atomic_read(&dest->weight)) ||
88792 @@ -3694,7 +3694,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
88793 {
88794 int idx;
88795 struct netns_ipvs *ipvs = net_ipvs(net);
88796 - struct ctl_table *tbl;
88797 + ctl_table_no_const *tbl;
88798
88799 atomic_set(&ipvs->dropentry, 0);
88800 spin_lock_init(&ipvs->dropentry_lock);
88801 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
88802 index fdd89b9..bd96aa9 100644
88803 --- a/net/netfilter/ipvs/ip_vs_lblc.c
88804 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
88805 @@ -115,7 +115,7 @@ struct ip_vs_lblc_table {
88806 * IPVS LBLC sysctl table
88807 */
88808 #ifdef CONFIG_SYSCTL
88809 -static ctl_table vs_vars_table[] = {
88810 +static ctl_table_no_const vs_vars_table[] __read_only = {
88811 {
88812 .procname = "lblc_expiration",
88813 .data = NULL,
88814 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
88815 index c03b6a3..8ce3681 100644
88816 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
88817 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
88818 @@ -288,7 +288,7 @@ struct ip_vs_lblcr_table {
88819 * IPVS LBLCR sysctl table
88820 */
88821
88822 -static ctl_table vs_vars_table[] = {
88823 +static ctl_table_no_const vs_vars_table[] __read_only = {
88824 {
88825 .procname = "lblcr_expiration",
88826 .data = NULL,
88827 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
88828 index 44fd10c..2a163b3 100644
88829 --- a/net/netfilter/ipvs/ip_vs_sync.c
88830 +++ b/net/netfilter/ipvs/ip_vs_sync.c
88831 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
88832 cp = cp->control;
88833 if (cp) {
88834 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88835 - pkts = atomic_add_return(1, &cp->in_pkts);
88836 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88837 else
88838 pkts = sysctl_sync_threshold(ipvs);
88839 ip_vs_sync_conn(net, cp->control, pkts);
88840 @@ -758,7 +758,7 @@ control:
88841 if (!cp)
88842 return;
88843 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88844 - pkts = atomic_add_return(1, &cp->in_pkts);
88845 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88846 else
88847 pkts = sysctl_sync_threshold(ipvs);
88848 goto sloop;
88849 @@ -885,7 +885,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
88850
88851 if (opt)
88852 memcpy(&cp->in_seq, opt, sizeof(*opt));
88853 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88854 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88855 cp->state = state;
88856 cp->old_state = cp->state;
88857 /*
88858 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
88859 index ee6b7a9..f9a89f6 100644
88860 --- a/net/netfilter/ipvs/ip_vs_xmit.c
88861 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
88862 @@ -1210,7 +1210,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
88863 else
88864 rc = NF_ACCEPT;
88865 /* do not touch skb anymore */
88866 - atomic_inc(&cp->in_pkts);
88867 + atomic_inc_unchecked(&cp->in_pkts);
88868 goto out;
88869 }
88870
88871 @@ -1332,7 +1332,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
88872 else
88873 rc = NF_ACCEPT;
88874 /* do not touch skb anymore */
88875 - atomic_inc(&cp->in_pkts);
88876 + atomic_inc_unchecked(&cp->in_pkts);
88877 goto out;
88878 }
88879
88880 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
88881 index 2d3030a..7ba1c0a 100644
88882 --- a/net/netfilter/nf_conntrack_acct.c
88883 +++ b/net/netfilter/nf_conntrack_acct.c
88884 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
88885 #ifdef CONFIG_SYSCTL
88886 static int nf_conntrack_acct_init_sysctl(struct net *net)
88887 {
88888 - struct ctl_table *table;
88889 + ctl_table_no_const *table;
88890
88891 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
88892 GFP_KERNEL);
88893 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
88894 index c8e001a..f842a8b 100644
88895 --- a/net/netfilter/nf_conntrack_core.c
88896 +++ b/net/netfilter/nf_conntrack_core.c
88897 @@ -1594,6 +1594,10 @@ void nf_conntrack_init_end(void)
88898 #define DYING_NULLS_VAL ((1<<30)+1)
88899 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
88900
88901 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88902 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
88903 +#endif
88904 +
88905 int nf_conntrack_init_net(struct net *net)
88906 {
88907 int ret;
88908 @@ -1608,7 +1612,11 @@ int nf_conntrack_init_net(struct net *net)
88909 goto err_stat;
88910 }
88911
88912 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88913 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
88914 +#else
88915 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
88916 +#endif
88917 if (!net->ct.slabname) {
88918 ret = -ENOMEM;
88919 goto err_slabname;
88920 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
88921 index b5d2eb8..61ef19a 100644
88922 --- a/net/netfilter/nf_conntrack_ecache.c
88923 +++ b/net/netfilter/nf_conntrack_ecache.c
88924 @@ -186,7 +186,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
88925 #ifdef CONFIG_SYSCTL
88926 static int nf_conntrack_event_init_sysctl(struct net *net)
88927 {
88928 - struct ctl_table *table;
88929 + ctl_table_no_const *table;
88930
88931 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
88932 GFP_KERNEL);
88933 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
88934 index 94b4b98..97cf0ad 100644
88935 --- a/net/netfilter/nf_conntrack_helper.c
88936 +++ b/net/netfilter/nf_conntrack_helper.c
88937 @@ -56,7 +56,7 @@ static struct ctl_table helper_sysctl_table[] = {
88938
88939 static int nf_conntrack_helper_init_sysctl(struct net *net)
88940 {
88941 - struct ctl_table *table;
88942 + ctl_table_no_const *table;
88943
88944 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
88945 GFP_KERNEL);
88946 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
88947 index 58ab405..50eb8d3 100644
88948 --- a/net/netfilter/nf_conntrack_proto.c
88949 +++ b/net/netfilter/nf_conntrack_proto.c
88950 @@ -51,7 +51,7 @@ nf_ct_register_sysctl(struct net *net,
88951
88952 static void
88953 nf_ct_unregister_sysctl(struct ctl_table_header **header,
88954 - struct ctl_table **table,
88955 + ctl_table_no_const **table,
88956 unsigned int users)
88957 {
88958 if (users > 0)
88959 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
88960 index fedee39..d62a93d 100644
88961 --- a/net/netfilter/nf_conntrack_standalone.c
88962 +++ b/net/netfilter/nf_conntrack_standalone.c
88963 @@ -470,7 +470,7 @@ static ctl_table nf_ct_netfilter_table[] = {
88964
88965 static int nf_conntrack_standalone_init_sysctl(struct net *net)
88966 {
88967 - struct ctl_table *table;
88968 + ctl_table_no_const *table;
88969
88970 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
88971 GFP_KERNEL);
88972 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
88973 index 902fb0a..87f7fdb 100644
88974 --- a/net/netfilter/nf_conntrack_timestamp.c
88975 +++ b/net/netfilter/nf_conntrack_timestamp.c
88976 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
88977 #ifdef CONFIG_SYSCTL
88978 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
88979 {
88980 - struct ctl_table *table;
88981 + ctl_table_no_const *table;
88982
88983 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
88984 GFP_KERNEL);
88985 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
88986 index 9e31269..bc4c1b7 100644
88987 --- a/net/netfilter/nf_log.c
88988 +++ b/net/netfilter/nf_log.c
88989 @@ -215,7 +215,7 @@ static const struct file_operations nflog_file_ops = {
88990
88991 #ifdef CONFIG_SYSCTL
88992 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
88993 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
88994 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
88995 static struct ctl_table_header *nf_log_dir_header;
88996
88997 static int nf_log_proc_dostring(ctl_table *table, int write,
88998 @@ -246,14 +246,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
88999 rcu_assign_pointer(nf_loggers[tindex], logger);
89000 mutex_unlock(&nf_log_mutex);
89001 } else {
89002 + ctl_table_no_const nf_log_table = *table;
89003 +
89004 mutex_lock(&nf_log_mutex);
89005 logger = rcu_dereference_protected(nf_loggers[tindex],
89006 lockdep_is_held(&nf_log_mutex));
89007 if (!logger)
89008 - table->data = "NONE";
89009 + nf_log_table.data = "NONE";
89010 else
89011 - table->data = logger->name;
89012 - r = proc_dostring(table, write, buffer, lenp, ppos);
89013 + nf_log_table.data = logger->name;
89014 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
89015 mutex_unlock(&nf_log_mutex);
89016 }
89017
89018 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
89019 index f042ae5..30ea486 100644
89020 --- a/net/netfilter/nf_sockopt.c
89021 +++ b/net/netfilter/nf_sockopt.c
89022 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
89023 }
89024 }
89025
89026 - list_add(&reg->list, &nf_sockopts);
89027 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
89028 out:
89029 mutex_unlock(&nf_sockopt_mutex);
89030 return ret;
89031 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
89032 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
89033 {
89034 mutex_lock(&nf_sockopt_mutex);
89035 - list_del(&reg->list);
89036 + pax_list_del((struct list_head *)&reg->list);
89037 mutex_unlock(&nf_sockopt_mutex);
89038 }
89039 EXPORT_SYMBOL(nf_unregister_sockopt);
89040 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
89041 index f248db5..3778ad9 100644
89042 --- a/net/netfilter/nfnetlink_log.c
89043 +++ b/net/netfilter/nfnetlink_log.c
89044 @@ -72,7 +72,7 @@ struct nfulnl_instance {
89045 };
89046
89047 static DEFINE_SPINLOCK(instances_lock);
89048 -static atomic_t global_seq;
89049 +static atomic_unchecked_t global_seq;
89050
89051 #define INSTANCE_BUCKETS 16
89052 static struct hlist_head instance_table[INSTANCE_BUCKETS];
89053 @@ -536,7 +536,7 @@ __build_packet_message(struct nfulnl_instance *inst,
89054 /* global sequence number */
89055 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
89056 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
89057 - htonl(atomic_inc_return(&global_seq))))
89058 + htonl(atomic_inc_return_unchecked(&global_seq))))
89059 goto nla_put_failure;
89060
89061 if (data_len) {
89062 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
89063 new file mode 100644
89064 index 0000000..c566332
89065 --- /dev/null
89066 +++ b/net/netfilter/xt_gradm.c
89067 @@ -0,0 +1,51 @@
89068 +/*
89069 + * gradm match for netfilter
89070 + * Copyright © Zbigniew Krzystolik, 2010
89071 + *
89072 + * This program is free software; you can redistribute it and/or modify
89073 + * it under the terms of the GNU General Public License; either version
89074 + * 2 or 3 as published by the Free Software Foundation.
89075 + */
89076 +#include <linux/module.h>
89077 +#include <linux/moduleparam.h>
89078 +#include <linux/skbuff.h>
89079 +#include <linux/netfilter/x_tables.h>
89080 +#include <linux/grsecurity.h>
89081 +#include <linux/netfilter/xt_gradm.h>
89082 +
89083 +static bool
89084 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
89085 +{
89086 + const struct xt_gradm_mtinfo *info = par->matchinfo;
89087 + bool retval = false;
89088 + if (gr_acl_is_enabled())
89089 + retval = true;
89090 + return retval ^ info->invflags;
89091 +}
89092 +
89093 +static struct xt_match gradm_mt_reg __read_mostly = {
89094 + .name = "gradm",
89095 + .revision = 0,
89096 + .family = NFPROTO_UNSPEC,
89097 + .match = gradm_mt,
89098 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
89099 + .me = THIS_MODULE,
89100 +};
89101 +
89102 +static int __init gradm_mt_init(void)
89103 +{
89104 + return xt_register_match(&gradm_mt_reg);
89105 +}
89106 +
89107 +static void __exit gradm_mt_exit(void)
89108 +{
89109 + xt_unregister_match(&gradm_mt_reg);
89110 +}
89111 +
89112 +module_init(gradm_mt_init);
89113 +module_exit(gradm_mt_exit);
89114 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
89115 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
89116 +MODULE_LICENSE("GPL");
89117 +MODULE_ALIAS("ipt_gradm");
89118 +MODULE_ALIAS("ip6t_gradm");
89119 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
89120 index 4fe4fb4..87a89e5 100644
89121 --- a/net/netfilter/xt_statistic.c
89122 +++ b/net/netfilter/xt_statistic.c
89123 @@ -19,7 +19,7 @@
89124 #include <linux/module.h>
89125
89126 struct xt_statistic_priv {
89127 - atomic_t count;
89128 + atomic_unchecked_t count;
89129 } ____cacheline_aligned_in_smp;
89130
89131 MODULE_LICENSE("GPL");
89132 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
89133 break;
89134 case XT_STATISTIC_MODE_NTH:
89135 do {
89136 - oval = atomic_read(&info->master->count);
89137 + oval = atomic_read_unchecked(&info->master->count);
89138 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
89139 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
89140 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
89141 if (nval == 0)
89142 ret = !ret;
89143 break;
89144 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
89145 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
89146 if (info->master == NULL)
89147 return -ENOMEM;
89148 - atomic_set(&info->master->count, info->u.nth.count);
89149 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
89150
89151 return 0;
89152 }
89153 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
89154 index 1e3fd5b..ad397ea 100644
89155 --- a/net/netlink/af_netlink.c
89156 +++ b/net/netlink/af_netlink.c
89157 @@ -781,7 +781,7 @@ static void netlink_overrun(struct sock *sk)
89158 sk->sk_error_report(sk);
89159 }
89160 }
89161 - atomic_inc(&sk->sk_drops);
89162 + atomic_inc_unchecked(&sk->sk_drops);
89163 }
89164
89165 static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
89166 @@ -2063,7 +2063,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
89167 sk_wmem_alloc_get(s),
89168 nlk->cb,
89169 atomic_read(&s->sk_refcnt),
89170 - atomic_read(&s->sk_drops),
89171 + atomic_read_unchecked(&s->sk_drops),
89172 sock_i_ino(s)
89173 );
89174
89175 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
89176 index 5a55be3..7630745 100644
89177 --- a/net/netlink/genetlink.c
89178 +++ b/net/netlink/genetlink.c
89179 @@ -296,18 +296,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
89180 goto errout;
89181 }
89182
89183 + pax_open_kernel();
89184 if (ops->dumpit)
89185 - ops->flags |= GENL_CMD_CAP_DUMP;
89186 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
89187 if (ops->doit)
89188 - ops->flags |= GENL_CMD_CAP_DO;
89189 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
89190 if (ops->policy)
89191 - ops->flags |= GENL_CMD_CAP_HASPOL;
89192 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
89193 + pax_close_kernel();
89194
89195 genl_lock();
89196 - list_add_tail(&ops->ops_list, &family->ops_list);
89197 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
89198 genl_unlock();
89199
89200 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
89201 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
89202 err = 0;
89203 errout:
89204 return err;
89205 @@ -337,9 +339,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
89206 genl_lock();
89207 list_for_each_entry(rc, &family->ops_list, ops_list) {
89208 if (rc == ops) {
89209 - list_del(&ops->ops_list);
89210 + pax_list_del((struct list_head *)&ops->ops_list);
89211 genl_unlock();
89212 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
89213 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
89214 return 0;
89215 }
89216 }
89217 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
89218 index 103bd70..f21aad3 100644
89219 --- a/net/netrom/af_netrom.c
89220 +++ b/net/netrom/af_netrom.c
89221 @@ -834,6 +834,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89222 struct sock *sk = sock->sk;
89223 struct nr_sock *nr = nr_sk(sk);
89224
89225 + memset(sax, 0, sizeof(*sax));
89226 lock_sock(sk);
89227 if (peer != 0) {
89228 if (sk->sk_state != TCP_ESTABLISHED) {
89229 @@ -848,7 +849,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89230 *uaddr_len = sizeof(struct full_sockaddr_ax25);
89231 } else {
89232 sax->fsa_ax25.sax25_family = AF_NETROM;
89233 - sax->fsa_ax25.sax25_ndigis = 0;
89234 sax->fsa_ax25.sax25_call = nr->source_addr;
89235 *uaddr_len = sizeof(struct sockaddr_ax25);
89236 }
89237 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
89238 index f83e172..b57140d 100644
89239 --- a/net/packet/af_packet.c
89240 +++ b/net/packet/af_packet.c
89241 @@ -1571,7 +1571,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89242
89243 spin_lock(&sk->sk_receive_queue.lock);
89244 po->stats.tp_packets++;
89245 - skb->dropcount = atomic_read(&sk->sk_drops);
89246 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
89247 __skb_queue_tail(&sk->sk_receive_queue, skb);
89248 spin_unlock(&sk->sk_receive_queue.lock);
89249 sk->sk_data_ready(sk, skb->len);
89250 @@ -1580,7 +1580,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89251 drop_n_acct:
89252 spin_lock(&sk->sk_receive_queue.lock);
89253 po->stats.tp_drops++;
89254 - atomic_inc(&sk->sk_drops);
89255 + atomic_inc_unchecked(&sk->sk_drops);
89256 spin_unlock(&sk->sk_receive_queue.lock);
89257
89258 drop_n_restore:
89259 @@ -2558,6 +2558,7 @@ out:
89260
89261 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89262 {
89263 + struct sock_extended_err ee;
89264 struct sock_exterr_skb *serr;
89265 struct sk_buff *skb, *skb2;
89266 int copied, err;
89267 @@ -2579,8 +2580,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89268 sock_recv_timestamp(msg, sk, skb);
89269
89270 serr = SKB_EXT_ERR(skb);
89271 + ee = serr->ee;
89272 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
89273 - sizeof(serr->ee), &serr->ee);
89274 + sizeof ee, &ee);
89275
89276 msg->msg_flags |= MSG_ERRQUEUE;
89277 err = copied;
89278 @@ -3205,7 +3207,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89279 case PACKET_HDRLEN:
89280 if (len > sizeof(int))
89281 len = sizeof(int);
89282 - if (copy_from_user(&val, optval, len))
89283 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
89284 return -EFAULT;
89285 switch (val) {
89286 case TPACKET_V1:
89287 @@ -3247,7 +3249,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89288 len = lv;
89289 if (put_user(len, optlen))
89290 return -EFAULT;
89291 - if (copy_to_user(optval, data, len))
89292 + if (len > sizeof(st) || copy_to_user(optval, data, len))
89293 return -EFAULT;
89294 return 0;
89295 }
89296 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
89297 index 5a940db..d6a502d 100644
89298 --- a/net/phonet/af_phonet.c
89299 +++ b/net/phonet/af_phonet.c
89300 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
89301 {
89302 int err = 0;
89303
89304 - if (protocol >= PHONET_NPROTO)
89305 + if (protocol < 0 || protocol >= PHONET_NPROTO)
89306 return -EINVAL;
89307
89308 err = proto_register(pp->prot, 1);
89309 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
89310 index e774117..900b8b7 100644
89311 --- a/net/phonet/pep.c
89312 +++ b/net/phonet/pep.c
89313 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89314
89315 case PNS_PEP_CTRL_REQ:
89316 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
89317 - atomic_inc(&sk->sk_drops);
89318 + atomic_inc_unchecked(&sk->sk_drops);
89319 break;
89320 }
89321 __skb_pull(skb, 4);
89322 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89323 }
89324
89325 if (pn->rx_credits == 0) {
89326 - atomic_inc(&sk->sk_drops);
89327 + atomic_inc_unchecked(&sk->sk_drops);
89328 err = -ENOBUFS;
89329 break;
89330 }
89331 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
89332 }
89333
89334 if (pn->rx_credits == 0) {
89335 - atomic_inc(&sk->sk_drops);
89336 + atomic_inc_unchecked(&sk->sk_drops);
89337 err = NET_RX_DROP;
89338 break;
89339 }
89340 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
89341 index 1afd138..0b42453 100644
89342 --- a/net/phonet/socket.c
89343 +++ b/net/phonet/socket.c
89344 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
89345 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
89346 sock_i_ino(sk),
89347 atomic_read(&sk->sk_refcnt), sk,
89348 - atomic_read(&sk->sk_drops), &len);
89349 + atomic_read_unchecked(&sk->sk_drops), &len);
89350 }
89351 seq_printf(seq, "%*s\n", 127 - len, "");
89352 return 0;
89353 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
89354 index d6bbbbd..61561e4 100644
89355 --- a/net/phonet/sysctl.c
89356 +++ b/net/phonet/sysctl.c
89357 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
89358 {
89359 int ret;
89360 int range[2] = {local_port_range[0], local_port_range[1]};
89361 - ctl_table tmp = {
89362 + ctl_table_no_const tmp = {
89363 .data = &range,
89364 .maxlen = sizeof(range),
89365 .mode = table->mode,
89366 diff --git a/net/rds/cong.c b/net/rds/cong.c
89367 index e5b65ac..f3b6fb7 100644
89368 --- a/net/rds/cong.c
89369 +++ b/net/rds/cong.c
89370 @@ -78,7 +78,7 @@
89371 * finds that the saved generation number is smaller than the global generation
89372 * number, it wakes up the process.
89373 */
89374 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
89375 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
89376
89377 /*
89378 * Congestion monitoring
89379 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
89380 rdsdebug("waking map %p for %pI4\n",
89381 map, &map->m_addr);
89382 rds_stats_inc(s_cong_update_received);
89383 - atomic_inc(&rds_cong_generation);
89384 + atomic_inc_unchecked(&rds_cong_generation);
89385 if (waitqueue_active(&map->m_waitq))
89386 wake_up(&map->m_waitq);
89387 if (waitqueue_active(&rds_poll_waitq))
89388 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
89389
89390 int rds_cong_updated_since(unsigned long *recent)
89391 {
89392 - unsigned long gen = atomic_read(&rds_cong_generation);
89393 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
89394
89395 if (likely(*recent == gen))
89396 return 0;
89397 diff --git a/net/rds/ib.h b/net/rds/ib.h
89398 index 7280ab8..e04f4ea 100644
89399 --- a/net/rds/ib.h
89400 +++ b/net/rds/ib.h
89401 @@ -128,7 +128,7 @@ struct rds_ib_connection {
89402 /* sending acks */
89403 unsigned long i_ack_flags;
89404 #ifdef KERNEL_HAS_ATOMIC64
89405 - atomic64_t i_ack_next; /* next ACK to send */
89406 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89407 #else
89408 spinlock_t i_ack_lock; /* protect i_ack_next */
89409 u64 i_ack_next; /* next ACK to send */
89410 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
89411 index 31b74f5..dc1fbfa 100644
89412 --- a/net/rds/ib_cm.c
89413 +++ b/net/rds/ib_cm.c
89414 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
89415 /* Clear the ACK state */
89416 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89417 #ifdef KERNEL_HAS_ATOMIC64
89418 - atomic64_set(&ic->i_ack_next, 0);
89419 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89420 #else
89421 ic->i_ack_next = 0;
89422 #endif
89423 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
89424 index 8eb9501..0c386ff 100644
89425 --- a/net/rds/ib_recv.c
89426 +++ b/net/rds/ib_recv.c
89427 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89428 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
89429 int ack_required)
89430 {
89431 - atomic64_set(&ic->i_ack_next, seq);
89432 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89433 if (ack_required) {
89434 smp_mb__before_clear_bit();
89435 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89436 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89437 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89438 smp_mb__after_clear_bit();
89439
89440 - return atomic64_read(&ic->i_ack_next);
89441 + return atomic64_read_unchecked(&ic->i_ack_next);
89442 }
89443 #endif
89444
89445 diff --git a/net/rds/iw.h b/net/rds/iw.h
89446 index 04ce3b1..48119a6 100644
89447 --- a/net/rds/iw.h
89448 +++ b/net/rds/iw.h
89449 @@ -134,7 +134,7 @@ struct rds_iw_connection {
89450 /* sending acks */
89451 unsigned long i_ack_flags;
89452 #ifdef KERNEL_HAS_ATOMIC64
89453 - atomic64_t i_ack_next; /* next ACK to send */
89454 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89455 #else
89456 spinlock_t i_ack_lock; /* protect i_ack_next */
89457 u64 i_ack_next; /* next ACK to send */
89458 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
89459 index a91e1db..cf3053f 100644
89460 --- a/net/rds/iw_cm.c
89461 +++ b/net/rds/iw_cm.c
89462 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
89463 /* Clear the ACK state */
89464 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89465 #ifdef KERNEL_HAS_ATOMIC64
89466 - atomic64_set(&ic->i_ack_next, 0);
89467 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89468 #else
89469 ic->i_ack_next = 0;
89470 #endif
89471 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
89472 index 4503335..db566b4 100644
89473 --- a/net/rds/iw_recv.c
89474 +++ b/net/rds/iw_recv.c
89475 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89476 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
89477 int ack_required)
89478 {
89479 - atomic64_set(&ic->i_ack_next, seq);
89480 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89481 if (ack_required) {
89482 smp_mb__before_clear_bit();
89483 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89484 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89485 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89486 smp_mb__after_clear_bit();
89487
89488 - return atomic64_read(&ic->i_ack_next);
89489 + return atomic64_read_unchecked(&ic->i_ack_next);
89490 }
89491 #endif
89492
89493 diff --git a/net/rds/rds.h b/net/rds/rds.h
89494 index ec1d731..90a3a8d 100644
89495 --- a/net/rds/rds.h
89496 +++ b/net/rds/rds.h
89497 @@ -449,7 +449,7 @@ struct rds_transport {
89498 void (*sync_mr)(void *trans_private, int direction);
89499 void (*free_mr)(void *trans_private, int invalidate);
89500 void (*flush_mrs)(void);
89501 -};
89502 +} __do_const;
89503
89504 struct rds_sock {
89505 struct sock rs_sk;
89506 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
89507 index edac9ef..16bcb98 100644
89508 --- a/net/rds/tcp.c
89509 +++ b/net/rds/tcp.c
89510 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
89511 int val = 1;
89512
89513 set_fs(KERNEL_DS);
89514 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
89515 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
89516 sizeof(val));
89517 set_fs(oldfs);
89518 }
89519 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
89520 index 81cf5a4..b5826ff 100644
89521 --- a/net/rds/tcp_send.c
89522 +++ b/net/rds/tcp_send.c
89523 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
89524
89525 oldfs = get_fs();
89526 set_fs(KERNEL_DS);
89527 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
89528 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
89529 sizeof(val));
89530 set_fs(oldfs);
89531 }
89532 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
89533 index e61aa60..f07cc89 100644
89534 --- a/net/rxrpc/af_rxrpc.c
89535 +++ b/net/rxrpc/af_rxrpc.c
89536 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
89537 __be32 rxrpc_epoch;
89538
89539 /* current debugging ID */
89540 -atomic_t rxrpc_debug_id;
89541 +atomic_unchecked_t rxrpc_debug_id;
89542
89543 /* count of skbs currently in use */
89544 atomic_t rxrpc_n_skbs;
89545 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
89546 index e4d9cbc..b229649 100644
89547 --- a/net/rxrpc/ar-ack.c
89548 +++ b/net/rxrpc/ar-ack.c
89549 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89550
89551 _enter("{%d,%d,%d,%d},",
89552 call->acks_hard, call->acks_unacked,
89553 - atomic_read(&call->sequence),
89554 + atomic_read_unchecked(&call->sequence),
89555 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
89556
89557 stop = 0;
89558 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89559
89560 /* each Tx packet has a new serial number */
89561 sp->hdr.serial =
89562 - htonl(atomic_inc_return(&call->conn->serial));
89563 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
89564
89565 hdr = (struct rxrpc_header *) txb->head;
89566 hdr->serial = sp->hdr.serial;
89567 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
89568 */
89569 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
89570 {
89571 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
89572 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
89573 }
89574
89575 /*
89576 @@ -629,7 +629,7 @@ process_further:
89577
89578 latest = ntohl(sp->hdr.serial);
89579 hard = ntohl(ack.firstPacket);
89580 - tx = atomic_read(&call->sequence);
89581 + tx = atomic_read_unchecked(&call->sequence);
89582
89583 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89584 latest,
89585 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
89586 goto maybe_reschedule;
89587
89588 send_ACK_with_skew:
89589 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
89590 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
89591 ntohl(ack.serial));
89592 send_ACK:
89593 mtu = call->conn->trans->peer->if_mtu;
89594 @@ -1173,7 +1173,7 @@ send_ACK:
89595 ackinfo.rxMTU = htonl(5692);
89596 ackinfo.jumbo_max = htonl(4);
89597
89598 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89599 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89600 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89601 ntohl(hdr.serial),
89602 ntohs(ack.maxSkew),
89603 @@ -1191,7 +1191,7 @@ send_ACK:
89604 send_message:
89605 _debug("send message");
89606
89607 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89608 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89609 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
89610 send_message_2:
89611
89612 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
89613 index a3bbb36..3341fb9 100644
89614 --- a/net/rxrpc/ar-call.c
89615 +++ b/net/rxrpc/ar-call.c
89616 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
89617 spin_lock_init(&call->lock);
89618 rwlock_init(&call->state_lock);
89619 atomic_set(&call->usage, 1);
89620 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
89621 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89622 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
89623
89624 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
89625 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
89626 index 4106ca9..a338d7a 100644
89627 --- a/net/rxrpc/ar-connection.c
89628 +++ b/net/rxrpc/ar-connection.c
89629 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
89630 rwlock_init(&conn->lock);
89631 spin_lock_init(&conn->state_lock);
89632 atomic_set(&conn->usage, 1);
89633 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
89634 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89635 conn->avail_calls = RXRPC_MAXCALLS;
89636 conn->size_align = 4;
89637 conn->header_size = sizeof(struct rxrpc_header);
89638 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
89639 index e7ed43a..6afa140 100644
89640 --- a/net/rxrpc/ar-connevent.c
89641 +++ b/net/rxrpc/ar-connevent.c
89642 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
89643
89644 len = iov[0].iov_len + iov[1].iov_len;
89645
89646 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89647 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89648 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
89649
89650 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89651 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
89652 index 529572f..c758ca7 100644
89653 --- a/net/rxrpc/ar-input.c
89654 +++ b/net/rxrpc/ar-input.c
89655 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
89656 /* track the latest serial number on this connection for ACK packet
89657 * information */
89658 serial = ntohl(sp->hdr.serial);
89659 - hi_serial = atomic_read(&call->conn->hi_serial);
89660 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
89661 while (serial > hi_serial)
89662 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
89663 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
89664 serial);
89665
89666 /* request ACK generation for any ACK or DATA packet that requests
89667 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
89668 index a693aca..81e7293 100644
89669 --- a/net/rxrpc/ar-internal.h
89670 +++ b/net/rxrpc/ar-internal.h
89671 @@ -272,8 +272,8 @@ struct rxrpc_connection {
89672 int error; /* error code for local abort */
89673 int debug_id; /* debug ID for printks */
89674 unsigned int call_counter; /* call ID counter */
89675 - atomic_t serial; /* packet serial number counter */
89676 - atomic_t hi_serial; /* highest serial number received */
89677 + atomic_unchecked_t serial; /* packet serial number counter */
89678 + atomic_unchecked_t hi_serial; /* highest serial number received */
89679 u8 avail_calls; /* number of calls available */
89680 u8 size_align; /* data size alignment (for security) */
89681 u8 header_size; /* rxrpc + security header size */
89682 @@ -346,7 +346,7 @@ struct rxrpc_call {
89683 spinlock_t lock;
89684 rwlock_t state_lock; /* lock for state transition */
89685 atomic_t usage;
89686 - atomic_t sequence; /* Tx data packet sequence counter */
89687 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
89688 u32 abort_code; /* local/remote abort code */
89689 enum { /* current state of call */
89690 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
89691 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
89692 */
89693 extern atomic_t rxrpc_n_skbs;
89694 extern __be32 rxrpc_epoch;
89695 -extern atomic_t rxrpc_debug_id;
89696 +extern atomic_unchecked_t rxrpc_debug_id;
89697 extern struct workqueue_struct *rxrpc_workqueue;
89698
89699 /*
89700 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
89701 index 87f7135..74d3703 100644
89702 --- a/net/rxrpc/ar-local.c
89703 +++ b/net/rxrpc/ar-local.c
89704 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
89705 spin_lock_init(&local->lock);
89706 rwlock_init(&local->services_lock);
89707 atomic_set(&local->usage, 1);
89708 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
89709 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89710 memcpy(&local->srx, srx, sizeof(*srx));
89711 }
89712
89713 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
89714 index e1ac183..b43e10e 100644
89715 --- a/net/rxrpc/ar-output.c
89716 +++ b/net/rxrpc/ar-output.c
89717 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
89718 sp->hdr.cid = call->cid;
89719 sp->hdr.callNumber = call->call_id;
89720 sp->hdr.seq =
89721 - htonl(atomic_inc_return(&call->sequence));
89722 + htonl(atomic_inc_return_unchecked(&call->sequence));
89723 sp->hdr.serial =
89724 - htonl(atomic_inc_return(&conn->serial));
89725 + htonl(atomic_inc_return_unchecked(&conn->serial));
89726 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
89727 sp->hdr.userStatus = 0;
89728 sp->hdr.securityIndex = conn->security_ix;
89729 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
89730 index bebaa43..2644591 100644
89731 --- a/net/rxrpc/ar-peer.c
89732 +++ b/net/rxrpc/ar-peer.c
89733 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
89734 INIT_LIST_HEAD(&peer->error_targets);
89735 spin_lock_init(&peer->lock);
89736 atomic_set(&peer->usage, 1);
89737 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
89738 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89739 memcpy(&peer->srx, srx, sizeof(*srx));
89740
89741 rxrpc_assess_MTU_size(peer);
89742 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
89743 index 38047f7..9f48511 100644
89744 --- a/net/rxrpc/ar-proc.c
89745 +++ b/net/rxrpc/ar-proc.c
89746 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
89747 atomic_read(&conn->usage),
89748 rxrpc_conn_states[conn->state],
89749 key_serial(conn->key),
89750 - atomic_read(&conn->serial),
89751 - atomic_read(&conn->hi_serial));
89752 + atomic_read_unchecked(&conn->serial),
89753 + atomic_read_unchecked(&conn->hi_serial));
89754
89755 return 0;
89756 }
89757 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
89758 index 92df566..87ec1bf 100644
89759 --- a/net/rxrpc/ar-transport.c
89760 +++ b/net/rxrpc/ar-transport.c
89761 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
89762 spin_lock_init(&trans->client_lock);
89763 rwlock_init(&trans->conn_lock);
89764 atomic_set(&trans->usage, 1);
89765 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
89766 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89767
89768 if (peer->srx.transport.family == AF_INET) {
89769 switch (peer->srx.transport_type) {
89770 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
89771 index f226709..0e735a8 100644
89772 --- a/net/rxrpc/rxkad.c
89773 +++ b/net/rxrpc/rxkad.c
89774 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
89775
89776 len = iov[0].iov_len + iov[1].iov_len;
89777
89778 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89779 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89780 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
89781
89782 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89783 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
89784
89785 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
89786
89787 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
89788 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89789 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
89790
89791 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
89792 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
89793 index 391a245..296b3d7 100644
89794 --- a/net/sctp/ipv6.c
89795 +++ b/net/sctp/ipv6.c
89796 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
89797 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
89798 };
89799
89800 -static struct sctp_af sctp_af_inet6 = {
89801 +static struct sctp_af sctp_af_inet6 __read_only = {
89802 .sa_family = AF_INET6,
89803 .sctp_xmit = sctp_v6_xmit,
89804 .setsockopt = ipv6_setsockopt,
89805 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
89806 #endif
89807 };
89808
89809 -static struct sctp_pf sctp_pf_inet6 = {
89810 +static struct sctp_pf sctp_pf_inet6 __read_only = {
89811 .event_msgname = sctp_inet6_event_msgname,
89812 .skb_msgname = sctp_inet6_skb_msgname,
89813 .af_supported = sctp_inet6_af_supported,
89814 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
89815
89816 void sctp_v6_pf_exit(void)
89817 {
89818 - list_del(&sctp_af_inet6.list);
89819 + pax_list_del(&sctp_af_inet6.list);
89820 }
89821
89822 /* Initialize IPv6 support and register with socket layer. */
89823 diff --git a/net/sctp/probe.c b/net/sctp/probe.c
89824 index ad0dba8..e62c225 100644
89825 --- a/net/sctp/probe.c
89826 +++ b/net/sctp/probe.c
89827 @@ -63,7 +63,7 @@ static struct {
89828 struct timespec tstart;
89829 } sctpw;
89830
89831 -static void printl(const char *fmt, ...)
89832 +static __printf(1, 2) void printl(const char *fmt, ...)
89833 {
89834 va_list args;
89835 int len;
89836 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
89837 index ab3bba8..2fbab4e 100644
89838 --- a/net/sctp/proc.c
89839 +++ b/net/sctp/proc.c
89840 @@ -336,7 +336,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
89841 seq_printf(seq,
89842 "%8pK %8pK %-3d %-3d %-2d %-4d "
89843 "%4d %8d %8d %7d %5lu %-5d %5d ",
89844 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
89845 + assoc, sk,
89846 + sctp_sk(sk)->type, sk->sk_state,
89847 assoc->state, hash,
89848 assoc->assoc_id,
89849 assoc->sndbuf_used,
89850 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
89851 index 1c2e46c..f91cf5e 100644
89852 --- a/net/sctp/protocol.c
89853 +++ b/net/sctp/protocol.c
89854 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
89855 return 0;
89856 }
89857
89858 + pax_open_kernel();
89859 INIT_LIST_HEAD(&af->list);
89860 - list_add_tail(&af->list, &sctp_address_families);
89861 + pax_close_kernel();
89862 + pax_list_add_tail(&af->list, &sctp_address_families);
89863 return 1;
89864 }
89865
89866 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
89867
89868 static struct sctp_af sctp_af_inet;
89869
89870 -static struct sctp_pf sctp_pf_inet = {
89871 +static struct sctp_pf sctp_pf_inet __read_only = {
89872 .event_msgname = sctp_inet_event_msgname,
89873 .skb_msgname = sctp_inet_skb_msgname,
89874 .af_supported = sctp_inet_af_supported,
89875 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
89876 };
89877
89878 /* IPv4 address related functions. */
89879 -static struct sctp_af sctp_af_inet = {
89880 +static struct sctp_af sctp_af_inet __read_only = {
89881 .sa_family = AF_INET,
89882 .sctp_xmit = sctp_v4_xmit,
89883 .setsockopt = ip_setsockopt,
89884 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
89885
89886 static void sctp_v4_pf_exit(void)
89887 {
89888 - list_del(&sctp_af_inet.list);
89889 + pax_list_del(&sctp_af_inet.list);
89890 }
89891
89892 static int sctp_v4_protosw_init(void)
89893 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
89894 index 8aab894..f6b7e7d 100644
89895 --- a/net/sctp/sm_sideeffect.c
89896 +++ b/net/sctp/sm_sideeffect.c
89897 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
89898 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
89899 }
89900
89901 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89902 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89903 NULL,
89904 sctp_generate_t1_cookie_event,
89905 sctp_generate_t1_init_event,
89906 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
89907 index b907073..57fef6c 100644
89908 --- a/net/sctp/socket.c
89909 +++ b/net/sctp/socket.c
89910 @@ -2166,11 +2166,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
89911 {
89912 struct sctp_association *asoc;
89913 struct sctp_ulpevent *event;
89914 + struct sctp_event_subscribe subscribe;
89915
89916 if (optlen > sizeof(struct sctp_event_subscribe))
89917 return -EINVAL;
89918 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
89919 + if (copy_from_user(&subscribe, optval, optlen))
89920 return -EFAULT;
89921 + sctp_sk(sk)->subscribe = subscribe;
89922
89923 /*
89924 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
89925 @@ -4215,13 +4217,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
89926 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
89927 int __user *optlen)
89928 {
89929 + struct sctp_event_subscribe subscribe;
89930 +
89931 if (len <= 0)
89932 return -EINVAL;
89933 if (len > sizeof(struct sctp_event_subscribe))
89934 len = sizeof(struct sctp_event_subscribe);
89935 if (put_user(len, optlen))
89936 return -EFAULT;
89937 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
89938 + subscribe = sctp_sk(sk)->subscribe;
89939 + if (copy_to_user(optval, &subscribe, len))
89940 return -EFAULT;
89941 return 0;
89942 }
89943 @@ -4239,6 +4244,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
89944 */
89945 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
89946 {
89947 + __u32 autoclose;
89948 +
89949 /* Applicable to UDP-style socket only */
89950 if (sctp_style(sk, TCP))
89951 return -EOPNOTSUPP;
89952 @@ -4247,7 +4254,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
89953 len = sizeof(int);
89954 if (put_user(len, optlen))
89955 return -EFAULT;
89956 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
89957 + autoclose = sctp_sk(sk)->autoclose;
89958 + if (copy_to_user(optval, &autoclose, sizeof(int)))
89959 return -EFAULT;
89960 return 0;
89961 }
89962 @@ -4619,12 +4627,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
89963 */
89964 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
89965 {
89966 + struct sctp_initmsg initmsg;
89967 +
89968 if (len < sizeof(struct sctp_initmsg))
89969 return -EINVAL;
89970 len = sizeof(struct sctp_initmsg);
89971 if (put_user(len, optlen))
89972 return -EFAULT;
89973 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
89974 + initmsg = sctp_sk(sk)->initmsg;
89975 + if (copy_to_user(optval, &initmsg, len))
89976 return -EFAULT;
89977 return 0;
89978 }
89979 @@ -4665,6 +4676,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
89980 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
89981 if (space_left < addrlen)
89982 return -ENOMEM;
89983 + if (addrlen > sizeof(temp) || addrlen < 0)
89984 + return -EFAULT;
89985 if (copy_to_user(to, &temp, addrlen))
89986 return -EFAULT;
89987 to += addrlen;
89988 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
89989 index bf3c6e8..376d8d0 100644
89990 --- a/net/sctp/sysctl.c
89991 +++ b/net/sctp/sysctl.c
89992 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
89993 {
89994 struct net *net = current->nsproxy->net_ns;
89995 char tmp[8];
89996 - ctl_table tbl;
89997 + ctl_table_no_const tbl;
89998 int ret;
89999 int changed = 0;
90000 char *none = "none";
90001 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
90002
90003 int sctp_sysctl_net_register(struct net *net)
90004 {
90005 - struct ctl_table *table;
90006 + ctl_table_no_const *table;
90007 int i;
90008
90009 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
90010 diff --git a/net/socket.c b/net/socket.c
90011 index 88f759a..c6933de 100644
90012 --- a/net/socket.c
90013 +++ b/net/socket.c
90014 @@ -88,6 +88,7 @@
90015 #include <linux/magic.h>
90016 #include <linux/slab.h>
90017 #include <linux/xattr.h>
90018 +#include <linux/in.h>
90019
90020 #include <asm/uaccess.h>
90021 #include <asm/unistd.h>
90022 @@ -105,6 +106,8 @@
90023 #include <linux/sockios.h>
90024 #include <linux/atalk.h>
90025
90026 +#include <linux/grsock.h>
90027 +
90028 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
90029 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
90030 unsigned long nr_segs, loff_t pos);
90031 @@ -321,7 +324,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
90032 &sockfs_dentry_operations, SOCKFS_MAGIC);
90033 }
90034
90035 -static struct vfsmount *sock_mnt __read_mostly;
90036 +struct vfsmount *sock_mnt __read_mostly;
90037
90038 static struct file_system_type sock_fs_type = {
90039 .name = "sockfs",
90040 @@ -1268,6 +1271,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
90041 return -EAFNOSUPPORT;
90042 if (type < 0 || type >= SOCK_MAX)
90043 return -EINVAL;
90044 + if (protocol < 0)
90045 + return -EINVAL;
90046
90047 /* Compatibility.
90048
90049 @@ -1399,6 +1404,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
90050 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
90051 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
90052
90053 + if(!gr_search_socket(family, type, protocol)) {
90054 + retval = -EACCES;
90055 + goto out;
90056 + }
90057 +
90058 + if (gr_handle_sock_all(family, type, protocol)) {
90059 + retval = -EACCES;
90060 + goto out;
90061 + }
90062 +
90063 retval = sock_create(family, type, protocol, &sock);
90064 if (retval < 0)
90065 goto out;
90066 @@ -1526,6 +1541,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90067 if (sock) {
90068 err = move_addr_to_kernel(umyaddr, addrlen, &address);
90069 if (err >= 0) {
90070 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
90071 + err = -EACCES;
90072 + goto error;
90073 + }
90074 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
90075 + if (err)
90076 + goto error;
90077 +
90078 err = security_socket_bind(sock,
90079 (struct sockaddr *)&address,
90080 addrlen);
90081 @@ -1534,6 +1557,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90082 (struct sockaddr *)
90083 &address, addrlen);
90084 }
90085 +error:
90086 fput_light(sock->file, fput_needed);
90087 }
90088 return err;
90089 @@ -1557,10 +1581,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
90090 if ((unsigned int)backlog > somaxconn)
90091 backlog = somaxconn;
90092
90093 + if (gr_handle_sock_server_other(sock->sk)) {
90094 + err = -EPERM;
90095 + goto error;
90096 + }
90097 +
90098 + err = gr_search_listen(sock);
90099 + if (err)
90100 + goto error;
90101 +
90102 err = security_socket_listen(sock, backlog);
90103 if (!err)
90104 err = sock->ops->listen(sock, backlog);
90105
90106 +error:
90107 fput_light(sock->file, fput_needed);
90108 }
90109 return err;
90110 @@ -1604,6 +1638,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90111 newsock->type = sock->type;
90112 newsock->ops = sock->ops;
90113
90114 + if (gr_handle_sock_server_other(sock->sk)) {
90115 + err = -EPERM;
90116 + sock_release(newsock);
90117 + goto out_put;
90118 + }
90119 +
90120 + err = gr_search_accept(sock);
90121 + if (err) {
90122 + sock_release(newsock);
90123 + goto out_put;
90124 + }
90125 +
90126 /*
90127 * We don't need try_module_get here, as the listening socket (sock)
90128 * has the protocol module (sock->ops->owner) held.
90129 @@ -1649,6 +1695,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90130 fd_install(newfd, newfile);
90131 err = newfd;
90132
90133 + gr_attach_curr_ip(newsock->sk);
90134 +
90135 out_put:
90136 fput_light(sock->file, fput_needed);
90137 out:
90138 @@ -1681,6 +1729,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90139 int, addrlen)
90140 {
90141 struct socket *sock;
90142 + struct sockaddr *sck;
90143 struct sockaddr_storage address;
90144 int err, fput_needed;
90145
90146 @@ -1691,6 +1740,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90147 if (err < 0)
90148 goto out_put;
90149
90150 + sck = (struct sockaddr *)&address;
90151 +
90152 + if (gr_handle_sock_client(sck)) {
90153 + err = -EACCES;
90154 + goto out_put;
90155 + }
90156 +
90157 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
90158 + if (err)
90159 + goto out_put;
90160 +
90161 err =
90162 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
90163 if (err)
90164 @@ -1772,6 +1832,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
90165 * the protocol.
90166 */
90167
90168 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
90169 +
90170 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
90171 unsigned int, flags, struct sockaddr __user *, addr,
90172 int, addr_len)
90173 @@ -1838,7 +1900,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
90174 struct socket *sock;
90175 struct iovec iov;
90176 struct msghdr msg;
90177 - struct sockaddr_storage address;
90178 + struct sockaddr_storage address = { };
90179 int err, err2;
90180 int fput_needed;
90181
90182 @@ -2045,7 +2107,7 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
90183 * checking falls down on this.
90184 */
90185 if (copy_from_user(ctl_buf,
90186 - (void __user __force *)msg_sys->msg_control,
90187 + (void __force_user *)msg_sys->msg_control,
90188 ctl_len))
90189 goto out_freectl;
90190 msg_sys->msg_control = ctl_buf;
90191 @@ -2185,7 +2247,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90192 int err, total_len, len;
90193
90194 /* kernel mode address */
90195 - struct sockaddr_storage addr;
90196 + struct sockaddr_storage addr = { };
90197
90198 /* user mode address pointers */
90199 struct sockaddr __user *uaddr;
90200 @@ -2213,7 +2275,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90201 * kernel msghdr to use the kernel address space)
90202 */
90203
90204 - uaddr = (__force void __user *)msg_sys->msg_name;
90205 + uaddr = (void __force_user *)msg_sys->msg_name;
90206 uaddr_len = COMPAT_NAMELEN(msg);
90207 if (MSG_CMSG_COMPAT & flags) {
90208 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
90209 @@ -2952,7 +3014,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
90210 old_fs = get_fs();
90211 set_fs(KERNEL_DS);
90212 err = dev_ioctl(net, cmd,
90213 - (struct ifreq __user __force *) &kifr);
90214 + (struct ifreq __force_user *) &kifr);
90215 set_fs(old_fs);
90216
90217 return err;
90218 @@ -3061,7 +3123,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
90219
90220 old_fs = get_fs();
90221 set_fs(KERNEL_DS);
90222 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
90223 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
90224 set_fs(old_fs);
90225
90226 if (cmd == SIOCGIFMAP && !err) {
90227 @@ -3166,7 +3228,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
90228 ret |= __get_user(rtdev, &(ur4->rt_dev));
90229 if (rtdev) {
90230 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
90231 - r4.rt_dev = (char __user __force *)devname;
90232 + r4.rt_dev = (char __force_user *)devname;
90233 devname[15] = 0;
90234 } else
90235 r4.rt_dev = NULL;
90236 @@ -3392,8 +3454,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
90237 int __user *uoptlen;
90238 int err;
90239
90240 - uoptval = (char __user __force *) optval;
90241 - uoptlen = (int __user __force *) optlen;
90242 + uoptval = (char __force_user *) optval;
90243 + uoptlen = (int __force_user *) optlen;
90244
90245 set_fs(KERNEL_DS);
90246 if (level == SOL_SOCKET)
90247 @@ -3413,7 +3475,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
90248 char __user *uoptval;
90249 int err;
90250
90251 - uoptval = (char __user __force *) optval;
90252 + uoptval = (char __force_user *) optval;
90253
90254 set_fs(KERNEL_DS);
90255 if (level == SOL_SOCKET)
90256 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
90257 index d5f35f1..da2680b5 100644
90258 --- a/net/sunrpc/clnt.c
90259 +++ b/net/sunrpc/clnt.c
90260 @@ -1283,7 +1283,9 @@ call_start(struct rpc_task *task)
90261 (RPC_IS_ASYNC(task) ? "async" : "sync"));
90262
90263 /* Increment call count */
90264 - task->tk_msg.rpc_proc->p_count++;
90265 + pax_open_kernel();
90266 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
90267 + pax_close_kernel();
90268 clnt->cl_stats->rpccnt++;
90269 task->tk_action = call_reserve;
90270 }
90271 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
90272 index f8529fc..ce8c643 100644
90273 --- a/net/sunrpc/sched.c
90274 +++ b/net/sunrpc/sched.c
90275 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
90276 #ifdef RPC_DEBUG
90277 static void rpc_task_set_debuginfo(struct rpc_task *task)
90278 {
90279 - static atomic_t rpc_pid;
90280 + static atomic_unchecked_t rpc_pid;
90281
90282 - task->tk_pid = atomic_inc_return(&rpc_pid);
90283 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
90284 }
90285 #else
90286 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
90287 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
90288 index 89a588b..ba2cef8 100644
90289 --- a/net/sunrpc/svc.c
90290 +++ b/net/sunrpc/svc.c
90291 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
90292 svc_putnl(resv, RPC_SUCCESS);
90293
90294 /* Bump per-procedure stats counter */
90295 - procp->pc_count++;
90296 + pax_open_kernel();
90297 + (*(unsigned int *)&procp->pc_count)++;
90298 + pax_close_kernel();
90299
90300 /* Initialize storage for argp and resp */
90301 memset(rqstp->rq_argp, 0, procp->pc_argsize);
90302 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
90303 index 8343737..677025e 100644
90304 --- a/net/sunrpc/xprtrdma/svc_rdma.c
90305 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
90306 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
90307 static unsigned int min_max_inline = 4096;
90308 static unsigned int max_max_inline = 65536;
90309
90310 -atomic_t rdma_stat_recv;
90311 -atomic_t rdma_stat_read;
90312 -atomic_t rdma_stat_write;
90313 -atomic_t rdma_stat_sq_starve;
90314 -atomic_t rdma_stat_rq_starve;
90315 -atomic_t rdma_stat_rq_poll;
90316 -atomic_t rdma_stat_rq_prod;
90317 -atomic_t rdma_stat_sq_poll;
90318 -atomic_t rdma_stat_sq_prod;
90319 +atomic_unchecked_t rdma_stat_recv;
90320 +atomic_unchecked_t rdma_stat_read;
90321 +atomic_unchecked_t rdma_stat_write;
90322 +atomic_unchecked_t rdma_stat_sq_starve;
90323 +atomic_unchecked_t rdma_stat_rq_starve;
90324 +atomic_unchecked_t rdma_stat_rq_poll;
90325 +atomic_unchecked_t rdma_stat_rq_prod;
90326 +atomic_unchecked_t rdma_stat_sq_poll;
90327 +atomic_unchecked_t rdma_stat_sq_prod;
90328
90329 /* Temporary NFS request map and context caches */
90330 struct kmem_cache *svc_rdma_map_cachep;
90331 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
90332 len -= *ppos;
90333 if (len > *lenp)
90334 len = *lenp;
90335 - if (len && copy_to_user(buffer, str_buf, len))
90336 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
90337 return -EFAULT;
90338 *lenp = len;
90339 *ppos += len;
90340 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
90341 {
90342 .procname = "rdma_stat_read",
90343 .data = &rdma_stat_read,
90344 - .maxlen = sizeof(atomic_t),
90345 + .maxlen = sizeof(atomic_unchecked_t),
90346 .mode = 0644,
90347 .proc_handler = read_reset_stat,
90348 },
90349 {
90350 .procname = "rdma_stat_recv",
90351 .data = &rdma_stat_recv,
90352 - .maxlen = sizeof(atomic_t),
90353 + .maxlen = sizeof(atomic_unchecked_t),
90354 .mode = 0644,
90355 .proc_handler = read_reset_stat,
90356 },
90357 {
90358 .procname = "rdma_stat_write",
90359 .data = &rdma_stat_write,
90360 - .maxlen = sizeof(atomic_t),
90361 + .maxlen = sizeof(atomic_unchecked_t),
90362 .mode = 0644,
90363 .proc_handler = read_reset_stat,
90364 },
90365 {
90366 .procname = "rdma_stat_sq_starve",
90367 .data = &rdma_stat_sq_starve,
90368 - .maxlen = sizeof(atomic_t),
90369 + .maxlen = sizeof(atomic_unchecked_t),
90370 .mode = 0644,
90371 .proc_handler = read_reset_stat,
90372 },
90373 {
90374 .procname = "rdma_stat_rq_starve",
90375 .data = &rdma_stat_rq_starve,
90376 - .maxlen = sizeof(atomic_t),
90377 + .maxlen = sizeof(atomic_unchecked_t),
90378 .mode = 0644,
90379 .proc_handler = read_reset_stat,
90380 },
90381 {
90382 .procname = "rdma_stat_rq_poll",
90383 .data = &rdma_stat_rq_poll,
90384 - .maxlen = sizeof(atomic_t),
90385 + .maxlen = sizeof(atomic_unchecked_t),
90386 .mode = 0644,
90387 .proc_handler = read_reset_stat,
90388 },
90389 {
90390 .procname = "rdma_stat_rq_prod",
90391 .data = &rdma_stat_rq_prod,
90392 - .maxlen = sizeof(atomic_t),
90393 + .maxlen = sizeof(atomic_unchecked_t),
90394 .mode = 0644,
90395 .proc_handler = read_reset_stat,
90396 },
90397 {
90398 .procname = "rdma_stat_sq_poll",
90399 .data = &rdma_stat_sq_poll,
90400 - .maxlen = sizeof(atomic_t),
90401 + .maxlen = sizeof(atomic_unchecked_t),
90402 .mode = 0644,
90403 .proc_handler = read_reset_stat,
90404 },
90405 {
90406 .procname = "rdma_stat_sq_prod",
90407 .data = &rdma_stat_sq_prod,
90408 - .maxlen = sizeof(atomic_t),
90409 + .maxlen = sizeof(atomic_unchecked_t),
90410 .mode = 0644,
90411 .proc_handler = read_reset_stat,
90412 },
90413 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90414 index 0ce7552..d074459 100644
90415 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90416 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90417 @@ -501,7 +501,7 @@ next_sge:
90418 svc_rdma_put_context(ctxt, 0);
90419 goto out;
90420 }
90421 - atomic_inc(&rdma_stat_read);
90422 + atomic_inc_unchecked(&rdma_stat_read);
90423
90424 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
90425 chl_map->ch[ch_no].count -= read_wr.num_sge;
90426 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90427 dto_q);
90428 list_del_init(&ctxt->dto_q);
90429 } else {
90430 - atomic_inc(&rdma_stat_rq_starve);
90431 + atomic_inc_unchecked(&rdma_stat_rq_starve);
90432 clear_bit(XPT_DATA, &xprt->xpt_flags);
90433 ctxt = NULL;
90434 }
90435 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90436 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
90437 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
90438 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
90439 - atomic_inc(&rdma_stat_recv);
90440 + atomic_inc_unchecked(&rdma_stat_recv);
90441
90442 /* Build up the XDR from the receive buffers. */
90443 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
90444 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90445 index c1d124d..acfc59e 100644
90446 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90447 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90448 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
90449 write_wr.wr.rdma.remote_addr = to;
90450
90451 /* Post It */
90452 - atomic_inc(&rdma_stat_write);
90453 + atomic_inc_unchecked(&rdma_stat_write);
90454 if (svc_rdma_send(xprt, &write_wr))
90455 goto err;
90456 return 0;
90457 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90458 index 62e4f9b..dd3f2d7 100644
90459 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
90460 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90461 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90462 return;
90463
90464 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
90465 - atomic_inc(&rdma_stat_rq_poll);
90466 + atomic_inc_unchecked(&rdma_stat_rq_poll);
90467
90468 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
90469 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
90470 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90471 }
90472
90473 if (ctxt)
90474 - atomic_inc(&rdma_stat_rq_prod);
90475 + atomic_inc_unchecked(&rdma_stat_rq_prod);
90476
90477 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
90478 /*
90479 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90480 return;
90481
90482 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
90483 - atomic_inc(&rdma_stat_sq_poll);
90484 + atomic_inc_unchecked(&rdma_stat_sq_poll);
90485 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
90486 if (wc.status != IB_WC_SUCCESS)
90487 /* Close the transport */
90488 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90489 }
90490
90491 if (ctxt)
90492 - atomic_inc(&rdma_stat_sq_prod);
90493 + atomic_inc_unchecked(&rdma_stat_sq_prod);
90494 }
90495
90496 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
90497 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
90498 spin_lock_bh(&xprt->sc_lock);
90499 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
90500 spin_unlock_bh(&xprt->sc_lock);
90501 - atomic_inc(&rdma_stat_sq_starve);
90502 + atomic_inc_unchecked(&rdma_stat_sq_starve);
90503
90504 /* See if we can opportunistically reap SQ WR to make room */
90505 sq_cq_reap(xprt);
90506 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
90507 index 9bc6db0..47ac8c0 100644
90508 --- a/net/sysctl_net.c
90509 +++ b/net/sysctl_net.c
90510 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
90511 kgid_t root_gid = make_kgid(net->user_ns, 0);
90512
90513 /* Allow network administrator to have same access as root. */
90514 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
90515 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
90516 uid_eq(root_uid, current_uid())) {
90517 int mode = (table->mode >> 6) & 7;
90518 return (mode << 6) | (mode << 3) | mode;
90519 diff --git a/net/tipc/link.c b/net/tipc/link.c
90520 index daa6080..2bbbe70 100644
90521 --- a/net/tipc/link.c
90522 +++ b/net/tipc/link.c
90523 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
90524 struct tipc_msg fragm_hdr;
90525 struct sk_buff *buf, *buf_chain, *prev;
90526 u32 fragm_crs, fragm_rest, hsz, sect_rest;
90527 - const unchar *sect_crs;
90528 + const unchar __user *sect_crs;
90529 int curr_sect;
90530 u32 fragm_no;
90531
90532 @@ -1242,7 +1242,7 @@ again:
90533
90534 if (!sect_rest) {
90535 sect_rest = msg_sect[++curr_sect].iov_len;
90536 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
90537 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
90538 }
90539
90540 if (sect_rest < fragm_rest)
90541 @@ -1261,7 +1261,7 @@ error:
90542 }
90543 } else
90544 skb_copy_to_linear_data_offset(buf, fragm_crs,
90545 - sect_crs, sz);
90546 + (const void __force_kernel *)sect_crs, sz);
90547 sect_crs += sz;
90548 sect_rest -= sz;
90549 fragm_crs += sz;
90550 @@ -2306,8 +2306,11 @@ static int link_recv_changeover_msg(struct tipc_link **l_ptr,
90551 struct tipc_msg *tunnel_msg = buf_msg(tunnel_buf);
90552 u32 msg_typ = msg_type(tunnel_msg);
90553 u32 msg_count = msg_msgcnt(tunnel_msg);
90554 + u32 bearer_id = msg_bearer_id(tunnel_msg);
90555
90556 - dest_link = (*l_ptr)->owner->links[msg_bearer_id(tunnel_msg)];
90557 + if (bearer_id >= MAX_BEARERS)
90558 + goto exit;
90559 + dest_link = (*l_ptr)->owner->links[bearer_id];
90560 if (!dest_link)
90561 goto exit;
90562 if (dest_link == *l_ptr) {
90563 @@ -2521,14 +2524,16 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
90564 struct tipc_msg *imsg = (struct tipc_msg *)msg_data(fragm);
90565 u32 msg_sz = msg_size(imsg);
90566 u32 fragm_sz = msg_data_sz(fragm);
90567 - u32 exp_fragm_cnt = msg_sz/fragm_sz + !!(msg_sz % fragm_sz);
90568 + u32 exp_fragm_cnt;
90569 u32 max = TIPC_MAX_USER_MSG_SIZE + NAMED_H_SIZE;
90570 +
90571 if (msg_type(imsg) == TIPC_MCAST_MSG)
90572 max = TIPC_MAX_USER_MSG_SIZE + MCAST_H_SIZE;
90573 - if (msg_size(imsg) > max) {
90574 + if (fragm_sz == 0 || msg_size(imsg) > max) {
90575 kfree_skb(fbuf);
90576 return 0;
90577 }
90578 + exp_fragm_cnt = msg_sz / fragm_sz + !!(msg_sz % fragm_sz);
90579 pbuf = tipc_buf_acquire(msg_size(imsg));
90580 if (pbuf != NULL) {
90581 pbuf->next = *pending;
90582 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
90583 index f2db8a8..9245aa4 100644
90584 --- a/net/tipc/msg.c
90585 +++ b/net/tipc/msg.c
90586 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
90587 msg_sect[cnt].iov_len);
90588 else
90589 skb_copy_to_linear_data_offset(*buf, pos,
90590 - msg_sect[cnt].iov_base,
90591 + (const void __force_kernel *)msg_sect[cnt].iov_base,
90592 msg_sect[cnt].iov_len);
90593 pos += msg_sect[cnt].iov_len;
90594 }
90595 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
90596 index 6b42d47..2ac24d5 100644
90597 --- a/net/tipc/subscr.c
90598 +++ b/net/tipc/subscr.c
90599 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
90600 {
90601 struct iovec msg_sect;
90602
90603 - msg_sect.iov_base = (void *)&sub->evt;
90604 + msg_sect.iov_base = (void __force_user *)&sub->evt;
90605 msg_sect.iov_len = sizeof(struct tipc_event);
90606
90607 sub->evt.event = htohl(event, sub->swap);
90608 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
90609 index 2db702d..09a77488 100644
90610 --- a/net/unix/af_unix.c
90611 +++ b/net/unix/af_unix.c
90612 @@ -783,6 +783,12 @@ static struct sock *unix_find_other(struct net *net,
90613 err = -ECONNREFUSED;
90614 if (!S_ISSOCK(inode->i_mode))
90615 goto put_fail;
90616 +
90617 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
90618 + err = -EACCES;
90619 + goto put_fail;
90620 + }
90621 +
90622 u = unix_find_socket_byinode(inode);
90623 if (!u)
90624 goto put_fail;
90625 @@ -803,6 +809,13 @@ static struct sock *unix_find_other(struct net *net,
90626 if (u) {
90627 struct dentry *dentry;
90628 dentry = unix_sk(u)->path.dentry;
90629 +
90630 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
90631 + err = -EPERM;
90632 + sock_put(u);
90633 + goto fail;
90634 + }
90635 +
90636 if (dentry)
90637 touch_atime(&unix_sk(u)->path);
90638 } else
90639 @@ -836,12 +849,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
90640 */
90641 err = security_path_mknod(&path, dentry, mode, 0);
90642 if (!err) {
90643 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
90644 + err = -EACCES;
90645 + goto out;
90646 + }
90647 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
90648 if (!err) {
90649 res->mnt = mntget(path.mnt);
90650 res->dentry = dget(dentry);
90651 + gr_handle_create(dentry, path.mnt);
90652 }
90653 }
90654 +out:
90655 done_path_create(&path, dentry);
90656 return err;
90657 }
90658 @@ -2323,9 +2342,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90659 seq_puts(seq, "Num RefCount Protocol Flags Type St "
90660 "Inode Path\n");
90661 else {
90662 - struct sock *s = v;
90663 + struct sock *s = v, *peer;
90664 struct unix_sock *u = unix_sk(s);
90665 unix_state_lock(s);
90666 + peer = unix_peer(s);
90667 + unix_state_unlock(s);
90668 +
90669 + unix_state_double_lock(s, peer);
90670
90671 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
90672 s,
90673 @@ -2352,8 +2375,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90674 }
90675 for ( ; i < len; i++)
90676 seq_putc(seq, u->addr->name->sun_path[i]);
90677 - }
90678 - unix_state_unlock(s);
90679 + } else if (peer)
90680 + seq_printf(seq, " P%lu", sock_i_ino(peer));
90681 +
90682 + unix_state_double_unlock(s, peer);
90683 seq_putc(seq, '\n');
90684 }
90685
90686 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
90687 index 8800604..0526440 100644
90688 --- a/net/unix/sysctl_net_unix.c
90689 +++ b/net/unix/sysctl_net_unix.c
90690 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
90691
90692 int __net_init unix_sysctl_register(struct net *net)
90693 {
90694 - struct ctl_table *table;
90695 + ctl_table_no_const *table;
90696
90697 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
90698 if (table == NULL)
90699 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
90700 index c8717c1..08539f5 100644
90701 --- a/net/wireless/wext-core.c
90702 +++ b/net/wireless/wext-core.c
90703 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90704 */
90705
90706 /* Support for very large requests */
90707 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
90708 - (user_length > descr->max_tokens)) {
90709 + if (user_length > descr->max_tokens) {
90710 /* Allow userspace to GET more than max so
90711 * we can support any size GET requests.
90712 * There is still a limit : -ENOMEM.
90713 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90714 }
90715 }
90716
90717 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
90718 - /*
90719 - * If this is a GET, but not NOMAX, it means that the extra
90720 - * data is not bounded by userspace, but by max_tokens. Thus
90721 - * set the length to max_tokens. This matches the extra data
90722 - * allocation.
90723 - * The driver should fill it with the number of tokens it
90724 - * provided, and it may check iwp->length rather than having
90725 - * knowledge of max_tokens. If the driver doesn't change the
90726 - * iwp->length, this ioctl just copies back max_token tokens
90727 - * filled with zeroes. Hopefully the driver isn't claiming
90728 - * them to be valid data.
90729 - */
90730 - iwp->length = descr->max_tokens;
90731 - }
90732 -
90733 err = handler(dev, info, (union iwreq_data *) iwp, extra);
90734
90735 iwp->length += essid_compat;
90736 diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
90737 index bcfda89..0cf003d 100644
90738 --- a/net/xfrm/xfrm_output.c
90739 +++ b/net/xfrm/xfrm_output.c
90740 @@ -64,6 +64,7 @@ static int xfrm_output_one(struct sk_buff *skb, int err)
90741
90742 if (unlikely(x->km.state != XFRM_STATE_VALID)) {
90743 XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTSTATEINVALID);
90744 + err = -EINVAL;
90745 goto error;
90746 }
90747
90748 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
90749 index 167c67d..3f2ae427 100644
90750 --- a/net/xfrm/xfrm_policy.c
90751 +++ b/net/xfrm/xfrm_policy.c
90752 @@ -334,7 +334,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
90753 {
90754 policy->walk.dead = 1;
90755
90756 - atomic_inc(&policy->genid);
90757 + atomic_inc_unchecked(&policy->genid);
90758
90759 del_timer(&policy->polq.hold_timer);
90760 xfrm_queue_purge(&policy->polq.hold_queue);
90761 @@ -659,7 +659,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
90762 hlist_add_head(&policy->bydst, chain);
90763 xfrm_pol_hold(policy);
90764 net->xfrm.policy_count[dir]++;
90765 - atomic_inc(&flow_cache_genid);
90766 + atomic_inc_unchecked(&flow_cache_genid);
90767 rt_genid_bump(net);
90768 if (delpol) {
90769 xfrm_policy_requeue(delpol, policy);
90770 @@ -1611,7 +1611,7 @@ free_dst:
90771 goto out;
90772 }
90773
90774 -static int inline
90775 +static inline int
90776 xfrm_dst_alloc_copy(void **target, const void *src, int size)
90777 {
90778 if (!*target) {
90779 @@ -1623,7 +1623,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
90780 return 0;
90781 }
90782
90783 -static int inline
90784 +static inline int
90785 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90786 {
90787 #ifdef CONFIG_XFRM_SUB_POLICY
90788 @@ -1635,7 +1635,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90789 #endif
90790 }
90791
90792 -static int inline
90793 +static inline int
90794 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
90795 {
90796 #ifdef CONFIG_XFRM_SUB_POLICY
90797 @@ -1729,7 +1729,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
90798
90799 xdst->num_pols = num_pols;
90800 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
90801 - xdst->policy_genid = atomic_read(&pols[0]->genid);
90802 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
90803
90804 return xdst;
90805 }
90806 @@ -2598,7 +2598,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
90807 if (xdst->xfrm_genid != dst->xfrm->genid)
90808 return 0;
90809 if (xdst->num_pols > 0 &&
90810 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
90811 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
90812 return 0;
90813
90814 mtu = dst_mtu(dst->child);
90815 @@ -2686,8 +2686,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
90816 dst_ops->link_failure = xfrm_link_failure;
90817 if (likely(dst_ops->neigh_lookup == NULL))
90818 dst_ops->neigh_lookup = xfrm_neigh_lookup;
90819 - if (likely(afinfo->garbage_collect == NULL))
90820 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90821 + if (likely(afinfo->garbage_collect == NULL)) {
90822 + pax_open_kernel();
90823 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90824 + pax_close_kernel();
90825 + }
90826 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
90827 }
90828 spin_unlock(&xfrm_policy_afinfo_lock);
90829 @@ -2741,7 +2744,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
90830 dst_ops->check = NULL;
90831 dst_ops->negative_advice = NULL;
90832 dst_ops->link_failure = NULL;
90833 - afinfo->garbage_collect = NULL;
90834 + pax_open_kernel();
90835 + *(void **)&afinfo->garbage_collect = NULL;
90836 + pax_close_kernel();
90837 }
90838 return err;
90839 }
90840 @@ -3124,7 +3129,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
90841 sizeof(pol->xfrm_vec[i].saddr));
90842 pol->xfrm_vec[i].encap_family = mp->new_family;
90843 /* flush bundles */
90844 - atomic_inc(&pol->genid);
90845 + atomic_inc_unchecked(&pol->genid);
90846 }
90847 }
90848
90849 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
90850 index 2c341bd..4404211 100644
90851 --- a/net/xfrm/xfrm_state.c
90852 +++ b/net/xfrm/xfrm_state.c
90853 @@ -177,12 +177,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
90854
90855 if (unlikely(afinfo == NULL))
90856 return -EAFNOSUPPORT;
90857 - typemap = afinfo->type_map;
90858 + typemap = (const struct xfrm_type **)afinfo->type_map;
90859 spin_lock_bh(&xfrm_type_lock);
90860
90861 - if (likely(typemap[type->proto] == NULL))
90862 + if (likely(typemap[type->proto] == NULL)) {
90863 + pax_open_kernel();
90864 typemap[type->proto] = type;
90865 - else
90866 + pax_close_kernel();
90867 + } else
90868 err = -EEXIST;
90869 spin_unlock_bh(&xfrm_type_lock);
90870 xfrm_state_put_afinfo(afinfo);
90871 @@ -198,13 +200,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
90872
90873 if (unlikely(afinfo == NULL))
90874 return -EAFNOSUPPORT;
90875 - typemap = afinfo->type_map;
90876 + typemap = (const struct xfrm_type **)afinfo->type_map;
90877 spin_lock_bh(&xfrm_type_lock);
90878
90879 if (unlikely(typemap[type->proto] != type))
90880 err = -ENOENT;
90881 - else
90882 + else {
90883 + pax_open_kernel();
90884 typemap[type->proto] = NULL;
90885 + pax_close_kernel();
90886 + }
90887 spin_unlock_bh(&xfrm_type_lock);
90888 xfrm_state_put_afinfo(afinfo);
90889 return err;
90890 @@ -214,7 +219,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
90891 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
90892 {
90893 struct xfrm_state_afinfo *afinfo;
90894 - const struct xfrm_type **typemap;
90895 const struct xfrm_type *type;
90896 int modload_attempted = 0;
90897
90898 @@ -222,9 +226,8 @@ retry:
90899 afinfo = xfrm_state_get_afinfo(family);
90900 if (unlikely(afinfo == NULL))
90901 return NULL;
90902 - typemap = afinfo->type_map;
90903
90904 - type = typemap[proto];
90905 + type = afinfo->type_map[proto];
90906 if (unlikely(type && !try_module_get(type->owner)))
90907 type = NULL;
90908 if (!type && !modload_attempted) {
90909 @@ -258,7 +261,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
90910 return -EAFNOSUPPORT;
90911
90912 err = -EEXIST;
90913 - modemap = afinfo->mode_map;
90914 + modemap = (struct xfrm_mode **)afinfo->mode_map;
90915 spin_lock_bh(&xfrm_mode_lock);
90916 if (modemap[mode->encap])
90917 goto out;
90918 @@ -267,8 +270,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
90919 if (!try_module_get(afinfo->owner))
90920 goto out;
90921
90922 - mode->afinfo = afinfo;
90923 + pax_open_kernel();
90924 + *(const void **)&mode->afinfo = afinfo;
90925 modemap[mode->encap] = mode;
90926 + pax_close_kernel();
90927 err = 0;
90928
90929 out:
90930 @@ -292,10 +297,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
90931 return -EAFNOSUPPORT;
90932
90933 err = -ENOENT;
90934 - modemap = afinfo->mode_map;
90935 + modemap = (struct xfrm_mode **)afinfo->mode_map;
90936 spin_lock_bh(&xfrm_mode_lock);
90937 if (likely(modemap[mode->encap] == mode)) {
90938 + pax_open_kernel();
90939 modemap[mode->encap] = NULL;
90940 + pax_close_kernel();
90941 module_put(mode->afinfo->owner);
90942 err = 0;
90943 }
90944 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
90945 index 05a6e3d..6716ec9 100644
90946 --- a/net/xfrm/xfrm_sysctl.c
90947 +++ b/net/xfrm/xfrm_sysctl.c
90948 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
90949
90950 int __net_init xfrm_sysctl_init(struct net *net)
90951 {
90952 - struct ctl_table *table;
90953 + ctl_table_no_const *table;
90954
90955 __xfrm_sysctl_init(net);
90956
90957 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
90958 index 0e801c3..5c8ad3b 100644
90959 --- a/scripts/Makefile.build
90960 +++ b/scripts/Makefile.build
90961 @@ -111,7 +111,7 @@ endif
90962 endif
90963
90964 # Do not include host rules unless needed
90965 -ifneq ($(hostprogs-y)$(hostprogs-m),)
90966 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
90967 include scripts/Makefile.host
90968 endif
90969
90970 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
90971 index 686cb0d..9d653bf 100644
90972 --- a/scripts/Makefile.clean
90973 +++ b/scripts/Makefile.clean
90974 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
90975 __clean-files := $(extra-y) $(always) \
90976 $(targets) $(clean-files) \
90977 $(host-progs) \
90978 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
90979 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
90980 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
90981
90982 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
90983
90984 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
90985 index 1ac414f..38575f7 100644
90986 --- a/scripts/Makefile.host
90987 +++ b/scripts/Makefile.host
90988 @@ -31,6 +31,8 @@
90989 # Note: Shared libraries consisting of C++ files are not supported
90990
90991 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
90992 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
90993 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
90994
90995 # C code
90996 # Executables compiled from a single .c file
90997 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
90998 # Shared libaries (only .c supported)
90999 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
91000 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
91001 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
91002 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
91003 # Remove .so files from "xxx-objs"
91004 host-cobjs := $(filter-out %.so,$(host-cobjs))
91005 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
91006
91007 -#Object (.o) files used by the shared libaries
91008 +# Object (.o) files used by the shared libaries
91009 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
91010 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
91011
91012 # output directory for programs/.o files
91013 # hostprogs-y := tools/build may have been specified. Retrieve directory
91014 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
91015 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
91016 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
91017 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
91018 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
91019 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
91020 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
91021 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
91022
91023 obj-dirs += $(host-objdirs)
91024 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
91025 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
91026 $(call if_changed_dep,host-cshobjs)
91027
91028 +# Compile .c file, create position independent .o file
91029 +# host-cxxshobjs -> .o
91030 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
91031 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
91032 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
91033 + $(call if_changed_dep,host-cxxshobjs)
91034 +
91035 # Link a shared library, based on position independent .o files
91036 # *.o -> .so shared library (host-cshlib)
91037 quiet_cmd_host-cshlib = HOSTLLD -shared $@
91038 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
91039 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
91040 $(call if_changed,host-cshlib)
91041
91042 +# Link a shared library, based on position independent .o files
91043 +# *.o -> .so shared library (host-cxxshlib)
91044 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
91045 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
91046 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
91047 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
91048 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
91049 + $(call if_changed,host-cxxshlib)
91050 +
91051 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
91052 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
91053 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
91054
91055 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
91056 index 7f6425e..9864506 100644
91057 --- a/scripts/basic/fixdep.c
91058 +++ b/scripts/basic/fixdep.c
91059 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
91060 /*
91061 * Lookup a value in the configuration string.
91062 */
91063 -static int is_defined_config(const char *name, int len, unsigned int hash)
91064 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
91065 {
91066 struct item *aux;
91067
91068 @@ -211,10 +211,10 @@ static void clear_config(void)
91069 /*
91070 * Record the use of a CONFIG_* word.
91071 */
91072 -static void use_config(const char *m, int slen)
91073 +static void use_config(const char *m, unsigned int slen)
91074 {
91075 unsigned int hash = strhash(m, slen);
91076 - int c, i;
91077 + unsigned int c, i;
91078
91079 if (is_defined_config(m, slen, hash))
91080 return;
91081 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
91082
91083 static void parse_config_file(const char *map, size_t len)
91084 {
91085 - const int *end = (const int *) (map + len);
91086 + const unsigned int *end = (const unsigned int *) (map + len);
91087 /* start at +1, so that p can never be < map */
91088 - const int *m = (const int *) map + 1;
91089 + const unsigned int *m = (const unsigned int *) map + 1;
91090 const char *p, *q;
91091
91092 for (; m < end; m++) {
91093 @@ -406,7 +406,7 @@ static void print_deps(void)
91094 static void traps(void)
91095 {
91096 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
91097 - int *p = (int *)test;
91098 + unsigned int *p = (unsigned int *)test;
91099
91100 if (*p != INT_CONF) {
91101 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
91102 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
91103 new file mode 100644
91104 index 0000000..5e0222d
91105 --- /dev/null
91106 +++ b/scripts/gcc-plugin.sh
91107 @@ -0,0 +1,17 @@
91108 +#!/bin/bash
91109 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
91110 +#include "gcc-plugin.h"
91111 +#include "tree.h"
91112 +#include "tm.h"
91113 +#include "rtl.h"
91114 +#ifdef ENABLE_BUILD_WITH_CXX
91115 +#warning $2
91116 +#else
91117 +#warning $1
91118 +#endif
91119 +EOF`
91120 +if [ $? -eq 0 ]
91121 +then
91122 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
91123 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
91124 +fi
91125 diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
91126 index 581ca99..a6ff02e 100644
91127 --- a/scripts/headers_install.pl
91128 +++ b/scripts/headers_install.pl
91129 @@ -35,6 +35,7 @@ foreach my $filename (@files) {
91130 $line =~ s/([\s(])__user\s/$1/g;
91131 $line =~ s/([\s(])__force\s/$1/g;
91132 $line =~ s/([\s(])__iomem\s/$1/g;
91133 + $line =~ s/(\s?)__intentional_overflow\([-\d\s,]*\)\s?/$1/g;
91134 $line =~ s/\s__attribute_const__\s/ /g;
91135 $line =~ s/\s__attribute_const__$//g;
91136 $line =~ s/\b__packed\b/__attribute__((packed))/g;
91137 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
91138 index 3d569d6..0c09522 100644
91139 --- a/scripts/link-vmlinux.sh
91140 +++ b/scripts/link-vmlinux.sh
91141 @@ -159,7 +159,7 @@ else
91142 fi;
91143
91144 # final build of init/
91145 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
91146 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
91147
91148 kallsymso=""
91149 kallsyms_vmlinux=""
91150 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
91151 index 771ac17..9f0d3ee 100644
91152 --- a/scripts/mod/file2alias.c
91153 +++ b/scripts/mod/file2alias.c
91154 @@ -140,7 +140,7 @@ static void device_id_check(const char *modname, const char *device_id,
91155 unsigned long size, unsigned long id_size,
91156 void *symval)
91157 {
91158 - int i;
91159 + unsigned int i;
91160
91161 if (size % id_size || size < id_size) {
91162 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
91163 @@ -168,7 +168,7 @@ static void device_id_check(const char *modname, const char *device_id,
91164 /* USB is special because the bcdDevice can be matched against a numeric range */
91165 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
91166 static void do_usb_entry(void *symval,
91167 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
91168 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
91169 unsigned char range_lo, unsigned char range_hi,
91170 unsigned char max, struct module *mod)
91171 {
91172 @@ -278,7 +278,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
91173 {
91174 unsigned int devlo, devhi;
91175 unsigned char chi, clo, max;
91176 - int ndigits;
91177 + unsigned int ndigits;
91178
91179 DEF_FIELD(symval, usb_device_id, match_flags);
91180 DEF_FIELD(symval, usb_device_id, idVendor);
91181 @@ -531,7 +531,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
91182 for (i = 0; i < count; i++) {
91183 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
91184 char acpi_id[sizeof(*id)];
91185 - int j;
91186 + unsigned int j;
91187
91188 buf_printf(&mod->dev_table_buf,
91189 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
91190 @@ -560,7 +560,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91191
91192 for (j = 0; j < PNP_MAX_DEVICES; j++) {
91193 const char *id = (char *)(*devs)[j].id;
91194 - int i2, j2;
91195 + unsigned int i2, j2;
91196 int dup = 0;
91197
91198 if (!id[0])
91199 @@ -586,7 +586,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91200 /* add an individual alias for every device entry */
91201 if (!dup) {
91202 char acpi_id[PNP_ID_LEN];
91203 - int k;
91204 + unsigned int k;
91205
91206 buf_printf(&mod->dev_table_buf,
91207 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91208 @@ -938,7 +938,7 @@ static void dmi_ascii_filter(char *d, const char *s)
91209 static int do_dmi_entry(const char *filename, void *symval,
91210 char *alias)
91211 {
91212 - int i, j;
91213 + unsigned int i, j;
91214 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
91215 sprintf(alias, "dmi*");
91216
91217 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
91218 index 78b30c1..536850d 100644
91219 --- a/scripts/mod/modpost.c
91220 +++ b/scripts/mod/modpost.c
91221 @@ -931,6 +931,7 @@ enum mismatch {
91222 ANY_INIT_TO_ANY_EXIT,
91223 ANY_EXIT_TO_ANY_INIT,
91224 EXPORT_TO_INIT_EXIT,
91225 + DATA_TO_TEXT
91226 };
91227
91228 struct sectioncheck {
91229 @@ -1045,6 +1046,12 @@ const struct sectioncheck sectioncheck[] = {
91230 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
91231 .mismatch = EXPORT_TO_INIT_EXIT,
91232 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
91233 +},
91234 +/* Do not reference code from writable data */
91235 +{
91236 + .fromsec = { DATA_SECTIONS, NULL },
91237 + .tosec = { TEXT_SECTIONS, NULL },
91238 + .mismatch = DATA_TO_TEXT
91239 }
91240 };
91241
91242 @@ -1167,10 +1174,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
91243 continue;
91244 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
91245 continue;
91246 - if (sym->st_value == addr)
91247 - return sym;
91248 /* Find a symbol nearby - addr are maybe negative */
91249 d = sym->st_value - addr;
91250 + if (d == 0)
91251 + return sym;
91252 if (d < 0)
91253 d = addr - sym->st_value;
91254 if (d < distance) {
91255 @@ -1449,6 +1456,14 @@ static void report_sec_mismatch(const char *modname,
91256 tosym, prl_to, prl_to, tosym);
91257 free(prl_to);
91258 break;
91259 + case DATA_TO_TEXT:
91260 +#if 0
91261 + fprintf(stderr,
91262 + "The %s %s:%s references\n"
91263 + "the %s %s:%s%s\n",
91264 + from, fromsec, fromsym, to, tosec, tosym, to_p);
91265 +#endif
91266 + break;
91267 }
91268 fprintf(stderr, "\n");
91269 }
91270 @@ -1683,7 +1698,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
91271 static void check_sec_ref(struct module *mod, const char *modname,
91272 struct elf_info *elf)
91273 {
91274 - int i;
91275 + unsigned int i;
91276 Elf_Shdr *sechdrs = elf->sechdrs;
91277
91278 /* Walk through all sections */
91279 @@ -1781,7 +1796,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
91280 va_end(ap);
91281 }
91282
91283 -void buf_write(struct buffer *buf, const char *s, int len)
91284 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
91285 {
91286 if (buf->size - buf->pos < len) {
91287 buf->size += len + SZ;
91288 @@ -1999,7 +2014,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
91289 if (fstat(fileno(file), &st) < 0)
91290 goto close_write;
91291
91292 - if (st.st_size != b->pos)
91293 + if (st.st_size != (off_t)b->pos)
91294 goto close_write;
91295
91296 tmp = NOFAIL(malloc(b->pos));
91297 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
91298 index 51207e4..f7d603d 100644
91299 --- a/scripts/mod/modpost.h
91300 +++ b/scripts/mod/modpost.h
91301 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
91302
91303 struct buffer {
91304 char *p;
91305 - int pos;
91306 - int size;
91307 + unsigned int pos;
91308 + unsigned int size;
91309 };
91310
91311 void __attribute__((format(printf, 2, 3)))
91312 buf_printf(struct buffer *buf, const char *fmt, ...);
91313
91314 void
91315 -buf_write(struct buffer *buf, const char *s, int len);
91316 +buf_write(struct buffer *buf, const char *s, unsigned int len);
91317
91318 struct module {
91319 struct module *next;
91320 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
91321 index 9dfcd6d..099068e 100644
91322 --- a/scripts/mod/sumversion.c
91323 +++ b/scripts/mod/sumversion.c
91324 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
91325 goto out;
91326 }
91327
91328 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
91329 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
91330 warn("writing sum in %s failed: %s\n",
91331 filename, strerror(errno));
91332 goto out;
91333 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
91334 index acb8650..b8c5f02 100644
91335 --- a/scripts/package/builddeb
91336 +++ b/scripts/package/builddeb
91337 @@ -246,6 +246,7 @@ fi
91338 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
91339 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
91340 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
91341 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
91342 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
91343 mkdir -p "$destdir"
91344 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
91345 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
91346 index 68bb4ef..2f419e1 100644
91347 --- a/scripts/pnmtologo.c
91348 +++ b/scripts/pnmtologo.c
91349 @@ -244,14 +244,14 @@ static void write_header(void)
91350 fprintf(out, " * Linux logo %s\n", logoname);
91351 fputs(" */\n\n", out);
91352 fputs("#include <linux/linux_logo.h>\n\n", out);
91353 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
91354 + fprintf(out, "static unsigned char %s_data[] = {\n",
91355 logoname);
91356 }
91357
91358 static void write_footer(void)
91359 {
91360 fputs("\n};\n\n", out);
91361 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
91362 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
91363 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
91364 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
91365 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
91366 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
91367 fputs("\n};\n\n", out);
91368
91369 /* write logo clut */
91370 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
91371 + fprintf(out, "static unsigned char %s_clut[] = {\n",
91372 logoname);
91373 write_hex_cnt = 0;
91374 for (i = 0; i < logo_clutsize; i++) {
91375 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
91376 index f5eb43d..1814de8 100644
91377 --- a/scripts/sortextable.h
91378 +++ b/scripts/sortextable.h
91379 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
91380 const char *secstrtab;
91381 const char *strtab;
91382 char *extab_image;
91383 - int extab_index = 0;
91384 - int i;
91385 - int idx;
91386 + unsigned int extab_index = 0;
91387 + unsigned int i;
91388 + unsigned int idx;
91389
91390 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
91391 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
91392 diff --git a/security/Kconfig b/security/Kconfig
91393 index e9c6ac7..e6254cf 100644
91394 --- a/security/Kconfig
91395 +++ b/security/Kconfig
91396 @@ -4,6 +4,944 @@
91397
91398 menu "Security options"
91399
91400 +menu "Grsecurity"
91401 +
91402 + config ARCH_TRACK_EXEC_LIMIT
91403 + bool
91404 +
91405 + config PAX_KERNEXEC_PLUGIN
91406 + bool
91407 +
91408 + config PAX_PER_CPU_PGD
91409 + bool
91410 +
91411 + config TASK_SIZE_MAX_SHIFT
91412 + int
91413 + depends on X86_64
91414 + default 47 if !PAX_PER_CPU_PGD
91415 + default 42 if PAX_PER_CPU_PGD
91416 +
91417 + config PAX_ENABLE_PAE
91418 + bool
91419 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
91420 +
91421 + config PAX_USERCOPY_SLABS
91422 + bool
91423 +
91424 +config GRKERNSEC
91425 + bool "Grsecurity"
91426 + select CRYPTO
91427 + select CRYPTO_SHA256
91428 + select PROC_FS
91429 + select STOP_MACHINE
91430 + select TTY
91431 + help
91432 + If you say Y here, you will be able to configure many features
91433 + that will enhance the security of your system. It is highly
91434 + recommended that you say Y here and read through the help
91435 + for each option so that you fully understand the features and
91436 + can evaluate their usefulness for your machine.
91437 +
91438 +choice
91439 + prompt "Configuration Method"
91440 + depends on GRKERNSEC
91441 + default GRKERNSEC_CONFIG_CUSTOM
91442 + help
91443 +
91444 +config GRKERNSEC_CONFIG_AUTO
91445 + bool "Automatic"
91446 + help
91447 + If you choose this configuration method, you'll be able to answer a small
91448 + number of simple questions about how you plan to use this kernel.
91449 + The settings of grsecurity and PaX will be automatically configured for
91450 + the highest commonly-used settings within the provided constraints.
91451 +
91452 + If you require additional configuration, custom changes can still be made
91453 + from the "custom configuration" menu.
91454 +
91455 +config GRKERNSEC_CONFIG_CUSTOM
91456 + bool "Custom"
91457 + help
91458 + If you choose this configuration method, you'll be able to configure all
91459 + grsecurity and PaX settings manually. Via this method, no options are
91460 + automatically enabled.
91461 +
91462 +endchoice
91463 +
91464 +choice
91465 + prompt "Usage Type"
91466 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91467 + default GRKERNSEC_CONFIG_SERVER
91468 + help
91469 +
91470 +config GRKERNSEC_CONFIG_SERVER
91471 + bool "Server"
91472 + help
91473 + Choose this option if you plan to use this kernel on a server.
91474 +
91475 +config GRKERNSEC_CONFIG_DESKTOP
91476 + bool "Desktop"
91477 + help
91478 + Choose this option if you plan to use this kernel on a desktop.
91479 +
91480 +endchoice
91481 +
91482 +choice
91483 + prompt "Virtualization Type"
91484 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
91485 + default GRKERNSEC_CONFIG_VIRT_NONE
91486 + help
91487 +
91488 +config GRKERNSEC_CONFIG_VIRT_NONE
91489 + bool "None"
91490 + help
91491 + Choose this option if this kernel will be run on bare metal.
91492 +
91493 +config GRKERNSEC_CONFIG_VIRT_GUEST
91494 + bool "Guest"
91495 + help
91496 + Choose this option if this kernel will be run as a VM guest.
91497 +
91498 +config GRKERNSEC_CONFIG_VIRT_HOST
91499 + bool "Host"
91500 + help
91501 + Choose this option if this kernel will be run as a VM host.
91502 +
91503 +endchoice
91504 +
91505 +choice
91506 + prompt "Virtualization Hardware"
91507 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91508 + help
91509 +
91510 +config GRKERNSEC_CONFIG_VIRT_EPT
91511 + bool "EPT/RVI Processor Support"
91512 + depends on X86
91513 + help
91514 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
91515 + hardware virtualization. This allows for additional kernel hardening protections
91516 + to operate without additional performance impact.
91517 +
91518 + To see if your Intel processor supports EPT, see:
91519 + http://ark.intel.com/Products/VirtualizationTechnology
91520 + (Most Core i3/5/7 support EPT)
91521 +
91522 + To see if your AMD processor supports RVI, see:
91523 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
91524 +
91525 +config GRKERNSEC_CONFIG_VIRT_SOFT
91526 + bool "First-gen/No Hardware Virtualization"
91527 + help
91528 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
91529 + support hardware virtualization or doesn't support the EPT/RVI extensions.
91530 +
91531 +endchoice
91532 +
91533 +choice
91534 + prompt "Virtualization Software"
91535 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91536 + help
91537 +
91538 +config GRKERNSEC_CONFIG_VIRT_XEN
91539 + bool "Xen"
91540 + help
91541 + Choose this option if this kernel is running as a Xen guest or host.
91542 +
91543 +config GRKERNSEC_CONFIG_VIRT_VMWARE
91544 + bool "VMWare"
91545 + help
91546 + Choose this option if this kernel is running as a VMWare guest or host.
91547 +
91548 +config GRKERNSEC_CONFIG_VIRT_KVM
91549 + bool "KVM"
91550 + help
91551 + Choose this option if this kernel is running as a KVM guest or host.
91552 +
91553 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
91554 + bool "VirtualBox"
91555 + help
91556 + Choose this option if this kernel is running as a VirtualBox guest or host.
91557 +
91558 +endchoice
91559 +
91560 +choice
91561 + prompt "Required Priorities"
91562 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91563 + default GRKERNSEC_CONFIG_PRIORITY_PERF
91564 + help
91565 +
91566 +config GRKERNSEC_CONFIG_PRIORITY_PERF
91567 + bool "Performance"
91568 + help
91569 + Choose this option if performance is of highest priority for this deployment
91570 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
91571 + clearing of structures intended for userland, and freed memory sanitizing will
91572 + be disabled.
91573 +
91574 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
91575 + bool "Security"
91576 + help
91577 + Choose this option if security is of highest priority for this deployment of
91578 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
91579 + for userland, and freed memory sanitizing will be enabled for this kernel.
91580 + In a worst-case scenario, these features can introduce a 20% performance hit
91581 + (UDEREF on x64 contributing half of this hit).
91582 +
91583 +endchoice
91584 +
91585 +menu "Default Special Groups"
91586 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91587 +
91588 +config GRKERNSEC_PROC_GID
91589 + int "GID exempted from /proc restrictions"
91590 + default 1001
91591 + help
91592 + Setting this GID determines which group will be exempted from
91593 + grsecurity's /proc restrictions, allowing users of the specified
91594 + group to view network statistics and the existence of other users'
91595 + processes on the system. This GID may also be chosen at boot time
91596 + via "grsec_proc_gid=" on the kernel commandline.
91597 +
91598 +config GRKERNSEC_TPE_UNTRUSTED_GID
91599 + int "GID for TPE-untrusted users"
91600 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
91601 + default 1005
91602 + help
91603 + Setting this GID determines which group untrusted users should
91604 + be added to. These users will be placed under grsecurity's Trusted Path
91605 + Execution mechanism, preventing them from executing their own binaries.
91606 + The users will only be able to execute binaries in directories owned and
91607 + writable only by the root user. If the sysctl option is enabled, a sysctl
91608 + option with name "tpe_gid" is created.
91609 +
91610 +config GRKERNSEC_TPE_TRUSTED_GID
91611 + int "GID for TPE-trusted users"
91612 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
91613 + default 1005
91614 + help
91615 + Setting this GID determines what group TPE restrictions will be
91616 + *disabled* for. If the sysctl option is enabled, a sysctl option
91617 + with name "tpe_gid" is created.
91618 +
91619 +config GRKERNSEC_SYMLINKOWN_GID
91620 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
91621 + depends on GRKERNSEC_CONFIG_SERVER
91622 + default 1006
91623 + help
91624 + Setting this GID determines what group kernel-enforced
91625 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
91626 + is enabled, a sysctl option with name "symlinkown_gid" is created.
91627 +
91628 +
91629 +endmenu
91630 +
91631 +menu "Customize Configuration"
91632 +depends on GRKERNSEC
91633 +
91634 +menu "PaX"
91635 +
91636 +config PAX
91637 + bool "Enable various PaX features"
91638 + default y if GRKERNSEC_CONFIG_AUTO
91639 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
91640 + help
91641 + This allows you to enable various PaX features. PaX adds
91642 + intrusion prevention mechanisms to the kernel that reduce
91643 + the risks posed by exploitable memory corruption bugs.
91644 +
91645 +menu "PaX Control"
91646 + depends on PAX
91647 +
91648 +config PAX_SOFTMODE
91649 + bool 'Support soft mode'
91650 + help
91651 + Enabling this option will allow you to run PaX in soft mode, that
91652 + is, PaX features will not be enforced by default, only on executables
91653 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
91654 + support as they are the only way to mark executables for soft mode use.
91655 +
91656 + Soft mode can be activated by using the "pax_softmode=1" kernel command
91657 + line option on boot. Furthermore you can control various PaX features
91658 + at runtime via the entries in /proc/sys/kernel/pax.
91659 +
91660 +config PAX_EI_PAX
91661 + bool 'Use legacy ELF header marking'
91662 + default y if GRKERNSEC_CONFIG_AUTO
91663 + help
91664 + Enabling this option will allow you to control PaX features on
91665 + a per executable basis via the 'chpax' utility available at
91666 + http://pax.grsecurity.net/. The control flags will be read from
91667 + an otherwise reserved part of the ELF header. This marking has
91668 + numerous drawbacks (no support for soft-mode, toolchain does not
91669 + know about the non-standard use of the ELF header) therefore it
91670 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
91671 + support.
91672 +
91673 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
91674 + support as well, they will override the legacy EI_PAX marks.
91675 +
91676 + If you enable none of the marking options then all applications
91677 + will run with PaX enabled on them by default.
91678 +
91679 +config PAX_PT_PAX_FLAGS
91680 + bool 'Use ELF program header marking'
91681 + default y if GRKERNSEC_CONFIG_AUTO
91682 + help
91683 + Enabling this option will allow you to control PaX features on
91684 + a per executable basis via the 'paxctl' utility available at
91685 + http://pax.grsecurity.net/. The control flags will be read from
91686 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
91687 + has the benefits of supporting both soft mode and being fully
91688 + integrated into the toolchain (the binutils patch is available
91689 + from http://pax.grsecurity.net).
91690 +
91691 + Note that if you enable the legacy EI_PAX marking support as well,
91692 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
91693 +
91694 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91695 + must make sure that the marks are the same if a binary has both marks.
91696 +
91697 + If you enable none of the marking options then all applications
91698 + will run with PaX enabled on them by default.
91699 +
91700 +config PAX_XATTR_PAX_FLAGS
91701 + bool 'Use filesystem extended attributes marking'
91702 + default y if GRKERNSEC_CONFIG_AUTO
91703 + select CIFS_XATTR if CIFS
91704 + select EXT2_FS_XATTR if EXT2_FS
91705 + select EXT3_FS_XATTR if EXT3_FS
91706 + select EXT4_FS_XATTR if EXT4_FS
91707 + select JFFS2_FS_XATTR if JFFS2_FS
91708 + select REISERFS_FS_XATTR if REISERFS_FS
91709 + select SQUASHFS_XATTR if SQUASHFS
91710 + select TMPFS_XATTR if TMPFS
91711 + select UBIFS_FS_XATTR if UBIFS_FS
91712 + help
91713 + Enabling this option will allow you to control PaX features on
91714 + a per executable basis via the 'setfattr' utility. The control
91715 + flags will be read from the user.pax.flags extended attribute of
91716 + the file. This marking has the benefit of supporting binary-only
91717 + applications that self-check themselves (e.g., skype) and would
91718 + not tolerate chpax/paxctl changes. The main drawback is that
91719 + extended attributes are not supported by some filesystems (e.g.,
91720 + isofs, udf, vfat) so copying files through such filesystems will
91721 + lose the extended attributes and these PaX markings.
91722 +
91723 + Note that if you enable the legacy EI_PAX marking support as well,
91724 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
91725 +
91726 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91727 + must make sure that the marks are the same if a binary has both marks.
91728 +
91729 + If you enable none of the marking options then all applications
91730 + will run with PaX enabled on them by default.
91731 +
91732 +choice
91733 + prompt 'MAC system integration'
91734 + default PAX_HAVE_ACL_FLAGS
91735 + help
91736 + Mandatory Access Control systems have the option of controlling
91737 + PaX flags on a per executable basis, choose the method supported
91738 + by your particular system.
91739 +
91740 + - "none": if your MAC system does not interact with PaX,
91741 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
91742 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
91743 +
91744 + NOTE: this option is for developers/integrators only.
91745 +
91746 + config PAX_NO_ACL_FLAGS
91747 + bool 'none'
91748 +
91749 + config PAX_HAVE_ACL_FLAGS
91750 + bool 'direct'
91751 +
91752 + config PAX_HOOK_ACL_FLAGS
91753 + bool 'hook'
91754 +endchoice
91755 +
91756 +endmenu
91757 +
91758 +menu "Non-executable pages"
91759 + depends on PAX
91760 +
91761 +config PAX_NOEXEC
91762 + bool "Enforce non-executable pages"
91763 + default y if GRKERNSEC_CONFIG_AUTO
91764 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
91765 + help
91766 + By design some architectures do not allow for protecting memory
91767 + pages against execution or even if they do, Linux does not make
91768 + use of this feature. In practice this means that if a page is
91769 + readable (such as the stack or heap) it is also executable.
91770 +
91771 + There is a well known exploit technique that makes use of this
91772 + fact and a common programming mistake where an attacker can
91773 + introduce code of his choice somewhere in the attacked program's
91774 + memory (typically the stack or the heap) and then execute it.
91775 +
91776 + If the attacked program was running with different (typically
91777 + higher) privileges than that of the attacker, then he can elevate
91778 + his own privilege level (e.g. get a root shell, write to files for
91779 + which he does not have write access to, etc).
91780 +
91781 + Enabling this option will let you choose from various features
91782 + that prevent the injection and execution of 'foreign' code in
91783 + a program.
91784 +
91785 + This will also break programs that rely on the old behaviour and
91786 + expect that dynamically allocated memory via the malloc() family
91787 + of functions is executable (which it is not). Notable examples
91788 + are the XFree86 4.x server, the java runtime and wine.
91789 +
91790 +config PAX_PAGEEXEC
91791 + bool "Paging based non-executable pages"
91792 + default y if GRKERNSEC_CONFIG_AUTO
91793 + 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)
91794 + select S390_SWITCH_AMODE if S390
91795 + select S390_EXEC_PROTECT if S390
91796 + select ARCH_TRACK_EXEC_LIMIT if X86_32
91797 + help
91798 + This implementation is based on the paging feature of the CPU.
91799 + On i386 without hardware non-executable bit support there is a
91800 + variable but usually low performance impact, however on Intel's
91801 + P4 core based CPUs it is very high so you should not enable this
91802 + for kernels meant to be used on such CPUs.
91803 +
91804 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
91805 + with hardware non-executable bit support there is no performance
91806 + impact, on ppc the impact is negligible.
91807 +
91808 + Note that several architectures require various emulations due to
91809 + badly designed userland ABIs, this will cause a performance impact
91810 + but will disappear as soon as userland is fixed. For example, ppc
91811 + userland MUST have been built with secure-plt by a recent toolchain.
91812 +
91813 +config PAX_SEGMEXEC
91814 + bool "Segmentation based non-executable pages"
91815 + default y if GRKERNSEC_CONFIG_AUTO
91816 + depends on PAX_NOEXEC && X86_32
91817 + help
91818 + This implementation is based on the segmentation feature of the
91819 + CPU and has a very small performance impact, however applications
91820 + will be limited to a 1.5 GB address space instead of the normal
91821 + 3 GB.
91822 +
91823 +config PAX_EMUTRAMP
91824 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
91825 + default y if PARISC
91826 + help
91827 + There are some programs and libraries that for one reason or
91828 + another attempt to execute special small code snippets from
91829 + non-executable memory pages. Most notable examples are the
91830 + signal handler return code generated by the kernel itself and
91831 + the GCC trampolines.
91832 +
91833 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
91834 + such programs will no longer work under your kernel.
91835 +
91836 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
91837 + utilities to enable trampoline emulation for the affected programs
91838 + yet still have the protection provided by the non-executable pages.
91839 +
91840 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
91841 + your system will not even boot.
91842 +
91843 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
91844 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
91845 + for the affected files.
91846 +
91847 + NOTE: enabling this feature *may* open up a loophole in the
91848 + protection provided by non-executable pages that an attacker
91849 + could abuse. Therefore the best solution is to not have any
91850 + files on your system that would require this option. This can
91851 + be achieved by not using libc5 (which relies on the kernel
91852 + signal handler return code) and not using or rewriting programs
91853 + that make use of the nested function implementation of GCC.
91854 + Skilled users can just fix GCC itself so that it implements
91855 + nested function calls in a way that does not interfere with PaX.
91856 +
91857 +config PAX_EMUSIGRT
91858 + bool "Automatically emulate sigreturn trampolines"
91859 + depends on PAX_EMUTRAMP && PARISC
91860 + default y
91861 + help
91862 + Enabling this option will have the kernel automatically detect
91863 + and emulate signal return trampolines executing on the stack
91864 + that would otherwise lead to task termination.
91865 +
91866 + This solution is intended as a temporary one for users with
91867 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
91868 + Modula-3 runtime, etc) or executables linked to such, basically
91869 + everything that does not specify its own SA_RESTORER function in
91870 + normal executable memory like glibc 2.1+ does.
91871 +
91872 + On parisc you MUST enable this option, otherwise your system will
91873 + not even boot.
91874 +
91875 + NOTE: this feature cannot be disabled on a per executable basis
91876 + and since it *does* open up a loophole in the protection provided
91877 + by non-executable pages, the best solution is to not have any
91878 + files on your system that would require this option.
91879 +
91880 +config PAX_MPROTECT
91881 + bool "Restrict mprotect()"
91882 + default y if GRKERNSEC_CONFIG_AUTO
91883 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
91884 + help
91885 + Enabling this option will prevent programs from
91886 + - changing the executable status of memory pages that were
91887 + not originally created as executable,
91888 + - making read-only executable pages writable again,
91889 + - creating executable pages from anonymous memory,
91890 + - making read-only-after-relocations (RELRO) data pages writable again.
91891 +
91892 + You should say Y here to complete the protection provided by
91893 + the enforcement of non-executable pages.
91894 +
91895 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
91896 + this feature on a per file basis.
91897 +
91898 +config PAX_MPROTECT_COMPAT
91899 + bool "Use legacy/compat protection demoting (read help)"
91900 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
91901 + depends on PAX_MPROTECT
91902 + help
91903 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
91904 + by sending the proper error code to the application. For some broken
91905 + userland, this can cause problems with Python or other applications. The
91906 + current implementation however allows for applications like clamav to
91907 + detect if JIT compilation/execution is allowed and to fall back gracefully
91908 + to an interpreter-based mode if it does not. While we encourage everyone
91909 + to use the current implementation as-is and push upstream to fix broken
91910 + userland (note that the RWX logging option can assist with this), in some
91911 + environments this may not be possible. Having to disable MPROTECT
91912 + completely on certain binaries reduces the security benefit of PaX,
91913 + so this option is provided for those environments to revert to the old
91914 + behavior.
91915 +
91916 +config PAX_ELFRELOCS
91917 + bool "Allow ELF text relocations (read help)"
91918 + depends on PAX_MPROTECT
91919 + default n
91920 + help
91921 + Non-executable pages and mprotect() restrictions are effective
91922 + in preventing the introduction of new executable code into an
91923 + attacked task's address space. There remain only two venues
91924 + for this kind of attack: if the attacker can execute already
91925 + existing code in the attacked task then he can either have it
91926 + create and mmap() a file containing his code or have it mmap()
91927 + an already existing ELF library that does not have position
91928 + independent code in it and use mprotect() on it to make it
91929 + writable and copy his code there. While protecting against
91930 + the former approach is beyond PaX, the latter can be prevented
91931 + by having only PIC ELF libraries on one's system (which do not
91932 + need to relocate their code). If you are sure this is your case,
91933 + as is the case with all modern Linux distributions, then leave
91934 + this option disabled. You should say 'n' here.
91935 +
91936 +config PAX_ETEXECRELOCS
91937 + bool "Allow ELF ET_EXEC text relocations"
91938 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
91939 + select PAX_ELFRELOCS
91940 + default y
91941 + help
91942 + On some architectures there are incorrectly created applications
91943 + that require text relocations and would not work without enabling
91944 + this option. If you are an alpha, ia64 or parisc user, you should
91945 + enable this option and disable it once you have made sure that
91946 + none of your applications need it.
91947 +
91948 +config PAX_EMUPLT
91949 + bool "Automatically emulate ELF PLT"
91950 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
91951 + default y
91952 + help
91953 + Enabling this option will have the kernel automatically detect
91954 + and emulate the Procedure Linkage Table entries in ELF files.
91955 + On some architectures such entries are in writable memory, and
91956 + become non-executable leading to task termination. Therefore
91957 + it is mandatory that you enable this option on alpha, parisc,
91958 + sparc and sparc64, otherwise your system would not even boot.
91959 +
91960 + NOTE: this feature *does* open up a loophole in the protection
91961 + provided by the non-executable pages, therefore the proper
91962 + solution is to modify the toolchain to produce a PLT that does
91963 + not need to be writable.
91964 +
91965 +config PAX_DLRESOLVE
91966 + bool 'Emulate old glibc resolver stub'
91967 + depends on PAX_EMUPLT && SPARC
91968 + default n
91969 + help
91970 + This option is needed if userland has an old glibc (before 2.4)
91971 + that puts a 'save' instruction into the runtime generated resolver
91972 + stub that needs special emulation.
91973 +
91974 +config PAX_KERNEXEC
91975 + bool "Enforce non-executable kernel pages"
91976 + 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))
91977 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
91978 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
91979 + select PAX_KERNEXEC_PLUGIN if X86_64
91980 + help
91981 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
91982 + that is, enabling this option will make it harder to inject
91983 + and execute 'foreign' code in kernel memory itself.
91984 +
91985 +choice
91986 + prompt "Return Address Instrumentation Method"
91987 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
91988 + depends on PAX_KERNEXEC_PLUGIN
91989 + help
91990 + Select the method used to instrument function pointer dereferences.
91991 + Note that binary modules cannot be instrumented by this approach.
91992 +
91993 + Note that the implementation requires a gcc with plugin support,
91994 + i.e., gcc 4.5 or newer. You may need to install the supporting
91995 + headers explicitly in addition to the normal gcc package.
91996 +
91997 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
91998 + bool "bts"
91999 + help
92000 + This method is compatible with binary only modules but has
92001 + a higher runtime overhead.
92002 +
92003 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
92004 + bool "or"
92005 + depends on !PARAVIRT
92006 + help
92007 + This method is incompatible with binary only modules but has
92008 + a lower runtime overhead.
92009 +endchoice
92010 +
92011 +config PAX_KERNEXEC_PLUGIN_METHOD
92012 + string
92013 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
92014 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
92015 + default ""
92016 +
92017 +config PAX_KERNEXEC_MODULE_TEXT
92018 + int "Minimum amount of memory reserved for module code"
92019 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
92020 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92021 + depends on PAX_KERNEXEC && X86_32 && MODULES
92022 + help
92023 + Due to implementation details the kernel must reserve a fixed
92024 + amount of memory for module code at compile time that cannot be
92025 + changed at runtime. Here you can specify the minimum amount
92026 + in MB that will be reserved. Due to the same implementation
92027 + details this size will always be rounded up to the next 2/4 MB
92028 + boundary (depends on PAE) so the actually available memory for
92029 + module code will usually be more than this minimum.
92030 +
92031 + The default 4 MB should be enough for most users but if you have
92032 + an excessive number of modules (e.g., most distribution configs
92033 + compile many drivers as modules) or use huge modules such as
92034 + nvidia's kernel driver, you will need to adjust this amount.
92035 + A good rule of thumb is to look at your currently loaded kernel
92036 + modules and add up their sizes.
92037 +
92038 +endmenu
92039 +
92040 +menu "Address Space Layout Randomization"
92041 + depends on PAX
92042 +
92043 +config PAX_ASLR
92044 + bool "Address Space Layout Randomization"
92045 + default y if GRKERNSEC_CONFIG_AUTO
92046 + help
92047 + Many if not most exploit techniques rely on the knowledge of
92048 + certain addresses in the attacked program. The following options
92049 + will allow the kernel to apply a certain amount of randomization
92050 + to specific parts of the program thereby forcing an attacker to
92051 + guess them in most cases. Any failed guess will most likely crash
92052 + the attacked program which allows the kernel to detect such attempts
92053 + and react on them. PaX itself provides no reaction mechanisms,
92054 + instead it is strongly encouraged that you make use of Nergal's
92055 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
92056 + (http://www.grsecurity.net/) built-in crash detection features or
92057 + develop one yourself.
92058 +
92059 + By saying Y here you can choose to randomize the following areas:
92060 + - top of the task's kernel stack
92061 + - top of the task's userland stack
92062 + - base address for mmap() requests that do not specify one
92063 + (this includes all libraries)
92064 + - base address of the main executable
92065 +
92066 + It is strongly recommended to say Y here as address space layout
92067 + randomization has negligible impact on performance yet it provides
92068 + a very effective protection.
92069 +
92070 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92071 + this feature on a per file basis.
92072 +
92073 +config PAX_RANDKSTACK
92074 + bool "Randomize kernel stack base"
92075 + default y if GRKERNSEC_CONFIG_AUTO
92076 + depends on X86_TSC && X86
92077 + help
92078 + By saying Y here the kernel will randomize every task's kernel
92079 + stack on every system call. This will not only force an attacker
92080 + to guess it but also prevent him from making use of possible
92081 + leaked information about it.
92082 +
92083 + Since the kernel stack is a rather scarce resource, randomization
92084 + may cause unexpected stack overflows, therefore you should very
92085 + carefully test your system. Note that once enabled in the kernel
92086 + configuration, this feature cannot be disabled on a per file basis.
92087 +
92088 +config PAX_RANDUSTACK
92089 + bool "Randomize user stack base"
92090 + default y if GRKERNSEC_CONFIG_AUTO
92091 + depends on PAX_ASLR
92092 + help
92093 + By saying Y here the kernel will randomize every task's userland
92094 + stack. The randomization is done in two steps where the second
92095 + one may apply a big amount of shift to the top of the stack and
92096 + cause problems for programs that want to use lots of memory (more
92097 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
92098 + For this reason the second step can be controlled by 'chpax' or
92099 + 'paxctl' on a per file basis.
92100 +
92101 +config PAX_RANDMMAP
92102 + bool "Randomize mmap() base"
92103 + default y if GRKERNSEC_CONFIG_AUTO
92104 + depends on PAX_ASLR
92105 + help
92106 + By saying Y here the kernel will use a randomized base address for
92107 + mmap() requests that do not specify one themselves. As a result
92108 + all dynamically loaded libraries will appear at random addresses
92109 + and therefore be harder to exploit by a technique where an attacker
92110 + attempts to execute library code for his purposes (e.g. spawn a
92111 + shell from an exploited program that is running at an elevated
92112 + privilege level).
92113 +
92114 + Furthermore, if a program is relinked as a dynamic ELF file, its
92115 + base address will be randomized as well, completing the full
92116 + randomization of the address space layout. Attacking such programs
92117 + becomes a guess game. You can find an example of doing this at
92118 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
92119 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
92120 +
92121 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
92122 + feature on a per file basis.
92123 +
92124 +endmenu
92125 +
92126 +menu "Miscellaneous hardening features"
92127 +
92128 +config PAX_MEMORY_SANITIZE
92129 + bool "Sanitize all freed memory"
92130 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92131 + depends on !HIBERNATION
92132 + help
92133 + By saying Y here the kernel will erase memory pages as soon as they
92134 + are freed. This in turn reduces the lifetime of data stored in the
92135 + pages, making it less likely that sensitive information such as
92136 + passwords, cryptographic secrets, etc stay in memory for too long.
92137 +
92138 + This is especially useful for programs whose runtime is short, long
92139 + lived processes and the kernel itself benefit from this as long as
92140 + they operate on whole memory pages and ensure timely freeing of pages
92141 + that may hold sensitive information.
92142 +
92143 + The tradeoff is performance impact, on a single CPU system kernel
92144 + compilation sees a 3% slowdown, other systems and workloads may vary
92145 + and you are advised to test this feature on your expected workload
92146 + before deploying it.
92147 +
92148 + Note that this feature does not protect data stored in live pages,
92149 + e.g., process memory swapped to disk may stay there for a long time.
92150 +
92151 +config PAX_MEMORY_STACKLEAK
92152 + bool "Sanitize kernel stack"
92153 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92154 + depends on X86
92155 + help
92156 + By saying Y here the kernel will erase the kernel stack before it
92157 + returns from a system call. This in turn reduces the information
92158 + that a kernel stack leak bug can reveal.
92159 +
92160 + Note that such a bug can still leak information that was put on
92161 + the stack by the current system call (the one eventually triggering
92162 + the bug) but traces of earlier system calls on the kernel stack
92163 + cannot leak anymore.
92164 +
92165 + The tradeoff is performance impact: on a single CPU system kernel
92166 + compilation sees a 1% slowdown, other systems and workloads may vary
92167 + and you are advised to test this feature on your expected workload
92168 + before deploying it.
92169 +
92170 + Note that the full feature requires a gcc with plugin support,
92171 + i.e., gcc 4.5 or newer. You may need to install the supporting
92172 + headers explicitly in addition to the normal gcc package. Using
92173 + older gcc versions means that functions with large enough stack
92174 + frames may leave uninitialized memory behind that may be exposed
92175 + to a later syscall leaking the stack.
92176 +
92177 +config PAX_MEMORY_STRUCTLEAK
92178 + bool "Forcibly initialize local variables copied to userland"
92179 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92180 + help
92181 + By saying Y here the kernel will zero initialize some local
92182 + variables that are going to be copied to userland. This in
92183 + turn prevents unintended information leakage from the kernel
92184 + stack should later code forget to explicitly set all parts of
92185 + the copied variable.
92186 +
92187 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
92188 + at a much smaller coverage.
92189 +
92190 + Note that the implementation requires a gcc with plugin support,
92191 + i.e., gcc 4.5 or newer. You may need to install the supporting
92192 + headers explicitly in addition to the normal gcc package.
92193 +
92194 +config PAX_MEMORY_UDEREF
92195 + bool "Prevent invalid userland pointer dereference"
92196 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
92197 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
92198 + select PAX_PER_CPU_PGD if X86_64
92199 + help
92200 + By saying Y here the kernel will be prevented from dereferencing
92201 + userland pointers in contexts where the kernel expects only kernel
92202 + pointers. This is both a useful runtime debugging feature and a
92203 + security measure that prevents exploiting a class of kernel bugs.
92204 +
92205 + The tradeoff is that some virtualization solutions may experience
92206 + a huge slowdown and therefore you should not enable this feature
92207 + for kernels meant to run in such environments. Whether a given VM
92208 + solution is affected or not is best determined by simply trying it
92209 + out, the performance impact will be obvious right on boot as this
92210 + mechanism engages from very early on. A good rule of thumb is that
92211 + VMs running on CPUs without hardware virtualization support (i.e.,
92212 + the majority of IA-32 CPUs) will likely experience the slowdown.
92213 +
92214 +config PAX_REFCOUNT
92215 + bool "Prevent various kernel object reference counter overflows"
92216 + default y if GRKERNSEC_CONFIG_AUTO
92217 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
92218 + help
92219 + By saying Y here the kernel will detect and prevent overflowing
92220 + various (but not all) kinds of object reference counters. Such
92221 + overflows can normally occur due to bugs only and are often, if
92222 + not always, exploitable.
92223 +
92224 + The tradeoff is that data structures protected by an overflowed
92225 + refcount will never be freed and therefore will leak memory. Note
92226 + that this leak also happens even without this protection but in
92227 + that case the overflow can eventually trigger the freeing of the
92228 + data structure while it is still being used elsewhere, resulting
92229 + in the exploitable situation that this feature prevents.
92230 +
92231 + Since this has a negligible performance impact, you should enable
92232 + this feature.
92233 +
92234 +config PAX_CONSTIFY_PLUGIN
92235 + bool "Automatically constify eligible structures"
92236 + default y
92237 + depends on !UML && PAX_KERNEXEC
92238 + help
92239 + By saying Y here the compiler will automatically constify a class
92240 + of types that contain only function pointers. This reduces the
92241 + kernel's attack surface and also produces a better memory layout.
92242 +
92243 + Note that the implementation requires a gcc with plugin support,
92244 + i.e., gcc 4.5 or newer. You may need to install the supporting
92245 + headers explicitly in addition to the normal gcc package.
92246 +
92247 + Note that if some code really has to modify constified variables
92248 + then the source code will have to be patched to allow it. Examples
92249 + can be found in PaX itself (the no_const attribute) and for some
92250 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
92251 +
92252 +config PAX_USERCOPY
92253 + bool "Harden heap object copies between kernel and userland"
92254 + default y if GRKERNSEC_CONFIG_AUTO
92255 + depends on ARM || IA64 || PPC || SPARC || X86
92256 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
92257 + select PAX_USERCOPY_SLABS
92258 + help
92259 + By saying Y here the kernel will enforce the size of heap objects
92260 + when they are copied in either direction between the kernel and
92261 + userland, even if only a part of the heap object is copied.
92262 +
92263 + Specifically, this checking prevents information leaking from the
92264 + kernel heap during kernel to userland copies (if the kernel heap
92265 + object is otherwise fully initialized) and prevents kernel heap
92266 + overflows during userland to kernel copies.
92267 +
92268 + Note that the current implementation provides the strictest bounds
92269 + checks for the SLUB allocator.
92270 +
92271 + Enabling this option also enables per-slab cache protection against
92272 + data in a given cache being copied into/out of via userland
92273 + accessors. Though the whitelist of regions will be reduced over
92274 + time, it notably protects important data structures like task structs.
92275 +
92276 + If frame pointers are enabled on x86, this option will also restrict
92277 + copies into and out of the kernel stack to local variables within a
92278 + single frame.
92279 +
92280 + Since this has a negligible performance impact, you should enable
92281 + this feature.
92282 +
92283 +config PAX_USERCOPY_DEBUG
92284 + bool
92285 + depends on X86 && PAX_USERCOPY
92286 + default n
92287 +
92288 +config PAX_SIZE_OVERFLOW
92289 + bool "Prevent various integer overflows in function size parameters"
92290 + default y if GRKERNSEC_CONFIG_AUTO
92291 + depends on X86
92292 + help
92293 + By saying Y here the kernel recomputes expressions of function
92294 + arguments marked by a size_overflow attribute with double integer
92295 + precision (DImode/TImode for 32/64 bit integer types).
92296 +
92297 + The recomputed argument is checked against TYPE_MAX and an event
92298 + is logged on overflow and the triggering process is killed.
92299 +
92300 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
92301 +
92302 + Note that the implementation requires a gcc with plugin support,
92303 + i.e., gcc 4.5 or newer. You may need to install the supporting
92304 + headers explicitly in addition to the normal gcc package.
92305 +
92306 +config PAX_LATENT_ENTROPY
92307 + bool "Generate some entropy during boot"
92308 + default y if GRKERNSEC_CONFIG_AUTO
92309 + help
92310 + By saying Y here the kernel will instrument early boot code to
92311 + extract some entropy from both original and artificially created
92312 + program state. This will help especially embedded systems where
92313 + there is little 'natural' source of entropy normally. The cost
92314 + is some slowdown of the boot process.
92315 +
92316 + When pax_extra_latent_entropy is passed on the kernel command line,
92317 + entropy will be extracted from up to the first 4GB of RAM while the
92318 + runtime memory allocator is being initialized. This costs even more
92319 + slowdown of the boot process.
92320 +
92321 + Note that the implementation requires a gcc with plugin support,
92322 + i.e., gcc 4.5 or newer. You may need to install the supporting
92323 + headers explicitly in addition to the normal gcc package.
92324 +
92325 + Note that entropy extracted this way is not cryptographically
92326 + secure!
92327 +
92328 +endmenu
92329 +
92330 +endmenu
92331 +
92332 +source grsecurity/Kconfig
92333 +
92334 +endmenu
92335 +
92336 +endmenu
92337 +
92338 source security/keys/Kconfig
92339
92340 config SECURITY_DMESG_RESTRICT
92341 @@ -103,7 +1041,7 @@ config INTEL_TXT
92342 config LSM_MMAP_MIN_ADDR
92343 int "Low address space for LSM to protect from user allocation"
92344 depends on SECURITY && SECURITY_SELINUX
92345 - default 32768 if ARM
92346 + default 32768 if ALPHA || ARM || PARISC || SPARC32
92347 default 65536
92348 help
92349 This is the portion of low virtual memory which should be protected
92350 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
92351 index b21830e..a7d1a17 100644
92352 --- a/security/apparmor/lsm.c
92353 +++ b/security/apparmor/lsm.c
92354 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
92355 return error;
92356 }
92357
92358 -static struct security_operations apparmor_ops = {
92359 +static struct security_operations apparmor_ops __read_only = {
92360 .name = "apparmor",
92361
92362 .ptrace_access_check = apparmor_ptrace_access_check,
92363 diff --git a/security/commoncap.c b/security/commoncap.c
92364 index c44b6fe..932df30 100644
92365 --- a/security/commoncap.c
92366 +++ b/security/commoncap.c
92367 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
92368 return 0;
92369 }
92370
92371 +/* returns:
92372 + 1 for suid privilege
92373 + 2 for sgid privilege
92374 + 3 for fscap privilege
92375 +*/
92376 +int is_privileged_binary(const struct dentry *dentry)
92377 +{
92378 + struct cpu_vfs_cap_data capdata;
92379 + struct inode *inode = dentry->d_inode;
92380 +
92381 + if (!inode || S_ISDIR(inode->i_mode))
92382 + return 0;
92383 +
92384 + if (inode->i_mode & S_ISUID)
92385 + return 1;
92386 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
92387 + return 2;
92388 +
92389 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
92390 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
92391 + return 3;
92392 + }
92393 +
92394 + return 0;
92395 +}
92396 +
92397 /*
92398 * Attempt to get the on-exec apply capability sets for an executable file from
92399 * its xattrs and, if present, apply them to the proposed credentials being
92400 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
92401 const struct cred *cred = current_cred();
92402 kuid_t root_uid = make_kuid(cred->user_ns, 0);
92403
92404 + if (gr_acl_enable_at_secure())
92405 + return 1;
92406 +
92407 if (!uid_eq(cred->uid, root_uid)) {
92408 if (bprm->cap_effective)
92409 return 1;
92410 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
92411 index a41c9c1..83da6dd 100644
92412 --- a/security/integrity/ima/ima.h
92413 +++ b/security/integrity/ima/ima.h
92414 @@ -97,8 +97,8 @@ int ima_init_crypto(void);
92415 extern spinlock_t ima_queue_lock;
92416
92417 struct ima_h_table {
92418 - atomic_long_t len; /* number of stored measurements in the list */
92419 - atomic_long_t violations;
92420 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
92421 + atomic_long_unchecked_t violations;
92422 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
92423 };
92424 extern struct ima_h_table ima_htable;
92425 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
92426 index 1c03e8f1..398a941 100644
92427 --- a/security/integrity/ima/ima_api.c
92428 +++ b/security/integrity/ima/ima_api.c
92429 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
92430 int result;
92431
92432 /* can overflow, only indicator */
92433 - atomic_long_inc(&ima_htable.violations);
92434 + atomic_long_inc_unchecked(&ima_htable.violations);
92435
92436 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
92437 if (!entry) {
92438 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
92439 index 38477c9..87a60c7 100644
92440 --- a/security/integrity/ima/ima_fs.c
92441 +++ b/security/integrity/ima/ima_fs.c
92442 @@ -28,12 +28,12 @@
92443 static int valid_policy = 1;
92444 #define TMPBUFLEN 12
92445 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
92446 - loff_t *ppos, atomic_long_t *val)
92447 + loff_t *ppos, atomic_long_unchecked_t *val)
92448 {
92449 char tmpbuf[TMPBUFLEN];
92450 ssize_t len;
92451
92452 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
92453 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
92454 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
92455 }
92456
92457 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
92458 index ff63fe0..809cd96 100644
92459 --- a/security/integrity/ima/ima_queue.c
92460 +++ b/security/integrity/ima/ima_queue.c
92461 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
92462 INIT_LIST_HEAD(&qe->later);
92463 list_add_tail_rcu(&qe->later, &ima_measurements);
92464
92465 - atomic_long_inc(&ima_htable.len);
92466 + atomic_long_inc_unchecked(&ima_htable.len);
92467 key = ima_hash_key(entry->digest);
92468 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
92469 return 0;
92470 diff --git a/security/keys/compat.c b/security/keys/compat.c
92471 index d65fa7f..cbfe366 100644
92472 --- a/security/keys/compat.c
92473 +++ b/security/keys/compat.c
92474 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
92475 if (ret == 0)
92476 goto no_payload_free;
92477
92478 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92479 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92480 err:
92481 if (iov != iovstack)
92482 kfree(iov);
92483 diff --git a/security/keys/internal.h b/security/keys/internal.h
92484 index 8bbefc3..299d03f 100644
92485 --- a/security/keys/internal.h
92486 +++ b/security/keys/internal.h
92487 @@ -240,7 +240,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
92488 extern long keyctl_invalidate_key(key_serial_t);
92489
92490 extern long keyctl_instantiate_key_common(key_serial_t,
92491 - const struct iovec *,
92492 + const struct iovec __user *,
92493 unsigned, size_t, key_serial_t);
92494
92495 /*
92496 diff --git a/security/keys/key.c b/security/keys/key.c
92497 index 8fb7c7b..ba3610d 100644
92498 --- a/security/keys/key.c
92499 +++ b/security/keys/key.c
92500 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
92501
92502 atomic_set(&key->usage, 1);
92503 init_rwsem(&key->sem);
92504 - lockdep_set_class(&key->sem, &type->lock_class);
92505 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
92506 key->type = type;
92507 key->user = user;
92508 key->quotalen = quotalen;
92509 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
92510 struct key_type *p;
92511 int ret;
92512
92513 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
92514 + pax_open_kernel();
92515 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
92516 + pax_close_kernel();
92517
92518 ret = -EEXIST;
92519 down_write(&key_types_sem);
92520 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
92521 }
92522
92523 /* store the type */
92524 - list_add(&ktype->link, &key_types_list);
92525 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
92526
92527 pr_notice("Key type %s registered\n", ktype->name);
92528 ret = 0;
92529 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
92530 void unregister_key_type(struct key_type *ktype)
92531 {
92532 down_write(&key_types_sem);
92533 - list_del_init(&ktype->link);
92534 + pax_list_del_init((struct list_head *)&ktype->link);
92535 downgrade_write(&key_types_sem);
92536 key_gc_keytype(ktype);
92537 pr_notice("Key type %s unregistered\n", ktype->name);
92538 @@ -1084,10 +1086,10 @@ void __init key_init(void)
92539 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
92540
92541 /* add the special key types */
92542 - list_add_tail(&key_type_keyring.link, &key_types_list);
92543 - list_add_tail(&key_type_dead.link, &key_types_list);
92544 - list_add_tail(&key_type_user.link, &key_types_list);
92545 - list_add_tail(&key_type_logon.link, &key_types_list);
92546 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
92547 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
92548 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
92549 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
92550
92551 /* record the root user tracking */
92552 rb_link_node(&root_key_user.node,
92553 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
92554 index 4b5c948..2054dc1 100644
92555 --- a/security/keys/keyctl.c
92556 +++ b/security/keys/keyctl.c
92557 @@ -986,7 +986,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
92558 /*
92559 * Copy the iovec data from userspace
92560 */
92561 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92562 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
92563 unsigned ioc)
92564 {
92565 for (; ioc > 0; ioc--) {
92566 @@ -1008,7 +1008,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92567 * If successful, 0 will be returned.
92568 */
92569 long keyctl_instantiate_key_common(key_serial_t id,
92570 - const struct iovec *payload_iov,
92571 + const struct iovec __user *payload_iov,
92572 unsigned ioc,
92573 size_t plen,
92574 key_serial_t ringid)
92575 @@ -1103,7 +1103,7 @@ long keyctl_instantiate_key(key_serial_t id,
92576 [0].iov_len = plen
92577 };
92578
92579 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
92580 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
92581 }
92582
92583 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
92584 @@ -1136,7 +1136,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
92585 if (ret == 0)
92586 goto no_payload_free;
92587
92588 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92589 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92590 err:
92591 if (iov != iovstack)
92592 kfree(iov);
92593 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
92594 index 6ece7f2..ecdb55c 100644
92595 --- a/security/keys/keyring.c
92596 +++ b/security/keys/keyring.c
92597 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
92598 ret = -EFAULT;
92599
92600 for (loop = 0; loop < klist->nkeys; loop++) {
92601 + key_serial_t serial;
92602 key = rcu_deref_link_locked(klist, loop,
92603 keyring);
92604 + serial = key->serial;
92605
92606 tmp = sizeof(key_serial_t);
92607 if (tmp > buflen)
92608 tmp = buflen;
92609
92610 - if (copy_to_user(buffer,
92611 - &key->serial,
92612 - tmp) != 0)
92613 + if (copy_to_user(buffer, &serial, tmp))
92614 goto error;
92615
92616 buflen -= tmp;
92617 diff --git a/security/min_addr.c b/security/min_addr.c
92618 index f728728..6457a0c 100644
92619 --- a/security/min_addr.c
92620 +++ b/security/min_addr.c
92621 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
92622 */
92623 static void update_mmap_min_addr(void)
92624 {
92625 +#ifndef SPARC
92626 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
92627 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
92628 mmap_min_addr = dac_mmap_min_addr;
92629 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
92630 #else
92631 mmap_min_addr = dac_mmap_min_addr;
92632 #endif
92633 +#endif
92634 }
92635
92636 /*
92637 diff --git a/security/security.c b/security/security.c
92638 index 03f248b..5710c33 100644
92639 --- a/security/security.c
92640 +++ b/security/security.c
92641 @@ -20,6 +20,7 @@
92642 #include <linux/ima.h>
92643 #include <linux/evm.h>
92644 #include <linux/fsnotify.h>
92645 +#include <linux/mm.h>
92646 #include <linux/mman.h>
92647 #include <linux/mount.h>
92648 #include <linux/personality.h>
92649 @@ -32,8 +33,8 @@
92650 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
92651 CONFIG_DEFAULT_SECURITY;
92652
92653 -static struct security_operations *security_ops;
92654 -static struct security_operations default_security_ops = {
92655 +static struct security_operations *security_ops __read_only;
92656 +static struct security_operations default_security_ops __read_only = {
92657 .name = "default",
92658 };
92659
92660 @@ -74,7 +75,9 @@ int __init security_init(void)
92661
92662 void reset_security_ops(void)
92663 {
92664 + pax_open_kernel();
92665 security_ops = &default_security_ops;
92666 + pax_close_kernel();
92667 }
92668
92669 /* Save user chosen LSM */
92670 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
92671 index 7171a95..c35e879 100644
92672 --- a/security/selinux/hooks.c
92673 +++ b/security/selinux/hooks.c
92674 @@ -96,8 +96,6 @@
92675
92676 #define NUM_SEL_MNT_OPTS 5
92677
92678 -extern struct security_operations *security_ops;
92679 -
92680 /* SECMARK reference count */
92681 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
92682
92683 @@ -5498,7 +5496,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
92684
92685 #endif
92686
92687 -static struct security_operations selinux_ops = {
92688 +static struct security_operations selinux_ops __read_only = {
92689 .name = "selinux",
92690
92691 .ptrace_access_check = selinux_ptrace_access_check,
92692 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
92693 index 65f67cb..3f141ef 100644
92694 --- a/security/selinux/include/xfrm.h
92695 +++ b/security/selinux/include/xfrm.h
92696 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
92697
92698 static inline void selinux_xfrm_notify_policyload(void)
92699 {
92700 - atomic_inc(&flow_cache_genid);
92701 + atomic_inc_unchecked(&flow_cache_genid);
92702 rt_genid_bump(&init_net);
92703 }
92704 #else
92705 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
92706 index fa64740..bc95b74 100644
92707 --- a/security/smack/smack_lsm.c
92708 +++ b/security/smack/smack_lsm.c
92709 @@ -3392,7 +3392,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
92710 return 0;
92711 }
92712
92713 -struct security_operations smack_ops = {
92714 +struct security_operations smack_ops __read_only = {
92715 .name = "smack",
92716
92717 .ptrace_access_check = smack_ptrace_access_check,
92718 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
92719 index 390c646..f2f8db3 100644
92720 --- a/security/tomoyo/mount.c
92721 +++ b/security/tomoyo/mount.c
92722 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
92723 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
92724 need_dev = -1; /* dev_name is a directory */
92725 } else {
92726 + if (!capable(CAP_SYS_ADMIN)) {
92727 + error = -EPERM;
92728 + goto out;
92729 + }
92730 fstype = get_fs_type(type);
92731 if (!fstype) {
92732 error = -ENODEV;
92733 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
92734 index a2ee362..5754f34 100644
92735 --- a/security/tomoyo/tomoyo.c
92736 +++ b/security/tomoyo/tomoyo.c
92737 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
92738 * tomoyo_security_ops is a "struct security_operations" which is used for
92739 * registering TOMOYO.
92740 */
92741 -static struct security_operations tomoyo_security_ops = {
92742 +static struct security_operations tomoyo_security_ops __read_only = {
92743 .name = "tomoyo",
92744 .cred_alloc_blank = tomoyo_cred_alloc_blank,
92745 .cred_prepare = tomoyo_cred_prepare,
92746 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
92747 index 20ef514..4182bed 100644
92748 --- a/security/yama/Kconfig
92749 +++ b/security/yama/Kconfig
92750 @@ -1,6 +1,6 @@
92751 config SECURITY_YAMA
92752 bool "Yama support"
92753 - depends on SECURITY
92754 + depends on SECURITY && !GRKERNSEC
92755 select SECURITYFS
92756 select SECURITY_PATH
92757 default n
92758 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
92759 index 13c88fbc..f8c115e 100644
92760 --- a/security/yama/yama_lsm.c
92761 +++ b/security/yama/yama_lsm.c
92762 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
92763 }
92764
92765 #ifndef CONFIG_SECURITY_YAMA_STACKED
92766 -static struct security_operations yama_ops = {
92767 +static struct security_operations yama_ops __read_only = {
92768 .name = "yama",
92769
92770 .ptrace_access_check = yama_ptrace_access_check,
92771 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
92772 #endif
92773
92774 #ifdef CONFIG_SYSCTL
92775 +static int zero __read_only;
92776 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
92777 +
92778 static int yama_dointvec_minmax(struct ctl_table *table, int write,
92779 void __user *buffer, size_t *lenp, loff_t *ppos)
92780 {
92781 - int rc;
92782 + ctl_table_no_const yama_table;
92783
92784 if (write && !capable(CAP_SYS_PTRACE))
92785 return -EPERM;
92786
92787 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
92788 - if (rc)
92789 - return rc;
92790 -
92791 + yama_table = *table;
92792 /* Lock the max value if it ever gets set. */
92793 - if (write && *(int *)table->data == *(int *)table->extra2)
92794 - table->extra1 = table->extra2;
92795 -
92796 - return rc;
92797 + if (ptrace_scope == max_scope)
92798 + yama_table.extra1 = &max_scope;
92799 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
92800 }
92801
92802 -static int zero;
92803 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
92804 -
92805 struct ctl_path yama_sysctl_path[] = {
92806 { .procname = "kernel", },
92807 { .procname = "yama", },
92808 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
92809 index 4cedc69..e59d8a3 100644
92810 --- a/sound/aoa/codecs/onyx.c
92811 +++ b/sound/aoa/codecs/onyx.c
92812 @@ -54,7 +54,7 @@ struct onyx {
92813 spdif_locked:1,
92814 analog_locked:1,
92815 original_mute:2;
92816 - int open_count;
92817 + local_t open_count;
92818 struct codec_info *codec_info;
92819
92820 /* mutex serializes concurrent access to the device
92821 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
92822 struct onyx *onyx = cii->codec_data;
92823
92824 mutex_lock(&onyx->mutex);
92825 - onyx->open_count++;
92826 + local_inc(&onyx->open_count);
92827 mutex_unlock(&onyx->mutex);
92828
92829 return 0;
92830 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
92831 struct onyx *onyx = cii->codec_data;
92832
92833 mutex_lock(&onyx->mutex);
92834 - onyx->open_count--;
92835 - if (!onyx->open_count)
92836 + if (local_dec_and_test(&onyx->open_count))
92837 onyx->spdif_locked = onyx->analog_locked = 0;
92838 mutex_unlock(&onyx->mutex);
92839
92840 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
92841 index ffd2025..df062c9 100644
92842 --- a/sound/aoa/codecs/onyx.h
92843 +++ b/sound/aoa/codecs/onyx.h
92844 @@ -11,6 +11,7 @@
92845 #include <linux/i2c.h>
92846 #include <asm/pmac_low_i2c.h>
92847 #include <asm/prom.h>
92848 +#include <asm/local.h>
92849
92850 /* PCM3052 register definitions */
92851
92852 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
92853 index 4c1cc51..16040040 100644
92854 --- a/sound/core/oss/pcm_oss.c
92855 +++ b/sound/core/oss/pcm_oss.c
92856 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
92857 if (in_kernel) {
92858 mm_segment_t fs;
92859 fs = snd_enter_user();
92860 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
92861 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
92862 snd_leave_user(fs);
92863 } else {
92864 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
92865 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
92866 }
92867 if (ret != -EPIPE && ret != -ESTRPIPE)
92868 break;
92869 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
92870 if (in_kernel) {
92871 mm_segment_t fs;
92872 fs = snd_enter_user();
92873 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
92874 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
92875 snd_leave_user(fs);
92876 } else {
92877 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
92878 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
92879 }
92880 if (ret == -EPIPE) {
92881 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
92882 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
92883 struct snd_pcm_plugin_channel *channels;
92884 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
92885 if (!in_kernel) {
92886 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
92887 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
92888 return -EFAULT;
92889 buf = runtime->oss.buffer;
92890 }
92891 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
92892 }
92893 } else {
92894 tmp = snd_pcm_oss_write2(substream,
92895 - (const char __force *)buf,
92896 + (const char __force_kernel *)buf,
92897 runtime->oss.period_bytes, 0);
92898 if (tmp <= 0)
92899 goto err;
92900 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
92901 struct snd_pcm_runtime *runtime = substream->runtime;
92902 snd_pcm_sframes_t frames, frames1;
92903 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
92904 - char __user *final_dst = (char __force __user *)buf;
92905 + char __user *final_dst = (char __force_user *)buf;
92906 if (runtime->oss.plugin_first) {
92907 struct snd_pcm_plugin_channel *channels;
92908 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
92909 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
92910 xfer += tmp;
92911 runtime->oss.buffer_used -= tmp;
92912 } else {
92913 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
92914 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
92915 runtime->oss.period_bytes, 0);
92916 if (tmp <= 0)
92917 goto err;
92918 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
92919 size1);
92920 size1 /= runtime->channels; /* frames */
92921 fs = snd_enter_user();
92922 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
92923 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
92924 snd_leave_user(fs);
92925 }
92926 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
92927 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
92928 index af49721..e85058e 100644
92929 --- a/sound/core/pcm_compat.c
92930 +++ b/sound/core/pcm_compat.c
92931 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
92932 int err;
92933
92934 fs = snd_enter_user();
92935 - err = snd_pcm_delay(substream, &delay);
92936 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
92937 snd_leave_user(fs);
92938 if (err < 0)
92939 return err;
92940 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
92941 index eb560fa..69a4995 100644
92942 --- a/sound/core/pcm_native.c
92943 +++ b/sound/core/pcm_native.c
92944 @@ -2806,11 +2806,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
92945 switch (substream->stream) {
92946 case SNDRV_PCM_STREAM_PLAYBACK:
92947 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
92948 - (void __user *)arg);
92949 + (void __force_user *)arg);
92950 break;
92951 case SNDRV_PCM_STREAM_CAPTURE:
92952 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
92953 - (void __user *)arg);
92954 + (void __force_user *)arg);
92955 break;
92956 default:
92957 result = -EINVAL;
92958 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
92959 index 040c60e..989a19a 100644
92960 --- a/sound/core/seq/seq_device.c
92961 +++ b/sound/core/seq/seq_device.c
92962 @@ -64,7 +64,7 @@ struct ops_list {
92963 int argsize; /* argument size */
92964
92965 /* operators */
92966 - struct snd_seq_dev_ops ops;
92967 + struct snd_seq_dev_ops *ops;
92968
92969 /* registered devices */
92970 struct list_head dev_list; /* list of devices */
92971 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
92972
92973 mutex_lock(&ops->reg_mutex);
92974 /* copy driver operators */
92975 - ops->ops = *entry;
92976 + ops->ops = entry;
92977 ops->driver |= DRIVER_LOADED;
92978 ops->argsize = argsize;
92979
92980 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
92981 dev->name, ops->id, ops->argsize, dev->argsize);
92982 return -EINVAL;
92983 }
92984 - if (ops->ops.init_device(dev) >= 0) {
92985 + if (ops->ops->init_device(dev) >= 0) {
92986 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
92987 ops->num_init_devices++;
92988 } else {
92989 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
92990 dev->name, ops->id, ops->argsize, dev->argsize);
92991 return -EINVAL;
92992 }
92993 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
92994 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
92995 dev->status = SNDRV_SEQ_DEVICE_FREE;
92996 dev->driver_data = NULL;
92997 ops->num_init_devices--;
92998 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
92999 index 4e0dd22..7a1f32c 100644
93000 --- a/sound/drivers/mts64.c
93001 +++ b/sound/drivers/mts64.c
93002 @@ -29,6 +29,7 @@
93003 #include <sound/initval.h>
93004 #include <sound/rawmidi.h>
93005 #include <sound/control.h>
93006 +#include <asm/local.h>
93007
93008 #define CARD_NAME "Miditerminal 4140"
93009 #define DRIVER_NAME "MTS64"
93010 @@ -67,7 +68,7 @@ struct mts64 {
93011 struct pardevice *pardev;
93012 int pardev_claimed;
93013
93014 - int open_count;
93015 + local_t open_count;
93016 int current_midi_output_port;
93017 int current_midi_input_port;
93018 u8 mode[MTS64_NUM_INPUT_PORTS];
93019 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93020 {
93021 struct mts64 *mts = substream->rmidi->private_data;
93022
93023 - if (mts->open_count == 0) {
93024 + if (local_read(&mts->open_count) == 0) {
93025 /* We don't need a spinlock here, because this is just called
93026 if the device has not been opened before.
93027 So there aren't any IRQs from the device */
93028 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93029
93030 msleep(50);
93031 }
93032 - ++(mts->open_count);
93033 + local_inc(&mts->open_count);
93034
93035 return 0;
93036 }
93037 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93038 struct mts64 *mts = substream->rmidi->private_data;
93039 unsigned long flags;
93040
93041 - --(mts->open_count);
93042 - if (mts->open_count == 0) {
93043 + if (local_dec_return(&mts->open_count) == 0) {
93044 /* We need the spinlock_irqsave here because we can still
93045 have IRQs at this point */
93046 spin_lock_irqsave(&mts->lock, flags);
93047 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93048
93049 msleep(500);
93050
93051 - } else if (mts->open_count < 0)
93052 - mts->open_count = 0;
93053 + } else if (local_read(&mts->open_count) < 0)
93054 + local_set(&mts->open_count, 0);
93055
93056 return 0;
93057 }
93058 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
93059 index b953fb4..1999c01 100644
93060 --- a/sound/drivers/opl4/opl4_lib.c
93061 +++ b/sound/drivers/opl4/opl4_lib.c
93062 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
93063 MODULE_DESCRIPTION("OPL4 driver");
93064 MODULE_LICENSE("GPL");
93065
93066 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
93067 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
93068 {
93069 int timeout = 10;
93070 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
93071 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
93072 index 991018d..8984740 100644
93073 --- a/sound/drivers/portman2x4.c
93074 +++ b/sound/drivers/portman2x4.c
93075 @@ -48,6 +48,7 @@
93076 #include <sound/initval.h>
93077 #include <sound/rawmidi.h>
93078 #include <sound/control.h>
93079 +#include <asm/local.h>
93080
93081 #define CARD_NAME "Portman 2x4"
93082 #define DRIVER_NAME "portman"
93083 @@ -85,7 +86,7 @@ struct portman {
93084 struct pardevice *pardev;
93085 int pardev_claimed;
93086
93087 - int open_count;
93088 + local_t open_count;
93089 int mode[PORTMAN_NUM_INPUT_PORTS];
93090 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
93091 };
93092 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
93093 index ea995af..f1bfa37 100644
93094 --- a/sound/firewire/amdtp.c
93095 +++ b/sound/firewire/amdtp.c
93096 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
93097 ptr = s->pcm_buffer_pointer + data_blocks;
93098 if (ptr >= pcm->runtime->buffer_size)
93099 ptr -= pcm->runtime->buffer_size;
93100 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
93101 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
93102
93103 s->pcm_period_pointer += data_blocks;
93104 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
93105 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
93106 */
93107 void amdtp_out_stream_update(struct amdtp_out_stream *s)
93108 {
93109 - ACCESS_ONCE(s->source_node_id_field) =
93110 + ACCESS_ONCE_RW(s->source_node_id_field) =
93111 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
93112 }
93113 EXPORT_SYMBOL(amdtp_out_stream_update);
93114 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
93115 index b680c5e..061b7a0 100644
93116 --- a/sound/firewire/amdtp.h
93117 +++ b/sound/firewire/amdtp.h
93118 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
93119 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
93120 struct snd_pcm_substream *pcm)
93121 {
93122 - ACCESS_ONCE(s->pcm) = pcm;
93123 + ACCESS_ONCE_RW(s->pcm) = pcm;
93124 }
93125
93126 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
93127 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
93128 index d428ffe..751ef78 100644
93129 --- a/sound/firewire/isight.c
93130 +++ b/sound/firewire/isight.c
93131 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
93132 ptr += count;
93133 if (ptr >= runtime->buffer_size)
93134 ptr -= runtime->buffer_size;
93135 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
93136 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
93137
93138 isight->period_counter += count;
93139 if (isight->period_counter >= runtime->period_size) {
93140 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
93141 if (err < 0)
93142 return err;
93143
93144 - ACCESS_ONCE(isight->pcm_active) = true;
93145 + ACCESS_ONCE_RW(isight->pcm_active) = true;
93146
93147 return 0;
93148 }
93149 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
93150 {
93151 struct isight *isight = substream->private_data;
93152
93153 - ACCESS_ONCE(isight->pcm_active) = false;
93154 + ACCESS_ONCE_RW(isight->pcm_active) = false;
93155
93156 mutex_lock(&isight->mutex);
93157 isight_stop_streaming(isight);
93158 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
93159
93160 switch (cmd) {
93161 case SNDRV_PCM_TRIGGER_START:
93162 - ACCESS_ONCE(isight->pcm_running) = true;
93163 + ACCESS_ONCE_RW(isight->pcm_running) = true;
93164 break;
93165 case SNDRV_PCM_TRIGGER_STOP:
93166 - ACCESS_ONCE(isight->pcm_running) = false;
93167 + ACCESS_ONCE_RW(isight->pcm_running) = false;
93168 break;
93169 default:
93170 return -EINVAL;
93171 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
93172 index 844a555..985ab83 100644
93173 --- a/sound/firewire/scs1x.c
93174 +++ b/sound/firewire/scs1x.c
93175 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
93176 {
93177 struct scs *scs = stream->rmidi->private_data;
93178
93179 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
93180 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
93181 if (up) {
93182 scs->output_idle = false;
93183 tasklet_schedule(&scs->tasklet);
93184 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
93185 {
93186 struct scs *scs = stream->rmidi->private_data;
93187
93188 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
93189 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
93190 }
93191
93192 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
93193 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
93194
93195 snd_card_disconnect(scs->card);
93196
93197 - ACCESS_ONCE(scs->output) = NULL;
93198 - ACCESS_ONCE(scs->input) = NULL;
93199 + ACCESS_ONCE_RW(scs->output) = NULL;
93200 + ACCESS_ONCE_RW(scs->input) = NULL;
93201
93202 wait_event(scs->idle_wait, scs->output_idle);
93203
93204 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
93205 index 048439a..3be9f6f 100644
93206 --- a/sound/oss/sb_audio.c
93207 +++ b/sound/oss/sb_audio.c
93208 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
93209 buf16 = (signed short *)(localbuf + localoffs);
93210 while (c)
93211 {
93212 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93213 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93214 if (copy_from_user(lbuf8,
93215 userbuf+useroffs + p,
93216 locallen))
93217 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
93218 index 7d8803a..559f8d0 100644
93219 --- a/sound/oss/swarm_cs4297a.c
93220 +++ b/sound/oss/swarm_cs4297a.c
93221 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
93222 {
93223 struct cs4297a_state *s;
93224 u32 pwr, id;
93225 - mm_segment_t fs;
93226 int rval;
93227 #ifndef CONFIG_BCM_CS4297A_CSWARM
93228 u64 cfg;
93229 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
93230 if (!rval) {
93231 char *sb1250_duart_present;
93232
93233 +#if 0
93234 + mm_segment_t fs;
93235 fs = get_fs();
93236 set_fs(KERNEL_DS);
93237 -#if 0
93238 val = SOUND_MASK_LINE;
93239 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
93240 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
93241 val = initvol[i].vol;
93242 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
93243 }
93244 + set_fs(fs);
93245 // cs4297a_write_ac97(s, 0x18, 0x0808);
93246 #else
93247 // cs4297a_write_ac97(s, 0x5e, 0x180);
93248 cs4297a_write_ac97(s, 0x02, 0x0808);
93249 cs4297a_write_ac97(s, 0x18, 0x0808);
93250 #endif
93251 - set_fs(fs);
93252
93253 list_add(&s->list, &cs4297a_devs);
93254
93255 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
93256 index 4631a23..001ae57 100644
93257 --- a/sound/pci/ymfpci/ymfpci.h
93258 +++ b/sound/pci/ymfpci/ymfpci.h
93259 @@ -358,7 +358,7 @@ struct snd_ymfpci {
93260 spinlock_t reg_lock;
93261 spinlock_t voice_lock;
93262 wait_queue_head_t interrupt_sleep;
93263 - atomic_t interrupt_sleep_count;
93264 + atomic_unchecked_t interrupt_sleep_count;
93265 struct snd_info_entry *proc_entry;
93266 const struct firmware *dsp_microcode;
93267 const struct firmware *controller_microcode;
93268 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
93269 index 22056c5..25d3244 100644
93270 --- a/sound/pci/ymfpci/ymfpci_main.c
93271 +++ b/sound/pci/ymfpci/ymfpci_main.c
93272 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
93273 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
93274 break;
93275 }
93276 - if (atomic_read(&chip->interrupt_sleep_count)) {
93277 - atomic_set(&chip->interrupt_sleep_count, 0);
93278 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93279 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93280 wake_up(&chip->interrupt_sleep);
93281 }
93282 __end:
93283 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
93284 continue;
93285 init_waitqueue_entry(&wait, current);
93286 add_wait_queue(&chip->interrupt_sleep, &wait);
93287 - atomic_inc(&chip->interrupt_sleep_count);
93288 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
93289 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
93290 remove_wait_queue(&chip->interrupt_sleep, &wait);
93291 }
93292 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
93293 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
93294 spin_unlock(&chip->reg_lock);
93295
93296 - if (atomic_read(&chip->interrupt_sleep_count)) {
93297 - atomic_set(&chip->interrupt_sleep_count, 0);
93298 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93299 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93300 wake_up(&chip->interrupt_sleep);
93301 }
93302 }
93303 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
93304 spin_lock_init(&chip->reg_lock);
93305 spin_lock_init(&chip->voice_lock);
93306 init_waitqueue_head(&chip->interrupt_sleep);
93307 - atomic_set(&chip->interrupt_sleep_count, 0);
93308 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93309 chip->card = card;
93310 chip->pci = pci;
93311 chip->irq = -1;
93312 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
93313 index 7decbd9..d17d9d0 100644
93314 --- a/sound/soc/fsl/fsl_ssi.c
93315 +++ b/sound/soc/fsl/fsl_ssi.c
93316 @@ -643,7 +643,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
93317 {
93318 struct fsl_ssi_private *ssi_private;
93319 int ret = 0;
93320 - struct device_attribute *dev_attr = NULL;
93321 + device_attribute_no_const *dev_attr = NULL;
93322 struct device_node *np = pdev->dev.of_node;
93323 const char *p, *sprop;
93324 const uint32_t *iprop;
93325 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
93326 new file mode 100644
93327 index 0000000..50f2f2f
93328 --- /dev/null
93329 +++ b/tools/gcc/.gitignore
93330 @@ -0,0 +1 @@
93331 +size_overflow_hash.h
93332 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
93333 new file mode 100644
93334 index 0000000..144dbee
93335 --- /dev/null
93336 +++ b/tools/gcc/Makefile
93337 @@ -0,0 +1,45 @@
93338 +#CC := gcc
93339 +#PLUGIN_SOURCE_FILES := pax_plugin.c
93340 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
93341 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
93342 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
93343 +
93344 +ifeq ($(PLUGINCC),$(HOSTCC))
93345 +HOSTLIBS := hostlibs
93346 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
93347 +else
93348 +HOSTLIBS := hostcxxlibs
93349 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
93350 +endif
93351 +
93352 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
93353 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
93354 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
93355 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
93356 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
93357 +$(HOSTLIBS)-y += colorize_plugin.so
93358 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
93359 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
93360 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
93361 +
93362 +always := $($(HOSTLIBS)-y)
93363 +
93364 +constify_plugin-objs := constify_plugin.o
93365 +stackleak_plugin-objs := stackleak_plugin.o
93366 +kallocstat_plugin-objs := kallocstat_plugin.o
93367 +kernexec_plugin-objs := kernexec_plugin.o
93368 +checker_plugin-objs := checker_plugin.o
93369 +colorize_plugin-objs := colorize_plugin.o
93370 +size_overflow_plugin-objs := size_overflow_plugin.o
93371 +latent_entropy_plugin-objs := latent_entropy_plugin.o
93372 +structleak_plugin-objs := structleak_plugin.o
93373 +
93374 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
93375 +
93376 +quiet_cmd_build_size_overflow_hash = GENHASH $@
93377 + cmd_build_size_overflow_hash = \
93378 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
93379 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
93380 + $(call if_changed,build_size_overflow_hash)
93381 +
93382 +targets += size_overflow_hash.h
93383 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
93384 new file mode 100644
93385 index 0000000..22f03c0
93386 --- /dev/null
93387 +++ b/tools/gcc/checker_plugin.c
93388 @@ -0,0 +1,172 @@
93389 +/*
93390 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
93391 + * Licensed under the GPL v2
93392 + *
93393 + * Note: the choice of the license means that the compilation process is
93394 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93395 + * but for the kernel it doesn't matter since it doesn't link against
93396 + * any of the gcc libraries
93397 + *
93398 + * gcc plugin to implement various sparse (source code checker) features
93399 + *
93400 + * TODO:
93401 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
93402 + *
93403 + * BUGS:
93404 + * - none known
93405 + */
93406 +#include "gcc-plugin.h"
93407 +#include "config.h"
93408 +#include "system.h"
93409 +#include "coretypes.h"
93410 +#include "tree.h"
93411 +#include "tree-pass.h"
93412 +#include "flags.h"
93413 +#include "intl.h"
93414 +#include "toplev.h"
93415 +#include "plugin.h"
93416 +//#include "expr.h" where are you...
93417 +#include "diagnostic.h"
93418 +#include "plugin-version.h"
93419 +#include "tm.h"
93420 +#include "function.h"
93421 +#include "basic-block.h"
93422 +#include "gimple.h"
93423 +#include "rtl.h"
93424 +#include "emit-rtl.h"
93425 +#include "tree-flow.h"
93426 +#include "target.h"
93427 +
93428 +extern void c_register_addr_space (const char *str, addr_space_t as);
93429 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
93430 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
93431 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
93432 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
93433 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
93434 +
93435 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93436 +extern rtx emit_move_insn(rtx x, rtx y);
93437 +
93438 +int plugin_is_GPL_compatible;
93439 +
93440 +static struct plugin_info checker_plugin_info = {
93441 + .version = "201111150100",
93442 + .help = NULL,
93443 +};
93444 +
93445 +#define ADDR_SPACE_KERNEL 0
93446 +#define ADDR_SPACE_FORCE_KERNEL 1
93447 +#define ADDR_SPACE_USER 2
93448 +#define ADDR_SPACE_FORCE_USER 3
93449 +#define ADDR_SPACE_IOMEM 0
93450 +#define ADDR_SPACE_FORCE_IOMEM 0
93451 +#define ADDR_SPACE_PERCPU 0
93452 +#define ADDR_SPACE_FORCE_PERCPU 0
93453 +#define ADDR_SPACE_RCU 0
93454 +#define ADDR_SPACE_FORCE_RCU 0
93455 +
93456 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
93457 +{
93458 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
93459 +}
93460 +
93461 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
93462 +{
93463 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
93464 +}
93465 +
93466 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
93467 +{
93468 + return default_addr_space_valid_pointer_mode(mode, as);
93469 +}
93470 +
93471 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
93472 +{
93473 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
93474 +}
93475 +
93476 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
93477 +{
93478 + return default_addr_space_legitimize_address(x, oldx, mode, as);
93479 +}
93480 +
93481 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
93482 +{
93483 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
93484 + return true;
93485 +
93486 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
93487 + return true;
93488 +
93489 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
93490 + return true;
93491 +
93492 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
93493 + return true;
93494 +
93495 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
93496 + return true;
93497 +
93498 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
93499 + return true;
93500 +
93501 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
93502 + return true;
93503 +
93504 + return subset == superset;
93505 +}
93506 +
93507 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
93508 +{
93509 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
93510 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
93511 +
93512 + return op;
93513 +}
93514 +
93515 +static void register_checker_address_spaces(void *event_data, void *data)
93516 +{
93517 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
93518 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
93519 + c_register_addr_space("__user", ADDR_SPACE_USER);
93520 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
93521 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
93522 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
93523 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
93524 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
93525 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
93526 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
93527 +
93528 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
93529 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
93530 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
93531 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
93532 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
93533 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
93534 + targetm.addr_space.convert = checker_addr_space_convert;
93535 +}
93536 +
93537 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93538 +{
93539 + const char * const plugin_name = plugin_info->base_name;
93540 + const int argc = plugin_info->argc;
93541 + const struct plugin_argument * const argv = plugin_info->argv;
93542 + int i;
93543 +
93544 + if (!plugin_default_version_check(version, &gcc_version)) {
93545 + error(G_("incompatible gcc/plugin versions"));
93546 + return 1;
93547 + }
93548 +
93549 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
93550 +
93551 + for (i = 0; i < argc; ++i)
93552 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93553 +
93554 + if (TARGET_64BIT == 0)
93555 + return 0;
93556 +
93557 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
93558 +
93559 + return 0;
93560 +}
93561 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
93562 new file mode 100644
93563 index 0000000..414fe5e
93564 --- /dev/null
93565 +++ b/tools/gcc/colorize_plugin.c
93566 @@ -0,0 +1,151 @@
93567 +/*
93568 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
93569 + * Licensed under the GPL v2
93570 + *
93571 + * Note: the choice of the license means that the compilation process is
93572 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93573 + * but for the kernel it doesn't matter since it doesn't link against
93574 + * any of the gcc libraries
93575 + *
93576 + * gcc plugin to colorize diagnostic output
93577 + *
93578 + */
93579 +
93580 +#include "gcc-plugin.h"
93581 +#include "config.h"
93582 +#include "system.h"
93583 +#include "coretypes.h"
93584 +#include "tree.h"
93585 +#include "tree-pass.h"
93586 +#include "flags.h"
93587 +#include "intl.h"
93588 +#include "toplev.h"
93589 +#include "plugin.h"
93590 +#include "diagnostic.h"
93591 +#include "plugin-version.h"
93592 +#include "tm.h"
93593 +
93594 +int plugin_is_GPL_compatible;
93595 +
93596 +static struct plugin_info colorize_plugin_info = {
93597 + .version = "201302112000",
93598 + .help = NULL,
93599 +};
93600 +
93601 +#define GREEN "\033[32m\033[2m"
93602 +#define LIGHTGREEN "\033[32m\033[1m"
93603 +#define YELLOW "\033[33m\033[2m"
93604 +#define LIGHTYELLOW "\033[33m\033[1m"
93605 +#define RED "\033[31m\033[2m"
93606 +#define LIGHTRED "\033[31m\033[1m"
93607 +#define BLUE "\033[34m\033[2m"
93608 +#define LIGHTBLUE "\033[34m\033[1m"
93609 +#define BRIGHT "\033[m\033[1m"
93610 +#define NORMAL "\033[m"
93611 +
93612 +static diagnostic_starter_fn old_starter;
93613 +static diagnostic_finalizer_fn old_finalizer;
93614 +
93615 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93616 +{
93617 + const char *color;
93618 + char *newprefix;
93619 +
93620 + switch (diagnostic->kind) {
93621 + case DK_NOTE:
93622 + color = LIGHTBLUE;
93623 + break;
93624 +
93625 + case DK_PEDWARN:
93626 + case DK_WARNING:
93627 + color = LIGHTYELLOW;
93628 + break;
93629 +
93630 + case DK_ERROR:
93631 + case DK_FATAL:
93632 + case DK_ICE:
93633 + case DK_PERMERROR:
93634 + case DK_SORRY:
93635 + color = LIGHTRED;
93636 + break;
93637 +
93638 + default:
93639 + color = NORMAL;
93640 + }
93641 +
93642 + old_starter(context, diagnostic);
93643 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
93644 + return;
93645 + pp_destroy_prefix(context->printer);
93646 + pp_set_prefix(context->printer, newprefix);
93647 +}
93648 +
93649 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93650 +{
93651 + old_finalizer(context, diagnostic);
93652 +}
93653 +
93654 +static void colorize_arm(void)
93655 +{
93656 + old_starter = diagnostic_starter(global_dc);
93657 + old_finalizer = diagnostic_finalizer(global_dc);
93658 +
93659 + diagnostic_starter(global_dc) = start_colorize;
93660 + diagnostic_finalizer(global_dc) = finalize_colorize;
93661 +}
93662 +
93663 +static unsigned int execute_colorize_rearm(void)
93664 +{
93665 + if (diagnostic_starter(global_dc) == start_colorize)
93666 + return 0;
93667 +
93668 + colorize_arm();
93669 + return 0;
93670 +}
93671 +
93672 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
93673 + .pass = {
93674 + .type = SIMPLE_IPA_PASS,
93675 + .name = "colorize_rearm",
93676 +#if BUILDING_GCC_VERSION >= 4008
93677 + .optinfo_flags = OPTGROUP_NONE,
93678 +#endif
93679 + .gate = NULL,
93680 + .execute = execute_colorize_rearm,
93681 + .sub = NULL,
93682 + .next = NULL,
93683 + .static_pass_number = 0,
93684 + .tv_id = TV_NONE,
93685 + .properties_required = 0,
93686 + .properties_provided = 0,
93687 + .properties_destroyed = 0,
93688 + .todo_flags_start = 0,
93689 + .todo_flags_finish = 0
93690 + }
93691 +};
93692 +
93693 +static void colorize_start_unit(void *gcc_data, void *user_data)
93694 +{
93695 + colorize_arm();
93696 +}
93697 +
93698 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93699 +{
93700 + const char * const plugin_name = plugin_info->base_name;
93701 + struct register_pass_info colorize_rearm_pass_info = {
93702 + .pass = &pass_ipa_colorize_rearm.pass,
93703 + .reference_pass_name = "*free_lang_data",
93704 + .ref_pass_instance_number = 1,
93705 + .pos_op = PASS_POS_INSERT_AFTER
93706 + };
93707 +
93708 + if (!plugin_default_version_check(version, &gcc_version)) {
93709 + error(G_("incompatible gcc/plugin versions"));
93710 + return 1;
93711 + }
93712 +
93713 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
93714 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
93715 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
93716 + return 0;
93717 +}
93718 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
93719 new file mode 100644
93720 index 0000000..c17312d
93721 --- /dev/null
93722 +++ b/tools/gcc/constify_plugin.c
93723 @@ -0,0 +1,560 @@
93724 +/*
93725 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
93726 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
93727 + * Licensed under the GPL v2, or (at your option) v3
93728 + *
93729 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
93730 + *
93731 + * Homepage:
93732 + * http://www.grsecurity.net/~ephox/const_plugin/
93733 + *
93734 + * Usage:
93735 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
93736 + * $ gcc -fplugin=constify_plugin.so test.c -O2
93737 + */
93738 +
93739 +#include "gcc-plugin.h"
93740 +#include "config.h"
93741 +#include "system.h"
93742 +#include "coretypes.h"
93743 +#include "tree.h"
93744 +#include "tree-pass.h"
93745 +#include "flags.h"
93746 +#include "intl.h"
93747 +#include "toplev.h"
93748 +#include "plugin.h"
93749 +#include "diagnostic.h"
93750 +#include "plugin-version.h"
93751 +#include "tm.h"
93752 +#include "function.h"
93753 +#include "basic-block.h"
93754 +#include "gimple.h"
93755 +#include "rtl.h"
93756 +#include "emit-rtl.h"
93757 +#include "tree-flow.h"
93758 +#include "target.h"
93759 +#include "langhooks.h"
93760 +
93761 +// should come from c-tree.h if only it were installed for gcc 4.5...
93762 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
93763 +
93764 +// unused type flag in all versions 4.5-4.8
93765 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
93766 +
93767 +int plugin_is_GPL_compatible;
93768 +
93769 +static struct plugin_info const_plugin_info = {
93770 + .version = "201305231310",
93771 + .help = "no-constify\tturn off constification\n",
93772 +};
93773 +
93774 +typedef struct {
93775 + bool has_fptr_field;
93776 + bool has_writable_field;
93777 + bool has_do_const_field;
93778 + bool has_no_const_field;
93779 +} constify_info;
93780 +
93781 +static const_tree get_field_type(const_tree field)
93782 +{
93783 + return strip_array_types(TREE_TYPE(field));
93784 +}
93785 +
93786 +static bool is_fptr(const_tree field)
93787 +{
93788 + const_tree ptr = get_field_type(field);
93789 +
93790 + if (TREE_CODE(ptr) != POINTER_TYPE)
93791 + return false;
93792 +
93793 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
93794 +}
93795 +
93796 +/*
93797 + * determine whether the given structure type meets the requirements for automatic constification,
93798 + * including the constification attributes on nested structure types
93799 + */
93800 +static void constifiable(const_tree node, constify_info *cinfo)
93801 +{
93802 + const_tree field;
93803 +
93804 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93805 +
93806 + // e.g., pointer to structure fields while still constructing the structure type
93807 + if (TYPE_FIELDS(node) == NULL_TREE)
93808 + return;
93809 +
93810 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
93811 + const_tree type = get_field_type(field);
93812 + enum tree_code code = TREE_CODE(type);
93813 +
93814 + if (node == type)
93815 + continue;
93816 +
93817 + if (is_fptr(field))
93818 + cinfo->has_fptr_field = true;
93819 + else if (!TREE_READONLY(field))
93820 + cinfo->has_writable_field = true;
93821 +
93822 + if (code == RECORD_TYPE || code == UNION_TYPE) {
93823 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93824 + cinfo->has_do_const_field = true;
93825 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
93826 + cinfo->has_no_const_field = true;
93827 + else
93828 + constifiable(type, cinfo);
93829 + }
93830 + }
93831 +}
93832 +
93833 +static bool constified(const_tree node)
93834 +{
93835 + constify_info cinfo = {
93836 + .has_fptr_field = false,
93837 + .has_writable_field = false,
93838 + .has_do_const_field = false,
93839 + .has_no_const_field = false
93840 + };
93841 +
93842 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93843 +
93844 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
93845 + gcc_assert(!TYPE_READONLY(node));
93846 + return false;
93847 + }
93848 +
93849 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
93850 + gcc_assert(TYPE_READONLY(node));
93851 + return true;
93852 + }
93853 +
93854 + constifiable(node, &cinfo);
93855 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
93856 + return false;
93857 +
93858 + return TYPE_READONLY(node);
93859 +}
93860 +
93861 +static void deconstify_tree(tree node);
93862 +
93863 +static void deconstify_type(tree type)
93864 +{
93865 + tree field;
93866 +
93867 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
93868 +
93869 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
93870 + const_tree fieldtype = get_field_type(field);
93871 +
93872 + // special case handling of simple ptr-to-same-array-type members
93873 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
93874 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
93875 +
93876 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
93877 + continue;
93878 + if (TREE_TYPE(TREE_TYPE(field)) == type)
93879 + continue;
93880 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
93881 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
93882 + TREE_TYPE(TREE_TYPE(field)) = type;
93883 + }
93884 + continue;
93885 + }
93886 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
93887 + continue;
93888 + if (!constified(fieldtype))
93889 + continue;
93890 +
93891 + deconstify_tree(field);
93892 + TREE_READONLY(field) = 0;
93893 + }
93894 + TYPE_READONLY(type) = 0;
93895 + C_TYPE_FIELDS_READONLY(type) = 0;
93896 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93897 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
93898 +}
93899 +
93900 +static void deconstify_tree(tree node)
93901 +{
93902 + tree old_type, new_type, field;
93903 +
93904 + old_type = TREE_TYPE(node);
93905 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
93906 + node = TREE_TYPE(node) = copy_node(old_type);
93907 + old_type = TREE_TYPE(old_type);
93908 + }
93909 +
93910 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
93911 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
93912 +
93913 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
93914 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
93915 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
93916 + DECL_FIELD_CONTEXT(field) = new_type;
93917 +
93918 + deconstify_type(new_type);
93919 +
93920 + TREE_TYPE(node) = new_type;
93921 +}
93922 +
93923 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
93924 +{
93925 + tree type;
93926 + constify_info cinfo = {
93927 + .has_fptr_field = false,
93928 + .has_writable_field = false,
93929 + .has_do_const_field = false,
93930 + .has_no_const_field = false
93931 + };
93932 +
93933 + *no_add_attrs = true;
93934 + if (TREE_CODE(*node) == FUNCTION_DECL) {
93935 + error("%qE attribute does not apply to functions", name);
93936 + return NULL_TREE;
93937 + }
93938 +
93939 + if (TREE_CODE(*node) == PARM_DECL) {
93940 + error("%qE attribute does not apply to function parameters", name);
93941 + return NULL_TREE;
93942 + }
93943 +
93944 + if (TREE_CODE(*node) == VAR_DECL) {
93945 + error("%qE attribute does not apply to variables", name);
93946 + return NULL_TREE;
93947 + }
93948 +
93949 + if (TYPE_P(*node)) {
93950 + *no_add_attrs = false;
93951 + type = *node;
93952 + } else {
93953 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
93954 + type = TREE_TYPE(*node);
93955 + }
93956 +
93957 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
93958 + error("%qE attribute applies to struct and union types only", name);
93959 + return NULL_TREE;
93960 + }
93961 +
93962 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
93963 + error("%qE attribute is already applied to the type", name);
93964 + return NULL_TREE;
93965 + }
93966 +
93967 + if (TYPE_P(*node)) {
93968 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93969 + error("%qE attribute is incompatible with 'do_const'", name);
93970 + return NULL_TREE;
93971 + }
93972 +
93973 + constifiable(type, &cinfo);
93974 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
93975 + deconstify_tree(*node);
93976 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
93977 + return NULL_TREE;
93978 + }
93979 +
93980 + error("%qE attribute used on type that is not constified", name);
93981 + return NULL_TREE;
93982 +}
93983 +
93984 +static void constify_type(tree type)
93985 +{
93986 + TYPE_READONLY(type) = 1;
93987 + C_TYPE_FIELDS_READONLY(type) = 1;
93988 + TYPE_CONSTIFY_VISITED(type) = 1;
93989 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
93990 +}
93991 +
93992 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
93993 +{
93994 + *no_add_attrs = true;
93995 + if (!TYPE_P(*node)) {
93996 + error("%qE attribute applies to types only", name);
93997 + return NULL_TREE;
93998 + }
93999 +
94000 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
94001 + error("%qE attribute applies to struct and union types only", name);
94002 + return NULL_TREE;
94003 + }
94004 +
94005 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
94006 + error("%qE attribute is already applied to the type", name);
94007 + return NULL_TREE;
94008 + }
94009 +
94010 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
94011 + error("%qE attribute is incompatible with 'no_const'", name);
94012 + return NULL_TREE;
94013 + }
94014 +
94015 + *no_add_attrs = false;
94016 + return NULL_TREE;
94017 +}
94018 +
94019 +static struct attribute_spec no_const_attr = {
94020 + .name = "no_const",
94021 + .min_length = 0,
94022 + .max_length = 0,
94023 + .decl_required = false,
94024 + .type_required = false,
94025 + .function_type_required = false,
94026 + .handler = handle_no_const_attribute,
94027 +#if BUILDING_GCC_VERSION >= 4007
94028 + .affects_type_identity = true
94029 +#endif
94030 +};
94031 +
94032 +static struct attribute_spec do_const_attr = {
94033 + .name = "do_const",
94034 + .min_length = 0,
94035 + .max_length = 0,
94036 + .decl_required = false,
94037 + .type_required = false,
94038 + .function_type_required = false,
94039 + .handler = handle_do_const_attribute,
94040 +#if BUILDING_GCC_VERSION >= 4007
94041 + .affects_type_identity = true
94042 +#endif
94043 +};
94044 +
94045 +static void register_attributes(void *event_data, void *data)
94046 +{
94047 + register_attribute(&no_const_attr);
94048 + register_attribute(&do_const_attr);
94049 +}
94050 +
94051 +static void finish_type(void *event_data, void *data)
94052 +{
94053 + tree type = (tree)event_data;
94054 + constify_info cinfo = {
94055 + .has_fptr_field = false,
94056 + .has_writable_field = false,
94057 + .has_do_const_field = false,
94058 + .has_no_const_field = false
94059 + };
94060 +
94061 + if (type == NULL_TREE || type == error_mark_node)
94062 + return;
94063 +
94064 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
94065 + return;
94066 +
94067 + constifiable(type, &cinfo);
94068 +
94069 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
94070 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94071 + return;
94072 + if (cinfo.has_writable_field)
94073 + return;
94074 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
94075 + return;
94076 + }
94077 +
94078 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
94079 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
94080 + deconstify_type(type);
94081 + TYPE_CONSTIFY_VISITED(type) = 1;
94082 + } else
94083 + error("'no_const' attribute used on type that is not constified");
94084 + return;
94085 + }
94086 +
94087 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
94088 + constify_type(type);
94089 + return;
94090 + }
94091 +
94092 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
94093 + constify_type(type);
94094 + return;
94095 + }
94096 +
94097 + deconstify_type(type);
94098 + TYPE_CONSTIFY_VISITED(type) = 1;
94099 +}
94100 +
94101 +static void check_global_variables(void)
94102 +{
94103 + struct varpool_node *node;
94104 +
94105 +#if BUILDING_GCC_VERSION <= 4007
94106 + for (node = varpool_nodes; node; node = node->next) {
94107 + tree var = node->decl;
94108 +#else
94109 + FOR_EACH_VARIABLE(node) {
94110 + tree var = node->symbol.decl;
94111 +#endif
94112 + tree type = TREE_TYPE(var);
94113 +
94114 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
94115 + continue;
94116 +
94117 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
94118 + continue;
94119 +
94120 + if (!TYPE_CONSTIFY_VISITED(type))
94121 + continue;
94122 +
94123 + if (DECL_EXTERNAL(var))
94124 + continue;
94125 +
94126 + if (DECL_INITIAL(var))
94127 + continue;
94128 +
94129 + // this works around a gcc bug/feature where uninitialized globals
94130 + // are moved into the .bss section regardless of any constification
94131 + DECL_INITIAL(var) = build_constructor(type, NULL);
94132 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
94133 + }
94134 +}
94135 +
94136 +static unsigned int check_local_variables(void)
94137 +{
94138 + unsigned int ret = 0;
94139 + tree var;
94140 +
94141 +#if BUILDING_GCC_VERSION == 4005
94142 + tree vars;
94143 +#else
94144 + unsigned int i;
94145 +#endif
94146 +
94147 +#if BUILDING_GCC_VERSION == 4005
94148 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
94149 + var = TREE_VALUE(vars);
94150 +#else
94151 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
94152 +#endif
94153 + tree type = TREE_TYPE(var);
94154 +
94155 + gcc_assert(DECL_P(var));
94156 + if (is_global_var(var))
94157 + continue;
94158 +
94159 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
94160 + continue;
94161 +
94162 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
94163 + continue;
94164 +
94165 + if (!TYPE_CONSTIFY_VISITED(type))
94166 + continue;
94167 +
94168 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
94169 + ret = 1;
94170 + }
94171 + return ret;
94172 +}
94173 +
94174 +static unsigned int check_variables(void)
94175 +{
94176 + check_global_variables();
94177 + return check_local_variables();
94178 +}
94179 +
94180 + unsigned int ret = 0;
94181 +static struct gimple_opt_pass pass_local_variable = {
94182 + {
94183 + .type = GIMPLE_PASS,
94184 + .name = "check_variables",
94185 +#if BUILDING_GCC_VERSION >= 4008
94186 + .optinfo_flags = OPTGROUP_NONE,
94187 +#endif
94188 + .gate = NULL,
94189 + .execute = check_variables,
94190 + .sub = NULL,
94191 + .next = NULL,
94192 + .static_pass_number = 0,
94193 + .tv_id = TV_NONE,
94194 + .properties_required = 0,
94195 + .properties_provided = 0,
94196 + .properties_destroyed = 0,
94197 + .todo_flags_start = 0,
94198 + .todo_flags_finish = 0
94199 + }
94200 +};
94201 +
94202 +static struct {
94203 + const char *name;
94204 + const char *asm_op;
94205 +} sections[] = {
94206 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
94207 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
94208 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
94209 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
94210 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
94211 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
94212 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
94213 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
94214 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
94215 +};
94216 +
94217 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
94218 +
94219 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
94220 +{
94221 + size_t i;
94222 +
94223 + for (i = 0; i < ARRAY_SIZE(sections); i++)
94224 + if (!strcmp(sections[i].name, name))
94225 + return 0;
94226 + return old_section_type_flags(decl, name, reloc);
94227 +}
94228 +
94229 +static void constify_start_unit(void *gcc_data, void *user_data)
94230 +{
94231 +// size_t i;
94232 +
94233 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
94234 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
94235 +// sections[i].section = get_section(sections[i].name, 0, NULL);
94236 +
94237 + old_section_type_flags = targetm.section_type_flags;
94238 + targetm.section_type_flags = constify_section_type_flags;
94239 +}
94240 +
94241 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94242 +{
94243 + const char * const plugin_name = plugin_info->base_name;
94244 + const int argc = plugin_info->argc;
94245 + const struct plugin_argument * const argv = plugin_info->argv;
94246 + int i;
94247 + bool constify = true;
94248 +
94249 + struct register_pass_info local_variable_pass_info = {
94250 + .pass = &pass_local_variable.pass,
94251 + .reference_pass_name = "ssa",
94252 + .ref_pass_instance_number = 1,
94253 + .pos_op = PASS_POS_INSERT_BEFORE
94254 + };
94255 +
94256 + if (!plugin_default_version_check(version, &gcc_version)) {
94257 + error(G_("incompatible gcc/plugin versions"));
94258 + return 1;
94259 + }
94260 +
94261 + for (i = 0; i < argc; ++i) {
94262 + if (!(strcmp(argv[i].key, "no-constify"))) {
94263 + constify = false;
94264 + continue;
94265 + }
94266 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94267 + }
94268 +
94269 + if (strcmp(lang_hooks.name, "GNU C")) {
94270 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
94271 + constify = false;
94272 + }
94273 +
94274 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
94275 + if (constify) {
94276 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
94277 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
94278 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
94279 + }
94280 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
94281 +
94282 + return 0;
94283 +}
94284 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
94285 new file mode 100644
94286 index 0000000..e518932
94287 --- /dev/null
94288 +++ b/tools/gcc/generate_size_overflow_hash.sh
94289 @@ -0,0 +1,94 @@
94290 +#!/bin/bash
94291 +
94292 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
94293 +
94294 +header1="size_overflow_hash.h"
94295 +database="size_overflow_hash.data"
94296 +n=65536
94297 +
94298 +usage() {
94299 +cat <<EOF
94300 +usage: $0 options
94301 +OPTIONS:
94302 + -h|--help help
94303 + -o header file
94304 + -d database file
94305 + -n hash array size
94306 +EOF
94307 + return 0
94308 +}
94309 +
94310 +while true
94311 +do
94312 + case "$1" in
94313 + -h|--help) usage && exit 0;;
94314 + -n) n=$2; shift 2;;
94315 + -o) header1="$2"; shift 2;;
94316 + -d) database="$2"; shift 2;;
94317 + --) shift 1; break ;;
94318 + *) break ;;
94319 + esac
94320 +done
94321 +
94322 +create_defines() {
94323 + for i in `seq 0 31`
94324 + do
94325 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
94326 + done
94327 + echo >> "$header1"
94328 +}
94329 +
94330 +create_structs() {
94331 + rm -f "$header1"
94332 +
94333 + create_defines
94334 +
94335 + cat "$database" | while read data
94336 + do
94337 + data_array=($data)
94338 + struct_hash_name="${data_array[0]}"
94339 + funcn="${data_array[1]}"
94340 + params="${data_array[2]}"
94341 + next="${data_array[4]}"
94342 +
94343 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
94344 +
94345 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
94346 + echo -en "\t.param\t= " >> "$header1"
94347 + line=
94348 + for param_num in ${params//-/ };
94349 + do
94350 + line="${line}PARAM"$param_num"|"
94351 + done
94352 +
94353 + echo -e "${line%?},\n};\n" >> "$header1"
94354 + done
94355 +}
94356 +
94357 +create_headers() {
94358 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
94359 +}
94360 +
94361 +create_array_elements() {
94362 + index=0
94363 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
94364 + do
94365 + data_array=($data)
94366 + i="${data_array[3]}"
94367 + hash="${data_array[0]}"
94368 + while [[ $index -lt $i ]]
94369 + do
94370 + echo -e "\t["$index"]\t= NULL," >> "$header1"
94371 + index=$(($index + 1))
94372 + done
94373 + index=$(($index + 1))
94374 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
94375 + done
94376 + echo '};' >> $header1
94377 +}
94378 +
94379 +create_structs
94380 +create_headers
94381 +create_array_elements
94382 +
94383 +exit 0
94384 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
94385 new file mode 100644
94386 index 0000000..568b360
94387 --- /dev/null
94388 +++ b/tools/gcc/kallocstat_plugin.c
94389 @@ -0,0 +1,170 @@
94390 +/*
94391 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94392 + * Licensed under the GPL v2
94393 + *
94394 + * Note: the choice of the license means that the compilation process is
94395 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94396 + * but for the kernel it doesn't matter since it doesn't link against
94397 + * any of the gcc libraries
94398 + *
94399 + * gcc plugin to find the distribution of k*alloc sizes
94400 + *
94401 + * TODO:
94402 + *
94403 + * BUGS:
94404 + * - none known
94405 + */
94406 +#include "gcc-plugin.h"
94407 +#include "config.h"
94408 +#include "system.h"
94409 +#include "coretypes.h"
94410 +#include "tree.h"
94411 +#include "tree-pass.h"
94412 +#include "flags.h"
94413 +#include "intl.h"
94414 +#include "toplev.h"
94415 +#include "plugin.h"
94416 +//#include "expr.h" where are you...
94417 +#include "diagnostic.h"
94418 +#include "plugin-version.h"
94419 +#include "tm.h"
94420 +#include "function.h"
94421 +#include "basic-block.h"
94422 +#include "gimple.h"
94423 +#include "rtl.h"
94424 +#include "emit-rtl.h"
94425 +
94426 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94427 +
94428 +int plugin_is_GPL_compatible;
94429 +
94430 +static const char * const kalloc_functions[] = {
94431 + "__kmalloc",
94432 + "kmalloc",
94433 + "kmalloc_large",
94434 + "kmalloc_node",
94435 + "kmalloc_order",
94436 + "kmalloc_order_trace",
94437 + "kmalloc_slab",
94438 + "kzalloc",
94439 + "kzalloc_node",
94440 +};
94441 +
94442 +static struct plugin_info kallocstat_plugin_info = {
94443 + .version = "201302112000",
94444 +};
94445 +
94446 +static unsigned int execute_kallocstat(void);
94447 +
94448 +static struct gimple_opt_pass kallocstat_pass = {
94449 + .pass = {
94450 + .type = GIMPLE_PASS,
94451 + .name = "kallocstat",
94452 +#if BUILDING_GCC_VERSION >= 4008
94453 + .optinfo_flags = OPTGROUP_NONE,
94454 +#endif
94455 + .gate = NULL,
94456 + .execute = execute_kallocstat,
94457 + .sub = NULL,
94458 + .next = NULL,
94459 + .static_pass_number = 0,
94460 + .tv_id = TV_NONE,
94461 + .properties_required = 0,
94462 + .properties_provided = 0,
94463 + .properties_destroyed = 0,
94464 + .todo_flags_start = 0,
94465 + .todo_flags_finish = 0
94466 + }
94467 +};
94468 +
94469 +static bool is_kalloc(const char *fnname)
94470 +{
94471 + size_t i;
94472 +
94473 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
94474 + if (!strcmp(fnname, kalloc_functions[i]))
94475 + return true;
94476 + return false;
94477 +}
94478 +
94479 +static unsigned int execute_kallocstat(void)
94480 +{
94481 + basic_block bb;
94482 +
94483 + // 1. loop through BBs and GIMPLE statements
94484 + FOR_EACH_BB(bb) {
94485 + gimple_stmt_iterator gsi;
94486 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94487 + // gimple match:
94488 + tree fndecl, size;
94489 + gimple call_stmt;
94490 + const char *fnname;
94491 +
94492 + // is it a call
94493 + call_stmt = gsi_stmt(gsi);
94494 + if (!is_gimple_call(call_stmt))
94495 + continue;
94496 + fndecl = gimple_call_fndecl(call_stmt);
94497 + if (fndecl == NULL_TREE)
94498 + continue;
94499 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
94500 + continue;
94501 +
94502 + // is it a call to k*alloc
94503 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
94504 + if (!is_kalloc(fnname))
94505 + continue;
94506 +
94507 + // is the size arg the result of a simple const assignment
94508 + size = gimple_call_arg(call_stmt, 0);
94509 + while (true) {
94510 + gimple def_stmt;
94511 + expanded_location xloc;
94512 + size_t size_val;
94513 +
94514 + if (TREE_CODE(size) != SSA_NAME)
94515 + break;
94516 + def_stmt = SSA_NAME_DEF_STMT(size);
94517 + if (!def_stmt || !is_gimple_assign(def_stmt))
94518 + break;
94519 + if (gimple_num_ops(def_stmt) != 2)
94520 + break;
94521 + size = gimple_assign_rhs1(def_stmt);
94522 + if (!TREE_CONSTANT(size))
94523 + continue;
94524 + xloc = expand_location(gimple_location(def_stmt));
94525 + if (!xloc.file)
94526 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
94527 + size_val = TREE_INT_CST_LOW(size);
94528 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
94529 + break;
94530 + }
94531 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94532 +//debug_tree(gimple_call_fn(call_stmt));
94533 +//print_node(stderr, "pax", fndecl, 4);
94534 + }
94535 + }
94536 +
94537 + return 0;
94538 +}
94539 +
94540 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94541 +{
94542 + const char * const plugin_name = plugin_info->base_name;
94543 + struct register_pass_info kallocstat_pass_info = {
94544 + .pass = &kallocstat_pass.pass,
94545 + .reference_pass_name = "ssa",
94546 + .ref_pass_instance_number = 1,
94547 + .pos_op = PASS_POS_INSERT_AFTER
94548 + };
94549 +
94550 + if (!plugin_default_version_check(version, &gcc_version)) {
94551 + error(G_("incompatible gcc/plugin versions"));
94552 + return 1;
94553 + }
94554 +
94555 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
94556 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
94557 +
94558 + return 0;
94559 +}
94560 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
94561 new file mode 100644
94562 index 0000000..0408e06
94563 --- /dev/null
94564 +++ b/tools/gcc/kernexec_plugin.c
94565 @@ -0,0 +1,465 @@
94566 +/*
94567 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94568 + * Licensed under the GPL v2
94569 + *
94570 + * Note: the choice of the license means that the compilation process is
94571 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94572 + * but for the kernel it doesn't matter since it doesn't link against
94573 + * any of the gcc libraries
94574 + *
94575 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
94576 + *
94577 + * TODO:
94578 + *
94579 + * BUGS:
94580 + * - none known
94581 + */
94582 +#include "gcc-plugin.h"
94583 +#include "config.h"
94584 +#include "system.h"
94585 +#include "coretypes.h"
94586 +#include "tree.h"
94587 +#include "tree-pass.h"
94588 +#include "flags.h"
94589 +#include "intl.h"
94590 +#include "toplev.h"
94591 +#include "plugin.h"
94592 +//#include "expr.h" where are you...
94593 +#include "diagnostic.h"
94594 +#include "plugin-version.h"
94595 +#include "tm.h"
94596 +#include "function.h"
94597 +#include "basic-block.h"
94598 +#include "gimple.h"
94599 +#include "rtl.h"
94600 +#include "emit-rtl.h"
94601 +#include "tree-flow.h"
94602 +
94603 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94604 +extern rtx emit_move_insn(rtx x, rtx y);
94605 +
94606 +#if BUILDING_GCC_VERSION <= 4006
94607 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
94608 +#endif
94609 +
94610 +#if BUILDING_GCC_VERSION >= 4008
94611 +#define TODO_dump_func 0
94612 +#endif
94613 +
94614 +int plugin_is_GPL_compatible;
94615 +
94616 +static struct plugin_info kernexec_plugin_info = {
94617 + .version = "201302112000",
94618 + .help = "method=[bts|or]\tinstrumentation method\n"
94619 +};
94620 +
94621 +static unsigned int execute_kernexec_reload(void);
94622 +static unsigned int execute_kernexec_fptr(void);
94623 +static unsigned int execute_kernexec_retaddr(void);
94624 +static bool kernexec_cmodel_check(void);
94625 +
94626 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
94627 +static void (*kernexec_instrument_retaddr)(rtx);
94628 +
94629 +static struct gimple_opt_pass kernexec_reload_pass = {
94630 + .pass = {
94631 + .type = GIMPLE_PASS,
94632 + .name = "kernexec_reload",
94633 +#if BUILDING_GCC_VERSION >= 4008
94634 + .optinfo_flags = OPTGROUP_NONE,
94635 +#endif
94636 + .gate = kernexec_cmodel_check,
94637 + .execute = execute_kernexec_reload,
94638 + .sub = NULL,
94639 + .next = NULL,
94640 + .static_pass_number = 0,
94641 + .tv_id = TV_NONE,
94642 + .properties_required = 0,
94643 + .properties_provided = 0,
94644 + .properties_destroyed = 0,
94645 + .todo_flags_start = 0,
94646 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94647 + }
94648 +};
94649 +
94650 +static struct gimple_opt_pass kernexec_fptr_pass = {
94651 + .pass = {
94652 + .type = GIMPLE_PASS,
94653 + .name = "kernexec_fptr",
94654 +#if BUILDING_GCC_VERSION >= 4008
94655 + .optinfo_flags = OPTGROUP_NONE,
94656 +#endif
94657 + .gate = kernexec_cmodel_check,
94658 + .execute = execute_kernexec_fptr,
94659 + .sub = NULL,
94660 + .next = NULL,
94661 + .static_pass_number = 0,
94662 + .tv_id = TV_NONE,
94663 + .properties_required = 0,
94664 + .properties_provided = 0,
94665 + .properties_destroyed = 0,
94666 + .todo_flags_start = 0,
94667 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94668 + }
94669 +};
94670 +
94671 +static struct rtl_opt_pass kernexec_retaddr_pass = {
94672 + .pass = {
94673 + .type = RTL_PASS,
94674 + .name = "kernexec_retaddr",
94675 +#if BUILDING_GCC_VERSION >= 4008
94676 + .optinfo_flags = OPTGROUP_NONE,
94677 +#endif
94678 + .gate = kernexec_cmodel_check,
94679 + .execute = execute_kernexec_retaddr,
94680 + .sub = NULL,
94681 + .next = NULL,
94682 + .static_pass_number = 0,
94683 + .tv_id = TV_NONE,
94684 + .properties_required = 0,
94685 + .properties_provided = 0,
94686 + .properties_destroyed = 0,
94687 + .todo_flags_start = 0,
94688 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
94689 + }
94690 +};
94691 +
94692 +static bool kernexec_cmodel_check(void)
94693 +{
94694 + tree section;
94695 +
94696 + if (ix86_cmodel != CM_KERNEL)
94697 + return false;
94698 +
94699 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
94700 + if (!section || !TREE_VALUE(section))
94701 + return true;
94702 +
94703 + section = TREE_VALUE(TREE_VALUE(section));
94704 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
94705 + return true;
94706 +
94707 + return false;
94708 +}
94709 +
94710 +/*
94711 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
94712 + */
94713 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
94714 +{
94715 + gimple asm_movabs_stmt;
94716 +
94717 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
94718 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
94719 + gimple_asm_set_volatile(asm_movabs_stmt, true);
94720 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
94721 + update_stmt(asm_movabs_stmt);
94722 +}
94723 +
94724 +/*
94725 + * find all asm() stmts that clobber r10 and add a reload of r10
94726 + */
94727 +static unsigned int execute_kernexec_reload(void)
94728 +{
94729 + basic_block bb;
94730 +
94731 + // 1. loop through BBs and GIMPLE statements
94732 + FOR_EACH_BB(bb) {
94733 + gimple_stmt_iterator gsi;
94734 +
94735 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94736 + // gimple match: __asm__ ("" : : : "r10");
94737 + gimple asm_stmt;
94738 + size_t nclobbers;
94739 +
94740 + // is it an asm ...
94741 + asm_stmt = gsi_stmt(gsi);
94742 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
94743 + continue;
94744 +
94745 + // ... clobbering r10
94746 + nclobbers = gimple_asm_nclobbers(asm_stmt);
94747 + while (nclobbers--) {
94748 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
94749 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
94750 + continue;
94751 + kernexec_reload_fptr_mask(&gsi);
94752 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
94753 + break;
94754 + }
94755 + }
94756 + }
94757 +
94758 + return 0;
94759 +}
94760 +
94761 +/*
94762 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
94763 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
94764 + */
94765 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
94766 +{
94767 + gimple assign_intptr, assign_new_fptr, call_stmt;
94768 + tree intptr, old_fptr, new_fptr, kernexec_mask;
94769 +
94770 + call_stmt = gsi_stmt(*gsi);
94771 + old_fptr = gimple_call_fn(call_stmt);
94772 +
94773 + // create temporary unsigned long variable used for bitops and cast fptr to it
94774 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
94775 +#if BUILDING_GCC_VERSION <= 4007
94776 + add_referenced_var(intptr);
94777 + mark_sym_for_renaming(intptr);
94778 +#endif
94779 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
94780 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94781 + update_stmt(assign_intptr);
94782 +
94783 + // apply logical or to temporary unsigned long and bitmask
94784 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
94785 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
94786 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
94787 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94788 + update_stmt(assign_intptr);
94789 +
94790 + // cast temporary unsigned long back to a temporary fptr variable
94791 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
94792 +#if BUILDING_GCC_VERSION <= 4007
94793 + add_referenced_var(new_fptr);
94794 + mark_sym_for_renaming(new_fptr);
94795 +#endif
94796 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
94797 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
94798 + update_stmt(assign_new_fptr);
94799 +
94800 + // replace call stmt fn with the new fptr
94801 + gimple_call_set_fn(call_stmt, new_fptr);
94802 + update_stmt(call_stmt);
94803 +}
94804 +
94805 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
94806 +{
94807 + gimple asm_or_stmt, call_stmt;
94808 + tree old_fptr, new_fptr, input, output;
94809 +#if BUILDING_GCC_VERSION <= 4007
94810 + VEC(tree, gc) *inputs = NULL;
94811 + VEC(tree, gc) *outputs = NULL;
94812 +#else
94813 + vec<tree, va_gc> *inputs = NULL;
94814 + vec<tree, va_gc> *outputs = NULL;
94815 +#endif
94816 +
94817 + call_stmt = gsi_stmt(*gsi);
94818 + old_fptr = gimple_call_fn(call_stmt);
94819 +
94820 + // create temporary fptr variable
94821 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
94822 +#if BUILDING_GCC_VERSION <= 4007
94823 + add_referenced_var(new_fptr);
94824 + mark_sym_for_renaming(new_fptr);
94825 +#endif
94826 +
94827 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
94828 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
94829 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
94830 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
94831 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
94832 +#if BUILDING_GCC_VERSION <= 4007
94833 + VEC_safe_push(tree, gc, inputs, input);
94834 + VEC_safe_push(tree, gc, outputs, output);
94835 +#else
94836 + vec_safe_push(inputs, input);
94837 + vec_safe_push(outputs, output);
94838 +#endif
94839 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
94840 + gimple_asm_set_volatile(asm_or_stmt, true);
94841 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
94842 + update_stmt(asm_or_stmt);
94843 +
94844 + // replace call stmt fn with the new fptr
94845 + gimple_call_set_fn(call_stmt, new_fptr);
94846 + update_stmt(call_stmt);
94847 +}
94848 +
94849 +/*
94850 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
94851 + */
94852 +static unsigned int execute_kernexec_fptr(void)
94853 +{
94854 + basic_block bb;
94855 +
94856 + // 1. loop through BBs and GIMPLE statements
94857 + FOR_EACH_BB(bb) {
94858 + gimple_stmt_iterator gsi;
94859 +
94860 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94861 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
94862 + tree fn;
94863 + gimple call_stmt;
94864 +
94865 + // is it a call ...
94866 + call_stmt = gsi_stmt(gsi);
94867 + if (!is_gimple_call(call_stmt))
94868 + continue;
94869 + fn = gimple_call_fn(call_stmt);
94870 + if (TREE_CODE(fn) == ADDR_EXPR)
94871 + continue;
94872 + if (TREE_CODE(fn) != SSA_NAME)
94873 + gcc_unreachable();
94874 +
94875 + // ... through a function pointer
94876 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
94877 + fn = SSA_NAME_VAR(fn);
94878 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
94879 + debug_tree(fn);
94880 + gcc_unreachable();
94881 + }
94882 + }
94883 + fn = TREE_TYPE(fn);
94884 + if (TREE_CODE(fn) != POINTER_TYPE)
94885 + continue;
94886 + fn = TREE_TYPE(fn);
94887 + if (TREE_CODE(fn) != FUNCTION_TYPE)
94888 + continue;
94889 +
94890 + kernexec_instrument_fptr(&gsi);
94891 +
94892 +//debug_tree(gimple_call_fn(call_stmt));
94893 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94894 + }
94895 + }
94896 +
94897 + return 0;
94898 +}
94899 +
94900 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
94901 +static void kernexec_instrument_retaddr_bts(rtx insn)
94902 +{
94903 + rtx btsq;
94904 + rtvec argvec, constraintvec, labelvec;
94905 + int line;
94906 +
94907 + // create asm volatile("btsq $63,(%%rsp)":::)
94908 + argvec = rtvec_alloc(0);
94909 + constraintvec = rtvec_alloc(0);
94910 + labelvec = rtvec_alloc(0);
94911 + line = expand_location(RTL_LOCATION(insn)).line;
94912 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
94913 + MEM_VOLATILE_P(btsq) = 1;
94914 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
94915 + emit_insn_before(btsq, insn);
94916 +}
94917 +
94918 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
94919 +static void kernexec_instrument_retaddr_or(rtx insn)
94920 +{
94921 + rtx orq;
94922 + rtvec argvec, constraintvec, labelvec;
94923 + int line;
94924 +
94925 + // create asm volatile("orq %%r10,(%%rsp)":::)
94926 + argvec = rtvec_alloc(0);
94927 + constraintvec = rtvec_alloc(0);
94928 + labelvec = rtvec_alloc(0);
94929 + line = expand_location(RTL_LOCATION(insn)).line;
94930 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
94931 + MEM_VOLATILE_P(orq) = 1;
94932 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
94933 + emit_insn_before(orq, insn);
94934 +}
94935 +
94936 +/*
94937 + * find all asm level function returns and forcibly set the highest bit of the return address
94938 + */
94939 +static unsigned int execute_kernexec_retaddr(void)
94940 +{
94941 + rtx insn;
94942 +
94943 + // 1. find function returns
94944 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
94945 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
94946 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
94947 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
94948 + rtx body;
94949 +
94950 + // is it a retn
94951 + if (!JUMP_P(insn))
94952 + continue;
94953 + body = PATTERN(insn);
94954 + if (GET_CODE(body) == PARALLEL)
94955 + body = XVECEXP(body, 0, 0);
94956 + if (!ANY_RETURN_P(body))
94957 + continue;
94958 + kernexec_instrument_retaddr(insn);
94959 + }
94960 +
94961 +// print_simple_rtl(stderr, get_insns());
94962 +// print_rtl(stderr, get_insns());
94963 +
94964 + return 0;
94965 +}
94966 +
94967 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94968 +{
94969 + const char * const plugin_name = plugin_info->base_name;
94970 + const int argc = plugin_info->argc;
94971 + const struct plugin_argument * const argv = plugin_info->argv;
94972 + int i;
94973 + struct register_pass_info kernexec_reload_pass_info = {
94974 + .pass = &kernexec_reload_pass.pass,
94975 + .reference_pass_name = "ssa",
94976 + .ref_pass_instance_number = 1,
94977 + .pos_op = PASS_POS_INSERT_AFTER
94978 + };
94979 + struct register_pass_info kernexec_fptr_pass_info = {
94980 + .pass = &kernexec_fptr_pass.pass,
94981 + .reference_pass_name = "ssa",
94982 + .ref_pass_instance_number = 1,
94983 + .pos_op = PASS_POS_INSERT_AFTER
94984 + };
94985 + struct register_pass_info kernexec_retaddr_pass_info = {
94986 + .pass = &kernexec_retaddr_pass.pass,
94987 + .reference_pass_name = "pro_and_epilogue",
94988 + .ref_pass_instance_number = 1,
94989 + .pos_op = PASS_POS_INSERT_AFTER
94990 + };
94991 +
94992 + if (!plugin_default_version_check(version, &gcc_version)) {
94993 + error(G_("incompatible gcc/plugin versions"));
94994 + return 1;
94995 + }
94996 +
94997 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
94998 +
94999 + if (TARGET_64BIT == 0)
95000 + return 0;
95001 +
95002 + for (i = 0; i < argc; ++i) {
95003 + if (!strcmp(argv[i].key, "method")) {
95004 + if (!argv[i].value) {
95005 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95006 + continue;
95007 + }
95008 + if (!strcmp(argv[i].value, "bts")) {
95009 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
95010 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
95011 + } else if (!strcmp(argv[i].value, "or")) {
95012 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
95013 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
95014 + fix_register("r10", 1, 1);
95015 + } else
95016 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
95017 + continue;
95018 + }
95019 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95020 + }
95021 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
95022 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
95023 +
95024 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
95025 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
95026 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
95027 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
95028 +
95029 + return 0;
95030 +}
95031 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
95032 new file mode 100644
95033 index 0000000..b5395ba
95034 --- /dev/null
95035 +++ b/tools/gcc/latent_entropy_plugin.c
95036 @@ -0,0 +1,327 @@
95037 +/*
95038 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
95039 + * Licensed under the GPL v2
95040 + *
95041 + * Note: the choice of the license means that the compilation process is
95042 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95043 + * but for the kernel it doesn't matter since it doesn't link against
95044 + * any of the gcc libraries
95045 + *
95046 + * gcc plugin to help generate a little bit of entropy from program state,
95047 + * used during boot in the kernel
95048 + *
95049 + * TODO:
95050 + * - add ipa pass to identify not explicitly marked candidate functions
95051 + * - mix in more program state (function arguments/return values, loop variables, etc)
95052 + * - more instrumentation control via attribute parameters
95053 + *
95054 + * BUGS:
95055 + * - LTO needs -flto-partition=none for now
95056 + */
95057 +#include "gcc-plugin.h"
95058 +#include "config.h"
95059 +#include "system.h"
95060 +#include "coretypes.h"
95061 +#include "tree.h"
95062 +#include "tree-pass.h"
95063 +#include "flags.h"
95064 +#include "intl.h"
95065 +#include "toplev.h"
95066 +#include "plugin.h"
95067 +//#include "expr.h" where are you...
95068 +#include "diagnostic.h"
95069 +#include "plugin-version.h"
95070 +#include "tm.h"
95071 +#include "function.h"
95072 +#include "basic-block.h"
95073 +#include "gimple.h"
95074 +#include "rtl.h"
95075 +#include "emit-rtl.h"
95076 +#include "tree-flow.h"
95077 +#include "langhooks.h"
95078 +
95079 +#if BUILDING_GCC_VERSION >= 4008
95080 +#define TODO_dump_func 0
95081 +#endif
95082 +
95083 +int plugin_is_GPL_compatible;
95084 +
95085 +static tree latent_entropy_decl;
95086 +
95087 +static struct plugin_info latent_entropy_plugin_info = {
95088 + .version = "201303102320",
95089 + .help = NULL
95090 +};
95091 +
95092 +static unsigned int execute_latent_entropy(void);
95093 +static bool gate_latent_entropy(void);
95094 +
95095 +static struct gimple_opt_pass latent_entropy_pass = {
95096 + .pass = {
95097 + .type = GIMPLE_PASS,
95098 + .name = "latent_entropy",
95099 +#if BUILDING_GCC_VERSION >= 4008
95100 + .optinfo_flags = OPTGROUP_NONE,
95101 +#endif
95102 + .gate = gate_latent_entropy,
95103 + .execute = execute_latent_entropy,
95104 + .sub = NULL,
95105 + .next = NULL,
95106 + .static_pass_number = 0,
95107 + .tv_id = TV_NONE,
95108 + .properties_required = PROP_gimple_leh | PROP_cfg,
95109 + .properties_provided = 0,
95110 + .properties_destroyed = 0,
95111 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
95112 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
95113 + }
95114 +};
95115 +
95116 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
95117 +{
95118 + if (TREE_CODE(*node) != FUNCTION_DECL) {
95119 + *no_add_attrs = true;
95120 + error("%qE attribute only applies to functions", name);
95121 + }
95122 + return NULL_TREE;
95123 +}
95124 +
95125 +static struct attribute_spec latent_entropy_attr = {
95126 + .name = "latent_entropy",
95127 + .min_length = 0,
95128 + .max_length = 0,
95129 + .decl_required = true,
95130 + .type_required = false,
95131 + .function_type_required = false,
95132 + .handler = handle_latent_entropy_attribute,
95133 +#if BUILDING_GCC_VERSION >= 4007
95134 + .affects_type_identity = false
95135 +#endif
95136 +};
95137 +
95138 +static void register_attributes(void *event_data, void *data)
95139 +{
95140 + register_attribute(&latent_entropy_attr);
95141 +}
95142 +
95143 +static bool gate_latent_entropy(void)
95144 +{
95145 + tree latent_entropy_attr;
95146 +
95147 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
95148 + return latent_entropy_attr != NULL_TREE;
95149 +}
95150 +
95151 +static unsigned HOST_WIDE_INT seed;
95152 +static unsigned HOST_WIDE_INT get_random_const(void)
95153 +{
95154 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
95155 + return seed;
95156 +}
95157 +
95158 +static enum tree_code get_op(tree *rhs)
95159 +{
95160 + static enum tree_code op;
95161 + unsigned HOST_WIDE_INT random_const;
95162 +
95163 + random_const = get_random_const();
95164 +
95165 + switch (op) {
95166 + case BIT_XOR_EXPR:
95167 + op = PLUS_EXPR;
95168 + break;
95169 +
95170 + case PLUS_EXPR:
95171 + if (rhs) {
95172 + op = LROTATE_EXPR;
95173 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
95174 + break;
95175 + }
95176 +
95177 + case LROTATE_EXPR:
95178 + default:
95179 + op = BIT_XOR_EXPR;
95180 + break;
95181 + }
95182 + if (rhs)
95183 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
95184 + return op;
95185 +}
95186 +
95187 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
95188 +{
95189 + gimple_stmt_iterator gsi;
95190 + gimple assign;
95191 + tree addxorrol, rhs;
95192 + enum tree_code op;
95193 +
95194 + op = get_op(&rhs);
95195 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
95196 + assign = gimple_build_assign(local_entropy, addxorrol);
95197 +#if BUILDING_GCC_VERSION <= 4007
95198 + find_referenced_vars_in(assign);
95199 +#endif
95200 +//debug_bb(bb);
95201 + gsi = gsi_after_labels(bb);
95202 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
95203 + update_stmt(assign);
95204 +}
95205 +
95206 +static void perturb_latent_entropy(basic_block bb, tree rhs)
95207 +{
95208 + gimple_stmt_iterator gsi;
95209 + gimple assign;
95210 + tree addxorrol, temp;
95211 +
95212 + // 1. create temporary copy of latent_entropy
95213 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
95214 +#if BUILDING_GCC_VERSION <= 4007
95215 + add_referenced_var(temp);
95216 + mark_sym_for_renaming(temp);
95217 +#endif
95218 +
95219 + // 2. read...
95220 + assign = gimple_build_assign(temp, latent_entropy_decl);
95221 +#if BUILDING_GCC_VERSION <= 4007
95222 + find_referenced_vars_in(assign);
95223 +#endif
95224 + gsi = gsi_after_labels(bb);
95225 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95226 + update_stmt(assign);
95227 +
95228 + // 3. ...modify...
95229 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
95230 + assign = gimple_build_assign(temp, addxorrol);
95231 +#if BUILDING_GCC_VERSION <= 4007
95232 + find_referenced_vars_in(assign);
95233 +#endif
95234 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95235 + update_stmt(assign);
95236 +
95237 + // 4. ...write latent_entropy
95238 + assign = gimple_build_assign(latent_entropy_decl, temp);
95239 +#if BUILDING_GCC_VERSION <= 4007
95240 + find_referenced_vars_in(assign);
95241 +#endif
95242 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95243 + update_stmt(assign);
95244 +}
95245 +
95246 +static unsigned int execute_latent_entropy(void)
95247 +{
95248 + basic_block bb;
95249 + gimple assign;
95250 + gimple_stmt_iterator gsi;
95251 + tree local_entropy;
95252 +
95253 + if (!latent_entropy_decl) {
95254 + struct varpool_node *node;
95255 +
95256 +#if BUILDING_GCC_VERSION <= 4007
95257 + for (node = varpool_nodes; node; node = node->next) {
95258 + tree var = node->decl;
95259 +#else
95260 + FOR_EACH_VARIABLE(node) {
95261 + tree var = node->symbol.decl;
95262 +#endif
95263 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
95264 + continue;
95265 + latent_entropy_decl = var;
95266 +// debug_tree(var);
95267 + break;
95268 + }
95269 + if (!latent_entropy_decl) {
95270 +// debug_tree(current_function_decl);
95271 + return 0;
95272 + }
95273 + }
95274 +
95275 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
95276 +
95277 + // 1. create local entropy variable
95278 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
95279 +#if BUILDING_GCC_VERSION <= 4007
95280 + add_referenced_var(local_entropy);
95281 + mark_sym_for_renaming(local_entropy);
95282 +#endif
95283 +
95284 + // 2. initialize local entropy variable
95285 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
95286 + if (dom_info_available_p(CDI_DOMINATORS))
95287 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
95288 + gsi = gsi_start_bb(bb);
95289 +
95290 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
95291 +// gimple_set_location(assign, loc);
95292 +#if BUILDING_GCC_VERSION <= 4007
95293 + find_referenced_vars_in(assign);
95294 +#endif
95295 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95296 + update_stmt(assign);
95297 + bb = bb->next_bb;
95298 +
95299 + // 3. instrument each BB with an operation on the local entropy variable
95300 + while (bb != EXIT_BLOCK_PTR) {
95301 + perturb_local_entropy(bb, local_entropy);
95302 + bb = bb->next_bb;
95303 + };
95304 +
95305 + // 4. mix local entropy into the global entropy variable
95306 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
95307 + return 0;
95308 +}
95309 +
95310 +static void start_unit_callback(void *gcc_data, void *user_data)
95311 +{
95312 + tree latent_entropy_type;
95313 +
95314 +#if BUILDING_GCC_VERSION >= 4007
95315 + seed = get_random_seed(false);
95316 +#else
95317 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
95318 + seed *= seed;
95319 +#endif
95320 +
95321 + if (in_lto_p)
95322 + return;
95323 +
95324 + // extern volatile u64 latent_entropy
95325 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
95326 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
95327 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
95328 +
95329 + TREE_STATIC(latent_entropy_decl) = 1;
95330 + TREE_PUBLIC(latent_entropy_decl) = 1;
95331 + TREE_USED(latent_entropy_decl) = 1;
95332 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
95333 + DECL_EXTERNAL(latent_entropy_decl) = 1;
95334 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
95335 + DECL_INITIAL(latent_entropy_decl) = NULL;
95336 + lang_hooks.decls.pushdecl(latent_entropy_decl);
95337 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
95338 +// varpool_finalize_decl(latent_entropy_decl);
95339 +// varpool_mark_needed_node(latent_entropy_decl);
95340 +}
95341 +
95342 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95343 +{
95344 + const char * const plugin_name = plugin_info->base_name;
95345 + struct register_pass_info latent_entropy_pass_info = {
95346 + .pass = &latent_entropy_pass.pass,
95347 + .reference_pass_name = "optimized",
95348 + .ref_pass_instance_number = 1,
95349 + .pos_op = PASS_POS_INSERT_BEFORE
95350 + };
95351 +
95352 + if (!plugin_default_version_check(version, &gcc_version)) {
95353 + error(G_("incompatible gcc/plugin versions"));
95354 + return 1;
95355 + }
95356 +
95357 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
95358 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
95359 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
95360 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
95361 +
95362 + return 0;
95363 +}
95364 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
95365 new file mode 100644
95366 index 0000000..7982a0c
95367 --- /dev/null
95368 +++ b/tools/gcc/size_overflow_hash.data
95369 @@ -0,0 +1,5893 @@
95370 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
95371 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
95372 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
95373 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
95374 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
95375 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
95376 +padzero_55 padzero 1 55 &sel_read_policyvers_55
95377 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
95378 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
95379 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
95380 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
95381 +load_msg_95 load_msg 2 95 NULL
95382 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
95383 +init_q_132 init_q 4 132 NULL
95384 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
95385 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
95386 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
95387 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
95388 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
95389 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
95390 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
95391 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
95392 +br_port_info_size_268 br_port_info_size 0 268 NULL
95393 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
95394 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
95395 +syslog_print_307 syslog_print 2 307 NULL
95396 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
95397 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
95398 +next_node_allowed_318 next_node_allowed 1 318 NULL
95399 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
95400 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
95401 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
95402 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
95403 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
95404 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
95405 +pidlist_resize_496 pidlist_resize 2 496 NULL
95406 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
95407 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
95408 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
95409 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
95410 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
95411 +dle_count_543 dle_count 0 543 NULL
95412 +devres_alloc_551 devres_alloc 2 551 NULL
95413 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
95414 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
95415 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
95416 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
95417 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
95418 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
95419 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
95420 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
95421 +isp1760_register_628 isp1760_register 1-2 628 NULL
95422 +clone_split_bio_633 clone_split_bio 6 633 NULL
95423 +remap_to_cache_640 remap_to_cache 3 640 NULL
95424 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
95425 +unlink_queued_645 unlink_queued 3-4 645 NULL
95426 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
95427 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
95428 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
95429 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
95430 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
95431 +disk_max_parts_719 disk_max_parts 0 719 NULL
95432 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
95433 +dvb_video_write_754 dvb_video_write 3 754 NULL
95434 +if_writecmd_815 if_writecmd 2 815 NULL
95435 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
95436 +read_fifo_826 read_fifo 3 826 NULL
95437 +um_idi_read_850 um_idi_read 3 850 NULL
95438 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
95439 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
95440 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
95441 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
95442 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
95443 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
95444 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
95445 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
95446 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
95447 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
95448 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
95449 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
95450 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
95451 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
95452 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
95453 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
95454 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
95455 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
95456 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
95457 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
95458 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
95459 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
95460 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
95461 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
95462 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
95463 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
95464 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
95465 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
95466 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
95467 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
95468 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
95469 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
95470 +nested_get_page_1252 nested_get_page 2 1252 NULL
95471 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
95472 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
95473 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
95474 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
95475 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
95476 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
95477 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
95478 +ffs_1322 ffs 0 1322 NULL
95479 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
95480 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
95481 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
95482 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
95483 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
95484 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
95485 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
95486 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
95487 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
95488 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
95489 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
95490 +zone_page_state_1393 zone_page_state 0 1393 NULL
95491 +file_read_actor_1401 file_read_actor 4 1401 NULL
95492 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
95493 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
95494 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
95495 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
95496 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
95497 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
95498 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
95499 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
95500 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
95501 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
95502 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
95503 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
95504 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
95505 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
95506 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
95507 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
95508 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
95509 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
95510 +rmap_add_1677 rmap_add 3 1677 NULL
95511 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
95512 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
95513 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
95514 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
95515 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
95516 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
95517 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
95518 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
95519 +cosa_write_1774 cosa_write 3 1774 NULL
95520 +update_macheader_1775 update_macheader 7 1775 NULL
95521 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
95522 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
95523 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
95524 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
95525 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
95526 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
95527 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
95528 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
95529 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
95530 +read_swap_header_1957 read_swap_header 0 1957 NULL
95531 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
95532 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
95533 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
95534 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
95535 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
95536 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
95537 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
95538 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
95539 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
95540 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
95541 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
95542 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
95543 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
95544 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
95545 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
95546 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
95547 +audit_expand_2098 audit_expand 2 2098 NULL
95548 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
95549 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
95550 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
95551 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
95552 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
95553 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
95554 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
95555 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
95556 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
95557 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
95558 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
95559 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
95560 +u32_array_read_2219 u32_array_read 3 2219 NULL
95561 +vhci_write_2224 vhci_write 3 2224 NULL
95562 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
95563 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
95564 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
95565 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
95566 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
95567 +do_update_counters_2259 do_update_counters 4 2259 NULL
95568 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
95569 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
95570 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
95571 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
95572 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
95573 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
95574 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
95575 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
95576 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
95577 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
95578 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
95579 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
95580 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
95581 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
95582 +raid1_size_2419 raid1_size 0-2 2419 NULL
95583 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
95584 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
95585 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
95586 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
95587 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
95588 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
95589 +update_pmkid_2481 update_pmkid 4 2481 NULL
95590 +wiphy_new_2482 wiphy_new 2 2482 NULL
95591 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
95592 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
95593 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
95594 +dm_write_2513 dm_write 3 2513 NULL
95595 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
95596 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
95597 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
95598 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
95599 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
95600 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
95601 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
95602 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
95603 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
95604 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
95605 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
95606 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
95607 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
95608 +__next_cpu_2782 __next_cpu 1 2782 NULL
95609 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
95610 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
95611 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
95612 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
95613 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
95614 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
95615 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
95616 +mq_map_2871 mq_map 2 2871 NULL
95617 +nla_padlen_2883 nla_padlen 1 2883 NULL
95618 +cmm_write_2896 cmm_write 3 2896 NULL
95619 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
95620 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
95621 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
95622 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
95623 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
95624 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
95625 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
95626 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
95627 +depth_write_3021 depth_write 3 3021 NULL
95628 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
95629 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
95630 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
95631 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
95632 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
95633 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
95634 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
95635 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
95636 +free_coherent_3082 free_coherent 4-2 3082 NULL
95637 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
95638 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
95639 +rb_alloc_3102 rb_alloc 1 3102 NULL
95640 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
95641 +print_time_3132 print_time 0 3132 NULL
95642 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
95643 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
95644 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
95645 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
95646 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
95647 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
95648 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
95649 +alloc_context_3194 alloc_context 1 3194 NULL
95650 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
95651 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
95652 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
95653 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
95654 +key_key_read_3241 key_key_read 3 3241 NULL
95655 +number_3243 number 0 3243 NULL
95656 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
95657 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
95658 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
95659 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
95660 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
95661 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
95662 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
95663 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
95664 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
95665 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
95666 +scnprintf_3360 scnprintf 0-2 3360 NULL
95667 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
95668 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
95669 +send_stream_3397 send_stream 4 3397 NULL
95670 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
95671 +msix_map_region_3411 msix_map_region 3 3411 NULL
95672 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
95673 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
95674 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
95675 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
95676 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
95677 +map_single_3449 map_single 0-2 3449 NULL
95678 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
95679 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
95680 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
95681 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
95682 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
95683 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
95684 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
95685 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
95686 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
95687 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
95688 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
95689 +evtchn_read_3569 evtchn_read 3 3569 NULL
95690 +vc_resize_3585 vc_resize 2-3 3585 NULL
95691 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
95692 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
95693 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
95694 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
95695 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
95696 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 NULL
95697 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
95698 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
95699 +create_irq_3703 create_irq 0 3703 NULL nohasharray
95700 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
95701 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
95702 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
95703 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
95704 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
95705 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
95706 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
95707 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
95708 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
95709 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
95710 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
95711 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
95712 +get_fd_set_3866 get_fd_set 1 3866 NULL
95713 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
95714 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
95715 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
95716 +nvram_write_3894 nvram_write 3 3894 NULL
95717 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
95718 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
95719 +vcs_write_3910 vcs_write 3 3910 NULL
95720 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
95721 +do_add_counters_3992 do_add_counters 3 3992 NULL
95722 +userspace_status_4004 userspace_status 4 4004 NULL
95723 +mei_write_4005 mei_write 3 4005 NULL nohasharray
95724 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
95725 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
95726 +mm_populate_4016 mm_populate 1 4016 NULL
95727 +blk_end_request_4024 blk_end_request 3 4024 NULL
95728 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
95729 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
95730 +read_file_queues_4078 read_file_queues 3 4078 NULL
95731 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
95732 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
95733 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
95734 +tm6000_read_4151 tm6000_read 3 4151 NULL
95735 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
95736 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
95737 +get_alua_req_4166 get_alua_req 3 4166 NULL
95738 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
95739 +read_file_bool_4180 read_file_bool 3 4180 NULL
95740 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
95741 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
95742 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
95743 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
95744 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
95745 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
95746 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
95747 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
95748 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
95749 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
95750 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
95751 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
95752 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
95753 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
95754 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
95755 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
95756 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
95757 +memparse_4444 memparse 0 4444 NULL
95758 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
95759 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
95760 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
95761 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
95762 +set_link_security_4502 set_link_security 4 4502 NULL
95763 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
95764 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
95765 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
95766 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
95767 +tty_register_device_4544 tty_register_device 2 4544 NULL
95768 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
95769 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
95770 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
95771 +bch_alloc_4593 bch_alloc 1 4593 NULL
95772 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
95773 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
95774 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
95775 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
95776 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
95777 +kone_receive_4690 kone_receive 4 4690 NULL
95778 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
95779 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
95780 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
95781 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
95782 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
95783 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
95784 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
95785 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
95786 +create_subvol_4791 create_subvol 4 4791 NULL
95787 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
95788 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
95789 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
95790 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
95791 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
95792 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
95793 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
95794 +sys_ipc_4889 sys_ipc 3 4889 NULL
95795 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
95796 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
95797 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
95798 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
95799 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
95800 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
95801 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
95802 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
95803 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
95804 +do_mincore_5018 do_mincore 0-1 5018 NULL
95805 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
95806 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
95807 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
95808 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
95809 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
95810 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
95811 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
95812 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
95813 +sound_write_5102 sound_write 3 5102 NULL
95814 +clear_dirty_5105 clear_dirty 3 5105 NULL
95815 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
95816 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
95817 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
95818 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
95819 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
95820 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
95821 +skb_network_header_5203 skb_network_header 0 5203 NULL
95822 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
95823 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
95824 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
95825 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
95826 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
95827 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
95828 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
95829 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
95830 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
95831 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
95832 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
95833 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
95834 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
95835 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
95836 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
95837 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
95838 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
95839 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
95840 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
95841 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
95842 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
95843 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
95844 +tty_write_5494 tty_write 3 5494 NULL
95845 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
95846 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
95847 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
95848 +spidev_message_5518 spidev_message 3 5518 NULL
95849 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
95850 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
95851 +le_readq_5557 le_readq 0 5557 NULL
95852 +inw_5558 inw 0 5558 NULL
95853 +fir16_create_5574 fir16_create 3 5574 NULL
95854 +bioset_create_5580 bioset_create 1 5580 NULL
95855 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
95856 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
95857 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
95858 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
95859 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
95860 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
95861 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
95862 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
95863 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
95864 +get_arg_5694 get_arg 3 5694 NULL
95865 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
95866 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
95867 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
95868 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
95869 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
95870 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
95871 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
95872 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
95873 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
95874 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
95875 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
95876 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
95877 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
95878 +setup_req_5848 setup_req 3 5848 NULL
95879 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
95880 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
95881 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
95882 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
95883 +port_show_regs_5904 port_show_regs 3 5904 NULL
95884 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
95885 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
95886 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
95887 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
95888 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
95889 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
95890 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
95891 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
95892 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
95893 +native_pte_val_5978 native_pte_val 0 5978 NULL
95894 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
95895 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
95896 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
95897 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
95898 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
95899 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
95900 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
95901 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
95902 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
95903 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
95904 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
95905 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
95906 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
95907 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
95908 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
95909 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
95910 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
95911 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
95912 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
95913 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
95914 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
95915 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
95916 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
95917 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
95918 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
95919 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
95920 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
95921 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
95922 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
95923 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
95924 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
95925 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
95926 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
95927 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
95928 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
95929 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
95930 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
95931 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
95932 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
95933 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
95934 +mei_read_6507 mei_read 3 6507 NULL
95935 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
95936 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
95937 +wdm_read_6549 wdm_read 3 6549 NULL
95938 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
95939 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
95940 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
95941 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
95942 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
95943 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
95944 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
95945 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
95946 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
95947 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
95948 +mpeg_read_6708 mpeg_read 3 6708 NULL
95949 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
95950 +video_proc_write_6724 video_proc_write 3 6724 NULL
95951 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
95952 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
95953 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
95954 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
95955 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
95956 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
95957 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
95958 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
95959 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
95960 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
95961 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
95962 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
95963 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
95964 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
95965 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
95966 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
95967 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
95968 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
95969 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
95970 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
95971 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
95972 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
95973 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
95974 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
95975 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
95976 +request_key_async_6990 request_key_async 4 6990 NULL
95977 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
95978 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
95979 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
95980 +wimax_msg_7030 wimax_msg 4 7030 NULL
95981 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
95982 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
95983 +event_enable_read_7074 event_enable_read 3 7074 NULL
95984 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
95985 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
95986 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
95987 +check_header_7108 check_header 0 7108 NULL
95988 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
95989 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
95990 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
95991 +get_param_h_7247 get_param_h 0 7247 NULL
95992 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
95993 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
95994 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
95995 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
95996 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
95997 +mgmt_control_7349 mgmt_control 3 7349 NULL
95998 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
95999 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
96000 +hweight_long_7388 hweight_long 0-1 7388 NULL
96001 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
96002 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
96003 +readb_7401 readb 0 7401 NULL
96004 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
96005 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
96006 +numa_emulation_7466 numa_emulation 2 7466 NULL
96007 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
96008 +garp_request_join_7471 garp_request_join 4 7471 NULL
96009 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
96010 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
96011 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
96012 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
96013 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
96014 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
96015 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
96016 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
96017 +groups_alloc_7614 groups_alloc 1 7614 NULL
96018 +sg_virt_7616 sg_virt 0 7616 NULL
96019 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
96020 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
96021 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
96022 +dev_write_7708 dev_write 3 7708 NULL
96023 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
96024 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
96025 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
96026 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
96027 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
96028 +ioread32be_7773 ioread32be 0 7773 NULL
96029 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
96030 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
96031 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
96032 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
96033 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
96034 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
96035 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
96036 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
96037 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
96038 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
96039 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
96040 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
96041 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
96042 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
96043 +sys_mbind_7990 sys_mbind 5 7990 NULL
96044 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
96045 +vcs_read_8017 vcs_read 3 8017 NULL
96046 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
96047 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
96048 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
96049 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
96050 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
96051 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
96052 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
96053 +venus_lookup_8121 venus_lookup 4 8121 NULL
96054 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
96055 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
96056 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
96057 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
96058 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
96059 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
96060 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
96061 +play_iframe_8219 play_iframe 3 8219 NULL
96062 +create_log_8225 create_log 2 8225 NULL nohasharray
96063 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
96064 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
96065 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
96066 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
96067 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
96068 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
96069 +init_cdev_8274 init_cdev 1 8274 NULL
96070 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
96071 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
96072 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
96073 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
96074 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
96075 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
96076 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
96077 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
96078 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
96079 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
96080 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
96081 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
96082 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
96083 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
96084 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
96085 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
96086 +dev_config_8506 dev_config 3 8506 NULL
96087 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
96088 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
96089 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
96090 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
96091 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
96092 +profile_remove_8556 profile_remove 3 8556 NULL
96093 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
96094 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
96095 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
96096 +tower_write_8580 tower_write 3 8580 NULL
96097 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
96098 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
96099 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
96100 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
96101 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
96102 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
96103 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
96104 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
96105 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
96106 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
96107 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
96108 +arcfb_write_8702 arcfb_write 3 8702 NULL
96109 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
96110 +init_header_8703 init_header 0 8703 &i_size_read_8703
96111 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
96112 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
96113 +f_dupfd_8730 f_dupfd 1 8730 NULL
96114 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
96115 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
96116 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
96117 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
96118 +sys_prctl_8766 sys_prctl 4 8766 NULL
96119 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
96120 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
96121 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
96122 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
96123 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
96124 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
96125 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
96126 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
96127 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
96128 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
96129 +clear_bitset_8840 clear_bitset 2 8840 NULL
96130 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
96131 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
96132 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
96133 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
96134 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
96135 +layout_commit_8926 layout_commit 3 8926 NULL
96136 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
96137 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
96138 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
96139 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
96140 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
96141 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
96142 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
96143 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
96144 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
96145 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
96146 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
96147 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
96148 +nla_put_9042 nla_put 3 9042 NULL
96149 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
96150 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
96151 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
96152 +string_9080 string 0 9080 NULL
96153 +create_queues_9088 create_queues 2-3 9088 NULL
96154 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
96155 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
96156 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
96157 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
96158 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
96159 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
96160 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
96161 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
96162 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
96163 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
96164 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
96165 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
96166 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
96167 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
96168 +get_pfn_9207 get_pfn 1 9207 NULL
96169 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
96170 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
96171 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
96172 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
96173 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
96174 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
96175 +flakey_status_9274 flakey_status 5 9274 NULL
96176 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
96177 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
96178 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
96179 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
96180 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
96181 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
96182 +read_9397 read 3 9397 NULL
96183 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
96184 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
96185 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
96186 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
96187 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
96188 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
96189 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
96190 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
96191 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
96192 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
96193 +lp_write_9511 lp_write 3 9511 NULL
96194 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
96195 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
96196 +read_file_dma_9530 read_file_dma 3 9530 NULL
96197 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
96198 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
96199 +fw_node_create_9559 fw_node_create 2 9559 NULL
96200 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
96201 +kobj_map_9566 kobj_map 2-3 9566 NULL
96202 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
96203 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
96204 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
96205 +do_sync_9604 do_sync 1 9604 NULL
96206 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
96207 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
96208 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
96209 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
96210 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
96211 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
96212 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
96213 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
96214 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
96215 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
96216 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
96217 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
96218 +is_hole_9694 is_hole 2 9694 NULL nohasharray
96219 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
96220 +fnb_9703 fnb 2-3 9703 NULL
96221 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
96222 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
96223 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
96224 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
96225 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
96226 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
96227 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
96228 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
96229 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
96230 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
96231 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
96232 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
96233 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
96234 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
96235 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
96236 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
96237 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
96238 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
96239 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
96240 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
96241 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
96242 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
96243 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
96244 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
96245 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
96246 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
96247 +read_file_misc_9948 read_file_misc 3 9948 NULL
96248 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
96249 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
96250 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
96251 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
96252 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
96253 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
96254 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
96255 +handle_request_10024 handle_request 9 10024 NULL
96256 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
96257 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
96258 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
96259 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
96260 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
96261 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
96262 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
96263 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
96264 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
96265 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
96266 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
96267 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
96268 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
96269 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
96270 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
96271 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
96272 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
96273 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
96274 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
96275 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
96276 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
96277 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
96278 +read_emulate_10310 read_emulate 2-4 10310 NULL
96279 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
96280 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
96281 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
96282 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
96283 +get_dump_page_10338 get_dump_page 1 10338 NULL
96284 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
96285 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
96286 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
96287 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
96288 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
96289 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
96290 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
96291 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
96292 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
96293 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
96294 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
96295 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
96296 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
96297 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
96298 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
96299 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
96300 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
96301 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
96302 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
96303 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
96304 +otp_read_10594 otp_read 2-4-5 10594 NULL
96305 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
96306 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
96307 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
96308 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
96309 +parport_write_10669 parport_write 0 10669 NULL
96310 +inl_10708 inl 0 10708 NULL nohasharray
96311 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
96312 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
96313 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
96314 +spi_sync_10731 spi_sync 0 10731 NULL
96315 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
96316 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
96317 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
96318 +sys_syslog_10746 sys_syslog 3 10746 NULL
96319 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
96320 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
96321 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
96322 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
96323 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
96324 +sys_bind_10799 sys_bind 3 10799 NULL
96325 +compat_put_int_10828 compat_put_int 1 10828 NULL
96326 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
96327 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
96328 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
96329 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
96330 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
96331 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
96332 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
96333 +get_scq_10897 get_scq 2 10897 NULL
96334 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
96335 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
96336 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
96337 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
96338 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
96339 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
96340 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
96341 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
96342 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
96343 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
96344 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
96345 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
96346 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
96347 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
96348 +count_argc_11083 count_argc 0 11083 NULL
96349 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
96350 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
96351 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
96352 +page_offset_11120 page_offset 0 11120 NULL
96353 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
96354 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
96355 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
96356 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
96357 +__swab16p_11220 __swab16p 0 11220 NULL
96358 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
96359 +mmap_region_11247 mmap_region 0-2 11247 NULL
96360 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
96361 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
96362 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
96363 +cru_detect_11272 cru_detect 1 11272 NULL
96364 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
96365 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
96366 +construct_key_11329 construct_key 3 11329 NULL nohasharray
96367 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
96368 +next_segment_11330 next_segment 0-2-1 11330 NULL
96369 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
96370 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
96371 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
96372 +sel_write_create_11353 sel_write_create 3 11353 NULL
96373 +handle_unit_11355 handle_unit 0-1 11355 NULL
96374 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
96375 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
96376 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
96377 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
96378 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
96379 +str_to_user_11411 str_to_user 2 11411 NULL
96380 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
96381 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
96382 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
96383 +trace_options_read_11419 trace_options_read 3 11419 NULL
96384 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
96385 +prepare_image_11424 prepare_image 0 11424 NULL
96386 +vring_size_11426 vring_size 0-1-2 11426 NULL
96387 +bttv_read_11432 bttv_read 3 11432 NULL
96388 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
96389 +swp_offset_11475 swp_offset 0 11475 NULL
96390 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
96391 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
96392 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
96393 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
96394 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
96395 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
96396 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
96397 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
96398 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
96399 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
96400 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
96401 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
96402 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
96403 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
96404 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
96405 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
96406 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
96407 +split_11691 split 2 11691 NULL
96408 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
96409 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
96410 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
96411 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
96412 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
96413 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
96414 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
96415 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
96416 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
96417 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
96418 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
96419 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
96420 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
96421 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
96422 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
96423 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
96424 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
96425 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
96426 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
96427 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
96428 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
96429 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
96430 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
96431 +atmel_read16_11981 atmel_read16 0 11981 NULL
96432 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
96433 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
96434 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
96435 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
96436 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
96437 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
96438 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
96439 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
96440 +set_powered_12129 set_powered 4 12129 NULL
96441 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
96442 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
96443 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
96444 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
96445 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
96446 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
96447 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
96448 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
96449 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
96450 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
96451 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
96452 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
96453 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
96454 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
96455 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
96456 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
96457 +receive_copy_12216 receive_copy 3 12216 NULL
96458 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
96459 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
96460 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
96461 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
96462 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
96463 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
96464 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
96465 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
96466 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
96467 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
96468 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
96469 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
96470 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
96471 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
96472 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
96473 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
96474 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
96475 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
96476 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
96477 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
96478 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
96479 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
96480 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
96481 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
96482 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
96483 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
96484 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
96485 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
96486 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
96487 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
96488 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
96489 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
96490 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
96491 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
96492 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
96493 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
96494 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
96495 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
96496 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
96497 +wb_create_12651 wb_create 1 12651 NULL
96498 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
96499 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
96500 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
96501 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
96502 +ivtv_write_12721 ivtv_write 3 12721 NULL
96503 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
96504 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
96505 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
96506 +listxattr_12769 listxattr 3 12769 NULL
96507 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
96508 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
96509 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
96510 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
96511 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
96512 +readq_12825 readq 0 12825 NULL
96513 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
96514 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
96515 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
96516 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
96517 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
96518 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
96519 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
96520 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
96521 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
96522 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
96523 +bm_status_write_12964 bm_status_write 3 12964 NULL
96524 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
96525 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
96526 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
96527 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
96528 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
96529 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
96530 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
96531 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
96532 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
96533 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
96534 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
96535 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
96536 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
96537 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
96538 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
96539 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
96540 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
96541 +blk_update_request_13146 blk_update_request 3 13146 NULL
96542 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
96543 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
96544 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
96545 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
96546 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
96547 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
96548 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
96549 +comedi_read_13199 comedi_read 3 13199 NULL
96550 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
96551 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
96552 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
96553 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
96554 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
96555 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
96556 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
96557 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
96558 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
96559 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
96560 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
96561 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
96562 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
96563 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
96564 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
96565 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
96566 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
96567 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
96568 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
96569 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
96570 +cache_ctr_13364 cache_ctr 2 13364 NULL
96571 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
96572 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
96573 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
96574 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
96575 +sky2_receive_13407 sky2_receive 2 13407 NULL
96576 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
96577 +keyring_read_13438 keyring_read 3 13438 NULL
96578 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
96579 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
96580 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
96581 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
96582 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
96583 +core_status_13515 core_status 4 13515 NULL
96584 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
96585 +bm_init_13529 bm_init 2 13529 NULL
96586 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL
96587 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
96588 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
96589 +sys_madvise_13569 sys_madvise 1 13569 NULL
96590 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
96591 +cache_write_13589 cache_write 3 13589 NULL
96592 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
96593 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
96594 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
96595 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
96596 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
96597 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
96598 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
96599 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
96600 +packet_snd_13634 packet_snd 3 13634 NULL
96601 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
96602 +cache_downcall_13666 cache_downcall 3 13666 NULL
96603 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
96604 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
96605 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
96606 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
96607 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
96608 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
96609 +random_read_13815 random_read 3 13815 NULL
96610 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
96611 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
96612 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
96613 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
96614 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
96615 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
96616 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
96617 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
96618 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
96619 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
96620 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
96621 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
96622 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
96623 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
96624 +com90xx_found_13974 com90xx_found 3 13974 NULL
96625 +qcam_read_13977 qcam_read 3 13977 NULL
96626 +dsp_read_13980 dsp_read 2 13980 NULL
96627 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
96628 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
96629 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
96630 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
96631 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
96632 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
96633 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
96634 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
96635 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
96636 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
96637 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
96638 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
96639 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
96640 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
96641 +em_canid_change_14150 em_canid_change 3 14150 NULL
96642 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
96643 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
96644 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
96645 +alloc_async_14208 alloc_async 1 14208 NULL
96646 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
96647 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
96648 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
96649 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
96650 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
96651 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
96652 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
96653 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
96654 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
96655 +rr_status_14293 rr_status 5 14293 NULL
96656 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
96657 +oo_objects_14319 oo_objects 0 14319 NULL
96658 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
96659 +scsi2int_14358 scsi2int 0 14358 NULL
96660 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
96661 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
96662 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
96663 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
96664 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
96665 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
96666 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
96667 +block_size_14443 block_size 0 14443 NULL
96668 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
96669 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
96670 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
96671 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
96672 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
96673 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
96674 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
96675 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
96676 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
96677 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
96678 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
96679 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
96680 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
96681 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
96682 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
96683 +dbJoin_14644 dbJoin 0 14644 NULL
96684 +profile_replace_14652 profile_replace 3 14652 NULL
96685 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
96686 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
96687 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
96688 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
96689 +get_bio_block_14714 get_bio_block 0 14714 NULL
96690 +vfd_write_14717 vfd_write 3 14717 NULL
96691 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
96692 +raid1_resize_14740 raid1_resize 2 14740 NULL
96693 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
96694 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
96695 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
96696 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
96697 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
96698 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
96699 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
96700 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
96701 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
96702 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
96703 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
96704 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
96705 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
96706 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
96707 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
96708 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
96709 +unifi_read_14899 unifi_read 3 14899 NULL
96710 +krealloc_14908 krealloc 2 14908 NULL
96711 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
96712 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
96713 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
96714 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
96715 +queue_cnt_14951 queue_cnt 0 14951 NULL
96716 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
96717 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
96718 +setkey_14987 setkey 3 14987 NULL nohasharray
96719 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
96720 +vmap_15025 vmap 2 15025 NULL
96721 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
96722 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
96723 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
96724 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
96725 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
96726 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
96727 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
96728 +start_port_15124 start_port 0 15124 NULL
96729 +memchr_15126 memchr 0 15126 NULL
96730 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
96731 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
96732 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
96733 +reserve_resources_15194 reserve_resources 3 15194 NULL
96734 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
96735 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
96736 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
96737 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
96738 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
96739 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
96740 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
96741 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
96742 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
96743 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
96744 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
96745 +ioread16_15342 ioread16 0 15342 NULL
96746 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
96747 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
96748 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
96749 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
96750 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
96751 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
96752 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
96753 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
96754 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
96755 +get_modalias_15406 get_modalias 2 15406 NULL
96756 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
96757 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
96758 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
96759 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
96760 +memweight_15450 memweight 2 15450 NULL
96761 +vmalloc_15464 vmalloc 1 15464 NULL
96762 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
96763 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
96764 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
96765 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
96766 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
96767 +persistent_status_15574 persistent_status 4 15574 NULL
96768 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
96769 +vme_user_write_15587 vme_user_write 3 15587 NULL
96770 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
96771 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
96772 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
96773 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
96774 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
96775 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
96776 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
96777 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
96778 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
96779 +fs_path_add_15648 fs_path_add 3 15648 NULL
96780 +xsd_read_15653 xsd_read 3 15653 NULL
96781 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
96782 +unix_bind_15668 unix_bind 3 15668 NULL
96783 +dm_read_15674 dm_read 3 15674 NULL
96784 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
96785 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
96786 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
96787 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
96788 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
96789 +do_test_15766 do_test 1 15766 NULL
96790 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
96791 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
96792 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
96793 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
96794 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
96795 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
96796 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
96797 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
96798 +table_size_15851 table_size 0-1-2 15851 NULL
96799 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
96800 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
96801 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
96802 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
96803 +native_read_msr_15905 native_read_msr 0 15905 NULL
96804 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
96805 +power_read_15939 power_read 3 15939 NULL
96806 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
96807 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
96808 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
96809 +frame_alloc_15981 frame_alloc 4 15981 NULL
96810 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
96811 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
96812 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
96813 +got_frame_16028 got_frame 2 16028 NULL
96814 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
96815 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
96816 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
96817 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
96818 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
96819 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
96820 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
96821 +fsm_init_16134 fsm_init 2 16134 NULL
96822 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
96823 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
96824 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
96825 +mapping_level_16188 mapping_level 2 16188 NULL
96826 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
96827 +create_table_16213 create_table 2 16213 NULL
96828 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
96829 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
96830 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
96831 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
96832 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
96833 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
96834 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
96835 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
96836 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
96837 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
96838 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
96839 +account_16283 account 0-2-4 16283 NULL nohasharray
96840 +mirror_status_16283 mirror_status 5 16283 &account_16283
96841 +retry_instruction_16285 retry_instruction 2 16285 NULL
96842 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
96843 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
96844 +wb_map_16301 wb_map 2 16301 NULL
96845 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
96846 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
96847 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
96848 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
96849 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
96850 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
96851 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
96852 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
96853 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
96854 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
96855 +raid10_resize_16537 raid10_resize 2 16537 NULL
96856 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
96857 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
96858 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
96859 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
96860 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
96861 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
96862 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
96863 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
96864 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
96865 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
96866 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
96867 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
96868 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
96869 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
96870 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
96871 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
96872 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
96873 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
96874 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
96875 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
96876 +st_write_16874 st_write 3 16874 NULL
96877 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
96878 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
96879 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
96880 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
96881 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
96882 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
96883 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
96884 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
96885 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
96886 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
96887 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
96888 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
96889 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
96890 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
96891 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
96892 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
96893 +mac_address_string_17091 mac_address_string 0 17091 NULL
96894 +entry_length_17093 entry_length 0 17093 NULL
96895 +sys_preadv_17100 sys_preadv 3 17100 NULL
96896 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
96897 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
96898 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
96899 +sep_read_17161 sep_read 3 17161 NULL
96900 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
96901 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
96902 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
96903 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
96904 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
96905 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
96906 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
96907 +to_oblock_17254 to_oblock 0-1 17254 NULL
96908 +unpack_value_17259 unpack_value 1 17259 NULL
96909 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
96910 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
96911 +alloc_ep_17269 alloc_ep 1 17269 NULL
96912 +pg_read_17276 pg_read 3 17276 NULL
96913 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
96914 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
96915 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
96916 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
96917 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
96918 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
96919 +skb_pad_17302 skb_pad 2 17302 NULL
96920 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
96921 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
96922 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
96923 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
96924 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
96925 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
96926 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
96927 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
96928 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
96929 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
96930 +compat_cmd_17465 compat_cmd 2 17465 NULL
96931 +probe_bios_17467 probe_bios 1 17467 NULL
96932 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
96933 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
96934 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
96935 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
96936 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
96937 +copy_from_user_17559 copy_from_user 3 17559 NULL
96938 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
96939 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
96940 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
96941 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
96942 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
96943 +osst_execute_17607 osst_execute 7-6 17607 NULL
96944 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
96945 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
96946 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
96947 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
96948 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
96949 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
96950 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
96951 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
96952 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
96953 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
96954 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
96955 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
96956 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
96957 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
96958 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
96959 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
96960 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
96961 +count_leafs_17842 count_leafs 0 17842 NULL
96962 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
96963 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
96964 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
96965 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
96966 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
96967 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
96968 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
96969 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
96970 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
96971 +recover_head_17904 recover_head 3 17904 NULL
96972 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
96973 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
96974 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
96975 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
96976 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
96977 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
96978 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
96979 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
96980 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
96981 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
96982 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
96983 +fill_read_18019 fill_read 0 18019 NULL
96984 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
96985 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
96986 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
96987 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
96988 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
96989 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
96990 +packet_came_18072 packet_came 3 18072 NULL
96991 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
96992 +get_vm_area_18080 get_vm_area 1 18080 NULL
96993 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
96994 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
96995 +svc_getnl_18120 svc_getnl 0 18120 NULL
96996 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
96997 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
96998 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
96999 +_has_tag_18169 _has_tag 2 18169 NULL
97000 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
97001 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
97002 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
97003 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
97004 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
97005 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
97006 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
97007 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
97008 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
97009 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
97010 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
97011 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
97012 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
97013 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
97014 +um_idi_write_18293 um_idi_write 3 18293 NULL
97015 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
97016 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
97017 +vga_r_18310 vga_r 0 18310 NULL
97018 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
97019 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
97020 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
97021 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
97022 +ep_io_18367 ep_io 0 18367 NULL
97023 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
97024 +__video_register_device_18399 __video_register_device 3 18399 NULL
97025 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 NULL
97026 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
97027 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
97028 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
97029 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
97030 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
97031 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
97032 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
97033 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
97034 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
97035 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
97036 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
97037 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
97038 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
97039 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
97040 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
97041 +debug_output_18575 debug_output 3 18575 NULL
97042 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
97043 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
97044 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL
97045 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
97046 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
97047 +from_buffer_18625 from_buffer 3 18625 NULL
97048 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
97049 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
97050 +unmap_page_18665 unmap_page 2-3 18665 NULL
97051 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
97052 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
97053 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
97054 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
97055 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
97056 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
97057 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
97058 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
97059 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
97060 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
97061 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
97062 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
97063 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
97064 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
97065 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
97066 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
97067 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
97068 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
97069 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
97070 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
97071 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
97072 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
97073 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
97074 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
97075 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
97076 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
97077 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
97078 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
97079 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
97080 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
97081 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
97082 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
97083 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
97084 +huge_page_size_19008 huge_page_size 0 19008 NULL
97085 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
97086 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
97087 +revalidate_19043 revalidate 2 19043 NULL
97088 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
97089 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
97090 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
97091 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
97092 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
97093 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
97094 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
97095 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
97096 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
97097 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
97098 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
97099 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
97100 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
97101 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
97102 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
97103 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
97104 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
97105 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
97106 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
97107 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
97108 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
97109 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
97110 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
97111 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
97112 +qc_capture_19298 qc_capture 3 19298 NULL
97113 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
97114 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
97115 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
97116 +debug_read_19322 debug_read 3 19322 NULL
97117 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
97118 +read_zero_19366 read_zero 3 19366 NULL
97119 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
97120 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
97121 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
97122 +__phys_addr_19434 __phys_addr 0 19434 NULL
97123 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
97124 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
97125 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
97126 +sky2_read16_19475 sky2_read16 0 19475 NULL
97127 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
97128 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
97129 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
97130 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
97131 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
97132 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
97133 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
97134 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
97135 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
97136 +nfsd_read_19568 nfsd_read 5 19568 NULL
97137 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
97138 +bm_status_read_19583 bm_status_read 3 19583 NULL
97139 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
97140 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
97141 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
97142 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
97143 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
97144 +bio_detain_19690 bio_detain 2 19690 NULL
97145 +read_reg_19723 read_reg 0 19723 NULL
97146 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
97147 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
97148 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
97149 +p9_client_read_19750 p9_client_read 5 19750 NULL
97150 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
97151 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
97152 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
97153 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
97154 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
97155 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
97156 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
97157 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
97158 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
97159 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
97160 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
97161 +__nla_put_19857 __nla_put 3 19857 NULL
97162 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
97163 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
97164 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
97165 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
97166 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
97167 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
97168 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
97169 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
97170 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
97171 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
97172 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
97173 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
97174 +team_options_register_20091 team_options_register 3 20091 NULL
97175 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
97176 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
97177 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
97178 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
97179 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
97180 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
97181 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
97182 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
97183 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
97184 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
97185 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
97186 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
97187 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
97188 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
97189 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
97190 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
97191 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
97192 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
97193 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
97194 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
97195 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
97196 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
97197 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
97198 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
97199 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
97200 +read_buf_20469 read_buf 2 20469 NULL
97201 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
97202 +fast_user_write_20494 fast_user_write 5 20494 NULL
97203 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
97204 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
97205 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
97206 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
97207 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
97208 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
97209 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
97210 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
97211 +venus_create_20555 venus_create 4 20555 NULL
97212 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
97213 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
97214 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
97215 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
97216 +lirc_write_20604 lirc_write 3 20604 NULL
97217 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
97218 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
97219 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
97220 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
97221 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
97222 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
97223 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
97224 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
97225 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
97226 +cpumask_size_20683 cpumask_size 0 20683 NULL
97227 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
97228 +gru_vtop_20689 gru_vtop 2 20689 NULL
97229 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
97230 +__maestro_read_20700 __maestro_read 0 20700 NULL
97231 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
97232 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
97233 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
97234 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
97235 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
97236 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
97237 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
97238 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
97239 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
97240 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
97241 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
97242 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
97243 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
97244 +sys_sendto_20809 sys_sendto 6 20809 NULL
97245 +strndup_user_20819 strndup_user 2 20819 NULL
97246 +calc_layout_20829 calc_layout 3 20829 NULL
97247 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
97248 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
97249 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
97250 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
97251 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
97252 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
97253 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
97254 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
97255 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
97256 +htable_bits_20933 htable_bits 0 20933 NULL
97257 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
97258 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
97259 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
97260 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
97261 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
97262 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
97263 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
97264 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
97265 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
97266 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
97267 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
97268 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
97269 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
97270 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
97271 +multipath_status_21094 multipath_status 5 21094 NULL
97272 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
97273 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
97274 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
97275 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
97276 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
97277 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
97278 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
97279 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
97280 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
97281 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
97282 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
97283 +input_ff_create_21240 input_ff_create 2 21240 NULL
97284 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
97285 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
97286 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
97287 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
97288 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
97289 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
97290 +add_res_range_21310 add_res_range 4 21310 NULL
97291 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
97292 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
97293 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
97294 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
97295 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
97296 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
97297 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
97298 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
97299 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
97300 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
97301 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
97302 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
97303 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
97304 +concat_writev_21451 concat_writev 3 21451 NULL
97305 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
97306 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
97307 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
97308 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
97309 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
97310 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
97311 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
97312 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
97313 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
97314 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
97315 +validate_nnode_21638 validate_nnode 0 21638 NULL
97316 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
97317 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
97318 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
97319 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
97320 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
97321 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
97322 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
97323 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
97324 +vm_brk_21739 vm_brk 1 21739 NULL
97325 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
97326 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
97327 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
97328 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
97329 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
97330 +min_odd_21802 min_odd 0 21802 NULL
97331 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
97332 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
97333 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
97334 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
97335 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
97336 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
97337 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
97338 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
97339 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
97340 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
97341 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
97342 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
97343 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
97344 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
97345 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
97346 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
97347 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
97348 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
97349 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
97350 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
97351 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
97352 +write_opcode_22082 write_opcode 2 22082 NULL
97353 +mem_rw_22085 mem_rw 3 22085 NULL
97354 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
97355 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
97356 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
97357 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
97358 +compat_insn_22142 compat_insn 2 22142 NULL
97359 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
97360 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
97361 +fls_22210 fls 0 22210 NULL
97362 +mem_write_22232 mem_write 3 22232 NULL
97363 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
97364 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
97365 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
97366 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
97367 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
97368 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
97369 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
97370 +extend_brk_22301 extend_brk 0 22301 NULL
97371 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
97372 +get_segment_base_22324 get_segment_base 0 22324 NULL
97373 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
97374 +atomic_read_22342 atomic_read 0 22342 NULL
97375 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
97376 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
97377 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
97378 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
97379 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
97380 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
97381 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
97382 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
97383 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
97384 +zoran_write_22404 zoran_write 3 22404 NULL
97385 +queue_reply_22416 queue_reply 3 22416 NULL
97386 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
97387 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
97388 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
97389 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
97390 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
97391 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
97392 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
97393 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
97394 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
97395 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
97396 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
97397 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
97398 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
97399 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
97400 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
97401 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
97402 +snapshot_read_22601 snapshot_read 3 22601 NULL
97403 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
97404 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
97405 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
97406 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
97407 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
97408 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
97409 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
97410 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
97411 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
97412 +map_22700 map 2 22700 NULL
97413 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
97414 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
97415 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
97416 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
97417 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
97418 +print_frame_22769 print_frame 0 22769 NULL
97419 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
97420 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
97421 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
97422 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
97423 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
97424 +create_attr_set_22861 create_attr_set 1 22861 NULL
97425 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
97426 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
97427 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
97428 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
97429 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
97430 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
97431 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
97432 +vme_get_size_22964 vme_get_size 0 22964 NULL
97433 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
97434 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
97435 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
97436 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
97437 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
97438 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
97439 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
97440 +st_status_23032 st_status 5 23032 NULL
97441 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
97442 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
97443 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
97444 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
97445 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
97446 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
97447 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
97448 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
97449 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
97450 +fls_long_23096 fls_long 0 23096 NULL
97451 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
97452 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
97453 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
97454 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
97455 +__clear_user_23118 __clear_user 0 23118 NULL
97456 +dm_write_async_23120 dm_write_async 3 23120 NULL
97457 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
97458 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
97459 +read_file_ani_23161 read_file_ani 3 23161 NULL
97460 +ioremap_23172 ioremap 1-2 23172 NULL
97461 +usblp_write_23178 usblp_write 3 23178 NULL
97462 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
97463 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
97464 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
97465 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
97466 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
97467 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
97468 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
97469 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
97470 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
97471 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
97472 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
97473 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
97474 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
97475 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
97476 +doc_probe_23285 doc_probe 1 23285 NULL
97477 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
97478 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
97479 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
97480 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
97481 +page_readlink_23346 page_readlink 3 23346 NULL
97482 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
97483 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
97484 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
97485 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
97486 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
97487 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
97488 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
97489 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
97490 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
97491 +event_filter_read_23494 event_filter_read 3 23494 NULL
97492 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
97493 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
97494 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
97495 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
97496 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
97497 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
97498 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
97499 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
97500 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
97501 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
97502 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
97503 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
97504 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
97505 +sInW_23663 sInW 0 23663 NULL
97506 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
97507 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
97508 +cx18_read_23699 cx18_read 3 23699 NULL
97509 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
97510 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
97511 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
97512 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
97513 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
97514 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
97515 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
97516 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
97517 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
97518 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
97519 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
97520 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
97521 +p54_init_common_23850 p54_init_common 1 23850 NULL
97522 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
97523 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
97524 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
97525 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
97526 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
97527 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
97528 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
97529 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
97530 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
97531 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
97532 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
97533 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
97534 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
97535 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
97536 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
97537 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
97538 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
97539 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
97540 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
97541 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
97542 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
97543 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
97544 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
97545 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
97546 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
97547 +mpu401_read_24126 mpu401_read 3 24126 NULL
97548 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
97549 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
97550 +set_discard_24162 set_discard 2 24162 NULL
97551 +adu_read_24177 adu_read 3 24177 NULL
97552 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
97553 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
97554 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
97555 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
97556 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
97557 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
97558 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
97559 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
97560 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
97561 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
97562 +thin_status_24278 thin_status 5 24278 NULL
97563 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
97564 +msg_size_24288 msg_size 0 24288 NULL
97565 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
97566 +map_page_24298 map_page 3-4 24298 NULL
97567 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
97568 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
97569 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
97570 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
97571 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
97572 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
97573 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
97574 +igetword_24373 igetword 0 24373 NULL
97575 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
97576 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
97577 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
97578 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
97579 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
97580 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
97581 +smk_user_access_24440 smk_user_access 3 24440 NULL
97582 +page_address_24444 page_address 0 24444 NULL
97583 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
97584 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
97585 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
97586 +pd_video_read_24510 pd_video_read 3 24510 NULL
97587 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
97588 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
97589 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
97590 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
97591 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
97592 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
97593 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
97594 +count_preds_24600 count_preds 0 24600 NULL
97595 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
97596 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
97597 +context_alloc_24645 context_alloc 3 24645 NULL
97598 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
97599 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
97600 +read_fs_24717 read_fs 0 24717 NULL
97601 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
97602 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
97603 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
97604 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
97605 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
97606 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
97607 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
97608 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
97609 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
97610 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
97611 +cache_read_24790 cache_read 3 24790 NULL
97612 +unpack_str_24798 unpack_str 0 24798 NULL
97613 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
97614 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
97615 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
97616 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
97617 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
97618 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
97619 +setup_buffering_24872 setup_buffering 3 24872 NULL
97620 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
97621 +queues_read_24877 queues_read 3 24877 NULL
97622 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
97623 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
97624 +next_token_24929 next_token 0 24929 NULL
97625 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
97626 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
97627 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
97628 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
97629 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
97630 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
97631 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
97632 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
97633 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
97634 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
97635 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
97636 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
97637 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
97638 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
97639 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
97640 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
97641 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
97642 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
97643 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
97644 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
97645 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
97646 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
97647 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
97648 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
97649 +stripe_status_25259 stripe_status 5 25259 NULL
97650 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
97651 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
97652 +vfs_writev_25278 vfs_writev 3 25278 NULL
97653 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
97654 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
97655 +help_25316 help 5 25316 NULL nohasharray
97656 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
97657 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
97658 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
97659 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
97660 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
97661 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
97662 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
97663 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
97664 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
97665 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
97666 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
97667 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
97668 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
97669 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
97670 +sb_permission_25523 sb_permission 0 25523 NULL
97671 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
97672 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
97673 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
97674 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
97675 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
97676 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
97677 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
97678 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
97679 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
97680 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
97681 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
97682 +__direct_map_25647 __direct_map 5-6 25647 NULL
97683 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
97684 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
97685 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
97686 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
97687 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
97688 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
97689 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
97690 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
97691 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
97692 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
97693 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
97694 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
97695 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
97696 +sg_read_25799 sg_read 3 25799 NULL
97697 +system_enable_read_25815 system_enable_read 3 25815 NULL
97698 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
97699 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
97700 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
97701 +parport_read_25855 parport_read 0 25855 NULL
97702 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
97703 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
97704 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
97705 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
97706 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
97707 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
97708 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
97709 +rcname_read_25919 rcname_read 3 25919 NULL
97710 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
97711 +key_flags_read_25931 key_flags_read 3 25931 NULL
97712 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
97713 +flush_25957 flush 2 25957 NULL
97714 +video_register_device_25971 video_register_device 3 25971 NULL
97715 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
97716 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
97717 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
97718 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
97719 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
97720 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
97721 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
97722 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
97723 +tun_do_read_26047 tun_do_read 5 26047 NULL
97724 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
97725 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
97726 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
97727 +skb_cow_26138 skb_cow 2 26138 NULL
97728 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
97729 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
97730 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
97731 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
97732 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
97733 +disk_devt_26180 disk_devt 0 26180 NULL
97734 +get_registers_26187 get_registers 3 26187 NULL
97735 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
97736 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
97737 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
97738 +mce_write_26201 mce_write 3 26201 NULL
97739 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
97740 +bio_split_26235 bio_split 2 26235 NULL
97741 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
97742 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
97743 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
97744 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
97745 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
97746 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
97747 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
97748 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
97749 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
97750 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
97751 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
97752 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
97753 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
97754 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
97755 +read_vmcore_26501 read_vmcore 3 26501 NULL
97756 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
97757 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
97758 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
97759 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
97760 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
97761 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
97762 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
97763 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
97764 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
97765 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
97766 +pack_value_26625 pack_value 1 26625 NULL
97767 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
97768 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
97769 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
97770 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
97771 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
97772 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
97773 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
97774 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
97775 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
97776 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
97777 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
97778 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
97779 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
97780 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
97781 +smk_write_load_26829 smk_write_load 3 26829 NULL
97782 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
97783 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
97784 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
97785 +scnprint_id_26842 scnprint_id 3 26842 NULL
97786 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
97787 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
97788 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
97789 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
97790 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
97791 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
97792 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
97793 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
97794 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
97795 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
97796 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
97797 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
97798 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
97799 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
97800 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
97801 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
97802 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
97803 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
97804 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
97805 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
97806 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
97807 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
97808 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
97809 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
97810 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
97811 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
97812 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
97813 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
97814 +pms_capture_27142 pms_capture 4 27142 NULL
97815 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
97816 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
97817 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
97818 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
97819 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
97820 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
97821 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
97822 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
97823 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
97824 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
97825 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
97826 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
97827 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
97828 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
97829 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
97830 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
97831 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
97832 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
97833 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
97834 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
97835 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
97836 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
97837 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
97838 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
97839 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
97840 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
97841 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
97842 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
97843 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
97844 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
97845 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
97846 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
97847 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
97848 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
97849 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
97850 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
97851 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
97852 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
97853 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
97854 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
97855 +qword_get_27670 qword_get 0 27670 NULL
97856 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
97857 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
97858 +evm_write_key_27715 evm_write_key 3 27715 NULL
97859 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
97860 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
97861 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
97862 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
97863 +kcalloc_27770 kcalloc 1-2 27770 NULL
97864 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
97865 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
97866 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
97867 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
97868 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
97869 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
97870 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
97871 +read_profile_27859 read_profile 3 27859 NULL
97872 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
97873 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
97874 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
97875 +gluebi_write_27905 gluebi_write 3 27905 NULL
97876 +bm_find_next_27929 bm_find_next 2 27929 NULL
97877 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
97878 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
97879 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
97880 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
97881 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
97882 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
97883 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
97884 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
97885 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
97886 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
97887 +pool_status_28055 pool_status 5 28055 NULL
97888 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
97889 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
97890 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
97891 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
97892 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
97893 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
97894 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
97895 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
97896 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
97897 +video_read_28148 video_read 3 28148 NULL
97898 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
97899 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
97900 +vread_28173 vread 0 28173 NULL
97901 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
97902 +d_path_28198 d_path 0 28198 NULL
97903 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
97904 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
97905 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
97906 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
97907 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
97908 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
97909 +usemap_size_28281 usemap_size 0 28281 NULL
97910 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
97911 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
97912 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
97913 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
97914 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
97915 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
97916 +snapshot_write_28351 snapshot_write 3 28351 NULL
97917 +sys_writev_28384 sys_writev 3 28384 NULL
97918 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
97919 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
97920 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
97921 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
97922 +__split_large_page_28429 __split_large_page 2 28429 NULL
97923 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
97924 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
97925 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
97926 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
97927 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
97928 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
97929 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
97930 +max_response_pages_28492 max_response_pages 0 28492 NULL
97931 +clear_discard_28494 clear_discard 2 28494 NULL
97932 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
97933 +__next_node_28521 __next_node 1 28521 NULL
97934 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
97935 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
97936 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
97937 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
97938 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
97939 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
97940 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
97941 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
97942 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
97943 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
97944 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
97945 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
97946 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
97947 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
97948 +_set_range_28627 _set_range 3 28627 NULL
97949 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
97950 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
97951 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
97952 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
97953 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
97954 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
97955 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
97956 +spi_execute_28736 spi_execute 5 28736 NULL
97957 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
97958 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
97959 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
97960 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
97961 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
97962 +sel_write_member_28800 sel_write_member 3 28800 NULL
97963 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
97964 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
97965 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
97966 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
97967 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
97968 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
97969 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
97970 +to_cblock_28899 to_cblock 0-1 28899 NULL
97971 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
97972 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
97973 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
97974 +push_rx_28939 push_rx 3 28939 NULL
97975 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
97976 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
97977 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
97978 +bin_uuid_28999 bin_uuid 3 28999 NULL
97979 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
97980 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
97981 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
97982 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
97983 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
97984 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
97985 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
97986 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
97987 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
97988 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
97989 +snprintf_29125 snprintf 0 29125 NULL
97990 +iov_shorten_29130 iov_shorten 0 29130 NULL
97991 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
97992 +reshape_ring_29147 reshape_ring 2 29147 NULL
97993 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
97994 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
97995 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
97996 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
97997 +__mm_populate_29204 __mm_populate 1 29204 NULL
97998 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
97999 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
98000 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
98001 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
98002 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
98003 +recover_peb_29238 recover_peb 6-7 29238 NULL
98004 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
98005 +block_div_29268 block_div 0-1-2 29268 NULL
98006 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
98007 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
98008 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
98009 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
98010 +tun_put_user_29337 tun_put_user 5 29337 NULL
98011 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
98012 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
98013 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
98014 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
98015 +mempool_create_29437 mempool_create 1 29437 NULL
98016 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
98017 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
98018 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
98019 +do_register_entry_29478 do_register_entry 4 29478 NULL
98020 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
98021 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
98022 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
98023 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
98024 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
98025 +set_brk_29551 set_brk 1 29551 NULL nohasharray
98026 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
98027 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
98028 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
98029 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
98030 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
98031 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
98032 +slots_per_page_29601 slots_per_page 0 29601 NULL
98033 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
98034 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
98035 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
98036 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
98037 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
98038 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
98039 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
98040 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
98041 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
98042 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
98043 +probes_write_29711 probes_write 3 29711 NULL
98044 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
98045 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
98046 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
98047 +dbAlloc_29794 dbAlloc 0 29794 NULL
98048 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
98049 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
98050 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
98051 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
98052 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
98053 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
98054 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
98055 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
98056 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
98057 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
98058 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
98059 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
98060 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
98061 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
98062 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
98063 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
98064 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
98065 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
98066 +drp_wmove_30043 drp_wmove 4 30043 NULL
98067 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
98068 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
98069 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
98070 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
98071 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
98072 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
98073 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
98074 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
98075 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
98076 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
98077 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
98078 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
98079 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
98080 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
98081 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
98082 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
98083 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
98084 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
98085 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
98086 +compat_readv_30273 compat_readv 3 30273 NULL
98087 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
98088 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
98089 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
98090 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
98091 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
98092 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
98093 +resource_from_user_30341 resource_from_user 3 30341 NULL
98094 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
98095 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
98096 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
98097 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
98098 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
98099 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
98100 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
98101 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
98102 +mq_create_30425 mq_create 1 30425 NULL
98103 +enable_write_30456 enable_write 3 30456 NULL
98104 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
98105 +urandom_read_30462 urandom_read 3 30462 NULL
98106 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
98107 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
98108 +write_head_30481 write_head 4 30481 NULL
98109 +adu_write_30487 adu_write 3 30487 NULL
98110 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
98111 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
98112 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
98113 +set_le_30581 set_le 4 30581 NULL
98114 +from_cblock_30582 from_cblock 0-1 30582 NULL
98115 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
98116 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
98117 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
98118 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
98119 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
98120 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
98121 +agp_remap_30665 agp_remap 2 30665 NULL
98122 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
98123 +il_free_pages_30692 il_free_pages 2 30692 NULL
98124 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
98125 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
98126 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
98127 +snapshot_status_30744 snapshot_status 5 30744 NULL
98128 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
98129 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
98130 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
98131 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
98132 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
98133 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
98134 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
98135 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
98136 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
98137 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
98138 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
98139 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
98140 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
98141 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
98142 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
98143 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
98144 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
98145 +sys_mincore_31079 sys_mincore 1 31079 NULL
98146 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
98147 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
98148 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
98149 +depth_read_31112 depth_read 3 31112 NULL
98150 +ssb_read16_31139 ssb_read16 0 31139 NULL
98151 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
98152 +size_inside_page_31141 size_inside_page 0 31141 NULL
98153 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
98154 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
98155 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
98156 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
98157 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
98158 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
98159 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
98160 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
98161 +__read_reg_31216 __read_reg 0 31216 NULL
98162 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
98163 +cyy_readb_31240 cyy_readb 0 31240 NULL
98164 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
98165 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
98166 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
98167 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
98168 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
98169 +command_file_write_31318 command_file_write 3 31318 NULL
98170 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
98171 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
98172 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
98173 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
98174 +inb_31388 inb 0 31388 NULL
98175 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
98176 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
98177 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
98178 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
98179 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
98180 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
98181 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
98182 +do_fcntl_31468 do_fcntl 3 31468 NULL
98183 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
98184 +alg_setkey_31485 alg_setkey 3 31485 NULL
98185 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
98186 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
98187 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
98188 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
98189 +hidraw_write_31536 hidraw_write 3 31536 NULL
98190 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
98191 +usbvision_read_31555 usbvision_read 3 31555 NULL
98192 +normalize_31566 normalize 0-1-2 31566 NULL
98193 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
98194 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
98195 +osst_write_31581 osst_write 3 31581 NULL
98196 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
98197 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
98198 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
98199 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
98200 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
98201 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
98202 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
98203 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
98204 +__lgread_31668 __lgread 4 31668 NULL
98205 +symbol_string_31670 symbol_string 0 31670 NULL
98206 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
98207 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
98208 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
98209 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
98210 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
98211 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
98212 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
98213 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
98214 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
98215 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
98216 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
98217 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
98218 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
98219 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
98220 +get_count_order_31800 get_count_order 0 31800 NULL
98221 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
98222 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
98223 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
98224 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
98225 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
98226 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
98227 +xattr_permission_31907 xattr_permission 0 31907 NULL
98228 +new_dir_31919 new_dir 3 31919 NULL
98229 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
98230 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
98231 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
98232 +vb2_write_31948 vb2_write 3 31948 NULL
98233 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
98234 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
98235 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
98236 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
98237 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
98238 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
98239 +calc_hmac_32010 calc_hmac 3 32010 NULL
98240 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
98241 +aead_len_32021 aead_len 0 32021 NULL
98242 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
98243 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
98244 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
98245 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
98246 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
98247 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
98248 +bio_alloc_32095 bio_alloc 2 32095 NULL
98249 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
98250 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
98251 +disk_status_32120 disk_status 4 32120 NULL
98252 +venus_link_32165 venus_link 5 32165 NULL
98253 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
98254 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
98255 +load_header_32183 load_header 0 32183 NULL
98256 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
98257 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
98258 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
98259 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
98260 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
98261 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
98262 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
98263 +hex_string_32310 hex_string 0 32310 NULL
98264 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
98265 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
98266 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
98267 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
98268 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
98269 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
98270 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
98271 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
98272 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
98273 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
98274 +log_text_32428 log_text 0 32428 NULL
98275 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
98276 +hid_input_report_32458 hid_input_report 4 32458 NULL
98277 +cache_status_32462 cache_status 5 32462 NULL
98278 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
98279 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
98280 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
98281 +disconnect_32521 disconnect 4 32521 NULL
98282 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
98283 +ilo_read_32531 ilo_read 3 32531 NULL
98284 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
98285 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
98286 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
98287 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
98288 +__first_node_32558 __first_node 0 32558 NULL
98289 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
98290 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
98291 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
98292 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
98293 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
98294 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
98295 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
98296 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
98297 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
98298 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
98299 +kvmalloc_32646 kvmalloc 1 32646 NULL
98300 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
98301 +generic_readlink_32654 generic_readlink 3 32654 NULL
98302 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
98303 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
98304 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
98305 +get_arg_page_32746 get_arg_page 2 32746 NULL
98306 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
98307 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
98308 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
98309 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
98310 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
98311 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
98312 +vga_rseq_32848 vga_rseq 0 32848 NULL
98313 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
98314 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
98315 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
98316 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
98317 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
98318 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
98319 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
98320 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
98321 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
98322 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
98323 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
98324 +compat_filldir_32999 compat_filldir 3 32999 NULL
98325 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
98326 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
98327 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
98328 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
98329 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
98330 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
98331 +alloc_tio_33077 alloc_tio 3 33077 NULL
98332 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
98333 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
98334 +write_node_33121 write_node 4 33121 NULL
98335 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
98336 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
98337 +__len_within_target_33132 __len_within_target 0 33132 NULL
98338 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
98339 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
98340 +pp_read_33210 pp_read 3 33210 NULL
98341 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
98342 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
98343 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
98344 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
98345 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
98346 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
98347 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
98348 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
98349 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
98350 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
98351 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
98352 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
98353 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
98354 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
98355 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
98356 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
98357 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
98358 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
98359 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
98360 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
98361 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
98362 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
98363 +create_entry_33479 create_entry 2 33479 NULL
98364 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
98365 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
98366 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
98367 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
98368 +res_counter_read_33499 res_counter_read 4 33499 NULL
98369 +fb_read_33506 fb_read 3 33506 NULL
98370 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
98371 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
98372 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
98373 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
98374 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
98375 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
98376 +dup_array_33551 dup_array 3 33551 NULL
98377 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
98378 +count_subheaders_33591 count_subheaders 0 33591 NULL
98379 +scsi_execute_33596 scsi_execute 5 33596 NULL
98380 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
98381 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
98382 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
98383 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
98384 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
98385 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
98386 +inw_p_33668 inw_p 0 33668 NULL
98387 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
98388 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
98389 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
98390 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
98391 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
98392 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
98393 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
98394 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
98395 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
98396 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
98397 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
98398 +Read_hfc_33755 Read_hfc 0 33755 NULL
98399 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
98400 +hashtab_create_33769 hashtab_create 3 33769 NULL
98401 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
98402 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
98403 +find_next_offset_33804 find_next_offset 3 33804 NULL
98404 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
98405 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
98406 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
98407 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
98408 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
98409 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
98410 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
98411 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
98412 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
98413 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
98414 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
98415 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
98416 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
98417 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
98418 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
98419 +ppp_write_34034 ppp_write 3 34034 NULL
98420 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
98421 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
98422 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
98423 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
98424 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
98425 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
98426 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
98427 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
98428 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
98429 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
98430 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
98431 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
98432 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
98433 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
98434 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
98435 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
98436 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
98437 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
98438 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
98439 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
98440 +__insert_34349 __insert 2-3 34349 NULL
98441 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
98442 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
98443 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
98444 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
98445 +ea_read_34378 ea_read 0 34378 NULL
98446 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
98447 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
98448 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
98449 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
98450 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
98451 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
98452 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
98453 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
98454 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
98455 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
98456 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
98457 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
98458 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
98459 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
98460 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
98461 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
98462 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
98463 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
98464 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
98465 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
98466 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
98467 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
98468 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
98469 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
98470 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
98471 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
98472 +port_print_34704 port_print 3 34704 NULL
98473 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
98474 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
98475 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
98476 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
98477 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
98478 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
98479 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
98480 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
98481 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
98482 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
98483 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
98484 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
98485 +msg_print_text_34889 msg_print_text 0 34889 NULL
98486 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
98487 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
98488 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
98489 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
98490 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
98491 +Realloc_34961 Realloc 2 34961 NULL
98492 +mq_lookup_34990 mq_lookup 2 34990 NULL
98493 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
98494 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
98495 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
98496 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
98497 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
98498 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
98499 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
98500 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
98501 +store_ifalias_35088 store_ifalias 4 35088 NULL
98502 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
98503 +capi_write_35104 capi_write 3 35104 NULL nohasharray
98504 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
98505 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
98506 +pointer_35138 pointer 0 35138 NULL
98507 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
98508 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
98509 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
98510 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
98511 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
98512 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
98513 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
98514 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
98515 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
98516 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
98517 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
98518 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
98519 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
98520 +set_fd_set_35249 set_fd_set 1 35249 NULL
98521 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
98522 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
98523 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
98524 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
98525 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
98526 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
98527 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
98528 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
98529 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
98530 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
98531 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
98532 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
98533 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
98534 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
98535 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
98536 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
98537 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
98538 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
98539 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
98540 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
98541 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
98542 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
98543 +async_setkey_35521 async_setkey 3 35521 NULL
98544 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
98545 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
98546 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
98547 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
98548 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
98549 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
98550 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
98551 +ReadZReg_35604 ReadZReg 0 35604 NULL
98552 +kernel_readv_35617 kernel_readv 3 35617 NULL
98553 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
98554 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
98555 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
98556 +store_debug_level_35652 store_debug_level 3 35652 NULL
98557 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
98558 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
98559 +dm_table_create_35687 dm_table_create 3 35687 NULL
98560 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
98561 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
98562 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
98563 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
98564 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
98565 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
98566 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
98567 +fls64_35862 fls64 0 35862 NULL
98568 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
98569 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
98570 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
98571 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
98572 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
98573 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
98574 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
98575 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
98576 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
98577 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
98578 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
98579 +acl_alloc_35979 acl_alloc 1 35979 NULL
98580 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
98581 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
98582 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
98583 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
98584 +account_shadowed_36048 account_shadowed 2 36048 NULL
98585 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
98586 +write_emulate_36065 write_emulate 2-4 36065 NULL
98587 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
98588 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
98589 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
98590 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
98591 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
98592 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
98593 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
98594 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
98595 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
98596 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
98597 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
98598 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
98599 +twl_set_36154 twl_set 2 36154 NULL
98600 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
98601 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
98602 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
98603 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
98604 +is_dirty_36223 is_dirty 2 36223 NULL
98605 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
98606 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
98607 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
98608 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
98609 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
98610 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
98611 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
98612 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
98613 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
98614 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
98615 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
98616 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
98617 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
98618 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
98619 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
98620 +lc_create_36332 lc_create 4 36332 NULL
98621 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
98622 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
98623 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
98624 +to_sector_36361 to_sector 0-1 36361 NULL
98625 +tunables_read_36385 tunables_read 3 36385 NULL
98626 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
98627 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
98628 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
98629 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
98630 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
98631 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
98632 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
98633 +get_param_l_36518 get_param_l 0 36518 NULL
98634 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
98635 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
98636 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
98637 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
98638 +get_entry_len_36549 get_entry_len 0 36549 NULL
98639 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
98640 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
98641 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
98642 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
98643 +__erst_read_36579 __erst_read 0 36579 NULL
98644 +put_cmsg_36589 put_cmsg 4 36589 NULL
98645 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
98646 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
98647 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
98648 +format_decode_36638 format_decode 0 36638 NULL
98649 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
98650 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
98651 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
98652 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
98653 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
98654 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
98655 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
98656 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
98657 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
98658 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
98659 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
98660 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
98661 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
98662 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
98663 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
98664 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
98665 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
98666 +cm_write_36858 cm_write 3 36858 NULL
98667 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
98668 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
98669 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
98670 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
98671 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
98672 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
98673 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
98674 +build_key_36931 build_key 1 36931 NULL
98675 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
98676 +write_leb_36957 write_leb 5 36957 NULL
98677 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
98678 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
98679 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
98680 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
98681 +setxattr_37006 setxattr 4 37006 NULL
98682 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
98683 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
98684 +parse_command_37079 parse_command 2 37079 NULL
98685 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
98686 +tun_get_user_37094 tun_get_user 5 37094 NULL
98687 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
98688 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
98689 +msg_word_37164 msg_word 0 37164 NULL
98690 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
98691 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
98692 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
98693 +__do_replace_37227 __do_replace 5 37227 NULL
98694 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
98695 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
98696 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
98697 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
98698 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
98699 +c101_run_37279 c101_run 2 37279 NULL
98700 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
98701 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
98702 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
98703 +send_msg_37323 send_msg 4 37323 NULL
98704 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
98705 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
98706 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
98707 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
98708 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
98709 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
98710 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
98711 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
98712 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
98713 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
98714 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
98715 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
98716 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
98717 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
98718 +__remove_37457 __remove 2 37457 NULL
98719 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
98720 +get_est_timing_37484 get_est_timing 0 37484 NULL
98721 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
98722 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
98723 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
98724 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
98725 +hdr_size_37536 hdr_size 0 37536 NULL
98726 +a2p_37544 a2p 0-1 37544 NULL
98727 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
98728 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
98729 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
98730 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
98731 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
98732 +policy_residency_37629 policy_residency 0 37629 NULL
98733 +check_pt_base_37635 check_pt_base 3 37635 NULL
98734 +alloc_fd_37637 alloc_fd 1 37637 NULL
98735 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
98736 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
98737 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
98738 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
98739 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
98740 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
98741 +nametbl_header_37698 nametbl_header 2 37698 NULL
98742 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
98743 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
98744 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
98745 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
98746 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
98747 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
98748 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
98749 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
98750 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
98751 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
98752 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
98753 +deny_write_access_37813 deny_write_access 0 37813 NULL
98754 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
98755 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
98756 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
98757 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
98758 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
98759 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
98760 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
98761 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
98762 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
98763 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
98764 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
98765 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
98766 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
98767 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
98768 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
98769 +vfs_readv_38011 vfs_readv 3 38011 NULL
98770 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
98771 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
98772 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
98773 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
98774 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
98775 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
98776 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
98777 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
98778 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
98779 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
98780 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
98781 +ep0_read_38095 ep0_read 3 38095 NULL
98782 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
98783 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
98784 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
98785 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
98786 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
98787 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
98788 +cdev_add_38176 cdev_add 2-3 38176 NULL
98789 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
98790 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
98791 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
98792 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
98793 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
98794 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
98795 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
98796 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
98797 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
98798 +from_dblock_38256 from_dblock 0-1 38256 NULL
98799 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
98800 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
98801 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
98802 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
98803 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
98804 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
98805 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
98806 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
98807 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
98808 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
98809 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
98810 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
98811 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
98812 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
98813 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
98814 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
98815 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
98816 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
98817 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
98818 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
98819 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
98820 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
98821 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
98822 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
98823 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
98824 +dev_names_read_38509 dev_names_read 3 38509 NULL
98825 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
98826 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
98827 +set_queue_count_38519 set_queue_count 0 38519 NULL
98828 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
98829 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
98830 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
98831 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
98832 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
98833 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
98834 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
98835 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
98836 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
98837 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
98838 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
98839 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
98840 +cma_create_area_38642 cma_create_area 2 38642 NULL
98841 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
98842 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
98843 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
98844 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
98845 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
98846 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
98847 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
98848 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
98849 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
98850 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
98851 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
98852 +udf_readpages_38761 udf_readpages 4 38761 NULL
98853 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
98854 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
98855 +err_decode_38804 err_decode 2 38804 NULL
98856 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
98857 +sys_select_38827 sys_select 1 38827 NULL
98858 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
98859 +direct_entry_38836 direct_entry 3 38836 NULL
98860 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
98861 +interfaces_38859 interfaces 2 38859 NULL
98862 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
98863 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
98864 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
98865 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
98866 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
98867 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
98868 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
98869 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
98870 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
98871 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
98872 +udf_new_block_38999 udf_new_block 4 38999 NULL
98873 +get_nodes_39012 get_nodes 3 39012 NULL
98874 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
98875 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
98876 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
98877 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
98878 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
98879 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
98880 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
98881 +ea_foreach_39133 ea_foreach 0 39133 NULL
98882 +generic_permission_39150 generic_permission 0 39150 NULL
98883 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
98884 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
98885 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
98886 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
98887 +init_list_set_39188 init_list_set 2-3 39188 NULL
98888 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
98889 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
98890 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
98891 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
98892 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
98893 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
98894 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
98895 +drm_order_39244 drm_order 0 39244 NULL
98896 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
98897 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
98898 +__skb_cow_39254 __skb_cow 2 39254 NULL
98899 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
98900 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
98901 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
98902 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
98903 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
98904 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
98905 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
98906 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
98907 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
98908 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
98909 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
98910 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
98911 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
98912 +__send_to_port_39386 __send_to_port 3 39386 NULL
98913 +user_power_read_39414 user_power_read 3 39414 NULL
98914 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
98915 +sys_semop_39457 sys_semop 3 39457 NULL
98916 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
98917 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
98918 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
98919 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
98920 +int_proc_write_39542 int_proc_write 3 39542 NULL
98921 +pp_write_39554 pp_write 3 39554 NULL
98922 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
98923 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
98924 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
98925 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
98926 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
98927 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
98928 +ext_depth_39607 ext_depth 0 39607 NULL
98929 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
98930 +sdio_readb_39618 sdio_readb 0 39618 NULL
98931 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
98932 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
98933 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
98934 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
98935 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
98936 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
98937 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
98938 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
98939 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
98940 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
98941 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
98942 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
98943 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
98944 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
98945 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
98946 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
98947 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
98948 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
98949 +pkt_add_39897 pkt_add 3 39897 NULL
98950 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
98951 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
98952 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
98953 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
98954 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
98955 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
98956 +__spi_async_39932 __spi_async 0 39932 NULL
98957 +__get_order_39935 __get_order 0 39935 NULL
98958 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
98959 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
98960 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
98961 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
98962 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
98963 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
98964 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
98965 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
98966 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
98967 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
98968 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
98969 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
98970 +add_tty_40055 add_tty 1 40055 NULL nohasharray
98971 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
98972 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
98973 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
98974 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
98975 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
98976 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
98977 +pt_write_40159 pt_write 3 40159 NULL
98978 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
98979 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
98980 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
98981 +allocate_probes_40204 allocate_probes 1 40204 NULL
98982 +compat_put_long_40214 compat_put_long 1 40214 NULL
98983 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
98984 +osst_read_40237 osst_read 3 40237 NULL
98985 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
98986 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
98987 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
98988 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
98989 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
98990 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
98991 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
98992 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
98993 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
98994 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
98995 +mmio_read_40348 mmio_read 4 40348 NULL
98996 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
98997 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
98998 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
98999 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
99000 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
99001 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
99002 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
99003 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
99004 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
99005 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
99006 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
99007 +tty_write_room_40495 tty_write_room 0 40495 NULL
99008 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
99009 +sg_phys_40507 sg_phys 0 40507 NULL
99010 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
99011 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
99012 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
99013 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
99014 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
99015 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
99016 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
99017 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
99018 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
99019 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
99020 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
99021 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
99022 +fops_read_40672 fops_read 3 40672 NULL
99023 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
99024 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
99025 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
99026 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
99027 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
99028 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
99029 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
99030 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
99031 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
99032 +card_send_command_40757 card_send_command 3 40757 NULL
99033 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
99034 +pg_write_40766 pg_write 3 40766 NULL
99035 +show_list_40775 show_list 3 40775 NULL
99036 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
99037 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
99038 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
99039 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
99040 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
99041 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
99042 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
99043 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
99044 +read_file_queue_40895 read_file_queue 3 40895 NULL
99045 +waiters_read_40902 waiters_read 3 40902 NULL
99046 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
99047 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
99048 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
99049 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
99050 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
99051 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
99052 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
99053 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
99054 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
99055 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
99056 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
99057 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
99058 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
99059 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
99060 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
99061 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
99062 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
99063 +dma_attach_41094 dma_attach 5-6 41094 NULL
99064 +provide_user_output_41105 provide_user_output 3 41105 NULL
99065 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
99066 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
99067 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
99068 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
99069 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
99070 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
99071 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
99072 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
99073 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
99074 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
99075 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
99076 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
99077 +erst_read_41260 erst_read 0 41260 NULL
99078 +__fprog_create_41263 __fprog_create 2 41263 NULL
99079 +alloc_context_41283 alloc_context 1 41283 NULL
99080 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
99081 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
99082 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
99083 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
99084 +kmp_init_41373 kmp_init 2 41373 NULL
99085 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
99086 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
99087 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
99088 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
99089 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
99090 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
99091 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
99092 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
99093 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
99094 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
99095 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
99096 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
99097 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
99098 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
99099 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
99100 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
99101 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
99102 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
99103 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
99104 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
99105 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
99106 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
99107 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
99108 +vga_io_r_41609 vga_io_r 0 41609 NULL
99109 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
99110 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
99111 +a2mp_send_41615 a2mp_send 4 41615 NULL
99112 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
99113 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
99114 +get_std_timing_41654 get_std_timing 0 41654 NULL
99115 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
99116 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
99117 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
99118 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
99119 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
99120 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
99121 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
99122 +fillonedir_41746 fillonedir 3 41746 NULL
99123 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
99124 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
99125 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
99126 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
99127 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
99128 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
99129 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
99130 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
99131 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
99132 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
99133 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
99134 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
99135 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
99136 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
99137 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
99138 +portnames_read_41958 portnames_read 3 41958 NULL
99139 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
99140 +dst_mtu_41969 dst_mtu 0 41969 NULL
99141 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
99142 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
99143 +lguest_map_42008 lguest_map 1-2 42008 NULL
99144 +pool_allocate_42012 pool_allocate 3 42012 NULL
99145 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
99146 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
99147 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
99148 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
99149 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
99150 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
99151 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
99152 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
99153 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
99154 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
99155 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
99156 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
99157 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
99158 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
99159 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
99160 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
99161 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
99162 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
99163 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
99164 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
99165 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
99166 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
99167 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
99168 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
99169 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
99170 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
99171 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
99172 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
99173 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
99174 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
99175 +free_cblock_42318 free_cblock 2 42318 NULL
99176 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
99177 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
99178 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
99179 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
99180 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
99181 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
99182 +krng_get_random_42420 krng_get_random 3 42420 NULL
99183 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
99184 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
99185 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
99186 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
99187 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
99188 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
99189 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
99190 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
99191 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
99192 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
99193 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
99194 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
99195 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
99196 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
99197 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
99198 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
99199 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
99200 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
99201 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
99202 +map_state_42602 map_state 1 42602 NULL nohasharray
99203 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
99204 +nd_get_link_42603 nd_get_link 0 42603 NULL
99205 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
99206 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
99207 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
99208 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
99209 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
99210 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
99211 +vb2_read_42703 vb2_read 3 42703 NULL
99212 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
99213 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
99214 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
99215 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
99216 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
99217 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
99218 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
99219 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
99220 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
99221 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
99222 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
99223 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
99224 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
99225 +set_arg_42824 set_arg 3 42824 NULL
99226 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
99227 +prandom_u32_42853 prandom_u32 0 42853 NULL
99228 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
99229 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
99230 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
99231 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
99232 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
99233 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
99234 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
99235 +hd_end_request_42904 hd_end_request 2 42904 NULL
99236 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
99237 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
99238 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
99239 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
99240 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
99241 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
99242 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
99243 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
99244 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
99245 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
99246 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
99247 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
99248 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
99249 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
99250 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
99251 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
99252 +uuid_string_43154 uuid_string 0 43154 NULL
99253 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
99254 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
99255 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
99256 +process_measurement_43190 process_measurement 0 43190 NULL
99257 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
99258 +uio_write_43202 uio_write 3 43202 NULL
99259 +iso_callback_43208 iso_callback 3 43208 NULL
99260 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
99261 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
99262 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
99263 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
99264 +fixup_leb_43256 fixup_leb 3 43256 NULL
99265 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
99266 +evtchn_write_43278 evtchn_write 3 43278 NULL
99267 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
99268 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
99269 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
99270 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
99271 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
99272 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
99273 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
99274 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
99275 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
99276 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
99277 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
99278 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
99279 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
99280 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
99281 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
99282 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
99283 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
99284 +do_readlink_43518 do_readlink 2 43518 NULL
99285 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
99286 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
99287 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
99288 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
99289 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
99290 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
99291 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
99292 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
99293 +proc_read_43614 proc_read 3 43614 NULL
99294 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
99295 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
99296 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
99297 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
99298 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
99299 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
99300 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
99301 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
99302 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
99303 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
99304 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
99305 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
99306 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
99307 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
99308 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
99309 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
99310 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
99311 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
99312 +read_flush_43851 read_flush 3 43851 NULL
99313 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
99314 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
99315 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
99316 +SendString_43928 SendString 3 43928 NULL
99317 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
99318 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
99319 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
99320 +nla_reserve_43984 nla_reserve 3 43984 NULL
99321 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
99322 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
99323 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
99324 +emit_flags_44006 emit_flags 4-3 44006 NULL
99325 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
99326 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
99327 +load_discard_44083 load_discard 3 44083 NULL
99328 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
99329 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
99330 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
99331 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
99332 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
99333 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
99334 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
99335 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
99336 +__set_free_44211 __set_free 2 44211 NULL
99337 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
99338 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
99339 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
99340 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
99341 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
99342 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
99343 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
99344 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
99345 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
99346 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
99347 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
99348 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
99349 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
99350 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
99351 +__is_discarded_44359 __is_discarded 2 44359 NULL
99352 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
99353 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
99354 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
99355 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
99356 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
99357 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
99358 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
99359 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
99360 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
99361 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
99362 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
99363 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
99364 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
99365 +spidev_write_44510 spidev_write 3 44510 NULL
99366 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
99367 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
99368 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
99369 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
99370 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
99371 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
99372 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
99373 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
99374 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
99375 +mpi_resize_44674 mpi_resize 2 44674 NULL
99376 +ts_read_44687 ts_read 3 44687 NULL
99377 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
99378 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
99379 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
99380 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
99381 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
99382 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
99383 +set_brk_44749 set_brk 1 44749 NULL
99384 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
99385 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
99386 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
99387 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
99388 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
99389 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
99390 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
99391 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
99392 +sisusb_write_44834 sisusb_write 3 44834 NULL
99393 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
99394 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
99395 +skb_availroom_44883 skb_availroom 0 44883 NULL
99396 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
99397 +do_tty_write_44896 do_tty_write 5 44896 NULL
99398 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
99399 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
99400 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
99401 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
99402 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
99403 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
99404 +sel_write_user_45060 sel_write_user 3 45060 NULL
99405 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
99406 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
99407 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
99408 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
99409 +usbdev_read_45114 usbdev_read 3 45114 NULL
99410 +send_to_tty_45141 send_to_tty 3 45141 NULL
99411 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
99412 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
99413 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
99414 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
99415 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
99416 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
99417 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
99418 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
99419 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
99420 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
99421 +add_child_45201 add_child 4 45201 NULL
99422 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
99423 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
99424 +__dirty_45228 __dirty 2 45228 NULL
99425 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
99426 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
99427 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
99428 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
99429 +pte_val_45313 pte_val 0 45313 NULL
99430 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
99431 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
99432 +keymap_store_45406 keymap_store 4 45406 NULL
99433 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
99434 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
99435 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
99436 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
99437 +__node_remap_45458 __node_remap 4 45458 NULL
99438 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
99439 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
99440 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
99441 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
99442 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
99443 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
99444 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
99445 +copy_macs_45534 copy_macs 4 45534 NULL
99446 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
99447 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
99448 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
99449 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
99450 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
99451 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
99452 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
99453 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
99454 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
99455 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
99456 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
99457 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
99458 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
99459 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
99460 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
99461 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
99462 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
99463 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
99464 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
99465 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
99466 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
99467 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
99468 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
99469 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
99470 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
99471 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
99472 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
99473 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
99474 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
99475 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
99476 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
99477 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
99478 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
99479 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
99480 +isdn_write_45863 isdn_write 3 45863 NULL
99481 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
99482 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
99483 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
99484 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
99485 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
99486 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
99487 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
99488 +alloc_mr_45935 alloc_mr 1 45935 NULL
99489 +split_large_page_45941 split_large_page 2 45941 NULL
99490 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
99491 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
99492 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
99493 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
99494 +get_free_entries_46030 get_free_entries 1 46030 NULL
99495 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
99496 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
99497 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
99498 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
99499 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
99500 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
99501 +slhc_toss_46066 slhc_toss 0 46066 NULL
99502 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
99503 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
99504 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
99505 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
99506 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
99507 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
99508 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
99509 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
99510 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
99511 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
99512 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
99513 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
99514 +add_conn_list_46197 add_conn_list 3 46197 NULL
99515 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
99516 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
99517 +dsp_write_46218 dsp_write 2 46218 NULL
99518 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
99519 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
99520 +ReadReg_46277 ReadReg 0 46277 NULL
99521 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
99522 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
99523 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
99524 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
99525 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
99526 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
99527 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
99528 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
99529 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
99530 +filldir64_46469 filldir64 3 46469 NULL
99531 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
99532 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
99533 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
99534 +kmsg_read_46514 kmsg_read 3 46514 NULL
99535 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
99536 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
99537 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
99538 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
99539 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
99540 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
99541 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
99542 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
99543 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
99544 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
99545 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
99546 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
99547 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
99548 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
99549 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
99550 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
99551 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
99552 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
99553 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
99554 +prepare_copy_46725 prepare_copy 2 46725 NULL
99555 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
99556 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
99557 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
99558 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
99559 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
99560 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
99561 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
99562 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
99563 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
99564 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
99565 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
99566 +spi_async_46857 spi_async 0 46857 NULL
99567 +vsnprintf_46863 vsnprintf 0 46863 NULL
99568 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
99569 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
99570 +rvmalloc_46873 rvmalloc 1 46873 NULL
99571 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
99572 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
99573 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
99574 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
99575 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
99576 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
99577 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
99578 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
99579 +fb_write_46924 fb_write 3 46924 NULL
99580 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
99581 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
99582 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
99583 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
99584 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
99585 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
99586 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
99587 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
99588 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
99589 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
99590 +__map_single_47020 __map_single 3-4-7 47020 NULL
99591 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
99592 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
99593 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
99594 +fs_path_len_47060 fs_path_len 0 47060 NULL
99595 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
99596 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
99597 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
99598 +mousedev_read_47123 mousedev_read 3 47123 NULL
99599 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
99600 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
99601 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
99602 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
99603 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
99604 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
99605 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
99606 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
99607 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
99608 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
99609 +l2headersize_47238 l2headersize 0 47238 NULL
99610 +options_write_47243 options_write 3 47243 NULL
99611 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
99612 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
99613 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
99614 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
99615 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
99616 +vsnprintf_47291 vsnprintf 0 47291 NULL
99617 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
99618 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
99619 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
99620 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
99621 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
99622 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
99623 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
99624 +nametbl_list_47391 nametbl_list 2 47391 NULL
99625 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
99626 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
99627 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
99628 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
99629 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
99630 +vzalloc_47421 vzalloc 1 47421 NULL
99631 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
99632 +__load_mapping_47460 __load_mapping 2 47460 NULL
99633 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
99634 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
99635 +core_sys_select_47494 core_sys_select 1 47494 NULL
99636 +unlink_simple_47506 unlink_simple 3 47506 NULL
99637 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
99638 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
99639 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
99640 +oz_events_read_47535 oz_events_read 3 47535 NULL
99641 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
99642 +read_ldt_47570 read_ldt 2 47570 NULL
99643 +pci_iomap_47575 pci_iomap 3 47575 NULL
99644 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
99645 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
99646 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
99647 +uea_request_47613 uea_request 4 47613 NULL
99648 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
99649 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
99650 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
99651 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
99652 +save_microcode_47717 save_microcode 3 47717 NULL
99653 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
99654 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
99655 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
99656 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
99657 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
99658 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
99659 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
99660 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
99661 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
99662 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
99663 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
99664 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
99665 +vhci_read_47878 vhci_read 3 47878 NULL
99666 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
99667 +load_mapping_47904 load_mapping 3 47904 NULL
99668 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
99669 +comedi_write_47926 comedi_write 3 47926 NULL
99670 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
99671 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
99672 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
99673 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
99674 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
99675 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
99676 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
99677 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
99678 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
99679 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
99680 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
99681 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
99682 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
99683 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
99684 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
99685 +set_discoverable_48141 set_discoverable 4 48141 NULL
99686 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
99687 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
99688 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
99689 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
99690 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
99691 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
99692 +init_ipath_48187 init_ipath 1 48187 NULL
99693 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
99694 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
99695 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
99696 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
99697 +read_file_recv_48232 read_file_recv 3 48232 NULL
99698 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
99699 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
99700 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
99701 +send_set_info_48288 send_set_info 7 48288 NULL
99702 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
99703 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
99704 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
99705 +hash_setkey_48310 hash_setkey 3 48310 NULL
99706 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
99707 +skb_add_data_48363 skb_add_data 3 48363 NULL
99708 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
99709 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
99710 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
99711 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
99712 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
99713 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
99714 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
99715 +send_control_msg_48498 send_control_msg 6 48498 NULL
99716 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
99717 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
99718 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
99719 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
99720 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
99721 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
99722 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
99723 +named_distribute_48544 named_distribute 4 48544 NULL
99724 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
99725 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
99726 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
99727 +mtd_read_48655 mtd_read 0 48655 NULL
99728 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
99729 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
99730 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
99731 +altera_drscan_48698 altera_drscan 2 48698 NULL
99732 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
99733 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
99734 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
99735 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
99736 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
99737 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
99738 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
99739 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
99740 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
99741 +azx_get_position_48841 azx_get_position 0 48841 NULL
99742 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
99743 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
99744 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
99745 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
99746 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
99747 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
99748 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
99749 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
99750 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
99751 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
99752 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
99753 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
99754 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
99755 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
99756 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
99757 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
99758 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
99759 +transient_status_49027 transient_status 4 49027 NULL
99760 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
99761 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
99762 +ubi_read_49061 ubi_read 0 49061 NULL
99763 +scsi_register_49094 scsi_register 2 49094 NULL
99764 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
99765 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
99766 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
99767 +pt_read_49136 pt_read 3 49136 NULL
99768 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
99769 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
99770 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
99771 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
99772 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
99773 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
99774 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
99775 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
99776 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
99777 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
99778 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
99779 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
99780 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
99781 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
99782 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
99783 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
99784 +uio_read_49300 uio_read 3 49300 NULL
99785 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
99786 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
99787 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
99788 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
99789 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
99790 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
99791 +px_raw_event_49371 px_raw_event 4 49371 NULL
99792 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
99793 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
99794 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
99795 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
99796 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
99797 +md_domain_init_49432 md_domain_init 2 49432 NULL
99798 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
99799 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
99800 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
99801 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
99802 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
99803 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
99804 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
99805 +smk_write_access_49561 smk_write_access 3 49561 NULL
99806 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
99807 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
99808 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
99809 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
99810 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
99811 +heap_init_49617 heap_init 2 49617 NULL
99812 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
99813 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
99814 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
99815 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
99816 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
99817 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
99818 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
99819 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
99820 +check_frame_49741 check_frame 0 49741 NULL
99821 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
99822 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
99823 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
99824 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
99825 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
99826 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
99827 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
99828 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
99829 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
99830 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
99831 +add_uuid_49831 add_uuid 4 49831 NULL
99832 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
99833 +twl4030_write_49846 twl4030_write 2 49846 NULL
99834 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
99835 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
99836 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
99837 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
99838 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
99839 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
99840 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
99841 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
99842 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
99843 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
99844 +__module_alloc_50004 __module_alloc 1 50004 NULL
99845 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
99846 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
99847 +isdn_read_50021 isdn_read 3 50021 NULL
99848 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
99849 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
99850 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
99851 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
99852 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
99853 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
99854 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
99855 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
99856 +read_file_slot_50111 read_file_slot 3 50111 NULL
99857 +copy_items_50140 copy_items 6 50140 NULL
99858 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
99859 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
99860 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
99861 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
99862 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
99863 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
99864 +odev_update_50169 odev_update 2 50169 NULL
99865 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
99866 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
99867 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
99868 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
99869 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
99870 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
99871 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
99872 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
99873 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
99874 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
99875 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
99876 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
99877 +do_launder_page_50329 do_launder_page 0 50329 NULL
99878 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
99879 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
99880 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
99881 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
99882 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
99883 +tpm_read_50344 tpm_read 3 50344 NULL
99884 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
99885 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
99886 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
99887 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
99888 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
99889 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
99890 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
99891 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
99892 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
99893 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
99894 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
99895 +force_mapping_50464 force_mapping 2 50464 NULL
99896 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
99897 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
99898 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
99899 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
99900 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
99901 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
99902 +fat_readpages_50582 fat_readpages 4 50582 NULL
99903 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
99904 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
99905 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
99906 +__ffs_50625 __ffs 0 50625 NULL
99907 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
99908 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
99909 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
99910 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
99911 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
99912 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
99913 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
99914 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
99915 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
99916 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
99917 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
99918 +skb_padto_50759 skb_padto 2 50759 NULL
99919 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
99920 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
99921 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
99922 +tpm_write_50798 tpm_write 3 50798 NULL
99923 +write_flush_50803 write_flush 3 50803 NULL
99924 +dvb_play_50814 dvb_play 3 50814 NULL
99925 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
99926 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
99927 +SetArea_50835 SetArea 4 50835 NULL nohasharray
99928 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
99929 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
99930 +self_check_write_50856 self_check_write 5 50856 NULL
99931 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
99932 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
99933 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
99934 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
99935 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
99936 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
99937 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
99938 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
99939 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
99940 +timeout_write_50991 timeout_write 3 50991 NULL
99941 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
99942 +proc_write_51003 proc_write 3 51003 NULL
99943 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
99944 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
99945 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
99946 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
99947 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
99948 +dump_midi_51040 dump_midi 3 51040 NULL
99949 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
99950 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
99951 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
99952 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
99953 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
99954 +ti_recv_51110 ti_recv 3 51110 NULL
99955 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
99956 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
99957 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
99958 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
99959 +set_dirty_51144 set_dirty 3 51144 NULL
99960 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
99961 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
99962 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
99963 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
99964 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
99965 +tipc_send_51238 tipc_send 4 51238 NULL
99966 +drm_property_create_51239 drm_property_create 4 51239 NULL
99967 +st_read_51251 st_read 3 51251 NULL
99968 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
99969 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
99970 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
99971 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
99972 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
99973 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
99974 +get_cell_51316 get_cell 2 51316 NULL
99975 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
99976 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
99977 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
99978 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
99979 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
99980 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
99981 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
99982 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
99983 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
99984 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
99985 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
99986 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
99987 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
99988 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
99989 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
99990 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
99991 +vaddr_51480 vaddr 0 51480 NULL
99992 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
99993 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
99994 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
99995 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
99996 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
99997 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
99998 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
99999 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
100000 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
100001 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
100002 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
100003 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
100004 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
100005 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
100006 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
100007 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
100008 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
100009 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
100010 +sel_write_access_51704 sel_write_access 3 51704 NULL
100011 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
100012 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
100013 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
100014 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
100015 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
100016 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
100017 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
100018 +if_write_51756 if_write 3 51756 NULL
100019 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
100020 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
100021 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
100022 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
100023 +ioread32_51847 ioread32 0 51847 NULL nohasharray
100024 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
100025 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
100026 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
100027 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
100028 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
100029 +user_read_51881 user_read 3 51881 NULL
100030 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
100031 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
100032 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
100033 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
100034 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
100035 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
100036 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
100037 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
100038 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
100039 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
100040 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
100041 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
100042 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
100043 +rdmalt_52022 rdmalt 0 52022 NULL
100044 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
100045 +override_release_52032 override_release 2 52032 NULL
100046 +end_port_52042 end_port 0 52042 NULL
100047 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
100048 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
100049 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
100050 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
100051 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
100052 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
100053 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
100054 +retry_count_read_52129 retry_count_read 3 52129 NULL
100055 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
100056 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
100057 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
100058 +htable_size_52148 htable_size 0-1 52148 NULL
100059 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
100060 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
100061 +alix_present_52165 alix_present 1 52165 NULL
100062 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
100063 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
100064 +print_prefix_52176 print_prefix 0 52176 NULL
100065 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
100066 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
100067 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
100068 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
100069 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
100070 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
100071 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
100072 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
100073 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
100074 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
100075 +read_file_reset_52310 read_file_reset 3 52310 NULL
100076 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
100077 +hwflags_read_52318 hwflags_read 3 52318 NULL
100078 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
100079 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
100080 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
100081 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
100082 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
100083 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
100084 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
100085 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
100086 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
100087 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
100088 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
100089 +delay_status_52431 delay_status 5 52431 NULL
100090 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
100091 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
100092 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
100093 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
100094 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
100095 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
100096 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
100097 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
100098 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
100099 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
100100 +from_oblock_52546 from_oblock 0-1 52546 NULL
100101 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
100102 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
100103 +emit_code_52583 emit_code 0-3 52583 NULL
100104 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
100105 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
100106 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
100107 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
100108 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
100109 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
100110 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
100111 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
100112 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
100113 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
100114 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
100115 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
100116 +twlreg_write_52880 twlreg_write 3 52880 NULL
100117 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
100118 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
100119 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
100120 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
100121 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
100122 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
100123 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
100124 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
100125 +send_packet_52960 send_packet 4 52960 NULL
100126 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
100127 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
100128 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
100129 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
100130 +num_node_state_52989 num_node_state 0 52989 NULL
100131 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
100132 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
100133 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
100134 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
100135 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
100136 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
100137 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
100138 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
100139 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
100140 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
100141 +verity_status_53120 verity_status 5 53120 NULL
100142 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
100143 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
100144 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
100145 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
100146 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
100147 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
100148 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
100149 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
100150 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
100151 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
100152 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
100153 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
100154 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
100155 +vm_mmap_53339 vm_mmap 0 53339 NULL
100156 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
100157 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
100158 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
100159 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
100160 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
100161 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
100162 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
100163 +n2_run_53459 n2_run 3 53459 NULL
100164 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
100165 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
100166 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
100167 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
100168 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
100169 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
100170 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
100171 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
100172 +check_acl_53512 check_acl 0 53512 NULL
100173 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
100174 +set_registers_53582 set_registers 3 53582 NULL
100175 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
100176 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
100177 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
100178 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
100179 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
100180 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
100181 +_preload_range_53676 _preload_range 2-3 53676 NULL
100182 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
100183 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
100184 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
100185 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
100186 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
100187 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
100188 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
100189 +wdm_write_53735 wdm_write 3 53735 NULL
100190 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
100191 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
100192 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
100193 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
100194 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
100195 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
100196 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
100197 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
100198 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
100199 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
100200 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
100201 +pms_read_53873 pms_read 3 53873 NULL
100202 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
100203 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
100204 +proc_file_read_53905 proc_file_read 3 53905 NULL
100205 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
100206 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
100207 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
100208 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
100209 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
100210 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
100211 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
100212 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
100213 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
100214 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
100215 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
100216 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
100217 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
100218 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
100219 +_malloc_54077 _malloc 1 54077 NULL
100220 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
100221 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
100222 +create_xattr_54106 create_xattr 5 54106 NULL
100223 +strn_len_54122 strn_len 0 54122 NULL
100224 +isku_receive_54130 isku_receive 4 54130 NULL
100225 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
100226 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
100227 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
100228 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
100229 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
100230 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
100231 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
100232 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
100233 +reada_add_block_54247 reada_add_block 2 54247 NULL
100234 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
100235 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
100236 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
100237 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
100238 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
100239 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
100240 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
100241 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
100242 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
100243 +sprintf_54306 sprintf 0 54306 NULL
100244 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
100245 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
100246 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
100247 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
100248 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
100249 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
100250 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
100251 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
100252 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
100253 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
100254 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
100255 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
100256 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
100257 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
100258 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
100259 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
100260 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
100261 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
100262 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
100263 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
100264 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
100265 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
100266 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
100267 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
100268 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
100269 +viacam_read_54526 viacam_read 3 54526 NULL
100270 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
100271 +setsockopt_54539 setsockopt 5 54539 NULL
100272 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
100273 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
100274 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
100275 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
100276 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
100277 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
100278 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
100279 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
100280 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
100281 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
100282 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
100283 +evm_read_key_54674 evm_read_key 3 54674 NULL
100284 +resource_string_54699 resource_string 0 54699 NULL
100285 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
100286 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
100287 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
100288 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
100289 +kzalloc_54740 kzalloc 1 54740 NULL
100290 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
100291 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
100292 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
100293 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
100294 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
100295 +domain_init_54797 domain_init 2 54797 NULL
100296 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
100297 +get_dev_size_54807 get_dev_size 0 54807 NULL
100298 +nfsd_write_54809 nfsd_write 6 54809 NULL
100299 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
100300 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
100301 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
100302 +write_rio_54837 write_rio 3 54837 NULL
100303 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
100304 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
100305 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
100306 +printer_read_54851 printer_read 3 54851 NULL
100307 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
100308 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
100309 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
100310 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
100311 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
100312 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
100313 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
100314 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
100315 +add_port_54941 add_port 2 54941 NULL
100316 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
100317 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
100318 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
100319 +c4_add_card_54968 c4_add_card 3 54968 NULL
100320 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
100321 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
100322 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
100323 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
100324 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
100325 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
100326 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
100327 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
100328 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
100329 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
100330 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
100331 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
100332 +corrupt_data_55120 corrupt_data 0 55120 NULL
100333 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
100334 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
100335 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
100336 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
100337 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
100338 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
100339 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
100340 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
100341 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
100342 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
100343 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
100344 +dump_command_55220 dump_command 1 55220 NULL
100345 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
100346 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
100347 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
100348 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
100349 +ptrace_request_55288 ptrace_request 3 55288 NULL
100350 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
100351 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
100352 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
100353 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
100354 +do_shmat_55336 do_shmat 5 55336 NULL
100355 +vme_user_read_55338 vme_user_read 3 55338 NULL
100356 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
100357 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
100358 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
100359 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
100360 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
100361 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
100362 +alloc_skb_55439 alloc_skb 1 55439 NULL
100363 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
100364 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
100365 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
100366 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
100367 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
100368 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
100369 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
100370 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
100371 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
100372 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
100373 +ea_get_55522 ea_get 0 55522 NULL
100374 +buffer_size_55534 buffer_size 0 55534 NULL
100375 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
100376 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
100377 +add_partition_55588 add_partition 2 55588 NULL
100378 +free_pages_55603 free_pages 1 55603 NULL
100379 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
100380 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
100381 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
100382 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
100383 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
100384 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
100385 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
100386 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
100387 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
100388 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
100389 +read_oldmem_55658 read_oldmem 3 55658 NULL
100390 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
100391 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
100392 +get_info_55681 get_info 3 55681 NULL
100393 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
100394 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
100395 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
100396 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
100397 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
100398 +set_local_name_55757 set_local_name 4 55757 NULL
100399 +strlen_55778 strlen 0 55778 NULL
100400 +set_spte_55783 set_spte 5-4 55783 NULL
100401 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
100402 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
100403 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
100404 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
100405 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
100406 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
100407 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
100408 +hsc_write_55875 hsc_write 3 55875 NULL
100409 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
100410 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
100411 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
100412 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
100413 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
100414 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
100415 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
100416 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
100417 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
100418 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
100419 +__set_discard_56081 __set_discard 2 56081 NULL
100420 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
100421 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
100422 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
100423 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
100424 +map_addr_56144 map_addr 7 56144 NULL
100425 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
100426 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
100427 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
100428 +skb_headroom_56200 skb_headroom 0 56200 NULL
100429 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
100430 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
100431 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
100432 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
100433 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
100434 +fd_copyin_56247 fd_copyin 3 56247 NULL
100435 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
100436 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
100437 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
100438 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
100439 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
100440 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
100441 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
100442 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
100443 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
100444 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
100445 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
100446 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
100447 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
100448 +dev_read_56369 dev_read 3 56369 NULL
100449 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
100450 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
100451 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
100452 +store_msg_56417 store_msg 3 56417 NULL
100453 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
100454 +fl_create_56435 fl_create 5 56435 NULL
100455 +gnttab_map_56439 gnttab_map 2 56439 NULL
100456 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
100457 +set_connectable_56458 set_connectable 4 56458 NULL
100458 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
100459 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
100460 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
100461 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
100462 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
100463 +ip_options_get_56538 ip_options_get 4 56538 NULL
100464 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
100465 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
100466 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
100467 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
100468 +event_filter_write_56609 event_filter_write 3 56609 NULL
100469 +gather_array_56641 gather_array 3 56641 NULL
100470 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
100471 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
100472 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
100473 +build_map_info_56696 build_map_info 2 56696 NULL
100474 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
100475 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
100476 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
100477 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
100478 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
100479 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
100480 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
100481 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
100482 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
100483 +hash_lookup_56792 hash_lookup 2 56792 NULL
100484 +do_syslog_56807 do_syslog 3 56807 NULL
100485 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
100486 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
100487 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
100488 +wb_lookup_56858 wb_lookup 2 56858 NULL
100489 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
100490 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
100491 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
100492 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
100493 +strcspn_56913 strcspn 0 56913 NULL
100494 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
100495 +check_header_56930 check_header 2 56930 NULL
100496 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
100497 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
100498 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
100499 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
100500 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
100501 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
100502 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
100503 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
100504 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
100505 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
100506 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
100507 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
100508 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
100509 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
100510 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
100511 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
100512 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
100513 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
100514 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
100515 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
100516 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
100517 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
100518 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
100519 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
100520 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
100521 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
100522 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
100523 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
100524 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
100525 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
100526 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
100527 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
100528 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
100529 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
100530 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
100531 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
100532 +fw_file_size_57307 fw_file_size 0 57307 NULL
100533 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
100534 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
100535 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
100536 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
100537 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
100538 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
100539 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
100540 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
100541 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
100542 +read_file_blob_57406 read_file_blob 3 57406 NULL
100543 +enclosure_register_57412 enclosure_register 3 57412 NULL
100544 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
100545 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
100546 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
100547 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
100548 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
100549 +ReadReg_57453 ReadReg 0 57453 NULL
100550 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
100551 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
100552 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
100553 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
100554 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
100555 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
100556 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
100557 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
100558 +skb_headlen_57501 skb_headlen 0 57501 NULL
100559 +copy_in_user_57502 copy_in_user 3 57502 NULL
100560 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
100561 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
100562 +init_tag_map_57515 init_tag_map 3 57515 NULL
100563 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
100564 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
100565 +inode_permission_57531 inode_permission 0 57531 NULL
100566 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
100567 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
100568 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
100569 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
100570 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
100571 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
100572 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
100573 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
100574 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
100575 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
100576 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
100577 +mem_read_57631 mem_read 3 57631 NULL
100578 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
100579 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
100580 +r3964_write_57662 r3964_write 4 57662 NULL
100581 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
100582 +__lgwrite_57669 __lgwrite 4 57669 NULL
100583 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
100584 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
100585 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
100586 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
100587 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
100588 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
100589 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
100590 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
100591 +ld2_57794 ld2 0 57794 NULL
100592 +ivtv_read_57796 ivtv_read 3 57796 NULL
100593 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
100594 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
100595 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
100596 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
100597 +copy_to_user_57835 copy_to_user 3 57835 NULL
100598 +flash_read_57843 flash_read 3 57843 NULL
100599 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
100600 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
100601 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
100602 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
100603 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
100604 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
100605 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
100606 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
100607 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
100608 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
100609 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
100610 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
100611 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
100612 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
100613 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
100614 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
100615 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
100616 +mce_async_out_58056 mce_async_out 3 58056 NULL
100617 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
100618 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
100619 +cm4040_write_58079 cm4040_write 3 58079 NULL
100620 +udi_log_event_58105 udi_log_event 3 58105 NULL
100621 +savemem_58129 savemem 3 58129 NULL
100622 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
100623 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
100624 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
100625 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
100626 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
100627 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
100628 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
100629 +read_file_debug_58256 read_file_debug 3 58256 NULL
100630 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
100631 +profile_load_58267 profile_load 3 58267 NULL
100632 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
100633 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
100634 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
100635 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
100636 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
100637 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
100638 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
100639 +next_pidmap_58347 next_pidmap 2 58347 NULL
100640 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
100641 +save_hint_58359 save_hint 2 58359 NULL
100642 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
100643 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
100644 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
100645 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
100646 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
100647 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
100648 +capabilities_read_58457 capabilities_read 3 58457 NULL
100649 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
100650 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
100651 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
100652 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
100653 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
100654 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
100655 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
100656 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
100657 +__clear_discard_58546 __clear_discard 2 58546 NULL
100658 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
100659 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
100660 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
100661 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
100662 +xip_file_read_58592 xip_file_read 3 58592 NULL
100663 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
100664 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
100665 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
100666 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
100667 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
100668 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
100669 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
100670 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
100671 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
100672 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
100673 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
100674 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
100675 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
100676 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
100677 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
100678 +acpi_map_58725 acpi_map 1-2 58725 NULL
100679 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
100680 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
100681 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
100682 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
100683 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
100684 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
100685 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
100686 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
100687 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
100688 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
100689 +ep_read_58813 ep_read 3 58813 NULL
100690 +command_write_58841 command_write 3 58841 NULL
100691 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
100692 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
100693 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
100694 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
100695 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
100696 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
100697 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
100698 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
100699 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
100700 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
100701 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
100702 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
100703 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
100704 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
100705 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
100706 +ep_write_59008 ep_write 3 59008 NULL
100707 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
100708 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
100709 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
100710 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
100711 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
100712 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
100713 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
100714 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
100715 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
100716 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
100717 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
100718 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
100719 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
100720 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
100721 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
100722 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
100723 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
100724 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
100725 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
100726 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
100727 +dt3155_read_59226 dt3155_read 3 59226 NULL
100728 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
100729 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
100730 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
100731 +nla_len_59258 nla_len 0 59258 NULL
100732 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
100733 +fd_copyout_59323 fd_copyout 3 59323 NULL
100734 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
100735 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
100736 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
100737 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
100738 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
100739 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
100740 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
100741 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
100742 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
100743 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
100744 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
100745 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
100746 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
100747 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
100748 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
100749 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
100750 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
100751 +tunables_write_59563 tunables_write 3 59563 NULL
100752 +memdup_user_59590 memdup_user 2 59590 NULL
100753 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
100754 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
100755 +mtrr_write_59622 mtrr_write 3 59622 NULL
100756 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
100757 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
100758 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
100759 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
100760 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
100761 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
100762 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
100763 +sriov_enable_59689 sriov_enable 2 59689 NULL
100764 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
100765 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
100766 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
100767 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
100768 +strnlen_59746 strnlen 0 59746 NULL
100769 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
100770 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
100771 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
100772 +venus_remove_59781 venus_remove 4 59781 NULL
100773 +ipw_write_59807 ipw_write 3 59807 NULL
100774 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
100775 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
100776 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
100777 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
100778 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
100779 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
100780 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
100781 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
100782 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
100783 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
100784 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
100785 +lookup_node_59953 lookup_node 2 59953 NULL
100786 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
100787 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
100788 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
100789 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
100790 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
100791 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
100792 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
100793 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
100794 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
100795 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
100796 +register_device_60015 register_device 2-3 60015 NULL
100797 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
100798 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
100799 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
100800 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
100801 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
100802 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
100803 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
100804 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
100805 +compat_writev_60063 compat_writev 3 60063 NULL
100806 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
100807 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
100808 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
100809 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
100810 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
100811 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
100812 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
100813 +init_state_60165 init_state 2 60165 NULL
100814 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
100815 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
100816 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
100817 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
100818 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
100819 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
100820 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
100821 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
100822 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
100823 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
100824 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
100825 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
100826 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
100827 +printer_write_60276 printer_write 3 60276 NULL
100828 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
100829 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
100830 +getDataLength_60301 getDataLength 0 60301 NULL
100831 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
100832 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
100833 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
100834 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
100835 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
100836 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
100837 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
100838 +driver_names_read_60399 driver_names_read 3 60399 NULL
100839 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
100840 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
100841 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
100842 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
100843 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
100844 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
100845 +rx_data_60442 rx_data 4 60442 NULL
100846 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
100847 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
100848 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
100849 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
100850 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
100851 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
100852 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
100853 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
100854 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
100855 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
100856 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
100857 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
100858 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
100859 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
100860 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
100861 +init_data_container_60709 init_data_container 1 60709 NULL
100862 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
100863 +raid_status_60755 raid_status 5 60755 NULL
100864 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
100865 +opticon_write_60775 opticon_write 4 60775 NULL
100866 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
100867 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
100868 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
100869 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
100870 +generic_writepages_60871 generic_writepages 0 60871 NULL
100871 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
100872 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
100873 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
100874 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
100875 +sys_mlock_60932 sys_mlock 1 60932 NULL
100876 +pti_char_write_60960 pti_char_write 3 60960 NULL
100877 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
100878 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
100879 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
100880 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
100881 +symtab_init_61050 symtab_init 2 61050 NULL
100882 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
100883 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
100884 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
100885 +get_derived_key_61100 get_derived_key 4 61100 NULL
100886 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
100887 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
100888 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
100889 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
100890 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
100891 +__vmalloc_61168 __vmalloc 1 61168 NULL
100892 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
100893 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
100894 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
100895 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
100896 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
100897 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
100898 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
100899 +sys_add_key_61288 sys_add_key 4 61288 NULL
100900 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
100901 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
100902 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
100903 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
100904 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
100905 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
100906 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
100907 +change_xattr_61390 change_xattr 5 61390 NULL
100908 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
100909 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
100910 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
100911 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
100912 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
100913 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
100914 +erst_errno_61526 erst_errno 0 61526 NULL
100915 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
100916 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
100917 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
100918 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
100919 +seq_open_private_61589 seq_open_private 3 61589 NULL
100920 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
100921 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
100922 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
100923 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
100924 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
100925 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
100926 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
100927 +resize_stripes_61650 resize_stripes 2 61650 NULL
100928 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
100929 +insert_one_name_61668 insert_one_name 7 61668 NULL
100930 +lock_loop_61681 lock_loop 1 61681 NULL
100931 +filter_read_61692 filter_read 3 61692 NULL
100932 +iov_length_61716 iov_length 0 61716 NULL
100933 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
100934 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
100935 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
100936 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
100937 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
100938 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
100939 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
100940 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
100941 +get_fw_name_61874 get_fw_name 3 61874 NULL
100942 +free_init_pages_61875 free_init_pages 2 61875 NULL
100943 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
100944 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
100945 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
100946 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
100947 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
100948 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
100949 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
100950 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
100951 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
100952 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
100953 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
100954 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
100955 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
100956 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
100957 +cow_file_range_61979 cow_file_range 3 61979 NULL
100958 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
100959 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
100960 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
100961 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
100962 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
100963 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
100964 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
100965 +do_pselect_62061 do_pselect 1 62061 NULL
100966 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
100967 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
100968 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
100969 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
100970 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
100971 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
100972 +ql_status_62135 ql_status 5 62135 NULL
100973 +video_usercopy_62151 video_usercopy 2 62151 NULL
100974 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
100975 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
100976 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
100977 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
100978 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
100979 +allocate_partition_62245 allocate_partition 4 62245 NULL
100980 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
100981 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
100982 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
100983 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
100984 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
100985 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
100986 +subseq_list_62332 subseq_list 3-0 62332 NULL
100987 +flash_write_62354 flash_write 3 62354 NULL
100988 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
100989 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
100990 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
100991 +altera_irscan_62396 altera_irscan 2 62396 NULL
100992 +set_ssp_62411 set_ssp 4 62411 NULL
100993 +unmap_single_62423 unmap_single 2 62423 NULL
100994 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
100995 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
100996 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
100997 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
100998 +remove_mapping_62491 remove_mapping 2 62491 NULL
100999 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
101000 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
101001 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
101002 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
101003 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
101004 +debugfs_read_62535 debugfs_read 3 62535 NULL
101005 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
101006 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
101007 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
101008 +get_subdir_62581 get_subdir 3 62581 NULL
101009 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
101010 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
101011 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
101012 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
101013 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
101014 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
101015 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
101016 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
101017 +write_62671 write 3 62671 NULL
101018 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
101019 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
101020 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
101021 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
101022 +rdm_62719 rdm 0 62719 NULL
101023 +key_replays_read_62746 key_replays_read 3 62746 NULL
101024 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
101025 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
101026 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
101027 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
101028 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
101029 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
101030 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
101031 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
101032 +set_swbp_62853 set_swbp 3 62853 NULL
101033 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
101034 +aoechr_write_62883 aoechr_write 3 62883 NULL
101035 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
101036 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
101037 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
101038 +getdqbuf_62908 getdqbuf 1 62908 NULL
101039 +try_async_pf_62914 try_async_pf 3 62914 NULL
101040 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
101041 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
101042 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
101043 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
101044 +unlink1_63059 unlink1 3 63059 NULL
101045 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
101046 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
101047 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
101048 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
101049 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
101050 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
101051 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
101052 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
101053 +vme_master_read_63221 vme_master_read 0 63221 NULL
101054 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
101055 +ptp_read_63251 ptp_read 4 63251 NULL
101056 +raid5_resize_63306 raid5_resize 2 63306 NULL
101057 +proc_info_read_63344 proc_info_read 3 63344 NULL
101058 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
101059 +idmouse_read_63374 idmouse_read 3 63374 NULL
101060 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
101061 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
101062 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
101063 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
101064 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
101065 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
101066 +kone_send_63435 kone_send 4 63435 NULL
101067 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
101068 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
101069 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
101070 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
101071 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
101072 +read_kcore_63488 read_kcore 3 63488 NULL
101073 +save_hint_63497 save_hint 2 63497 NULL
101074 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
101075 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
101076 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
101077 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
101078 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
101079 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
101080 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
101081 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
101082 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
101083 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
101084 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
101085 +module_alloc_63630 module_alloc 1 63630 NULL
101086 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
101087 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
101088 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
101089 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
101090 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
101091 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
101092 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
101093 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
101094 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
101095 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
101096 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
101097 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
101098 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
101099 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
101100 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
101101 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
101102 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
101103 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
101104 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
101105 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
101106 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
101107 +sel_write_load_63830 sel_write_load 3 63830 NULL
101108 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
101109 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
101110 +divas_write_63901 divas_write 3 63901 NULL
101111 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
101112 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
101113 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
101114 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
101115 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
101116 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
101117 +__team_options_register_63941 __team_options_register 3 63941 NULL
101118 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
101119 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
101120 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
101121 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
101122 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
101123 +kmemdup_64015 kmemdup 2 64015 NULL
101124 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
101125 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
101126 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
101127 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
101128 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
101129 +get_u8_64076 get_u8 0 64076 NULL
101130 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
101131 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
101132 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
101133 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
101134 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
101135 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
101136 +init_bch_64130 init_bch 1-2 64130 NULL
101137 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
101138 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
101139 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
101140 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
101141 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
101142 +read_pulse_64227 read_pulse 0-3 64227 NULL
101143 +header_len_64232 header_len 0 64232 NULL
101144 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
101145 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
101146 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
101147 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
101148 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
101149 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
101150 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
101151 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
101152 +ffz_64324 ffz 0 64324 NULL
101153 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
101154 +ts_write_64336 ts_write 3 64336 NULL
101155 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
101156 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
101157 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
101158 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
101159 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
101160 +ilo_write_64378 ilo_write 3 64378 NULL
101161 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
101162 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
101163 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
101164 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
101165 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
101166 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
101167 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
101168 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
101169 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
101170 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
101171 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
101172 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
101173 +cap_capable_64462 cap_capable 0 64462 NULL
101174 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
101175 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
101176 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
101177 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
101178 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
101179 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
101180 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
101181 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
101182 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
101183 +__spi_sync_64561 __spi_sync 0 64561 NULL
101184 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
101185 +fanotify_write_64623 fanotify_write 3 64623 NULL
101186 +to_dblock_64655 to_dblock 0-1 64655 NULL
101187 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
101188 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
101189 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
101190 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
101191 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
101192 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
101193 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
101194 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
101195 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
101196 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
101197 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
101198 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
101199 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
101200 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
101201 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
101202 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
101203 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
101204 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
101205 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
101206 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
101207 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
101208 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
101209 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
101210 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
101211 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
101212 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
101213 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
101214 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
101215 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
101216 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
101217 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
101218 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
101219 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
101220 +pskb_pull_65005 pskb_pull 2 65005 NULL
101221 +unifi_write_65012 unifi_write 3 65012 NULL
101222 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
101223 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
101224 +insert_dent_65034 insert_dent 7 65034 NULL
101225 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
101226 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
101227 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
101228 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
101229 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
101230 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
101231 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
101232 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
101233 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
101234 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
101235 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
101236 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
101237 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
101238 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
101239 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
101240 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
101241 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
101242 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
101243 +get_var_len_65304 get_var_len 0 65304 NULL
101244 +unpack_array_65318 unpack_array 0 65318 NULL
101245 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
101246 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
101247 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
101248 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
101249 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
101250 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
101251 +strchr_65372 strchr 0 65372 NULL
101252 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
101253 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
101254 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
101255 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
101256 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
101257 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
101258 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
101259 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
101260 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
101261 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
101262 +alloc_dr_65495 alloc_dr 2 65495 NULL
101263 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
101264 new file mode 100644
101265 index 0000000..9db0d0e
101266 --- /dev/null
101267 +++ b/tools/gcc/size_overflow_plugin.c
101268 @@ -0,0 +1,2114 @@
101269 +/*
101270 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
101271 + * Licensed under the GPL v2, or (at your option) v3
101272 + *
101273 + * Homepage:
101274 + * http://www.grsecurity.net/~ephox/overflow_plugin/
101275 + *
101276 + * Documentation:
101277 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
101278 + *
101279 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
101280 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
101281 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
101282 + *
101283 + * Usage:
101284 + * $ 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
101285 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
101286 + */
101287 +
101288 +#include "gcc-plugin.h"
101289 +#include "config.h"
101290 +#include "system.h"
101291 +#include "coretypes.h"
101292 +#include "tree.h"
101293 +#include "tree-pass.h"
101294 +#include "intl.h"
101295 +#include "plugin-version.h"
101296 +#include "tm.h"
101297 +#include "toplev.h"
101298 +#include "function.h"
101299 +#include "tree-flow.h"
101300 +#include "plugin.h"
101301 +#include "gimple.h"
101302 +#include "diagnostic.h"
101303 +#include "cfgloop.h"
101304 +
101305 +#if BUILDING_GCC_VERSION >= 4008
101306 +#define TODO_dump_func 0
101307 +#endif
101308 +
101309 +struct size_overflow_hash {
101310 + const struct size_overflow_hash * const next;
101311 + const char * const name;
101312 + const unsigned int param;
101313 +};
101314 +
101315 +#include "size_overflow_hash.h"
101316 +
101317 +enum mark {
101318 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
101319 +};
101320 +
101321 +enum err_code_conditions {
101322 + CAST_ONLY, FROM_CONST
101323 +};
101324 +
101325 +static unsigned int call_count = 0;
101326 +
101327 +#define __unused __attribute__((__unused__))
101328 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
101329 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
101330 +#define BEFORE_STMT true
101331 +#define AFTER_STMT false
101332 +#define CREATE_NEW_VAR NULL_TREE
101333 +#define CODES_LIMIT 32
101334 +#define MAX_PARAM 31
101335 +#define MY_STMT GF_PLF_1
101336 +#define NO_CAST_CHECK GF_PLF_2
101337 +#define FROM_ARG true
101338 +#define FROM_RET false
101339 +
101340 +#if BUILDING_GCC_VERSION == 4005
101341 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
101342 +#endif
101343 +
101344 +int plugin_is_GPL_compatible;
101345 +void debug_gimple_stmt(gimple gs);
101346 +
101347 +static tree expand(struct pointer_set_t *visited, tree lhs);
101348 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
101349 +static tree report_size_overflow_decl;
101350 +static const_tree const_char_ptr_type_node;
101351 +static unsigned int handle_function(void);
101352 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
101353 +static tree get_size_overflow_type(gimple stmt, const_tree node);
101354 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
101355 +static void print_missing_msg(tree func, unsigned int argnum);
101356 +
101357 +static struct plugin_info size_overflow_plugin_info = {
101358 + .version = "20130410beta",
101359 + .help = "no-size-overflow\tturn off size overflow checking\n",
101360 +};
101361 +
101362 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101363 +{
101364 + unsigned int arg_count;
101365 + enum tree_code code = TREE_CODE(*node);
101366 +
101367 + switch (code) {
101368 + case FUNCTION_DECL:
101369 + arg_count = type_num_arguments(TREE_TYPE(*node));
101370 + break;
101371 + case FUNCTION_TYPE:
101372 + case METHOD_TYPE:
101373 + arg_count = type_num_arguments(*node);
101374 + break;
101375 + default:
101376 + *no_add_attrs = true;
101377 + error("%s: %qE attribute only applies to functions", __func__, name);
101378 + return NULL_TREE;
101379 + }
101380 +
101381 + for (; args; args = TREE_CHAIN(args)) {
101382 + tree position = TREE_VALUE(args);
101383 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101384 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101385 + *no_add_attrs = true;
101386 + }
101387 + }
101388 + return NULL_TREE;
101389 +}
101390 +
101391 +static const char* get_asm_name(tree node)
101392 +{
101393 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
101394 +}
101395 +
101396 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101397 +{
101398 + unsigned int arg_count, arg_num;
101399 + enum tree_code code = TREE_CODE(*node);
101400 +
101401 + switch (code) {
101402 + case FUNCTION_DECL:
101403 + arg_count = type_num_arguments(TREE_TYPE(*node));
101404 + break;
101405 + case FUNCTION_TYPE:
101406 + case METHOD_TYPE:
101407 + arg_count = type_num_arguments(*node);
101408 + break;
101409 + case FIELD_DECL:
101410 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
101411 + if (arg_num != 0) {
101412 + *no_add_attrs = true;
101413 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
101414 + }
101415 + return NULL_TREE;
101416 + default:
101417 + *no_add_attrs = true;
101418 + error("%qE attribute only applies to functions", name);
101419 + return NULL_TREE;
101420 + }
101421 +
101422 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
101423 + return NULL_TREE;
101424 +
101425 + for (; args; args = TREE_CHAIN(args)) {
101426 + tree position = TREE_VALUE(args);
101427 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101428 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101429 + *no_add_attrs = true;
101430 + }
101431 + }
101432 + return NULL_TREE;
101433 +}
101434 +
101435 +static struct attribute_spec size_overflow_attr = {
101436 + .name = "size_overflow",
101437 + .min_length = 1,
101438 + .max_length = -1,
101439 + .decl_required = true,
101440 + .type_required = false,
101441 + .function_type_required = false,
101442 + .handler = handle_size_overflow_attribute,
101443 +#if BUILDING_GCC_VERSION >= 4007
101444 + .affects_type_identity = false
101445 +#endif
101446 +};
101447 +
101448 +static struct attribute_spec intentional_overflow_attr = {
101449 + .name = "intentional_overflow",
101450 + .min_length = 1,
101451 + .max_length = -1,
101452 + .decl_required = true,
101453 + .type_required = false,
101454 + .function_type_required = false,
101455 + .handler = handle_intentional_overflow_attribute,
101456 +#if BUILDING_GCC_VERSION >= 4007
101457 + .affects_type_identity = false
101458 +#endif
101459 +};
101460 +
101461 +static void register_attributes(void __unused *event_data, void __unused *data)
101462 +{
101463 + register_attribute(&size_overflow_attr);
101464 + register_attribute(&intentional_overflow_attr);
101465 +}
101466 +
101467 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
101468 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
101469 +{
101470 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
101471 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
101472 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
101473 +
101474 + unsigned int m = 0x57559429;
101475 + unsigned int n = 0x5052acdb;
101476 + const unsigned int *key4 = (const unsigned int *)key;
101477 + unsigned int h = len;
101478 + unsigned int k = len + seed + n;
101479 + unsigned long long p;
101480 +
101481 + while (len >= 8) {
101482 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
101483 + len -= 8;
101484 + }
101485 + if (len >= 4) {
101486 + cwmixb(key4[0]) key4 += 1;
101487 + len -= 4;
101488 + }
101489 + if (len)
101490 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
101491 + cwmixb(h ^ (k + n));
101492 + return k ^ h;
101493 +
101494 +#undef cwfold
101495 +#undef cwmixa
101496 +#undef cwmixb
101497 +}
101498 +
101499 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
101500 +{
101501 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
101502 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
101503 + return fn ^ codes;
101504 +}
101505 +
101506 +static inline tree get_original_function_decl(tree fndecl)
101507 +{
101508 + if (DECL_ABSTRACT_ORIGIN(fndecl))
101509 + return DECL_ABSTRACT_ORIGIN(fndecl);
101510 + return fndecl;
101511 +}
101512 +
101513 +static inline gimple get_def_stmt(const_tree node)
101514 +{
101515 + gcc_assert(node != NULL_TREE);
101516 + if (TREE_CODE(node) != SSA_NAME)
101517 + return NULL;
101518 + return SSA_NAME_DEF_STMT(node);
101519 +}
101520 +
101521 +static unsigned char get_tree_code(const_tree type)
101522 +{
101523 + switch (TREE_CODE(type)) {
101524 + case ARRAY_TYPE:
101525 + return 0;
101526 + case BOOLEAN_TYPE:
101527 + return 1;
101528 + case ENUMERAL_TYPE:
101529 + return 2;
101530 + case FUNCTION_TYPE:
101531 + return 3;
101532 + case INTEGER_TYPE:
101533 + return 4;
101534 + case POINTER_TYPE:
101535 + return 5;
101536 + case RECORD_TYPE:
101537 + return 6;
101538 + case UNION_TYPE:
101539 + return 7;
101540 + case VOID_TYPE:
101541 + return 8;
101542 + case REAL_TYPE:
101543 + return 9;
101544 + case VECTOR_TYPE:
101545 + return 10;
101546 + case REFERENCE_TYPE:
101547 + return 11;
101548 + case OFFSET_TYPE:
101549 + return 12;
101550 + case COMPLEX_TYPE:
101551 + return 13;
101552 + default:
101553 + debug_tree((tree)type);
101554 + gcc_unreachable();
101555 + }
101556 +}
101557 +
101558 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
101559 +{
101560 + gcc_assert(type != NULL_TREE);
101561 +
101562 + while (type && len < CODES_LIMIT) {
101563 + tree_codes[len] = get_tree_code(type);
101564 + len++;
101565 + type = TREE_TYPE(type);
101566 + }
101567 + return len;
101568 +}
101569 +
101570 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
101571 +{
101572 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
101573 + enum tree_code code = TREE_CODE(type);
101574 + size_t len = 0;
101575 +
101576 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
101577 +
101578 + arg = TYPE_ARG_TYPES(type);
101579 + // skip builtins __builtin_constant_p
101580 + if (!arg && DECL_BUILT_IN(fndecl))
101581 + return 0;
101582 +
101583 + if (TREE_CODE_CLASS(code) == tcc_type)
101584 + result = type;
101585 + else
101586 + result = DECL_RESULT(fndecl);
101587 +
101588 + gcc_assert(result != NULL_TREE);
101589 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
101590 +
101591 + if (arg == NULL_TREE) {
101592 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
101593 + arg_field = DECL_ARGUMENT_FLD(fndecl);
101594 + if (arg_field == NULL_TREE)
101595 + return 0;
101596 + arg = TREE_TYPE(arg_field);
101597 + len = add_type_codes(arg, tree_codes, len);
101598 + gcc_assert(len != 0);
101599 + return len;
101600 + }
101601 +
101602 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
101603 + while (arg && len < CODES_LIMIT) {
101604 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
101605 + arg = TREE_CHAIN(arg);
101606 + }
101607 +
101608 + gcc_assert(len != 0);
101609 + return len;
101610 +}
101611 +
101612 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
101613 +{
101614 + unsigned int hash;
101615 + const struct size_overflow_hash *entry;
101616 + unsigned char tree_codes[CODES_LIMIT];
101617 + size_t len;
101618 + const char *func_name;
101619 +
101620 + fndecl = get_original_function_decl(fndecl);
101621 + len = get_function_decl(fndecl, tree_codes);
101622 + if (len == 0)
101623 + return NULL;
101624 +
101625 + func_name = get_asm_name(fndecl);
101626 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
101627 +
101628 + entry = size_overflow_hash[hash];
101629 + while (entry) {
101630 + if (!strcmp(entry->name, func_name))
101631 + return entry;
101632 + entry = entry->next;
101633 + }
101634 +
101635 + return NULL;
101636 +}
101637 +
101638 +static bool is_bool(const_tree node)
101639 +{
101640 + const_tree type;
101641 +
101642 + if (node == NULL_TREE)
101643 + return false;
101644 +
101645 + type = TREE_TYPE(node);
101646 + if (!INTEGRAL_TYPE_P(type))
101647 + return false;
101648 + if (TREE_CODE(type) == BOOLEAN_TYPE)
101649 + return true;
101650 + if (TYPE_PRECISION(type) == 1)
101651 + return true;
101652 + return false;
101653 +}
101654 +
101655 +static bool skip_types(const_tree var)
101656 +{
101657 + tree type;
101658 +
101659 + if (is_gimple_constant(var))
101660 + return true;
101661 +
101662 + switch (TREE_CODE(var)) {
101663 + case ADDR_EXPR:
101664 +#if BUILDING_GCC_VERSION >= 4006
101665 + case MEM_REF:
101666 +#endif
101667 + case ARRAY_REF:
101668 + case BIT_FIELD_REF:
101669 + case INDIRECT_REF:
101670 + case TARGET_MEM_REF:
101671 + return true;
101672 + case PARM_DECL:
101673 + case VAR_DECL:
101674 + case COMPONENT_REF:
101675 + return false;
101676 + default:
101677 + break;
101678 + }
101679 +
101680 + gcc_assert(TREE_CODE(var) == SSA_NAME);
101681 +
101682 + type = TREE_TYPE(var);
101683 + switch (TREE_CODE(type)) {
101684 + case INTEGER_TYPE:
101685 + case ENUMERAL_TYPE:
101686 + return false;
101687 + case BOOLEAN_TYPE:
101688 + return is_bool(var);
101689 + default:
101690 + break;
101691 + }
101692 +
101693 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
101694 +
101695 + type = TREE_TYPE(type);
101696 + gcc_assert(type != NULL_TREE);
101697 + switch (TREE_CODE(type)) {
101698 + case RECORD_TYPE:
101699 + case POINTER_TYPE:
101700 + case ARRAY_TYPE:
101701 + return true;
101702 + case VOID_TYPE:
101703 + case INTEGER_TYPE:
101704 + case UNION_TYPE:
101705 + return false;
101706 + default:
101707 + break;
101708 + }
101709 +
101710 + debug_tree((tree)var);
101711 + gcc_unreachable();
101712 +}
101713 +
101714 +static unsigned int find_arg_number(const_tree arg, tree func)
101715 +{
101716 + tree var;
101717 + unsigned int argnum = 1;
101718 +
101719 + if (TREE_CODE(arg) == SSA_NAME)
101720 + arg = SSA_NAME_VAR(arg);
101721 +
101722 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
101723 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
101724 + continue;
101725 + if (!skip_types(var))
101726 + return argnum;
101727 + }
101728 +
101729 + return 0;
101730 +}
101731 +
101732 +static tree create_new_var(tree type)
101733 +{
101734 + tree new_var = create_tmp_var(type, "cicus");
101735 +
101736 +#if BUILDING_GCC_VERSION <= 4007
101737 + add_referenced_var(new_var);
101738 + mark_sym_for_renaming(new_var);
101739 +#endif
101740 + return new_var;
101741 +}
101742 +
101743 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
101744 +{
101745 + gimple assign;
101746 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101747 + tree type = TREE_TYPE(rhs1);
101748 + tree lhs = create_new_var(type);
101749 +
101750 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
101751 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
101752 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101753 +
101754 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
101755 + update_stmt(assign);
101756 + gimple_set_plf(assign, MY_STMT, true);
101757 + return assign;
101758 +}
101759 +
101760 +static tree cast_a_tree(tree type, tree var)
101761 +{
101762 + gcc_assert(type != NULL_TREE);
101763 + gcc_assert(var != NULL_TREE);
101764 + gcc_assert(fold_convertible_p(type, var));
101765 +
101766 + return fold_convert(type, var);
101767 +}
101768 +
101769 +static tree get_lhs(const_gimple stmt)
101770 +{
101771 + switch (gimple_code(stmt)) {
101772 + case GIMPLE_ASSIGN:
101773 + return gimple_get_lhs(stmt);
101774 + case GIMPLE_PHI:
101775 + return gimple_phi_result(stmt);
101776 + case GIMPLE_CALL:
101777 + return gimple_call_lhs(stmt);
101778 + default:
101779 + return NULL_TREE;
101780 + }
101781 +}
101782 +
101783 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
101784 +{
101785 + const_gimple def_stmt = get_def_stmt(rhs);
101786 +
101787 + if (force)
101788 + return false;
101789 +
101790 + if (is_gimple_constant(rhs))
101791 + return false;
101792 +
101793 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
101794 + return false;
101795 +
101796 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
101797 + return false;
101798 +
101799 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
101800 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
101801 + return false;
101802 +
101803 + return true;
101804 +}
101805 +
101806 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
101807 +{
101808 + gimple assign, def_stmt;
101809 +
101810 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
101811 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
101812 + gcc_unreachable();
101813 +
101814 + def_stmt = get_def_stmt(rhs);
101815 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
101816 + return def_stmt;
101817 +
101818 + if (lhs == CREATE_NEW_VAR)
101819 + lhs = create_new_var(dst_type);
101820 +
101821 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
101822 +
101823 + if (!gsi_end_p(*gsi)) {
101824 + location_t loc = gimple_location(gsi_stmt(*gsi));
101825 + gimple_set_location(assign, loc);
101826 + }
101827 +
101828 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101829 +
101830 + if (before)
101831 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
101832 + else
101833 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
101834 + update_stmt(assign);
101835 + gimple_set_plf(assign, MY_STMT, true);
101836 +
101837 + return assign;
101838 +}
101839 +
101840 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
101841 +{
101842 + gimple_stmt_iterator gsi;
101843 + tree lhs;
101844 + const_gimple new_stmt;
101845 +
101846 + if (rhs == NULL_TREE)
101847 + return NULL_TREE;
101848 +
101849 + gsi = gsi_for_stmt(stmt);
101850 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
101851 +
101852 + lhs = get_lhs(new_stmt);
101853 + gcc_assert(lhs != NULL_TREE);
101854 + return lhs;
101855 +}
101856 +
101857 +static tree cast_to_TI_type(gimple stmt, tree node)
101858 +{
101859 + gimple_stmt_iterator gsi;
101860 + gimple cast_stmt;
101861 + tree type = TREE_TYPE(node);
101862 +
101863 + if (types_compatible_p(type, intTI_type_node))
101864 + return node;
101865 +
101866 + gsi = gsi_for_stmt(stmt);
101867 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101868 + return gimple_get_lhs(cast_stmt);
101869 +}
101870 +
101871 +static void check_function_hash(const_gimple stmt)
101872 +{
101873 + tree func;
101874 + const struct size_overflow_hash *hash;
101875 +
101876 + if (gimple_code(stmt) != GIMPLE_CALL)
101877 + return;
101878 +
101879 + func = gimple_call_fndecl(stmt);
101880 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
101881 + if (func == NULL_TREE)
101882 + return;
101883 +
101884 + hash = get_function_hash(func);
101885 + if (!hash)
101886 + print_missing_msg(func, 0);
101887 +}
101888 +
101889 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
101890 +{
101891 + tree lhs, new_lhs;
101892 + gimple_stmt_iterator gsi;
101893 +
101894 + if (rhs1 == NULL_TREE) {
101895 + debug_gimple_stmt(oldstmt);
101896 + error("%s: rhs1 is NULL_TREE", __func__);
101897 + gcc_unreachable();
101898 + }
101899 +
101900 + switch (gimple_code(oldstmt)) {
101901 + case GIMPLE_ASM:
101902 + lhs = rhs1;
101903 + break;
101904 + case GIMPLE_CALL:
101905 + lhs = gimple_call_lhs(oldstmt);
101906 + break;
101907 + case GIMPLE_ASSIGN:
101908 + lhs = gimple_get_lhs(oldstmt);
101909 + break;
101910 + default:
101911 + debug_gimple_stmt(oldstmt);
101912 + gcc_unreachable();
101913 + }
101914 +
101915 + gsi = gsi_for_stmt(oldstmt);
101916 + pointer_set_insert(visited, oldstmt);
101917 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
101918 + basic_block next_bb, cur_bb;
101919 + const_edge e;
101920 +
101921 + gcc_assert(before == false);
101922 + gcc_assert(stmt_can_throw_internal(oldstmt));
101923 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
101924 + gcc_assert(!gsi_end_p(gsi));
101925 +
101926 + cur_bb = gimple_bb(oldstmt);
101927 + next_bb = cur_bb->next_bb;
101928 + e = find_edge(cur_bb, next_bb);
101929 + gcc_assert(e != NULL);
101930 + gcc_assert(e->flags & EDGE_FALLTHRU);
101931 +
101932 + gsi = gsi_after_labels(next_bb);
101933 + gcc_assert(!gsi_end_p(gsi));
101934 +
101935 + before = true;
101936 + oldstmt = gsi_stmt(gsi);
101937 + }
101938 +
101939 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
101940 + return new_lhs;
101941 +}
101942 +
101943 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
101944 +{
101945 + gimple stmt;
101946 + gimple_stmt_iterator gsi;
101947 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
101948 +
101949 + if (gimple_plf(oldstmt, MY_STMT))
101950 + return lhs;
101951 +
101952 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
101953 + rhs1 = gimple_assign_rhs1(oldstmt);
101954 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
101955 + }
101956 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
101957 + rhs2 = gimple_assign_rhs2(oldstmt);
101958 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
101959 + }
101960 +
101961 + stmt = gimple_copy(oldstmt);
101962 + gimple_set_location(stmt, gimple_location(oldstmt));
101963 + gimple_set_plf(stmt, MY_STMT, true);
101964 +
101965 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
101966 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
101967 +
101968 + size_overflow_type = get_size_overflow_type(oldstmt, node);
101969 +
101970 + new_var = create_new_var(size_overflow_type);
101971 + new_var = make_ssa_name(new_var, stmt);
101972 + gimple_set_lhs(stmt, new_var);
101973 +
101974 + if (rhs1 != NULL_TREE)
101975 + gimple_assign_set_rhs1(stmt, rhs1);
101976 +
101977 + if (rhs2 != NULL_TREE)
101978 + gimple_assign_set_rhs2(stmt, rhs2);
101979 +#if BUILDING_GCC_VERSION >= 4007
101980 + if (rhs3 != NULL_TREE)
101981 + gimple_assign_set_rhs3(stmt, rhs3);
101982 +#endif
101983 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
101984 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
101985 +
101986 + gsi = gsi_for_stmt(oldstmt);
101987 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
101988 + update_stmt(stmt);
101989 + pointer_set_insert(visited, oldstmt);
101990 + return gimple_get_lhs(stmt);
101991 +}
101992 +
101993 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
101994 +{
101995 + basic_block first_bb;
101996 + gimple assign;
101997 + gimple_stmt_iterator gsi;
101998 +
101999 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102000 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
102001 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
102002 +
102003 + gsi = gsi_start_bb(first_bb);
102004 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
102005 + return gimple_get_lhs(assign);
102006 +}
102007 +
102008 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
102009 +{
102010 + gimple_stmt_iterator gsi;
102011 + const_gimple assign;
102012 + gimple def_stmt = get_def_stmt(new_arg);
102013 +
102014 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
102015 + gsi = gsi_after_labels(gimple_bb(def_stmt));
102016 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
102017 + } else {
102018 + gsi = gsi_for_stmt(def_stmt);
102019 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
102020 + }
102021 +
102022 + return gimple_get_lhs(assign);
102023 +}
102024 +
102025 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
102026 +{
102027 + basic_block bb;
102028 + gimple_stmt_iterator gsi;
102029 + const_gimple assign, def_stmt;
102030 +
102031 + def_stmt = get_def_stmt(arg);
102032 + bb = gimple_bb(def_stmt);
102033 + gcc_assert(bb->index != 0);
102034 + gsi = gsi_after_labels(bb);
102035 +
102036 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
102037 + return gimple_get_lhs(assign);
102038 +}
102039 +
102040 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
102041 +{
102042 + tree size_overflow_type;
102043 + const_gimple def_stmt = get_def_stmt(arg);
102044 +
102045 + if (phi_ssa_name != NULL_TREE)
102046 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
102047 +
102048 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
102049 +
102050 + if (new_arg != NULL_TREE) {
102051 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
102052 + return use_phi_ssa_name(phi_ssa_name, new_arg);
102053 + }
102054 +
102055 + switch(gimple_code(def_stmt)) {
102056 + case GIMPLE_PHI:
102057 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
102058 + case GIMPLE_NOP:
102059 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
102060 + default:
102061 + debug_gimple_stmt((gimple)def_stmt);
102062 + gcc_unreachable();
102063 + }
102064 +}
102065 +
102066 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
102067 +{
102068 + basic_block bb;
102069 + gimple phi;
102070 + gimple_seq seq;
102071 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
102072 +
102073 + bb = gsi_bb(gsi);
102074 +
102075 + phi = create_phi_node(result, bb);
102076 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
102077 + seq = phi_nodes(bb);
102078 + gsi = gsi_last(seq);
102079 + gsi_remove(&gsi, false);
102080 +
102081 + gsi = gsi_for_stmt(oldstmt);
102082 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
102083 + gimple_set_bb(phi, bb);
102084 + gimple_set_plf(phi, MY_STMT, true);
102085 + return phi;
102086 +}
102087 +
102088 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
102089 +{
102090 + gimple new_phi = NULL;
102091 + gimple oldstmt = get_def_stmt(orig_result);
102092 + tree phi_ssa_name = NULL_TREE;
102093 + unsigned int i;
102094 +
102095 + pointer_set_insert(visited, oldstmt);
102096 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
102097 + tree arg, new_arg;
102098 +
102099 + arg = gimple_phi_arg_def(oldstmt, i);
102100 +
102101 + new_arg = expand(visited, arg);
102102 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
102103 + if (i == 0) {
102104 + phi_ssa_name = new_arg;
102105 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
102106 + }
102107 +
102108 + gcc_assert(new_phi != NULL);
102109 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
102110 + }
102111 +
102112 + gcc_assert(new_phi != NULL);
102113 + update_stmt(new_phi);
102114 + return gimple_phi_result(new_phi);
102115 +}
102116 +
102117 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
102118 +{
102119 + const_gimple assign;
102120 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102121 + tree origtype = TREE_TYPE(orig_rhs);
102122 +
102123 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
102124 +
102125 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102126 + return gimple_get_lhs(assign);
102127 +}
102128 +
102129 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
102130 +{
102131 + const_tree rhs1, lhs, rhs1_type, lhs_type;
102132 + enum machine_mode lhs_mode, rhs_mode;
102133 + gimple def_stmt = get_def_stmt(no_const_rhs);
102134 +
102135 + if (!gimple_assign_cast_p(def_stmt))
102136 + return false;
102137 +
102138 + rhs1 = gimple_assign_rhs1(def_stmt);
102139 + lhs = gimple_get_lhs(def_stmt);
102140 + rhs1_type = TREE_TYPE(rhs1);
102141 + lhs_type = TREE_TYPE(lhs);
102142 + rhs_mode = TYPE_MODE(rhs1_type);
102143 + lhs_mode = TYPE_MODE(lhs_type);
102144 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
102145 + return false;
102146 +
102147 + return true;
102148 +}
102149 +
102150 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
102151 +{
102152 + tree rhs1 = gimple_assign_rhs1(stmt);
102153 + tree lhs = gimple_get_lhs(stmt);
102154 + const_tree rhs1_type = TREE_TYPE(rhs1);
102155 + const_tree lhs_type = TREE_TYPE(lhs);
102156 +
102157 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
102158 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102159 +
102160 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
102161 +}
102162 +
102163 +static bool no_uses(tree node)
102164 +{
102165 + imm_use_iterator imm_iter;
102166 + use_operand_p use_p;
102167 +
102168 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
102169 + const_gimple use_stmt = USE_STMT(use_p);
102170 + if (use_stmt == NULL)
102171 + return true;
102172 + if (is_gimple_debug(use_stmt))
102173 + continue;
102174 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
102175 + continue;
102176 + return false;
102177 + }
102178 + return true;
102179 +}
102180 +
102181 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
102182 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
102183 +{
102184 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
102185 + gimple def_stmt = get_def_stmt(lhs);
102186 +
102187 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
102188 + return false;
102189 +
102190 + rhs1 = gimple_assign_rhs1(def_stmt);
102191 + rhs_type = TREE_TYPE(rhs1);
102192 + lhs_type = TREE_TYPE(lhs);
102193 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
102194 + return false;
102195 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
102196 + return false;
102197 +
102198 + def_stmt = get_def_stmt(rhs1);
102199 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
102200 + return false;
102201 +
102202 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
102203 + return false;
102204 +
102205 + rhs1 = gimple_assign_rhs1(def_stmt);
102206 + rhs2 = gimple_assign_rhs2(def_stmt);
102207 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
102208 + return false;
102209 +
102210 + if (is_gimple_constant(rhs2))
102211 + not_const_rhs = rhs1;
102212 + else
102213 + not_const_rhs = rhs2;
102214 +
102215 + return no_uses(not_const_rhs);
102216 +}
102217 +
102218 +static bool skip_lhs_cast_check(const_gimple stmt)
102219 +{
102220 + const_tree rhs = gimple_assign_rhs1(stmt);
102221 + const_gimple def_stmt = get_def_stmt(rhs);
102222 +
102223 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
102224 + if (gimple_code(def_stmt) == GIMPLE_ASM)
102225 + return true;
102226 +
102227 + if (is_const_plus_unsigned_signed_truncation(rhs))
102228 + return true;
102229 +
102230 + return false;
102231 +}
102232 +
102233 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
102234 +{
102235 + bool cast_lhs, cast_rhs;
102236 + tree lhs = gimple_get_lhs(stmt);
102237 + tree rhs = gimple_assign_rhs1(stmt);
102238 + const_tree lhs_type = TREE_TYPE(lhs);
102239 + const_tree rhs_type = TREE_TYPE(rhs);
102240 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
102241 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
102242 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
102243 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
102244 +
102245 + static bool check_lhs[3][4] = {
102246 + // ss su us uu
102247 + { false, true, true, false }, // lhs > rhs
102248 + { false, false, false, false }, // lhs = rhs
102249 + { true, true, true, true }, // lhs < rhs
102250 + };
102251 +
102252 + static bool check_rhs[3][4] = {
102253 + // ss su us uu
102254 + { true, false, true, true }, // lhs > rhs
102255 + { true, false, true, true }, // lhs = rhs
102256 + { true, false, true, true }, // lhs < rhs
102257 + };
102258 +
102259 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
102260 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
102261 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102262 +
102263 + if (lhs_size > rhs_size) {
102264 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102265 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102266 + } else if (lhs_size == rhs_size) {
102267 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102268 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102269 + } else {
102270 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102271 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102272 + }
102273 +
102274 + if (!cast_lhs && !cast_rhs)
102275 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102276 +
102277 + if (cast_lhs && !skip_lhs_cast_check(stmt))
102278 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
102279 +
102280 + if (cast_rhs)
102281 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
102282 +
102283 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102284 +}
102285 +
102286 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
102287 +{
102288 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
102289 +
102290 + if (gimple_plf(stmt, MY_STMT))
102291 + return lhs;
102292 +
102293 + rhs1 = gimple_assign_rhs1(stmt);
102294 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
102295 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102296 +
102297 + new_rhs1 = expand(visited, rhs1);
102298 +
102299 + if (new_rhs1 == NULL_TREE)
102300 + return create_cast_assign(visited, stmt);
102301 +
102302 + if (gimple_plf(stmt, NO_CAST_CHECK))
102303 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102304 +
102305 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
102306 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
102307 +
102308 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
102309 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
102310 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102311 + }
102312 +
102313 + if (!gimple_assign_cast_p(stmt))
102314 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102315 +
102316 + return create_cast_overflow_check(visited, new_rhs1, stmt);
102317 +}
102318 +
102319 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
102320 +{
102321 + tree rhs1, lhs = gimple_get_lhs(stmt);
102322 + gimple def_stmt = get_def_stmt(lhs);
102323 +
102324 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
102325 + rhs1 = gimple_assign_rhs1(def_stmt);
102326 +
102327 + if (is_gimple_constant(rhs1))
102328 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102329 +
102330 + switch (TREE_CODE(rhs1)) {
102331 + case SSA_NAME:
102332 + return handle_unary_rhs(visited, def_stmt);
102333 + case ARRAY_REF:
102334 + case BIT_FIELD_REF:
102335 + case ADDR_EXPR:
102336 + case COMPONENT_REF:
102337 + case INDIRECT_REF:
102338 +#if BUILDING_GCC_VERSION >= 4006
102339 + case MEM_REF:
102340 +#endif
102341 + case TARGET_MEM_REF:
102342 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102343 + case PARM_DECL:
102344 + case VAR_DECL:
102345 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102346 +
102347 + default:
102348 + debug_gimple_stmt(def_stmt);
102349 + debug_tree(rhs1);
102350 + gcc_unreachable();
102351 + }
102352 +}
102353 +
102354 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
102355 +{
102356 + gimple cond_stmt;
102357 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
102358 +
102359 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
102360 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
102361 + update_stmt(cond_stmt);
102362 +}
102363 +
102364 +static tree create_string_param(tree string)
102365 +{
102366 + tree i_type, a_type;
102367 + const int length = TREE_STRING_LENGTH(string);
102368 +
102369 + gcc_assert(length > 0);
102370 +
102371 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
102372 + a_type = build_array_type(char_type_node, i_type);
102373 +
102374 + TREE_TYPE(string) = a_type;
102375 + TREE_CONSTANT(string) = 1;
102376 + TREE_READONLY(string) = 1;
102377 +
102378 + return build1(ADDR_EXPR, ptr_type_node, string);
102379 +}
102380 +
102381 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
102382 +{
102383 + gimple func_stmt;
102384 + const_gimple def_stmt;
102385 + const_tree loc_line;
102386 + tree loc_file, ssa_name, current_func;
102387 + expanded_location xloc;
102388 + char *ssa_name_buf;
102389 + int len;
102390 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
102391 +
102392 + def_stmt = get_def_stmt(arg);
102393 + xloc = expand_location(gimple_location(def_stmt));
102394 +
102395 + if (!gimple_has_location(def_stmt)) {
102396 + xloc = expand_location(gimple_location(stmt));
102397 + if (!gimple_has_location(stmt))
102398 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
102399 + }
102400 +
102401 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
102402 +
102403 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
102404 + loc_file = create_string_param(loc_file);
102405 +
102406 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
102407 + current_func = create_string_param(current_func);
102408 +
102409 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
102410 + call_count++;
102411 + 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);
102412 + gcc_assert(len > 0);
102413 + ssa_name = build_string(len + 1, ssa_name_buf);
102414 + free(ssa_name_buf);
102415 + ssa_name = create_string_param(ssa_name);
102416 +
102417 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
102418 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
102419 +
102420 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
102421 +}
102422 +
102423 +static void __unused print_the_code_insertions(const_gimple stmt)
102424 +{
102425 + location_t loc = gimple_location(stmt);
102426 +
102427 + inform(loc, "Integer size_overflow check applied here.");
102428 +}
102429 +
102430 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
102431 +{
102432 + basic_block cond_bb, join_bb, bb_true;
102433 + edge e;
102434 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102435 +
102436 + cond_bb = gimple_bb(stmt);
102437 + if (before)
102438 + gsi_prev(&gsi);
102439 + if (gsi_end_p(gsi))
102440 + e = split_block_after_labels(cond_bb);
102441 + else
102442 + e = split_block(cond_bb, gsi_stmt(gsi));
102443 + cond_bb = e->src;
102444 + join_bb = e->dest;
102445 + e->flags = EDGE_FALSE_VALUE;
102446 + e->probability = REG_BR_PROB_BASE;
102447 +
102448 + bb_true = create_empty_bb(cond_bb);
102449 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
102450 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
102451 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
102452 +
102453 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
102454 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
102455 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
102456 +
102457 + if (current_loops != NULL) {
102458 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
102459 + add_bb_to_loop(bb_true, cond_bb->loop_father);
102460 + }
102461 +
102462 + insert_cond(cond_bb, arg, cond_code, type_value);
102463 + insert_cond_result(bb_true, stmt, arg, min);
102464 +
102465 +// print_the_code_insertions(stmt);
102466 +}
102467 +
102468 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
102469 +{
102470 + const_tree rhs_type = TREE_TYPE(rhs);
102471 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
102472 +
102473 + gcc_assert(rhs_type != NULL_TREE);
102474 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
102475 + return;
102476 +
102477 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
102478 +
102479 + if (is_const_plus_unsigned_signed_truncation(rhs))
102480 + return;
102481 +
102482 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
102483 + // typemax (-1) < typemin (0)
102484 + if (TREE_OVERFLOW(type_max))
102485 + return;
102486 +
102487 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
102488 +
102489 + cast_rhs_type = TREE_TYPE(cast_rhs);
102490 + type_max_type = TREE_TYPE(type_max);
102491 + type_min_type = TREE_TYPE(type_min);
102492 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
102493 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
102494 +
102495 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
102496 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
102497 +}
102498 +
102499 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
102500 +{
102501 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
102502 + return false;
102503 + if (!is_gimple_constant(rhs))
102504 + return false;
102505 + return true;
102506 +}
102507 +
102508 +static tree get_def_stmt_rhs(const_tree var)
102509 +{
102510 + tree rhs1, def_stmt_rhs1;
102511 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
102512 +
102513 + def_stmt = get_def_stmt(var);
102514 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
102515 +
102516 + rhs1 = gimple_assign_rhs1(def_stmt);
102517 + rhs1_def_stmt = get_def_stmt(rhs1);
102518 + if (!gimple_assign_cast_p(rhs1_def_stmt))
102519 + return rhs1;
102520 +
102521 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102522 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
102523 +
102524 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
102525 + case GIMPLE_CALL:
102526 + case GIMPLE_NOP:
102527 + case GIMPLE_ASM:
102528 + case GIMPLE_PHI:
102529 + return def_stmt_rhs1;
102530 + case GIMPLE_ASSIGN:
102531 + return rhs1;
102532 + default:
102533 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
102534 + gcc_unreachable();
102535 + }
102536 +}
102537 +
102538 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
102539 +{
102540 + tree new_rhs, orig_rhs;
102541 + void (*gimple_assign_set_rhs)(gimple, tree);
102542 + tree rhs1 = gimple_assign_rhs1(stmt);
102543 + tree rhs2 = gimple_assign_rhs2(stmt);
102544 + tree lhs = gimple_get_lhs(stmt);
102545 +
102546 + if (!check_overflow)
102547 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102548 +
102549 + if (change_rhs == NULL_TREE)
102550 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102551 +
102552 + if (new_rhs2 == NULL_TREE) {
102553 + orig_rhs = rhs1;
102554 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
102555 + } else {
102556 + orig_rhs = rhs2;
102557 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
102558 + }
102559 +
102560 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
102561 +
102562 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
102563 + gimple_assign_set_rhs(stmt, new_rhs);
102564 + update_stmt(stmt);
102565 +
102566 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102567 +}
102568 +
102569 +static bool is_subtraction_special(const_gimple stmt)
102570 +{
102571 + gimple rhs1_def_stmt, rhs2_def_stmt;
102572 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
102573 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
102574 + const_tree rhs1 = gimple_assign_rhs1(stmt);
102575 + const_tree rhs2 = gimple_assign_rhs2(stmt);
102576 +
102577 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
102578 + return false;
102579 +
102580 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
102581 +
102582 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
102583 + return false;
102584 +
102585 + rhs1_def_stmt = get_def_stmt(rhs1);
102586 + rhs2_def_stmt = get_def_stmt(rhs2);
102587 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
102588 + return false;
102589 +
102590 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102591 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
102592 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
102593 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
102594 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
102595 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
102596 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
102597 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
102598 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
102599 + return false;
102600 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
102601 + return false;
102602 +
102603 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
102604 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
102605 + return true;
102606 +}
102607 +
102608 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
102609 +{
102610 + tree new_rhs1, new_rhs2;
102611 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
102612 + gimple assign, stmt = get_def_stmt(lhs);
102613 + tree rhs1 = gimple_assign_rhs1(stmt);
102614 + tree rhs2 = gimple_assign_rhs2(stmt);
102615 +
102616 + if (!is_subtraction_special(stmt))
102617 + return NULL_TREE;
102618 +
102619 + new_rhs1 = expand(visited, rhs1);
102620 + new_rhs2 = expand(visited, rhs2);
102621 +
102622 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
102623 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
102624 +
102625 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
102626 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
102627 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
102628 + }
102629 +
102630 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
102631 + new_lhs = gimple_get_lhs(assign);
102632 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
102633 +
102634 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102635 +}
102636 +
102637 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
102638 +{
102639 + const_gimple def_stmt;
102640 +
102641 + if (TREE_CODE(rhs) != SSA_NAME)
102642 + return false;
102643 +
102644 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
102645 + return false;
102646 +
102647 + def_stmt = get_def_stmt(rhs);
102648 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
102649 + return false;
102650 +
102651 + return true;
102652 +}
102653 +
102654 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
102655 +{
102656 + tree rhs1, rhs2, new_lhs;
102657 + gimple def_stmt = get_def_stmt(lhs);
102658 + tree new_rhs1 = NULL_TREE;
102659 + tree new_rhs2 = NULL_TREE;
102660 +
102661 + rhs1 = gimple_assign_rhs1(def_stmt);
102662 + rhs2 = gimple_assign_rhs2(def_stmt);
102663 +
102664 + /* no DImode/TImode division in the 32/64 bit kernel */
102665 + switch (gimple_assign_rhs_code(def_stmt)) {
102666 + case RDIV_EXPR:
102667 + case TRUNC_DIV_EXPR:
102668 + case CEIL_DIV_EXPR:
102669 + case FLOOR_DIV_EXPR:
102670 + case ROUND_DIV_EXPR:
102671 + case TRUNC_MOD_EXPR:
102672 + case CEIL_MOD_EXPR:
102673 + case FLOOR_MOD_EXPR:
102674 + case ROUND_MOD_EXPR:
102675 + case EXACT_DIV_EXPR:
102676 + case POINTER_PLUS_EXPR:
102677 + case BIT_AND_EXPR:
102678 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102679 + default:
102680 + break;
102681 + }
102682 +
102683 + new_lhs = handle_integer_truncation(visited, lhs);
102684 + if (new_lhs != NULL_TREE)
102685 + return new_lhs;
102686 +
102687 + if (TREE_CODE(rhs1) == SSA_NAME)
102688 + new_rhs1 = expand(visited, rhs1);
102689 + if (TREE_CODE(rhs2) == SSA_NAME)
102690 + new_rhs2 = expand(visited, rhs2);
102691 +
102692 + if (is_a_neg_overflow(def_stmt, rhs2))
102693 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
102694 + if (is_a_neg_overflow(def_stmt, rhs1))
102695 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
102696 +
102697 +
102698 + if (is_a_constant_overflow(def_stmt, rhs2))
102699 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
102700 + if (is_a_constant_overflow(def_stmt, rhs1))
102701 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
102702 +
102703 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102704 +}
102705 +
102706 +#if BUILDING_GCC_VERSION >= 4007
102707 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
102708 +{
102709 + if (is_gimple_constant(rhs))
102710 + return cast_a_tree(size_overflow_type, rhs);
102711 + if (TREE_CODE(rhs) != SSA_NAME)
102712 + return NULL_TREE;
102713 + return expand(visited, rhs);
102714 +}
102715 +
102716 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
102717 +{
102718 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
102719 + gimple def_stmt = get_def_stmt(lhs);
102720 +
102721 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
102722 +
102723 + rhs1 = gimple_assign_rhs1(def_stmt);
102724 + rhs2 = gimple_assign_rhs2(def_stmt);
102725 + rhs3 = gimple_assign_rhs3(def_stmt);
102726 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
102727 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
102728 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
102729 +
102730 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
102731 +}
102732 +#endif
102733 +
102734 +static tree get_size_overflow_type(gimple stmt, const_tree node)
102735 +{
102736 + const_tree type;
102737 + tree new_type;
102738 +
102739 + gcc_assert(node != NULL_TREE);
102740 +
102741 + type = TREE_TYPE(node);
102742 +
102743 + if (gimple_plf(stmt, MY_STMT))
102744 + return TREE_TYPE(node);
102745 +
102746 + switch (TYPE_MODE(type)) {
102747 + case QImode:
102748 + new_type = intHI_type_node;
102749 + break;
102750 + case HImode:
102751 + new_type = intSI_type_node;
102752 + break;
102753 + case SImode:
102754 + new_type = intDI_type_node;
102755 + break;
102756 + case DImode:
102757 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
102758 + new_type = intDI_type_node;
102759 + else
102760 + new_type = intTI_type_node;
102761 + break;
102762 + default:
102763 + debug_tree((tree)node);
102764 + error("%s: unsupported gcc configuration.", __func__);
102765 + gcc_unreachable();
102766 + }
102767 +
102768 + if (TYPE_QUALS(type) != 0)
102769 + return build_qualified_type(new_type, TYPE_QUALS(type));
102770 + return new_type;
102771 +}
102772 +
102773 +static tree expand_visited(gimple def_stmt)
102774 +{
102775 + const_gimple next_stmt;
102776 + gimple_stmt_iterator gsi;
102777 + enum gimple_code code = gimple_code(def_stmt);
102778 +
102779 + if (code == GIMPLE_ASM)
102780 + return NULL_TREE;
102781 +
102782 + gsi = gsi_for_stmt(def_stmt);
102783 + gsi_next(&gsi);
102784 +
102785 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
102786 + return NULL_TREE;
102787 + gcc_assert(!gsi_end_p(gsi));
102788 + next_stmt = gsi_stmt(gsi);
102789 +
102790 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
102791 + return NULL_TREE;
102792 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
102793 +
102794 + return get_lhs(next_stmt);
102795 +}
102796 +
102797 +static tree expand(struct pointer_set_t *visited, tree lhs)
102798 +{
102799 + gimple def_stmt;
102800 +
102801 + if (skip_types(lhs))
102802 + return NULL_TREE;
102803 +
102804 + def_stmt = get_def_stmt(lhs);
102805 +
102806 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
102807 + return NULL_TREE;
102808 +
102809 + if (gimple_plf(def_stmt, MY_STMT))
102810 + return lhs;
102811 +
102812 + if (pointer_set_contains(visited, def_stmt))
102813 + return expand_visited(def_stmt);
102814 +
102815 + switch (gimple_code(def_stmt)) {
102816 + case GIMPLE_PHI:
102817 + return handle_phi(visited, lhs);
102818 + case GIMPLE_CALL:
102819 + case GIMPLE_ASM:
102820 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102821 + case GIMPLE_ASSIGN:
102822 + switch (gimple_num_ops(def_stmt)) {
102823 + case 2:
102824 + return handle_unary_ops(visited, def_stmt);
102825 + case 3:
102826 + return handle_binary_ops(visited, lhs);
102827 +#if BUILDING_GCC_VERSION >= 4007
102828 + case 4:
102829 + return handle_ternary_ops(visited, lhs);
102830 +#endif
102831 + }
102832 + default:
102833 + debug_gimple_stmt(def_stmt);
102834 + error("%s: unknown gimple code", __func__);
102835 + gcc_unreachable();
102836 + }
102837 +}
102838 +
102839 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
102840 +{
102841 + const_gimple assign;
102842 + tree orig_type = TREE_TYPE(orig_node);
102843 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102844 +
102845 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102846 + return gimple_get_lhs(assign);
102847 +}
102848 +
102849 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
102850 +{
102851 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
102852 + update_stmt(stmt);
102853 +}
102854 +
102855 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
102856 +{
102857 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
102858 + update_stmt(stmt);
102859 +}
102860 +
102861 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
102862 +{
102863 + tree arg;
102864 + const_tree origarg;
102865 +
102866 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
102867 + return true;
102868 +
102869 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
102870 + while (origarg && *argnum) {
102871 + (*argnum)--;
102872 + origarg = TREE_CHAIN(origarg);
102873 + }
102874 +
102875 + gcc_assert(*argnum == 0);
102876 +
102877 + gcc_assert(origarg != NULL_TREE);
102878 + *argnum = 0;
102879 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
102880 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
102881 + return true;
102882 + return false;
102883 +}
102884 +
102885 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
102886 +{
102887 + gimple phi = get_def_stmt(result);
102888 + unsigned int i, n = gimple_phi_num_args(phi);
102889 +
102890 + if (!phi)
102891 + return MARK_NO;
102892 +
102893 + pointer_set_insert(visited, phi);
102894 + for (i = 0; i < n; i++) {
102895 + enum mark marked;
102896 + const_tree arg = gimple_phi_arg_def(phi, i);
102897 + marked = pre_expand(visited, search_err_code, arg);
102898 + if (marked != MARK_NO)
102899 + return marked;
102900 + }
102901 + return MARK_NO;
102902 +}
102903 +
102904 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102905 +{
102906 + gimple def_stmt = get_def_stmt(lhs);
102907 + const_tree rhs;
102908 +
102909 + if (!def_stmt)
102910 + return MARK_NO;
102911 +
102912 + rhs = gimple_assign_rhs1(def_stmt);
102913 +
102914 + def_stmt = get_def_stmt(rhs);
102915 + if (is_gimple_constant(rhs))
102916 + search_err_code[FROM_CONST] = true;
102917 +
102918 + return pre_expand(visited, search_err_code, rhs);
102919 +}
102920 +
102921 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102922 +{
102923 + gimple def_stmt = get_def_stmt(lhs);
102924 + const_tree rhs1, rhs2;
102925 + enum mark marked;
102926 +
102927 + if (!def_stmt)
102928 + return MARK_NO;
102929 +
102930 + search_err_code[CAST_ONLY] = false;
102931 +
102932 + rhs1 = gimple_assign_rhs1(def_stmt);
102933 + rhs2 = gimple_assign_rhs2(def_stmt);
102934 + marked = pre_expand(visited, search_err_code, rhs1);
102935 + if (marked != MARK_NO)
102936 + return marked;
102937 + return pre_expand(visited, search_err_code, rhs2);
102938 +}
102939 +
102940 +static const_tree search_field_decl(const_tree comp_ref)
102941 +{
102942 + const_tree field = NULL_TREE;
102943 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
102944 +
102945 + for (i = 0; i < len; i++) {
102946 + field = TREE_OPERAND(comp_ref, i);
102947 + if (TREE_CODE(field) == FIELD_DECL)
102948 + break;
102949 + }
102950 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
102951 + return field;
102952 +}
102953 +
102954 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
102955 +{
102956 + const_tree attr, p;
102957 +
102958 + // 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);
102959 + if (fndecl == NULL_TREE)
102960 + return MARK_NO;
102961 +
102962 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
102963 + if (!attr || !TREE_VALUE(attr))
102964 + return MARK_NO;
102965 +
102966 + p = TREE_VALUE(attr);
102967 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
102968 + return MARK_TURN_OFF;
102969 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
102970 + return MARK_NOT_INTENTIONAL;
102971 + if (argnum == 0) {
102972 + gcc_assert(current_function_decl == fndecl);
102973 + return MARK_NO;
102974 + }
102975 +
102976 + do {
102977 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
102978 + return MARK_YES;
102979 + p = TREE_CHAIN(p);
102980 + } while (p);
102981 +
102982 + return MARK_NO;
102983 +}
102984 +
102985 +static void print_missing_msg(tree func, unsigned int argnum)
102986 +{
102987 + unsigned int new_hash;
102988 + size_t len;
102989 + unsigned char tree_codes[CODES_LIMIT];
102990 + location_t loc;
102991 + const char *curfunc;
102992 +
102993 + func = get_original_function_decl(func);
102994 + loc = DECL_SOURCE_LOCATION(func);
102995 + curfunc = get_asm_name(func);
102996 +
102997 + len = get_function_decl(func, tree_codes);
102998 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
102999 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
103000 +}
103001 +
103002 +static unsigned int search_missing_attribute(const_tree arg)
103003 +{
103004 + unsigned int argnum;
103005 + const struct size_overflow_hash *hash;
103006 + const_tree type = TREE_TYPE(arg);
103007 + tree func = get_original_function_decl(current_function_decl);
103008 +
103009 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
103010 +
103011 + if (TREE_CODE(type) == POINTER_TYPE)
103012 + return 0;
103013 +
103014 + argnum = find_arg_number(arg, func);
103015 + if (argnum == 0)
103016 + return 0;
103017 +
103018 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
103019 + return argnum;
103020 +
103021 + hash = get_function_hash(func);
103022 + if (!hash || !(hash->param & (1U << argnum))) {
103023 + print_missing_msg(func, argnum);
103024 + return 0;
103025 + }
103026 + return argnum;
103027 +}
103028 +
103029 +static enum mark is_already_marked(const_tree lhs)
103030 +{
103031 + unsigned int argnum;
103032 + const_tree fndecl;
103033 +
103034 + argnum = search_missing_attribute(lhs);
103035 + fndecl = get_original_function_decl(current_function_decl);
103036 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
103037 + return MARK_YES;
103038 + return MARK_NO;
103039 +}
103040 +
103041 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103042 +{
103043 + const_gimple def_stmt;
103044 +
103045 + if (skip_types(lhs))
103046 + return MARK_NO;
103047 +
103048 + if (TREE_CODE(lhs) == PARM_DECL)
103049 + return is_already_marked(lhs);
103050 +
103051 + if (TREE_CODE(lhs) == COMPONENT_REF) {
103052 + const_tree field, attr;
103053 +
103054 + field = search_field_decl(lhs);
103055 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
103056 + if (!attr || !TREE_VALUE(attr))
103057 + return MARK_NO;
103058 + return MARK_YES;
103059 + }
103060 +
103061 + def_stmt = get_def_stmt(lhs);
103062 +
103063 + if (!def_stmt)
103064 + return MARK_NO;
103065 +
103066 + if (pointer_set_contains(visited, def_stmt))
103067 + return MARK_NO;
103068 +
103069 + switch (gimple_code(def_stmt)) {
103070 + case GIMPLE_NOP:
103071 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
103072 + return is_already_marked(lhs);
103073 + return MARK_NO;
103074 + case GIMPLE_PHI:
103075 + return walk_phi(visited, search_err_code, lhs);
103076 + case GIMPLE_CALL:
103077 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
103078 + return MARK_TURN_OFF;
103079 + check_function_hash(def_stmt);
103080 + return MARK_NO;
103081 + case GIMPLE_ASM:
103082 + search_err_code[CAST_ONLY] = false;
103083 + return MARK_NO;
103084 + case GIMPLE_ASSIGN:
103085 + switch (gimple_num_ops(def_stmt)) {
103086 + case 2:
103087 + return walk_unary_ops(visited, search_err_code, lhs);
103088 + case 3:
103089 + return walk_binary_ops(visited, search_err_code, lhs);
103090 + }
103091 + default:
103092 + debug_gimple_stmt((gimple)def_stmt);
103093 + error("%s: unknown gimple code", __func__);
103094 + gcc_unreachable();
103095 + }
103096 +}
103097 +
103098 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
103099 +static bool skip_asm(const_tree arg)
103100 +{
103101 + gimple def_stmt = get_def_stmt(arg);
103102 +
103103 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
103104 + return false;
103105 +
103106 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
103107 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
103108 +}
103109 +
103110 +/*
103111 +0</MARK_YES: no dup, search attributes (so, int)
103112 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
103113 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
103114 +*/
103115 +
103116 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
103117 +{
103118 + struct pointer_set_t *visited;
103119 + enum mark is_marked, is_found;
103120 + location_t loc;
103121 + bool search_err_code[2] = {true, false};
103122 +
103123 + is_marked = mark_status(current_function_decl, 0);
103124 + if (is_marked == MARK_TURN_OFF)
103125 + return true;
103126 +
103127 + is_marked = mark_status(fndecl, argnum + 1);
103128 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
103129 + return true;
103130 +
103131 + visited = pointer_set_create();
103132 + is_found = pre_expand(visited, search_err_code, arg);
103133 + pointer_set_destroy(visited);
103134 +
103135 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
103136 + return true;
103137 +
103138 + if (where == FROM_ARG && skip_asm(arg))
103139 + return true;
103140 +
103141 + if (is_found == MARK_TURN_OFF)
103142 + return true;
103143 +
103144 + if ((is_found == MARK_YES && is_marked == MARK_YES))
103145 + return true;
103146 +
103147 + if (is_found == MARK_YES) {
103148 + loc = DECL_SOURCE_LOCATION(fndecl);
103149 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
103150 + return true;
103151 + }
103152 + return false;
103153 +}
103154 +
103155 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
103156 +{
103157 + struct pointer_set_t *visited;
103158 + tree arg, new_arg;
103159 + bool match;
103160 +
103161 + if (argnum == 0)
103162 + return;
103163 +
103164 + argnum--;
103165 +
103166 + match = get_function_arg(&argnum, fndecl);
103167 + if (!match)
103168 + return;
103169 + gcc_assert(gimple_call_num_args(stmt) > argnum);
103170 + arg = gimple_call_arg(stmt, argnum);
103171 + if (arg == NULL_TREE)
103172 + return;
103173 +
103174 + if (skip_types(arg))
103175 + return;
103176 +
103177 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
103178 + return;
103179 +
103180 + visited = pointer_set_create();
103181 + new_arg = expand(visited, arg);
103182 + pointer_set_destroy(visited);
103183 +
103184 + if (new_arg == NULL_TREE)
103185 + return;
103186 +
103187 + change_function_arg(stmt, arg, argnum, new_arg);
103188 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
103189 +}
103190 +
103191 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
103192 +{
103193 + tree p = TREE_VALUE(attr);
103194 + do {
103195 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
103196 + p = TREE_CHAIN(p);
103197 + } while (p);
103198 +}
103199 +
103200 +static void handle_function_by_hash(gimple stmt, tree fndecl)
103201 +{
103202 + unsigned int num;
103203 + const struct size_overflow_hash *hash;
103204 +
103205 + hash = get_function_hash(fndecl);
103206 + if (!hash)
103207 + return;
103208 +
103209 + for (num = 0; num <= MAX_PARAM; num++)
103210 + if (hash->param & (1U << num))
103211 + handle_function_arg(stmt, fndecl, num);
103212 +}
103213 +
103214 +static bool check_return_value(void)
103215 +{
103216 + const struct size_overflow_hash *hash;
103217 +
103218 + hash = get_function_hash(current_function_decl);
103219 + if (!hash || !(hash->param & 1U << 0))
103220 + return false;
103221 +
103222 + return true;
103223 +}
103224 +
103225 +static void handle_return_value(gimple ret_stmt)
103226 +{
103227 + struct pointer_set_t *visited;
103228 + tree ret, new_ret;
103229 +
103230 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
103231 + return;
103232 +
103233 + ret = gimple_return_retval(ret_stmt);
103234 +
103235 + if (skip_types(ret))
103236 + return;
103237 +
103238 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
103239 + return;
103240 +
103241 + visited = pointer_set_create();
103242 + new_ret = expand(visited, ret);
103243 + pointer_set_destroy(visited);
103244 +
103245 + change_function_return(ret_stmt, ret, new_ret);
103246 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
103247 +}
103248 +
103249 +static void set_plf_false(void)
103250 +{
103251 + basic_block bb;
103252 +
103253 + FOR_ALL_BB(bb) {
103254 + gimple_stmt_iterator si;
103255 +
103256 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
103257 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103258 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
103259 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103260 + }
103261 +}
103262 +
103263 +static unsigned int handle_function(void)
103264 +{
103265 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
103266 + bool check_ret;
103267 +
103268 + set_plf_false();
103269 +
103270 + check_ret = check_return_value();
103271 +
103272 + do {
103273 + gimple_stmt_iterator gsi;
103274 + next = bb->next_bb;
103275 +
103276 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103277 + tree fndecl, attr;
103278 + gimple stmt = gsi_stmt(gsi);
103279 +
103280 + if (check_ret)
103281 + handle_return_value(stmt);
103282 +
103283 + if (!(is_gimple_call(stmt)))
103284 + continue;
103285 + fndecl = gimple_call_fndecl(stmt);
103286 + if (fndecl == NULL_TREE)
103287 + continue;
103288 + if (gimple_call_num_args(stmt) == 0)
103289 + continue;
103290 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
103291 + if (!attr || !TREE_VALUE(attr))
103292 + handle_function_by_hash(stmt, fndecl);
103293 + else
103294 + handle_function_by_attribute(stmt, attr, fndecl);
103295 + gsi = gsi_for_stmt(stmt);
103296 + next = gimple_bb(stmt)->next_bb;
103297 + }
103298 + bb = next;
103299 + } while (bb);
103300 + return 0;
103301 +}
103302 +
103303 +static struct gimple_opt_pass size_overflow_pass = {
103304 + .pass = {
103305 + .type = GIMPLE_PASS,
103306 + .name = "size_overflow",
103307 +#if BUILDING_GCC_VERSION >= 4008
103308 + .optinfo_flags = OPTGROUP_NONE,
103309 +#endif
103310 + .gate = NULL,
103311 + .execute = handle_function,
103312 + .sub = NULL,
103313 + .next = NULL,
103314 + .static_pass_number = 0,
103315 + .tv_id = TV_NONE,
103316 + .properties_required = PROP_cfg,
103317 + .properties_provided = 0,
103318 + .properties_destroyed = 0,
103319 + .todo_flags_start = 0,
103320 + .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
103321 + }
103322 +};
103323 +
103324 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
103325 +{
103326 + tree fntype;
103327 +
103328 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
103329 +
103330 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
103331 + fntype = build_function_type_list(void_type_node,
103332 + const_char_ptr_type_node,
103333 + unsigned_type_node,
103334 + const_char_ptr_type_node,
103335 + const_char_ptr_type_node,
103336 + NULL_TREE);
103337 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
103338 +
103339 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
103340 + TREE_PUBLIC(report_size_overflow_decl) = 1;
103341 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
103342 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
103343 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
103344 +}
103345 +
103346 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103347 +{
103348 + int i;
103349 + const char * const plugin_name = plugin_info->base_name;
103350 + const int argc = plugin_info->argc;
103351 + const struct plugin_argument * const argv = plugin_info->argv;
103352 + bool enable = true;
103353 +
103354 + struct register_pass_info size_overflow_pass_info = {
103355 + .pass = &size_overflow_pass.pass,
103356 + .reference_pass_name = "ssa",
103357 + .ref_pass_instance_number = 1,
103358 + .pos_op = PASS_POS_INSERT_AFTER
103359 + };
103360 +
103361 + if (!plugin_default_version_check(version, &gcc_version)) {
103362 + error(G_("incompatible gcc/plugin versions"));
103363 + return 1;
103364 + }
103365 +
103366 + for (i = 0; i < argc; ++i) {
103367 + if (!strcmp(argv[i].key, "no-size-overflow")) {
103368 + enable = false;
103369 + continue;
103370 + }
103371 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103372 + }
103373 +
103374 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
103375 + if (enable) {
103376 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
103377 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
103378 + }
103379 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103380 +
103381 + return 0;
103382 +}
103383 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
103384 new file mode 100644
103385 index 0000000..ac2901e
103386 --- /dev/null
103387 +++ b/tools/gcc/stackleak_plugin.c
103388 @@ -0,0 +1,327 @@
103389 +/*
103390 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
103391 + * Licensed under the GPL v2
103392 + *
103393 + * Note: the choice of the license means that the compilation process is
103394 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103395 + * but for the kernel it doesn't matter since it doesn't link against
103396 + * any of the gcc libraries
103397 + *
103398 + * gcc plugin to help implement various PaX features
103399 + *
103400 + * - track lowest stack pointer
103401 + *
103402 + * TODO:
103403 + * - initialize all local variables
103404 + *
103405 + * BUGS:
103406 + * - none known
103407 + */
103408 +#include "gcc-plugin.h"
103409 +#include "config.h"
103410 +#include "system.h"
103411 +#include "coretypes.h"
103412 +#include "tree.h"
103413 +#include "tree-pass.h"
103414 +#include "flags.h"
103415 +#include "intl.h"
103416 +#include "toplev.h"
103417 +#include "plugin.h"
103418 +//#include "expr.h" where are you...
103419 +#include "diagnostic.h"
103420 +#include "plugin-version.h"
103421 +#include "tm.h"
103422 +#include "function.h"
103423 +#include "basic-block.h"
103424 +#include "gimple.h"
103425 +#include "rtl.h"
103426 +#include "emit-rtl.h"
103427 +
103428 +#if BUILDING_GCC_VERSION >= 4008
103429 +#define TODO_dump_func 0
103430 +#endif
103431 +
103432 +extern void print_gimple_stmt(FILE *, gimple, int, int);
103433 +
103434 +int plugin_is_GPL_compatible;
103435 +
103436 +static int track_frame_size = -1;
103437 +static const char track_function[] = "pax_track_stack";
103438 +static const char check_function[] = "pax_check_alloca";
103439 +static bool init_locals;
103440 +
103441 +static struct plugin_info stackleak_plugin_info = {
103442 + .version = "201302112000",
103443 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
103444 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
103445 +};
103446 +
103447 +static bool gate_stackleak_track_stack(void);
103448 +static unsigned int execute_stackleak_tree_instrument(void);
103449 +static unsigned int execute_stackleak_final(void);
103450 +
103451 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
103452 + .pass = {
103453 + .type = GIMPLE_PASS,
103454 + .name = "stackleak_tree_instrument",
103455 +#if BUILDING_GCC_VERSION >= 4008
103456 + .optinfo_flags = OPTGROUP_NONE,
103457 +#endif
103458 + .gate = gate_stackleak_track_stack,
103459 + .execute = execute_stackleak_tree_instrument,
103460 + .sub = NULL,
103461 + .next = NULL,
103462 + .static_pass_number = 0,
103463 + .tv_id = TV_NONE,
103464 + .properties_required = PROP_gimple_leh | PROP_cfg,
103465 + .properties_provided = 0,
103466 + .properties_destroyed = 0,
103467 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
103468 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
103469 + }
103470 +};
103471 +
103472 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
103473 + .pass = {
103474 + .type = RTL_PASS,
103475 + .name = "stackleak_final",
103476 +#if BUILDING_GCC_VERSION >= 4008
103477 + .optinfo_flags = OPTGROUP_NONE,
103478 +#endif
103479 + .gate = gate_stackleak_track_stack,
103480 + .execute = execute_stackleak_final,
103481 + .sub = NULL,
103482 + .next = NULL,
103483 + .static_pass_number = 0,
103484 + .tv_id = TV_NONE,
103485 + .properties_required = 0,
103486 + .properties_provided = 0,
103487 + .properties_destroyed = 0,
103488 + .todo_flags_start = 0,
103489 + .todo_flags_finish = TODO_dump_func
103490 + }
103491 +};
103492 +
103493 +static bool gate_stackleak_track_stack(void)
103494 +{
103495 + return track_frame_size >= 0;
103496 +}
103497 +
103498 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
103499 +{
103500 + gimple check_alloca;
103501 + tree fntype, fndecl, alloca_size;
103502 +
103503 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
103504 + fndecl = build_fn_decl(check_function, fntype);
103505 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103506 +
103507 + // insert call to void pax_check_alloca(unsigned long size)
103508 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
103509 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
103510 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
103511 +}
103512 +
103513 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
103514 +{
103515 + gimple track_stack;
103516 + tree fntype, fndecl;
103517 +
103518 + fntype = build_function_type_list(void_type_node, NULL_TREE);
103519 + fndecl = build_fn_decl(track_function, fntype);
103520 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103521 +
103522 + // insert call to void pax_track_stack(void)
103523 + track_stack = gimple_build_call(fndecl, 0);
103524 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
103525 +}
103526 +
103527 +#if BUILDING_GCC_VERSION == 4005
103528 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
103529 +{
103530 + tree fndecl;
103531 +
103532 + if (!is_gimple_call(stmt))
103533 + return false;
103534 + fndecl = gimple_call_fndecl(stmt);
103535 + if (!fndecl)
103536 + return false;
103537 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
103538 + return false;
103539 +// print_node(stderr, "pax", fndecl, 4);
103540 + return DECL_FUNCTION_CODE(fndecl) == code;
103541 +}
103542 +#endif
103543 +
103544 +static bool is_alloca(gimple stmt)
103545 +{
103546 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
103547 + return true;
103548 +
103549 +#if BUILDING_GCC_VERSION >= 4007
103550 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
103551 + return true;
103552 +#endif
103553 +
103554 + return false;
103555 +}
103556 +
103557 +static unsigned int execute_stackleak_tree_instrument(void)
103558 +{
103559 + basic_block bb, entry_bb;
103560 + bool prologue_instrumented = false, is_leaf = true;
103561 +
103562 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
103563 +
103564 + // 1. loop through BBs and GIMPLE statements
103565 + FOR_EACH_BB(bb) {
103566 + gimple_stmt_iterator gsi;
103567 +
103568 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103569 + gimple stmt;
103570 +
103571 + stmt = gsi_stmt(gsi);
103572 +
103573 + if (is_gimple_call(stmt))
103574 + is_leaf = false;
103575 +
103576 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
103577 + if (!is_alloca(stmt))
103578 + continue;
103579 +
103580 + // 2. insert stack overflow check before each __builtin_alloca call
103581 + stackleak_check_alloca(&gsi);
103582 +
103583 + // 3. insert track call after each __builtin_alloca call
103584 + stackleak_add_instrumentation(&gsi);
103585 + if (bb == entry_bb)
103586 + prologue_instrumented = true;
103587 + }
103588 + }
103589 +
103590 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
103591 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
103592 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
103593 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
103594 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
103595 + return 0;
103596 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
103597 + return 0;
103598 +
103599 + // 4. insert track call at the beginning
103600 + if (!prologue_instrumented) {
103601 + gimple_stmt_iterator gsi;
103602 +
103603 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103604 + if (dom_info_available_p(CDI_DOMINATORS))
103605 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103606 + gsi = gsi_start_bb(bb);
103607 + stackleak_add_instrumentation(&gsi);
103608 + }
103609 +
103610 + return 0;
103611 +}
103612 +
103613 +static unsigned int execute_stackleak_final(void)
103614 +{
103615 + rtx insn, next;
103616 +
103617 + if (cfun->calls_alloca)
103618 + return 0;
103619 +
103620 + // keep calls only if function frame is big enough
103621 + if (get_frame_size() >= track_frame_size)
103622 + return 0;
103623 +
103624 + // 1. find pax_track_stack calls
103625 + for (insn = get_insns(); insn; insn = next) {
103626 + // 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))
103627 + rtx body;
103628 +
103629 + next = NEXT_INSN(insn);
103630 + if (!CALL_P(insn))
103631 + continue;
103632 + body = PATTERN(insn);
103633 + if (GET_CODE(body) != CALL)
103634 + continue;
103635 + body = XEXP(body, 0);
103636 + if (GET_CODE(body) != MEM)
103637 + continue;
103638 + body = XEXP(body, 0);
103639 + if (GET_CODE(body) != SYMBOL_REF)
103640 + continue;
103641 + if (strcmp(XSTR(body, 0), track_function))
103642 + continue;
103643 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103644 + // 2. delete call
103645 + delete_insn_and_edges(insn);
103646 +#if BUILDING_GCC_VERSION >= 4007
103647 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
103648 + insn = next;
103649 + next = NEXT_INSN(insn);
103650 + delete_insn_and_edges(insn);
103651 + }
103652 +#endif
103653 + }
103654 +
103655 +// print_simple_rtl(stderr, get_insns());
103656 +// print_rtl(stderr, get_insns());
103657 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103658 +
103659 + return 0;
103660 +}
103661 +
103662 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103663 +{
103664 + const char * const plugin_name = plugin_info->base_name;
103665 + const int argc = plugin_info->argc;
103666 + const struct plugin_argument * const argv = plugin_info->argv;
103667 + int i;
103668 + struct register_pass_info stackleak_tree_instrument_pass_info = {
103669 + .pass = &stackleak_tree_instrument_pass.pass,
103670 +// .reference_pass_name = "tree_profile",
103671 + .reference_pass_name = "optimized",
103672 + .ref_pass_instance_number = 1,
103673 + .pos_op = PASS_POS_INSERT_BEFORE
103674 + };
103675 + struct register_pass_info stackleak_final_pass_info = {
103676 + .pass = &stackleak_final_rtl_opt_pass.pass,
103677 + .reference_pass_name = "final",
103678 + .ref_pass_instance_number = 1,
103679 + .pos_op = PASS_POS_INSERT_BEFORE
103680 + };
103681 +
103682 + if (!plugin_default_version_check(version, &gcc_version)) {
103683 + error(G_("incompatible gcc/plugin versions"));
103684 + return 1;
103685 + }
103686 +
103687 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
103688 +
103689 + for (i = 0; i < argc; ++i) {
103690 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
103691 + if (!argv[i].value) {
103692 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103693 + continue;
103694 + }
103695 + track_frame_size = atoi(argv[i].value);
103696 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
103697 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103698 + continue;
103699 + }
103700 + if (!strcmp(argv[i].key, "initialize-locals")) {
103701 + if (argv[i].value) {
103702 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103703 + continue;
103704 + }
103705 + init_locals = true;
103706 + continue;
103707 + }
103708 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103709 + }
103710 +
103711 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
103712 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
103713 +
103714 + return 0;
103715 +}
103716 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
103717 new file mode 100644
103718 index 0000000..4fae911
103719 --- /dev/null
103720 +++ b/tools/gcc/structleak_plugin.c
103721 @@ -0,0 +1,277 @@
103722 +/*
103723 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
103724 + * Licensed under the GPL v2
103725 + *
103726 + * Note: the choice of the license means that the compilation process is
103727 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103728 + * but for the kernel it doesn't matter since it doesn't link against
103729 + * any of the gcc libraries
103730 + *
103731 + * gcc plugin to forcibly initialize certain local variables that could
103732 + * otherwise leak kernel stack to userland if they aren't properly initialized
103733 + * by later code
103734 + *
103735 + * Homepage: http://pax.grsecurity.net/
103736 + *
103737 + * Usage:
103738 + * $ # for 4.5/4.6/C based 4.7
103739 + * $ 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
103740 + * $ # for C++ based 4.7/4.8+
103741 + * $ 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
103742 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
103743 + *
103744 + * TODO: eliminate redundant initializers
103745 + * increase type coverage
103746 + */
103747 +
103748 +#include "gcc-plugin.h"
103749 +#include "config.h"
103750 +#include "system.h"
103751 +#include "coretypes.h"
103752 +#include "tree.h"
103753 +#include "tree-pass.h"
103754 +#include "intl.h"
103755 +#include "plugin-version.h"
103756 +#include "tm.h"
103757 +#include "toplev.h"
103758 +#include "function.h"
103759 +#include "tree-flow.h"
103760 +#include "plugin.h"
103761 +#include "gimple.h"
103762 +#include "diagnostic.h"
103763 +#include "cfgloop.h"
103764 +#include "langhooks.h"
103765 +
103766 +#if BUILDING_GCC_VERSION >= 4008
103767 +#define TODO_dump_func 0
103768 +#endif
103769 +
103770 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
103771 +
103772 +// unused type flag in all versions 4.5-4.8
103773 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
103774 +
103775 +int plugin_is_GPL_compatible;
103776 +void debug_gimple_stmt(gimple gs);
103777 +
103778 +static struct plugin_info structleak_plugin_info = {
103779 + .version = "201304082245",
103780 + .help = "disable\tdo not activate plugin\n",
103781 +};
103782 +
103783 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
103784 +{
103785 + *no_add_attrs = true;
103786 +
103787 + // check for types? for now accept everything linux has to offer
103788 + if (TREE_CODE(*node) != FIELD_DECL)
103789 + return NULL_TREE;
103790 +
103791 + *no_add_attrs = false;
103792 + return NULL_TREE;
103793 +}
103794 +
103795 +static struct attribute_spec user_attr = {
103796 + .name = "user",
103797 + .min_length = 0,
103798 + .max_length = 0,
103799 + .decl_required = false,
103800 + .type_required = false,
103801 + .function_type_required = false,
103802 + .handler = handle_user_attribute,
103803 +#if BUILDING_GCC_VERSION >= 4007
103804 + .affects_type_identity = true
103805 +#endif
103806 +};
103807 +
103808 +static void register_attributes(void *event_data, void *data)
103809 +{
103810 + register_attribute(&user_attr);
103811 +// register_attribute(&force_attr);
103812 +}
103813 +
103814 +static tree get_field_type(tree field)
103815 +{
103816 + return strip_array_types(TREE_TYPE(field));
103817 +}
103818 +
103819 +static bool is_userspace_type(tree type)
103820 +{
103821 + tree field;
103822 +
103823 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
103824 + tree fieldtype = get_field_type(field);
103825 + enum tree_code code = TREE_CODE(fieldtype);
103826 +
103827 + if (code == RECORD_TYPE || code == UNION_TYPE)
103828 + if (is_userspace_type(fieldtype))
103829 + return true;
103830 +
103831 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
103832 + return true;
103833 + }
103834 + return false;
103835 +}
103836 +
103837 +static void finish_type(void *event_data, void *data)
103838 +{
103839 + tree type = (tree)event_data;
103840 +
103841 + if (TYPE_USERSPACE(type))
103842 + return;
103843 +
103844 + if (is_userspace_type(type))
103845 + TYPE_USERSPACE(type) = 1;
103846 +}
103847 +
103848 +static void initialize(tree var)
103849 +{
103850 + basic_block bb;
103851 + gimple_stmt_iterator gsi;
103852 + tree initializer;
103853 + gimple init_stmt;
103854 +
103855 + // this is the original entry bb before the forced split
103856 + // TODO: check further BBs in case more splits occured before us
103857 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
103858 +
103859 + // first check if the variable is already initialized, warn otherwise
103860 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103861 + gimple stmt = gsi_stmt(gsi);
103862 + tree rhs1;
103863 +
103864 + // we're looking for an assignment of a single rhs...
103865 + if (!gimple_assign_single_p(stmt))
103866 + continue;
103867 + rhs1 = gimple_assign_rhs1(stmt);
103868 +#if BUILDING_GCC_VERSION >= 4007
103869 + // ... of a non-clobbering expression...
103870 + if (TREE_CLOBBER_P(rhs1))
103871 + continue;
103872 +#endif
103873 + // ... to our variable...
103874 + if (gimple_get_lhs(stmt) != var)
103875 + continue;
103876 + // if it's an initializer then we're good
103877 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
103878 + return;
103879 + }
103880 +
103881 + // these aren't the 0days you're looking for
103882 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
103883 +
103884 + // build the initializer expression
103885 + initializer = build_constructor(TREE_TYPE(var), NULL);
103886 +
103887 + // build the initializer stmt
103888 + init_stmt = gimple_build_assign(var, initializer);
103889 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
103890 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
103891 + update_stmt(init_stmt);
103892 +}
103893 +
103894 +static unsigned int handle_function(void)
103895 +{
103896 + basic_block bb;
103897 + unsigned int ret = 0;
103898 + tree var;
103899 +
103900 +#if BUILDING_GCC_VERSION == 4005
103901 + tree vars;
103902 +#else
103903 + unsigned int i;
103904 +#endif
103905 +
103906 + // split the first bb where we can put the forced initializers
103907 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103908 + if (dom_info_available_p(CDI_DOMINATORS))
103909 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103910 +
103911 + // enumarate all local variables and forcibly initialize our targets
103912 +#if BUILDING_GCC_VERSION == 4005
103913 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
103914 + var = TREE_VALUE(vars);
103915 +#else
103916 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
103917 +#endif
103918 + tree type = TREE_TYPE(var);
103919 +
103920 + gcc_assert(DECL_P(var));
103921 + if (!auto_var_in_fn_p(var, current_function_decl))
103922 + continue;
103923 +
103924 + // only care about structure types
103925 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
103926 + continue;
103927 +
103928 + // if the type is of interest, examine the variable
103929 + if (TYPE_USERSPACE(type))
103930 + initialize(var);
103931 + }
103932 +
103933 + return ret;
103934 +}
103935 +
103936 +static struct gimple_opt_pass structleak_pass = {
103937 + .pass = {
103938 + .type = GIMPLE_PASS,
103939 + .name = "structleak",
103940 +#if BUILDING_GCC_VERSION >= 4008
103941 + .optinfo_flags = OPTGROUP_NONE,
103942 +#endif
103943 + .gate = NULL,
103944 + .execute = handle_function,
103945 + .sub = NULL,
103946 + .next = NULL,
103947 + .static_pass_number = 0,
103948 + .tv_id = TV_NONE,
103949 + .properties_required = PROP_cfg,
103950 + .properties_provided = 0,
103951 + .properties_destroyed = 0,
103952 + .todo_flags_start = 0,
103953 + .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
103954 + }
103955 +};
103956 +
103957 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103958 +{
103959 + int i;
103960 + const char * const plugin_name = plugin_info->base_name;
103961 + const int argc = plugin_info->argc;
103962 + const struct plugin_argument * const argv = plugin_info->argv;
103963 + bool enable = true;
103964 +
103965 + struct register_pass_info structleak_pass_info = {
103966 + .pass = &structleak_pass.pass,
103967 + .reference_pass_name = "ssa",
103968 + .ref_pass_instance_number = 1,
103969 + .pos_op = PASS_POS_INSERT_AFTER
103970 + };
103971 +
103972 + if (!plugin_default_version_check(version, &gcc_version)) {
103973 + error(G_("incompatible gcc/plugin versions"));
103974 + return 1;
103975 + }
103976 +
103977 + if (strcmp(lang_hooks.name, "GNU C")) {
103978 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
103979 + enable = false;
103980 + }
103981 +
103982 + for (i = 0; i < argc; ++i) {
103983 + if (!strcmp(argv[i].key, "disable")) {
103984 + enable = false;
103985 + continue;
103986 + }
103987 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103988 + }
103989 +
103990 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
103991 + if (enable) {
103992 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
103993 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
103994 + }
103995 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103996 +
103997 + return 0;
103998 +}
103999 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
104000 index 6789d78..4afd019e 100644
104001 --- a/tools/perf/util/include/asm/alternative-asm.h
104002 +++ b/tools/perf/util/include/asm/alternative-asm.h
104003 @@ -5,4 +5,7 @@
104004
104005 #define altinstruction_entry #
104006
104007 + .macro pax_force_retaddr rip=0, reload=0
104008 + .endm
104009 +
104010 #endif
104011 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
104012 index 96b919d..c49bb74 100644
104013 --- a/tools/perf/util/include/linux/compiler.h
104014 +++ b/tools/perf/util/include/linux/compiler.h
104015 @@ -18,4 +18,12 @@
104016 #define __force
104017 #endif
104018
104019 +#ifndef __size_overflow
104020 +# define __size_overflow(...)
104021 +#endif
104022 +
104023 +#ifndef __intentional_overflow
104024 +# define __intentional_overflow(...)
104025 +#endif
104026 +
104027 #endif
104028 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
104029 index f18013f..90421df 100644
104030 --- a/virt/kvm/kvm_main.c
104031 +++ b/virt/kvm/kvm_main.c
104032 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
104033
104034 static cpumask_var_t cpus_hardware_enabled;
104035 static int kvm_usage_count = 0;
104036 -static atomic_t hardware_enable_failed;
104037 +static atomic_unchecked_t hardware_enable_failed;
104038
104039 struct kmem_cache *kvm_vcpu_cache;
104040 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
104041
104042 -static __read_mostly struct preempt_ops kvm_preempt_ops;
104043 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
104044 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
104045 +static struct preempt_ops kvm_preempt_ops = {
104046 + .sched_in = kvm_sched_in,
104047 + .sched_out = kvm_sched_out,
104048 +};
104049
104050 struct dentry *kvm_debugfs_dir;
104051
104052 @@ -769,7 +774,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
104053 /* We can read the guest memory with __xxx_user() later on. */
104054 if (user_alloc &&
104055 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
104056 - !access_ok(VERIFY_WRITE,
104057 + !__access_ok(VERIFY_WRITE,
104058 (void __user *)(unsigned long)mem->userspace_addr,
104059 mem->memory_size)))
104060 goto out;
104061 @@ -1881,7 +1886,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
104062 return 0;
104063 }
104064
104065 -static struct file_operations kvm_vcpu_fops = {
104066 +static file_operations_no_const kvm_vcpu_fops __read_only = {
104067 .release = kvm_vcpu_release,
104068 .unlocked_ioctl = kvm_vcpu_ioctl,
104069 #ifdef CONFIG_COMPAT
104070 @@ -2402,7 +2407,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
104071 return 0;
104072 }
104073
104074 -static struct file_operations kvm_vm_fops = {
104075 +static file_operations_no_const kvm_vm_fops __read_only = {
104076 .release = kvm_vm_release,
104077 .unlocked_ioctl = kvm_vm_ioctl,
104078 #ifdef CONFIG_COMPAT
104079 @@ -2500,7 +2505,7 @@ out:
104080 return r;
104081 }
104082
104083 -static struct file_operations kvm_chardev_ops = {
104084 +static file_operations_no_const kvm_chardev_ops __read_only = {
104085 .unlocked_ioctl = kvm_dev_ioctl,
104086 .compat_ioctl = kvm_dev_ioctl,
104087 .llseek = noop_llseek,
104088 @@ -2526,7 +2531,7 @@ static void hardware_enable_nolock(void *junk)
104089
104090 if (r) {
104091 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
104092 - atomic_inc(&hardware_enable_failed);
104093 + atomic_inc_unchecked(&hardware_enable_failed);
104094 printk(KERN_INFO "kvm: enabling virtualization on "
104095 "CPU%d failed\n", cpu);
104096 }
104097 @@ -2580,10 +2585,10 @@ static int hardware_enable_all(void)
104098
104099 kvm_usage_count++;
104100 if (kvm_usage_count == 1) {
104101 - atomic_set(&hardware_enable_failed, 0);
104102 + atomic_set_unchecked(&hardware_enable_failed, 0);
104103 on_each_cpu(hardware_enable_nolock, NULL, 1);
104104
104105 - if (atomic_read(&hardware_enable_failed)) {
104106 + if (atomic_read_unchecked(&hardware_enable_failed)) {
104107 hardware_disable_all_nolock();
104108 r = -EBUSY;
104109 }
104110 @@ -2941,7 +2946,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
104111 kvm_arch_vcpu_put(vcpu);
104112 }
104113
104114 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104115 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104116 struct module *module)
104117 {
104118 int r;
104119 @@ -2977,7 +2982,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104120 if (!vcpu_align)
104121 vcpu_align = __alignof__(struct kvm_vcpu);
104122 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
104123 - 0, NULL);
104124 + SLAB_USERCOPY, NULL);
104125 if (!kvm_vcpu_cache) {
104126 r = -ENOMEM;
104127 goto out_free_3;
104128 @@ -2987,9 +2992,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104129 if (r)
104130 goto out_free;
104131
104132 + pax_open_kernel();
104133 kvm_chardev_ops.owner = module;
104134 kvm_vm_fops.owner = module;
104135 kvm_vcpu_fops.owner = module;
104136 + pax_close_kernel();
104137
104138 r = misc_register(&kvm_dev);
104139 if (r) {
104140 @@ -2999,9 +3006,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104141
104142 register_syscore_ops(&kvm_syscore_ops);
104143
104144 - kvm_preempt_ops.sched_in = kvm_sched_in;
104145 - kvm_preempt_ops.sched_out = kvm_sched_out;
104146 -
104147 r = kvm_init_debug();
104148 if (r) {
104149 printk(KERN_ERR "kvm: create debugfs files failed\n");